proof

package
v0.0.0-...-5cda5f8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStorageProof

func GetStorageProof(
	db vm.StateDB,
	address common.Address,
	key common.Hash,
) (*MPTProof, *MPTProof, error)

func IsStackError

func IsStackError(err error) bool

func IsStopTokenError

func IsStopTokenError(err error) bool

Types

type BlockHashMerkleProof

type BlockHashMerkleProof struct {
	MerklePath  uint64
	MerkleProof []common.Hash
}

func GetBlockHashMerkleProof

func GetBlockHashMerkleProof(tree *state.BlockHashTree, blockNum uint64) (*BlockHashMerkleProof, error)

func (*BlockHashMerkleProof) Encode

func (p *BlockHashMerkleProof) Encode() []byte

type BlockHashProof

type BlockHashProof struct {
	BlockHash common.Hash
}

func (*BlockHashProof) Encode

func (b *BlockHashProof) Encode() []byte

type BlockStateProof

type BlockStateProof struct {
	BlockNumber     uint64
	GlobalStateRoot common.Hash
	BlockHashRoot   common.Hash
}

func BlockStateProofFromBlockState

func BlockStateProofFromBlockState(s *state.BlockState) *BlockStateProof

func (*BlockStateProof) Encode

func (s *BlockStateProof) Encode() []byte

type CodeProof

type CodeProof struct {
	Content []byte
}

func (*CodeProof) Encode

func (c *CodeProof) Encode() []byte

type InterStateProof

type InterStateProof struct {
	BlockNumber         uint64
	TransactionIdx      uint64
	GlobalStateRoot     common.Hash
	BlockGasUsed        uint256.Int
	BlockHashRoot       common.Hash
	TransactionTireRoot common.Hash
	ReceiptTrieRoot     common.Hash
	LogsBloom           types.Bloom
}

func InterStateProofFromInterState

func InterStateProofFromInterState(s *state.InterState) *InterStateProof

func (*InterStateProof) Encode

func (s *InterStateProof) Encode() []byte

type IntraStateProof

type IntraStateProof struct {
	BlockNumber              uint64
	TransactionIdx           uint64
	Depth                    uint16
	Gas                      uint64
	Refund                   uint64
	LastDepthHash            common.Hash
	ContractAddress          common.Address
	Caller                   common.Address
	Value                    uint256.Int
	CallFlag                 state.CallFlag
	Out                      uint64
	OutSize                  uint64
	Pc                       uint64
	OpCode                   vm.OpCode
	CodeHash                 common.Hash
	StackHash                common.Hash
	StackSize                uint64
	MemorySize               uint64
	MemoryRoot               common.Hash
	InputDataSize            uint64
	InputDataRoot            common.Hash
	ReturnDataSize           uint64
	ReturnDataRoot           common.Hash
	CommittedGlobalStateRoot common.Hash
	GlobalStateRoot          common.Hash
	SelfDestructAcc          common.Hash
	LogAcc                   common.Hash
	BlockHashRoot            common.Hash
	AccesslistRoot           common.Hash
}

func StateProofFromState

func StateProofFromState(s *state.IntraState) *IntraStateProof

func (*IntraStateProof) Encode

func (s *IntraStateProof) Encode() []byte

func (*IntraStateProof) Hash

func (s *IntraStateProof) Hash() common.Hash

type LogProof

type LogProof struct {
	AccumulateHash common.Hash
	Bloom          types.Bloom
}

func LogProofFromLogSeries

func LogProofFromLogSeries(logSeries *state.LogSeries) *LogProof

func (*LogProof) Encode

func (p *LogProof) Encode() []byte

type MPTProof

type MPTProof struct {
	Proof [][]byte
}

func GetAccountProof

func GetAccountProof(
	db vm.StateDB,
	address common.Address,
) (*MPTProof, error)

func (*MPTProof) Encode

func (m *MPTProof) Encode() []byte

type MemoryAppendProof

type MemoryAppendProof struct {
	AppendCells []uint256.Int
	Proof       []common.Hash
}

func (*MemoryAppendProof) Encode

func (m *MemoryAppendProof) Encode() []byte

type MemoryCombinedReadProof

type MemoryCombinedReadProof struct {
	Cells       []uint256.Int
	AppendCells []uint256.Int
	Proof       []common.Hash
}

func (*MemoryCombinedReadProof) Encode

func (m *MemoryCombinedReadProof) Encode() []byte

type MemoryCombinedWriteProof

type MemoryCombinedWriteProof struct {
	Cells        []uint256.Int
	UpdatedCells []uint256.Int
	AppendCells  []uint256.Int
	Proof        []common.Hash
}

func (*MemoryCombinedWriteProof) Encode

func (m *MemoryCombinedWriteProof) Encode() []byte

type MemoryReadProof

type MemoryReadProof struct {
	Cells []uint256.Int
	Proof []common.Hash
}

func (*MemoryReadProof) Encode

func (m *MemoryReadProof) Encode() []byte

type MemoryWriteProof

type MemoryWriteProof struct {
	Cells        []uint256.Int
	UpdatedCells []uint256.Int
	Proof        []common.Hash
}

func (*MemoryWriteProof) Encode

func (m *MemoryWriteProof) Encode() []byte

type OneStepProof

type OneStepProof struct {
	VerifierType VerifierType
	Proofs       []Proof

	TotalCodeSize uint64 // for statistics
}

func EmptyProof

func EmptyProof() *OneStepProof

func GetBlockFinalizationProof

func GetBlockFinalizationProof(interState *state.InterState) (*OneStepProof, error)

Type 6 InterState -> BlockState: block finalization The verifier needs to first pack the block header and calculate the block hash; then, the verifier can simulate changing the block hash in the block hash tree using the plain Merkle tree proof.

func GetBlockInitiationProof

func GetBlockInitiationProof(blockState *state.BlockState) (*OneStepProof, error)

Type 1 BlockState -> InterState: block initiation A BlockStateProof suffices to prove this state transition.

The verifier can generate the first InterState by setting the transaction trie root and receipt trie root to the empty trie root, logs bloom to empty, and setting the block gas used to 0.

func GetIntraProof

func GetIntraProof(ctx ProofGenContext, currState, nextState *state.IntraState, vmerr error) (*OneStepProof, error)

Type 4 IntraState -> IntraState: one-step EVM execution Type 5 IntraState -> InterState: transaction finalization

func GetTransactionInitaitionProof

func GetTransactionInitaitionProof(
	chainConfig *params.ChainConfig,
	vmctx *vm.BlockContext,
	tx *types.Transaction,
	txctx *vm.Context,
	interState *state.InterState,
	statedb vm.StateDB,
) (*OneStepProof, error)

Type 2 InterState -> IntraState: transaction initiation Type 3 InterState -> InterState: EOA transfer transaction See go-ethereum/core/state_transition.go for the full state transition logic.

  1. Provide the inter state proof.
  2. Provide the MPT proof for the sender account. Verifier can perform nonce check and balance check through the MPT proof.
  3. Simulate the transaction initation including nonce increment, gas buying, and balance transfer. If error, stop. Note: sadly EVM does not expose methods for these so we have to implement them by ourselves.
  4. Provide the MPT proof for the recipient account, based on the simulated state. Verifier can construct the state trie root after transfer.
  5. If EOA transfer, also provde the MPT proof for both transaction trie, receipt trie, and account proof of coinbase so verifier can finalize the transaction.

func (*OneStepProof) AddProof

func (p *OneStepProof) AddProof(proof Proof)

func (*OneStepProof) Encode

func (p *OneStepProof) Encode() []byte

func (*OneStepProof) SetVerifierType

func (p *OneStepProof) SetVerifierType(ty VerifierType)

type Proof

type Proof interface {
	Encode() []byte
}

type ProofGenContext

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

func NewProofGenContext

func NewProofGenContext(rules params.Rules, coinbase common.Address, transaction *types.Transaction, receipt *types.Receipt, actualCode []byte) ProofGenContext

type ReceiptProof

type ReceiptProof struct {
	RLPEncodedReceipt []byte
}

func ReceiptProofFromReceipt

func ReceiptProofFromReceipt(r *types.Receipt) *ReceiptProof

func (*ReceiptProof) Encode

func (s *ReceiptProof) Encode() []byte

type SelfDestructSetProof

type SelfDestructSetProof struct {
	Contracts []common.Address
}

func SelfDestructSetProofFromSelfDestructSet

func SelfDestructSetProofFromSelfDestructSet(selfDestructSet *state.SelfDestructSet) *SelfDestructSetProof

func (*SelfDestructSetProof) Encode

func (p *SelfDestructSetProof) Encode() []byte

type StackProof

type StackProof struct {
	Pops               []uint256.Int
	StackHashAfterPops common.Hash
}

func (*StackProof) Encode

func (s *StackProof) Encode() []byte

type VerifierType

type VerifierType int
const (
	VerifierTypeStackOp         VerifierType = 0
	VerifierTypeEnvironmentalOp VerifierType = 1
	VerifierTypeMemoryOp        VerifierType = 2
	VerifierTypeStorageOp       VerifierType = 3
	VerifierTypeCallOp          VerifierType = 4
	VerifierTypeInvalidOp       VerifierType = 5
	VerifierTypeInterTx         VerifierType = 6
	VerifierTypeBlockInit       VerifierType = 7
	VerifierTypeBlockFinal      VerifierType = 8
)

Jump to

Keyboard shortcuts

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