walker

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package walker drives both sszutils.HashWalker implementations over the same generated call sequence and compares what they build. hasher.Hasher carries one byte buffer and cuts chunks when a region is reduced; treeproof.Wrapper builds the tree. They must agree for any sequence, including one a delegate leaves on a partial chunk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(prog []Op) error

compareWalkers runs one program through both walkers twice: once comparing the tail after every call, which forces the hasher to flush its deferred reductions, and once without, which leaves the deferral path as callers see it. Both runs must agree on the root, and a panic must happen in both or in neither.

func Run

func Run(hh sszutils.HashWalker, prog []Op, check func(int)) (root [32]byte, err error)

runProgram drives one walker. It keeps that walker's own scope indices, since the two walkers number their scopes in their own way, and every reduction closes the innermost scope the program opened. When check is non-nil it runs after every op with that op's index.

func String

func String(prog []Op) string

Types

type Op

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

walkerOp is one call. n carries a length, a count or a value, and treeType the shape of a scope.

func CloseScopes

func CloseScopes(open []sszutils.TreeType) []Op

closeScopes returns the reductions that close the given open scopes, innermost first, so a prefix of a program can be finished and compared.

func Generate

func Generate(rng *rand.Rand) []Op

generateProgram builds one program: an outer scope, a body of random calls with a shadow scope stack so reductions mostly close a scope that is open, then the closing reductions. The body deliberately includes the sequences a delegate that breaks its contract produces: raw appends that leave a partial chunk before a scope opens or a value is written.

func GenerateWithScopes

func GenerateWithScopes(rng *rand.Rand) ([]Op, [][]sszutils.TreeType)

generateProgramWithScopes also reports, for every prefix of the program, the scopes still open after it, so a prefix can be closed and compared on its own.

func (Op) String

func (o Op) String() string

Jump to

Keyboard shortcuts

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