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 23, 2025

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

@guy-starkware guy-starkware marked this pull request as ready for review November 23, 2025 11:59
@guy-starkware guy-starkware force-pushed the guyn/l1provider/use_atomic_instead_of_mutex branch from 86cea3b to fe01db9 Compare November 23, 2025 12:16
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from 976c083 to 7b71af3 Compare November 23, 2025 12:16
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from 7b71af3 to e3bf1a2 Compare November 23, 2025 14:18
@guy-starkware guy-starkware force-pushed the guyn/l1provider/use_atomic_instead_of_mutex branch from fe01db9 to 0561669 Compare November 23, 2025 14:18
@guy-starkware guy-starkware force-pushed the guyn/l1provider/use_atomic_instead_of_mutex branch from 0561669 to 540158c Compare November 23, 2025 15:14
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from e3bf1a2 to 3593658 Compare November 23, 2025 15:14
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from 3593658 to f408e04 Compare November 24, 2025 09:03
@guy-starkware guy-starkware force-pushed the guyn/l1provider/use_atomic_instead_of_mutex branch from 540158c to 76a7ed4 Compare November 24, 2025 09:03
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from f408e04 to 7c809c5 Compare December 2, 2025 11:06
@guy-starkware guy-starkware force-pushed the guyn/l1provider/use_atomic_instead_of_mutex branch from 76a7ed4 to 21157d9 Compare December 2, 2025 11:06
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 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @guy-starkware)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 159 at r1 (raw file):

#[tokio::test]
async fn base_layer_returns_block_number_below_finality() {

Add the expect result to the end of the test (_causes_error)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 163 at r1 (raw file):

    const FINALITY: u64 = 10;
    const INITIAL_L1_BLOCK_NUMBER: u64 = 100;
    const INITIAL_L1_BLOCK_HASH: L1BlockHash = L1BlockHash([123; 32]);

This is in-fact the hash of all l1 blocks in this test. Either fix it so that you'll have different hash for INITIAL_L1_BLOCK_NUMBER and WRONG_L1_BLOCK_NUMBER or rename this to reflect that it's for all blocks


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 188 at r1 (raw file):

    // Test.
    assert_eq!(scraper.send_events_to_l1_provider().await, Ok(()));

use unwrap instead


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

    assert_matches!(
        scraper.send_events_to_l1_provider().await,
        Err(L1ScraperError::FinalityTooHigh { .. })

Why is that the expected outcome? IIUC this means that if I got block x then got block x-95 then you return finality too high to the provider, but shouldn't you return a reorg error?

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, 4 unresolved discussions (waiting on @ShahakShama)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 159 at r1 (raw file):

Previously, ShahakShama wrote…

Add the expect result to the end of the test (_causes_error)

I'm not sure what you want me to add where?


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 163 at r1 (raw file):

Previously, ShahakShama wrote…

This is in-fact the hash of all l1 blocks in this test. Either fix it so that you'll have different hash for INITIAL_L1_BLOCK_NUMBER and WRONG_L1_BLOCK_NUMBER or rename this to reflect that it's for all blocks

Done.


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, ShahakShama wrote…

Why is that the expected outcome? IIUC this means that if I got block x then got block x-95 then you return finality too high to the provider, but shouldn't you return a reorg error?

If x is 100 you should get FinalityTooHigh. If the new height is lower than the old height but still above 10, you should get a reorg.

Here are the list of checks we do each scrape, in order:

  1. Reorg detection. Assume the same block number, try to get that block again. If the block is missing, or if the hash changed, trigger a reorg. This doesn't check finality. So if the endpoint's latest L1 block number goes down a few blocks, it may still have the block in question, so it may not trigger the reorg error.
  2. Check if the latest L1 block number from the endpoint is above finality. This guards against what I assume is a but in Infura where sometimes it reports the latest number is zero (I never checked, it could also be reporting 3 or 8, but it doesn't matter). The get block at number function could still work normally, so it doesn't necessarily trigger reorg. In such cases we cannot continue because the latest number - 10 is not valid. This is FinalityTooHigh error.
  3. If we don't trigger these two errors, and still the endpoint reports a latest number (after subtracting finality) that is lower than the number we already scraped (or equal) we just issue a warning and wait until the next scrape (this happens when switching endpoints and the new one -- usually Infura -- is less updated than the old one).

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, 4 unresolved discussions (waiting on @ShahakShama)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 188 at r1 (raw file):

Previously, ShahakShama wrote…

use unwrap instead

Done.

@guy-starkware guy-starkware changed the base branch from guyn/l1provider/use_atomic_instead_of_mutex to graphite-base/10345 December 3, 2025 08:27
@guy-starkware guy-starkware force-pushed the guyn/baselayer/tests_for_bad_block_numbers branch from 7c809c5 to 67ca8a6 Compare December 3, 2025 08:27
@guy-starkware guy-starkware changed the base branch from graphite-base/10345 to main-v0.14.1 December 3, 2025 08:28
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: 0 of 1 files reviewed, 4 unresolved discussions (waiting on @ShahakShama)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, guy-starkware wrote…

If x is 100 you should get FinalityTooHigh. If the new height is lower than the old height but still above 10, you should get a reorg.

Here are the list of checks we do each scrape, in order:

  1. Reorg detection. Assume the same block number, try to get that block again. If the block is missing, or if the hash changed, trigger a reorg. This doesn't check finality. So if the endpoint's latest L1 block number goes down a few blocks, it may still have the block in question, so it may not trigger the reorg error.
  2. Check if the latest L1 block number from the endpoint is above finality. This guards against what I assume is a but in Infura where sometimes it reports the latest number is zero (I never checked, it could also be reporting 3 or 8, but it doesn't matter). The get block at number function could still work normally, so it doesn't necessarily trigger reorg. In such cases we cannot continue because the latest number - 10 is not valid. This is FinalityTooHigh error.
  3. If we don't trigger these two errors, and still the endpoint reports a latest number (after subtracting finality) that is lower than the number we already scraped (or equal) we just issue a warning and wait until the next scrape (this happens when switching endpoints and the new one -- usually Infura -- is less updated than the old one).

Correction: if new height is lower but still above 10 you may get a reorg (if the block you last scraped no longer exists) but you may also just get a warning if the block exists but the (finality-adjusted) latest number is not higher than the last one you scraped.

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: 0 of 1 files reviewed, 4 unresolved discussions (waiting on @ShahakShama)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, guy-starkware wrote…

If x is 100 you should get FinalityTooHigh. If the new height is lower than the old height but still above 10, you should get a reorg.

Here are the list of checks we do each scrape, in order:

  1. Reorg detection. Assume the same block number, try to get that block again. If the block is missing, or if the hash changed, trigger a reorg. This doesn't check finality. So if the endpoint's latest L1 block number goes down a few blocks, it may still have the block in question, so it may not trigger the reorg error.
  2. Check if the latest L1 block number from the endpoint is above finality. This guards against what I assume is a but in Infura where sometimes it reports the latest number is zero (I never checked, it could also be reporting 3 or 8, but it doesn't matter). The get block at number function could still work normally, so it doesn't necessarily trigger reorg. In such cases we cannot continue because the latest number - 10 is not valid. This is FinalityTooHigh error.
  3. If we don't trigger these two errors, and still the endpoint reports a latest number (after subtracting finality) that is lower than the number we already scraped (or equal) we just issue a warning and wait until the next scrape (this happens when switching endpoints and the new one -- usually Infura -- is less updated than the old one).

Correction: if new height is lower but still above 10 you may get a reorg (if the block you last scraped no longer exists) but you may also just get a warning if the block exists but the (finality-adjusted) latest number is not higher than the last one you scraped.

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.

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @guy-starkware)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 159 at r1 (raw file):

Previously, guy-starkware wrote…

I'm not sure what you want me to add where?

Sorry, I should've been more clear
Rename the test to base_layer_returns_block_number_below_finality_causes_error


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, guy-starkware wrote…

Correction: if new height is lower but still above 10 you may get a reorg (if the block you last scraped no longer exists) but you may also just get a warning if the block exists but the (finality-adjusted) latest number is not higher than the last one you scraped.

Let's discuss. 2 sounds like it has nothing to do with finality and we arbitrarily decided to use the finality as the threshold to determine if this is an error

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: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @ShahakShama)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, ShahakShama wrote…

Let's discuss. 2 sounds like it has nothing to do with finality and we arbitrarily decided to use the finality as the threshold to determine if this is an error

If you prefer that we rename this error LatestBlockNumberTooLow instead, that's fine by me.

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 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @guy-starkware)


crates/apollo_l1_provider/src/l1_scraper_tests.rs line 196 at r1 (raw file):

Previously, guy-starkware wrote…

If you prefer that we rename this error LatestBlockNumberTooLow instead, that's fine by me.

Yes, in future PR

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 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @guy-starkware)

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