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

Fix for DA L2 sync race condition #2512

Conversation

MitchTurner
Copy link
Member

@MitchTurner MitchTurner commented Dec 20, 2024

Linked Issues/PRs

Description

In the case we are syncing from an existing network, it is possible for the L2 blocks to sync slower than the DA costs, in which case you will try to apply DA costs to an algorithm that is missing the corresponding unrecorded L2 blocks.

This PR

  • introduces a latest_l2_height to the DaSourceService which will filter out any DA bundles that include L2 blocks after the current height
  • moves the recorded height concept into the DaSourceService where it probably should have been to begin with

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@rymnc
Copy link
Member

rymnc commented Dec 20, 2024

this error occurs because we call the latest_block_costs from the block committer. i think we can just pass the l2 block height into the da source service (not an arc) and make the da source service fetch all the cost data from that l2 block onwards from the block committer

@MitchTurner MitchTurner added the no changelog Skip the CI check of the changelog modification label Dec 20, 2024
@MitchTurner MitchTurner marked this pull request as ready for review December 20, 2024 20:03
@rymnc rymnc force-pushed the chore/add-tests-for-v1-gas-service branch 5 times, most recently from ff8243c to eb202cf Compare December 25, 2024 18:55
@MitchTurner MitchTurner self-assigned this Dec 27, 2024
@rymnc rymnc requested a review from a team December 30, 2024 18:15
@MitchTurner MitchTurner requested a review from rymnc as a code owner January 6, 2025 19:06
@rymnc rymnc requested a review from a team January 6, 2025 20:09
Comment on lines 82 to 87
pub fn new(
client: BlockCommitter,
last_recorded_height: Option<BlockHeight>,
) -> Self {
Self {
client,
last_recorded_height,
}
Copy link
Member

Choose a reason for hiding this comment

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

@MitchTurner was this change intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because in practice we only set the last_recorded_height after we've constructed the BlockCommitterDaBlockCosts.

Copy link
Member

Choose a reason for hiding this comment

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

okidoki

Copy link
Member

Choose a reason for hiding this comment

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

there are some merge conflicts around this

Comment on lines -113 to -111
if let Some(cost) = raw_da_block_costs.last() {
self.last_recorded_height = Some(BlockHeight::from(cost.end_height));
}
Copy link
Member

@rymnc rymnc Jan 7, 2025

Choose a reason for hiding this comment

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

how do we set it here then? do we move the last_recorded_height elsewhere?
ignore pls

Copy link
Member Author

Choose a reason for hiding this comment

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

It's held by the DA service instead now:

pub struct DaSourceService<Source> {
    poll_interval: Interval,
    source: Source,
    shared_state: SharedState,
    latest_l2_height: Arc<Mutex<BlockHeight>>,
    recorded_height: Option<BlockHeight>,
}

@rymnc rymnc requested a review from a team January 7, 2025 16:34
@MitchTurner MitchTurner merged commit 31fd51f into chore/add-tests-for-v1-gas-service Jan 7, 2025
31 checks passed
@MitchTurner MitchTurner deleted the fix/test-for-DA-L2-sync-race-condition branch January 7, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Skip the CI check of the changelog modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants