writetarget

package
v0.0.0-...-1c5c8e4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 20 Imported by: 1

README

Generalized Write Target

This framework allows for any chain to implement the write target with minimal friction simply by implementing the interface target_strategy

Aptos Implementation EVM Implementation

Documentation

Index

Constants

View Source
const (
	CapabilityName = "write"

	// Input keys
	// Is this key chain agnostic?
	KeySignedReport = "signed_report"
)

chain-agnostic consts

Variables

View Source
var DefaultConfigSet = Config{
	PollPeriod:        1 * time.Second,
	AcceptanceTimeout: 10 * time.Second,
}

DefaultConfigSet is the default configuration for the write target component.

Functions

func NewMessageBuilder

func NewMessageBuilder(chainInfo types.ChainInfo, capInfo capabilities.CapabilityInfo) *messageBuilder

NewMessageBuilder creates a new message builder

func NewMonitor

func NewMonitor(opts MonitorOpts) (*beholder.BeholderClient, error)

NewMonitor initializes a Beholder client for the Write Target

The client is initialized as a BeholderClient extension with a custom ProtoEmitter. The ProtoEmitter is proxied with additional processing for emitted messages. This processing includes decoding messages as specific types and deriving metrics based on the decoded messages. TODO: Report decoding uses the same ABI for EVM and Aptos, however, future chains may need a different decoding scheme. Generalize this in the future to support different chains and decoding schemes.

func NewMonitorEmitter

func NewMonitorEmitter(lggr logger.Logger) beholder.ProtoEmitter

func NewWriteTarget

TODO: opts.Config input is not validated for sanity

func NewWriteTargetID

func NewWriteTargetID(chainFamilyName, networkName, chainID, version string) (string, error)

NewWriteTargetID returns the capability ID for the write target

Types

type Config

type Config struct {
	PollPeriod        time.Duration
	AcceptanceTimeout time.Duration
}

Config defines the write target component configuration.

type MonitorOpts

type MonitorOpts struct {
	Lggr              logger.Logger
	Processors        map[string]beholder.ProtoProcessor
	EnabledProcessors []string
	Emitter           beholder.ProtoEmitter
}

type ReqConfig

type ReqConfig struct {
	Address   string
	Processor string
}

Capability-specific configuration

type TargetStrategy

type TargetStrategy interface {
	// QueryTransmissionState defines how the report should be queried
	// via ChainReader, and how resulting errors should be classified.
	QueryTransmissionState(ctx context.Context, reportID uint16, request capabilities.CapabilityRequest) (*TransmissionState, error)
	// TransmitReport constructs the tx to transmit the report, and defines
	// any specific handling for sending the report via ChainWriter.
	TransmitReport(ctx context.Context, report []byte, reportContext []byte, signatures [][]byte, request capabilities.CapabilityRequest) (string, error)
	// Wrapper around the ChainWriter to get the transaction status
	GetTransactionStatus(ctx context.Context, transactionID string) (commontypes.TransactionStatus, error)
	// Wrapper around the ChainWriter to get the fee esimate
	GetEstimateFee(ctx context.Context, report []byte, reportContext []byte, signatures [][]byte, request capabilities.CapabilityRequest) (commontypes.EstimateFee, error)
	// GetTransactionFee retrieves the actual transaction fee in native currency from the transaction receipt.
	// This method should be implemented by chain-specific services and handle the conversion of gas units to native currency.
	GetTransactionFee(ctx context.Context, transactionID string) (decimal.Decimal, error)
}

type TransactionStatus

type TransactionStatus uint8
const (
	TransmissionStateNotAttempted TransactionStatus = iota
	TransmissionStateSucceeded
	TransmissionStateFailed // retry
	TransmissionStateFatal  // don't retry
)

new chain agnostic transmission state types

type TransmissionState

type TransmissionState struct {
	Status      TransactionStatus
	Transmitter string
	Err         error
}

alter TransmissionState to reference specific types rather than just success bool

type WriteTargetOpts

type WriteTargetOpts struct {
	ID string

	// toml: [<CHAIN>.WriteTargetCap]
	Config Config
	// ChainInfo contains the chain information (used as execution context)
	// TODO: simplify by passing via ChainService.GetChainStatus fn
	ChainInfo commontypes.ChainInfo

	Logger   logger.Logger
	Beholder *beholder.BeholderClient

	ChainService     chainService
	ConfigValidateFn func(request capabilities.CapabilityRequest) (string, error)

	NodeAddress      string
	ForwarderAddress string

	TargetStrategy       TargetStrategy
	WriteAcceptanceState commontypes.TransactionStatus
}

Directories

Path Synopsis
monitoring
pb/common
pb/common/generate.go
pb/common/generate.go
report

Jump to

Keyboard shortcuts

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