-
Notifications
You must be signed in to change notification settings - Fork 704
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
Allow calls to Options
before Verify
#2363
Merged
Merged
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ffbc96d
wip
StephenButtolph f6c0949
wip
StephenButtolph 3b817f2
wip
StephenButtolph 743e176
fix unit tests
StephenButtolph 6a35a2c
Merge branch 'dev' into options-before-verify
StephenButtolph 527c22c
fix typo
StephenButtolph 5edf87a
nit
StephenButtolph 7d49953
nit
StephenButtolph 6655c06
fix tests
StephenButtolph 8d266a8
Merge branch 'dev' into options-before-verify
StephenButtolph f0cfa6d
Merge branch 'dev' into options-before-verify
StephenButtolph 82b4338
Merge branch 'dev' into options-before-verify
StephenButtolph 0e37af9
Merge branch 'dev' into options-before-verify
StephenButtolph 2e863f4
Merge branch 'dev' into options-before-verify
StephenButtolph 92363ec
Allow errors from Options() calls
StephenButtolph dc6e557
add test
StephenButtolph 877bc76
Revert "Allow errors from Options() calls"
StephenButtolph fec4276
Revert "add test"
StephenButtolph 70df297
Remove error handling
StephenButtolph 8c5bb37
nits
StephenButtolph c6c4a8c
merged
StephenButtolph e1b3547
nits
StephenButtolph 67610a7
Merge branch 'dev' into options-before-verify
StephenButtolph 99dd506
merged
StephenButtolph 5a6bf3d
merged
StephenButtolph bc9e195
Merge branch 'master' into options-before-verify
StephenButtolph 7de3c5c
Merge branch 'master' into options-before-verify
StephenButtolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,11 +33,11 @@ type acceptor struct { | |
} | ||
|
||
func (a *acceptor) BanffAbortBlock(b *block.BanffAbortBlock) error { | ||
return a.abortBlock(b, "banff abort") | ||
return a.optionBlock(b, "banff abort") | ||
} | ||
|
||
func (a *acceptor) BanffCommitBlock(b *block.BanffCommitBlock) error { | ||
return a.commitBlock(b, "apricot commit") | ||
return a.optionBlock(b, "banff commit") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the wrong block previously |
||
} | ||
|
||
func (a *acceptor) BanffProposalBlock(b *block.BanffProposalBlock) error { | ||
|
@@ -50,11 +50,11 @@ func (a *acceptor) BanffStandardBlock(b *block.BanffStandardBlock) error { | |
} | ||
|
||
func (a *acceptor) ApricotAbortBlock(b *block.ApricotAbortBlock) error { | ||
return a.abortBlock(b, "apricot abort") | ||
return a.optionBlock(b, "apricot abort") | ||
} | ||
|
||
func (a *acceptor) ApricotCommitBlock(b *block.ApricotCommitBlock) error { | ||
return a.commitBlock(b, "apricot commit") | ||
return a.optionBlock(b, "apricot commit") | ||
} | ||
|
||
func (a *acceptor) ApricotProposalBlock(b *block.ApricotProposalBlock) error { | ||
|
@@ -116,46 +116,14 @@ func (a *acceptor) ApricotAtomicBlock(b *block.ApricotAtomicBlock) error { | |
return nil | ||
} | ||
|
||
func (a *acceptor) abortBlock(b block.Block, blockType string) error { | ||
func (a *acceptor) optionBlock(b block.Block, blockType string) error { | ||
parentID := b.Parent() | ||
parentState, ok := a.blkIDToState[parentID] | ||
if !ok { | ||
return fmt.Errorf("%w: %s", state.ErrMissingParentState, parentID) | ||
} | ||
|
||
if a.bootstrapped.Get() { | ||
if parentState.initiallyPreferCommit { | ||
a.metrics.MarkOptionVoteLost() | ||
} else { | ||
a.metrics.MarkOptionVoteWon() | ||
} | ||
Comment on lines
-127
to
-131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't set this value during execution, so the acceptor doesn't really have access to it anymore. |
||
} | ||
|
||
return a.optionBlock(b, parentState.statelessBlock, blockType) | ||
} | ||
|
||
func (a *acceptor) commitBlock(b block.Block, blockType string) error { | ||
parentID := b.Parent() | ||
parentState, ok := a.blkIDToState[parentID] | ||
if !ok { | ||
return fmt.Errorf("%w: %s", state.ErrMissingParentState, parentID) | ||
} | ||
|
||
if a.bootstrapped.Get() { | ||
if parentState.initiallyPreferCommit { | ||
a.metrics.MarkOptionVoteWon() | ||
} else { | ||
a.metrics.MarkOptionVoteLost() | ||
} | ||
} | ||
|
||
return a.optionBlock(b, parentState.statelessBlock, blockType) | ||
} | ||
|
||
func (a *acceptor) optionBlock(b, parent block.Block, blockType string) error { | ||
blkID := b.ID() | ||
parentID := parent.ID() | ||
|
||
defer func() { | ||
// Note: we assume this block's sibling doesn't | ||
// need the parent's state when it's rejected. | ||
|
@@ -164,7 +132,7 @@ func (a *acceptor) optionBlock(b, parent block.Block, blockType string) error { | |
}() | ||
|
||
// Note that the parent must be accepted first. | ||
if err := a.commonAccept(parent); err != nil { | ||
if err := a.commonAccept(parentState.statelessBlock); err != nil { | ||
return err | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is the whole point of the PR