adapter

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this package.
	MetricsSubsystem = "adapter"
)

Variables

This section is empty.

Functions

func AggregatorNodeSignatureBytesProvider

func AggregatorNodeSignatureBytesProvider(adapter *Adapter) evtypes.AggregatorNodeSignatureBytesProvider

func LoadGenesisDoc

func LoadGenesisDoc(cfg *cmtcfg.Config) (*cmttypes.GenesisDoc, error)

LoadGenesisDoc returns the genesis document from the provided config file.

func MakeABCIBlock

func MakeABCIBlock(
	blockHeight uint64,
	cmtTxs cmttypes.Txs,
	currentState *cmtstate.State,
	abciHeader cmttypes.Header,
	lastCommit *cmttypes.Commit,
) (*cmttypes.Block, *cmttypes.BlockID, error)

MakeABCIBlock makes an ABCI block and its block ID.

func SyncNodeSignatureBytesProvider

func SyncNodeSignatureBytesProvider(adapter *Adapter) evtypes.SyncNodeSignatureBytesProvider

func ToABCIBlock

func ToABCIBlock(header cmttypes.Header, lastCommit *cmttypes.Commit, data *rlktypes.Data) (*cmttypes.Block, error)

ToABCIBlock converts rollit block into block format defined by ABCI.

func ToABCIBlockMeta

func ToABCIBlockMeta(abciBlock *cmttypes.Block) (*cmttypes.BlockMeta, error)

ToABCIBlockMeta converts an ABCI block into a BlockMeta format.

func ToABCIHeader

func ToABCIHeader(header rlktypes.Header, lastCommit *cmttypes.Commit) (cmttypes.Header, error)

ToABCIHeader converts rollkit header format defined by ABCI.

func ValidatorHasherProvider

func ValidatorHasherProvider() func(proposerAddress []byte, pubKey crypto.PubKey) (evtypes.Hash, error)

ValidatorHasher returns a function that calculates the ValidatorHash compatible with CometBFT. This function is intended to be injected into ev-node's Manager.

Types

type Adapter

type Adapter struct {
	App          servertypes.ABCI
	Store        *execstore.Store
	RollkitStore rstore.Store
	Mempool      mempool.Mempool
	MempoolIDs   *mempoolIDs

	P2PClient  P2PClientInfo
	TxGossiper *p2p.Gossiper

	EventBus   *cmttypes.EventBus
	AppGenesis *genutiltypes.AppGenesis

	Logger log.Logger
	// contains filtered or unexported fields
}

Adapter is a struct that will contain an ABCI Application, and will implement the go-execution interface

func NewABCIExecutor

func NewABCIExecutor(
	app servertypes.ABCI,
	store ds.Batching,
	p2pClient *rollkitp2p.Client,
	p2pMetrics *rollkitp2p.Metrics,
	logger log.Logger,
	cfg *cmtcfg.Config,
	appGenesis *genutiltypes.AppGenesis,
	opts ...Option,
) *Adapter

NewABCIExecutor creates a new Adapter instance that implements the go-execution.Executor interface. The Adapter wraps the provided ABCI application and delegates execution-related operations to it.

func (*Adapter) ExecuteTxs

func (a *Adapter) ExecuteTxs(
	ctx context.Context,
	txs [][]byte,
	blockHeight uint64,
	timestamp time.Time,
	prevStateRoot []byte,
) ([]byte, uint64, error)

ExecuteTxs implements execution.Executor.

func (*Adapter) GetLastCommit

func (a *Adapter) GetLastCommit(ctx context.Context, blockHeight uint64) (*cmttypes.Commit, error)

GetLastCommit retrieves the last commit for the given block height.

func (*Adapter) GetTxs

func (a *Adapter) GetTxs(ctx context.Context) ([][]byte, error)

GetTxs calls PrepareProposal with the next height from the store and returns the transactions from the ABCI app

func (*Adapter) InitChain

func (a *Adapter) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, chainID string) ([]byte, uint64, error)

InitChain implements execution.Executor.

func (*Adapter) SetFinal

func (a *Adapter) SetFinal(ctx context.Context, blockHeight uint64) error

SetFinal handles extra logic once the block has been finalized (posted to DA). It publishes all queued events up to this height in the correct sequence, ensuring that events are only emitted after consensus is achieved.

func (*Adapter) SetMempool

func (a *Adapter) SetMempool(mempool mempool.Mempool)

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context) error

type BlockFilter

type BlockFilter interface {
	IsPublishable(ctx context.Context, height int64) bool
}

BlockFilter decides if a block commit is build and published

type BlockFilterFn

type BlockFilterFn func(ctx context.Context, height int64) bool

func (BlockFilterFn) IsPublishable

func (b BlockFilterFn) IsPublishable(ctx context.Context, height int64) bool

type Metrics

type Metrics struct {
	// Tx Validation
	TxValidationTotal       metrics.Counter
	TxValidationResultTotal metrics.Counter `metrics_labels:"result"`
	CheckTxDurationSeconds  metrics.Histogram

	// InitChain
	InitChainDurationSeconds metrics.Histogram

	// Block Execution
	BlockExecutionDurationSeconds     metrics.Histogram
	TxsExecutedPerBlock               metrics.Histogram
	BlockExecutionStepDurationSeconds metrics.Histogram `metrics_labels:"step"`
	ValidatorUpdatesTotal             metrics.Counter
	ConsensusParamUpdatesTotal        metrics.Counter

	// Tx Retrieval
	GetTxsDurationSeconds          metrics.Histogram
	TxsProposedTotal               metrics.Counter
	MempoolReapDurationSeconds     metrics.Histogram
	PrepareProposalDurationSeconds metrics.Histogram
}

Metrics contains metrics exposed by this package. Each metric is annotated with `metrics_labels` tag, which lists the labels used by the metric.

func NopMetrics

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").

type NetworkSoftConfirmationBlockFilter

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

NetworkSoftConfirmationBlockFilter is a BlockFilter implementation that uses the network module's SoftConfirmationStatus.

func (*NetworkSoftConfirmationBlockFilter) IsPublishable

func (f *NetworkSoftConfirmationBlockFilter) IsPublishable(ctx context.Context, height int64) bool

IsPublishable implements the BlockFilter interface.

type Option

type Option func(*Adapter)

Option is a functional option for configuring the Adapter.

func WithBlockFilter

func WithBlockFilter(publisher BlockFilter) Option

WithBlockFilter sets a custom block publisher for the Adapter.

func WithMetrics

func WithMetrics(m *Metrics) Option

WithMetrics sets custom metrics for the Adapter.

func WithNetworkSoftConfirmationBlockFilter

func WithNetworkSoftConfirmationBlockFilter() Option

WithNetworkSoftConfirmationBlockFilter creates a BlockFilter that uses the network module's SoftConfirmationStatus.

type P2PClientInfo

type P2PClientInfo interface {
	Info() (string, string, string, error)
	Host() host.Host
	PubSub() *pubsub.PubSub
	Addrs() []ma.Multiaddr
	Peers() []rollkitp2p.PeerConnection
}

type StackedEvent

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

Jump to

Keyboard shortcuts

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