Skip to content

Conversation

@guy-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

guy-starkware commented Nov 20, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@guy-starkware guy-starkware force-pushed the guyn/baselayer/finality_out_of_baselayer branch from 8347d5b to ccc3ad5 Compare November 20, 2025 08:03
@guy-starkware guy-starkware force-pushed the guyn/baselayer/remove_latest_l1_block branch from caf904a to f25015f Compare November 20, 2025 08:03
@guy-starkware guy-starkware force-pushed the guyn/baselayer/finality_out_of_baselayer branch from ccc3ad5 to d9c733e Compare November 20, 2025 13:09
@guy-starkware guy-starkware force-pushed the guyn/baselayer/remove_latest_l1_block branch from f25015f to b5122b5 Compare November 20, 2025 13:09
Copy link
Collaborator

@ShahakShama ShahakShama left a 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 guy-starkware changed the base branch from guyn/baselayer/remove_latest_l1_block to graphite-base/10303 November 23, 2025 09:11
Copy link
Contributor Author

@guy-starkware guy-starkware left a 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.

@guy-starkware guy-starkware force-pushed the guyn/baselayer/finality_out_of_baselayer branch from d9c733e to 9c6f35c Compare November 23, 2025 09:20
@guy-starkware guy-starkware changed the base branch from graphite-base/10303 to guyn/baselayer/remove_latest_l1_block November 23, 2025 09:20
Copy link
Collaborator

@ShahakShama ShahakShama left a 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

Copy link
Contributor Author

@guy-starkware guy-starkware left a 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.

Copy link
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@ShahakShama reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @guy-starkware)

@guy-starkware guy-starkware changed the base branch from guyn/baselayer/remove_latest_l1_block to main-v0.14.1 November 23, 2025 12:57
@guy-starkware guy-starkware force-pushed the guyn/baselayer/finality_out_of_baselayer branch from 5ccde42 to 75ebc95 Compare November 23, 2025 12:57
@graphite-app
Copy link

graphite-app bot commented Nov 23, 2025

Merge activity

  • Nov 23, 12:58 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@guy-starkware guy-starkware added this pull request to the merge queue Nov 23, 2025
Merged via the queue into main-v0.14.1 with commit 893e16f Nov 23, 2025
22 of 24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants