Documentation
¶
Overview ¶
Package api provides the implementation agnostic consensus API.
Index ¶
- Constants
- Variables
- func NewBlockMetadataTx(meta *BlockMetadata) *transaction.Transaction
- func RegisterService(server *grpc.Server, service Services)
- func SignAndSubmitTx(ctx context.Context, consensus Service, signer signature.Signer, ...) error
- func SignAndSubmitTxWithProof(ctx context.Context, consensus Service, signer signature.Signer, ...) (*transaction.SignedTransaction, *transaction.Proof, error)
- type Backend
- type Block
- type BlockMetadata
- type BlockResults
- type Client
- func (c *Client) EstimateGas(ctx context.Context, req *EstimateGasRequest) (transaction.Gas, error)
- func (c *Client) GetBlock(ctx context.Context, height int64) (*Block, error)
- func (c *Client) GetBlockResults(ctx context.Context, height int64) (*BlockResults, error)
- func (c *Client) GetChainContext(ctx context.Context) (string, error)
- func (c *Client) GetGenesisDocument(ctx context.Context) (*genesis.Document, error)
- func (c *Client) GetLastRetainedHeight(ctx context.Context) (int64, error)
- func (c *Client) GetLatestHeight(ctx context.Context) (int64, error)
- func (c *Client) GetLightBlock(ctx context.Context, height int64) (*LightBlock, error)
- func (c *Client) GetNextBlockState(ctx context.Context) (*NextBlockState, error)
- func (c *Client) GetParameters(ctx context.Context, height int64) (*Parameters, error)
- func (c *Client) GetSignerNonce(ctx context.Context, req *GetSignerNonceRequest) (uint64, error)
- func (c *Client) GetStatus(ctx context.Context) (*Status, error)
- func (c *Client) GetTransactions(ctx context.Context, height int64) ([][]byte, error)
- func (c *Client) GetTransactionsWithProofs(ctx context.Context, height int64) (*TransactionsWithProofs, error)
- func (c *Client) GetTransactionsWithResults(ctx context.Context, height int64) (*TransactionsWithResults, error)
- func (c *Client) GetUnconfirmedTransactions(ctx context.Context) ([][]byte, error)
- func (c *Client) MinGasPrice(ctx context.Context) (*quantity.Quantity, error)
- func (c *Client) State() syncer.ReadSyncer
- func (c *Client) StateToGenesis(ctx context.Context, height int64) (*genesis.Document, error)
- func (c *Client) SubmitEvidence(ctx context.Context, evidence *Evidence) error
- func (c *Client) SubmitTx(ctx context.Context, tx *transaction.SignedTransaction) error
- func (c *Client) SubmitTxNoWait(ctx context.Context, tx *transaction.SignedTransaction) error
- func (c *Client) SubmitTxWithProof(ctx context.Context, tx *transaction.SignedTransaction) (*transaction.Proof, error)
- func (c *Client) WatchBlocks(ctx context.Context) (<-chan *Block, pubsub.ClosableSubscription, error)
- type EstimateGasRequest
- type Evidence
- type FeatureMask
- type GetSignerNonceRequest
- type LightBlock
- type LightClient
- type LightClientStatus
- type LightProvider
- type LightService
- type NextBlockState
- type NoOpSubmissionManager
- func (m *NoOpSubmissionManager) EstimateGasAndSetFee(context.Context, signature.Signer, *transaction.Transaction) error
- func (m *NoOpSubmissionManager) PriceDiscovery() PriceDiscovery
- func (m *NoOpSubmissionManager) SignAndSubmitTx(context.Context, signature.Signer, *transaction.Transaction) error
- func (m *NoOpSubmissionManager) SignAndSubmitTxWithProof(context.Context, signature.Signer, *transaction.Transaction) (*transaction.SignedTransaction, *transaction.Proof, error)
- type P2PStatus
- type Parameters
- type PriceDiscovery
- type Service
- type Services
- type ServicesClient
- func (c *ServicesClient) Beacon() beacon.Backend
- func (c *ServicesClient) Core() Backend
- func (c *ServicesClient) Governance() governance.Backend
- func (c *ServicesClient) KeyManager() keymanager.Backend
- func (c *ServicesClient) Registry() registry.Backend
- func (c *ServicesClient) RootHash() roothash.Backend
- func (c *ServicesClient) Scheduler() scheduler.Backend
- func (c *ServicesClient) Staking() staking.Backend
- func (c *ServicesClient) Vault() vault.Backend
- type StatePruneHandler
- type StatePruner
- type Status
- type StatusState
- type SubmissionManager
- type TransactionsWithProofs
- type TransactionsWithResults
- type Vote
- type Votes
Constants ¶
const ( // ModuleName is the module name used for error definitions. ModuleName = "consensus" // HeightLatest is the height that represents the most recent block height. HeightLatest int64 = 0 )
const BlockMetadataMaxSize = 16_384
BlockMetadataMaxSize is the maximum size of a fully populated and signed block metadata transaction.
This should be less than any reasonably configured MaxTxSize.
Variables ¶
var ( // ErrNoCommittedBlocks is the error returned when there are no committed // blocks and as such no state can be queried. ErrNoCommittedBlocks = errors.New(ModuleName, 1, "consensus: no committed blocks") // ErrOversizedTx is the error returned when the given transaction is too big to be processed. ErrOversizedTx = errors.New(ModuleName, 2, "consensus: oversized transaction") // ErrVersionNotFound is the error returned when the given version (height) cannot be found, // possibly because it was pruned. ErrVersionNotFound = errors.New(ModuleName, 3, "consensus: version not found") // ErrUnsupported is the error returned when the given method is not supported by the consensus // backend. ErrUnsupported = errors.New(ModuleName, 4, "consensus: method not supported") // ErrDuplicateTx is the error returned when the transaction already exists in the mempool. ErrDuplicateTx = errors.New(ModuleName, 5, "consensus: duplicate transaction") // ErrInvalidArgument is the error returned when the request contains an invalid argument. ErrInvalidArgument = errors.New(ModuleName, 6, "consensus: invalid argument") // SystemMethods is a map of all system methods. SystemMethods = map[transaction.MethodName]struct{}{ MethodMeta: {}, } // KeyFormat is the namespace for the consensus state key formats. KeyFormat = keyformat.NewNamespace("consensus") )
var MethodMeta = transaction.NewMethodName(ModuleName, "Meta", BlockMetadata{})
MethodMeta is the method name for the special block metadata transaction.
Functions ¶
func NewBlockMetadataTx ¶ added in v0.2300.0
func NewBlockMetadataTx(meta *BlockMetadata) *transaction.Transaction
NewBlockMetadataTx creates a new block metadata transaction.
func RegisterService ¶
RegisterService registers a new client backend service with the given gRPC server.
func SignAndSubmitTx ¶
func SignAndSubmitTx(ctx context.Context, consensus Service, signer signature.Signer, tx *transaction.Transaction) error
SignAndSubmitTx is a helper function that signs and submits a transaction to the consensus backend.
If the nonce is set to zero, it will be automatically filled in based on the current consensus state.
If the fee is set to nil, it will be automatically filled in based on gas estimation and current gas price discovery.
func SignAndSubmitTxWithProof ¶ added in v0.2202.0
func SignAndSubmitTxWithProof(ctx context.Context, consensus Service, signer signature.Signer, tx *transaction.Transaction) (*transaction.SignedTransaction, *transaction.Proof, error)
SignAndSubmitTxWithProof is a helper function that signs and submits a transaction to the consensus backend and creates a proof of inclusion.
If the nonce is set to zero, it will be automatically filled in based on the current consensus state.
If the fee is set to nil, it will be automatically filled in based on gas estimation and current gas price discovery.
Types ¶
type Backend ¶
type Backend interface { // SubmitTx submits a signed consensus transaction and waits for the transaction to be included // in a block. Use SubmitTxNoWait if you only need to broadcast the transaction. SubmitTx(ctx context.Context, tx *transaction.SignedTransaction) error // SubmitTxNoWait submits a signed consensus transaction, but does not wait for the transaction // to be included in a block. Use SubmitTx if you need to wait for execution. SubmitTxNoWait(ctx context.Context, tx *transaction.SignedTransaction) error // SubmitTxWithProof submits a signed consensus transaction, waits for the transaction to be // included in a block and returns a proof of inclusion. SubmitTxWithProof(ctx context.Context, tx *transaction.SignedTransaction) (*transaction.Proof, error) // StateToGenesis returns the genesis state at the specified block height. StateToGenesis(ctx context.Context, height int64) (*genesis.Document, error) // EstimateGas calculates the amount of gas required to execute the given transaction. EstimateGas(ctx context.Context, req *EstimateGasRequest) (transaction.Gas, error) // MinGasPrice returns the minimum gas price. MinGasPrice(ctx context.Context) (*quantity.Quantity, error) // GetBlock returns a consensus block at a specific height. GetBlock(ctx context.Context, height int64) (*Block, error) // GetBlockResults returns the consensus block results at a specific height. GetBlockResults(ctx context.Context, height int64) (*BlockResults, error) // GetLightBlock returns a light version of the consensus layer block that can be used for light // client verification. GetLightBlock(ctx context.Context, height int64) (*LightBlock, error) // GetLatestHeight returns the height of the latest consensus block. GetLatestHeight(ctx context.Context) (int64, error) // GetLastRetainedHeight returns the height of the oldest retained consensus block. GetLastRetainedHeight(ctx context.Context) (int64, error) // State returns a MKVS read syncer that can be used to read consensus state from a remote node // and verify it against the trusted local root. State() syncer.ReadSyncer // GetParameters returns the consensus parameters for a specific height. GetParameters(ctx context.Context, height int64) (*Parameters, error) // SubmitEvidence submits evidence of misbehavior. SubmitEvidence(ctx context.Context, evidence *Evidence) error // GetSignerNonce returns the nonce that should be used by the given // signer for transmitting the next transaction. // // Deprecated: Use staking backend instead. GetSignerNonce(ctx context.Context, req *GetSignerNonceRequest) (uint64, error) // GetTransactions returns a list of all transactions contained within a // consensus block at a specific height. // // NOTE: Any of these transactions could be invalid. GetTransactions(ctx context.Context, height int64) ([][]byte, error) // GetTransactionsWithResults returns a list of transactions and their // execution results, contained within a consensus block at a specific // height. GetTransactionsWithResults(ctx context.Context, height int64) (*TransactionsWithResults, error) // GetTransactionsWithProofs returns a list of all transactions and their proofs of inclusion // contained within a consensus block at a specific height. GetTransactionsWithProofs(ctx context.Context, height int64) (*TransactionsWithProofs, error) // GetUnconfirmedTransactions returns a list of transactions currently in the local node's // mempool. These have not yet been included in a block. GetUnconfirmedTransactions(ctx context.Context) ([][]byte, error) // WatchBlocks returns a channel that produces a stream of consensus // blocks as they are being finalized. WatchBlocks(ctx context.Context) (<-chan *Block, pubsub.ClosableSubscription, error) // GetGenesisDocument returns the original genesis document. GetGenesisDocument(ctx context.Context) (*genesis.Document, error) // GetChainContext returns the chain domain separation context. GetChainContext(ctx context.Context) (string, error) // GetStatus returns the current status overview. GetStatus(ctx context.Context) (*Status, error) // GetNextBlockState returns the state of the next block being voted on by validators. GetNextBlockState(ctx context.Context) (*NextBlockState, error) }
Backend is a consensus interface used by clients that connect to the local full node.
type Block ¶
type Block struct { // Height contains the block height. Height int64 `json:"height"` // Hash contains the block header hash. Hash hash.Hash `json:"hash"` // Time is the second-granular consensus time. Time time.Time `json:"time"` // StateRoot is the Merkle root of the consensus state tree. StateRoot mkvsNode.Root `json:"state_root"` // Size is the size of the block in bytes. Size uint64 `json:"size,omitempty"` // Meta contains the consensus backend specific block metadata. Meta cbor.RawMessage `json:"meta"` }
Block is a consensus block.
While some common fields are provided, most of the structure is dependent on the actual backend implementation.
type BlockMetadata ¶ added in v0.2300.0
type BlockMetadata struct { // StateRoot is the state root after executing all logic in the block. StateRoot hash.Hash `json:"state_root"` // EventsRoot is the provable events root. EventsRoot []byte `json:"events_root"` }
BlockMetadata contains additional metadata related to the executing block.
The metadata is included in the form of a special transaction where this structure is the transaction body.
func (*BlockMetadata) ValidateBasic ¶ added in v0.2300.0
func (bm *BlockMetadata) ValidateBasic() error
ValidateBasic performs basic block metadata structure validation.
type BlockResults ¶ added in v0.2503.0
type BlockResults struct { // Height contains the block height. Height int64 `json:"height"` // Meta contains the consensus backend specific block results metadata. Meta cbor.RawMessage `json:"meta"` }
BlockResults are consensus block results.
While some common fields are provided, most of the structure is dependent on the actual backend implementation.
type Client ¶ added in v0.2501.0
type Client struct {
// contains filtered or unexported fields
}
Client is a gRPC consensus client.
func NewClient ¶ added in v0.2501.0
func NewClient(c *grpc.ClientConn) *Client
NewClient creates a new gRPC consensus client.
func (*Client) EstimateGas ¶ added in v0.2501.0
func (c *Client) EstimateGas(ctx context.Context, req *EstimateGasRequest) (transaction.Gas, error)
func (*Client) GetBlockResults ¶ added in v0.2503.0
func (*Client) GetChainContext ¶ added in v0.2501.0
func (*Client) GetGenesisDocument ¶ added in v0.2501.0
func (*Client) GetLastRetainedHeight ¶ added in v0.2501.0
func (*Client) GetLatestHeight ¶ added in v0.2502.0
func (*Client) GetLightBlock ¶ added in v0.2501.0
func (*Client) GetNextBlockState ¶ added in v0.2501.0
func (c *Client) GetNextBlockState(ctx context.Context) (*NextBlockState, error)
func (*Client) GetParameters ¶ added in v0.2501.0
func (*Client) GetSignerNonce ¶ added in v0.2501.0
func (*Client) GetTransactions ¶ added in v0.2501.0
func (*Client) GetTransactionsWithProofs ¶ added in v0.2501.0
func (*Client) GetTransactionsWithResults ¶ added in v0.2501.0
func (*Client) GetUnconfirmedTransactions ¶ added in v0.2501.0
func (*Client) MinGasPrice ¶ added in v0.2501.0
func (*Client) State ¶ added in v0.2501.0
func (c *Client) State() syncer.ReadSyncer
func (*Client) StateToGenesis ¶ added in v0.2501.0
func (*Client) SubmitEvidence ¶ added in v0.2501.0
func (*Client) SubmitTx ¶ added in v0.2501.0
func (c *Client) SubmitTx(ctx context.Context, tx *transaction.SignedTransaction) error
func (*Client) SubmitTxNoWait ¶ added in v0.2501.0
func (c *Client) SubmitTxNoWait(ctx context.Context, tx *transaction.SignedTransaction) error
func (*Client) SubmitTxWithProof ¶ added in v0.2501.0
func (c *Client) SubmitTxWithProof(ctx context.Context, tx *transaction.SignedTransaction) (*transaction.Proof, error)
func (*Client) WatchBlocks ¶ added in v0.2501.0
type EstimateGasRequest ¶
type EstimateGasRequest struct { Signer signature.PublicKey `json:"signer"` Transaction *transaction.Transaction `json:"transaction"` }
EstimateGasRequest is a EstimateGas request.
type Evidence ¶
type Evidence struct { // Meta contains the consensus backend specific evidence. Meta []byte `json:"meta"` }
Evidence is evidence of a node's Byzantine behavior.
type FeatureMask ¶
type FeatureMask uint8
FeatureMask is the consensus backend feature bitmask.
const ( // FeatureServices indicates support for communicating with consensus services. FeatureServices FeatureMask = 1 << 0 // FeatureFullNode indicates that the consensus backend is independently fully verifying all // consensus-layer blocks. FeatureFullNode FeatureMask = 1 << 1 // FeatureArchiveNode indicates that the node is an archive node. FeatureArchiveNode FeatureMask = 1 << 2 )
func (FeatureMask) Has ¶
func (m FeatureMask) Has(f FeatureMask) bool
Has checks whether the feature bitmask includes specific features.
func (FeatureMask) String ¶
func (m FeatureMask) String() string
String returns a string representation of the consensus backend feature bitmask.
type GetSignerNonceRequest ¶
type GetSignerNonceRequest struct { AccountAddress staking.Address `json:"account_address"` Height int64 `json:"height"` }
GetSignerNonceRequest is a GetSignerNonce request.
type LightBlock ¶ added in v0.2010.0
type LightBlock struct { // Height contains the block height. Height int64 `json:"height"` // Meta contains the consensus backend specific light block. Meta []byte `json:"meta"` }
LightBlock is a light consensus block suitable for syncing light clients.
type LightClient ¶ added in v0.2300.0
type LightClient interface { // TrustedLightBlock returns trusted light block at the specified height. TrustedLightBlock(height int64) (*LightBlock, error) }
LightClient is a consensus light client interface.
Light blocks returned by this client are trusted and don't need to be verified before use.
type LightClientStatus ¶ added in v0.2300.0
type LightClientStatus struct { // LatestHeight is the height of the latest block. LatestHeight int64 `json:"latest_height"` // LatestHash is the hash of the latest block. LatestHash hash.Hash `json:"latest_hash"` // LatestTime is the timestamp of the latest block. LatestTime time.Time `json:"latest_time"` // OldestHeight is the height of the oldest block. OldestHeight int64 `json:"oldest_height"` // LatestHash is the hash of the oldest block. OldestHash hash.Hash `json:"oldest_hash"` // OldestTime is the timestamp of the oldest block. OldestTime time.Time `json:"oldest_time"` // PeerIDs are the light client provider peer identifiers. PeerIDs []string `json:"peer_ids"` }
LightClientStatus is the current light client status overview.
type LightProvider ¶ added in v0.2501.0
type LightProvider interface { // LightBlock retrieves an untrusted light block at the specified height. LightBlock(ctx context.Context, height int64) (*LightBlock, error) }
LightProvider is a consensus light provider interface.
Warning: Light blocks returned by this provider are untrusted and should be verified before use.
type LightService ¶ added in v0.2300.0
type LightService interface { LightProvider // GetStatus returns the current status overview. GetStatus() (*LightClientStatus, error) }
LightService is a consensus light client service.
type NextBlockState ¶ added in v0.2200.0
type NextBlockState struct { Height int64 `json:"height"` NumValidators uint64 `json:"num_validators"` VotingPower uint64 `json:"voting_power"` Prevotes Votes `json:"prevotes"` Precommits Votes `json:"precommits"` }
NextBlockState has the state of the next block being voted on by validators.
type NoOpSubmissionManager ¶ added in v0.2010.2
type NoOpSubmissionManager struct{}
NoOpSubmissionManager implements a submission manager that doesn't support submitting transactions.
func (*NoOpSubmissionManager) EstimateGasAndSetFee ¶ added in v0.2103.13
func (m *NoOpSubmissionManager) EstimateGasAndSetFee(context.Context, signature.Signer, *transaction.Transaction) error
EstimateGasAndSetFee implements SubmissionManager.
func (*NoOpSubmissionManager) PriceDiscovery ¶ added in v0.2103.13
func (m *NoOpSubmissionManager) PriceDiscovery() PriceDiscovery
PriceDiscovery implements SubmissionManager.
func (*NoOpSubmissionManager) SignAndSubmitTx ¶ added in v0.2010.2
func (m *NoOpSubmissionManager) SignAndSubmitTx(context.Context, signature.Signer, *transaction.Transaction) error
SignAndSubmitTx implements SubmissionManager.
func (*NoOpSubmissionManager) SignAndSubmitTxWithProof ¶ added in v0.2202.0
func (m *NoOpSubmissionManager) SignAndSubmitTxWithProof(context.Context, signature.Signer, *transaction.Transaction) (*transaction.SignedTransaction, *transaction.Proof, error)
SignAndSubmitTxWithProof implements SubmissionManager.
type P2PStatus ¶ added in v0.2300.0
type P2PStatus struct { // PubKey is the public key used for consensus P2P communication. PubKey signature.PublicKey `json:"pub_key"` // PeerID is the peer ID derived by hashing peer's public key. PeerID string `json:"peer_id"` // Addresses is a list of configured P2P addresses used when registering the node. Addresses []node.ConsensusAddress `json:"addresses"` // Peers is a list of node's peers. Peers []string `json:"peers"` }
P2PStatus is the P2P status of a node.
type Parameters ¶
type Parameters struct { // Height contains the block height these consensus parameters are for. Height int64 `json:"height"` // Parameters are the backend agnostic consensus parameters. Parameters genesis.Parameters `json:"parameters"` // Meta contains the consensus backend specific consensus parameters. Meta []byte `json:"meta"` }
Parameters are the consensus backend parameters.
type PriceDiscovery ¶
type PriceDiscovery interface { // GasPrice returns the current consensus gas price. GasPrice() (*quantity.Quantity, error) }
PriceDiscovery is the consensus fee price discovery interface.
type Service ¶ added in v0.2503.0
type Service interface { service.BackgroundService Services // SupportedFeatures returns the features supported by this consensus backend. SupportedFeatures() FeatureMask // Synced returns a channel that is closed once synchronization is // complete. Synced() <-chan struct{} // GetAddresses returns the consensus backend addresses. GetAddresses() ([]node.ConsensusAddress, error) // Checkpointer returns the checkpointer associated with consensus state. // // This may be nil in case checkpoints are disabled. Checkpointer() checkpoint.Checkpointer // Pruner returns the state pruner. Pruner() StatePruner // SubmissionManager returns the transaction submission manager. SubmissionManager() SubmissionManager }
Service is an interface that a consensus backend service must provide.
type Services ¶ added in v0.2503.0
type Services interface { // Beacon returns the beacon backend. Beacon() beacon.Backend // Core returns the consensus core backend. Core() Backend // Governance returns the governance backend. Governance() governance.Backend // KeyManager returns the keymanager backend. KeyManager() keymanager.Backend // Registry returns the registry backend. Registry() registry.Backend // RootHash returns the roothash backend. RootHash() roothash.Backend // Scheduler returns the scheduler backend. Scheduler() scheduler.Backend // Staking returns the staking backend. Staking() staking.Backend // Vault returns the vault backend. Vault() vault.Backend }
Services are consensus services.
type ServicesClient ¶ added in v0.2503.0
type ServicesClient struct {
// contains filtered or unexported fields
}
ServicesClient is a gRPC consensus services client.
func NewServicesClient ¶ added in v0.2503.0
func NewServicesClient(c *grpc.ClientConn) *ServicesClient
NewServicesClient creates a new gRPC consensus services client.
func (*ServicesClient) Beacon ¶ added in v0.2503.0
func (c *ServicesClient) Beacon() beacon.Backend
func (*ServicesClient) Core ¶ added in v0.2503.0
func (c *ServicesClient) Core() Backend
func (*ServicesClient) Governance ¶ added in v0.2503.0
func (c *ServicesClient) Governance() governance.Backend
func (*ServicesClient) KeyManager ¶ added in v0.2503.0
func (c *ServicesClient) KeyManager() keymanager.Backend
func (*ServicesClient) Registry ¶ added in v0.2503.0
func (c *ServicesClient) Registry() registry.Backend
func (*ServicesClient) RootHash ¶ added in v0.2503.0
func (c *ServicesClient) RootHash() roothash.Backend
func (*ServicesClient) Scheduler ¶ added in v0.2503.0
func (c *ServicesClient) Scheduler() scheduler.Backend
func (*ServicesClient) Staking ¶ added in v0.2503.0
func (c *ServicesClient) Staking() staking.Backend
func (*ServicesClient) Vault ¶ added in v0.2503.0
func (c *ServicesClient) Vault() vault.Backend
type StatePruneHandler ¶ added in v0.2501.0
type StatePruneHandler interface { // Prune is called before the specified height is pruned. // // If an error is returned, pruning is aborted and the height is // not pruned from history. // // Note that this can be called for the same height multiple // times (e.g., if one of the handlers fails but others succeed // and pruning is later retried). Prune(height int64) error }
StatePruneHandler is a handler that is called when heights are pruned from history.
type StatePruner ¶ added in v0.2501.0
type StatePruner interface { // RegisterHandler registers a prune handler. RegisterHandler(handler StatePruneHandler) }
StatePruner is a state pruner implementation.
type Status ¶
type Status struct { // Status is an concise status of the consensus backend. Status StatusState `json:"status"` // Version is the version of the consensus protocol that the node is using. Version version.Version `json:"version"` // Backend is the consensus backend identifier. Backend string `json:"backend"` // Features are the indicated consensus backend features. Features FeatureMask `json:"features"` // LatestHeight is the height of the latest block. LatestHeight int64 `json:"latest_height"` // LatestHash is the hash of the latest block. LatestHash hash.Hash `json:"latest_hash"` // LatestTime is the timestamp of the latest block. LatestTime time.Time `json:"latest_time"` // LatestEpoch is the epoch of the latest block. LatestEpoch beacon.EpochTime `json:"latest_epoch"` // LatestStateRoot is the Merkle root of the consensus state tree. LatestStateRoot mkvsNode.Root `json:"latest_state_root"` // LatestBlockSize is the size (in bytes) of the latest block. LatestBlockSize uint64 `json:"latest_block_size,omitempty"` // GenesisHeight is the height of the genesis block. GenesisHeight int64 `json:"genesis_height"` // GenesisHash is the hash of the genesis block. GenesisHash hash.Hash `json:"genesis_hash"` // LastRetainedHeight is the height of the oldest retained block. LastRetainedHeight int64 `json:"last_retained_height"` // LastRetainedHash is the hash of the oldest retained block. LastRetainedHash hash.Hash `json:"last_retained_hash"` // ChainContext is the chain domain separation context. ChainContext string `json:"chain_context"` // IsValidator returns whether the current node is part of the validator set. IsValidator bool `json:"is_validator"` // P2P is the P2P status of the node. P2P *P2PStatus `json:"p2p,omitempty"` }
Status is the current status overview.
type StatusState ¶ added in v0.2202.0
type StatusState uint8
StatusState is the concise status state of the consensus backend.
var ( // StatusStateReady is the ready status state. StatusStateReady StatusState // StatusStateSyncing is the syncing status state. StatusStateSyncing StatusState = 1 )
func (StatusState) MarshalText ¶ added in v0.2202.0
func (s StatusState) MarshalText() ([]byte, error)
MarshalText encodes a StatusState into text form.
func (StatusState) String ¶ added in v0.2202.0
func (s StatusState) String() string
String returns a string representation of a status state.
func (*StatusState) UnmarshalText ¶ added in v0.2202.0
func (s *StatusState) UnmarshalText(text []byte) error
UnmarshalText decodes a text slice into a StatusState.
type SubmissionManager ¶
type SubmissionManager interface { // PriceDiscovery returns the configured price discovery mechanism instance. PriceDiscovery() PriceDiscovery // EstimateGasAndSetFee populates the fee field in the transaction if not already set. EstimateGasAndSetFee(ctx context.Context, signer signature.Signer, tx *transaction.Transaction) error // SignAndSubmitTx populates the nonce and fee fields in the transaction, signs the transaction // with the passed signer and submits it to consensus backend. // // It also automatically handles retries in case the nonce was incorrectly estimated. SignAndSubmitTx(ctx context.Context, signer signature.Signer, tx *transaction.Transaction) error // SignAndSubmitTxWithProof populates the nonce and fee fields in the transaction, signs // the transaction with the passed signer, submits it to consensus backend and creates // a proof of inclusion. // // It also automatically handles retries in case the nonce was incorrectly estimated. SignAndSubmitTxWithProof(ctx context.Context, signer signature.Signer, tx *transaction.Transaction) (*transaction.SignedTransaction, *transaction.Proof, error) }
SubmissionManager is a transaction submission manager interface.
func NewSubmissionManager ¶
func NewSubmissionManager(consensus Services, priceDiscovery PriceDiscovery, maxFee uint64) SubmissionManager
NewSubmissionManager creates a new transaction submission manager.
type TransactionsWithProofs ¶ added in v0.2300.0
type TransactionsWithProofs struct { Transactions [][]byte `json:"transactions"` Proofs [][]byte `json:"proofs"` }
TransactionsWithProofs is GetTransactionsWithProofs response.
Proofs[i] is a proof of block inclusion for Transactions[i].
type TransactionsWithResults ¶
type TransactionsWithResults struct { Transactions [][]byte `json:"transactions"` Results []*results.Result `json:"results"` }
TransactionsWithResults is GetTransactionsWithResults response.
Results[i] are the results of executing Transactions[i].