Skip to content
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

test: rm unit tests for calc_next_block_base_fee #9275

Closed
tcoratger opened this issue Jul 3, 2024 · 3 comments · Fixed by #9280
Closed

test: rm unit tests for calc_next_block_base_fee #9275

tcoratger opened this issue Jul 3, 2024 · 3 comments · Fixed by #9280
Labels
C-enhancement New feature or request S-needs-triage This issue needs to be labelled

Comments

@tcoratger
Copy link
Contributor

Describe the feature

In the codebase, we still have some places where we unit test the calc_next_block_base_fee method:

#[test]
fn calculate_base_fee_success() {
let base_fee = [
1000000000, 1000000000, 1000000000, 1072671875, 1059263476, 1049238967, 1049238967, 0,
1, 2,
];
let gas_used = [
10000000, 10000000, 10000000, 9000000, 10001000, 0, 10000000, 10000000, 10000000,
10000000,
];
let gas_limit = [
10000000, 12000000, 14000000, 10000000, 14000000, 2000000, 18000000, 18000000,
18000000, 18000000,
];
let next_base_fee = [
1125000000, 1083333333, 1053571428, 1179939062, 1116028649, 918084097, 1063811730, 1,
2, 3,
];
for i in 0..base_fee.len() {
assert_eq!(
next_base_fee[i],
calc_next_block_base_fee(
gas_used[i] as u128,
gas_limit[i] as u128,
base_fee[i] as u128,
crate::BaseFeeParams::ethereum(),
) as u64
);
}
}

#[test]
fn calculate_optimism_base_fee_success() {
let base_fee = [
1000000000, 1000000000, 1000000000, 1072671875, 1059263476, 1049238967, 1049238967, 0,
1, 2,
];
let gas_used = [
10000000, 10000000, 10000000, 9000000, 10001000, 0, 10000000, 10000000, 10000000,
10000000,
];
let gas_limit = [
10000000, 12000000, 14000000, 10000000, 14000000, 2000000, 18000000, 18000000,
18000000, 18000000,
];
let next_base_fee = [
1100000048, 1080000000, 1065714297, 1167067046, 1128881311, 1028254188, 1098203452, 1,
2, 3,
];
for i in 0..base_fee.len() {
assert_eq!(
next_base_fee[i],
calc_next_block_base_fee(
gas_used[i] as u128,
gas_limit[i] as u128,
base_fee[i] as u128,
OP_BASE_FEE_PARAMS,
) as u64
);
}
}

But this method is already widely tested here:

https://github.com/alloy-rs/alloy/blob/ec9e13e6336717b988b6ec2908bb4ceec6e874a5/crates/eips/src/eip1559/helpers.rs#L73-L103

Maybe we could:

  • Remove these tests which seem useless on reth
  • Add one or two scenarios on alloy if there are any missing but I don't have the impression, the function already seems to be well covered on alloy.

Additional context

No response

@tcoratger tcoratger added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Jul 3, 2024
@mattsse
Copy link
Collaborator

mattsse commented Jul 3, 2024

we can remove those, yes

actually, I don't mind having them, especially the op ones.

@tcoratger
Copy link
Contributor Author

we can remove those, yes

actually, I don't mind having them, especially the op ones.

Maybe we can migrate the op ones to alloy and remove all from reth?

@mattsse
Copy link
Collaborator

mattsse commented Jul 3, 2024

sg!
we can do both prs in parallel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request S-needs-triage This issue needs to be labelled
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants