From 3e0fffb0ab3efa188fd660095ed9d16be8232ce8 Mon Sep 17 00:00:00 2001 From: driftluo Date: Tue, 17 Oct 2023 13:34:34 +0800 Subject: [PATCH] fix: fix evm config init --- core/api/src/jsonrpc/error.rs | 2 +- core/executor/src/lib.rs | 11 ++++++----- core/executor/src/tests/system_script/metadata.rs | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/api/src/jsonrpc/error.rs b/core/api/src/jsonrpc/error.rs index 3ac820882..91d57d431 100644 --- a/core/api/src/jsonrpc/error.rs +++ b/core/api/src/jsonrpc/error.rs @@ -54,7 +54,7 @@ pub enum RpcError { #[display(fmt = "Invalid filter id {}", _0)] CannotFindFilterId(u64), - #[display(fmt = "CKB-VM error {}", "decode_revert_msg(&_0.ret)")] + #[display(fmt = "EVM error {}", "decode_revert_msg(&_0.ret)")] VM(TxResp), #[display(fmt = "Internal error")] Internal(String), diff --git a/core/executor/src/lib.rs b/core/executor/src/lib.rs index 176a3beb4..ac7227e5e 100644 --- a/core/executor/src/lib.rs +++ b/core/executor/src/lib.rs @@ -73,6 +73,7 @@ impl Executor for AxonExecutor { value: U256, data: Vec, ) -> TxResp { + self.init_local_system_contract_roots(backend); let config = self.config(); let metadata = StackSubstateMetadata::new(gas_limit, &config); let state = MemoryStackState::new(metadata, backend); @@ -138,9 +139,8 @@ impl Executor for AxonExecutor { let mut hashes = Vec::with_capacity(txs_len); let (mut gas, mut fee) = (0u64, U256::zero()); let precompiles = build_precompile_set(); - let config = self.config(); - self.init_local_system_contract_roots(adapter); + let config = self.config(); // Execute system contracts before block hook. before_block_hook(adapter); @@ -309,7 +309,7 @@ impl AxonExecutor { /// The `exec()` function is run in `tokio::task::block_in_place()` and all /// the read or write operations are in the scope of exec function. The /// thread context is not switched during exec function. - fn init_local_system_contract_roots(&self, adapter: &mut Adapter) { + fn init_local_system_contract_roots(&self, adapter: &Adapter) { CURRENT_HEADER_CELL_ROOT.with(|root| { *root.borrow_mut() = adapter.storage(CKB_LIGHT_CLIENT_CONTRACT_ADDRESS, *HEADER_CELL_ROOT_KEY); @@ -324,13 +324,14 @@ impl AxonExecutor { let mut config = Config::london(); let create_contract_limit = { let latest_hardfork_info = &**HARDFORK_INFO.load(); - let enable_contract_limit_flag = H256::from_low_u64_be(HardforkName::Andromeda as u64); + let enable_contract_limit_flag = + H256::from_low_u64_be((HardforkName::Andromeda as u64).to_be()); if latest_hardfork_info & &enable_contract_limit_flag == enable_contract_limit_flag { let handle = MetadataHandle::new(CURRENT_METADATA_ROOT.with(|r| *r.borrow())); let config = handle.get_consensus_config().unwrap(); Some(config.max_contract_limit as usize) } else { - None + Some(0x6000) } }; config.create_contract_limit = create_contract_limit; diff --git a/core/executor/src/tests/system_script/metadata.rs b/core/executor/src/tests/system_script/metadata.rs index 91d9ba91b..be4ee29c2 100644 --- a/core/executor/src/tests/system_script/metadata.rs +++ b/core/executor/src/tests/system_script/metadata.rs @@ -252,8 +252,11 @@ fn prepare_validator() -> ValidatorExtend { // .gas(21000) // .nonce(nonce); -// let wallet = LocalWallet::from_str(PRIVATE_KEY).expect("failed to create -// wallet"); let tx = Legacy(transaction_request); +// let wallet = LocalWallet::from_str(PRIVATE_KEY).expect( +// "failed to create +// wallet", +// ); +// let tx = Legacy(transaction_request); // let signature: Signature = wallet.sign_transaction(&tx).await.unwrap(); // provider