Skip to content

Commit 17c7a66

Browse files
committed
fix: fix evm config init
1 parent ec26fab commit 17c7a66

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

core/executor/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl Executor for AxonExecutor {
7373
value: U256,
7474
data: Vec<u8>,
7575
) -> TxResp {
76+
self.init_local_system_contract_roots(backend);
7677
let config = self.config();
7778
let metadata = StackSubstateMetadata::new(gas_limit, &config);
7879
let state = MemoryStackState::new(metadata, backend);
@@ -138,9 +139,8 @@ impl Executor for AxonExecutor {
138139
let mut hashes = Vec::with_capacity(txs_len);
139140
let (mut gas, mut fee) = (0u64, U256::zero());
140141
let precompiles = build_precompile_set();
141-
let config = self.config();
142-
143142
self.init_local_system_contract_roots(adapter);
143+
let config = self.config();
144144

145145
// Execute system contracts before block hook.
146146
before_block_hook(adapter);
@@ -309,7 +309,7 @@ impl AxonExecutor {
309309
/// The `exec()` function is run in `tokio::task::block_in_place()` and all
310310
/// the read or write operations are in the scope of exec function. The
311311
/// thread context is not switched during exec function.
312-
fn init_local_system_contract_roots<Adapter: ExecutorAdapter>(&self, adapter: &mut Adapter) {
312+
fn init_local_system_contract_roots<Adapter: Backend>(&self, adapter: &Adapter) {
313313
CURRENT_HEADER_CELL_ROOT.with(|root| {
314314
*root.borrow_mut() =
315315
adapter.storage(CKB_LIGHT_CLIENT_CONTRACT_ADDRESS, *HEADER_CELL_ROOT_KEY);
@@ -324,13 +324,14 @@ impl AxonExecutor {
324324
let mut config = Config::london();
325325
let create_contract_limit = {
326326
let latest_hardfork_info = &**HARDFORK_INFO.load();
327-
let enable_contract_limit_flag = H256::from_low_u64_be(HardforkName::Andromeda as u64);
327+
let enable_contract_limit_flag =
328+
H256::from_low_u64_be((HardforkName::Andromeda as u64).to_be());
328329
if latest_hardfork_info & &enable_contract_limit_flag == enable_contract_limit_flag {
329330
let handle = MetadataHandle::new(CURRENT_METADATA_ROOT.with(|r| *r.borrow()));
330331
let config = handle.get_consensus_config().unwrap();
331332
Some(config.max_contract_limit as usize)
332333
} else {
333-
None
334+
Some(0x6000)
334335
}
335336
};
336337
config.create_contract_limit = create_contract_limit;

core/executor/src/tests/system_script/metadata.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ fn prepare_validator() -> ValidatorExtend {
252252
// .gas(21000)
253253
// .nonce(nonce);
254254

255-
// let wallet = LocalWallet::from_str(PRIVATE_KEY).expect("failed to create
256-
// wallet"); let tx = Legacy(transaction_request);
255+
// let wallet = LocalWallet::from_str(PRIVATE_KEY).expect(
256+
// "failed to create
257+
// wallet",
258+
// );
259+
// let tx = Legacy(transaction_request);
257260
// let signature: Signature = wallet.sign_transaction(&tx).await.unwrap();
258261

259262
// provider

0 commit comments

Comments
 (0)