Documentation
¶
Index ¶
- Constants
- Variables
- func NewMessageBuilder(chainInfo types.ChainInfo, capInfo capabilities.CapabilityInfo) *messageBuilder
- func NewMonitor(opts MonitorOpts) (*beholder.BeholderClient, error)
- func NewMonitorEmitter(lggr logger.Logger) beholder.ProtoEmitter
- func NewWriteTarget(opts WriteTargetOpts) capabilities.ExecutableCapability
- func NewWriteTargetID(chainFamilyName, networkName, chainID, version string) (string, error)
- type Config
- type MonitorOpts
- type ReqConfig
- type TargetStrategy
- type TransactionStatus
- type TransmissionState
- type WriteTargetOpts
Constants ¶
const ( CapabilityName = "write" // Input keys // Is this key chain agnostic? KeySignedReport = "signed_report" )
chain-agnostic consts
Variables ¶
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 ¶
func NewWriteTarget(opts WriteTargetOpts) capabilities.ExecutableCapability
TODO: opts.Config input is not validated for sanity
func NewWriteTargetID ¶
NewWriteTargetID returns the capability ID for the write target
Types ¶
type MonitorOpts ¶
type MonitorOpts struct {
Lggr logger.Logger
Processors map[string]beholder.ProtoProcessor
EnabledProcessors []string
Emitter beholder.ProtoEmitter
}
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
}