Documentation
¶
Index ¶
- Constants
- Variables
- func ReadUnitProofIndex(db keyvaluedb.KeyValueDB, unitID []byte, txOrderHash []byte) (*types.UnitStateWithProof, error)
- type BlockAndState
- type BlockProposalValidator
- type DefaultBlockProposalValidator
- type DefaultTxValidator
- type DefaultUnicityCertificateValidator
- type IndexReader
- type IndexWriter
- type Key
- type KeyConf
- type Leader
- type Node
- func (n *Node) CurrentRoundInfo(ctx context.Context) (*RoundInfo, error)
- func (n *Node) FilterValidatorNodes(exclude peer.ID) []peer.ID
- func (n *Node) GetBlock(_ context.Context, blockNr uint64) (*types.Block, error)
- func (n *Node) GetTransactionRecordProof(ctx context.Context, txoHash []byte) (*types.TxRecordProof, error)
- func (n *Node) GetTrustBase(epochNumber uint64) (types.RootTrustBase, error)
- func (n *Node) IsFeelessMode() bool
- func (n *Node) IsPermissionedMode() bool
- func (n *Node) IsValidator() bool
- func (n *Node) LatestBlockNumber() (uint64, error)
- func (n *Node) NetworkID() types.NetworkID
- func (n *Node) PartitionID() types.PartitionID
- func (n *Node) PartitionTypeID() types.PartitionTypeID
- func (n *Node) Peer() *network.Peer
- func (n *Node) RegisterShardConf(shardConf *types.PartitionDescriptionRecord) error
- func (n *Node) Run(ctx context.Context) error
- func (n *Node) SerializeState(w io.Writer) error
- func (n *Node) ShardID() types.ShardID
- func (n *Node) SubmitTx(ctx context.Context, tx *types.TransactionOrder) (txOrderHash []byte, err error)
- func (n *Node) TransactionSystemState() txsystem.StateReader
- func (n *Node) Validators() peer.IDSlice
- type NodeConf
- func (c *NodeConf) BlockStore() keyvaluedb.KeyValueDB
- func (c *NodeConf) GetT2Timeout() time.Duration
- func (c *NodeConf) HashAlgorithm() crypto.Hash
- func (c *NodeConf) NetworkID() types.NetworkID
- func (c *NodeConf) Observability() Observability
- func (c *NodeConf) Orchestration() Orchestration
- func (c *NodeConf) OwnerIndexer() *OwnerIndexer
- func (c *NodeConf) PartitionID() types.PartitionID
- func (c *NodeConf) PeerConf() (*network.PeerConfiguration, error)
- func (c *NodeConf) ProofStore() keyvaluedb.KeyValueDB
- func (c *NodeConf) ShardConf() *types.PartitionDescriptionRecord
- func (c *NodeConf) ShardID() types.ShardID
- func (c *NodeConf) TrustBase() types.RootTrustBasedeprecated
- type NodeOption
- func WithAddress(address string) NodeOption
- func WithAnnounceAddresses(announceAddresses []string) NodeOption
- func WithBlockProposalValidator(blockProposalValidator BlockProposalValidator) NodeOption
- func WithBlockStore(blockStore keyvaluedb.KeyValueDB) NodeOption
- func WithBlockSubscriptionTimeout(t time.Duration) NodeOption
- func WithBootstrapAddresses(bootstrapAddresses []string) NodeOption
- func WithBootstrapConnectRetry(bootstrapConnectRetry *network.BootstrapConnectRetry) NodeOption
- func WithEventHandler(eh event.Handler, eventChCapacity int) NodeOption
- func WithOwnerIndex(ownerIndexer *OwnerIndexer) NodeOption
- func WithProofIndex(db keyvaluedb.KeyValueDB, history uint64) NodeOption
- func WithReplicationParams(maxFetchBlocks, maxReturnBlocks uint64, maxTx uint32, timeout time.Duration) NodeOption
- func WithShardStore(shardStore keyvaluedb.KeyValueDB) NodeOption
- func WithT1Timeout(t1Timeout time.Duration) NodeOption
- func WithTxValidator(txValidator TxValidator) NodeOption
- func WithUnicityCertificateValidator(unicityCertificateValidator UnicityCertificateValidator) NodeOption
- func WithValidatorNetwork(validatorNetwork ValidatorNetwork) NodeOption
- type Observability
- type Orchestration
- type OwnerIndexer
- type ProofIndexer
- type RoundInfo
- type StateProvider
- type TxIndex
- type TxValidator
- type UnicityCertificateValidator
- type UnitAndProof
- type ValidatorNetwork
Constants ¶
const ( KeyAlgorithmSecp256k1 = "secp256k1" DefaultT1Timeout = 750 DefaultReplicationMaxBlocks uint64 = 1000 DefaultReplicationMaxTx uint32 = 10000 DefaultBlockSubscriptionTimeout = 3000 * time.Millisecond DefaultLedgerReplicationTimeout = 1500 * time.Millisecond )
const UnknownLeader = ""
Variables ¶
var ( ErrShardConfIsNil = errors.New("shard configuration is nil") ErrKeyConfIsNil = errors.New("key configuration is nil") ErrTrustBaseIsNil = errors.New("trust base is nil") )
var (
ErrIndexNotFound = errors.New("index not found")
)
var ErrNodeDoesNotHaveLatestBlock = errors.New("recovery needed, node does not have the latest block")
var ErrTxTimeout = errors.New("transaction has timed out")
Functions ¶
func ReadUnitProofIndex ¶
func ReadUnitProofIndex(db keyvaluedb.KeyValueDB, unitID []byte, txOrderHash []byte) (*types.UnitStateWithProof, error)
Types ¶
type BlockAndState ¶
type BlockAndState struct {
Block *types.Block
State UnitAndProof
}
type BlockProposalValidator ¶
type BlockProposalValidator interface {
// Validate validates the given blockproposal.BlockProposal. Returns an error if given block proposal
// is not valid.
Validate(bp *blockproposal.BlockProposal, sigVerifier crypto.Verifier, shardConfHash []byte) error
}
BlockProposalValidator is used to validate block proposals.
func NewDefaultBlockProposalValidator ¶
func NewDefaultBlockProposalValidator( partitionID types.PartitionID, shardID types.ShardID, trustBase types.RootTrustBase, hashAlg gocrypto.Hash, ) (BlockProposalValidator, error)
NewDefaultBlockProposalValidator creates a new instance of default BlockProposalValidator.
type DefaultBlockProposalValidator ¶
type DefaultBlockProposalValidator struct {
// contains filtered or unexported fields
}
DefaultBlockProposalValidator is a default implementation of UnicityCertificateValidator.
func (*DefaultBlockProposalValidator) Validate ¶
func (bpv *DefaultBlockProposalValidator) Validate(bp *blockproposal.BlockProposal, nodeSignatureVerifier crypto.Verifier, shardConfHash []byte) error
type DefaultTxValidator ¶
type DefaultTxValidator struct {
// contains filtered or unexported fields
}
func (*DefaultTxValidator) Validate ¶
func (dtv *DefaultTxValidator) Validate(tx *types.TransactionOrder, currentRoundNumber uint64) error
type DefaultUnicityCertificateValidator ¶
type DefaultUnicityCertificateValidator struct {
// contains filtered or unexported fields
}
DefaultUnicityCertificateValidator is a default implementation of UnicityCertificateValidator.
func (*DefaultUnicityCertificateValidator) Validate ¶
func (ucv *DefaultUnicityCertificateValidator) Validate(uc *types.UnicityCertificate, shardConfHash []byte) error
type IndexReader ¶
type IndexWriter ¶
type IndexWriter interface {
LoadState(s txsystem.StateReader) error
IndexBlock(b *types.Block, s StateProvider) error
}
type KeyConf ¶
func (*KeyConf) AuthKeyPair ¶
func (c *KeyConf) AuthKeyPair() (*network.PeerKeyPair, error)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a member in the partition and implements an instance of a specific TransactionSystem. Partition is a distributed system, it consists of either a set of shards, or one or more partition nodes.
func NewNode ¶
func NewNode(ctx context.Context, txSystem txsystem.TransactionSystem, conf *NodeConf) (*Node, error)
NewNode creates a new instance of the partition node. All parameters expect the nodeOptions are required. Functions implementing the NodeOption interface can be used to override default configuration values.
The following restrictions apply to the inputs:
- the network peer and signer must use the same keys that were used to generate node genesis file;
func (*Node) CurrentRoundInfo ¶
func (*Node) GetTransactionRecordProof ¶
func (*Node) GetTrustBase ¶
func (n *Node) GetTrustBase(epochNumber uint64) (types.RootTrustBase, error)
func (*Node) IsFeelessMode ¶
func (*Node) IsPermissionedMode ¶
func (*Node) IsValidator ¶
func (*Node) LatestBlockNumber ¶
LatestBlockNumber returns the latest committed round number. It's part of the public API exposed by node.
func (*Node) PartitionID ¶
func (n *Node) PartitionID() types.PartitionID
func (*Node) PartitionTypeID ¶
func (n *Node) PartitionTypeID() types.PartitionTypeID
func (*Node) RegisterShardConf ¶
func (n *Node) RegisterShardConf(shardConf *types.PartitionDescriptionRecord) error
func (*Node) TransactionSystemState ¶
func (n *Node) TransactionSystemState() txsystem.StateReader
func (*Node) Validators ¶
type NodeConf ¶
type NodeConf struct {
// contains filtered or unexported fields
}
func NewNodeConf ¶
func NewNodeConf( keyConf *KeyConf, shardConf *types.PartitionDescriptionRecord, trustBase types.RootTrustBase, observability Observability, nodeOptions ...NodeOption, ) (*NodeConf, error)
func (*NodeConf) BlockStore ¶
func (c *NodeConf) BlockStore() keyvaluedb.KeyValueDB
func (*NodeConf) GetT2Timeout ¶
func (*NodeConf) HashAlgorithm ¶
func (*NodeConf) Observability ¶
func (c *NodeConf) Observability() Observability
func (*NodeConf) Orchestration ¶
func (c *NodeConf) Orchestration() Orchestration
func (*NodeConf) OwnerIndexer ¶
func (c *NodeConf) OwnerIndexer() *OwnerIndexer
func (*NodeConf) PartitionID ¶
func (c *NodeConf) PartitionID() types.PartitionID
func (*NodeConf) ProofStore ¶
func (c *NodeConf) ProofStore() keyvaluedb.KeyValueDB
func (*NodeConf) ShardConf ¶
func (c *NodeConf) ShardConf() *types.PartitionDescriptionRecord
func (*NodeConf) TrustBase
deprecated
func (c *NodeConf) TrustBase() types.RootTrustBase
Deprecated: use orchestration instead to prepare for dynamic RootChain
type NodeOption ¶
type NodeOption func(c *NodeConf)
func WithAddress ¶
func WithAddress(address string) NodeOption
func WithAnnounceAddresses ¶
func WithAnnounceAddresses(announceAddresses []string) NodeOption
func WithBlockProposalValidator ¶
func WithBlockProposalValidator(blockProposalValidator BlockProposalValidator) NodeOption
func WithBlockStore ¶
func WithBlockStore(blockStore keyvaluedb.KeyValueDB) NodeOption
func WithBlockSubscriptionTimeout ¶
func WithBlockSubscriptionTimeout(t time.Duration) NodeOption
func WithBootstrapAddresses ¶
func WithBootstrapAddresses(bootstrapAddresses []string) NodeOption
func WithBootstrapConnectRetry ¶
func WithBootstrapConnectRetry(bootstrapConnectRetry *network.BootstrapConnectRetry) NodeOption
func WithEventHandler ¶
func WithEventHandler(eh event.Handler, eventChCapacity int) NodeOption
func WithOwnerIndex ¶
func WithOwnerIndex(ownerIndexer *OwnerIndexer) NodeOption
func WithProofIndex ¶
func WithProofIndex(db keyvaluedb.KeyValueDB, history uint64) NodeOption
func WithReplicationParams ¶
func WithReplicationParams(maxFetchBlocks, maxReturnBlocks uint64, maxTx uint32, timeout time.Duration) NodeOption
func WithShardStore ¶
func WithShardStore(shardStore keyvaluedb.KeyValueDB) NodeOption
func WithT1Timeout ¶
func WithT1Timeout(t1Timeout time.Duration) NodeOption
func WithTxValidator ¶
func WithTxValidator(txValidator TxValidator) NodeOption
func WithUnicityCertificateValidator ¶
func WithUnicityCertificateValidator(unicityCertificateValidator UnicityCertificateValidator) NodeOption
func WithValidatorNetwork ¶
func WithValidatorNetwork(validatorNetwork ValidatorNetwork) NodeOption
type Observability ¶
type Observability interface {
TracerProvider() trace.TracerProvider
Tracer(name string, options ...trace.TracerOption) trace.Tracer
Meter(name string, opts ...metric.MeterOption) metric.Meter
PrometheusRegisterer() prometheus.Registerer
Logger() *slog.Logger
RoundLogger(curRound func() uint64) *slog.Logger
Shutdown() error
}
type Orchestration ¶
type Orchestration struct {
// contains filtered or unexported fields
}
static orchestration until real thing is implemented.
func (Orchestration) TrustBase ¶
func (orc Orchestration) TrustBase(epoch uint64) (types.RootTrustBase, error)
type OwnerIndexer ¶
type OwnerIndexer struct {
// contains filtered or unexported fields
}
OwnerIndexer manages index of unit owners based on txsystem state.
func NewOwnerIndexer ¶
func NewOwnerIndexer(l *slog.Logger) *OwnerIndexer
func (*OwnerIndexer) GetOwnerUnits ¶
func (o *OwnerIndexer) GetOwnerUnits(ownerID []byte, sinceUnitID *types.UnitID, limit int) ([]types.UnitID, error)
GetOwnerUnits returns all unit ids for given owner. If sinceUnitID is set, only units after sinceUnitID are returned
func (*OwnerIndexer) IndexBlock ¶
func (o *OwnerIndexer) IndexBlock(b *types.Block, s StateProvider) error
IndexBlock updates the index based on current committed state and transactions in a block (changed units).
func (*OwnerIndexer) LoadState ¶
func (o *OwnerIndexer) LoadState(s txsystem.StateReader) error
LoadState fills the index from state.
type ProofIndexer ¶
type ProofIndexer struct {
// contains filtered or unexported fields
}
func NewProofIndexer ¶
func NewProofIndexer(algo crypto.Hash, db keyvaluedb.KeyValueDB, historySize uint64, obs Observability) *ProofIndexer
func (*ProofIndexer) GetDB ¶
func (p *ProofIndexer) GetDB() keyvaluedb.KeyValueDB
func (*ProofIndexer) Handle ¶
func (p *ProofIndexer) Handle(ctx context.Context, block *types.Block, state UnitAndProof)
func (*ProofIndexer) IndexBlock ¶
func (p *ProofIndexer) IndexBlock(ctx context.Context, block *types.Block, roundNumber uint64, state UnitAndProof) error
type StateProvider ¶
type TxIndex ¶
func ReadTransactionIndex ¶
func ReadTransactionIndex(db keyvaluedb.KeyValueDB, txOrderHash []byte) (*TxIndex, error)
type TxValidator ¶
type TxValidator interface {
Validate(tx *types.TransactionOrder, currentRoundNumber uint64) error
}
TxValidator is used to validate generic transactions (e.g. timeouts, partition identifiers, etc.). This validator should not contain transaction system specific validation logic.
func NewDefaultTxValidator ¶
func NewDefaultTxValidator(partitionID types.PartitionID) (TxValidator, error)
NewDefaultTxValidator creates a new instance of default TxValidator.
type UnicityCertificateValidator ¶
type UnicityCertificateValidator interface {
// Validate validates the given UC. Returns an error if UC is not valid.
Validate(uc *types.UnicityCertificate, shardConfHash []byte) error
}
UnicityCertificateValidator is used to validate certificates.UnicityCertificate.
func NewDefaultUnicityCertificateValidator ¶
func NewDefaultUnicityCertificateValidator( partitionID types.PartitionID, shardID types.ShardID, trustBase types.RootTrustBase, hashAlg gocrypto.Hash, ) (UnicityCertificateValidator, error)
NewDefaultUnicityCertificateValidator creates a new instance of default UnicityCertificateValidator.
type UnitAndProof ¶
type UnitAndProof interface {
// GetUnit - access tx system unit state
GetUnit(id types.UnitID, committed bool) (state.Unit, error)
// CreateUnitStateProof - create unit proofs
CreateUnitStateProof(id types.UnitID, logIndex int) (*types.UnitStateProof, error)
}
UnitAndProof read access to state to access unit and unit proofs
type ValidatorNetwork ¶
type ValidatorNetwork interface {
Send(ctx context.Context, msg any, receivers ...peer.ID) error
ReceivedChannel() <-chan any
PublishBlock(ctx context.Context, block *types.Block) error
SubscribeToBlocks(ctx context.Context) error
UnsubscribeFromBlocks()
RegisterValidatorProtocols() error
UnregisterValidatorProtocols()
AddTransaction(ctx context.Context, tx *types.TransactionOrder) ([]byte, error)
ForwardTransactions(ctx context.Context, receiverFunc network.TxReceiver)
ProcessTransactions(ctx context.Context, txProcessor network.TxProcessor)
}
ValidatorNetwork provides an interface for sending and receiving validator network messages.