-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement GRANDPA equivocation #747
Conversation
|
||
import java.math.BigInteger; | ||
|
||
@Data |
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.
I'd add lombok's builder annotation here. https://projectlombok.org/features/Builder
Runtime runtime = warpSyncState.getRuntime(); | ||
SignedVote firstSignedVote = votes.get(authorityPublicKey); | ||
|
||
GrandpaEquivocation grandpaEquivocation = new GrandpaEquivocation(); |
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.
Use builder here.
|
||
if (votes.containsKey(authorityPublicKey)) { | ||
equivocations.computeIfAbsent(authorityPublicKey, _ -> new HashSet<>()).add(signedVote); | ||
Runtime runtime = warpSyncState.getRuntime(); |
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.
Runtime runtime = warpSyncState.getRuntime(); | |
BlockState blockState = stateManager.getBlockState(); | |
Runtime runtime = bs.getRuntime(bs.getHighestFinalizedHash()); |
Optional<OpaqueKeyOwnershipProof> opaqueKeyOwnershipProof = runtime.generateGrandpaKeyOwnershipProof(voteMessageSetId, authorityPublicKey.getBytes()); | ||
opaqueKeyOwnershipProof.ifPresentOrElse( | ||
key -> runtime.submitReportGrandpaEquivocationUnsignedExtrinsic(grandpaEquivocation, key.getProof()), | ||
() -> log.warning(String.format( |
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.
If generateGrandpaKeyOwnershipProof() fails we'll log Failure to report Grandpa vote equivocation for authority: %s.
and still return true.
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.
Yeah because equivocation is still exist we just can't report it
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.
The outer log in GrandpaMessageHandler
is a bit misleading then.
String.format("Reported vote equivocation for round %s, set %s, block hash %s, block number %s", voteMessageSetId, voteMessageSetId, signedMessage.getBlockHash(), signedMessage.getBlockNumber()));
@@ -91,6 +93,28 @@ public void submitReportEquivocationUnsignedExtrinsic(BlockEquivocationProof blo | |||
} | |||
} | |||
|
|||
@Override | |||
public Optional<OpaqueKeyOwnershipProof> generateGrandpaKeyOwnershipProof(BigInteger authoritySetId, | |||
byte[] authorityPublicKey) { |
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.
Not sure if this is because of github's UI or the line is not formated.
2109db3
to
c07a806
Compare
|
Implement GRANDPA equivocation
Checklist: