Skip to content

Commit

Permalink
fix: merge fails (#23)
Browse files Browse the repository at this point in the history
* fix merge fails

* fix ci

* fix clippy
  • Loading branch information
lightsing committed Sep 3, 2024
1 parent 3a4129b commit 7162ec5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn blockhash<H: Host + ?Sized, SPEC: Spec>(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 {
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/context/inner_evm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<DB: Database> InnerEvmContext<DB> {
pub fn code_size(&mut self, address: Address) -> Result<(usize, bool), EVMError<DB::Error>> {
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.
Expand Down Expand Up @@ -280,10 +280,10 @@ impl<DB: Database> InnerEvmContext<DB> {
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))
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions crates/revm/src/scroll/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn deduct_caller<SPEC: Spec, EXT, DB: Database>(
context: &mut Context<EXT, DB>,
) -> Result<(), EVMError<DB::Error>> {
// load caller's account.
let (caller_account, _) = context
let caller_account = context
.evm
.inner
.journaled_state
Expand All @@ -53,7 +53,7 @@ pub fn deduct_caller<SPEC: Spec, EXT, DB: Database>(
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::<SPEC>(caller_account, &context.evm.inner.env);
deduct_caller_inner::<SPEC>(caller_account.data, &context.evm.inner.env);

let Some(rlp_bytes) = &context.evm.inner.env.tx.scroll.rlp_bytes else {
return Err(EVMError::Custom(
Expand All @@ -76,16 +76,17 @@ pub fn deduct_caller<SPEC: Spec, EXT, DB: Database>(
},
));
}
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(())
}
Expand All @@ -102,7 +103,7 @@ pub fn reward_beneficiary<SPEC: Spec, EXT, DB: Database>(
// transfer fee to coinbase/beneficiary.
let coinbase_gas_price = effective_gas_price;

let (coinbase_account, _) = context
let coinbase_account = context
.evm
.inner
.journaled_state
Expand All @@ -123,8 +124,9 @@ pub fn reward_beneficiary<SPEC: Spec, EXT, DB: Database>(

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))
Expand Down

0 comments on commit 7162ec5

Please sign in to comment.