types

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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 136

BlockSize is the size in bytes required for leaf data.

Variables

This section is empty.

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	// StateMatrix is the packed state matrix preimage of the StateCommitment in Prestate
	StateMatrix StateSnapshot

	// Prestate is the valid leaf immediately prior to the first invalid leaf
	Prestate      Leaf
	PrestateProof merkle.Proof

	// Poststate is the first invalid leaf in the preimage. The challenge claims that this leaf is invalid.
	Poststate      Leaf
	PoststateProof merkle.Proof
}

type InputData

type InputData struct {
	// Input is the preimage data.
	// When Finalize is false, len(Input) must equal len(Commitments)*BlockSize
	// When Finalize is true, len(Input) must be between len(Commitments - 1)*BlockSize and len(Commitments)*BlockSize
	Input []byte
	// Commitments are the keccak commitments for each leaf in the chunk.
	Commitments []common.Hash
	// Finalize indicates whether the chunk is the final chunk.
	Finalize bool
}

InputData is a contiguous segment of preimage data.

type LargePreimageIdent

type LargePreimageIdent struct {
	Claimant common.Address
	UUID     *big.Int
}

type LargePreimageMetaData

type LargePreimageMetaData struct {
	LargePreimageIdent

	// Timestamp is the time at which the proposal first became fully available.
	// 0 when not all data is available yet
	Timestamp       uint64
	PartOffset      uint32
	ClaimedSize     uint32
	BlocksProcessed uint32
	BytesProcessed  uint32
	Countered       bool
}

func (LargePreimageMetaData) ShouldVerify

func (m LargePreimageMetaData) ShouldVerify(now time.Time, ignoreAfter time.Duration) bool

ShouldVerify returns true if the preimage upload is complete, has not yet been countered, and the challenge period has not yet elapsed.

type LargePreimageOracle

type LargePreimageOracle interface {
	Addr() common.Address
	GetActivePreimages(ctx context.Context, blockHash common.Hash) ([]LargePreimageMetaData, error)
	GetInputDataBlocks(ctx context.Context, block rpcblock.Block, ident LargePreimageIdent) ([]uint64, error)
	GetProposalTreeRoot(ctx context.Context, block rpcblock.Block, ident LargePreimageIdent) (common.Hash, error)
	DecodeInputData(data []byte) (*big.Int, InputData, error)
	ChallengeTx(ident LargePreimageIdent, challenge Challenge) (txmgr.TxCandidate, error)
	ChallengePeriod(ctx context.Context) (uint64, error)
}

type Leaf

type Leaf struct {
	// Input is the data absorbed for the block, exactly 136 bytes
	Input [BlockSize]byte
	// Index of the block in the absorption process
	Index uint64
	// StateCommitment is the hash of the internal state after absorbing the input.
	StateCommitment common.Hash
}

Leaf is the keccak state matrix added to the large preimage merkle tree.

func (Leaf) Hash

func (l Leaf) Hash() common.Hash

Hash returns the hash of the leaf data. That is the bytewise concatenation of the input, index, and state commitment.

type StateSnapshot

type StateSnapshot [25]uint64

func (StateSnapshot) Pack

func (s StateSnapshot) Pack() []byte

Pack packs the state in to the solidity ABI encoding required for the state matrix

Jump to

Keyboard shortcuts

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