-
Notifications
You must be signed in to change notification settings - Fork 21
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(mempool): fix overflow bug in fee escalation flow; add tests #1447
base: main
Are you sure you want to change the base?
Conversation
566df08
to
3f6c3eb
Compare
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
a discussion (no related file):
Depends on: #1445, for CI to pass.
3f6c3eb
to
cbb685f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1447 +/- ##
===========================================
- Coverage 74.18% 13.37% -60.82%
===========================================
Files 359 31 -328
Lines 36240 3087 -33153
Branches 36240 3087 -33153
===========================================
- Hits 26886 413 -26473
+ Misses 7220 2656 -4564
+ Partials 2134 18 -2116
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
let percentage = u128::from(self.fee_escalation_percentage); let Some(escalation_qualified_value) = (existing_value / 100)
Can you please document why it's okay to divide it before the multiplication?
Does it depend on the ranges of the gas/tip values?
What's the range of these values?
Code quote:
(existing_value / 100)
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.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Can you please document why it's okay to divide it before the multiplication?
Does it depend on the ranges of the gas/tip values?
What's the range of these values?
Why wouldn't it be okay? Value is u128
, clear from the signature. Not sure what information I can add with words.
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.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
Previously, elintul (Elin) wrote…
Why wouldn't it be okay? Value is
u128
, clear from the signature. Not sure what information I can add with words.
Typically, to avoid issues with integer division, we multiply first and then divide. However, in this case, we use a different approach.
This can cause problems when existing_value
s are less than 100..
Do you assume that tip/gas are above these values? is it worth mentioning?
Another Q that I asked above: what's the range of these values?
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.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Typically, to avoid issues with integer division, we multiply first and then divide. However, in this case, we use a different approach.
This can cause problems when
existing_value
s are less than 100..
Do you assume that tip/gas are above these values? is it worth mentioning?Another Q that I asked above: what's the range of these values?
Okay good point, I'll give it some more thought; changed the order in the meantime in order not to delay this PR.
WDYM by range? Can you rephrase differently? I thought I answered: you know from the type.
a8868f7
to
9e9ac82
Compare
9e9ac82
to
577e96b
Compare
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.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
Previously, elintul (Elin) wrote…
Okay good point, I'll give it some more thought; changed the order in the meantime in order not to delay this PR.
WDYM by range? Can you rephrase differently? I thought I answered: you know from the type.
Is it acceptable for the 'tip' or 'gas' values to be small (smaller than 100 in this case)? While the parameter type allows it, does the UX permit such small values?
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.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool_test.rs
line 803 at r3 (raw file):
for (tip, max_l2_gas_price) in initial_values { let existing_tx = tx!(tip: tip, max_l2_gas_price: max_l2_gas_price, tx_nonce: 1, sender_address: "0x0");
Why do you pass sender_address? I see you always use the default address.
Code quote:
sender_address: "0x0"
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.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/mempool.rs
line 251 at r2 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Is it acceptable for the 'tip' or 'gas' values to be small (smaller than 100 in this case)? While the parameter type allows it, does the UX permit such small values?
Not sure, but we should handle well all possible values.
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.
Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)
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.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool.rs
line 252 at r3 (raw file):
let escalation_factor = 100 + u128::from(self.fee_escalation_percentage); // TODO(Elin): add overflow tests; 2^127 existing with 10% increase should not overflow.
Do you want to keep the TODO?
Code quote:
// TODO(Elin): add overflow tests; 2^127 existing with 10% increase should not overflow.
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.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/mempool_test.rs
line 803 at r3 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Why do you pass sender_address? I see you always use the default address.
Since it appears in the error message.
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.
Reviewed 1 of 2 files at r3, all commit messages.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @elintul, and @giladchase)
crates/mempool/src/mempool_test.rs
line 803 at r3 (raw file):
Previously, elintul (Elin) wrote…
Since it appears in the error message.
Are you referring to the error in add_txs_and_verify_no_replacement
? Since it's not part of the test, I believe you can use the default value.
But, feel free to disregard this comment and go ahead with merging the PR.
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.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @ayeletstarkware, @giladchase, and @MohammadNassar1)
crates/mempool/src/mempool_test.rs
line 803 at r3 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Are you referring to the error in
add_txs_and_verify_no_replacement
? Since it's not part of the test, I believe you can use the default value.But, feel free to disregard this comment and go ahead with merging the PR.
Yeah, perhaps it isn't needed here, since the address is now inferred from the existing transaction.
Good catch, I'll go over all fee escalation tests and fix it.
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.
Reviewed 1 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ayeletstarkware, @elintul, and @giladchase)
No description provided.