-
Notifications
You must be signed in to change notification settings - Fork 129
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
feat(lib/grandpa): Include equivocatory nodes while creating justification #1911
Merged
Merged
Changes from 4 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
ef6546f
feat: include equivocatory nodes while creating just
EclesioMeloJunior 35fea30
chore: remove unecessary error return
EclesioMeloJunior 1ceb49d
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior 64b96fc
chore: undo condition format
EclesioMeloJunior c2bf981
chore: use equivocatory votes on threshold count
EclesioMeloJunior 5039268
chore: add unsupported subround error
EclesioMeloJunior 0100140
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior e2bafd8
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior b627509
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior d626dae
chore: remove unecessary check
EclesioMeloJunior b0f3c27
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior 7d21850
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior e6299b5
chore: remove eqv votes and use the eqv voters
EclesioMeloJunior bbe8ba7
Merge branch 'eclesio/include-eqv-votes' of github.com:ChainSafe/goss…
EclesioMeloJunior 0ed4ce5
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior a5f4684
chore: remove unecessary convertion
EclesioMeloJunior c9c278c
Merge branch 'eclesio/include-eqv-votes' of github.com:ChainSafe/goss…
EclesioMeloJunior 0274ef9
chore: export ErrUnsupportedSubround
EclesioMeloJunior 0b0c524
chore: improve code reading
EclesioMeloJunior 6e5dd0b
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior de8a4ed
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior f58afce
chore: add tests to grandpa.createJustification func
EclesioMeloJunior 56f3d05
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior ad81602
chore: add tests to grandpa message handler files
EclesioMeloJunior c93a134
chore: fix ci warns
EclesioMeloJunior 7abd69b
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior 0301b49
chore: put back a condition to check enough precommits in the justifi…
EclesioMeloJunior ec61d8e
chore: check if the equivocatory votes are on justification
EclesioMeloJunior a7d9ecb
chore: fix the fakeAuthorities format
EclesioMeloJunior f1f4d04
chore: removing parallel and uncoment Err...
EclesioMeloJunior 5730645
chore: adjusting the equivocatory and prevote testing
EclesioMeloJunior 69ee68d
chore: fix lint warns
EclesioMeloJunior 5091650
chore: address nit comments
EclesioMeloJunior 349080b
chore: adjust test asserts
EclesioMeloJunior 32856fa
chore: adjust naming
EclesioMeloJunior c10dc71
chore: mock time.Unix in tests
EclesioMeloJunior a0dd708
chore: add test to equivocatory voters on to VerifyBlockJustification
EclesioMeloJunior 37b2ba3
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior add5820
chore: adjust testing
EclesioMeloJunior e3546d8
chore: check errors
EclesioMeloJunior 9ac7015
chore: changing the style to checking ok variable
EclesioMeloJunior 3a4ee28
Merge branch 'development' into eclesio/include-eqv-votes
EclesioMeloJunior c675cab
chore: fix conflicts and ignore testing lint warns
EclesioMeloJunior 9490f66
chore: check err
EclesioMeloJunior f3abef8
chore: fix runtime not found problems
EclesioMeloJunior 1bec0db
chore: removing unused imports
EclesioMeloJunior 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,7 +697,7 @@ func (s *Service) determinePreCommit() (*Vote, error) { | |
return &pvb, nil | ||
} | ||
|
||
// isFinalisable returns true is the round is finalisable, false otherwise. | ||
// isFinalisable returns true if the round is finalisable, false otherwise. | ||
func (s *Service) isFinalisable(round uint64) (bool, error) { | ||
var pvb Vote | ||
var err error | ||
|
@@ -766,16 +766,10 @@ func (s *Service) finalise() error { | |
s.bestFinalCandidate[s.state.round] = bfc | ||
|
||
// create prevote justification ie. list of all signed prevotes for the bfc | ||
pvs, err := s.createJustification(bfc.Hash, prevote) | ||
if err != nil { | ||
return err | ||
} | ||
pvs := s.createJustification(bfc.Hash, prevote) | ||
|
||
// create precommit justification ie. list of all signed precommits for the bfc | ||
pcs, err := s.createJustification(bfc.Hash, precommit) | ||
if err != nil { | ||
return err | ||
} | ||
pcs := s.createJustification(bfc.Hash, precommit) | ||
|
||
pcj, err := scale.Marshal(*newJustification(s.state.round, bfc.Hash, bfc.Number, pcs)) | ||
if err != nil { | ||
|
@@ -810,21 +804,23 @@ func (s *Service) finalise() error { | |
// createJustification collects the signed precommits received for this round and turns them into | ||
// a justification by adding all signed precommits that are for the best finalised candidate or | ||
// a descendent of the bfc | ||
func (s *Service) createJustification(bfc common.Hash, stage Subround) ([]SignedVote, error) { | ||
func (s *Service) createJustification(bfc common.Hash, stage Subround) []SignedVote { | ||
var ( | ||
spc *sync.Map | ||
err error | ||
just []SignedVote | ||
eqv map[ed25519.PublicKeyBytes][]*SignedVote | ||
) | ||
|
||
switch stage { | ||
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. should probably throw an error if you pass an unsupported 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. added |
||
case prevote: | ||
spc = s.prevotes | ||
eqv = make(map[ed25519.PublicKeyBytes][]*SignedVote, len(s.pvEquivocations)) | ||
case precommit: | ||
spc = s.precommits | ||
eqv = make(map[ed25519.PublicKeyBytes][]*SignedVote, len(s.pcEquivocations)) | ||
} | ||
|
||
// TODO: use equivacatory votes to create justification as well (#1667) | ||
spc.Range(func(_, value interface{}) bool { | ||
pc := value.(*SignedVote) | ||
var isDescendant bool | ||
|
@@ -842,11 +838,24 @@ func (s *Service) createJustification(bfc common.Hash, stage Subround) ([]Signed | |
return true | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
for _, votes := range eqv { | ||
for _, vote := range votes { | ||
var signedVote SignedVote = *vote | ||
qdm12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isDescendant, err := s.blockState.IsDescendantOf(bfc, signedVote.Vote.Hash) | ||
|
||
if err != nil { | ||
break | ||
} | ||
|
||
if !isDescendant { | ||
continue | ||
} | ||
|
||
just = append(just, signedVote) | ||
} | ||
} | ||
|
||
return just, nil | ||
return just | ||
} | ||
|
||
// derivePrimary returns the primary for the current round | ||
|
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
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.
what's the reasoning behind removing the error?
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.
Oh, my bad, I realized that the error assignment inside the
.Range
function has been used lines below. I'm adding it back