From 619850aa7a222aa4bdfe55da8e6b20e10a3edffd Mon Sep 17 00:00:00 2001 From: Emanuel Pargov Date: Tue, 30 Jul 2024 16:03:02 +0300 Subject: [PATCH] Add dispute structs --- internal/block/block.go | 1 + internal/block/dispute.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 internal/block/dispute.go diff --git a/internal/block/block.go b/internal/block/block.go index a7eb69a1..78f5c9e4 100644 --- a/internal/block/block.go +++ b/internal/block/block.go @@ -9,4 +9,5 @@ type Block struct { // Extrinsic represents the block extrinsic data type Extrinsic struct { ET []*TicketProof + ED *DisputeExtrinsic } diff --git a/internal/block/dispute.go b/internal/block/dispute.go new file mode 100644 index 00000000..728e23bd --- /dev/null +++ b/internal/block/dispute.go @@ -0,0 +1,39 @@ +package block + +import "github.com/eigerco/strawberry/internal/crypto" + +const ( + judgmentSignatureSize = 64 // Size of Ed25519 signature +) + +type DisputeExtrinsic struct { + Verdicts []Verdict + Culprits []Culprit + Faults []Fault +} + +type Verdict struct { + ReportHash crypto.Hash // H, hash of the work report + EpochIndex uint32 // ⌊τ/E⌋ - N2, epoch index + Judgments []Judgment // ⟦{⊺,⊥},NV,E⟧⌊2/3V⌋+1 +} + +type Culprit struct { + ReportHash crypto.Hash // H, hash of the work report + ValidatorEd25519PublicKey crypto.Ed25519PublicKey // He + Signature [judgmentSignatureSize]byte // E +} + +type Fault struct { + ReportHash crypto.Hash // H, hash of the work report + IsValid bool // {⊺,⊥} + ValidatorEd25519PublicKey crypto.Ed25519PublicKey // He + Signature [judgmentSignatureSize]byte // E +} + +// Judgment represents a single judgment with a signature +type Judgment struct { + IsValid bool // v: {⊺,⊥} + ValidatorIndex uint16 // i: NV + Signature [judgmentSignatureSize]byte // s: E +}