From bea7812768dc579f55fe1d70f69312a47e3b5d46 Mon Sep 17 00:00:00 2001 From: Web3 Philosopher Date: Wed, 24 May 2023 12:49:09 +0100 Subject: [PATCH] fix state_trie_key (#45) * fix state_trie_key * fix testsuite --- ismp-testsuite/src/mocks.rs | 2 +- ismp/src/consensus.rs | 4 ++-- ismp/src/handlers/timeout.rs | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ismp-testsuite/src/mocks.rs b/ismp-testsuite/src/mocks.rs index 9fedd05e5..686809e60 100644 --- a/ismp-testsuite/src/mocks.rs +++ b/ismp-testsuite/src/mocks.rs @@ -54,7 +54,7 @@ impl ConsensusClient for MockClient { Ok(()) } - fn state_trie_key(&self, _request: RequestResponse) -> Vec> { + fn state_trie_key(&self, _request: Vec) -> Vec> { Default::default() } diff --git a/ismp/src/consensus.rs b/ismp/src/consensus.rs index 8d041056e..c19b917ef 100644 --- a/ismp/src/consensus.rs +++ b/ismp/src/consensus.rs @@ -20,7 +20,7 @@ use crate::{ host::{IsmpHost, StateMachine}, messaging::Proof, prelude::Vec, - router::RequestResponse, + router::{Request, RequestResponse}, }; use codec::{Decode, Encode}; use core::time::Duration; @@ -113,7 +113,7 @@ pub trait ConsensusClient { ) -> Result<(), Error>; /// Transform the requests/responses into their equivalent key in the state trie. - fn state_trie_key(&self, request: RequestResponse) -> Vec>; + fn state_trie_key(&self, request: Vec) -> Vec>; /// Verify the state of proof of some arbitrary data. Should return the verified data fn verify_state_proof( diff --git a/ismp/src/handlers/timeout.rs b/ismp/src/handlers/timeout.rs index f7d6118b3..553d683ae 100644 --- a/ismp/src/handlers/timeout.rs +++ b/ismp/src/handlers/timeout.rs @@ -20,7 +20,6 @@ use crate::{ handlers::{validate_state_machine, MessageResult}, host::IsmpHost, messaging::TimeoutMessage, - router::RequestResponse, util::hash_request, }; use alloc::vec::Vec; @@ -56,7 +55,7 @@ where } } - let key = consensus_client.state_trie_key(RequestResponse::Request(requests.clone())); + let key = consensus_client.state_trie_key(requests.clone()); let values = consensus_client.verify_state_proof(host, key, state, &timeout_proof)?;