-
Notifications
You must be signed in to change notification settings - Fork 10
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
Start event ingestion on proper block height when connecting to local Emulator #753
Conversation
WalkthroughThis change adds a conditional check in the Changes
Sequence Diagram(s)sequenceDiagram
participant B as Bootstrap
participant A as Access Node
participant E as Emulator
B->>B: StartEventIngestion()
alt latestCadenceHeight equals config.EmulatorInitCadenceHeight
B->>B: Decrement nextCadenceHeight by 1
else
B->>B: Use latestCadenceHeight as-is
end
B->>A: Subscribe to events at nextCadenceHeight
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bootstrap/bootstrap.go (1)
148-153
: LGTM! Consider adding a debug log.The special case handling for the Emulator is well-implemented and properly documented. The solution effectively prevents the subscription error when the Emulator starts at block height 0.
Consider adding a debug log when this special case is triggered to aid in troubleshooting:
if latestCadenceHeight == config.EmulatorInitCadenceHeight { + l.Debug(). + Uint64("next_cadence_height", nextCadenceHeight). + Msg("adjusting next cadence height for Emulator") nextCadenceHeight -= 1 }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bootstrap/bootstrap.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bootstrap/bootstrap.go (1)
148-153
: Add test coverage for Emulator special case.Consider adding a test case to verify the behavior when connecting to a local Emulator, ensuring that the block height adjustment works as expected.
Would you like me to help generate the test case for this special case handling?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bootstrap/bootstrap.go
(1 hunks)
🔇 Additional comments (2)
bootstrap/bootstrap.go (2)
148-153
: LGTM! Well-documented special case handling for local Emulator.The implementation correctly handles the edge case where the local Emulator starts at block height 0, preventing the subscription attempt to non-existent block height 1.
128-135
: Verify block height validation for Emulator case.The block height validation might fail when using the Emulator and
latestCadenceHeight
is 0, as it attempts to load the block before applying the special case adjustment.Consider moving the Emulator special case handling before the block height validation or adding a specific validation bypass for the Emulator case.
I had an issue where the dockerized version of the emulator and gateway don't work together unless a transaction is executed on emulator and gateway is restarted (thus, starting from height 1 instead of 0). Seems like this fixes my issue! Thanks! |
Description
The Emulator always starts at block height 0, so if we try to subscribe at block height 1, we'll get an error, as it doesn't exist.
For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit