-
Notifications
You must be signed in to change notification settings - Fork 65
papyrus_base_layer: remove finality from base layer #10303
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
papyrus_base_layer: remove finality from base layer #10303
Conversation
8347d5b to
ccc3ad5
Compare
caf904a to
f25015f
Compare
ccc3ad5 to
d9c733e
Compare
f25015f to
b5122b5
Compare
ShahakShama
left a comment
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.
@ShahakShama reviewed 14 of 14 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @guy-starkware)
crates/apollo_central_sync/src/sources/base_layer.rs line 52 at r1 (raw file):
return Err(BaseLayerSourceError::FinalityTooHigh { finality, latest_l1_block_number }); } let latest_l1_block_number = latest_l1_block_number.saturating_sub(finality);
Use checked_sub and ok_or instead
crates/apollo_l1_provider/src/l1_scraper.rs line 82 at r1 (raw file):
.await .map_err(L1ScraperError::BaseLayerError)?; if latest_l1_block_number < finality {
Consider extracting to a utility function. You do this code a lot
crates/apollo_l1_provider/src/l1_scraper.rs line 88 at r1 (raw file):
}); } let latest_l1_block_number = latest_l1_block_number.saturating_sub(finality);
Same here
crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 144 at r1 (raw file):
) .await??; // let Some(block_number) = block_number.checked_sub(finality) else {
Remove commented code
crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs line 24 at r1 (raw file):
L1_GAS_PRICE_SCRAPER_SUCCESS_COUNT, };
Now that I think of it, why do we care about finality in the gas price scraper? Worst case is that we have a few blocks in the average that don't really exist, and they will be erased in a few hours. Doesn't sound like a problem to me
Maybe we should consider removing finality to make the code flow easier? Anyway, later PR
crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs line 165 at r1 (raw file):
}); } let latest_l1_block_number = latest_l1_block_number.saturating_sub(self.config.finality);
Same here
guy-starkware
left a comment
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: all files reviewed, 3 unresolved discussions (waiting on @ShahakShama)
crates/apollo_central_sync/src/sources/base_layer.rs line 52 at r1 (raw file):
Previously, ShahakShama wrote…
Use checked_sub and ok_or instead
Done.
crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs line 24 at r1 (raw file):
Previously, ShahakShama wrote…
Now that I think of it, why do we care about finality in the gas price scraper? Worst case is that we have a few blocks in the average that don't really exist, and they will be erased in a few hours. Doesn't sound like a problem to me
Maybe we should consider removing finality to make the code flow easier? Anyway, later PR
Maybe you are right. But there's an issue with what happens when the gas price provider gets the same L1 block twice (after the reorg). Currently we panic on getting unexpected block number (either skipping ahead or going back).
We could fix that, in a general sense that "we don't really care if we lose a block or add a block" but that deserves some more consideration.
crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs line 165 at r1 (raw file):
Previously, ShahakShama wrote…
Same here
Done.
crates/apollo_l1_provider/src/l1_scraper.rs line 82 at r1 (raw file):
Previously, ShahakShama wrote…
Consider extracting to a utility function. You do this code a lot
I think "checked_sub" is the utility function (given that the error returned is a different type in each place).
Suppose I did want to extract a helper function, where in the code would I put it (that is accessible to all three crates)?
crates/apollo_l1_provider/src/l1_scraper.rs line 88 at r1 (raw file):
Previously, ShahakShama wrote…
Same here
Done.
crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 144 at r1 (raw file):
Previously, ShahakShama wrote…
Remove commented code
Done.
b5122b5 to
97f96dd
Compare
d9c733e to
9c6f35c
Compare
ShahakShama
left a comment
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.
@ShahakShama reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @guy-starkware)
crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs line 24 at r1 (raw file):
Previously, guy-starkware wrote…
Maybe you are right. But there's an issue with what happens when the gas price provider gets the same L1 block twice (after the reorg). Currently we panic on getting unexpected block number (either skipping ahead or going back).
We could fix that, in a general sense that "we don't really care if we lose a block or add a block" but that deserves some more consideration.
Food for thought
crates/apollo_l1_provider/src/l1_scraper.rs line 82 at r1 (raw file):
Previously, guy-starkware wrote…
I think "checked_sub" is the utility function (given that the error returned is a different type in each place).
Suppose I did want to extract a helper function, where in the code would I put it (that is accessible to all three crates)?
With checked_sub it becomes less code so nvm
crates/apollo_l1_provider/src/l1_scraper.rs line 88 at r1 (raw file):
Previously, guy-starkware wrote…
Done.
There were 2 places in this file that needed this fix. You only fixed one of them
97f96dd to
8e85d26
Compare
9c6f35c to
0f37072
Compare
0f37072 to
5ccde42
Compare
guy-starkware
left a comment
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: 12 of 14 files reviewed, 1 unresolved discussion (waiting on @ShahakShama)
crates/apollo_l1_provider/src/l1_scraper.rs line 88 at r1 (raw file):
Previously, ShahakShama wrote…
There were 2 places in this file that needed this fix. You only fixed one of them
Done.
ShahakShama
left a comment
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.
@ShahakShama reviewed 2 of 2 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @guy-starkware)
5ccde42 to
75ebc95
Compare
Merge activity
|

No description provided.