json

package
v0.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

This package does its best to ensure deterministic encoding by sorting various fields as specified by the GP appendix D. This allows for more useful JSON diffing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpBlockSnapshot

func DumpBlockSnapshot(b block.Block) string

func DumpStateSnapshot

func DumpStateSnapshot(state state.State) string

func RestoreBlockSnapshot

func RestoreBlockSnapshot(b []byte) block.Block

func RestoreStateSnapshot

func RestoreStateSnapshot(b []byte) state.State

Types

type Account

type Account struct {
	ID   uint32      `json:"id"`
	Data AccountData `json:"data"`
}

type AccountData

type AccountData struct {
	Service    ServiceInfo      `json:"service"`
	Preimages  []PreimageInfo   `json:"preimages"`
	LookupMeta []LookupMetaInfo `json:"lookup_meta"`
	Storage    *Storage         `json:"storage"`
}

func NewAccountData

func NewAccountData(account service.ServiceAccount) AccountData

func (AccountData) To

type Accounts

type Accounts []Account

func NewAccounts

func NewAccounts(accounts service.ServiceState) Accounts

func (Accounts) To

func (a Accounts) To() service.ServiceState

type AccumulatedQueue

type AccumulatedQueue [][]string

func NewAccumulatedQueue

func NewAccumulatedQueue(history state.AccumulationHistory) AccumulatedQueue

func (AccumulatedQueue) To

type ActivityStatistics

type ActivityStatistics struct {
	ValsCurrent []ValidatorStatistics `json:"vals_current"`
	ValsLast    []ValidatorStatistics `json:"vals_last"`
	Cores       []CoreStatistics      `json:"cores"`
	Services    ServiceStatistics     `json:"services"`
}

func (ActivityStatistics) To

type Assurance

type Assurance struct {
	Anchor         string `json:"anchor"`
	Bitfield       string `json:"bitfield"`
	ValidatorIndex uint16 `json:"validator_index"`
	Signature      string `json:"signature"`
}

type AuthPools

type AuthPools [][]string

func NewAuthPools

func NewAuthPools(pools state.CoreAuthorizersPool) AuthPools

func (AuthPools) To

type AuthQueues

type AuthQueues [][]string

func NewAuthQueues

func NewAuthQueues(queues state.PendingAuthorizersQueues) AuthQueues

func (AuthQueues) To

type AvailabilityAssigment

type AvailabilityAssigment struct {
	Report  *WorkReport `json:"report,omitempty"`
	Timeout uint32      `json:"timeout"`
}

type AvailabilityAssigments

type AvailabilityAssigments []*AvailabilityAssigment

func NewAvailabilityAssigments

func NewAvailabilityAssigments(assignments state.CoreAssignments) AvailabilityAssigments

func (AvailabilityAssigments) To

type Block

type Block struct {
	Header    Header    `json:"header"`
	Extrinsic Extrinsic `json:"extrinsic"`
}

func NewBlock

func NewBlock(b block.Block) Block

func (Block) To

func (b Block) To() block.Block

type BlockHistory

type BlockHistory []BlockInfo

func NewBlockHistory

func NewBlockHistory(blocks []state.BlockState) BlockHistory

func (BlockHistory) To

func (bh BlockHistory) To() []state.BlockState

type BlockInfo

type BlockInfo struct {
	HeaderHash string     `json:"header_hash"`
	MMR        MMR        `json:"mmr"`
	StateRoot  string     `json:"state_root"`
	Reported   []Reported `json:"reported"`
}

func NewBlockInfo

func NewBlockInfo(blockState state.BlockState) BlockInfo

func (BlockInfo) To

func (bi BlockInfo) To() state.BlockState

type CoreStatistics

type CoreStatistics struct {
	DALoad         uint32 `json:"da_load"`
	Popularity     uint16 `json:"popularity"`
	Imports        uint16 `json:"imports"`
	Exports        uint16 `json:"exports"`
	ExtrinsicSize  uint32 `json:"extrinsic_size"`
	ExtrinsicCount uint16 `json:"extrinsic_count"`
	BundleSize     uint32 `json:"bundle_size"`
	GasUsed        uint64 `json:"gas_used"`
}

type Culprit

type Culprit struct {
	Target    string `json:"target"`
	Key       string `json:"key"`
	Signature string `json:"signature"`
}

type DisputeRecords

type DisputeRecords struct {
	Good      []string `json:"good"`
	Bad       []string `json:"bad"`
	Wonky     []string `json:"wonky"`
	Offenders []string `json:"offenders"`
}

func NewDisputeRecords

func NewDisputeRecords(judgements state.Judgements) DisputeRecords

func (DisputeRecords) To

type Disputes

type Disputes struct {
	Verdicts []Verdict `json:"verdicts"`
	Culprits []Culprit `json:"culprits"`
	Faults   []Fault   `json:"faults"`
}

type EntropyPool

type EntropyPool []string

func NewEntropyPool

func NewEntropyPool(entropyPool state.EntropyPool) EntropyPool

func (EntropyPool) To

func (ep EntropyPool) To() state.EntropyPool

type EpochMark

type EpochMark struct {
	Entropy        string               `json:"entropy"`
	TicketsEntropy string               `json:"tickets_entropy"`
	Validators     []EpochMarkValidator `json:"validators"`
}

type EpochMarkValidator

type EpochMarkValidator struct {
	Bandersnatch string `json:"bandersnatch"`
	Ed25519      string `json:"ed25519"`
}

type Extrinsic

type Extrinsic struct {
	Tickets    []TicketProof `json:"tickets"`
	Preimages  []Preimage    `json:"preimages"`
	Guarantees []Guarantee   `json:"guarantees"`
	Assurances []Assurance   `json:"assurances"`
	Disputes   Disputes      `json:"disputes"`
}

func NewExtrinsic

func NewExtrinsic(e block.Extrinsic) Extrinsic

func (Extrinsic) To

func (e Extrinsic) To() block.Extrinsic

type Fault

type Fault struct {
	Target    string `json:"target"`
	Vote      bool   `json:"vote"`
	Key       string `json:"key"`
	Signature string `json:"signature"`
}

type Guarantee

type Guarantee struct {
	Report     WorkReport           `json:"report"`
	Slot       jamtime.Timeslot     `json:"slot"`
	Signatures []GuaranteeSignature `json:"signatures"`
}

type GuaranteeSignature

type GuaranteeSignature struct {
	ValidatorIndex uint16 `json:"validator_index"`
	Signature      string `json:"signature"`
}
type Header struct {
	Parent          string           `json:"parent"`
	ParentStateRoot string           `json:"parent_state_root"`
	ExtrinsicHash   string           `json:"extrinsic_hash"`
	Slot            jamtime.Timeslot `json:"slot"`
	EpochMark       *EpochMark       `json:"epoch_mark"`
	TicketsMark     *[]TicketBody    `json:"tickets_mark"`
	OffendersMark   []string         `json:"offenders_mark"`
	AuthorIndex     uint16           `json:"author_index"`
	EntropySource   string           `json:"entropy_source"`
	Seal            string           `json:"seal"`
}

func NewHeader

func NewHeader(h block.Header) Header

func (Header) To

func (h Header) To() block.Header

type LookupMetaInfo

type LookupMetaInfo struct {
	Key   LookupMetaKey `json:"key"`
	Value []uint32      `json:"value"`
}

type LookupMetaKey

type LookupMetaKey struct {
	Hash   string `json:"hash"`
	Length uint32 `json:"length"`
}

type MMR

type MMR struct {
	Peaks []*string `json:"peaks"`
}

type Preimage

type Preimage struct {
	Requester uint32 `json:"requester"`
	Blob      string `json:"blob"`
}

type PreimageInfo

type PreimageInfo struct {
	Hash string `json:"hash"`
	Blob string `json:"blob"`
}

type PrivilegedServices

type PrivilegedServices struct {
	ManagerService   uint32            `json:"chi_m"`
	AssignService    uint32            `json:"chi_a"`
	DesignateService uint32            `json:"chi_v"`
	GasUsed          map[uint32]uint64 `json:"chi_g"`
}

func NewPrivilegedServices

func NewPrivilegedServices(services service.PrivilegedServices) PrivilegedServices

func (PrivilegedServices) To

type ReadyQueue

type ReadyQueue [][]ReadyRecord

func NewReadyQueue

func NewReadyQueue(queue state.AccumulationQueue) ReadyQueue

func (ReadyQueue) To

type ReadyRecord

type ReadyRecord struct {
	Report       WorkReport
	Dependencies []string
}

type RefineContext

type RefineContext struct {
	Anchor           string   `json:"anchor"`
	StateRoot        string   `json:"state_root"`
	BeefyRoot        string   `json:"beefy_root"`
	LookupAnchor     string   `json:"lookup_anchor"`
	LookupAnchorSlot uint32   `json:"lookup_anchor_slot"`
	Prerequisites    []string `json:"prerequisites"`
}

func NewRefineContext

func NewRefineContext(context block.RefinementContext) RefineContext

func (RefineContext) To

type RefineLoad

type RefineLoad struct {
	GasUsed        uint64 `json:"gas_used"`
	Imports        uint16 `json:"imports"`
	ExtrinsicCount uint16 `json:"extrinsic_count"`
	ExtrinsicSize  uint32 `json:"extrinsic_size"`
	Exports        uint16 `json:"exports"`
}

type Reported

type Reported struct {
	Hash        string `json:"hash"`
	ExportsRoot string `json:"exports_root"`
}

type SafroleState

type SafroleState struct {
	PendingValidators  ValidatorsData     `json:"gamma_k"`
	RingCommitment     string             `json:"gamma_z"`
	SealingKeySeries   TicketsOrKeys      `json:"gamma_s"`
	TicketsAccumulator TicketsAccumulator `json:"gamma_a"`
}

func NewSafroleState

func NewSafroleState(state safrole.State) SafroleState

func (SafroleState) To

func (s SafroleState) To() safrole.State

type SegmentRootLookupItem

type SegmentRootLookupItem struct {
	WorkPackageHash string `json:"work_package_hash"`
	SegmentTreeRoot string `json:"segment_tree_root"`
}

type ServiceInfo

type ServiceInfo struct {
	CodeHash   string `json:"code_hash"`
	Balance    uint64 `json:"balance"`
	MinItemGas uint64 `json:"min_item_gas"`
	MinMemoGas uint64 `json:"min_memo_gas"`
	Bytes      uint64 `json:"bytes"`
	Items      uint32 `json:"items"`
}

type ServiceStatistics

type ServiceStatistics []ServiceStatisticsEntry

func (ServiceStatistics) To

type ServiceStatisticsEntry

type ServiceStatisticsEntry struct {
	ID     uint32                  `json:"id"`
	Record ServiceStatisticsRecord `json:"record"`
}

type ServiceStatisticsRecord

type ServiceStatisticsRecord struct {
	ProvidedCount      uint16 `json:"provided_count"`
	ProvidedSize       uint32 `json:"provided_size"`
	RefinementCount    uint32 `json:"refinement_count"`
	RefinementGasUsed  uint64 `json:"refinement_gas_used"`
	Imports            uint32 `json:"imports"`
	Exports            uint32 `json:"exports"`
	ExtrinsicSize      uint32 `json:"extrinsic_size"`
	ExtrinsicCount     uint32 `json:"extrinsic_count"`
	AccumulateCount    uint32 `json:"accumulate_count"`
	AccumulateGasUsed  uint64 `json:"accumulate_gas_used"`
	OnTransfersCount   uint32 `json:"on_transfers_count"`
	OnTransfersGasUsed uint64 `json:"on_transfers_gas_used"`
}

type State

type State struct {
	AuthPools               AuthPools              `json:"alpha"`
	AuthQueues              AuthQueues             `json:"varphi"`
	BlockHistory            BlockHistory           `json:"beta"`
	SafroleState            SafroleState           `json:"gamma"`
	DisputeRecords          DisputeRecords         `json:"psi"`
	EntropyPool             EntropyPool            `json:"eta"`
	QueuedValidators        ValidatorsData         `json:"iota"`
	ActiveValidators        ValidatorsData         `json:"kappa"`
	ArchivedValidators      ValidatorsData         `json:"lambda"`
	AvailabilityAssignments AvailabilityAssigments `json:"rho"`
	Timeslot                uint32                 `json:"tau"`
	PrivilegedServices      PrivilegedServices     `json:"chi"`
	ActivityStatistics      ActivityStatistics     `json:"pi"`
	ReadyQueue              ReadyQueue             `json:"theta"`
	AccumulatedQueue        AccumulatedQueue       `json:"xi"`
	Accounts                Accounts               `json:"accounts"`
}

func NewState

func NewState(state state.State) State

func (State) To

func (s State) To() state.State

type Storage

type Storage map[string]string

type TicketBody

type TicketBody struct {
	ID      string `json:"id"`
	Attempt uint8  `json:"attempt"`
}

func NewTicketBody

func NewTicketBody(ticket block.Ticket) TicketBody

func (TicketBody) To

func (tb TicketBody) To() block.Ticket

type TicketProof

type TicketProof struct {
	Attempt   uint8  `json:"attempt"`
	Signature string `json:"signature"`
}

type TicketsAccumulator

type TicketsAccumulator []TicketBody

func NewTicketsAccumulator

func NewTicketsAccumulator(tickets []block.Ticket) TicketsAccumulator

func (TicketsAccumulator) To

func (ta TicketsAccumulator) To() []block.Ticket

type TicketsOrKeys

type TicketsOrKeys struct {
	Keys    []string     `json:"keys,omitempty"`
	Tickets []TicketBody `json:"tickets,omitempty"`
}

func NewTicketsOrKeys

func NewTicketsOrKeys(sealingKeys safrole.SealingKeys) TicketsOrKeys

func (TicketsOrKeys) To

type ValidatorData

type ValidatorData struct {
	Bandersnatch string `json:"bandersnatch"`
	Ed25519      string `json:"ed25519"`
	Bls          string `json:"bls"`
	Metadata     string `json:"metadata"`
}

func NewValidatorData

func NewValidatorData(vk crypto.ValidatorKey) ValidatorData

func (ValidatorData) To

type ValidatorStatistics

type ValidatorStatistics struct {
	Blocks        uint32 `json:"blocks"`
	Tickets       uint32 `json:"tickets"`
	PreImages     uint32 `json:"pre_images"`
	PreImagesSize uint32 `json:"pre_images_size"`
	Guarantees    uint32 `json:"guarantees"`
	Assurances    uint32 `json:"assurances"`
}

type ValidatorsData

type ValidatorsData []ValidatorData

func NewValidatorsData

func NewValidatorsData(validators safrole.ValidatorsData) ValidatorsData

func (ValidatorsData) To

type Verdict

type Verdict struct {
	Target string        `json:"target"`
	Age    uint32        `json:"age"`
	Votes  []VerdictVote `json:"votes"`
}

type VerdictVote

type VerdictVote struct {
	Vote      bool   `json:"vote"`
	Index     uint16 `json:"index"`
	Signature string `json:"signature"`
}

type WorkPackageSpec

type WorkPackageSpec struct {
	Hash         string `json:"hash"`
	Length       uint32 `json:"length"`
	ErasureRoot  string `json:"erasure_root"`
	ExportsRoot  string `json:"exports_root"`
	ExportsCount uint16 `json:"exports_count"`
}

func (WorkPackageSpec) To

type WorkReport

type WorkReport struct {
	PackageSpec       WorkPackageSpec         `json:"package_spec"`
	Context           RefineContext           `json:"context"`
	CoreIndex         uint16                  `json:"core_index"`
	AuthorizerHash    string                  `json:"authorizer_hash"`
	AuthOutput        string                  `json:"auth_output"`
	SegmentRootLookup []SegmentRootLookupItem `json:"segment_root_lookup"`
	Results           []WorkResult            `json:"results"`
	AuthGasUsed       uint64                  `json:"auth_gas_used"`
}

func NewWorkReport

func NewWorkReport(report block.WorkReport) WorkReport

func (WorkReport) To

func (w WorkReport) To() block.WorkReport

type WorkResult

type WorkResult struct {
	ServiceID     uint32             `json:"service_id"`
	CodeHash      string             `json:"code_hash"`
	PayloadHash   string             `json:"payload_hash"`
	AccumulateGas uint64             `json:"accumulate_gas"`
	Result        map[string]*string `json:"result"`
	RefineLoad    RefineLoad         `json:"refine_load"`
}

func NewWorkResult

func NewWorkResult(result block.WorkResult) WorkResult

func (WorkResult) To

func (w WorkResult) To() block.WorkResult

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL