Documentation ¶
Index ¶
- Constants
- Variables
- func AddrBookPath(chainRootDir string) string
- func ExtractConsensusParams(cp *chain.BaseConsensusParams, appVersion uint64) *cmtTypes.ConsensusParams
- func MergeConsensusParams(cometbftParams *cmtTypes.ConsensusParams, abciParams *common.NetworkParameters) *chain.ConsensusParams
- func NodeIDAddressString(pubkey ed25519.PubKey, hostPort string) string
- func ParamUpdatesToComet(up *consensus.ParamUpdates) *cmtproto.ConsensusParams
- func PubkeyToAddr(pubkey []byte) (string, error)
- type CometBftNode
- type LogWrapper
- type PeerWhiteList
- func (p *PeerWhiteList) AddAndPersistPeer(ctx context.Context, peer string) error
- func (p *PeerWhiteList) AddPeer(ctx context.Context, peer string) error
- func (p *PeerWhiteList) IsPeerWhitelisted(peer string) bool
- func (p *PeerWhiteList) ListPeers(ctx context.Context) []string
- func (p *PeerWhiteList) RemovePeer(ctx context.Context, peer string) error
- func (p *PeerWhiteList) RemovePersistedPeer(ctx context.Context, peer string) error
- func (p *PeerWhiteList) SetRemovePeerFn(fn func(peerID string) error)
Constants ¶
const ( DataDir = "data" GenesisJSONName = "genesis.json" ConfigTOMLName = "config.toml" AddrBookFileName = "addrbook.json" )
CometBFT file and folder names. These will be under the chain root directory. e.g. With "abci" a the chain root directory set in cometbft's config, this give the paths "abci/config/genesis.json" and "abci/data".
Variables ¶
var ( ErrPeerAlreadyWhitelisted = fmt.Errorf("peer already whitelisted") ErrPeerNotWhitelisted = fmt.Errorf("peer not whitelisted") )
Functions ¶
func AddrBookPath ¶
func ExtractConsensusParams ¶ added in v0.8.1
func ExtractConsensusParams(cp *chain.BaseConsensusParams, appVersion uint64) *cmtTypes.ConsensusParams
ExtractConsensusParams creates cometbft's ConsensusParams from kwild's, which includes a subset of cometbft's and other parameters that pertain to the ABCI application (kwild) rather than the consensus engine (cometbft). The appVersion indicates state machine logic and it not an application parameter.
func MergeConsensusParams ¶ added in v0.9.0
func MergeConsensusParams(cometbftParams *cmtTypes.ConsensusParams, abciParams *common.NetworkParameters) *chain.ConsensusParams
MergeConsensusParams merges cometbft's ConsensusParams with kwild's NetworkParameters to create a unified representation of the chain's consensus parameters.
func NodeIDAddressString ¶
NodeIDAddressString makes a full CometBFT node ID address string in the format <nodeID>@hostPort where nodeID is derived from the provided public key.
func ParamUpdatesToComet ¶ added in v0.8.1
func ParamUpdatesToComet(up *consensus.ParamUpdates) *cmtproto.ConsensusParams
ParamUpdatesToComet converts the parameter updates to cometBFT's
func PubkeyToAddr ¶ added in v0.9.0
PubkeyToAddr converts an Ed25519 public key as used to identify nodes in CometBFT into an address, which for ed25519 in comet is an upper case truncated sha256 hash of the pubkey. For secp256k1, they do like BTC with RIPEMD160(SHA256(pubkey)). If we support both (if either), we'll need a type flag.
Types ¶
type CometBftNode ¶
type CometBftNode struct {
Node *cometNodes.Node
}
func NewCometBftNode ¶
func NewCometBftNode(ctx context.Context, app abciTypes.Application, conf *cometConfig.Config, genDoc *types.GenesisDoc, privateKey cometEd25519.PrivKey, atomicStore privval.AtomicReadWriter, logger *log.Logger) (*CometBftNode, error)
NewCometBftNode creates a new CometBFT node.
func (*CometBftNode) ConsensusParams ¶ added in v0.9.0
func (n *CometBftNode) ConsensusParams(ctx context.Context, height *int64) *types.ConsensusParams
func (*CometBftNode) IsCatchup ¶
func (n *CometBftNode) IsCatchup() bool
IsCatchup returns true if the node is operating in catchup / blocksync mode. If the node is caught up with the network, it returns false.
func (*CometBftNode) RemovePeer ¶ added in v0.9.0
func (n *CometBftNode) RemovePeer(nodeID string) error
type LogWrapper ¶
type LogWrapper struct {
// contains filtered or unexported fields
}
LogWrapper that implements cometbft's Logger interface.
func NewLogWrapper ¶
func NewLogWrapper(log *log.Logger) *LogWrapper
NewLogWrapper creates a new LogWrapper using the provided Kwil Logger.
func (*LogWrapper) Debug ¶
func (lw *LogWrapper) Debug(msg string, kvs ...any)
func (*LogWrapper) Error ¶
func (lw *LogWrapper) Error(msg string, kvs ...any)
func (*LogWrapper) Info ¶
func (lw *LogWrapper) Info(msg string, kvs ...any)
type PeerWhiteList ¶ added in v0.9.0
type PeerWhiteList struct {
// contains filtered or unexported fields
}
PeerWhitelist object is used to manage the set of peers that a node is allowed to connect to. Whitelist peers are the list of allowed nodes that the node can accept connections from. Whitelist peers can be configured using the "chain.p2p.whitelist_peers" config in the config.toml file and can be updated dynamically using kwil-admin commands. The genesis validators are by default added to the whitelist peers during genesis. Any new validators are automatically added to the whitelist peers and demoted validators are removed from the whitelist. The Peers gossiped using PEX are not automatically trusted, and to be added manually if needed.
func P2PInit ¶ added in v0.9.0
func P2PInit(ctx context.Context, db sql.TxMaker, privateMode bool, whitelistPeers []string, nodeID string) (*PeerWhiteList, error)
NewPeers creates a new Peers object.
func (*PeerWhiteList) AddAndPersistPeer ¶ added in v0.9.0
func (p *PeerWhiteList) AddAndPersistPeer(ctx context.Context, peer string) error
AddAndPersistPeer adds a peer to the whitelistPeers list and persists the peer to disk.
func (*PeerWhiteList) AddPeer ¶ added in v0.9.0
func (p *PeerWhiteList) AddPeer(ctx context.Context, peer string) error
AddPeer adds a peer to the whitelistPeers list. If the peer is already in the list, it returns an error indicating that the peer is already whitelisted.
func (*PeerWhiteList) IsPeerWhitelisted ¶ added in v0.9.0
func (p *PeerWhiteList) IsPeerWhitelisted(peer string) bool
IsPeerWhitelisted checks if a peer is in the list of whitelisted peers. If the node is running with private mode disabled, it always returns true.
func (*PeerWhiteList) ListPeers ¶ added in v0.9.0
func (p *PeerWhiteList) ListPeers(ctx context.Context) []string
ListPeers returns the list of whitelisted peers.
func (*PeerWhiteList) RemovePeer ¶ added in v0.9.0
func (p *PeerWhiteList) RemovePeer(ctx context.Context, peer string) error
RemovePeer gracefully stops an existing peer connection and removes the peer from the whitelisted peers list. If the peer is not found in the whitelistPeers list, it returns an error indicating that the peer is not found.
func (*PeerWhiteList) RemovePersistedPeer ¶ added in v0.9.0
func (p *PeerWhiteList) RemovePersistedPeer(ctx context.Context, peer string) error
RemovePersistedPeer removes a peer from the whitelistPeers list and from the database.
func (*PeerWhiteList) SetRemovePeerFn ¶ added in v0.9.0
func (p *PeerWhiteList) SetRemovePeerFn(fn func(peerID string) error)