utils

package
v0.0.0-...-011bec4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnapsDir     = "snapshots"
	PreimagesDir = "preimages"
	FinalState   = "final.json.gz"
)
View Source
const (
	ProofsDir = "proofs"
)

Variables

View Source
var (
	ErrInvalidScalarValue     = errors.New("invalid scalar value")
	ErrInvalidBlobKeyPreimage = errors.New("invalid blob key preimage")
)

Functions

func FindStartingSnapshot

func FindStartingSnapshot(logger log.Logger, snapDir string, absolutePreState string, traceIndex uint64) (string, error)

FindStartingSnapshot finds the closest snapshot before the specified traceIndex in snapDir. If no suitable snapshot can be found it returns absolutePreState.

func PreimageDir

func PreimageDir(dir string) string

func ReadLastStep

func ReadLastStep(dir string) (uint64, error)

ReadLastStep reads the tracked last step from disk.

func RunCmd

func RunCmd(ctx context.Context, l log.Logger, binary string, args ...string) error

func WriteLastStep

func WriteLastStep(dir string, proof *ProofData, step uint64) error

WriteLastStep writes the last step and proof to disk as a persistent cache.

Types

type CmdExecutor

type CmdExecutor func(ctx context.Context, l log.Logger, binary string, args ...string) error

type GameInputsSource

type GameInputsSource interface {
	L1HeadSource
	GetProposals(ctx context.Context) (agreed contracts.Proposal, disputed contracts.Proposal, err error)
}

type L1HeadSource

type L1HeadSource interface {
	GetL1Head(ctx context.Context) (common.Hash, error)
}

type L2HeaderSource

type L2HeaderSource interface {
	HeaderByNumber(context.Context, *big.Int) (*ethtypes.Header, error)
}

type LocalGameInputs

type LocalGameInputs struct {
	L1Head        common.Hash
	L2Head        common.Hash
	L2OutputRoot  common.Hash
	L2Claim       common.Hash
	L2BlockNumber *big.Int
}

func FetchLocalInputs

func FetchLocalInputs(ctx context.Context, caller GameInputsSource, l2Client L2HeaderSource) (LocalGameInputs, error)

func FetchLocalInputsFromProposals

func FetchLocalInputsFromProposals(ctx context.Context, l1Head common.Hash, l2Client L2HeaderSource, agreedOutput contracts.Proposal, claimedOutput contracts.Proposal) (LocalGameInputs, error)

type PreimageLoader

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

func NewPreimageLoader

func NewPreimageLoader(getPreimage preimageSource) *PreimageLoader

func (*PreimageLoader) LoadPreimage

func (l *PreimageLoader) LoadPreimage(proof *ProofData) (*types.PreimageOracleData, error)

type PreimageOpt

type PreimageOpt func() preimageOpts

func FirstKeccakPreimageLoad

func FirstKeccakPreimageLoad() PreimageOpt

func FirstPrecompilePreimageLoad

func FirstPrecompilePreimageLoad() PreimageOpt

func FirstPreimageLoadOfType

func FirstPreimageLoadOfType(preimageType string) PreimageOpt

func PreimageLargerThan

func PreimageLargerThan(size int) PreimageOpt

func PreimageLoad

func PreimageLoad(key preimage.Key, offset uint32) PreimageOpt

type ProofData

type ProofData struct {
	ClaimValue   common.Hash   `json:"post"`
	StateData    hexutil.Bytes `json:"state-data"`
	ProofData    hexutil.Bytes `json:"proof-data"`
	OracleKey    hexutil.Bytes `json:"oracle-key,omitempty"`
	OracleValue  hexutil.Bytes `json:"oracle-value,omitempty"`
	OracleOffset uint32        `json:"oracle-offset,omitempty"`
}

type ProofGenerator

type ProofGenerator interface {
	// GenerateProof executes FPVM binary to generate a proof at the specified trace index in dataDir.
	GenerateProof(ctx context.Context, dataDir string, proofAt uint64) error
}

type SnapshotSelect

type SnapshotSelect func(logger log.Logger, dir string, absolutePreState string, i uint64) (string, error)

Jump to

Keyboard shortcuts

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