diff --git a/network-rpc/api/src/lib.rs b/network-rpc/api/src/lib.rs index b4682f822a..d1b49ead18 100644 --- a/network-rpc/api/src/lib.rs +++ b/network-rpc/api/src/lib.rs @@ -14,7 +14,6 @@ use starcoin_accumulator::AccumulatorNode; use starcoin_crypto::HashValue; use starcoin_state_api::{StateWithProof, StateWithTableItemProof}; use starcoin_state_tree::StateNode; -use starcoin_types::access_path::AccessPath; use starcoin_types::account_address::AccountAddress; use starcoin_types::account_state::AccountState; use starcoin_types::block::{BlockHeader, BlockInfo, BlockNumber}; @@ -27,6 +26,7 @@ pub use network_p2p_core::RawRpcClient; pub use remote_chain_state::RemoteChainStateReader; pub use starcoin_types::block::BlockBody; +use starcoin_vm_types::state_store::state_key::StateKey; use starcoin_vm_types::state_store::table::TableHandle; pub const MAX_BLOCK_REQUEST_SIZE: u64 = 50; @@ -157,7 +157,7 @@ impl RpcRequest for GetTxnsWithHash { #[derive(Debug, Serialize, Deserialize, Clone)] pub struct GetStateWithProof { pub state_root: HashValue, - pub access_path: AccessPath, + pub state_key: StateKey, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/network-rpc/api/src/remote_chain_state.rs b/network-rpc/api/src/remote_chain_state.rs index 8a7571eae4..cec7ae7890 100644 --- a/network-rpc/api/src/remote_chain_state.rs +++ b/network-rpc/api/src/remote_chain_state.rs @@ -62,7 +62,7 @@ impl ChainStateReader for RemoteChainStateReader { .ok_or_else(|| anyhow!("state root not set"))?; let req = GetStateWithProof { state_root, - access_path: access_path.clone(), + state_key: state_key.clone(), }; let client = self.client.clone(); let state_proof: StateWithProof = diff --git a/network-rpc/src/rpc.rs b/network-rpc/src/rpc.rs index d295b29cdb..61496b2142 100644 --- a/network-rpc/src/rpc.rs +++ b/network-rpc/src/rpc.rs @@ -226,18 +226,15 @@ impl gen_server::NetworkRpc for NetworkRpcImpl { fn get_state_with_proof( &self, _peer_id: PeerId, - _req: GetStateWithProof, + req: GetStateWithProof, ) -> BoxFuture> { - // XXX FIXME YSG - /* let state_service = self.state_service.clone(); let fut = async move { state_service - .get_with_proof_by_root(req.access_path, req.state_root) + .get_with_proof_by_root(req.state_key, req.state_root) .await }; - Box::pin(fut) */ - unimplemented!("") + Box::pin(fut) } fn get_state_with_table_item_proof( diff --git a/network-rpc/src/tests.rs b/network-rpc/src/tests.rs index 7a6ceb1e8e..77a6a1885c 100644 --- a/network-rpc/src/tests.rs +++ b/network-rpc/src/tests.rs @@ -14,6 +14,7 @@ use starcoin_state_api::StateWithProof; use starcoin_types::{access_path, account_config::genesis_address, block::BlockHeader}; use starcoin_vm_types::access_path::DataPath; use starcoin_vm_types::on_chain_resource::Epoch; +use starcoin_vm_types::state_store::state_key::StateKey; use std::sync::Arc; #[stest::test] @@ -44,6 +45,8 @@ fn test_network_rpc() { DataPath::Resource(Epoch::struct_tag_for_epoch()), ); + let state_key = StateKey::resource(&genesis_address(), &Epoch::struct_tag_for_epoch()).unwrap(); + //ping ok let req = Ping { msg: "ping_test".to_string(), @@ -79,7 +82,7 @@ fn test_network_rpc() { let state_req = GetStateWithProof { state_root, - access_path: access_path.clone(), + state_key, }; let state_with_proof: StateWithProof = block_on(async { client