simplex

package
v1.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const CodecVersion = warp.CodecVersion + 1

Variables

Functions

func NewBLSAuth

func NewBLSAuth(config *Config) (BLSSigner, BLSVerifier, error)

Types

type BLSSigner

type BLSSigner struct {
	// contains filtered or unexported fields
}

BLSSigner signs messages encoded with the provided ChainID and NetworkID. using the SignBLS function.

func (*BLSSigner) Sign

func (s *BLSSigner) Sign(message []byte) ([]byte, error)

Sign returns a signature on the given message using BLS signature scheme. It encodes the message to sign with the chain ID, and network ID,

type BLSVerifier

type BLSVerifier struct {
	// contains filtered or unexported fields
}

func (BLSVerifier) Verify

func (v BLSVerifier) Verify(message []byte, signature []byte, signer simplex.NodeID) error

type Block added in v1.13.3

type Block struct {
	// contains filtered or unexported fields
}

func (*Block) BlockHeader added in v1.13.3

func (b *Block) BlockHeader() simplex.BlockHeader

BlockHeader returns the block header for the block.

func (*Block) Bytes added in v1.13.3

func (b *Block) Bytes() ([]byte, error)

Bytes returns the serialized bytes of the block.

func (*Block) Verify added in v1.13.3

func (b *Block) Verify(ctx context.Context) (simplex.VerifiedBlock, error)

Verify verifies the block.

type BlockBuilder added in v1.14.0

type BlockBuilder struct {
	// contains filtered or unexported fields
}

func (*BlockBuilder) BuildBlock added in v1.14.0

BuildBlock continuously tries to build a block until the context is cancelled. If there are no blocks to be built, it will wait for an event from the VM. It returns false if the context was cancelled, otherwise it returns the built block and true.

func (*BlockBuilder) WaitForPendingBlock added in v1.14.0

func (b *BlockBuilder) WaitForPendingBlock(ctx context.Context)

WaitForPendingBlock blocks until a new block is ready to be built from the VM, or until the context is cancelled.

type Comm added in v1.13.3

type Comm struct {
	// contains filtered or unexported fields
}

func NewComm added in v1.13.3

func NewComm(config *Config) (*Comm, error)

func (*Comm) Broadcast added in v1.13.3

func (c *Comm) Broadcast(msg *simplex.Message)

func (*Comm) Nodes added in v1.13.3

func (c *Comm) Nodes() []simplex.NodeID

func (*Comm) Send added in v1.13.3

func (c *Comm) Send(msg *simplex.Message, destination simplex.NodeID)

type Config

type Config struct {
	Ctx SimplexChainContext
	Log logging.Logger

	Sender             sender.ExternalSender
	OutboundMsgBuilder message.OutboundMsgBuilder

	VM block.ChainVM

	DB database.KeyValueReaderWriter

	// In the case of a crash, Simplex uses the WAL to recover its state and resume consensus.
	WAL simplex.WriteAheadLog

	// SignBLS is the signing function used for this node to sign messages.
	SignBLS SignFunc

	// Parameters passed in by the subnet configuration
	Params *simplexparams.Parameters
}

Config wraps all the parameters needed for a simplex engine

type Engine added in v1.14.2

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine added in v1.14.2

func NewEngine(ctx context.Context, config *Config) (*Engine, error)

The VM must be initialized before creating the engine

func (*Engine) Shutdown added in v1.14.2

func (e *Engine) Shutdown(_ context.Context) error

func (*Engine) Simplex added in v1.14.2

func (e *Engine) Simplex(ctx context.Context, nodeID ids.NodeID, msg *p2p.Simplex) error

func (*Engine) Start added in v1.14.2

func (e *Engine) Start(_ context.Context, _ uint32) error

type QC added in v1.13.4

type QC struct {
	// contains filtered or unexported fields
}

QC represents a quorum certificate in the Simplex consensus protocol.

func (*QC) Bytes added in v1.13.4

func (qc *QC) Bytes() []byte

Bytes serializes the quorum certificate into bytes.

func (*QC) Signers added in v1.13.4

func (qc *QC) Signers() []simplex.NodeID

Signers returns the list of signers for the quorum certificate.

func (*QC) Verify added in v1.13.4

func (qc *QC) Verify(msg []byte) error

Verify checks if the quorum certificate is valid by verifying the aggregated signature against the signers' public keys.

type QCDeserializer added in v1.13.4

type QCDeserializer struct {
	// contains filtered or unexported fields
}

func (*QCDeserializer) DeserializeQuorumCertificate added in v1.13.4

func (d *QCDeserializer) DeserializeQuorumCertificate(bytes []byte) (simplex.QuorumCertificate, error)

DeserializeQuorumCertificate deserializes a quorum certificate from bytes.

type SignFunc

type SignFunc func(msg []byte) (*bls.Signature, error)

type SignatureAggregator added in v1.13.4

type SignatureAggregator struct {
	// contains filtered or unexported fields
}

SignatureAggregator aggregates signatures into a quorum certificate.

func (*SignatureAggregator) Aggregate added in v1.13.4

func (a *SignatureAggregator) Aggregate(signatures []simplex.Signature) (simplex.QuorumCertificate, error)

Aggregate aggregates the provided signatures into a quorum certificate. It requires at least a quorum of signatures to succeed. If any signature is from a signer not in the membership set, it returns an error.

type SimplexChainContext

type SimplexChainContext struct {
	// NodeID is the ID of this node
	NodeID ids.NodeID

	// ChainID is the ID of the chain this context exists within.
	ChainID ids.ID

	// SubnetID is the ID of the subnet this context exists within.
	SubnetID ids.ID

	// Network is the ID of the network this context exists within.
	NetworkID uint32
}

Context is information about the current execution.

type Storage added in v1.13.5

type Storage struct {
	// contains filtered or unexported fields
}

func (*Storage) Index added in v1.13.5

func (s *Storage) Index(ctx context.Context, block simplex.VerifiedBlock, finalization simplex.Finalization) error

Index indexes the finalization in the storage. It stores the finalization bytes and increments numBlocks.

func (*Storage) NumBlocks added in v1.13.5

func (s *Storage) NumBlocks() uint64

func (*Storage) Retrieve added in v1.13.5

Retrieve returns the block and finalization at [seq]. If [seq] is not found, returns simplex.ErrBlockNotFound.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL