From c90e94ae9149972f24e95797bd284c54b4257879 Mon Sep 17 00:00:00 2001 From: driftluo Date: Tue, 29 Aug 2023 14:01:42 +0800 Subject: [PATCH] feat: hardfork storage --- core/api/src/adapter.rs | 8 +- core/api/src/jsonrpc/impl/axon.rs | 11 +- core/api/src/jsonrpc/mod.rs | 5 +- core/executor/benches/bench_transfer.rs | 1 + core/executor/benches/mock.rs | 1 + core/executor/src/debugger/mod.rs | 1 + .../abi/ckb_light_client_abi.rs | 107 +++++----- .../image_cell/abi/image_cell_abi.rs | 129 ++++++------ .../metadata/abi/metadata_abi.rs | 198 +++++++++--------- .../src/system_contract/metadata/handle.rs | 6 +- .../src/system_contract/metadata/mod.rs | 28 ++- .../src/system_contract/metadata/store.rs | 59 +++++- protocol/src/traits/api.rs | 6 +- protocol/src/types/executor.rs | 4 + protocol/src/types/primitive.rs | 31 +++ 15 files changed, 355 insertions(+), 240 deletions(-) diff --git a/core/api/src/adapter.rs b/core/api/src/adapter.rs index 045b8abe3..7f437c4e7 100644 --- a/core/api/src/adapter.rs +++ b/core/api/src/adapter.rs @@ -5,8 +5,8 @@ use protocol::traits::{ }; use protocol::trie::Trie as _; use protocol::types::{ - Account, BigEndianHash, Block, BlockNumber, Bytes, CkbRelatedInfo, ExecutorContext, Hash, - Header, Metadata, Proposal, Receipt, SignedTransaction, TxResp, H160, H256, + Account, BigEndianHash, Block, BlockNumber, Bytes, CkbRelatedInfo, ExecutorContext, + HardforkInfo, Hash, Header, Metadata, Proposal, Receipt, SignedTransaction, TxResp, H160, H256, MAX_BLOCK_GAS_LIMIT, NIL_DATA, RLP_NULL, U256, }; use protocol::{async_trait, codec::ProtocolCodec, trie, ProtocolResult}; @@ -281,4 +281,8 @@ where )? .get_metadata_root()) } + + async fn hardfork_info(&self, ctx: Context) -> ProtocolResult { + MetadataHandle::new(self.get_metadata_root(ctx).await?).hardfork_infos() + } } diff --git a/core/api/src/jsonrpc/impl/axon.rs b/core/api/src/jsonrpc/impl/axon.rs index 7cc1faf5e..2669dabed 100644 --- a/core/api/src/jsonrpc/impl/axon.rs +++ b/core/api/src/jsonrpc/impl/axon.rs @@ -4,7 +4,7 @@ use jsonrpsee::core::Error; use protocol::async_trait; use protocol::traits::{APIAdapter, Context}; -use protocol::types::{Block, CkbRelatedInfo, Metadata, Proof, Proposal, U256}; +use protocol::types::{Block, CkbRelatedInfo, HardforkInfo, Metadata, Proof, Proposal, U256}; use crate::jsonrpc::web3_types::BlockId; use crate::jsonrpc::{AxonRpcServer, RpcResult}; @@ -96,4 +96,13 @@ impl AxonRpcServer for AxonRpcImpl { Ok(ret) } + + async fn hardfork_info(&self) -> RpcResult { + let ret = self + .adapter + .hardfork_info(Context::new()) + .await + .map_err(|e| Error::Custom(e.to_string()))?; + Ok(ret) + } } diff --git a/core/api/src/jsonrpc/mod.rs b/core/api/src/jsonrpc/mod.rs index f10a83b9e..853109228 100644 --- a/core/api/src/jsonrpc/mod.rs +++ b/core/api/src/jsonrpc/mod.rs @@ -12,7 +12,7 @@ use jsonrpsee::{core::Error, proc_macros::rpc}; use common_config_parser::types::Config; use protocol::traits::APIAdapter; use protocol::types::{ - Block, CkbRelatedInfo, Hash, Hex, Metadata, Proof, Proposal, H160, H256, U256, + Block, CkbRelatedInfo, HardforkInfo, Hash, Hex, Metadata, Proof, Proposal, H160, H256, U256, }; use protocol::ProtocolResult; @@ -225,6 +225,9 @@ pub trait AxonRpc { #[method(name = "axon_getCkbRelatedInfo")] async fn get_ckb_related_info(&self) -> RpcResult; + + #[method(name = "axon_getHardforkInfo")] + async fn hardfork_info(&self) -> RpcResult; } #[rpc(server)] diff --git a/core/executor/benches/bench_transfer.rs b/core/executor/benches/bench_transfer.rs index 39bb5e019..0e92819f1 100644 --- a/core/executor/benches/bench_transfer.rs +++ b/core/executor/benches/bench_transfer.rs @@ -75,6 +75,7 @@ impl BenchAdapter { gas_price: 85u64.into(), block_gas_limit: 100_000_000_000u64.into(), block_base_fee_per_gas: Default::default(), + extra_data: Default::default(), }, ) .unwrap() diff --git a/core/executor/benches/mock.rs b/core/executor/benches/mock.rs index acb4d4e0b..55eb25ae9 100644 --- a/core/executor/benches/mock.rs +++ b/core/executor/benches/mock.rs @@ -54,6 +54,7 @@ pub fn mock_executor_context() -> ExecutorContext { gas_price: 85u64.into(), block_gas_limit: 100_000_000_000u64.into(), block_base_fee_per_gas: Default::default(), + extra_data: Default::default(), } } diff --git a/core/executor/src/debugger/mod.rs b/core/executor/src/debugger/mod.rs index 2be9255df..b1525496c 100644 --- a/core/executor/src/debugger/mod.rs +++ b/core/executor/src/debugger/mod.rs @@ -113,6 +113,7 @@ impl EvmDebugger { gas_price: 1u64.into(), block_gas_limit: 4294967295000u64.into(), block_base_fee_per_gas: 1337u64.into(), + extra_data: Default::default(), }; AxonExecutorApplyAdapter::from_root( diff --git a/core/executor/src/system_contract/ckb_light_client/abi/ckb_light_client_abi.rs b/core/executor/src/system_contract/ckb_light_client/abi/ckb_light_client_abi.rs index ed5af9575..761ca3e1c 100644 --- a/core/executor/src/system_contract/ckb_light_client/abi/ckb_light_client_abi.rs +++ b/core/executor/src/system_contract/ckb_light_client/abi/ckb_light_client_abi.rs @@ -7,16 +7,18 @@ pub use ckb_light_client_contract::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod ckb_light_client_contract { #[rustfmt::skip] const __ABI: &str = "[\n {\n \"inputs\": [\n {\n \"internalType\": \"bytes32[]\",\n \"name\": \"blockHashes\",\n \"type\": \"bytes32[]\"\n }\n ],\n \"name\": \"rollback\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"allowRead\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setState\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"components\": [\n {\n \"internalType\": \"uint32\",\n \"name\": \"version\",\n \"type\": \"uint32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"compactTarget\",\n \"type\": \"uint32\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"timestamp\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"number\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"uint64\",\n \"name\": \"epoch\",\n \"type\": \"uint64\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"parentHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"transactionsRoot\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"proposalsHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"extraHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"dao\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint128\",\n \"name\": \"nonce\",\n \"type\": \"uint128\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"extension\",\n \"type\": \"bytes\"\n },\n {\n \"internalType\": \"bytes32\",\n \"name\": \"blockHash\",\n \"type\": \"bytes32\"\n }\n ],\n \"internalType\": \"struct CkbType.Header[]\",\n \"name\": \"headers\",\n \"type\": \"tuple[]\"\n }\n ],\n \"name\": \"update\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n"; - /// The parsed JSON ABI of the contract. - pub static CKBLIGHTCLIENTCONTRACT_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + ///The parsed JSON ABI of the contract. + pub static CKBLIGHTCLIENTCONTRACT_ABI: ::ethers::contract::Lazy< + ::ethers::core::abi::Abi, + > = ::ethers::contract::Lazy::new(|| { + ::ethers::core::utils::__serde_json::from_str(__ABI) + .expect("ABI is always valid") + }); pub struct CkbLightClientContract(::ethers::contract::Contract); impl ::core::clone::Clone for CkbLightClientContract { fn clone(&self) -> Self { @@ -25,7 +27,6 @@ pub mod ckb_light_client_contract { } impl ::core::ops::Deref for CkbLightClientContract { type Target = ::ethers::contract::Contract; - fn deref(&self) -> &Self::Target { &self.0 } @@ -43,21 +44,21 @@ pub mod ckb_light_client_contract { } } impl CkbLightClientContract { - /// Creates a new contract instance with the specified `ethers` client - /// at `address`. The contract derefs to a `ethers::Contract` - /// object. + /// Creates a new contract instance with the specified `ethers` client at + /// `address`. The contract derefs to a `ethers::Contract` object. pub fn new>( address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - CKBLIGHTCLIENTCONTRACT_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + CKBLIGHTCLIENTCONTRACT_ABI.clone(), + client, + ), + ) } - - /// Calls the contract's `rollback` (0xd32a2285) function + ///Calls the contract's `rollback` (0xd32a2285) function pub fn rollback( &self, block_hashes: ::std::vec::Vec<[u8; 32]>, @@ -66,8 +67,7 @@ pub mod ckb_light_client_contract { .method_hash([211, 42, 34, 133], block_hashes) .expect("method not found (this should never happen)") } - - /// Calls the contract's `setState` (0xac9f0222) function + ///Calls the contract's `setState` (0xac9f0222) function pub fn set_state( &self, allow_read: bool, @@ -76,8 +76,7 @@ pub mod ckb_light_client_contract { .method_hash([172, 159, 2, 34], allow_read) .expect("method not found (this should never happen)") } - - /// Calls the contract's `update` (0x5d4e8442) function + ///Calls the contract's `update` (0x5d4e8442) function pub fn update( &self, headers: ::std::vec::Vec
, @@ -88,14 +87,12 @@ pub mod ckb_light_client_contract { } } impl From<::ethers::contract::Contract> - for CkbLightClientContract - { + for CkbLightClientContract { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } } - /// Container type for all input parameters for the `rollback` function with - /// signature `rollback(bytes32[])` and selector `0xd32a2285` + ///Container type for all input parameters for the `rollback` function with signature `rollback(bytes32[])` and selector `0xd32a2285` #[derive( Clone, ::ethers::contract::EthCall, @@ -104,14 +101,13 @@ pub mod ckb_light_client_contract { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall(name = "rollback", abi = "rollback(bytes32[])")] pub struct RollbackCall { pub block_hashes: ::std::vec::Vec<[u8; 32]>, } - /// Container type for all input parameters for the `setState` function with - /// signature `setState(bool)` and selector `0xac9f0222` + ///Container type for all input parameters for the `setState` function with signature `setState(bool)` and selector `0xac9f0222` #[derive( Clone, ::ethers::contract::EthCall, @@ -120,16 +116,13 @@ pub mod ckb_light_client_contract { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall(name = "setState", abi = "setState(bool)")] pub struct SetStateCall { pub allow_read: bool, } - /// Container type for all input parameters for the `update` function with - /// signature `update((uint32,uint32,uint64,uint64,uint64,bytes32,bytes32, - /// bytes32,bytes32,bytes32,uint128,bytes,bytes32)[])` and selector - /// `0x5d4e8442` + ///Container type for all input parameters for the `update` function with signature `update((uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes,bytes32)[])` and selector `0x5d4e8442` #[derive(Clone, ::ethers::contract::EthCall, ::ethers::contract::EthDisplay)] #[ethcall( name = "update", @@ -138,7 +131,7 @@ pub mod ckb_light_client_contract { pub struct UpdateCall { pub headers: ::std::vec::Vec
, } - /// Container type for all of the contract's call + ///Container type for all of the contract's call #[derive(Clone, ::ethers::contract::EthAbiType)] pub enum CkbLightClientContractCalls { Rollback(RollbackCall), @@ -150,13 +143,16 @@ pub mod ckb_light_client_contract { data: impl AsRef<[u8]>, ) -> ::core::result::Result { let data = data.as_ref(); - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::Rollback(decoded)); } - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::SetState(decoded)); } - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::Update(decoded)); } Err(::ethers::core::abi::Error::InvalidData.into()) @@ -165,8 +161,12 @@ pub mod ckb_light_client_contract { impl ::ethers::core::abi::AbiEncode for CkbLightClientContractCalls { fn encode(self) -> Vec { match self { - Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element), - Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Rollback(element) => { + ::ethers::core::abi::AbiEncode::encode(element) + } + Self::SetState(element) => { + ::ethers::core::abi::AbiEncode::encode(element) + } Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element), } } @@ -195,8 +195,7 @@ pub mod ckb_light_client_contract { Self::Update(value) } } - /// `Header(uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32, - /// bytes32,bytes32,uint128,bytes,bytes32)` + ///`Header(uint32,uint32,uint64,uint64,uint64,bytes32,bytes32,bytes32,bytes32,bytes32,uint128,bytes,bytes32)` #[derive( Clone, ::ethers::contract::EthAbiType, @@ -205,21 +204,21 @@ pub mod ckb_light_client_contract { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct Header { - pub version: u32, - pub compact_target: u32, - pub timestamp: u64, - pub number: u64, - pub epoch: u64, - pub parent_hash: [u8; 32], + pub version: u32, + pub compact_target: u32, + pub timestamp: u64, + pub number: u64, + pub epoch: u64, + pub parent_hash: [u8; 32], pub transactions_root: [u8; 32], - pub proposals_hash: [u8; 32], - pub extra_hash: [u8; 32], - pub dao: [u8; 32], - pub nonce: u128, - pub extension: ::ethers::core::types::Bytes, - pub block_hash: [u8; 32], + pub proposals_hash: [u8; 32], + pub extra_hash: [u8; 32], + pub dao: [u8; 32], + pub nonce: u128, + pub extension: ::ethers::core::types::Bytes, + pub block_hash: [u8; 32], } } diff --git a/core/executor/src/system_contract/image_cell/abi/image_cell_abi.rs b/core/executor/src/system_contract/image_cell/abi/image_cell_abi.rs index 7ea73910a..de4274ed6 100644 --- a/core/executor/src/system_contract/image_cell/abi/image_cell_abi.rs +++ b/core/executor/src/system_contract/image_cell/abi/image_cell_abi.rs @@ -7,16 +7,18 @@ pub use image_cell_contract::*; clippy::upper_case_acronyms, clippy::type_complexity, dead_code, - non_camel_case_types + non_camel_case_types, )] pub mod image_cell_contract { #[rustfmt::skip] const __ABI: &str = "[\n {\n \"inputs\": [\n {\n \"components\": [\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"txHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"index\",\n \"type\": \"uint32\"\n }\n ],\n \"internalType\": \"struct CkbType.OutPoint[]\",\n \"name\": \"txInputs\",\n \"type\": \"tuple[]\"\n },\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"txHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"index\",\n \"type\": \"uint32\"\n }\n ],\n \"internalType\": \"struct CkbType.OutPoint[]\",\n \"name\": \"txOutputs\",\n \"type\": \"tuple[]\"\n }\n ],\n \"internalType\": \"struct ImageCell.BlockRollBlack[]\",\n \"name\": \"blocks\",\n \"type\": \"tuple[]\"\n }\n ],\n \"name\": \"rollback\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"internalType\": \"bool\",\n \"name\": \"allowRead\",\n \"type\": \"bool\"\n }\n ],\n \"name\": \"setState\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"inputs\": [\n {\n \"components\": [\n {\n \"internalType\": \"uint64\",\n \"name\": \"blockNumber\",\n \"type\": \"uint64\"\n },\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"txHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"index\",\n \"type\": \"uint32\"\n }\n ],\n \"internalType\": \"struct CkbType.OutPoint[]\",\n \"name\": \"txInputs\",\n \"type\": \"tuple[]\"\n },\n {\n \"components\": [\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"txHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"uint32\",\n \"name\": \"index\",\n \"type\": \"uint32\"\n }\n ],\n \"internalType\": \"struct CkbType.OutPoint\",\n \"name\": \"outPoint\",\n \"type\": \"tuple\"\n },\n {\n \"components\": [\n {\n \"internalType\": \"uint64\",\n \"name\": \"capacity\",\n \"type\": \"uint64\"\n },\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"codeHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"enum CkbType.ScriptHashType\",\n \"name\": \"hashType\",\n \"type\": \"uint8\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"args\",\n \"type\": \"bytes\"\n }\n ],\n \"internalType\": \"struct CkbType.Script\",\n \"name\": \"lock\",\n \"type\": \"tuple\"\n },\n {\n \"components\": [\n {\n \"internalType\": \"bytes32\",\n \"name\": \"codeHash\",\n \"type\": \"bytes32\"\n },\n {\n \"internalType\": \"enum CkbType.ScriptHashType\",\n \"name\": \"hashType\",\n \"type\": \"uint8\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"args\",\n \"type\": \"bytes\"\n }\n ],\n \"internalType\": \"struct CkbType.Script[]\",\n \"name\": \"type_\",\n \"type\": \"tuple[]\"\n }\n ],\n \"internalType\": \"struct CkbType.CellOutput\",\n \"name\": \"output\",\n \"type\": \"tuple\"\n },\n {\n \"internalType\": \"bytes\",\n \"name\": \"data\",\n \"type\": \"bytes\"\n }\n ],\n \"internalType\": \"struct CkbType.CellInfo[]\",\n \"name\": \"txOutputs\",\n \"type\": \"tuple[]\"\n }\n ],\n \"internalType\": \"struct ImageCell.BlockUpdate[]\",\n \"name\": \"blocks\",\n \"type\": \"tuple[]\"\n }\n ],\n \"name\": \"update\",\n \"outputs\": [],\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n }\n]\n"; - /// The parsed JSON ABI of the contract. - pub static IMAGECELLCONTRACT_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = - ::ethers::contract::Lazy::new(|| { - ::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid") - }); + ///The parsed JSON ABI of the contract. + pub static IMAGECELLCONTRACT_ABI: ::ethers::contract::Lazy< + ::ethers::core::abi::Abi, + > = ::ethers::contract::Lazy::new(|| { + ::ethers::core::utils::__serde_json::from_str(__ABI) + .expect("ABI is always valid") + }); pub struct ImageCellContract(::ethers::contract::Contract); impl ::core::clone::Clone for ImageCellContract { fn clone(&self) -> Self { @@ -25,7 +27,6 @@ pub mod image_cell_contract { } impl ::core::ops::Deref for ImageCellContract { type Target = ::ethers::contract::Contract; - fn deref(&self) -> &Self::Target { &self.0 } @@ -37,27 +38,25 @@ pub mod image_cell_contract { } impl ::core::fmt::Debug for ImageCellContract { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple(stringify!(ImageCellContract)) - .field(&self.address()) - .finish() + f.debug_tuple(stringify!(ImageCellContract)).field(&self.address()).finish() } } impl ImageCellContract { - /// Creates a new contract instance with the specified `ethers` client - /// at `address`. The contract derefs to a `ethers::Contract` - /// object. + /// Creates a new contract instance with the specified `ethers` client at + /// `address`. The contract derefs to a `ethers::Contract` object. pub fn new>( address: T, client: ::std::sync::Arc, ) -> Self { - Self(::ethers::contract::Contract::new( - address.into(), - IMAGECELLCONTRACT_ABI.clone(), - client, - )) + Self( + ::ethers::contract::Contract::new( + address.into(), + IMAGECELLCONTRACT_ABI.clone(), + client, + ), + ) } - - /// Calls the contract's `rollback` (0x08c17228) function + ///Calls the contract's `rollback` (0x08c17228) function pub fn rollback( &self, blocks: ::std::vec::Vec, @@ -66,8 +65,7 @@ pub mod image_cell_contract { .method_hash([8, 193, 114, 40], blocks) .expect("method not found (this should never happen)") } - - /// Calls the contract's `setState` (0xac9f0222) function + ///Calls the contract's `setState` (0xac9f0222) function pub fn set_state( &self, allow_read: bool, @@ -76,8 +74,7 @@ pub mod image_cell_contract { .method_hash([172, 159, 2, 34], allow_read) .expect("method not found (this should never happen)") } - - /// Calls the contract's `update` (0xafa74e04) function + ///Calls the contract's `update` (0xafa74e04) function pub fn update( &self, blocks: ::std::vec::Vec, @@ -88,15 +85,12 @@ pub mod image_cell_contract { } } impl From<::ethers::contract::Contract> - for ImageCellContract - { + for ImageCellContract { fn from(contract: ::ethers::contract::Contract) -> Self { Self::new(contract.address(), contract.client()) } } - /// Container type for all input parameters for the `rollback` function with - /// signature `rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])` and - /// selector `0x08c17228` + ///Container type for all input parameters for the `rollback` function with signature `rollback(((bytes32,uint32)[],(bytes32,uint32)[])[])` and selector `0x08c17228` #[derive( Clone, ::ethers::contract::EthCall, @@ -105,7 +99,7 @@ pub mod image_cell_contract { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall( name = "rollback", @@ -114,8 +108,7 @@ pub mod image_cell_contract { pub struct RollbackCall { pub blocks: ::std::vec::Vec, } - /// Container type for all input parameters for the `setState` function with - /// signature `setState(bool)` and selector `0xac9f0222` + ///Container type for all input parameters for the `setState` function with signature `setState(bool)` and selector `0xac9f0222` #[derive( Clone, ::ethers::contract::EthCall, @@ -124,16 +117,13 @@ pub mod image_cell_contract { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall(name = "setState", abi = "setState(bool)")] pub struct SetStateCall { pub allow_read: bool, } - /// Container type for all input parameters for the `update` function with - /// signature `update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64, - /// (bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])` and - /// selector `0xafa74e04` + ///Container type for all input parameters for the `update` function with signature `update((uint64,(bytes32,uint32)[],((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)[])[])` and selector `0xafa74e04` #[derive( Clone, ::ethers::contract::EthCall, @@ -142,7 +132,7 @@ pub mod image_cell_contract { Debug, PartialEq, Eq, - Hash, + Hash )] #[ethcall( name = "update", @@ -151,7 +141,7 @@ pub mod image_cell_contract { pub struct UpdateCall { pub blocks: ::std::vec::Vec, } - /// Container type for all of the contract's call + ///Container type for all of the contract's call #[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)] pub enum ImageCellContractCalls { Rollback(RollbackCall), @@ -163,13 +153,16 @@ pub mod image_cell_contract { data: impl AsRef<[u8]>, ) -> ::core::result::Result { let data = data.as_ref(); - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::Rollback(decoded)); } - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::SetState(decoded)); } - if let Ok(decoded) = ::decode(data) { + if let Ok(decoded) + = ::decode(data) { return Ok(Self::Update(decoded)); } Err(::ethers::core::abi::Error::InvalidData.into()) @@ -178,8 +171,12 @@ pub mod image_cell_contract { impl ::ethers::core::abi::AbiEncode for ImageCellContractCalls { fn encode(self) -> Vec { match self { - Self::Rollback(element) => ::ethers::core::abi::AbiEncode::encode(element), - Self::SetState(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Rollback(element) => { + ::ethers::core::abi::AbiEncode::encode(element) + } + Self::SetState(element) => { + ::ethers::core::abi::AbiEncode::encode(element) + } Self::Update(element) => ::ethers::core::abi::AbiEncode::encode(element), } } @@ -208,8 +205,7 @@ pub mod image_cell_contract { Self::Update(value) } } - /// `CellInfo((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8, - /// bytes)[]),bytes)` + ///`CellInfo((bytes32,uint32),(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[]),bytes)` #[derive( Clone, ::ethers::contract::EthAbiType, @@ -218,14 +214,14 @@ pub mod image_cell_contract { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct CellInfo { pub out_point: OutPoint, - pub output: CellOutput, - pub data: ::ethers::core::types::Bytes, + pub output: CellOutput, + pub data: ::ethers::core::types::Bytes, } - /// `CellOutput(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[])` + ///`CellOutput(uint64,(bytes32,uint8,bytes),(bytes32,uint8,bytes)[])` #[derive( Clone, ::ethers::contract::EthAbiType, @@ -234,14 +230,14 @@ pub mod image_cell_contract { Debug, PartialEq, Eq, - Hash, + Hash )] pub struct CellOutput { pub capacity: u64, - pub lock: Script, - pub type_: ::std::vec::Vec