Documentation ¶
Overview ¶
Package bor is a generated GoMock package.
Package bor is a generated GoMock package.
Index ¶
- Variables
- func BorRLP(header *types.Header, c *params.BorConfig) []byte
- func CalcProducerDelay(number uint64, succession int, c *params.BorConfig) uint64
- func Difficulty(validatorSet *valset.ValidatorSet, signer common.Address) uint64
- func IsBlockOnTime(parent *types.Header, header *types.Header, number uint64, succession int, ...) bool
- func IsSprintStart(number, sprint uint64) bool
- func SealHash(header *types.Header, c *params.BorConfig) (hash common.Hash)
- func Sign(signFn SignerFn, signer common.Address, header *types.Header, ...) error
- type API
- func (api *API) GetAuthor(blockNrOrHash *rpc.BlockNumberOrHash) (*common.Address, error)
- func (api *API) GetCurrentProposer() (common.Address, error)
- func (api *API) GetCurrentValidators() ([]*valset.Validator, error)
- func (api *API) GetRootHash(start uint64, end uint64) (string, error)
- func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)
- func (api *API) GetSnapshotProposer(blockNrOrHash *rpc.BlockNumberOrHash) (common.Address, error)
- func (api *API) GetSnapshotProposerSequence(blockNrOrHash *rpc.BlockNumberOrHash) (BlockSigners, error)
- type BlockSigners
- type BlockTooSoonError
- type Bor
- func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (c *Bor) Author(header *types.Header) (common.Address, error)
- func (c *Bor) Authorize(currentSigner common.Address, signFn SignerFn)
- func (c *Bor) CalcDifficulty(chain consensus.ChainHeaderReader, _ uint64, parent *types.Header) *big.Int
- func (c *Bor) Close() error
- func (c *Bor) CommitStates(ctx context.Context, state *state.StateDB, header *types.Header, ...) ([]*types.StateSyncData, error)
- func (c *Bor) FetchAndCommitSpan(ctx context.Context, newSpanID uint64, state *state.StateDB, ...) error
- func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHeaderReader, header *types.Header, ...) (*types.Block, error)
- func (c *Bor) GetCurrentValidators(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error)
- func (c *Bor) GetSpanner() Spanner
- func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (c *Bor) SealHash(header *types.Header) common.Hash
- func (c *Bor) SetHeimdallClient(h IHeimdallClient)
- func (c *Bor) SetSpanner(spanner Spanner)
- func (c *Bor) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, _ bool) error
- func (c *Bor) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, _ []bool) (chan<- struct{}, <-chan error)
- func (c *Bor) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
- func (c *Bor) VerifyUncles(_ consensus.ChainReader, block *types.Block) error
- type GenesisContract
- type IHeimdallClient
- type InvalidStateReceivedError
- type MaxCheckpointLengthExceededError
- type MismatchingValidatorsError
- type MockGenesisContract
- func (m *MockGenesisContract) CommitState(arg0 *clerk.EventRecordWithTime, arg1 *state.StateDB, arg2 *types.Header, ...) (uint64, error)
- func (m *MockGenesisContract) EXPECT() *MockGenesisContractMockRecorder
- func (m *MockGenesisContract) LastStateId(arg0 *state.StateDB, arg1 uint64, arg2 common.Hash) (*big.Int, error)
- type MockGenesisContractMockRecorder
- type MockSpanner
- func (m *MockSpanner) CommitSpan(arg0 context.Context, arg1 span.HeimdallSpan, arg2 *state.StateDB, ...) error
- func (m *MockSpanner) EXPECT() *MockSpannerMockRecorder
- func (m *MockSpanner) GetCurrentSpan(arg0 context.Context, arg1 common.Hash) (*span.Span, error)
- func (m *MockSpanner) GetCurrentValidatorsByBlockNrOrHash(arg0 context.Context, arg1 rpc.BlockNumberOrHash, arg2 uint64) ([]*valset.Validator, error)
- func (m *MockSpanner) GetCurrentValidatorsByHash(arg0 context.Context, arg1 common.Hash, arg2 uint64) ([]*valset.Validator, error)
- type MockSpannerMockRecorder
- func (mr *MockSpannerMockRecorder) CommitSpan(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- func (mr *MockSpannerMockRecorder) GetCurrentSpan(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByBlockNrOrHash(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByHash(arg0, arg1, arg2 interface{}) *gomock.Call
- type SignerFn
- type Snapshot
- type Spanner
- type UnauthorizedProposerError
- type UnauthorizedSignerError
- type WrongDifficultyError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidTimestamp is returned if the timestamp of a block is lower than // the previous block's timestamp + the minimum block period. ErrInvalidTimestamp = errors.New("invalid timestamp") )
Various error messages to mark blocks invalid. These should be private to prevent engine specific errors from being referenced in the remainder of the codebase, inherently breaking if the engine is swapped out. Please put common error types into the consensus package.
var ( // MaxCheckpointLength is the maximum number of blocks that can be requested for constructing a checkpoint root hash MaxCheckpointLength = uint64(math.Pow(2, 15)) )
Functions ¶
func BorRLP ¶
BorRLP returns the rlp bytes which needs to be signed for the bor sealing. The RLP to sign consists of the entire header apart from the 65 byte signature contained at the end of the extra data.
Note, the method requires the extra data to be at least 65 bytes, otherwise it panics. This is done to avoid accidentally using both forms (signature present or not), which could be abused to produce different hashes for the same header.
func CalcProducerDelay ¶
CalcProducerDelay is the block delay algorithm based on block time, period, producerDelay and turn-ness of a signer
func Difficulty ¶
func Difficulty(validatorSet *valset.ValidatorSet, signer common.Address) uint64
Difficulty returns the difficulty for a particular signer at the current snapshot number
func IsBlockOnTime ¶
func IsSprintStart ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.
func (*API) GetCurrentProposer ¶
GetCurrentProposer gets the current proposer
func (*API) GetCurrentValidators ¶
GetCurrentValidators gets the current validators
func (*API) GetRootHash ¶
GetRootHash returns the merkle root of the start to end block headers
func (*API) GetSigners ¶
GetSigners retrieves the list of authorized signers at the specified block.
func (*API) GetSignersAtHash ¶
GetSignersAtHash retrieves the list of authorized signers at the specified block.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
func (*API) GetSnapshotProposer ¶
GetSnapshotProposer retrieves the in-turn signer at a given block.
func (*API) GetSnapshotProposerSequence ¶
func (api *API) GetSnapshotProposerSequence(blockNrOrHash *rpc.BlockNumberOrHash) (BlockSigners, error)
GetSnapshotProposerSequence retrieves the in-turn signers of all sprints in a span
type BlockSigners ¶
type BlockTooSoonError ¶
func (*BlockTooSoonError) Error ¶
func (e *BlockTooSoonError) Error() string
type Bor ¶
type Bor struct { GenesisContractsClient GenesisContract HeimdallClient IHeimdallClient // contains filtered or unexported fields }
Bor is the matic-bor consensus engine
func New ¶
func New( chainConfig *params.ChainConfig, db ethdb.Database, ethAPI api.Caller, spanner Spanner, heimdallClient IHeimdallClient, genesisContracts GenesisContract, devFakeAuthor bool, ) *Bor
New creates a Matic Bor consensus engine.
func (*Bor) APIs ¶
func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*Bor) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Bor) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*Bor) CalcDifficulty ¶
func (c *Bor) CalcDifficulty(chain consensus.ChainHeaderReader, _ uint64, parent *types.Header) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.
func (*Bor) Close ¶
Close implements consensus.Engine. It's a noop for bor as there are no background threads.
func (*Bor) CommitStates ¶
func (c *Bor) CommitStates( ctx context.Context, state *state.StateDB, header *types.Header, chain statefull.ChainContext, ) ([]*types.StateSyncData, error)
CommitStates commit states
func (*Bor) FetchAndCommitSpan ¶
func (*Bor) Finalize ¶
func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, _ []*types.Transaction, _ []*types.Header)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given.
func (*Bor) FinalizeAndAssemble ¶
func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Bor) GetCurrentValidators ¶
func (*Bor) GetSpanner ¶
func (*Bor) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Bor) Seal ¶
func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.
func (*Bor) SetHeimdallClient ¶
func (c *Bor) SetHeimdallClient(h IHeimdallClient)
func (*Bor) SetSpanner ¶
func (*Bor) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Bor) VerifyHeaders ¶
func (c *Bor) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, _ []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*Bor) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Bor) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type GenesisContract ¶
type IHeimdallClient ¶
type IHeimdallClient interface { StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) FetchCheckpoint(ctx context.Context, number int64) (*checkpoint.Checkpoint, error) FetchCheckpointCount(ctx context.Context) (int64, error) Close() }
type InvalidStateReceivedError ¶
type InvalidStateReceivedError struct { Number uint64 LastStateID uint64 To *time.Time Event *clerk.EventRecordWithTime }
func (*InvalidStateReceivedError) Error ¶
func (e *InvalidStateReceivedError) Error() string
type MaxCheckpointLengthExceededError ¶
func (*MaxCheckpointLengthExceededError) Error ¶
func (e *MaxCheckpointLengthExceededError) Error() string
type MismatchingValidatorsError ¶
type MismatchingValidatorsError struct { Number uint64 ValidatorSetSnap []byte ValidatorSetHeader []byte }
MismatchingValidatorsError is returned if a last block in sprint contains a list of validators different from the one that local node calculated
func (*MismatchingValidatorsError) Error ¶
func (e *MismatchingValidatorsError) Error() string
type MockGenesisContract ¶
type MockGenesisContract struct {
// contains filtered or unexported fields
}
MockGenesisContract is a mock of GenesisContract interface.
func NewMockGenesisContract ¶
func NewMockGenesisContract(ctrl *gomock.Controller) *MockGenesisContract
NewMockGenesisContract creates a new mock instance.
func (*MockGenesisContract) CommitState ¶
func (m *MockGenesisContract) CommitState(arg0 *clerk.EventRecordWithTime, arg1 *state.StateDB, arg2 *types.Header, arg3 statefull.ChainContext) (uint64, error)
CommitState mocks base method.
func (*MockGenesisContract) EXPECT ¶
func (m *MockGenesisContract) EXPECT() *MockGenesisContractMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockGenesisContractMockRecorder ¶
type MockGenesisContractMockRecorder struct {
// contains filtered or unexported fields
}
MockGenesisContractMockRecorder is the mock recorder for MockGenesisContract.
func (*MockGenesisContractMockRecorder) CommitState ¶
func (mr *MockGenesisContractMockRecorder) CommitState(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
CommitState indicates an expected call of CommitState.
func (*MockGenesisContractMockRecorder) LastStateId ¶
func (mr *MockGenesisContractMockRecorder) LastStateId(arg0, arg1, arg2 interface{}) *gomock.Call
LastStateId indicates an expected call of LastStateId.
type MockSpanner ¶
type MockSpanner struct {
// contains filtered or unexported fields
}
MockSpanner is a mock of Spanner interface.
func NewMockSpanner ¶
func NewMockSpanner(ctrl *gomock.Controller) *MockSpanner
NewMockSpanner creates a new mock instance.
func (*MockSpanner) CommitSpan ¶
func (m *MockSpanner) CommitSpan(arg0 context.Context, arg1 span.HeimdallSpan, arg2 *state.StateDB, arg3 *types.Header, arg4 core.ChainContext) error
CommitSpan mocks base method.
func (*MockSpanner) EXPECT ¶
func (m *MockSpanner) EXPECT() *MockSpannerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSpanner) GetCurrentSpan ¶
GetCurrentSpan mocks base method.
func (*MockSpanner) GetCurrentValidatorsByBlockNrOrHash ¶
func (m *MockSpanner) GetCurrentValidatorsByBlockNrOrHash(arg0 context.Context, arg1 rpc.BlockNumberOrHash, arg2 uint64) ([]*valset.Validator, error)
GetCurrentValidatorsByBlockNrOrHash mocks base method.
type MockSpannerMockRecorder ¶
type MockSpannerMockRecorder struct {
// contains filtered or unexported fields
}
MockSpannerMockRecorder is the mock recorder for MockSpanner.
func (*MockSpannerMockRecorder) CommitSpan ¶
func (mr *MockSpannerMockRecorder) CommitSpan(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
CommitSpan indicates an expected call of CommitSpan.
func (*MockSpannerMockRecorder) GetCurrentSpan ¶
func (mr *MockSpannerMockRecorder) GetCurrentSpan(arg0, arg1 interface{}) *gomock.Call
GetCurrentSpan indicates an expected call of GetCurrentSpan.
func (*MockSpannerMockRecorder) GetCurrentValidatorsByBlockNrOrHash ¶
func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByBlockNrOrHash(arg0, arg1, arg2 interface{}) *gomock.Call
GetCurrentValidatorsByBlockNrOrHash indicates an expected call of GetCurrentValidatorsByBlockNrOrHash.
func (*MockSpannerMockRecorder) GetCurrentValidatorsByHash ¶
func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByHash(arg0, arg1, arg2 interface{}) *gomock.Call
GetCurrentValidatorsByHash indicates an expected call of GetCurrentValidatorsByHash.
type SignerFn ¶
SignerFn is a signer callback function to request a header to be signed by a backing account.
type Snapshot ¶
type Snapshot struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created ValidatorSet *valset.ValidatorSet `json:"validatorSet"` // Validator set at this moment Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections // contains filtered or unexported fields }
Snapshot is the state of the authorization voting at a given point in time.
type Spanner ¶
type Spanner interface { GetCurrentSpan(ctx context.Context, headerHash common.Hash) (*span.Span, error) GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error) CommitSpan(ctx context.Context, heimdallSpan span.HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error }
type UnauthorizedProposerError ¶
type UnauthorizedProposerError struct {}
UnauthorizedProposerError is returned if a header is [being] signed by an unauthorized entity.
func (*UnauthorizedProposerError) Error ¶
func (e *UnauthorizedProposerError) Error() string
type UnauthorizedSignerError ¶
type UnauthorizedSignerError struct {}
UnauthorizedSignerError is returned if a header is [being] signed by an unauthorized entity.
func (*UnauthorizedSignerError) Error ¶
func (e *UnauthorizedSignerError) Error() string
type WrongDifficultyError ¶
WrongDifficultyError is returned if the difficulty of a block doesn't match the turn of the signer.
func (*WrongDifficultyError) Error ¶
func (e *WrongDifficultyError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package api is a generated GoMock package.
|
Package api is a generated GoMock package. |