-
Notifications
You must be signed in to change notification settings - Fork 25
Consider contracts for checkpoint #901
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
Conversation
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.
Pull request overview
This pull request fixes an issue where hosts with existing contracts performing instant sync could leave their contracts in a bad state if the checkpoint is before their first v2 contract. The solution adjusts the checkpoint based on the negotiation height of the first active or pending contract.
Key Changes:
- Added
FirstContractHeight()database method to retrieve the earliest negotiation height of active or pending v2 contracts - Modified instant sync logic to consider contract heights when determining the sync checkpoint
- Added new explorer API method
TipHeight()to retrieve chain index at a specific height
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| persist/sqlite/contracts.go | Implements FirstContractHeight() to query the minimum negotiation height of active/pending contracts |
| persist/sqlite/contracts_test.go | Adds test coverage for the new FirstContractHeight() method with various contract statuses |
| explorer/explorer.go | Adds TipHeight() method to retrieve chain index at a given height from the explorer API |
| cmd/hostd/run.go | Updates instant sync logic to adjust checkpoint based on contract heights, falling back one day of blocks before the first contract |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8a0553e to
d3fbd2f
Compare
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.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| log.Debug("using earlier checkpoint height from contracts", zap.Uint64("height", checkpointHeight)) | ||
| } | ||
|
|
||
| blocksPerDay := uint64(24 * time.Hour / network.BlockInterval) |
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.
Is this just a leeway?
peterjan
left a comment
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.
Missing a changelog entry but otherwise LGTM 👍
d3fbd2f to
c1c0323
Compare
Currently if a host with existing contracts instant syncs, it can leave their contracts in a bad state if the checkpoint is before their first v2 contract. This adjusts the checkpoint based on the negotiation height of the first active or pending contract.