Documentation ¶
Index ¶
- Constants
- func CalculateNewJudgements(newTimeslot jamtime.Timeslot, disputes block.DisputeExtrinsic, ...) (state.Judgements, error)
- func InvokePVMOnTransfer(serviceState service.ServiceState, serviceIndex block.ServiceId, ...) service.ServiceAccount
- func PermuteAssignments(entropy crypto.Hash, timeslot jamtime.Timeslot) ([]uint32, error)
- func RotateSequence(sequence []uint32, n uint32) []uint32
- func UpdateRecentBlocks(headerHash crypto.Hash, priorStateRoot crypto.Hash, ...) (newRecentBlocks []state.BlockState, err error)
- func UpdateState(s *state.State, newBlock block.Block) error
- type Accumulator
- func (a *Accumulator) Delta1(accumulationState state.AccumulationState, workReports []block.WorkReport, ...) (state.AccumulationState, []service.DeferredTransfer, *crypto.Hash, uint64)
- func (a *Accumulator) InvokePVM(accState state.AccumulationState, serviceIndex block.ServiceId, gas uint64, ...) (state.AccumulationState, []service.DeferredTransfer, *crypto.Hash, uint64)
- func (a *Accumulator) ParallelDelta(initialAccState state.AccumulationState, workReports []block.WorkReport, ...) (uint64, state.AccumulationState, []service.DeferredTransfer, ServiceHashPairs)
- func (a *Accumulator) SequentialDelta(gasLimit uint64, workReports []block.WorkReport, ctx state.AccumulationState, ...) (uint32, state.AccumulationState, []service.DeferredTransfer, ServiceHashPairs)
- type SafroleInput
- type SafroleOutput
- type ServiceHashPair
- type ServiceHashPairs
Constants ¶
const ( OnTransferCost = 10 AccumulateCost = 10 )
Variables ¶
This section is empty.
Functions ¶
func CalculateNewJudgements ¶
func CalculateNewJudgements(newTimeslot jamtime.Timeslot, disputes block.DisputeExtrinsic, stateJudgements state.Judgements, validators validator.ValidatorState) (state.Judgements, error)
calculateNewJudgements Equation 23: ψ′ ≺ (ED, ψ) Equations 112-115:(v0.4.5) ψ'g ≡ ψg ∪ {r | {r, ⌊2/3V⌋ + 1} ∈ V} ψ'b ≡ ψb ∪ {r | {r, 0} ∈ V} ψ'w ≡ ψw ∪ {r | {r, ⌊1/3V⌋} ∈ V} ψ'o ≡ ψo ∪ {k | (r, k, s) ∈ c} ∪ {k | (r, v, k, s) ∈ f}
func InvokePVMOnTransfer ¶
func InvokePVMOnTransfer(serviceState service.ServiceState, serviceIndex block.ServiceId, transfers []service.DeferredTransfer) service.ServiceAccount
InvokePVMOnTransfer On-Transfer service-account invocation (ΨT). The only state alteration it facilitates are basic alteration to the storage of the subject account
func PermuteAssignments ¶
PermuteAssignments generates the core assignments for validators. Implements Equation (134 v0.4.5): P(e, t) ≡ R(F([⌊C ⋅ i/V⌋ ∣i ∈ NV], e), ⌊t mod E/R⌋)
func RotateSequence ¶
RotateSequence rotates the sequence by n positions modulo C. Implements Equation (133 v.0.4.5): R(c, n) ≡ [(x + n) mod C ∣ x ∈ shuffledSequence]
func UpdateRecentBlocks ¶
func UpdateRecentBlocks( headerHash crypto.Hash, priorStateRoot crypto.Hash, accumulationRoot crypto.Hash, intermediateRecentBlocks []state.BlockState, workPackageMapping map[crypto.Hash]crypto.Hash) (newRecentBlocks []state.BlockState, err error)
UpdateRecentBlocks updates β. It takes the final inputs from Equation 83: let n = {p, h ▸▸ H(H), b, s ▸▸ H_0} and produces Equation 84: β′ ≡ ←────── β† n_H. We separate out this logic for ease of testing aganist the recent history test vectors.
func UpdateState ¶
UpdateState updates the state TODO: all the calculations which are not dependent on intermediate / new state can be done in parallel
it might be worth making State immutable and make it so that UpdateState returns a new State with all the updated fields
Types ¶
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
func NewAccumulator ¶
func NewAccumulator(state *state.State, header *block.Header) *Accumulator
func (*Accumulator) Delta1 ¶
func (a *Accumulator) Delta1( accumulationState state.AccumulationState, workReports []block.WorkReport, privilegedGas map[block.ServiceId]uint64, serviceIndex block.ServiceId, ) (state.AccumulationState, []service.DeferredTransfer, *crypto.Hash, uint64)
Delta1 implements equation 180 (∆1)
func (*Accumulator) InvokePVM ¶
func (a *Accumulator) InvokePVM(accState state.AccumulationState, serviceIndex block.ServiceId, gas uint64, accOperand []state.AccumulationOperand) (state.AccumulationState, []service.DeferredTransfer, *crypto.Hash, uint64)
InvokePVM ΨA(U, N_S , N_G, ⟦O⟧) → (U, ⟦T⟧, H?, N_G) Equation (B.8)
func (*Accumulator) ParallelDelta ¶
func (a *Accumulator) ParallelDelta( initialAccState state.AccumulationState, workReports []block.WorkReport, privilegedGas map[block.ServiceId]uint64, ) ( uint64, state.AccumulationState, []service.DeferredTransfer, ServiceHashPairs, )
ParallelDelta implements equation 178 (∆*)
func (*Accumulator) SequentialDelta ¶
func (a *Accumulator) SequentialDelta( gasLimit uint64, workReports []block.WorkReport, ctx state.AccumulationState, privileged service.PrivilegedServices, ) ( uint32, state.AccumulationState, []service.DeferredTransfer, ServiceHashPairs, )
SequentialDelta implements equation 177 (∆+)
type SafroleInput ¶
type SafroleInput struct { // Next timeslot. TimeSlot jamtime.Timeslot // Ticket extrinsic (E_T). Tickets []block.TicketProof // Y(Hv) Entropy crypto.BandersnatchOutputHash // ψ′ Offenders []ed25519.PublicKey }
Input to UpdateSafroleState. Derived from the incoming block.
func NewSafroleInputFromBlock ¶
func NewSafroleInputFromBlock(block block.Block) (SafroleInput, error)
type SafroleOutput ¶
type SafroleOutput struct { // H_e EpochMark *block.EpochMarker // H_w WinningTicketMark *block.WinningTicketMarker }
Output from UpdateSafroleState.
func UpdateSafroleState ¶
func UpdateSafroleState( input SafroleInput, preTimeSlot jamtime.Timeslot, entropyPool state.EntropyPool, validatorState validator.ValidatorState, ) (state.EntropyPool, validator.ValidatorState, SafroleOutput, error)
Implements section 6 of the graypaper. Updates all state associated with the SAFROLE protocol. Implements key equations (v.0.4.5) γ′k ≡ Φ(ι) if e′ > e (58) γ′s ≡ Z(γa) if e′ = e + 1 ∧ m ≥ Y ∧ |γa| = E
γs if e′ = e F(η′2, κ′) otherwise (69)
He ≡ (η′1, [kb S k <− γ′k]) if e′ > e
∅ otherwise (72)
Hw ≡ Z(γa) if e′ = e ∧ m < Y ≤ m′ ∧ |γa| = E
∅ otherwise (73)
type ServiceHashPairs ¶
type ServiceHashPairs []ServiceHashPair
ServiceHashPairs (176) B ≡ {(NS , H)}