stateless

package
v0.0.0-...-8588118 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeaderReader

type HeaderReader interface {
	// GetHeader retrieves a block header from the database by hash and number,
	GetHeader(hash common.Hash, number uint64) *types.Header
}

HeaderReader is an interface to pull in headers in place of block hashes for the witness.

type Witness

type Witness struct {
	Block   *types.Block        // Current block with rootHash and receiptHash zeroed out
	Headers []*types.Header     // Past headers in reverse order (0=parent, 1=parent's-parent, etc). First *must* be set.
	Codes   map[string]struct{} // Set of bytecodes ran or accessed
	State   map[string]struct{} // Set of MPT state trie nodes (account and storage together)
	// contains filtered or unexported fields
}

Witness encompasses a block, state and any other chain data required to apply a set of transactions and derive a post state/receipt root.

func NewWitness

func NewWitness(chain HeaderReader, block *types.Block) (*Witness, error)

NewWitness creates an empty witness ready for population.

func (*Witness) AddBlockHash

func (w *Witness) AddBlockHash(number uint64)

AddBlockHash adds a "blockhash" to the witness with the designated offset from chain head. Under the hood, this method actually pulls in enough headers from the chain to cover the block being added.

func (*Witness) AddCode

func (w *Witness) AddCode(code []byte)

AddCode adds a bytecode blob to the witness.

func (*Witness) AddState

func (w *Witness) AddState(nodes map[string]struct{})

AddState inserts a batch of MPT trie nodes into the witness.

func (*Witness) Copy

func (w *Witness) Copy() *Witness

Copy deep-copies the witness object. Witness.Block isn't deep-copied as it is never mutated by Witness

func (*Witness) DecodeRLP

func (w *Witness) DecodeRLP(s *rlp.Stream) error

DecodeRLP decodes a witness from RLP.

func (*Witness) EncodeRLP

func (w *Witness) EncodeRLP(wr io.Writer) error

EncodeRLP serializes a witness as RLP.

func (*Witness) MakeHashDB

func (w *Witness) MakeHashDB() ethdb.Database

MakeHashDB imports tries, codes and block hashes from a witness into a new hash-based memory db. We could eventually rewrite this into a pathdb, but simple is better for now.

func (*Witness) MarshalJSON

func (w *Witness) MarshalJSON() ([]byte, error)

MarshalJSON marshals a witness as JSON.

func (*Witness) Root

func (w *Witness) Root() common.Hash

Root returns the pre-state root from the first header.

Note, this method will panic in case of a bad witness (but RLP decoding will sanitize it and fail before that).

func (*Witness) String

func (w *Witness) String() string

String prints a human-readable summary containing the total size of the witness and the sizes of the underlying components

func (*Witness) UnmarshalJSON

func (w *Witness) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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