Documentation
¶
Overview ¶
Package engine implements the core fuzzing logic for comparing SSZ reflection-based and codegen-based implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintStats ¶
PrintStats prints current fuzzing statistics to stdout.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the core fuzz testing engine. Each Engine instance owns a private RNG and Filler (not thread-safe), but shares DynSsz instances, Stats, and Reporter across workers.
func NewEngine ¶
func NewEngine(reporter *Reporter, stats *Stats, ds, dsExtended *dynssz.DynSsz, seed int64, maxDataLen int, dsUnknown ...*dynssz.DynSsz) *Engine
NewEngine creates a new fuzz engine with its own RNG but shared DynSsz instances. The DynSsz TypeCache is thread-safe (uses sync.RWMutex), so sharing avoids duplicating large type caches across workers.
func (*Engine) FuzzEntry ¶
FuzzEntry runs one fuzz iteration on a given type entry. It alternates between three modes:
- Valid fill: create a struct with random values, test all comparisons
- Mutated: valid data with random mutations
- Random bytes: purely random input data
func (*Engine) FuzzEntryWithData ¶
FuzzEntryWithData runs a fuzz iteration with specific data.
type Filler ¶
type Filler struct {
// contains filtered or unexported fields
}
Filler populates Go struct instances with random valid values using reflection. It reads SSZ struct tags to determine valid sizes for slices, bitlists, etc.
func (*Filler) Fill ¶
Fill populates the value v with random data appropriate to its type. v must be settable (typically obtained via reflect.ValueOf(&x).Elem()).
func (*Filler) FillStruct ¶
FillStruct fills a struct pointer with random values.
type Issue ¶
type Issue struct {
Type IssueType
TypeName string
Data []byte
Details string
ReflectionOutput []byte
CodegenOutput []byte
}
Issue represents a single fuzzing issue found.
type IssueType ¶
type IssueType string
IssueType classifies the kind of fuzzing issue found.
const ( IssuePanic IssueType = "panic" IssueMarshalMismatch IssueType = "marshal-mismatch" IssueSizeMismatch IssueType = "size-mismatch" IssueHTRMismatch IssueType = "htr-mismatch" IssueStreamMismatch IssueType = "stream-mismatch" IssueUnmarshalDiff IssueType = "unmarshal-diff" IssueReferenceMismatch IssueType = "reference-mismatch" IssueNonDeterministic IssueType = "nondeterministic" )
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter persists fuzzing issues to disk.
func NewReporter ¶
NewReporter creates a new issue reporter that writes to the given directory.
func (*Reporter) IssueCount ¶
IssueCount returns the number of unique issues reported.
type Stats ¶
type Stats struct {
Iterations atomic.Uint64
ValidFills atomic.Uint64
MutatedFills atomic.Uint64
RandomInputs atomic.Uint64
Panics atomic.Uint64
MarshalMismatches atomic.Uint64
SizeMismatches atomic.Uint64
HTRMismatches atomic.Uint64
StreamMismatches atomic.Uint64
UnmarshalDiffs atomic.Uint64
WalkerPrograms atomic.Uint64
WalkerMismatches atomic.Uint64
Successes atomic.Uint64
OracleChecks atomic.Uint64
ReferenceChecks atomic.Uint64
ReferenceSkips atomic.Uint64
}
Stats tracks fuzzing statistics.