grandpa

package
v0.0.3-rc-1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorPauseFailed sc.U8 = iota
	ErrorResumeFailed
	ErrorChangePending
	ErrorTooSoon
	ErrorInvalidKeyOwnershipProof
	ErrorInvalidEquivocationProof
	ErrorDuplicateOffenceReport
)
View Source
const (
	// New authority set has been applied.
	EventNewAuthorities sc.U8 = iota
	// Current authority set has been paused.
	EventPaused
	// Current authority set has been resumed.
	EventResumed
)
View Source
const (
	// The current authority set is live, and GRANDPA is enabled.
	StoredStateLive sc.U8 = iota

	// There is a pending pause event which will be enacted at the given block
	// height.
	StoredStatePendingPause

	// The current GRANDPA authority set is paused.
	StoredStatePaused

	// There is a pending resume event which will be enacted at the given block
	// height.
	StoredStatePendingResume
)

Variables

View Source
var (
	EngineId  = [4]byte{'F', 'R', 'N', 'K'}
	KeyTypeId = [4]byte{'g', 'r', 'a', 'n'}
)

Functions

func DecodeEvent

func DecodeEvent(moduleIndex sc.U8, buffer *bytes.Buffer) (primitives.Event, error)

func NewDispatchErrorChangePending

func NewDispatchErrorChangePending(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorDuplicateOffenceReport

func NewDispatchErrorDuplicateOffenceReport(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorInvalidEquivocationProof

func NewDispatchErrorInvalidEquivocationProof(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorInvalidKeyOwnershipProof

func NewDispatchErrorInvalidKeyOwnershipProof(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorPauseFailed

func NewDispatchErrorPauseFailed(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorResumeFailed

func NewDispatchErrorResumeFailed(moduleId sc.U8) primitives.DispatchError

func NewDispatchErrorTooSoon

func NewDispatchErrorTooSoon(moduleId sc.U8) primitives.DispatchError

Types

type Config

type Config struct {
	Storage                  io.Storage
	DbWeight                 types.RuntimeDbWeight
	KeyType                  primitives.PublicKeyType
	MaxAuthorities           sc.U32
	MaxNominators            sc.U32
	MaxSetIdSessionEntries   sc.U64
	KeyOwnerProof            KeyOwnerProofSystem
	EquivocationReportSystem staking.OffenceReportSystem
	SystemModule             system.Module
	SessionModule            session.Module
}

func NewConfig

func NewConfig(
	storage io.Storage,
	dbWeight types.RuntimeDbWeight,
	keyType primitives.PublicKeyType,
	maxAuthorities sc.U32,
	maxNominators sc.U32,
	maxSetIdSessionEntries sc.U64,
	keyOwnerProof KeyOwnerProofSystem,
	equivocationReportSystem staking.OffenceReportSystem,
	systemModule system.Module,
	sessionModule session.Module,
) *Config

type DefaultKeyOwnerProofSystem

type DefaultKeyOwnerProofSystem struct{}

func (DefaultKeyOwnerProofSystem) Prove

type EquivocationOffence

type EquivocationOffence struct {
	// Time slot at which this inEquivocationOffencecident happened.
	TimeSlot TimeSlot
	// The session index in which the incident happened.
	SessionIndex sc.U32
	// The size of the validator set at the time of the offence.
	ValidatorSetCount sc.U32
	// The authority which produced this equivocation.
	Offender primitives.AccountId
}

GRANDPA equivocation offence report.

type EquivocationReportSystem

type EquivocationReportSystem struct {
	// contains filtered or unexported fields
}

func NewEquivocationReportSystem

func NewEquivocationReportSystem(sessionHistoricalModule session_historical.Module, authorshipModule authorship.Module, logger log.RuntimeLogger) EquivocationReportSystem

func (EquivocationReportSystem) ProcessEvidence

func (e EquivocationReportSystem) ProcessEvidence(reporterAccount sc.Option[primitives.AccountId], equivocationProof grandpatypes.EquivocationProof, keyOwnerProof grandpatypes.KeyOwnerProof,
) error

func (EquivocationReportSystem) PublishEvidence

func (e EquivocationReportSystem) PublishEvidence(equivocationProof grandpatypes.EquivocationProof, keyOwnerProof grandpatypes.KeyOwnerProof) error

func (EquivocationReportSystem) SetModule

func (e EquivocationReportSystem) SetModule(grandpaModule Module)

type GenesisConfig

type GenesisConfig struct {
	Authorities sc.Sequence[types.Authority]
}

func (*GenesisConfig) UnmarshalJSON

func (gc *GenesisConfig) UnmarshalJSON(data []byte) error

type KeyOwnerProofSystem

type KeyOwnerProofSystem interface {
	// Prove membership of a key owner in the current block-state.
	//
	// This should typically only be called off-chain, since it may be
	// computationally heavy.
	//
	// Returns `Some` iff the key owner referred to by the given `key` is a
	// member of the current set.
	Prove(key [4]byte, authorityId primitives.AccountId) sc.Option[session.MembershipProof]
}

Something which can compute and check proofs of a historical key owner and return full identification data of that key owner.

type Module

type Module interface {
	primitives.Module

	KeyType() primitives.PublicKeyType
	KeyTypeId() [4]byte
	Authorities() (sc.Sequence[primitives.Authority], error)
	StorageSetId() (sc.U64, error)
	SubmitUnsignedEquivocationReport(equivocationProof grandpatypes.EquivocationProof, keyOwnerProof grandpatypes.KeyOwnerProof) error
	HistoricalKeyOwnershipProof(authorityId primitives.AccountId) sc.Option[grandpatypes.OpaqueKeyOwnershipProof]

	StorageSetIdSessionGet(sc.U64) (sc.U32, error)
}

func New

func New(index sc.U8, config *Config, logger log.RuntimeLogger, mdGenerator *primitives.MetadataTypeGenerator) Module

type ScheduledAction

type ScheduledAction struct {
	// Block at which the action was scheduled.
	ScheduledAt sc.U64
	// Number of blocks after which the change will be enacted.
	Delay sc.U64
}

func DecodeScheduledAction

func DecodeScheduledAction(buffer *bytes.Buffer) (ScheduledAction, error)

func (ScheduledAction) Bytes

func (s ScheduledAction) Bytes() []byte

func (ScheduledAction) Encode

func (s ScheduledAction) Encode(buffer *bytes.Buffer) error

type StaleNotifier

type StaleNotifier interface {
	OnStalled(furtherWait sc.U64, median sc.U64)
}

type StoredPendingChange

type StoredPendingChange struct {
	// The block number this was scheduled at.
	ScheduledAt sc.U64
	// The delay in blocks until it will be applied.
	Delay sc.U64
	// The next authority set, weakly bounded in size by `Limit`.
	NextAuthorities sc.Sequence[primitives.Authority]
	// If defined it means the change was forced and the given block number
	// indicates the median last finalized block when the change was signaled.
	Forced sc.Option[sc.U64]
}

A stored pending change. `Limit` is the bound for `next_authorities`

func DecodeStoredPendingChange

func DecodeStoredPendingChange(buffer *bytes.Buffer) (StoredPendingChange, error)

func (StoredPendingChange) Bytes

func (s StoredPendingChange) Bytes() []byte

func (StoredPendingChange) Encode

func (s StoredPendingChange) Encode(buffer *bytes.Buffer) error

type StoredState

type StoredState struct {
	sc.VaryingData
}

Current state of the GRANDPA authority set. State transitions must happen in the same order of states defined below, e.g. `Paused` implies a prior `PendingPause`.

func DecodeStoredState

func DecodeStoredState(buffer *bytes.Buffer) (StoredState, error)

func NewStoredStateLive

func NewStoredStateLive() StoredState

func NewStoredStatePaused

func NewStoredStatePaused() StoredState

func NewStoredStatePendingPause

func NewStoredStatePendingPause(scheduledAction ScheduledAction) StoredState

func NewStoredStatePendingResume

func NewStoredStatePendingResume(scheduledAction ScheduledAction) StoredState

type TimeSlot

type TimeSlot struct {
	// Grandpa Set ID.
	SetId sc.U64
	// Round number.
	Round sc.U64
}

A round number and set id which point on the time of an offence.

Jump to

Keyboard shortcuts

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