-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GRANDPA equivocation (#747)
Implement GRANDPA equivocation
- Loading branch information
Showing
7 changed files
with
168 additions
and
28 deletions.
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
23 changes: 23 additions & 0 deletions
23
src/main/java/com/limechain/network/protocol/grandpa/messages/vote/GrandpaEquivocation.java
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.limechain.network.protocol.grandpa.messages.vote; | ||
|
||
import io.emeraldpay.polkaj.types.Hash256; | ||
import io.emeraldpay.polkaj.types.Hash512; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.math.BigInteger; | ||
|
||
@Getter | ||
@Builder | ||
public class GrandpaEquivocation { | ||
private BigInteger setId; | ||
private byte equivocationStage; | ||
private BigInteger roundNumber; | ||
private Hash256 authorityPublicKey; | ||
private Hash256 firstBlockHash; | ||
private BigInteger firstBlockNumber; | ||
private Hash512 firstSignature; | ||
private Hash256 secondBlockHash; | ||
private BigInteger secondBlockNumber; | ||
private Hash512 secondSignature; | ||
} |
36 changes: 36 additions & 0 deletions
36
.../com/limechain/network/protocol/grandpa/messages/vote/GrandpaEquivocationScaleWriter.java
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.limechain.network.protocol.grandpa.messages.vote; | ||
|
||
import io.emeraldpay.polkaj.scale.ScaleCodecWriter; | ||
import io.emeraldpay.polkaj.scale.ScaleWriter; | ||
import io.emeraldpay.polkaj.scale.writer.UInt64Writer; | ||
|
||
import java.io.IOException; | ||
|
||
public class GrandpaEquivocationScaleWriter implements ScaleWriter<GrandpaEquivocation> { | ||
|
||
private static final GrandpaEquivocationScaleWriter INSTANCE = new GrandpaEquivocationScaleWriter(); | ||
|
||
private final UInt64Writer uint64Writer; | ||
|
||
private GrandpaEquivocationScaleWriter() { | ||
this.uint64Writer = new UInt64Writer(); | ||
} | ||
|
||
public static GrandpaEquivocationScaleWriter getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public void write(ScaleCodecWriter writer, GrandpaEquivocation grandpaEquivocation) throws IOException { | ||
uint64Writer.write(writer, grandpaEquivocation.getSetId()); | ||
writer.writeByte(grandpaEquivocation.getEquivocationStage()); | ||
uint64Writer.write(writer, grandpaEquivocation.getRoundNumber()); | ||
writer.writeByteArray(grandpaEquivocation.getAuthorityPublicKey().getBytes()); | ||
uint64Writer.write(writer, grandpaEquivocation.getFirstBlockNumber()); | ||
writer.writeByteArray(grandpaEquivocation.getFirstBlockHash().getBytes()); | ||
writer.writeByteArray(grandpaEquivocation.getFirstSignature().getBytes()); | ||
uint64Writer.write(writer, grandpaEquivocation.getSecondBlockNumber()); | ||
writer.writeByteArray(grandpaEquivocation.getSecondBlockHash().getBytes()); | ||
writer.writeByteArray(grandpaEquivocation.getSecondSignature().getBytes()); | ||
} | ||
} |
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