aura

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Overview

Package aura implements the proof-of-authority consensus engine.

Index

Constants

View Source
const DEBUG_LOG_FROM = 999_999_999
View Source
const EVENT_NAME = "InitiateChange(bytes32,address[])"

Variables

View Source
var EVENT_NAME_HASH = crypto.Keccak256Hash([]byte(EVENT_NAME))

Functions

func EmptyStepFullRlp

func EmptyStepFullRlp(signature []byte, emptyStepRlp []byte) ([]byte, error)

func EmptyStepRlp

func EmptyStepRlp(step uint64, parentHash libcommon.Hash) ([]byte, error)

func GetFromValidatorSet

func GetFromValidatorSet(set ValidatorSet, parent libcommon.Hash, nonce uint, call consensus.Call) (libcommon.Address, error)

Draws an validator nonce modulo number of validators.

Types

type AuRa

type AuRa struct {
	EmptyStepsSet *EmptyStepSet
	EpochManager  *EpochManager // Mutex<EpochManager>,
	// contains filtered or unexported fields
}

AuRa nolint

func NewAuRa

func NewAuRa(spec *chain.AuRaConfig, db kv.RwDB) (*AuRa, error)

func (*AuRa) APIs

func (c *AuRa) APIs(chain consensus.ChainHeaderReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.

func (*AuRa) Author

func (c *AuRa) Author(header *types.Header) (libcommon.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section. This is thread-safe (only access the Coinbase of the header)

func (*AuRa) Authorize

func (c *AuRa) Authorize(signer libcommon.Address, signFn clique.SignerFn)

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*AuRa) CalcDifficulty

func (c *AuRa) CalcDifficulty(chain consensus.ChainHeaderReader, time, parentTime uint64, parentDifficulty *big.Int, parentNumber uint64, parentHash, parentUncleHash libcommon.Hash, parentStep uint64) *big.Int

func (*AuRa) CalculateRewards

func (c *AuRa) CalculateRewards(_ *chain.Config, header *types.Header, _ []*types.Header, syscall consensus.SystemCall,
) ([]consensus.Reward, error)

func (*AuRa) Close

func (c *AuRa) Close() error

Close implements consensus.Engine. It's a noop for clique as there are no background threads.

func (*AuRa) Finalize

func (c *AuRa) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions,
	uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal,
	chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger,
) (types.Transactions, types.Receipts, error)

word `signal epoch` == word `pending epoch`

func (*AuRa) FinalizeAndAssemble

func (c *AuRa) FinalizeAndAssemble(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, chain consensus.ChainReader, syscall consensus.SystemCall, call consensus.Call, logger log.Logger) (*types.Block, types.Transactions, types.Receipts, error)

FinalizeAndAssemble implements consensus.Engine

func (*AuRa) GenerateSeal

func (c *AuRa) GenerateSeal(chain consensus.ChainHeaderReader, current, parent *types.Header, call consensus.Call) []byte

GenerateSeal - Attempt to seal the block internally.

This operation is synchronous and may (quite reasonably) not be available, in which case `Seal::None` will be returned.

func (*AuRa) GenesisEpochData

func (c *AuRa) GenesisEpochData(header *types.Header, caller consensus.SystemCall) ([]byte, error)

func (*AuRa) GetBlockGasLimitFromContract

func (c *AuRa) GetBlockGasLimitFromContract(_ *chain.Config, syscall consensus.SystemCall) uint64

func (*AuRa) HasGasLimitContract

func (c *AuRa) HasGasLimitContract() bool

func (*AuRa) Initialize

func (c *AuRa) Initialize(config *chain.Config, chain consensus.ChainHeaderReader, header *types.Header,
	state *state.IntraBlockState, syscallCustom consensus.SysCallCustom, logger log.Logger,
)

func (*AuRa) IsServiceTransaction

func (c *AuRa) IsServiceTransaction(sender libcommon.Address, syscall consensus.SystemCall) bool

See https://openethereum.github.io/Permissioning.html#gas-price This is thread-safe: it only accesses the `certifier` which is used behind a RWLock

func (*AuRa) Prepare

func (c *AuRa) Prepare(chain consensus.ChainHeaderReader, header *types.Header, state *state.IntraBlockState) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.

func (*AuRa) Seal

func (c *AuRa) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

func (*AuRa) SealHash

func (c *AuRa) SealHash(header *types.Header) libcommon.Hash

func (*AuRa) Type

func (c *AuRa) Type() chain.ConsensusName

Type returns underlying consensus engine

func (*AuRa) VerifyHeader

func (c *AuRa) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, _ bool) error

VerifyHeader checks whether a header conforms to the consensus rules.

func (*AuRa) VerifySeal

func (c *AuRa) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*AuRa) VerifyUncles

func (c *AuRa) VerifyUncles(chain consensus.ChainReader, header *types.Header, uncles []*types.Header) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

type AuthorityRoundParams

type AuthorityRoundParams struct {
	// A map defining intervals of blocks with the given times (in seconds) to wait before next
	// block or authority switching. The keys in the map are steps of starting blocks of those
	// periods. The entry at `0` should be defined.
	//
	// Wait times (durations) are additionally required to be less than 65535 since larger values
	// lead to slow block issuance.
	StepDurations map[uint64]uint64
	// Starting step,
	StartStep *uint64
	// Valid validators.
	Validators ValidatorSet
	// Chain score validation transition block.
	ValidateScoreTransition uint64
	// Monotonic step validation transition block.
	ValidateStepTransition uint64
	// Immediate transitions.
	ImmediateTransitions bool
	// Block reward in base units.
	BlockReward BlockRewardList
	// Block reward contract addresses with their associated starting block numbers.
	BlockRewardContractTransitions BlockRewardContractList
	// Number of accepted uncles transition block.
	MaximumUncleCountTransition uint64
	// Number of accepted uncles.
	MaximumUncleCount uint
	// Transition block to strict empty steps validation.
	StrictEmptyStepsTransition uint64
	// If set, enables random number contract integration. It maps the transition block to the contract address.
	RandomnessContractAddress map[uint64]libcommon.Address
	// The addresses of contracts that determine the block gas limit with their associated block
	// numbers.
	BlockGasLimitContractTransitions map[uint64]libcommon.Address
	// If set, this is the block number at which the consensus engine switches from AuRa to AuRa
	// with POSDAO modifications.
	PosdaoTransition *uint64
	// Stores human-readable keys associated with addresses, like DNS information.
	// This contract is primarily required to store the address of the Certifier contract.
	Registrar *libcommon.Address

	// See https://github.com/gnosischain/specs/blob/master/execution/withdrawals.md
	WithdrawalContractAddress *libcommon.Address

	RewriteBytecode map[uint64]map[libcommon.Address][]byte
}

func FromJson

func FromJson(jsonParams *chain.AuRaConfig) (AuthorityRoundParams, error)

type BlockReward

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

type BlockRewardContract

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

func NewBlockRewardContract

func NewBlockRewardContract(address libcommon.Address) *BlockRewardContract

type BlockRewardContractList

type BlockRewardContractList []BlockRewardContract

func (BlockRewardContractList) Len

func (r BlockRewardContractList) Len() int

func (BlockRewardContractList) Less

func (r BlockRewardContractList) Less(i, j int) bool

func (BlockRewardContractList) Swap

func (r BlockRewardContractList) Swap(i, j int)

type BlockRewardList

type BlockRewardList []BlockReward

func (BlockRewardList) Len

func (r BlockRewardList) Len() int

func (BlockRewardList) Less

func (r BlockRewardList) Less(i, j int) bool

func (BlockRewardList) Swap

func (r BlockRewardList) Swap(i, j int)

type Call

type Call func(libcommon.Address, []byte) (CallResults, error)

Type alias for a function we can make calls through synchronously. Returns the call result and state proof for each call.

type CallResults

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

nolint

type Code

type Code struct {
	Code     []byte
	CodeHash libcommon.Hash
}

type EmptyStep

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

A message broadcast by authorities when it's their turn to seal a block but there are no transactions. Other authorities accumulate these messages and later include them in the seal as proof.

An empty step message is created _instead of_ a block if there are no pending transactions. It cannot itself be a parent, and `parent_hash` always points to the most recent block. E.g.:

  • Validator A creates block `bA`.
  • Validator B has no pending transactions, so it signs an empty step message `mB` instead whose hash points to block `bA`.
  • Validator C also has no pending transactions, so it also signs an empty step message `mC` instead whose hash points to block `bA`.
  • Validator D creates block `bD`. The parent is block `bA`, and the header includes `mB` and `mC`.

func (*EmptyStep) Less

func (s *EmptyStep) Less(other *EmptyStep) bool

func (*EmptyStep) LessOrEqual

func (s *EmptyStep) LessOrEqual(other *EmptyStep) bool

type EmptyStepSet

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

func (*EmptyStepSet) ForEach

func (s *EmptyStepSet) ForEach(f func(int, *EmptyStep))

func (*EmptyStepSet) Len

func (s *EmptyStepSet) Len() int

func (*EmptyStepSet) Less

func (s *EmptyStepSet) Less(i, j int) bool

func (*EmptyStepSet) Sort

func (s *EmptyStepSet) Sort()

func (*EmptyStepSet) Swap

func (s *EmptyStepSet) Swap(i, j int)

type EpochManager

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

nolint

func NewEpochManager

func NewEpochManager() *EpochManager

type EpochTransition

type EpochTransition struct {
	/// Block hash at which the transition occurred.
	BlockHash libcommon.Hash
	/// Block number at which the transition occurred.
	BlockNumber uint64
	/// "transition/epoch" proof from the engine combined with a finality proof.
	ProofRlp []byte
}

type EpochTransitionProof

type EpochTransitionProof struct {
	SignalNumber  uint64
	SetProof      []byte
	FinalityProof []byte
}

EpochTransitionProof - Holds 2 proofs inside: ValidatorSetProof and FinalityProof

type FirstValidatorSetProof

type FirstValidatorSetProof struct {
	ContractAddress libcommon.Address
	Header          *types.Header
}

FirstValidatorSetProof state-dependent proofs for the safe contract: only "first" proofs are such.

type GasLimitOverride

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

func NewGasLimitOverride

func NewGasLimitOverride() *GasLimitOverride

func (*GasLimitOverride) Add

func (pb *GasLimitOverride) Add(hash libcommon.Hash, b *uint256.Int)

func (*GasLimitOverride) Pop

func (pb *GasLimitOverride) Pop(hash libcommon.Hash) *uint256.Int

type Multi

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

func NewMulti

func NewMulti(m map[uint64]ValidatorSet) *Multi

func (*Multi) Len

func (s *Multi) Len() int

func (*Multi) Less

func (s *Multi) Less(i, j int) bool

func (*Multi) Swap

func (s *Multi) Swap(i, j int)

type MultiItem

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

nolint

type NonTransactionalEpochReader

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

func (*NonTransactionalEpochReader) FindBeforeOrEqualNumber

func (cr *NonTransactionalEpochReader) FindBeforeOrEqualNumber(number uint64) (blockNum uint64, blockHash libcommon.Hash, transitionProof []byte, err error)

func (*NonTransactionalEpochReader) GetEpoch

func (cr *NonTransactionalEpochReader) GetEpoch(hash libcommon.Hash, number uint64) (v []byte, err error)

func (*NonTransactionalEpochReader) GetPendingEpoch

func (cr *NonTransactionalEpochReader) GetPendingEpoch(hash libcommon.Hash, number uint64) (v []byte, err error)

func (*NonTransactionalEpochReader) PutEpoch

func (cr *NonTransactionalEpochReader) PutEpoch(hash libcommon.Hash, number uint64, proof []byte) error

func (*NonTransactionalEpochReader) PutPendingEpoch

func (cr *NonTransactionalEpochReader) PutPendingEpoch(hash libcommon.Hash, number uint64, proof []byte) error

type PermissionedStep

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

type ReceivedStepHashes

type ReceivedStepHashes map[uint64]map[libcommon.Address]libcommon.Hash //BTreeMap<(u64, Address), H256>

type ReportQueue

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

nolint

type ReportQueueItem

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

nolint

type RollingFinality

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

RollingFinality checker for authority round consensus. Stores a chain of unfinalized hashes that can be pushed onto. nolint

func NewRollingFinality

func NewRollingFinality(signers []libcommon.Address) *RollingFinality

NewRollingFinality creates a blank finality checker under the given validator set.

type SealedEmptyStep

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

An empty step message that is included in a seal, the only difference is that it doesn't include the `parent_hash` in order to save space. The included signature is of the original empty step message, which can be reconstructed by using the parent hash of the block in which this sealed empty message is included. nolint

type SimpleList

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

func NewSimpleList

func NewSimpleList(validators []libcommon.Address) *SimpleList

type Step

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

type StepDurationInfo

type StepDurationInfo struct {
	TransitionStep      uint64
	TransitionTimestamp uint64
	StepDuration        uint64
}

type SystemCall

type SystemCall func(libcommon.Address, []byte) (CallResults, error)

A system-calling closure. Enacts calls on a block's state from the system address.

type ValidatorContract

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

ValidatorContract a validator contract with reporting.

type ValidatorSafeContract

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

The validator contract should have the following interface: nolint

func NewValidatorSafeContract

func NewValidatorSafeContract(contractAddress libcommon.Address, posdaoTransition *uint64, client client) *ValidatorSafeContract

type ValidatorSet

type ValidatorSet interface {
	// contains filtered or unexported methods
}

type ValidatorSetProof

type ValidatorSetProof struct {
	Header   *types.Header
	Receipts types.Receipts
}

ValidatorSetProof - validator set proof

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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