From 7162ec565c79e5b6a35c312d32482c0dfae3ece5 Mon Sep 17 00:00:00 2001 From: Akase Haruka Date: Tue, 3 Sep 2024 13:01:58 +0800 Subject: [PATCH] fix: merge fails (#23) * fix merge fails * fix ci * fix clippy --- .github/workflows/ci.yml | 4 ++-- crates/interpreter/src/instructions/host.rs | 2 +- crates/revm/src/context/inner_evm_context.rs | 6 +++--- crates/revm/src/scroll/handler_register.rs | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb35d29cba..607e09a40e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: "--features=\"scroll, scroll-poseidon-codehash\"", "--features=\"all, scroll\"", "--features=\"all, scroll, scroll-poseidon-codehash\"", - "--features=\"optimism\"" + "--features=\"optimism\"", "--features=\"all, optimism\"" ] steps: @@ -47,7 +47,7 @@ jobs: strategy: fail-fast: false matrix: - features: ["", "optimism,kzg-rs"] + features: [ "", "optimism,kzg-rs" ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable diff --git a/crates/interpreter/src/instructions/host.rs b/crates/interpreter/src/instructions/host.rs index 96d838fc5b..15f330267f 100644 --- a/crates/interpreter/src/instructions/host.rs +++ b/crates/interpreter/src/instructions/host.rs @@ -142,7 +142,7 @@ pub fn blockhash(interpreter: &mut Interpreter, ho match block_number.checked_sub(*number) { Some(diff) if !diff.is_zero() => { - let diff = as_usize_saturated!(diff); + let diff = as_u64_saturated!(diff); let block_number = as_u64_or_fail!(interpreter, number); if SPEC::enabled(BERNOULLI) && diff <= BLOCK_HASH_HISTORY { diff --git a/crates/revm/src/context/inner_evm_context.rs b/crates/revm/src/context/inner_evm_context.rs index 9c6dd1f51e..e451488942 100644 --- a/crates/revm/src/context/inner_evm_context.rs +++ b/crates/revm/src/context/inner_evm_context.rs @@ -224,7 +224,7 @@ impl InnerEvmContext { pub fn code_size(&mut self, address: Address) -> Result<(usize, bool), EVMError> { self.journaled_state .load_account(address, &mut self.db) - .map(|(acc, is_cold)| (acc.info.code_size, is_cold)) + .map(|acc| (acc.info.code_size, acc.is_cold)) } /// Get code hash of address. @@ -280,10 +280,10 @@ impl InnerEvmContext { acc.info.code_hash }; - return Ok(Eip7702CodeLoad::new_not_delegated(hash, acc.is_cold)) + Ok(Eip7702CodeLoad::new_not_delegated(hash, acc.is_cold)) } else { // Scroll does not support EOF yet - return Ok(Eip7702CodeLoad::new_not_delegated(acc.info.code_hash, acc.is_cold)) + Ok(Eip7702CodeLoad::new_not_delegated(acc.info.code_hash, acc.is_cold)) } } } diff --git a/crates/revm/src/scroll/handler_register.rs b/crates/revm/src/scroll/handler_register.rs index 76ec22683b..7ed7c95ecd 100644 --- a/crates/revm/src/scroll/handler_register.rs +++ b/crates/revm/src/scroll/handler_register.rs @@ -44,7 +44,7 @@ pub fn deduct_caller( context: &mut Context, ) -> Result<(), EVMError> { // load caller's account. - let (caller_account, _) = context + let caller_account = context .evm .inner .journaled_state @@ -53,7 +53,7 @@ pub fn deduct_caller( if !context.evm.inner.env.tx.scroll.is_l1_msg { // We deduct caller max balance after minting and before deducing the // l1 cost, max values is already checked in pre_validate but l1 cost wasn't. - deduct_caller_inner::(caller_account, &context.evm.inner.env); + deduct_caller_inner::(caller_account.data, &context.evm.inner.env); let Some(rlp_bytes) = &context.evm.inner.env.tx.scroll.rlp_bytes else { return Err(EVMError::Custom( @@ -76,16 +76,17 @@ pub fn deduct_caller( }, )); } - caller_account.info.balance = caller_account.info.balance.saturating_sub(tx_l1_cost); + caller_account.data.info.balance = + caller_account.data.info.balance.saturating_sub(tx_l1_cost); } else { // bump the nonce for calls. Nonce for CREATE will be bumped in `handle_create`. if matches!(context.evm.inner.env.tx.transact_to, TransactTo::Call(_)) { // Nonce is already checked - caller_account.info.nonce = caller_account.info.nonce.saturating_add(1); + caller_account.data.info.nonce = caller_account.data.info.nonce.saturating_add(1); } // touch account so we know it is changed. - caller_account.mark_touch(); + caller_account.data.mark_touch(); } Ok(()) } @@ -102,7 +103,7 @@ pub fn reward_beneficiary( // transfer fee to coinbase/beneficiary. let coinbase_gas_price = effective_gas_price; - let (coinbase_account, _) = context + let coinbase_account = context .evm .inner .journaled_state @@ -123,8 +124,9 @@ pub fn reward_beneficiary( let l1_cost = l1_block_info.calculate_tx_l1_cost(rlp_bytes, SPEC::SPEC_ID); - coinbase_account.mark_touch(); - coinbase_account.info.balance = coinbase_account + coinbase_account.data.mark_touch(); + coinbase_account.data.info.balance = coinbase_account + .data .info .balance .saturating_add(coinbase_gas_price * U256::from(gas.spent() - gas.refunded() as u64))