Documentation
¶
Overview ¶
Package fuzz provides a lightweight harness for exercising OpenAudio node networks with disruptive actions and liveness assertions.
The package intentionally depends only on externally observable node behavior and local process management. That keeps it usable against a local devnet, staging-like environments, or an already-running validator set without importing the core runtime packages.
Index ¶
- Constants
- Variables
- func IsModelInvariantError(err error) bool
- func SeededValidatorPowers(nodeCount int, seed int64) map[NodeID]int64
- type Action
- func AdvertiseEndpointWith(mutator EndpointMutator, id NodeID, endpoint string) Action
- func CaptureReachabilityBaseline(baseline *ReachabilityBaseline) Action
- func CaptureValidatorPowerBaseline(baseline *ValidatorPowerBaseline) Action
- func DeregisterNodeWith(registrar Registrar, id NodeID) Action
- func HookAction(name string, fn func(context.Context, *RunContext) error) Action
- func JailNodeWith(jailer Jailer, id NodeID) Action
- func Parallel(name string, actions ...Action) Action
- func RegisterNodeWith(registrar Registrar, id NodeID) Action
- func RestartNode(id NodeID) Action
- func Sequence(name string, actions ...Action) Action
- func StartNode(id NodeID) Action
- func StopNode(id NodeID) Action
- func UnjailNodeWith(jailer Jailer, id NodeID) Action
- func Wait(duration time.Duration) Action
- type ActionFunc
- type Assertion
- func AllReachable() Assertion
- func HeightAdvances(minDelta int64, within, pollInterval time.Duration) Assertion
- func HeightFollowsValidatorQuorum(within, pollInterval time.Duration) Assertion
- func HeightStalls(observeFor, pollInterval time.Duration) Assertion
- func HeightStallsWithoutValidatorQuorum(within, pollInterval time.Duration) Assertion
- func LiveValidatorHeightsConverge(maxSpread int64, within, pollInterval time.Duration) Assertion
- func NoHeightRegression(observeFor, pollInterval time.Duration) Assertion
- func NoLiveValidatorFork() Assertion
- func NodesAvailable(ids []NodeID, within, pollInterval time.Duration) Assertion
- func NodesUnavailable(ids []NodeID, within, pollInterval time.Duration) Assertion
- func NodesWithoutValidatorPower(ids []NodeID, within, pollInterval time.Duration) Assertion
- func QuorumReady(required int, within, pollInterval time.Duration) Assertion
- func ReachabilityRestored(baseline *ReachabilityBaseline, within, pollInterval time.Duration) Assertion
- func ReachableAtLeast(required int, within, pollInterval time.Duration) Assertion
- func ValidatorOutcomeAssertions(within, pollInterval time.Duration, requireConvergence bool) []Assertion
- func ValidatorPowerEquals(id NodeID, power int64, within, pollInterval time.Duration) Assertion
- func ValidatorPowerRestored(baseline *ValidatorPowerBaseline, within, pollInterval time.Duration) Assertion
- func ValidatorStallOutcomeAssertions(within, pollInterval time.Duration) []Assertion
- type AssertionFunc
- type Client
- type ClientOption
- type EndpointMutator
- type EthRegistryController
- func (c *EthRegistryController) Close()
- func (c *EthRegistryController) DeregisterNode(ctx context.Context, node NodeSpec) error
- func (c *EthRegistryController) RegisterNode(ctx context.Context, node NodeSpec) error
- func (c *EthRegistryController) SetNodeEndpoint(ctx context.Context, node NodeSpec, endpoint string) error
- type EthRegistryControllerOptions
- type Event
- type Jailer
- type ModelAction
- type ModelActionKind
- type ModelEvent
- type ModelInvariantError
- type ModelNode
- type ModelResult
- type ModelValidatorState
- type Network
- type NetworkSpec
- type NodeID
- type NodeSpec
- type NodeStatus
- type ProcessNetwork
- func (n *ProcessNetwork) Close(ctx context.Context) error
- func (n *ProcessNetwork) RestartNode(ctx context.Context, id NodeID) error
- func (n *ProcessNetwork) Snapshot(ctx context.Context) (Snapshot, error)
- func (n *ProcessNetwork) Spec() NetworkSpec
- func (n *ProcessNetwork) StartNode(ctx context.Context, id NodeID) error
- func (n *ProcessNetwork) StopNode(ctx context.Context, id NodeID) error
- type ReachabilityBaseline
- type Registrar
- type Result
- type RunContext
- type Runner
- type Scenario
- func BasicLivenessScenario(minHeightDelta int64, within, pollInterval time.Duration) Scenario
- func CohortEndpointConsensusIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- func CohortLifecycleRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- func CompoundOutcomeEdgeCaseScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- func DuplicateDeregisterIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func DuplicateJailIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func EndpointLieConsensusIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func EndpointRegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func EndpointRepairIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func InactiveEndpointIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func InactiveStartIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func JailedDeregisterCompatibilityScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func JailedEndpointRepairRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func JailedRegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func LiveLivenessScenario(requiredReachable int, minHeightDelta int64, ...) Scenario
- func MixedLifecycleQuorumRecoveryScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- func NonJailedUnjailIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func OutcomeEdgeCaseScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- func PowerBoundaryOutcomeScenario(within, pollInterval time.Duration) Scenario
- func PowerSkewOutcomeScenario(spec NetworkSpec, controller ValidatorChaosController, highPowerID NodeID, ...) Scenario
- func QuorumLossRecoveryScenario(spec NetworkSpec, within, pollInterval time.Duration) Scenario
- func RegisterIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func RegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func RestartNodeScenario(id NodeID, readyCount int, within, pollInterval time.Duration) Scenario
- func SimulatedChaosScenarioFromProgram(spec NetworkSpec, controller ValidatorChaosController, program []byte, ...) Scenario
- func StopStartRoundTripScenario(spec NetworkSpec, target NodeID, within, pollInterval time.Duration) Scenario
- func UnjailRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, ...) Scenario
- func ValidatorChaosScenario(spec NetworkSpec, controller ValidatorChaosController, ...) Scenario
- type SimulatedNetwork
- func (n *SimulatedNetwork) Close(context.Context) error
- func (n *SimulatedNetwork) DeregisterNode(ctx context.Context, node NodeSpec) error
- func (n *SimulatedNetwork) JailNode(ctx context.Context, node NodeSpec) error
- func (n *SimulatedNetwork) RegisterNode(ctx context.Context, node NodeSpec) error
- func (n *SimulatedNetwork) RestartNode(ctx context.Context, id NodeID) error
- func (n *SimulatedNetwork) SetNodeEndpoint(ctx context.Context, node NodeSpec, endpoint string) error
- func (n *SimulatedNetwork) Snapshot(ctx context.Context) (Snapshot, error)
- func (n *SimulatedNetwork) Spec() NetworkSpec
- func (n *SimulatedNetwork) StartNode(ctx context.Context, id NodeID) error
- func (n *SimulatedNetwork) StopNode(ctx context.Context, id NodeID) error
- func (n *SimulatedNetwork) UnjailNode(ctx context.Context, node NodeSpec) error
- type SimulatedNetworkOptions
- type SimulatedProgramOptions
- type Snapshot
- func (s Snapshot) ByNode(id NodeID) (NodeStatus, bool)
- func (s Snapshot) HasValidatorQuorum() bool
- func (s Snapshot) MaxHeight() int64
- func (s Snapshot) MaxObservedHeight() int64
- func (s Snapshot) ReachableCount() int
- func (s Snapshot) ReadyCount() int
- func (s Snapshot) Summary() string
- func (s Snapshot) ValidatorPower() (totalPower, livePower int64)
- type StaticNetwork
- func (n *StaticNetwork) Close(context.Context) error
- func (n *StaticNetwork) RestartNode(context.Context, NodeID) error
- func (n *StaticNetwork) Snapshot(ctx context.Context) (Snapshot, error)
- func (n *StaticNetwork) Spec() NetworkSpec
- func (n *StaticNetwork) StartNode(context.Context, NodeID) error
- func (n *StaticNetwork) StopNode(context.Context, NodeID) error
- type StatusReader
- type Step
- type ValidatorChaosController
- type ValidatorChaosOptions
- type ValidatorLifecycleModel
- type ValidatorModelOptions
- type ValidatorPowerBaseline
- type ValidatorSetBehavior
- type VersionSkewMode
- type VersionSkewNetwork
- func (n *VersionSkewNetwork) Close(context.Context) error
- func (n *VersionSkewNetwork) DeregisterNode(ctx context.Context, node NodeSpec) error
- func (n *VersionSkewNetwork) JailNode(ctx context.Context, node NodeSpec) error
- func (n *VersionSkewNetwork) RegisterNode(ctx context.Context, node NodeSpec) error
- func (n *VersionSkewNetwork) RestartNode(ctx context.Context, id NodeID) error
- func (n *VersionSkewNetwork) SetNodeEndpoint(ctx context.Context, node NodeSpec, endpoint string) error
- func (n *VersionSkewNetwork) Snapshot(ctx context.Context) (Snapshot, error)
- func (n *VersionSkewNetwork) Spec() NetworkSpec
- func (n *VersionSkewNetwork) StartNode(ctx context.Context, id NodeID) error
- func (n *VersionSkewNetwork) StopNode(ctx context.Context, id NodeID) error
- func (n *VersionSkewNetwork) UnjailNode(ctx context.Context, node NodeSpec) error
- type VersionSkewNetworkOptions
Constants ¶
const (
DefaultModelNodeLimit = 300
)
Variables ¶
Functions ¶
func IsModelInvariantError ¶
func SeededValidatorPowers ¶
SeededValidatorPowers returns deterministic, uneven voting power for simulated networks. The skew keeps generated chaos from quietly assuming node-count quorum is equivalent to validator-power quorum.
Types ¶
type Action ¶
type Action interface {
Name() string
Run(ctx context.Context, run *RunContext) error
}
func AdvertiseEndpointWith ¶
func AdvertiseEndpointWith(mutator EndpointMutator, id NodeID, endpoint string) Action
func CaptureReachabilityBaseline ¶
func CaptureReachabilityBaseline(baseline *ReachabilityBaseline) Action
func CaptureValidatorPowerBaseline ¶
func CaptureValidatorPowerBaseline(baseline *ValidatorPowerBaseline) Action
func DeregisterNodeWith ¶
func HookAction ¶
func JailNodeWith ¶
func RegisterNodeWith ¶
func RestartNode ¶
func UnjailNodeWith ¶
type ActionFunc ¶
type ActionFunc struct {
Label string
Fn func(context.Context, *RunContext) error
}
func (ActionFunc) Name ¶
func (a ActionFunc) Name() string
func (ActionFunc) Run ¶
func (a ActionFunc) Run(ctx context.Context, run *RunContext) error
type Assertion ¶
type Assertion interface {
Name() string
Check(ctx context.Context, run *RunContext) error
}
func AllReachable ¶
func AllReachable() Assertion
func HeightAdvances ¶
func HeightStalls ¶
func NoHeightRegression ¶
func NoLiveValidatorFork ¶
func NoLiveValidatorFork() Assertion
func NodesAvailable ¶
func NodesUnavailable ¶
func ReachabilityRestored ¶
func ReachabilityRestored(baseline *ReachabilityBaseline, within, pollInterval time.Duration) Assertion
func ReachableAtLeast ¶
func ValidatorPowerEquals ¶
func ValidatorPowerRestored ¶
func ValidatorPowerRestored(baseline *ValidatorPowerBaseline, within, pollInterval time.Duration) Assertion
type AssertionFunc ¶
type AssertionFunc struct {
Label string
Fn func(context.Context, *RunContext) error
}
func (AssertionFunc) Check ¶
func (a AssertionFunc) Check(ctx context.Context, run *RunContext) error
func (AssertionFunc) Name ¶
func (a AssertionFunc) Name() string
type Client ¶
Client reads node status through public HTTP surfaces.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func (*Client) DiscoverValidatorEndpoints ¶
func (*Client) GetNodeStatus ¶
type ClientOption ¶
type ClientOption func(*Client)
func WithDefaultScheme ¶
func WithDefaultScheme(scheme string) ClientOption
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
func WithInsecureTLS ¶
func WithInsecureTLS() ClientOption
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) ClientOption
type EndpointMutator ¶
type EndpointMutator interface {
SetNodeEndpoint(ctx context.Context, node NodeSpec, endpoint string) error
}
EndpointMutator is implemented by test helpers that can make a node advertise a different endpoint. This is the harness hook for "lying" behaviors.
type EthRegistryController ¶
type EthRegistryController struct {
// contains filtered or unexported fields
}
EthRegistryController drives the L1 ServiceProviderFactory contract for devnet-style lifecycle fuzzing. It is deliberately opt-in: callers must provide the RPC URL, registry address, and private key.
func NewEthRegistryController ¶
func NewEthRegistryController(ctx context.Context, opts EthRegistryControllerOptions) (*EthRegistryController, error)
func (*EthRegistryController) Close ¶
func (c *EthRegistryController) Close()
func (*EthRegistryController) DeregisterNode ¶
func (c *EthRegistryController) DeregisterNode(ctx context.Context, node NodeSpec) error
func (*EthRegistryController) RegisterNode ¶
func (c *EthRegistryController) RegisterNode(ctx context.Context, node NodeSpec) error
func (*EthRegistryController) SetNodeEndpoint ¶
type Jailer ¶
type Jailer interface {
JailNode(ctx context.Context, node NodeSpec) error
UnjailNode(ctx context.Context, node NodeSpec) error
}
Jailer is implemented by test helpers that can remove and restore a node from the active validator set without deleting the app-level node row.
type ModelAction ¶
type ModelAction struct {
Kind ModelActionKind
Node NodeID
}
type ModelActionKind ¶
type ModelActionKind uint8
const ( ModelRegister ModelActionKind = iota ModelJail ModelUnjail ModelDeregister ModelDeregisterTwice ModelStop ModelStart ModelLieEndpoint ModelRepairEndpoint ModelTick )
func (ModelActionKind) String ¶
func (a ModelActionKind) String() string
type ModelEvent ¶
type ModelEvent struct {
Step int
Action ModelActionKind
Node NodeID
StateBefore ModelValidatorState
StateAfter ModelValidatorState
InCometBefore bool
InCometAfter bool
OnlineBefore bool
OnlineAfter bool
EmittedUpdate bool
QuorumBefore bool
QuorumAfter bool
TotalPower int64
OnlinePower int64
Height int64
Error string
}
type ModelInvariantError ¶
type ModelInvariantError struct {
Message string
Event ModelEvent
Trace []ModelEvent
}
func (*ModelInvariantError) Error ¶
func (e *ModelInvariantError) Error() string
type ModelResult ¶
type ModelResult struct {
Seed int64
NodeCount int
Steps int
Height int64
Events []ModelEvent
}
func RunValidatorLifecycleModel ¶
func RunValidatorLifecycleModel(seed int64, nodeCount, steps int, behavior ValidatorSetBehavior) (ModelResult, error)
func RunValidatorLifecycleProgram ¶
func RunValidatorLifecycleProgram(program []byte, nodeCount int, behavior ValidatorSetBehavior) (ModelResult, error)
type ModelValidatorState ¶
type ModelValidatorState int
const ( ModelValidatorAbsent ModelValidatorState = iota ModelValidatorActive ModelValidatorJailed )
func (ModelValidatorState) String ¶
func (s ModelValidatorState) String() string
type Network ¶
type Network interface {
Spec() NetworkSpec
StartNode(ctx context.Context, id NodeID) error
StopNode(ctx context.Context, id NodeID) error
RestartNode(ctx context.Context, id NodeID) error
Snapshot(ctx context.Context) (Snapshot, error)
Close(ctx context.Context) error
}
Network is the control and observation surface used by scenarios.
type NetworkSpec ¶
NetworkSpec describes a network under test.
func (NetworkSpec) NodeIDs ¶
func (s NetworkSpec) NodeIDs() []NodeID
func (NetworkSpec) Validate ¶
func (s NetworkSpec) Validate() error
type NodeSpec ¶
type NodeSpec struct {
ID NodeID
Endpoint string
Command []string
Env map[string]string
Dir string
LogPath string
StartupTimeout time.Duration
ShutdownTimeout time.Duration
}
NodeSpec describes one node from the harness point of view.
Endpoint is the externally reachable HTTP(S) endpoint used for observations. Command is optional; when it is set, ProcessNetwork can start and stop the node as a local process.
type NodeStatus ¶
type NodeStatus struct {
ID NodeID
Endpoint string
Reachable bool
Ready bool
Live bool
Synced bool
Height int64
BlockHash string
Version string
Git string
ValidatorPower int64
ProcessState string
ProcessError string
ObservationError string
ObservedAt time.Time
}
NodeStatus is a single observation of one node.
type ProcessNetwork ¶
type ProcessNetwork struct {
// contains filtered or unexported fields
}
ProcessNetwork observes a network and can manage nodes whose NodeSpec includes a Command. Nodes without a command are still observable but are not startable or stoppable through this type.
func NewProcessNetwork ¶
func NewProcessNetwork(spec NetworkSpec, reader StatusReader) (*ProcessNetwork, error)
func (*ProcessNetwork) RestartNode ¶
func (n *ProcessNetwork) RestartNode(ctx context.Context, id NodeID) error
func (*ProcessNetwork) Snapshot ¶
func (n *ProcessNetwork) Snapshot(ctx context.Context) (Snapshot, error)
func (*ProcessNetwork) Spec ¶
func (n *ProcessNetwork) Spec() NetworkSpec
type ReachabilityBaseline ¶
type ReachabilityBaseline struct {
// contains filtered or unexported fields
}
type Registrar ¶
type Registrar interface {
RegisterNode(ctx context.Context, node NodeSpec) error
DeregisterNode(ctx context.Context, node NodeSpec) error
}
Registrar is implemented by test helpers that can register or deregister a node through whatever backing system the scenario is using.
type RunContext ¶
type RunContext struct {
Network Network
Rand *rand.Rand
// contains filtered or unexported fields
}
func (*RunContext) Events ¶
func (r *RunContext) Events() []Event
type Scenario ¶
func BasicLivenessScenario ¶
func CohortEndpointConsensusIsolationScenario ¶
func CohortEndpointConsensusIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, within, pollInterval time.Duration) Scenario
func CohortLifecycleRoundTripScenario ¶
func CohortLifecycleRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, within, pollInterval time.Duration) Scenario
func CompoundOutcomeEdgeCaseScenario ¶
func CompoundOutcomeEdgeCaseScenario(spec NetworkSpec, controller ValidatorChaosController, within, pollInterval time.Duration) Scenario
func DuplicateDeregisterIdempotencyScenario ¶
func DuplicateDeregisterIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func DuplicateJailIdempotencyScenario ¶
func DuplicateJailIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func EndpointLieConsensusIsolationScenario ¶
func EndpointLieConsensusIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func EndpointRegisterRoundTripScenario ¶
func EndpointRegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func EndpointRepairIdempotencyScenario ¶
func EndpointRepairIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func InactiveEndpointIsolationScenario ¶
func InactiveEndpointIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func InactiveStartIsolationScenario ¶
func InactiveStartIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func JailedDeregisterCompatibilityScenario ¶
func JailedDeregisterCompatibilityScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func JailedEndpointRepairRoundTripScenario ¶
func JailedEndpointRepairRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func JailedRegisterRoundTripScenario ¶
func JailedRegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func LiveLivenessScenario ¶
func MixedLifecycleQuorumRecoveryScenario ¶
func MixedLifecycleQuorumRecoveryScenario(spec NetworkSpec, controller ValidatorChaosController, within, pollInterval time.Duration) Scenario
func NonJailedUnjailIsolationScenario ¶
func NonJailedUnjailIsolationScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func OutcomeEdgeCaseScenario ¶
func OutcomeEdgeCaseScenario(spec NetworkSpec, controller ValidatorChaosController, within, pollInterval time.Duration) Scenario
func PowerSkewOutcomeScenario ¶
func PowerSkewOutcomeScenario(spec NetworkSpec, controller ValidatorChaosController, highPowerID NodeID, lowPowerIDs []NodeID, within, pollInterval time.Duration) Scenario
func QuorumLossRecoveryScenario ¶
func QuorumLossRecoveryScenario(spec NetworkSpec, within, pollInterval time.Duration) Scenario
func RegisterIdempotencyScenario ¶
func RegisterIdempotencyScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func RegisterRoundTripScenario ¶
func RegisterRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func RestartNodeScenario ¶
func SimulatedChaosScenarioFromProgram ¶
func SimulatedChaosScenarioFromProgram(spec NetworkSpec, controller ValidatorChaosController, program []byte, opts SimulatedProgramOptions) Scenario
func StopStartRoundTripScenario ¶
func StopStartRoundTripScenario(spec NetworkSpec, target NodeID, within, pollInterval time.Duration) Scenario
func UnjailRoundTripScenario ¶
func UnjailRoundTripScenario(spec NetworkSpec, controller ValidatorChaosController, target NodeID, within, pollInterval time.Duration) Scenario
func ValidatorChaosScenario ¶
func ValidatorChaosScenario(spec NetworkSpec, controller ValidatorChaosController, opts ValidatorChaosOptions) Scenario
type SimulatedNetwork ¶
type SimulatedNetwork struct {
// contains filtered or unexported fields
}
SimulatedNetwork is an in-memory Network plus lifecycle controller. It runs the same chaos scenarios as a real network but keeps everything inside Go, which makes high-volume 300-node loops practical on a laptop.
func NewSimulatedNetwork ¶
func NewSimulatedNetwork(opts SimulatedNetworkOptions) (*SimulatedNetwork, error)
func (*SimulatedNetwork) DeregisterNode ¶
func (n *SimulatedNetwork) DeregisterNode(ctx context.Context, node NodeSpec) error
func (*SimulatedNetwork) JailNode ¶
func (n *SimulatedNetwork) JailNode(ctx context.Context, node NodeSpec) error
func (*SimulatedNetwork) RegisterNode ¶
func (n *SimulatedNetwork) RegisterNode(ctx context.Context, node NodeSpec) error
func (*SimulatedNetwork) RestartNode ¶
func (n *SimulatedNetwork) RestartNode(ctx context.Context, id NodeID) error
func (*SimulatedNetwork) SetNodeEndpoint ¶
func (*SimulatedNetwork) Snapshot ¶
func (n *SimulatedNetwork) Snapshot(ctx context.Context) (Snapshot, error)
func (*SimulatedNetwork) Spec ¶
func (n *SimulatedNetwork) Spec() NetworkSpec
func (*SimulatedNetwork) StartNode ¶
func (n *SimulatedNetwork) StartNode(ctx context.Context, id NodeID) error
func (*SimulatedNetwork) StopNode ¶
func (n *SimulatedNetwork) StopNode(ctx context.Context, id NodeID) error
func (*SimulatedNetwork) UnjailNode ¶
func (n *SimulatedNetwork) UnjailNode(ctx context.Context, node NodeSpec) error
type SimulatedNetworkOptions ¶
type SimulatedProgramOptions ¶
type Snapshot ¶
type Snapshot struct {
ObservedAt time.Time
Nodes []NodeStatus
}
Snapshot is a point-in-time observation of the whole network.
func (Snapshot) HasValidatorQuorum ¶
func (Snapshot) MaxObservedHeight ¶
func (Snapshot) ReachableCount ¶
func (Snapshot) ReadyCount ¶
func (Snapshot) ValidatorPower ¶
type StaticNetwork ¶
type StaticNetwork struct {
// contains filtered or unexported fields
}
StaticNetwork observes an already-running network. It cannot start or stop nodes, but it is useful for running assertions against devnet, staging, or production-like endpoints.
func NewStaticNetwork ¶
func NewStaticNetwork(spec NetworkSpec, reader StatusReader) (*StaticNetwork, error)
func (*StaticNetwork) RestartNode ¶
func (n *StaticNetwork) RestartNode(context.Context, NodeID) error
func (*StaticNetwork) Snapshot ¶
func (n *StaticNetwork) Snapshot(ctx context.Context) (Snapshot, error)
func (*StaticNetwork) Spec ¶
func (n *StaticNetwork) Spec() NetworkSpec
type StatusReader ¶
type StatusReader interface {
GetNodeStatus(ctx context.Context, node NodeSpec) (NodeStatus, error)
}
StatusReader reads externally visible node status.
type ValidatorChaosController ¶
type ValidatorChaosController struct {
Registrar Registrar
EndpointMutator EndpointMutator
Jailer Jailer
}
type ValidatorChaosOptions ¶
type ValidatorChaosOptions struct {
Seed int64
Steps int
StepTimeout time.Duration
LivenessEvery int
LivenessWithin time.Duration
PollInterval time.Duration
ActionNodeIDs []NodeID
StartNodes bool
IncludeProcessFaults bool
NoProcessFaultDelay bool
AssertAfterEachStep bool
AssertConvergence bool
IncludePersistentFaults bool
RecoverAtEnd bool
}
type ValidatorLifecycleModel ¶
type ValidatorLifecycleModel struct {
Behavior ValidatorSetBehavior
Nodes map[NodeID]*ModelNode
Order []NodeID
Height int64
Events []ModelEvent
}
func NewValidatorLifecycleModel ¶
func NewValidatorLifecycleModel(opts ValidatorModelOptions) *ValidatorLifecycleModel
func (*ValidatorLifecycleModel) Apply ¶
func (m *ValidatorLifecycleModel) Apply(step int, action ModelAction) error
func (*ValidatorLifecycleModel) HasOnlineQuorum ¶
func (m *ValidatorLifecycleModel) HasOnlineQuorum() bool
func (*ValidatorLifecycleModel) Power ¶
func (m *ValidatorLifecycleModel) Power() (totalPower, onlinePower int64)
func (*ValidatorLifecycleModel) RecentEvents ¶
func (m *ValidatorLifecycleModel) RecentEvents(limit int) []ModelEvent
type ValidatorModelOptions ¶
type ValidatorModelOptions struct {
NodeCount int
InitialActive int
Behavior ValidatorSetBehavior
NodePowers map[NodeID]int64
}
type ValidatorPowerBaseline ¶
type ValidatorPowerBaseline struct {
// contains filtered or unexported fields
}
type ValidatorSetBehavior ¶
type ValidatorSetBehavior int
const ( // ValidatorSetBehaviorCurrent models the intended behavior: deregistration // emits a Comet zero-power update only when the validator is active. ValidatorSetBehaviorCurrent ValidatorSetBehavior = iota // ValidatorSetBehaviorBuggyJailedDeregistration models the pre-fix class of // bug where deregistration emits a zero-power update even for a jailed row. ValidatorSetBehaviorBuggyJailedDeregistration // ValidatorSetBehaviorBuggyAnyDeregistrationUpdate models duplicate or // absent-validator removals emitting repeated zero-power updates. ValidatorSetBehaviorBuggyAnyDeregistrationUpdate // ValidatorSetBehaviorBuggyRegisterWithoutCometUpdate models app state // becoming active while the Comet validator set is not updated. ValidatorSetBehaviorBuggyRegisterWithoutCometUpdate // ValidatorSetBehaviorBuggyRegisterNoop models recovery code that accepts a // register action but leaves a removed validator out of the validator set. ValidatorSetBehaviorBuggyRegisterNoop // ValidatorSetBehaviorBuggyStartAbsentOnline models lifecycle code marking // an absent or jailed validator online. ValidatorSetBehaviorBuggyStartAbsentOnline // ValidatorSetBehaviorBuggyTickWithoutQuorum models height advancement when // the active online validator power does not have consensus quorum. ValidatorSetBehaviorBuggyTickWithoutQuorum // ValidatorSetBehaviorBuggyStallWithQuorum models a halt despite enough // online active validator power to make progress. ValidatorSetBehaviorBuggyStallWithQuorum )
type VersionSkewMode ¶
type VersionSkewMode int
const ( VersionSkewModeHaltLegacyOnJailedDeregister VersionSkewMode = iota VersionSkewModeForkLegacyOnJailedDeregister VersionSkewModeHaltLegacyOnDuplicateDeregister VersionSkewModeForkLegacyOnDuplicateDeregister VersionSkewModeHaltLegacyOnDuplicateJail VersionSkewModeForkLegacyOnDuplicateJail VersionSkewModeHaltLegacyOnEndpointLie VersionSkewModeForkLegacyOnEndpointLie VersionSkewModeHaltLegacyOnEndpointRepair VersionSkewModeForkLegacyOnEndpointRepair VersionSkewModeKeepBadEndpointOnRepair VersionSkewModeHaltLegacyOnEndpointNoopRepair VersionSkewModeForkLegacyOnEndpointNoopRepair VersionSkewModeReactivateJailedOnInactiveEndpoint VersionSkewModeReactivateAbsentOnInactiveEndpoint VersionSkewModeHaltLegacyOnInactiveEndpoint VersionSkewModeForkLegacyOnInactiveEndpoint VersionSkewModeKeepBadEndpointOnJailedRepair VersionSkewModeHaltLegacyOnRegister VersionSkewModeForkLegacyOnRegister VersionSkewModeKeepBadEndpointOnRegister VersionSkewModeBadEndpointOnRegister VersionSkewModeHaltLegacyOnActiveRegister VersionSkewModeForkLegacyOnActiveRegister VersionSkewModeNoopOnJailedRegister VersionSkewModeHaltLegacyOnJailedRegister VersionSkewModeForkLegacyOnJailedRegister VersionSkewModeNoopOnUnjail VersionSkewModeBadEndpointOnUnjail VersionSkewModeHaltLegacyOnUnjail VersionSkewModeForkLegacyOnUnjail VersionSkewModeHaltLegacyOnActiveUnjail VersionSkewModeForkLegacyOnActiveUnjail VersionSkewModeReactivateAbsentOnUnjail VersionSkewModeHaltLegacyOnAbsentUnjail VersionSkewModeForkLegacyOnAbsentUnjail VersionSkewModeNoopOnStart VersionSkewModeBadEndpointOnStart VersionSkewModeHaltLegacyOnStart VersionSkewModeForkLegacyOnStart VersionSkewModeReactivateJailedOnStart VersionSkewModeReactivateAbsentOnStart VersionSkewModeHaltLegacyOnInactiveStart VersionSkewModeForkLegacyOnInactiveStart )
type VersionSkewNetwork ¶
type VersionSkewNetwork struct {
// contains filtered or unexported fields
}
func NewVersionSkewNetwork ¶
func NewVersionSkewNetwork(opts VersionSkewNetworkOptions) (*VersionSkewNetwork, error)
func (*VersionSkewNetwork) DeregisterNode ¶
func (n *VersionSkewNetwork) DeregisterNode(ctx context.Context, node NodeSpec) error
func (*VersionSkewNetwork) JailNode ¶
func (n *VersionSkewNetwork) JailNode(ctx context.Context, node NodeSpec) error
func (*VersionSkewNetwork) RegisterNode ¶
func (n *VersionSkewNetwork) RegisterNode(ctx context.Context, node NodeSpec) error
func (*VersionSkewNetwork) RestartNode ¶
func (n *VersionSkewNetwork) RestartNode(ctx context.Context, id NodeID) error
func (*VersionSkewNetwork) SetNodeEndpoint ¶
func (*VersionSkewNetwork) Snapshot ¶
func (n *VersionSkewNetwork) Snapshot(ctx context.Context) (Snapshot, error)
func (*VersionSkewNetwork) Spec ¶
func (n *VersionSkewNetwork) Spec() NetworkSpec
func (*VersionSkewNetwork) StartNode ¶
func (n *VersionSkewNetwork) StartNode(ctx context.Context, id NodeID) error
func (*VersionSkewNetwork) StopNode ¶
func (n *VersionSkewNetwork) StopNode(ctx context.Context, id NodeID) error
func (*VersionSkewNetwork) UnjailNode ¶
func (n *VersionSkewNetwork) UnjailNode(ctx context.Context, node NodeSpec) error