From cb76d72cc1172fd433c8e465f7f51c11815fa938 Mon Sep 17 00:00:00 2001 From: David Salami Date: Thu, 14 Sep 2023 11:15:23 +0100 Subject: [PATCH 1/3] some updates --- .gitmodules | 3 --- ismp-demo/src/lib.rs | 20 +++++++++++++++----- pallet-ismp/rpc/src/lib.rs | 13 ------------- pallet-ismp/runtime-api/src/lib.rs | 3 --- 4 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 26647ca..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "ismp-solidity"] - path = pallet-ismp/evm/solidity/lib/ismp-solidity - url = https://github.com/polytope-labs/ismp-solidity.git diff --git a/ismp-demo/src/lib.rs b/ismp-demo/src/lib.rs index ebd3e3e..b2f0fac 100644 --- a/ismp-demo/src/lib.rs +++ b/ismp-demo/src/lib.rs @@ -206,9 +206,8 @@ pub mod pallet { /// Dispatch request to a connected EVM chain. #[pallet::weight(Weight::from_parts(1_000_000, 0))] #[pallet::call_index(2)] - pub fn disptach_to_evm(origin: OriginFor, params: EvmParams) -> DispatchResult { + pub fn dispatch_to_evm(origin: OriginFor, params: EvmParams) -> DispatchResult { ensure_signed(origin)?; - let post = DispatchPost { dest: StateMachine::Ethereum(params.destination), from: PALLET_ID.to_bytes(), @@ -217,13 +216,21 @@ pub mod pallet { data: b"Hello from polkadot".to_vec(), gas_limit: 10_000_000, }; - - // dispatch the request let dispatcher = T::IsmpDispatcher::default(); + // dispatch multiple requests to other ethereum execution layers + for _ in 0..params.count { + // dispatch the request + let mut post = post.clone(); + post.dest = StateMachine::Ethereum(Ethereum::Arbitrum); + + dispatcher + .dispatch_request(DispatchRequest::Post(post)) + .map_err(|_| Error::::TransferFailed)?; + } + dispatcher .dispatch_request(DispatchRequest::Post(post)) .map_err(|_| Error::::TransferFailed)?; - Ok(()) } } @@ -288,6 +295,9 @@ pub mod pallet { /// Timeout timestamp on destination chain in seconds pub timeout: u64, + + /// Request count + pub count: u64, } } diff --git a/pallet-ismp/rpc/src/lib.rs b/pallet-ismp/rpc/src/lib.rs index baa676e..3e82da8 100644 --- a/pallet-ismp/rpc/src/lib.rs +++ b/pallet-ismp/rpc/src/lib.rs @@ -122,10 +122,6 @@ where #[method(name = "ismp_queryChallengePeriod")] fn query_challenge_period(&self, client_id: ConsensusClientId) -> Result; - /// Query the latest timestamp for chain - #[method(name = "ismp_queryTimestamp")] - fn query_timestamp(&self) -> Result; - /// Query the latest height for a state machine #[method(name = "ismp_queryStateMachineLatestHeight")] fn query_state_machine_latest_height(&self, id: StateMachineId) -> Result; @@ -273,15 +269,6 @@ where .ok_or_else(|| runtime_error_into_rpc_error("Error fetching Challenge period")) } - fn query_timestamp(&self) -> Result { - let api = self.client.runtime_api(); - let at = self.client.info().best_hash; - api.timestamp(at) - .ok() - .flatten() - .ok_or_else(|| runtime_error_into_rpc_error("Error fetching latest timestamp")) - } - fn query_state_machine_latest_height(&self, id: StateMachineId) -> Result { let api = self.client.runtime_api(); let at = self.client.info().best_hash; diff --git a/pallet-ismp/runtime-api/src/lib.rs b/pallet-ismp/runtime-api/src/lib.rs index b558bd3..a8364c5 100644 --- a/pallet-ismp/runtime-api/src/lib.rs +++ b/pallet-ismp/runtime-api/src/lib.rs @@ -54,9 +54,6 @@ sp_api::decl_runtime_apis! { /// Return the timestamp this client was last updated in seconds fn consensus_update_time(id: ConsensusClientId) -> Option; - /// Return the latest timestamp for the chain - fn timestamp() -> Option; - /// Return the challenge period timestamp fn challenge_period(id: ConsensusClientId) -> Option; From 773cc12bfc4c6b965328bfe7a73f5f5f4c346739 Mon Sep 17 00:00:00 2001 From: David Salami Date: Thu, 14 Sep 2023 20:03:31 +0100 Subject: [PATCH 2/3] ismp-update --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2e70b1..38bea38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "ismp" version = "0.1.0" -source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#3a85db0d968eab5a88427a19a2a612332caec23f" +source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#5c4e0f412de788b5d86de8146b49f6db6795ca12" dependencies = [ "derive_more", "parity-scale-codec", @@ -1706,7 +1706,7 @@ dependencies = [ [[package]] name = "ismp-testsuite" version = "0.1.0" -source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#3a85db0d968eab5a88427a19a2a612332caec23f" +source = "git+https://github.com/polytope-labs/ismp-rs?branch=main#5c4e0f412de788b5d86de8146b49f6db6795ca12" dependencies = [ "ismp", "parity-scale-codec", From 25663561c112d8b3f122c0d8746d8276b1e211bf Mon Sep 17 00:00:00 2001 From: David Salami Date: Fri, 15 Sep 2023 10:31:05 +0100 Subject: [PATCH 3/3] minor change --- ismp-demo/src/lib.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ismp-demo/src/lib.rs b/ismp-demo/src/lib.rs index b2f0fac..82da701 100644 --- a/ismp-demo/src/lib.rs +++ b/ismp-demo/src/lib.rs @@ -217,20 +217,12 @@ pub mod pallet { gas_limit: 10_000_000, }; let dispatcher = T::IsmpDispatcher::default(); - // dispatch multiple requests to other ethereum execution layers for _ in 0..params.count { // dispatch the request - let mut post = post.clone(); - post.dest = StateMachine::Ethereum(Ethereum::Arbitrum); - dispatcher - .dispatch_request(DispatchRequest::Post(post)) + .dispatch_request(DispatchRequest::Post(post.clone())) .map_err(|_| Error::::TransferFailed)?; } - - dispatcher - .dispatch_request(DispatchRequest::Post(post)) - .map_err(|_| Error::::TransferFailed)?; Ok(()) } }