-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Optimism execution #789
Conversation
crates/revm/src/optimism.rs
Outdated
// input must not be an deposit transaction | ||
debug_assert!(!input.is_empty() && input[0] != 0x7E); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just return U256::ZERO
if either of these two conditions are met? This makes the function more abstract as opposed to it only being used for non-deposit, non-empty transactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure changed that, but I was wondering what the expected behavior should actually be for an empty transaction? If anything, shouldn't it return (0 + l1FeeOverhead) * l1Basefee * l1FeeScalar / 1000000
? To be consistent with hypothetical one-byte transactions?
.checked_div(U256::from(1_000_000)) | ||
.unwrap_or_default() | ||
/ U256::from(1_000_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer if we kept this as a checked div just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked_div
only checks if the divisor is 0
. Since it is always hardcoded to one million, I don't think checked div would make any difference.
However, checked operations might make sense before multiplication and addition, as there should be no overflows there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
* use l2 base fee * use optimism handler when activated * fix panic for eth execution with optimism flag * use is_none * address review comments
This PR fixes the issues with the Optimism execution described in #781:
Handler::optimism()
is used instead ofHandler::mainnet()
when theoptimism
feature is enabled andenv.cfg.optimism
istrue
.env.block.basefee * (gas.spend() - gas_refund)
.tx_l1_cost
only whenenv.cfg.optimism
istrue
and the corresponding transaction is not an Optimism deposit transaction. This supports regular Ethereum transactions whenenv.cfg.optimism
isfalse
andenv.tx.optimism.enveloped_tx
beingNone
for non-deposit transactions otherwise.