Documentation
¶
Index ¶
- Constants
- func CountPositiveJudgments(judgments [common.ValidatorsSuperMajority]Judgement) int
- type Assurance
- type AssurancesExtrinsic
- type Block
- type CredentialSignature
- type Culprit
- type DisputeExtrinsic
- type EpochMarker
- type Extrinsic
- type Fault
- type Guarantee
- type GuaranteesExtrinsic
- type Header
- type Judgement
- type Preimage
- type PreimageExtrinsic
- type RefinementContext
- type RefinementContextAnchor
- type RefinementContextLookupAnchor
- type ServiceId
- type Ticket
- type TicketExtrinsic
- type TicketProof
- type ValidatorKeys
- type Verdict
- type WinningTicketMarker
- type WorkPackageSpecification
- type WorkReport
- type WorkResult
- type WorkResultError
- type WorkResultOutputOrError
Constants ¶
const AvailBitfieldBytes = (common.TotalNumberOfCores + 7) / 8 // (cores-count + 7) / 8
const (
TicketProofSize = 784 // Size of F̄[]γz⟨XT ⌢ η′2 r⟩
)
Variables ¶
This section is empty.
Functions ¶
func CountPositiveJudgments ¶
func CountPositiveJudgments(judgments [common.ValidatorsSuperMajority]Judgement) int
CountPositiveJudgments counts the number of positive judgments in a verdict
Types ¶
type Assurance ¶
type Assurance struct {
Anchor crypto.Hash // Parent block hash (a ∈ H)
Bitfield [AvailBitfieldBytes]byte // Bitstring of assurances, one bit per core (f ∈ B_C)
ValidatorIndex uint16 // Index of the attesting validator (v ∈ N_V)
Signature crypto.Ed25519Signature // Ed25519 signature (s ∈ E)
}
Assurance represents a single validator's attestation of data availability for work reports on specific cores. It is part of the Assurances Extrinsic (E_A). Each Assurance contains: - An anchor to the parent block - A bitstring flag indicating availability for each core - The index of the attesting validator (0 to 1023) - A signature validating the assurance Assurances must be ordered by validator index in the extrinsic.
func (Assurance) SetCoreIndexes ¶
type AssurancesExtrinsic ¶
type AssurancesExtrinsic []Assurance
type Block ¶
Block represents the main block structure
func BlockFromBytes ¶
BlockFromBytes unmarshals a block from Jam encoded bytes
type CredentialSignature ¶
type CredentialSignature struct {
ValidatorIndex uint16 // Index of the validator providing this signature
Signature crypto.Ed25519Signature // The Ed25519 signature
}
CredentialSignature represents a single signature within the credential
type DisputeExtrinsic ¶
type EpochMarker ¶
type EpochMarker struct {
Entropy crypto.Hash
TicketsEntropy crypto.Hash
Keys [common.NumberOfValidators]ValidatorKeys
}
EpochMarker consists of epoch randomness and a sequence of Bandersnatch keys defining the Bandersnatch validator keys (kb) beginning in the next epoch.
type Extrinsic ¶
type Extrinsic struct {
ET TicketExtrinsic
EP PreimageExtrinsic
EG GuaranteesExtrinsic
EA AssurancesExtrinsic
ED DisputeExtrinsic
}
Extrinsic represents the block extrinsic data
type Guarantee ¶
type Guarantee struct {
WorkReport WorkReport // The work report being guaranteed
Timeslot jamtime.Timeslot // The timeslot when this guarantee was made
Credentials []CredentialSignature // The credentials proving the guarantee's validity
}
Guarantee represents a single guarantee within the E_G extrinsic
type GuaranteesExtrinsic ¶
type GuaranteesExtrinsic struct {
Guarantees []Guarantee
}
GuaranteesExtrinsic represents the E_G extrinsic
type Header ¶
type Header struct {
ParentHash crypto.Hash // Hp
PriorStateRoot crypto.Hash // Hr
ExtrinsicHash crypto.Hash // Hx
TimeSlotIndex jamtime.Timeslot // Ht
EpochMarker *EpochMarker // He
WinningTicketsMarker *WinningTicketMarker // Hw
OffendersMarkers []ed25519.PublicKey // Ho, the culprit's and fault's public keys
BlockAuthorIndex uint16 // Hi
VRFSignature crypto.BandersnatchSignature // Hv
BlockSealSignature crypto.BandersnatchSignature // Hs
}
Header as defined in the section 5 in the paper
func HeaderFromBytes ¶
HeaderFromBytes unmarshals a header from Jam encoded bytes
type Judgement ¶
type Judgement struct {
IsValid bool // v: {⊺,⊥}
ValidatorIndex uint16 // i: NV
Signature crypto.Ed25519Signature // s: E
}
Judgement represents a single judgment with a signature
type PreimageExtrinsic ¶
type PreimageExtrinsic []Preimage
type RefinementContext ¶
type RefinementContext struct {
Anchor RefinementContextAnchor // Historical block anchor
LookupAnchor RefinementContextLookupAnchor // Historical block anchor
PrerequisiteWorkPackage []crypto.Hash // Prerequisite work package (p)
}
RefinementContext describes the context of the chain at the point that the report’s corresponding work-package was evaluated. 11.4 GP 0.5.4
type RefinementContextAnchor ¶
type Ticket ¶
type Ticket struct {
Identifier crypto.BandersnatchOutputHash // y ∈ H 32bytes hash
EntryIndex uint8 // r ∈ Nn (0, 1)
}
Ticket represents a single ticket (C in equation 50)
func (Ticket) TicketOrKeyType ¶
func (t Ticket) TicketOrKeyType()
type TicketExtrinsic ¶
type TicketExtrinsic struct {
TicketProofs []TicketProof
}
TicketExtrinsic represents the E_T extrinsic
type TicketProof ¶
type TicketProof struct {
EntryIndex uint8 // r ∈ Nn (0, 1)
Proof [TicketProofSize]byte // RingVRF proof
}
TicketProof represents a proof of a valid ticket
type ValidatorKeys ¶
type ValidatorKeys struct {
Bandersnatch crypto.BandersnatchPublicKey
Ed25519 ed25519.PublicKey
}
type WinningTicketMarker ¶
type WinningTicketMarker [jamtime.TimeslotsPerEpoch]Ticket
type WorkPackageSpecification ¶
type WorkPackageSpecification struct {
WorkPackageHash crypto.Hash // Hash of the work-package (h)
AuditableWorkBundleLength uint32 // Length of the auditable work bundle (l)
ErasureRoot crypto.Hash // Erasure root (u) - is the root of a binary Merkle tree which functions as a commitment to all data required for the auditing of the report and for use by later workpackages should they need to retrieve any data yielded. It is thus used by assurers to verify the correctness of data they have been sent by guarantors, and it is later verified as correct by auditors.
SegmentRoot crypto.Hash // Segment root (e) - root of a constant-depth, left-biased and zero-hash-padded binary Merkle tree committing to the hashes of each of the exported segments of each work-item. These are used by guarantors to verify the correctness of any reconstructed segments they are called upon to import for evaluation of some later work-package.
SegmentCount uint16 // Segment count (n)
}
type WorkReport ¶
type WorkReport struct {
WorkPackageSpecification WorkPackageSpecification // Work-package specification (s)
RefinementContext RefinementContext // Refinement context (x)
CoreIndex uint16 `jam:"encoding=compact"` // Core index (c) - Max value: TotalNumberOfCores
AuthorizerHash crypto.Hash // HeaderHash of the authorizer (a)
Output []byte // Output of the work report (o)
SegmentRootLookup map[crypto.Hash]crypto.Hash // A segment-root lookup dictionary (l ∈ D⟨H → H⟩)
WorkResults []WorkResult // Results of the evaluation of each of the items in the work-package (r) - Min value: MinWorkPackageResultsSize. Max value: MaxWorkPackageResultsSize.
AuthGasUsed uint64 `jam:"encoding=compact"` // The amount of gas used during authorization (g)
}
WorkReport represents a work report in the JAM state (equation 11.2 v0.5.4)
func (*WorkReport) Encode ¶
func (w *WorkReport) Encode() ([]byte, error)
func (*WorkReport) OutputSizeIsValid ¶
func (w *WorkReport) OutputSizeIsValid() bool
type WorkResult ¶
type WorkResult struct {
ServiceId ServiceId // Service ID (s) - The index of the service whose state is to be altered and thus whose refine code was already executed.
ServiceHashCode crypto.Hash // Hash of the service code (c) - The hash of the code of the service at the time of being reported.
PayloadHash crypto.Hash // Hash of the payload (y) - The hash of the payload within the work item which was executed in the refine stage to give this result. Provided to the accumulation logic of the service later on.
GasPrioritizationRatio uint64 // Gas prioritization ratio (g) - used when determining how much gas should be allocated to execute of this item’s accumulate.
Output WorkResultOutputOrError // Output of the work result (d) ∈ Y ∪ J: Output or error (Y is the set of octet strings, J is the set of work execution errors)
GasUsed uint64 `jam:"encoding=compact"` // (u) the actual amount of gas used during refinement
ImportsCount uint16 `jam:"encoding=compact"` // (i) the number of segments imported from
ExtrinsicCount uint16 `jam:"encoding=compact"` // (x) the number of the extrinsics used in computing the workload
ExtrinsicSize uint32 `jam:"encoding=compact"` // (z) total size in octets of the extrinsics used in computing the workload
ExportsCount uint16 `jam:"encoding=compact"` // (e) the number of segments exported into
}
WorkResult is the data conduit by which services’ states may be altered through the computation done within a work-package. L ≡ (s ∈ NS, c ∈ H, y ∈ H, g ∈ NG, d ∈ Y ∪ J, u ∈ NG, i ∈ N, x ∈ N, z ∈ N, e ∈ N) (equation 11.6)
func NewErrorWorkResult ¶
func NewErrorWorkResult(serviceId ServiceId, serviceHashCode, payloadHash crypto.Hash, gasPrioritizationRatio uint64, errorResult WorkResultError) WorkResult
NewErrorWorkResult creates a new error WorkResult
func NewSuccessfulWorkResult ¶
func NewSuccessfulWorkResult(serviceId ServiceId, serviceHashCode, payloadHash crypto.Hash, gasPrioritizationRatio uint64, output []byte) WorkResult
NewSuccessfulWorkResult creates a new successful WorkResult
func (WorkResult) IsSuccessful ¶
func (wer WorkResult) IsSuccessful() bool
IsSuccessful checks if the work result is successful
type WorkResultError ¶
type WorkResultError uint8
WorkResultError represents the type of error that occurred during work execution
const ( NoError WorkResultError = iota // Represents no error, successful execution OutOfGas // ∞ Out-of-gas error UnexpectedTermination // ☇ Unexpected program termination. InvalidNumberOfExports // ⊚ The number of exports made was invalidly reported CodeNotAvailable // BAD The service’s code was not available for lookup in state at the posterior state of the lookup-anchor block. CodeTooLarge // BIG The code was available but was beyond the maximum size allowed WC. )
type WorkResultOutputOrError ¶
type WorkResultOutputOrError struct {
Inner any
}
WorkResultOutputOrError represents either the successful output or an error from a work result
func (WorkResultOutputOrError) IndexValue ¶
func (wer WorkResultOutputOrError) IndexValue() (uint, any, error)
func (*WorkResultOutputOrError) SetValue ¶
func (wer *WorkResultOutputOrError) SetValue(value any) error