Documentation
¶
Index ¶
- Constants
- Variables
- func ExpandPath(path string) (string, error)
- func FormatPeerString(rawPubKey []byte, keyType crypto.KeyType, ip string, port int) string
- func NewKey(r io.Reader) *crypto.Secp256k1PrivateKey
- func RestoreDB(ctx context.Context, reader io.Reader, db config.DBConfig, snapshotHash []byte, ...) error
- type AckRes
- type BlockProcessor
- type Config
- type ConsensusEngine
- type ConsensusReset
- type DB
- type ErrNotFoundWithBestHeight
- type Node
- func (n *Node) AbortBlockExecution(height int64, txIDs []types.Hash) error
- func (n *Node) Addrs() []string
- func (n *Node) BlockByHash(hash types.Hash) (*ktypes.Block, *ktypes.CommitInfo, error)
- func (n *Node) BlockByHeight(height int64) (types.Hash, *ktypes.Block, *ktypes.CommitInfo, error)
- func (n *Node) BlockHeight() int64
- func (n *Node) BlockResultByHash(hash types.Hash) ([]ktypes.TxResult, error)
- func (n *Node) BroadcastTx(ctx context.Context, tx *ktypes.Transaction, sync uint8) (ktypes.Hash, *ktypes.TxResult, error)
- func (n *Node) ChainTx(hash types.Hash) (*chainTypes.Tx, error)
- func (n *Node) ChainUnconfirmedTx(limit int) (int, []*types.Tx)
- func (n *Node) ConsensusParams() *ktypes.NetworkParameters
- func (n *Node) Dir() string
- func (n *Node) ID() string
- func (n *Node) InCatchup() bool
- func (n *Node) MultiAddrs() []string
- func (n *Node) Peers(context.Context) ([]*adminTypes.PeerInfo, error)
- func (n *Node) PromoteLeader(candidate crypto.PublicKey, height int64) error
- func (n *Node) RawBlockByHash(hash types.Hash) ([]byte, *ktypes.CommitInfo, error)
- func (n *Node) RawBlockByHeight(height int64) (types.Hash, []byte, *ktypes.CommitInfo, error)
- func (n *Node) Role() types.Role
- func (n *Node) Start(ctx context.Context) error
- func (n *Node) Status(ctx context.Context) (*adminTypes.Status, error)
- func (n *Node) TxQuery(ctx context.Context, hash types.Hash, prove bool) (*ktypes.TxQueryResponse, error)
- func (n *Node) Whitelister() *WhitelistMgr
- type Option
- type P2PService
- type P2PServiceConfig
- type SnapshotStore
- type StateSyncService
- func (s *StateSyncService) Bootstrap(ctx context.Context) error
- func (s *StateSyncService) DiscoverSnapshots(ctx context.Context) (int64, error)
- func (ss *StateSyncService) DoStatesync(ctx context.Context) (bool, error)
- func (ss *StateSyncService) VerifySnapshot(ctx context.Context, snap *snapshotMetadata) (bool, []byte)
- type StatesyncConfig
- type Streamer
- type WhitelistMgr
Constants ¶
const ( TopicACKs = "acks" TopicReset = "reset" TopicDiscReq = "discovery_request" TopicDiscResp = "discovery_response" )
const ( ProtocolIDDiscover = peers.ProtocolIDDiscover ProtocolIDCrawler = peers.ProtocolIDCrawler ProtocolIDTx protocol.ID = "/kwil/tx/1.0.0" ProtocolIDTxAnn protocol.ID = "/kwil/txann/1.0.0" ProtocolIDBlockHeight protocol.ID = "/kwil/blkheight/1.1.0" ProtocolIDBlock protocol.ID = "/kwil/blk/1.0.0" ProtocolIDBlkAnn protocol.ID = "/kwil/blkann/1.0.0" ProtocolIDBlockPropose protocol.ID = "/kwil/blkprop/1.0.0" )
const AppVersion = 1
AppVersion encompasses all aspects of the Kwil DB application. A new version indicates incompatible changes to the application, and nodes with different versions should not communicate (TODO).
Variables ¶
var ( ErrNotFound = errors.New("resource not available") ErrTxNotFound = types.ErrTxNotFound ErrTxAlreadyExists = types.ErrTxAlreadyExists ErrBlkNotFound = types.ErrBlkNotFound ErrNoResponse = types.ErrNoResponse )
var (
ErrNoSnapshotsDiscovered = errors.New("no snapshots discovered")
)
var RequiredStreamProtocols = []protocol.ID{ ProtocolIDDiscover, ProtocolIDTx, ProtocolIDTxAnn, ProtocolIDBlockHeight, ProtocolIDBlock, ProtocolIDBlkAnn, ProtocolIDBlockPropose, pubsub.GossipSubID_v12, }
Functions ¶
func ExpandPath ¶
TODO: this is WRONG considering paths like ~user. We should rewrite this correctly, for both ~/ and ~user/ and without assuming a platform separator.
func FormatPeerString ¶
Types ¶
type BlockProcessor ¶
type Config ¶
type Config struct { RootDir string ChainID string PrivKey crypto.PrivateKey DB DB P2P *config.PeerConfig DBConfig *config.DBConfig Statesync *config.StateSyncConfig Mempool types.MemPool BlockStore types.BlockStore Consensus ConsensusEngine Snapshotter SnapshotStore BlockProc BlockProcessor Logger log.Logger P2PService *P2PService }
Config is the configuration for a Node instance.
type ConsensusEngine ¶
type ConsensusEngine interface { Status() *ktypes.NodeStatus // includes: role, inCatchup, consensus params, last commit info and block header Role() types.Role InCatchup() bool AcceptProposal(height int64, blkID, prevBlkID types.Hash, leaderSig []byte, timestamp int64) bool NotifyBlockProposal(blk *ktypes.Block, done func()) AcceptCommit(height int64, blkID types.Hash, hdr *ktypes.BlockHeader, ci *ktypes.CommitInfo, leaderSig []byte) bool NotifyBlockCommit(blk *ktypes.Block, ci *ktypes.CommitInfo, blkID types.Hash, doneFn func()) NotifyACK(validatorPK []byte, ack types.AckRes) NotifyResetState(height int64, txIDs []types.Hash, senderPubKey []byte) NotifyDiscoveryMessage(validatorPK []byte, height int64) Start(ctx context.Context, fns consensus.BroadcastFns, peerFns consensus.WhitelistFns) error QueueTx(ctx context.Context, tx *types.Tx) error BroadcastTx(ctx context.Context, tx *types.Tx, sync uint8) (ktypes.Hash, *ktypes.TxResult, error) ConsensusParams() *ktypes.NetworkParameters CancelBlockExecution(height int64, txIDs []types.Hash) error // PromoteLeader is used to promote a validator to leader starting from the specified height PromoteLeader(leader crypto.PublicKey, height int64) error }
type ConsensusReset ¶
type ConsensusReset = types.ConsensusReset
type DB ¶
type DB interface { sql.ReadTxMaker }
type ErrNotFoundWithBestHeight ¶
type ErrNotFoundWithBestHeight struct {
BestHeight int64
}
ErrNotFoundWithBestHeight is an error that contains a BestHeight field, which is used when a block is not found, but the the negative responses from peers contained their best height.
Use with errors.As. For example:
func heightFromErr(err error) int64 { be := new(ErrNotFoundWithBestHeight) if errors.As(err, &be) { return be.BestHeight } return -1 }
func (*ErrNotFoundWithBestHeight) Error ¶
func (e *ErrNotFoundWithBestHeight) Error() string
type Node ¶
type Node struct { // Base services P2PService // contains filtered or unexported fields }
func NewNode ¶
NewNode creates a new node. The config struct is for required configuration, and the functional options for optional settings, like dependency overrides.
func (*Node) AbortBlockExecution ¶
func (*Node) BlockByHash ¶
BlockByHash returns the block by block hash.
func (*Node) BlockByHeight ¶
BlockByHeight returns the block by height. If height <= 0, the latest block will be returned.
func (*Node) BlockHeight ¶
func (*Node) BlockResultByHash ¶
BlockResultByHash returns the block result by block hash.
func (*Node) BroadcastTx ¶
func (*Node) ChainUnconfirmedTx ¶
ChainUnconfirmedTx return unconfirmed tx info that is used in Chain rpc.
func (*Node) ConsensusParams ¶
func (n *Node) ConsensusParams() *ktypes.NetworkParameters
func (*Node) MultiAddrs ¶
func (*Node) PromoteLeader ¶
func (*Node) RawBlockByHash ¶
RawBlockByHash returns the block by block hash.
func (*Node) RawBlockByHeight ¶
RawBlockByHeight returns the block by height. If height <= 0, the latest block will be returned.
func (*Node) Start ¶
Start begins tx and block gossip, connects to any bootstrap peers, and begins peer discovery.
func (*Node) Whitelister ¶
func (n *Node) Whitelister() *WhitelistMgr
Whitelister is a shim between the a Kwil consumer like RPC service and the p2p layer (PeerMan) which manages the persistent and effective white list in terms of libp2p types.
type P2PService ¶
type P2PService struct {
// contains filtered or unexported fields
}
func NewP2PService ¶
func NewP2PService(ctx context.Context, cfg *P2PServiceConfig, host host.Host) (*P2PService, error)
func (*P2PService) Close ¶
func (p *P2PService) Close() error
func (*P2PService) Discovery ¶
func (p *P2PService) Discovery() discovery.Discovery
func (*P2PService) Host ¶
func (p *P2PService) Host() host.Host
func (*P2PService) PEX ¶
func (p *P2PService) PEX() bool
PEX indicates whether the peer manager is configured to use peer exchange (PEX).
func (*P2PService) Start ¶
func (p *P2PService) Start(ctx context.Context, bootpeers ...string) error
Start launches the P2P service, registering the network Notifiee, and connecting to bootstrap peers. This method is NOT blocking. The context only affects the the connection process, and does not shutdown the service after this method has returned.
type P2PServiceConfig ¶
type SnapshotStore ¶
type StateSyncService ¶
type StateSyncService struct {
// contains filtered or unexported fields
}
func NewStateSyncService ¶
func NewStateSyncService(ctx context.Context, cfg *StatesyncConfig) (*StateSyncService, error)
func (*StateSyncService) Bootstrap ¶
func (s *StateSyncService) Bootstrap(ctx context.Context) error
func (*StateSyncService) DiscoverSnapshots ¶
func (s *StateSyncService) DiscoverSnapshots(ctx context.Context) (int64, error)
DiscoverSnapshots discovers snapshot providers and their catalogs. It waits for responsesp from snapshot catalog providers for the duration of the discoveryTimeout. If the timeout is reached, the best snapshot is selected and snapshot chunks are requested. If no snapshots are discovered, it reenters the discovery phase after a delay, retrying up to maxRetries times. If discovery fails after maxRetries, the node will switch to block sync. If snapshots and their chunks are successfully fetched, the DB is restored from the snapshot and the application state is verified.
func (*StateSyncService) DoStatesync ¶
func (ss *StateSyncService) DoStatesync(ctx context.Context) (bool, error)
DoStatesync attempts to perform statesync if the db is uninitialized. It also initializes the blockstore with the initial block data at the height of the discovered snapshot.
func (*StateSyncService) VerifySnapshot ¶
func (ss *StateSyncService) VerifySnapshot(ctx context.Context, snap *snapshotMetadata) (bool, []byte)
verifySnapshot verifies the snapshot with the trusted provider and returns the app hash if the snapshot is valid.
type StatesyncConfig ¶
type StatesyncConfig struct { StateSyncCfg *config.StateSyncConfig DBConfig config.DBConfig RcvdSnapsDir string P2PService *P2PService DB DB SnapshotStore SnapshotStore BlockStore blockStore Logger log.Logger }
type Streamer ¶
type Streamer struct {
// contains filtered or unexported fields
}
Utility to stream chunks of a snapshot
type WhitelistMgr ¶
type WhitelistMgr struct {
// contains filtered or unexported fields
}
func (*WhitelistMgr) AddPeer ¶
func (wl *WhitelistMgr) AddPeer(nodeID string) error
func (*WhitelistMgr) List ¶
func (wl *WhitelistMgr) List() []string
func (*WhitelistMgr) RemovePeer ¶
func (wl *WhitelistMgr) RemovePeer(nodeID string) error
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
package adminclient provides a client for the Kwil admin service.
|
package adminclient provides a client for the Kwil admin service. |
interpreter
package interpreter provides a basic interpreter for Kuneiform procedures.
|
package interpreter provides a basic interpreter for Kuneiform procedures. |
parse
package parse contains logic for parsing SQL, DDL, and Actions, and SQL.
|
package parse contains logic for parsing SQL, DDL, and Actions, and SQL. |
pg_generate
pggenerate package is responsible for generating the Postgres-compatible SQL from the AST.
|
pggenerate package is responsible for generating the Postgres-compatible SQL from the AST. |
exts
|
|
erc20-bridge/erc20
package erc20reward implements a meta extension that manages all rewards on a Kwil network.
|
package erc20reward implements a meta extension that manages all rewards on a Kwil network. |
erc20-bridge/signersvc
Package signersvc implements the SignerSvc of the Kwil reward system.
|
Package signersvc implements the SignerSvc of the Kwil reward system. |
evm-sync/chains
package chains tracks the EVM chains that are supported by the node.
|
package chains tracks the EVM chains that are supported by the node. |
ordered-sync
package orderedsync is a general purpose extension that synchronizes data from systems where absolute order is guaranteed (e.g.
|
package orderedsync is a general purpose extension that synchronizes data from systems where absolute order is guaranteed (e.g. |
poll
package poll implements a basic polling mechanism for Kwil event listeners
|
package poll implements a basic polling mechanism for Kwil event listeners |
Package meta defines a chain metadata store for the ABCI application.
|
Package meta defines a chain metadata store for the ABCI application. |
package migrations implements a long-running migrations protocol for Kwil.
|
package migrations implements a long-running migrations protocol for Kwil. |
Package pg defines the primary PostgreSQL-powered DB and Pool types used to support Kwil DB.
|
Package pg defines the primary PostgreSQL-powered DB and Pool types used to support Kwil DB. |
services
|
|
memstore
Package memstore provides a memory-backed block store, which is only suitable for testing where a disk-based store or third party dependencies are not desired.
|
Package memstore provides a memory-backed block store, which is only suitable for testing where a disk-based store or third party dependencies are not desired. |
package tx_router routes transactions to the appropriate module(s)
|
package tx_router routes transactions to the appropriate module(s) |
sql
Package sql defines common type required by SQL database implementations and consumers.
|
Package sql defines common type required by SQL database implementations and consumers. |
utils
|
|
syncmap
Package syncmap provides a map that is safe for concurrent use.
|
Package syncmap provides a map that is safe for concurrent use. |
url
package url provides url fuctionalities to provide consistent parsing for Kwil clients.
|
package url provides url fuctionalities to provide consistent parsing for Kwil clients. |
package versioning provides standard schema versioning for Kwil databases.
|
package versioning provides standard schema versioning for Kwil databases. |
package events is used to track events that need to be included in a Kwil block.
|
package events is used to track events that need to be included in a Kwil block. |