simulate

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const WorkflowExecutionTimeout = 5 * time.Minute

Variables

View Source
var (
	StyleBlue       = lipgloss.NewStyle().Foreground(lipgloss.Color(ui.ColorBlue500))
	StyleBrightCyan = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(ui.ColorTeal400))
	StyleYellow     = lipgloss.NewStyle().Foreground(lipgloss.Color(ui.ColorYellow400))
	StyleRed        = lipgloss.NewStyle().Foreground(lipgloss.Color(ui.ColorRed400))
	StyleGreen      = lipgloss.NewStyle().Foreground(lipgloss.Color(ui.ColorGreen400))
	StyleMagenta    = lipgloss.NewStyle().Foreground(lipgloss.Color(ui.ColorPurple400))
)

Style instances for consistent styling (using Chainlink Blocks palette)

Functions

func CleanLogMessage

func CleanLogMessage(msg string) string

CleanLogMessage removes structured log patterns from messages

func ExportDefaultLimitsJSON added in v1.6.0

func ExportDefaultLimitsJSON() []byte

ExportDefaultLimitsJSON returns the embedded default limits JSON.

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 GetLogLevel

func GetLogLevel(msg string) string

GetLogLevel extracts log level from a message

func GetStyle added in v1.1.0

func GetStyle(status string) lipgloss.Style

GetStyle returns the appropriate style for a given status/level

func HighlightLogLevels

func HighlightLogLevels(msg string, levelStyle lipgloss.Style) 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, secretsPath string, limits *SimulationLimits) ([]services.Service, error)

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

func ReplaceSecretNamesWithEnvVars

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

ReplaceSecretNamesWithEnvVars resolves env var references in the secrets YAML, returning a new YAML with the env var names replaced by their actual values. It rebuilds the YAML from the parsed structure to avoid substring corruption.

Types

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 {
	WasmPath     string `validate:"omitempty,file,ascii,max=97" cli:"--wasm"`
	WorkflowPath string `validate:"required,workflow_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:"-"`
	WorkflowName string `validate:"required"`
	// Chain-type-specific fields
	ChainTypeClients map[string]map[uint64]chain.ChainClient `validate:"omitempty"`
	ChainTypeKeys    map[string]interface{}                  `validate:"-"`
	// ChainTypeResolved holds the full ResolveClients bundle per chain type
	// (clients, forwarders, experimental-selector flags) so later steps
	// (health check, capability registration) have a single source of truth.
	ChainTypeResolved map[string]chain.ResolvedChains `validate:"-"`
	// Non-interactive mode options
	NonInteractive  bool              `validate:"-"`
	TriggerIndex    int               `validate:"-"`
	HTTPPayload     string            `validate:"-"` // JSON string or @/path/to/file.json
	ChainTypeInputs map[string]string `validate:"-"` // CLI-supplied chain-type-specific trigger inputs
	// Limits enforcement
	LimitsPath string `validate:"-"` // "default" or path to custom limits JSON
	// SkipTypeChecks passes --skip-type-checks to cre-compile for TypeScript workflows.
	SkipTypeChecks bool `validate:"-"`
	// InvocationDir is the working directory at the time the CLI was invoked, before
	// SetExecutionContext changes it to the workflow directory. Used to resolve file
	// paths entered interactively or via flags relative to where the user ran the command.
	InvocationDir string `validate:"-"`
}

type LimitedConfidentialHTTPAction added in v1.6.0

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

LimitedConfidentialHTTPAction wraps a confhttpserver.ClientCapability and enforces request/response size limits and connection timeout from SimulationLimits.

func NewLimitedConfidentialHTTPAction added in v1.6.0

func NewLimitedConfidentialHTTPAction(inner confhttpserver.ClientCapability, limits *SimulationLimits) *LimitedConfidentialHTTPAction

func (*LimitedConfidentialHTTPAction) Close added in v1.6.0

func (*LimitedConfidentialHTTPAction) Description added in v1.6.0

func (l *LimitedConfidentialHTTPAction) Description() string

func (*LimitedConfidentialHTTPAction) HealthReport added in v1.6.0

func (l *LimitedConfidentialHTTPAction) HealthReport() map[string]error

func (*LimitedConfidentialHTTPAction) Initialise added in v1.6.0

func (*LimitedConfidentialHTTPAction) Name added in v1.6.0

func (*LimitedConfidentialHTTPAction) Ready added in v1.6.0

func (*LimitedConfidentialHTTPAction) Start added in v1.6.0

type LimitedConsensusNoDAG added in v1.6.0

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

LimitedConsensusNoDAG wraps a consensusserver.ConsensusCapability and enforces observation size limits from SimulationLimits.

func NewLimitedConsensusNoDAG added in v1.6.0

func NewLimitedConsensusNoDAG(inner consensusserver.ConsensusCapability, limits *SimulationLimits) *LimitedConsensusNoDAG

func (*LimitedConsensusNoDAG) Close added in v1.6.0

func (l *LimitedConsensusNoDAG) Close() error

func (*LimitedConsensusNoDAG) Description added in v1.6.0

func (l *LimitedConsensusNoDAG) Description() string

func (*LimitedConsensusNoDAG) HealthReport added in v1.6.0

func (l *LimitedConsensusNoDAG) HealthReport() map[string]error

func (*LimitedConsensusNoDAG) Initialise added in v1.6.0

func (*LimitedConsensusNoDAG) Name added in v1.6.0

func (l *LimitedConsensusNoDAG) Name() string

func (*LimitedConsensusNoDAG) Ready added in v1.6.0

func (l *LimitedConsensusNoDAG) Ready() error

func (*LimitedConsensusNoDAG) Report added in v1.6.0

func (*LimitedConsensusNoDAG) Simple added in v1.6.0

func (*LimitedConsensusNoDAG) Start added in v1.6.0

type LimitedHTTPAction added in v1.6.0

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

LimitedHTTPAction wraps an httpserver.ClientCapability and enforces request/response size limits and connection timeout from SimulationLimits.

func NewLimitedHTTPAction added in v1.6.0

func NewLimitedHTTPAction(inner httpserver.ClientCapability, limits *SimulationLimits) *LimitedHTTPAction

func (*LimitedHTTPAction) Close added in v1.6.0

func (l *LimitedHTTPAction) Close() error

func (*LimitedHTTPAction) Description added in v1.6.0

func (l *LimitedHTTPAction) Description() string

func (*LimitedHTTPAction) HealthReport added in v1.6.0

func (l *LimitedHTTPAction) HealthReport() map[string]error

func (*LimitedHTTPAction) Initialise added in v1.6.0

func (*LimitedHTTPAction) Name added in v1.6.0

func (l *LimitedHTTPAction) Name() string

func (*LimitedHTTPAction) Ready added in v1.6.0

func (l *LimitedHTTPAction) Ready() error

func (*LimitedHTTPAction) SendRequest added in v1.6.0

func (*LimitedHTTPAction) Start added in v1.6.0

func (l *LimitedHTTPAction) Start(ctx context.Context) error

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 ManualTriggers

type ManualTriggers struct {
	ManualCronTrigger *fakes.ManualCronTriggerService
	ManualHTTPTrigger *fakes.ManualHTTPTriggerService
}

ManualTriggers holds chain-agnostic trigger services used in simulation.

func NewManualTriggerCapabilities

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

NewManualTriggerCapabilities creates and registers cron and HTTP trigger capabilities. These are chain-agnostic and shared across all chain types.

func (*ManualTriggers) Close

func (m *ManualTriggers) Close() error

Close closes cron and HTTP trigger services.

func (*ManualTriggers) Start

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

Start starts cron and HTTP trigger services.

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 SimulationLimits added in v1.6.0

type SimulationLimits struct {
	Workflows cresettings.Workflows
}

SimulationLimits holds the workflow-level limits applied during simulation.

func DefaultLimits added in v1.6.0

func DefaultLimits() (*SimulationLimits, error)

DefaultLimits returns simulation limits populated from the embedded defaults.

func LoadLimits added in v1.6.0

func LoadLimits(path string) (*SimulationLimits, error)

LoadLimits reads a limits JSON file from disk and returns parsed SimulationLimits.

func ResolveLimits added in v1.6.0

func ResolveLimits(limitsFlag string) (*SimulationLimits, error)

ResolveLimits resolves a --limits flag value to SimulationLimits. Returns nil if limitsFlag is "none" (no limits enforcement).

func (*SimulationLimits) ChainWriteGasLimit added in v1.12.0

func (l *SimulationLimits) ChainWriteGasLimit() uint64

ChainWriteGasLimit returns the default EVM gas limit.

func (*SimulationLimits) ChainWriteReportSizeLimit added in v1.6.0

func (l *SimulationLimits) ChainWriteReportSizeLimit() int

ChainWriteReportSizeLimit returns the chain write report size limit in bytes.

func (*SimulationLimits) ConfHTTPRequestSizeLimit added in v1.6.0

func (l *SimulationLimits) ConfHTTPRequestSizeLimit() int

ConfHTTPRequestSizeLimit returns the confidential HTTP request size limit in bytes.

func (*SimulationLimits) ConfHTTPResponseSizeLimit added in v1.6.0

func (l *SimulationLimits) ConfHTTPResponseSizeLimit() int

ConfHTTPResponseSizeLimit returns the confidential HTTP response size limit in bytes.

func (*SimulationLimits) ConsensusObservationSizeLimit added in v1.6.0

func (l *SimulationLimits) ConsensusObservationSizeLimit() int

ConsensusObservationSizeLimit returns the consensus observation size limit in bytes.

func (*SimulationLimits) HTTPRequestSizeLimit added in v1.6.0

func (l *SimulationLimits) HTTPRequestSizeLimit() int

HTTPRequestSizeLimit returns the HTTP action request size limit in bytes.

func (*SimulationLimits) HTTPResponseSizeLimit added in v1.6.0

func (l *SimulationLimits) HTTPResponseSizeLimit() int

HTTPResponseSizeLimit returns the HTTP action response size limit in bytes.

func (*SimulationLimits) LimitsSummary added in v1.6.0

func (l *SimulationLimits) LimitsSummary() string

LimitsSummary returns a human-readable summary of key limits.

func (*SimulationLimits) WASMBinarySize added in v1.6.0

func (l *SimulationLimits) WASMBinarySize() int

WASMBinarySize returns the WASM binary size limit in bytes.

func (*SimulationLimits) WASMCompressedBinarySize added in v1.6.0

func (l *SimulationLimits) WASMCompressedBinarySize() int

WASMCompressedBinarySize returns the WASM compressed binary size limit in bytes.

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 styled status

func (*SimulationLogger) PrintTimestampedLog

func (s *SimulationLogger) PrintTimestampedLog(timestamp, prefix, message string, prefixStyle lipgloss.Style)

PrintTimestampedLog prints a log with timestamp and styled prefix

func (*SimulationLogger) PrintTimestampedLogWithStatus

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

PrintTimestampedLogWithStatus prints a log with timestamp, prefix, and styled 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)
}

Directories

Path Synopsis
evm

Jump to

Keyboard shortcuts

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