From 352030015d32d7cde6456caaa1eb7a529bf482bc Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 28 Jul 2023 16:24:17 +0100 Subject: [PATCH 1/2] allowed proxies --- Cargo.lock | 20 ++++++++++---------- pallet-ismp/src/host.rs | 16 ++++++++++++---- pallet-ismp/src/lib.rs | 6 +++++- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5983683..f61055c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3144,7 +3144,7 @@ dependencies = [ [[package]] name = "ismp" version = "0.1.0" -source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#c72f00a984e0f53d842b0b378a7a9f19580042f9" +source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#59cac5c7e9961bc0884641339dea0244b859892b" dependencies = [ "derive_more", "parity-scale-codec", @@ -3374,7 +3374,7 @@ dependencies = [ [[package]] name = "ismp-testsuite" version = "0.1.0" -source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#c72f00a984e0f53d842b0b378a7a9f19580042f9" +source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#59cac5c7e9961bc0884641339dea0244b859892b" dependencies = [ "ismp", "parity-scale-codec", @@ -8026,18 +8026,18 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.176" +version = "1.0.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76dc28c9523c5d70816e393136b86d48909cfb27cecaa902d338c19ed47164dc" +checksum = "63ba2516aa6bf82e0b19ca8b50019d52df58455d3cf9bdaf6315225fdd0c560a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.176" +version = "1.0.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e7b8c5dc823e3b90651ff1d3808419cd14e5ad76de04feaf37da114e7a306f" +checksum = "401797fe7833d72109fedec6bfcbe67c0eed9b99772f26eb8afd261f0abc6fd3" dependencies = [ "proc-macro2", "quote", @@ -10329,9 +10329,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-ctl" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37706572f4b151dff7a0146e040804e9c26fe3a3118591112f05cf12a4216c1" +checksum = "619bfed27d807b54f7f776b9430d4f8060e66ee138a28632ca898584d462c31c" dependencies = [ "libc", "paste", @@ -10340,9 +10340,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", diff --git a/pallet-ismp/src/host.rs b/pallet-ismp/src/host.rs index 057d3ad..2cccd16 100644 --- a/pallet-ismp/src/host.rs +++ b/pallet-ismp/src/host.rs @@ -15,10 +15,10 @@ //! Host implementation for ISMP use crate::{ - dispatcher::Receipt, primitives::ConsensusClientProvider, ChallengePeriod, Config, - ConsensusClientUpdateTime, ConsensusStateClient, ConsensusStates, FrozenConsensusClients, - FrozenHeights, LatestStateMachineHeight, Nonce, RequestCommitments, RequestReceipts, - ResponseReceipts, StateCommitments, UnbondingPeriod, + dispatcher::Receipt, primitives::ConsensusClientProvider, AllowedProxies, ChallengePeriod, + Config, ConsensusClientUpdateTime, ConsensusStateClient, ConsensusStates, + FrozenConsensusClients, FrozenHeights, LatestStateMachineHeight, Nonce, RequestCommitments, + RequestReceipts, ResponseReceipts, StateCommitments, UnbondingPeriod, }; use alloc::{format, string::ToString}; use core::time::Duration; @@ -250,4 +250,12 @@ where ChallengePeriod::::insert(consensus_state_id, period); Ok(()) } + + fn allowed_proxies(&self) -> Vec { + AllowedProxies::::get() + } + + fn store_allowed_proxies(&self, allowed: Vec) { + AllowedProxies::::set(allowed); + } } diff --git a/pallet-ismp/src/lib.rs b/pallet-ismp/src/lib.rs index 41eccd6..c5279fe 100644 --- a/pallet-ismp/src/lib.rs +++ b/pallet-ismp/src/lib.rs @@ -122,7 +122,6 @@ pub mod pallet { /// Configurable router that dispatches calls to modules type IsmpRouter: IsmpRouter + Default; - /// Provides concrete implementations of consensus clients type ConsensusClientProvider: ConsensusClientProvider; @@ -205,6 +204,11 @@ pub mod pallet { pub type LatestStateMachineHeight = StorageMap<_, Blake2_128Concat, StateMachineId, u64, ValueQuery>; + /// Bounded vec of allowed proxies + #[pallet::storage] + #[pallet::getter(fn allowed_proxies)] + pub type AllowedProxies = StorageValue<_, Vec, ValueQuery>; + /// Holds the timestamp at which a consensus client was recently updated. /// Used in ensuring that the configured challenge period elapses. #[pallet::storage] From 2b9ce8c84c524d7ebc79d8878dd01a78d6304092 Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 28 Jul 2023 16:40:24 +0100 Subject: [PATCH 2/2] set config --- pallet-ismp/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pallet-ismp/src/lib.rs b/pallet-ismp/src/lib.rs index c5279fe..1d53336 100644 --- a/pallet-ismp/src/lib.rs +++ b/pallet-ismp/src/lib.rs @@ -369,6 +369,18 @@ pub mod pallet { Ok(()) } + + /// Set the allowed proxies + #[pallet::weight(::DbWeight::get().writes(1))] + #[pallet::call_index(3)] + pub fn set_config(origin: OriginFor, allowed: Vec) -> DispatchResult { + T::AdminOrigin::ensure_origin(origin)?; + + let host = Host::::default(); + host.store_allowed_proxies(allowed); + + Ok(()) + } } #[pallet::event]