fix: increment da height when we have already processed the height previously#2867
fix: increment da height when we have already processed the height previously#2867tac0turtle wants to merge 2 commits into
Conversation
Summary of ChangesHello @tac0turtle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug where the Data Availability (DA) height was not being correctly incremented on the node when a block had already been processed via a faster P2P sync. The fix ensures that even if a block is already known, if a DA-sourced event for that block arrives with a higher DA height, the node's state is properly updated to reflect the latest DA height, maintaining data consistency and preventing discrepancies between P2P and DA sync heights. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).
|
|
Claude finished @tac0turtle's task —— View job Code Review CompleteI've reviewed this PR which fixes a bug where DA height wasn't being incremented when blocks were already processed via P2P sync. The implementation is sound overall, but I've identified several areas for improvement. Critical Issues1. Race Condition in
|
There was a problem hiding this comment.
Code Review
This pull request addresses a bug where the Data Availability (DA) height was not being updated when a block was processed via P2P sync before being received from the DA layer. The changes introduce logic in processHeightEvent to call a new function, updateStateDAHeight, to persist the correct DA height even for already-processed blocks. A comprehensive test case has been added to validate this specific scenario, ensuring both the in-memory and persisted states are correctly updated. The overall approach is sound and effectively resolves the issue. I have one minor suggestion to improve test determinism.
| addr, pub, signer := buildSyncTestSigner(t) | ||
|
|
||
| cfg := config.DefaultConfig() | ||
| gen := genesis.Genesis{ChainID: "tchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr} |
There was a problem hiding this comment.
Using time.Now() in tests can introduce non-determinism, potentially leading to flaky tests in the future. It is a best practice to use a fixed timestamp to ensure that tests are fully reproducible.
| gen := genesis.Genesis{ChainID: "tchain", InitialHeight: 1, StartTime: time.Now().Add(-time.Second), ProposerAddress: addr} | |
| gen := genesis.Genesis{ChainID: "tchain", InitialHeight: 1, StartTime: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC), ProposerAddress: addr} |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2867 +/- ##
=======================================
Coverage 64.90% 64.91%
=======================================
Files 81 81
Lines 7243 7259 +16
=======================================
+ Hits 4701 4712 +11
- Misses 1998 2000 +2
- Partials 544 547 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overview
When we p2p sync its much faster than da sync making our processed height higher than what is coming form da, this uncovered a bug in which we were not incrementing the processed da height on the node.