Documentation
¶
Overview ¶
Package backend defines backend struct which implements Backend interface of Istanbul consensus engine. backend struct works as a backbone of the consensus engine having Istanbul core, required objects to get information for making a consensus, recent messages and a broadcaster to send its message to peer nodes.
Source Files ¶
Implementation of Backend interface and APIs are included in this package
- `api.go`: Implements APIs which provide the states of Istanbul
- `backend.go`: Defines backend struct which implements Backend interface working as a backbone of the consensus engine
- `engine.go`: Implements various backend methods especially for verifying and building header information
- `handler.go`: Implements backend methods for handling messages and broadcaster
- `snapshot.go`: Defines snapshot struct which handles votes from nodes and makes governance changes
Copyright 2024 The Kaia Authors This file is part of the Kaia library.
The Kaia library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Kaia library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Kaia library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func New(opts *BackendOpts) consensus.Istanbul
- func RecoverCommittedSeals(extra *types.IstanbulExtra, headerHash common.Hash) ([]common.Address, error)
- type API
- func (api *API) Candidates() map[common.Address]bool
- func (api *API) Discard(address common.Address)
- func (api *API) GetDemotedValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetDemotedValidatorsAtHash(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) GetTimeout() uint64
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) Propose(address common.Address, auth bool)
- type APIExtension
- func (api *APIExtension) GetActiveAddressFromRegistry(name string, number rpc.BlockNumber) (common.Address, error)
- func (api *APIExtension) GetAllRecordsFromRegistry(name string, number rpc.BlockNumber) ([]interface{}, error)
- func (api *APIExtension) GetBlockWithConsensusInfoByHash(blockHash common.Hash) (map[string]interface{}, error)
- func (api *APIExtension) GetBlockWithConsensusInfoByNumber(number *rpc.BlockNumber) (map[string]interface{}, error)
- func (api *APIExtension) GetBlockWithConsensusInfoByNumberRange(start *rpc.BlockNumber, end *rpc.BlockNumber) (map[string]interface{}, error)
- func (api *APIExtension) GetBlsInfos(number rpc.BlockNumber) (map[string]interface{}, error)
- func (api *APIExtension) GetCommittee(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *APIExtension) GetCommitteeSize(number *rpc.BlockNumber) (int, error)
- func (api *APIExtension) GetCouncil(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *APIExtension) GetCouncilSize(number *rpc.BlockNumber) (int, error)
- type BackendOpts
- type BlsPubkeyProvider
- type ChainBlsPubkeyProvider
- type Snapshot
Constants ¶
const (
IstanbulMsg = 0x11
)
Variables ¶
var ( // TODO-Kaia-Istanbul: define Versions and Lengths with correct values. IstanbulProtocol = consensus.Protocol{ Name: "istanbul", Versions: []uint{65, 64}, Lengths: []uint64{23, 21}, } )
Functions ¶
func New ¶
func New(opts *BackendOpts) consensus.Istanbul
func RecoverCommittedSeals ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to dump Istanbul state
func (*API) Candidates ¶
Candidates returns the current candidates the node tries to uphold and vote on.
func (*API) Discard ¶
Discard drops a currently running candidate, stopping the validator from casting further votes (either for or against).
func (*API) GetDemotedValidators ¶
GetDemotedValidators retrieves the list of authorized, but demoted validators with the given block number.
func (*API) GetDemotedValidatorsAtHash ¶
GetDemotedValidatorsAtHash retrieves the list of authorized, but demoted validators with the given block hash.
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) GetTimeout ¶
func (*API) GetValidators ¶
GetValidators retrieves the list of authorized validators with the given block number.
func (*API) GetValidatorsAtHash ¶
GetValidatorsAtHash retrieves the list of authorized validators with the given block hash.
type APIExtension ¶
type APIExtension struct {
// contains filtered or unexported fields
}
API extended by Kaia developers
func (*APIExtension) GetActiveAddressFromRegistry ¶
func (api *APIExtension) GetActiveAddressFromRegistry(name string, number rpc.BlockNumber) (common.Address, error)
func (*APIExtension) GetAllRecordsFromRegistry ¶
func (api *APIExtension) GetAllRecordsFromRegistry(name string, number rpc.BlockNumber) ([]interface{}, error)
func (*APIExtension) GetBlockWithConsensusInfoByHash ¶
func (api *APIExtension) GetBlockWithConsensusInfoByHash(blockHash common.Hash) (map[string]interface{}, error)
func (*APIExtension) GetBlockWithConsensusInfoByNumber ¶
func (api *APIExtension) GetBlockWithConsensusInfoByNumber(number *rpc.BlockNumber) (map[string]interface{}, error)
TODO-Kaia: This API functions should be managed with API functions with namespace "kaia"
func (*APIExtension) GetBlockWithConsensusInfoByNumberRange ¶
func (api *APIExtension) GetBlockWithConsensusInfoByNumberRange(start *rpc.BlockNumber, end *rpc.BlockNumber) (map[string]interface{}, error)
func (*APIExtension) GetBlsInfos ¶
func (api *APIExtension) GetBlsInfos(number rpc.BlockNumber) (map[string]interface{}, error)
func (*APIExtension) GetCommittee ¶
func (api *APIExtension) GetCommittee(number *rpc.BlockNumber) ([]common.Address, error)
func (*APIExtension) GetCommitteeSize ¶
func (api *APIExtension) GetCommitteeSize(number *rpc.BlockNumber) (int, error)
func (*APIExtension) GetCouncil ¶
func (api *APIExtension) GetCouncil(number *rpc.BlockNumber) ([]common.Address, error)
GetCouncil retrieves the list of authorized validators at the specified block.
func (*APIExtension) GetCouncilSize ¶
func (api *APIExtension) GetCouncilSize(number *rpc.BlockNumber) (int, error)
type BackendOpts ¶
type BackendOpts struct { IstanbulConfig *istanbul.Config // Istanbul consensus core config Rewardbase common.Address PrivateKey *ecdsa.PrivateKey // Consensus message signing key BlsSecretKey bls.SecretKey // Randao signing key. Required since Randao fork DB database.DBManager Governance governance.Engine // Governance parameter provider BlsPubkeyProvider BlsPubkeyProvider // If not nil, override the default BLS public key provider NodeType common.ConnType }
type BlsPubkeyProvider ¶
type BlsPubkeyProvider interface { // num should be the header number of the block to be verified. // Thus, since the state of num does not exist, the state of num-1 must be used. GetBlsPubkey(chain consensus.ChainReader, proposer common.Address, num *big.Int) (bls.PublicKey, error) ResetBlsCache() }
For testing without KIP-113 contract setup
type ChainBlsPubkeyProvider ¶
type ChainBlsPubkeyProvider struct {
// contains filtered or unexported fields
}
func (*ChainBlsPubkeyProvider) GetBlsPubkey ¶
func (p *ChainBlsPubkeyProvider) GetBlsPubkey(chain consensus.ChainReader, proposer common.Address, num *big.Int) (bls.PublicKey, error)
The default implementation for BlsPubkeyFunc. Queries KIP-113 contract and verifies the PoP.
func (*ChainBlsPubkeyProvider) ResetBlsCache ¶
func (p *ChainBlsPubkeyProvider) ResetBlsCache()
type Snapshot ¶
type Snapshot struct { Epoch uint64 // The number of blocks after which to checkpoint and reset the pending votes Number uint64 // Block number where the snapshot was created Hash common.Hash // Block hash where the snapshot was created ValSet istanbul.ValidatorSet // Set of authorized validators at this moment Policy uint64 CommitteeSize uint64 Votes []governance.GovernanceVote // List of votes cast in chronological order Tally []governance.GovernanceTallyItem // Current vote tally to avoid recalculating }
Snapshot is the state of the authorization voting at a given point in time.
func (*Snapshot) MarshalJSON ¶
Marshal to a json byte array
func (*Snapshot) UnmarshalJSON ¶
Unmarshal from a json byte array