simulate

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const WorkflowExecutionTimeout = 5 * time.Minute

Variables

View Source
var (
	ColorBlue       = color.New(color.FgBlue)
	ColorBrightCyan = color.New(color.FgCyan, color.Bold)
	ColorYellow     = color.New(color.FgYellow)
	ColorRed        = color.New(color.FgRed)
	ColorGreen      = color.New(color.FgGreen)
	ColorMagenta    = color.New(color.FgMagenta)
)

Color instances for consistent styling

View Source
var SupportedEVM = []ChainConfig{

	{Selector: chainselectors.ETHEREUM_TESTNET_SEPOLIA.Selector, Forwarder: "0x15fC6ae953E024d975e77382eEeC56A9101f9F88"},
	{Selector: chainselectors.ETHEREUM_MAINNET.Selector, Forwarder: "0xa3d1ad4ac559a6575a114998affb2fb2ec97a7d9"},

	{Selector: chainselectors.ETHEREUM_TESTNET_SEPOLIA_BASE_1.Selector, Forwarder: "0x82300bd7c3958625581cc2f77bc6464dcecdf3e5"},
	{Selector: chainselectors.ETHEREUM_MAINNET_BASE_1.Selector, Forwarder: "0x5e342a8438b4f5d39e72875fcee6f76b39cce548"},

	{Selector: chainselectors.AVALANCHE_TESTNET_FUJI.Selector, Forwarder: "0x2e7371a5d032489e4f60216d8d898a4c10805963"},
	{Selector: chainselectors.AVALANCHE_MAINNET.Selector, Forwarder: "0xdc21e279934ff6721cadfdd112dafb3261f09a2c"},

	{Selector: chainselectors.POLYGON_TESTNET_AMOY.Selector, Forwarder: "0x3675a5eb2286a3f87e8278fc66edf458a2e3bb74"},
	{Selector: chainselectors.POLYGON_MAINNET.Selector, Forwarder: "0xf458d621885e29a5003ea9bbba5280d54e19b1ce"},

	{Selector: chainselectors.BINANCE_SMART_CHAIN_TESTNET.Selector, Forwarder: "0xa238e42cb8782808dbb2f37e19859244ec4779b0"},
	{Selector: chainselectors.BINANCE_SMART_CHAIN_MAINNET.Selector, Forwarder: "0x6f3239bbb26e98961e1115aba83f8a282e5508c8"},

	{Selector: chainselectors.ETHEREUM_TESTNET_SEPOLIA_ARBITRUM_1.Selector, Forwarder: "0xd41263567ddfead91504199b8c6c87371e83ca5d"},
	{Selector: chainselectors.ETHEREUM_MAINNET_ARBITRUM_1.Selector, Forwarder: "0xd770499057619c9a76205fd4168161cf94abc532"},

	{Selector: chainselectors.ETHEREUM_TESTNET_SEPOLIA_OPTIMISM_1.Selector, Forwarder: "0xa2888380dff3704a8ab6d1cd1a8f69c15fea5ee3"},
	{Selector: chainselectors.ETHEREUM_MAINNET_OPTIMISM_1.Selector, Forwarder: "0x9119a1501550ed94a3f2794038ed9258337afa18"},
}

SupportedEVM is the canonical list you can range over.

Functions

func CleanLogMessage

func CleanLogMessage(msg string) string

CleanLogMessage removes structured log patterns from messages

func FormatCapability

func FormatCapability(capabilityID string) string

FormatCapability formats capability ID for display

func FormatStepRef

func FormatStepRef(stepRef string) string

FormatStepRef formats step reference, handling the -1 case

func FormatTimestamp

func FormatTimestamp(timestamp string) string

FormatTimestamp converts RFC3339Nano timestamp to simple format

func GetColor

func GetColor(status string) *color.Color

GetColor returns the appropriate color for a given status/level

func GetLogLevel

func GetLogLevel(msg string) string

GetLogLevel extracts log level from a message

func HighlightLogLevels

func HighlightLogLevels(msg string, levelColor *color.Color) string

HighlightLogLevels highlights INFO, WARN, ERROR in log messages

func MapCapabilityStatus

func MapCapabilityStatus(status string) string

MapCapabilityStatus maps capability status to display format

func New

func New(runtimeContext *runtime.Context) *cobra.Command

func NewFakeActionCapabilities

func NewFakeActionCapabilities(ctx context.Context, lggr logger.Logger, registry *capabilities.Registry) ([]services.Service, error)

NewFakeCapabilities builds faked capabilities, then registers them with the capability registry.

func ReplaceSecretNamesWithEnvVars

func ReplaceSecretNamesWithEnvVars(secrets []byte) ([]byte, error)

Replace secret names with secrets values that must be loaded into the environment by the user

Types

type ChainConfig

type ChainConfig struct {
	Selector  ChainSelector
	Forwarder string
}

type ChainSelector

type ChainSelector = uint64

type DataPoint

type DataPoint struct {
	Attributes []MetricAttribute `json:"Attributes"`
	StartTime  string            `json:"StartTime"`
	Time       string            `json:"Time"`
	Value      interface{}       `json:"Value"`
}

type Inputs

type Inputs struct {
	WorkflowPath  string                       `validate:"required,path_read"`
	ConfigPath    string                       `validate:"omitempty,file,ascii,max=97"`
	SecretsPath   string                       `validate:"omitempty,file,ascii,max=97"`
	EngineLogs    bool                         `validate:"omitempty" cli:"--engine-logs"`
	Broadcast     bool                         `validate:"-"`
	EVMClients    map[uint64]*ethclient.Client `validate:"omitempty"` // multichain clients keyed by selector
	EthPrivateKey *ecdsa.PrivateKey            `validate:"omitempty"`
	WorkflowName  string                       `validate:"required"`
	// Non-interactive mode options
	NonInteractive bool   `validate:"-"`
	TriggerIndex   int    `validate:"-"`
	HTTPPayload    string `validate:"-"` // JSON string or @/path/to/file.json
	EVMTxHash      string `validate:"-"` // 0x-prefixed
	EVMEventIndex  int    `validate:"-"`
}

type LogLevel

type LogLevel string

LogLevel represents the level of a simulation log

const (
	LogLevelDebug   LogLevel = "DEBUG"
	LogLevelInfo    LogLevel = "INFO"
	LogLevelWarning LogLevel = "WARNING"
	LogLevelError   LogLevel = "ERROR"
)

type ManualTriggerCapabilitiesConfig

type ManualTriggerCapabilitiesConfig struct {
	Clients    map[uint64]*ethclient.Client
	Forwarders map[uint64]common.Address
	PrivateKey *ecdsa.PrivateKey
}

type ManualTriggers

type ManualTriggers struct {
	ManualCronTrigger *fakes.ManualCronTriggerService
	ManualHTTPTrigger *fakes.ManualHTTPTriggerService
	ManualEVMChains   map[uint64]*fakes.FakeEVMChain
}

func NewManualTriggerCapabilities

func NewManualTriggerCapabilities(
	ctx context.Context,
	lggr logger.Logger,
	registry *capabilities.Registry,
	cfg ManualTriggerCapabilitiesConfig,
	dryRunChainWrite bool,
) (*ManualTriggers, error)

func (*ManualTriggers) Close

func (m *ManualTriggers) Close() error

func (*ManualTriggers) Start

func (m *ManualTriggers) Start(ctx context.Context) error

type Metric

type Metric struct {
	Name        string     `json:"Name"`
	Description string     `json:"Description"`
	Unit        string     `json:"Unit"`
	Data        MetricData `json:"Data"`
}

type MetricAttribute

type MetricAttribute struct {
	Key   string `json:"Key"`
	Value struct {
		Type  string `json:"Type"`
		Value string `json:"Value"`
	} `json:"Value"`
}

type MetricData

type MetricData struct {
	DataPoints []DataPoint `json:"DataPoints"`
}

type MetricsLog

type MetricsLog struct {
	Resource     []ResourceAttribute `json:"Resource"`
	ScopeMetrics []ScopeMetrics      `json:"ScopeMetrics"`
}

MetricsLog represents OpenTelemetry metrics logs

type MetricsScope

type MetricsScope struct {
	Name    string `json:"Name"`
	Version string `json:"Version"`
}

type ResourceAttribute

type ResourceAttribute struct {
	Key   string `json:"Key"`
	Value struct {
		Type  string `json:"Type"`
		Value string `json:"Value"`
	} `json:"Value"`
}

type ScopeMetrics

type ScopeMetrics struct {
	Scope   MetricsScope `json:"Scope"`
	Metrics []Metric     `json:"Metrics"`
}

type SimulationLogger

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

SimulationLogger provides an easy interface for formatted simulation logs

func NewSimulationLogger

func NewSimulationLogger(verbosity bool) *SimulationLogger

NewSimulationLogger creates a new simulation logger with verbosity control

func (*SimulationLogger) Debug

func (s *SimulationLogger) Debug(message string, fields ...interface{})

Debug logs a debug level message with colored formatting (only if verbosity is enabled)

func (*SimulationLogger) Error

func (s *SimulationLogger) Error(message string, fields ...interface{})

Error logs an error level message with colored formatting

func (*SimulationLogger) Info

func (s *SimulationLogger) Info(message string, fields ...interface{})

Info logs an info level message with colored formatting

func (*SimulationLogger) PrintStepLog

func (s *SimulationLogger) PrintStepLog(timestamp, component, stepRef, capability, status string)

PrintStepLog prints a capability step log with timestamp and colored status

func (*SimulationLogger) PrintTimestampedLog

func (s *SimulationLogger) PrintTimestampedLog(timestamp, prefix, message string, prefixColor *color.Color)

PrintTimestampedLog prints a log with timestamp and colored prefix

func (*SimulationLogger) PrintTimestampedLogWithStatus

func (s *SimulationLogger) PrintTimestampedLogWithStatus(timestamp, prefix, message, status string)

PrintTimestampedLogWithStatus prints a log with timestamp, prefix, and colored status

func (*SimulationLogger) PrintWorkflowMetadata

func (s *SimulationLogger) PrintWorkflowMetadata(metadata interface{})

PrintWorkflowMetadata prints workflow metadata with proper indentation

func (*SimulationLogger) Warn

func (s *SimulationLogger) Warn(message string, fields ...interface{})

Warn logs a warning level message with colored formatting

type TelemetryLog

type TelemetryLog struct {
	Severity int `json:"Severity"`
	Body     struct {
		Type  string `json:"Type"`
		Value string `json:"Value"` // Base64 encoded protobuf
	} `json:"Body"`
	Attributes []struct {
		Key   string `json:"Key"`
		Value struct {
			Type  string `json:"Type"`
			Value string `json:"Value"`
		} `json:"Value"`
	} `json:"Attributes"`
}

TelemetryLog represents the JSON structure of telemetry logs from beholder

type TriggerInfoAndBeforeStart

type TriggerInfoAndBeforeStart struct {
	TriggerFunc  func() error
	TriggerToRun *pb.TriggerSubscription
	BeforeStart  func(ctx context.Context, cfg simulator.RunnerConfig, registry *capabilities.Registry, services []services.Service, triggerSub []*pb.TriggerSubscription)
}

Jump to

Keyboard shortcuts

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