Documentation
¶
Index ¶
- Constants
- Variables
- func CreateTicketProof(pendingValidators safrole.ValidatorsData, entropy crypto.Hash, ...) (block.TicketProof, error)
- func IsSlotLeader(timeslot jamtime.Timeslot, sealingKeys safrole.SealingKeys, ...) (bool, error)
- func SealBlock(header *block.Header, sealKeys safrole.SealingKeys, entropy crypto.Hash, ...) error
- func SignBlock(header block.Header, ticketOrKey TicketOrKey, ...) (sealSignature crypto.BandersnatchSignature, ...)
- func SignBlockWithFallback(header block.Header, winningKey crypto.BandersnatchPublicKey, ...) (sealSignature crypto.BandersnatchSignature, ...)
- func SignBlockWithTicket(header block.Header, ticket block.Ticket, ...) (sealSignature crypto.BandersnatchSignature, ...)
- func VerifyBlockSeal(header *block.Header, sealKeys safrole.SealingKeys, ...) (bool, error)
- func VerifyBlockSignatures(header block.Header, ticketOrKey TicketOrKey, ...) (bool, error)
- func VerifyTicketProof(ringCommitment crypto.RingCommitment, entropy crypto.Hash, ...) (crypto.BandersnatchOutputHash, error)
- type AccumulationHistory
- type AccumulationOperand
- type AccumulationOutputLog
- type AccumulationQueue
- type AccumulationResult
- type AccumulationState
- type Assignment
- type BlockState
- type CoreAssignments
- type CoreAuthorizersPool
- type EntropyPool
- type Judgements
- type PendingAuthorizersQueue
- type PendingAuthorizersQueues
- type ServiceHashPair
- type State
- type TicketOrKey
- type WorkReportWithUnAccumulatedDependencies
Constants ¶
const ( TicketSealContext = "jam_ticket_seal" FallbackSealContext = "jam_fallback_seal" EntropyContext = "jam_entropy" )
const ( MaxTimeslotsForPreimage = 14400 // (L) Maximum number of timeslots for preimage metadata MaxRecentBlocks = 8 // (H) Maximum number of recent blocks to store MaxAuthorizersPerCore = 8 // (O) The maximum number of items in the authorizers pool. EntropyPoolSize = 4 // () Size of the entropy pool PendingAuthorizersQueueSize = 80 // (Q) The maximum number of items in the authorizers queue. MaximumNumberOfEntriesAccumulationQueue = 1024 // (S) The maximum number of entries in the accumulation queue. MaximumSizeIsAuthorizedCode = 64_000 // (WA) The maximum size of is-authorized code in octets SignatureContextGuarantee = "jam_guarantee" // X_G ≡ $jam_guarantee (11.27 v0.6.2) SignatureContextAvailable = "jam_available" // X_A ≡ $jam_available (11.14 v0.6.2) SignatureContextValid = "jam_valid" // X_A ≡ $jam_valid (10.4 v0.6.2) SignatureContextInvalid = "jam_invalid" // X_A ≡ $jam_invalid (10.4 v0.6.2) )
Variables ¶
var (
ErrBlockSealInvalidAuthor = errors.New("invalid block seal author")
)
Functions ¶
func CreateTicketProof ¶
func CreateTicketProof(pendingValidators safrole.ValidatorsData, entropy crypto.Hash, privateKey crypto.BandersnatchPrivateKey, attempt uint8) (block.TicketProof, error)
Creates a ticket proof as per equation 6.29 in the graypaper (v0.6.4) The ticket extrinic is a sequence of ticket proofs.
func IsSlotLeader ¶
func IsSlotLeader( timeslot jamtime.Timeslot, sealingKeys safrole.SealingKeys, entropy crypto.Hash, privateKey crypto.BandersnatchPrivateKey, ) (bool, error)
Determines if the holder of the given privateKey is the timeslot's block producer.
func SealBlock ¶
func SealBlock( header *block.Header, sealKeys safrole.SealingKeys, entropy crypto.Hash, privateKey crypto.BandersnatchPrivateKey, ) error
Attempts to a seal a block and add a block seal signature (Hs) and a VRFS signature (Hv) to the header. Uses either a ticket in most cases but uses a bandersnatch public key as a fallback. Checks that the private key given was either used to generate the winning ticket or otherwise if it's public key matches the winning public key in the case of fallback. Implements equations 6.15-6.20 in the graypaper. (v0.5.4)
func SignBlock ¶
func SignBlock( header block.Header, ticketOrKey TicketOrKey, privateKey crypto.BandersnatchPrivateKey, entropy crypto.Hash, ) ( sealSignature crypto.BandersnatchSignature, vrfSignature crypto.BandersnatchSignature, err error, )
Produces a seal signature and VRFS signature for the unsealed header bytes of the given header using either a winning ticket or a public key in the case of fallback. This will error if the private key can't be associated with the given ticket or public key in the case of fallback. Implements equations 6.15-6.20 in the graypaper. (v0.5.4)
func SignBlockWithFallback ¶
func SignBlockWithFallback( header block.Header, winningKey crypto.BandersnatchPublicKey, privateKey crypto.BandersnatchPrivateKey, entropy crypto.Hash, ) ( sealSignature crypto.BandersnatchSignature, vrfSignature crypto.BandersnatchSignature, err error, )
Produces a seal signature and VRFS signature for the unsealed header bytes of the given header using a winning public key. This is the fallback case. This will error if the private key can't be associated with the given public key. Implements equations 6.16 and 6.17-6.20 in the graypaper. (v0.5.4)
func SignBlockWithTicket ¶
func SignBlockWithTicket( header block.Header, ticket block.Ticket, privateKey crypto.BandersnatchPrivateKey, entropy crypto.Hash, ) ( sealSignature crypto.BandersnatchSignature, vrfSignature crypto.BandersnatchSignature, err error, )
Produces a seal signature and VRFS signature for the unsealed header bytes of the given header using a winning ticket. This will error if the private key can't be associated with the given ticket. Implements equations 6.15 and 6.17-6.20 in the graypaper. (v0.5.4)
func VerifyBlockSeal ¶
func VerifyBlockSeal( header *block.Header, sealKeys safrole.SealingKeys, validators safrole.ValidatorsData, entropy crypto.Hash, ) (bool, error)
func VerifyBlockSignatures ¶
func VerifyBlockSignatures( header block.Header, ticketOrKey TicketOrKey, currentValidators safrole.ValidatorsData, entropy crypto.Hash, ) (bool, error)
func VerifyTicketProof ¶
func VerifyTicketProof(ringCommitment crypto.RingCommitment, entropy crypto.Hash, ticket block.TicketProof) (crypto.BandersnatchOutputHash, error)
Verifies a ticket proof as per equation 6.29 in the graypaper (v0.6.4) Returns the output hash / identifier of the ticket if the proof is valid, or an error if it is not.
Types ¶
type AccumulationHistory ¶
type AccumulationHistory [jamtime.TimeslotsPerEpoch]map[crypto.Hash]struct{} // (equation 162 v0.4.5)
type AccumulationOperand ¶
type AccumulationOperand struct {
WorkPackageHash crypto.Hash // Work-package hash (h ∈ H)
SegmentRoot crypto.Hash // Segment root (e ∈ H)
AuthorizationHash crypto.Hash // Authorization hash (a ∈ H)
Output []byte // Output of the work report (o ∈ Y)
PayloadHash crypto.Hash // Payload hash (y ∈ H)
GasLimit uint64 `jam:"encoding=compact"` // Gas limit (g ∈ NG)
OutputOrError block.WorkResultOutputOrError // Output or error (d ∈ Y ∪ J)
}
AccumulationOperand represents a single operand for accumulation (eq. 12.19)
type AccumulationOutputLog ¶
type AccumulationOutputLog []ServiceHashPair
AccumulationOutputLog θ ∈ ⟦(NS, H)⟧ (eq. 7.4)
type AccumulationQueue ¶
type AccumulationQueue [jamtime.TimeslotsPerEpoch][]WorkReportWithUnAccumulatedDependencies
type AccumulationResult ¶
type AccumulationResult struct {
ServiceState *service.ServiceAccount // s - Optional updated service account state
ValidatorUpdates safrole.ValidatorsData // v - Single validator data set, not a slice
DeferredTransfers []service.DeferredTransfer // t - Deferred transfers sequence
AccumulationRoot *crypto.Hash // r - Optional accumulation result hash
CoreAssignments PendingAuthorizersQueues // c - Core authorizations queue
NewServices service.ServiceState // n - Newly created services mapping
PrivilegedUpdates struct {
ManagerServiceId block.ServiceId // m - Manager service
AssignServiceId block.ServiceId // a - Assign service
DesignateServiceId block.ServiceId // v - Designate service
GasAssignments map[block.ServiceId]uint64 // g - Gas assignments
}
}
AccumulationResult represents the result type from equation 162: A: NS → {s ∈ A?, v ∈ ⟦K⟧V, t ∈ ⟦T⟧, r ∈ H?, c ∈ C⟦H⟧QHC, n ∈ D⟨NS → A⟩, p ∈ {m,a,v ∈ NS, g ∈ D⟨NS → NG⟩}}
type AccumulationState ¶
type AccumulationState struct {
ServiceState service.ServiceState // Service accounts δ (d ∈ D⟨NS → A⟩)
ValidatorKeys safrole.ValidatorsData // Validator keys ι (i ∈ ⟦K⟧V)
PendingAuthorizersQueues [common.TotalNumberOfCores]PendingAuthorizersQueue // Queue of authorizers (q ∈ C⟦H⟧QHC)
PrivilegedServices service.PrivilegedServices // Privileges state (x ∈ (NS, NS, NS, D⟨NS → NG⟩))
}
AccumulationState characterization of state components (equation 174 v0.4.5)
type Assignment ¶
type Assignment struct {
WorkReport *block.WorkReport // Work-Report (w)
Time jamtime.Timeslot // time at which work-report was reported but not yet accumulated (t)
}
func (*Assignment) MarshalJAM ¶
func (a *Assignment) MarshalJAM() ([]byte, error)
TODO remove this when we refactor Assigment's WorkReport to not be a pointer.
func (*Assignment) UnmarshalJAM ¶
func (a *Assignment) UnmarshalJAM(reader io.Reader) error
TODO remove this when we refactor Assigment's WorkReport to not be a pointer.
type BlockState ¶
type BlockState struct {
HeaderHash crypto.Hash // Hash of the block header (h)
AccumulationResultMMR []*crypto.Hash // Accumulation-result MMR (s)
StateRoot crypto.Hash // State root (b)
WorkReportHashes map[crypto.Hash]crypto.Hash // Hashes of work-reports (p)
}
BlockState represents the details of the most recent blocks. (v0.4.5)
type CoreAssignments ¶
type CoreAssignments [common.TotalNumberOfCores]*Assignment
type CoreAuthorizersPool ¶
type CoreAuthorizersPool [common.TotalNumberOfCores][]crypto.Hash // TODO: Maximum length per core: MaxAuthorizersPerCore
type EntropyPool ¶
type EntropyPool [EntropyPoolSize]crypto.Hash
type Judgements ¶
type Judgements struct {
GoodWorkReports []crypto.Hash // Good work-reports (ψg) - Work-reports judged to be correct.
BadWorkReports []crypto.Hash // Bad work-reports (ψb) - Work-reports judged to be incorrect.
WonkyWorkReports []crypto.Hash // Wonky work-reports (ψw) - Work-reports whose validity is judged to be unknowable.
OffendingValidators []ed25519.PublicKey // Offending validators (ψp) - CurrentValidators who made a judgement found to be incorrect.
}
func (Judgements) MarshalJAM ¶
func (j Judgements) MarshalJAM() ([]byte, error)
Note that unmarshaling is not implemented given that we sort when serializing.
type PendingAuthorizersQueue ¶
type PendingAuthorizersQueue [PendingAuthorizersQueueSize]crypto.Hash
type PendingAuthorizersQueues ¶
type PendingAuthorizersQueues [common.TotalNumberOfCores]PendingAuthorizersQueue
type State ¶
type State struct {
Services service.ServiceState // Service accounts mapping (δ)
PrivilegedServices service.PrivilegedServices // Privileged services (𝝌): services which hold some privileged status.
ValidatorState validator.ValidatorState // Validator related state (κ, λ, ι, γ)
EntropyPool EntropyPool // On-chain Entropy pool (η): pool of entropy accumulators (also called randomness accumulators).
CoreAuthorizersPool CoreAuthorizersPool // Core authorizers pool (α): authorization requirement which work done on that core must satisfy at the time of being reported on-chain.
PendingAuthorizersQueues PendingAuthorizersQueues // Pending Core authorizers queue (φ): the queue which fills core authorizations.
CoreAssignments CoreAssignments // Core assignments (ρ): each of the cores’ currently assigned report, the availability of whose work-package must yet be assured by a super-majority of validators. This is what each core is up to right now, tracks the work-reports which have been reported but not yet accumulated, the identities of the guarantors who reported them and the time at which it was reported.
RecentBlocks []BlockState // Block-related state (β): details of the most recent blocks. TODO: Maximum length: MaxRecentBlocks
TimeslotIndex jamtime.Timeslot // Time-related state (τ): the most recent block’s slot index.
PastJudgements Judgements // PastJudgements (ψ) - past judgements on work-reports and validators.
ActivityStatistics validator.ActivityStatisticsState // Validator statistics (π) - The activity statistics for the validators.
AccumulationQueue AccumulationQueue // Accumulation Queue (ϑ) - ready (i.e. available and/or audited) but not-yet-accumulated work-reports. Each of these were made available at most one epoch ago but have or had unfulfilled dependencies.
AccumulationHistory AccumulationHistory // Accumulation history (ξ) - history of what has been accumulated for an epoch worth of work-reports. Mapping of work-package hash to segment-root.
AccumulationOutputLog AccumulationOutputLog // Accumulation Output Log (θ)
}
State represents the complete state of the system
type TicketOrKey ¶
type TicketOrKey interface {
TicketOrKeyType()
}
This represents a union of either a block.Ticket or a crypto.BandersnatchPublic key as a fallback.
type WorkReportWithUnAccumulatedDependencies ¶
type WorkReportWithUnAccumulatedDependencies struct {
WorkReport block.WorkReport
Dependencies map[crypto.Hash]struct{} // Set of Dependencies (Work-Package Hashes related to work report)
}