-
Notifications
You must be signed in to change notification settings - Fork 569
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
feat(op): use RollupCostData instead of full encoding #1491
base: main
Are you sure you want to change the base?
Conversation
/// The number of zeroes in the transaction. | ||
pub(crate) zeroes: u64, | ||
/// The number of ones in the transaction. | ||
pub(crate) ones: u64, |
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.
non-zero
pub fn from_bytes(bytes: &[u8]) -> Self { | ||
let mut data = RollupCostData::default(); | ||
let mut i = 0; | ||
while i < bytes.len() { |
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.
the same functionality exists in gas costs, this should reuse that
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.
wdym / where? the counting for op data gas costs at least we want to remove, and put here instead
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.
revm/crates/interpreter/src/gas/calc.rs
Lines 354 to 374 in b7b92ae
/// Initial gas that is deducted for transaction to be included. | |
/// Initial gas contains initial stipend gas, gas for access list and input data. | |
pub fn validate_initial_tx_gas( | |
spec_id: SpecId, | |
input: &[u8], | |
is_create: bool, | |
access_list: &[(Address, Vec<U256>)], | |
) -> u64 { | |
let mut initial_gas = 0; | |
let zero_data_len = input.iter().filter(|v| **v == 0).count() as u64; | |
let non_zero_data_len = input.len() as u64 - zero_data_len; | |
// initdate stipend | |
initial_gas += zero_data_len * TRANSACTION_ZERO_DATA; | |
// EIP-2028: Transaction data gas cost reduction | |
initial_gas += non_zero_data_len | |
* if spec_id.is_enabled_in(SpecId::ISTANBUL) { | |
16 | |
} else { | |
68 | |
}; |
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.
ah i see, thx
crates/revm/src/optimism/l1block.rs
Outdated
let mut rollup_data_gas_cost = U256::from(cost_data.ones.get()) | ||
.saturating_mul(U256::from(NON_ZERO_BYTE_COST)) | ||
.saturating_add( | ||
U256::from(cost_data.zeroes.get()).saturating_mul(U256::from(ZERO_BYTE_COST)), |
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.
pretty sure all the arithmetic in this function and *fjord can be scaled down to use u64
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.
@Rjected this looks nice, did you check why tests are failing?
nope, was busy with other things, can pick this back up this week |
This is a WIP to ultimately replace the
tx_envelope
part of theOptimismFields
with a new struct.Currently it just introduces the struct, which basically mirrors the
RollupCostData
from op-geth, and uses it in a few places. The plan is to first integrate this internally, without breakingOptimismFields
, and once it is properly tested, breakOptimismFields
to use this instead.