prover

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStepIdxAndHashMismatch = errors.New("step index and hash mismatch")

Functions

This section is empty.

Types

type GeneratedIntraState

type GeneratedIntraState struct {
	VMHash common.Hash
	Gas    uint64
}

type IntraStateGenerator

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

func NewIntraStateGenerator

func NewIntraStateGenerator(
	blockNumber, transactionIdx uint64,
	committedGlobalState vm.StateDB,
	interState state.InterState,
	blockHashTree *state.BlockHashTree,
) *IntraStateGenerator

func (*IntraStateGenerator) CaptureEnd

func (l *IntraStateGenerator) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error

func (*IntraStateGenerator) CaptureEnter

func (l *IntraStateGenerator) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

func (*IntraStateGenerator) CaptureExit

func (l *IntraStateGenerator) CaptureExit(output []byte, gasUsed uint64, vmerr error)

func (*IntraStateGenerator) CaptureFault

func (l *IntraStateGenerator) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error

CaptureFault will be called when the stack/gas validation is passed but the execution failed. The current call will immediately be reverted. The error is handled in CaptureExit so nothing to do here.

func (*IntraStateGenerator) CaptureStart

func (l *IntraStateGenerator) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error

func (*IntraStateGenerator) CaptureState

func (l *IntraStateGenerator) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, rData []byte, depth int, vmerr error) error

CaptureState will be called before the opcode execution vmerr is for stack validation and gas validation the execution error is captured in CaptureFault

func (*IntraStateGenerator) CaptureTxEnd

func (l *IntraStateGenerator) CaptureTxEnd(restGas uint64)

func (*IntraStateGenerator) CaptureTxStart

func (l *IntraStateGenerator) CaptureTxStart(gasLimit uint64)

func (*IntraStateGenerator) GetGeneratedStates

func (l *IntraStateGenerator) GetGeneratedStates() ([]GeneratedIntraState, error)

type OneStepProver

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

func NewProver

func NewProver(
	target common.Hash,
	step uint64,
	rules params.Rules,
	blockNumber uint64,
	transactionIdx uint64,
	committedGlobalState vm.StateDB,
	interState state.InterState,
	blockHashTree *state.BlockHashTree,
	transaction *types.Transaction,
	receipt *types.Receipt,
) *OneStepProver

NewProver creates a new tracer that generates proofs for:

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

target is the hash of the start state that we want to prove step is the step number of the start state (step 0 is the InterState before the transaction) The target hash and step should be matched, otherwise ErrStepIdxAndHashMismatch will be returned receipt is the receipt of the *current* transaction traced

func (*OneStepProver) CaptureEnd

func (l *OneStepProver) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error

func (*OneStepProver) CaptureEnter

func (l *OneStepProver) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

func (*OneStepProver) CaptureExit

func (l *OneStepProver) CaptureExit(output []byte, gasUsed uint64, vmerr error)

func (*OneStepProver) CaptureFault

func (l *OneStepProver) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, vmerr error) error

CaptureFault will be called when the stack/gas validation is passed but the execution failed. The current call will immediately be reverted.

func (*OneStepProver) CaptureStart

func (l *OneStepProver) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error

func (*OneStepProver) CaptureState

func (l *OneStepProver) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, rData []byte, depth int, vmerr error) error

CaptureState will be called before the opcode execution vmerr is for stack validation and gas validation the execution error is captured in CaptureFault

func (*OneStepProver) CaptureTxEnd

func (l *OneStepProver) CaptureTxEnd(restGas uint64)

func (*OneStepProver) CaptureTxStart

func (l *OneStepProver) CaptureTxStart(gasLimit uint64)

func (*OneStepProver) GetProof

func (l *OneStepProver) GetProof() (*proof.OneStepProof, error)

type OspTestGeneratedCtx

type OspTestGeneratedCtx struct {
	TxnHash     string `json:"txnHash"`
	TxNonce     string `json:"txNonce"`
	TxV         string `json:"txV"`
	TxR         string `json:"txR"`
	TxS         string `json:"txS"`
	Coinbase    string `json:"coinbase"`
	Timestamp   string `json:"timestamp"`
	BlockNumber string `json:"blockNumber"`
	Difficulty  string `json:"difficulty"`
	GasLimit    string `json:"gasLimit"`
	ChainID     string `json:"chainID"`
	BaseFee     string `json:"baseFee"`
	Origin      string `json:"origin"`
	Recipient   string `json:"recipient"`
	Value       string `json:"value"`
	Gas         string `json:"gas"`
	GasPrice    string `json:"gasPrice"`
	Input       string `json:"input"`
	InputSize   string `json:"inputSize"`
}

type OspTestProof

type OspTestProof struct {
	Opcode    string `json:"opcode"`
	Verifier  uint64 `json:"verifier"`
	CurrHash  string `json:"currHash"`
	NextHash  string `json:"nextHash"`
	ProofSize string `json:"proofSize"`
	CodeSize  string `json:"codeSize"`
	Proof     string `json:"proof"`
	Idx       uint64 `json:"idx"`
}

type OspTestResult

type OspTestResult struct {
	Ctx   OspTestGeneratedCtx `json:"ctx"`
	Proof OspTestProof        `json:"proof"`
}

type TestProver

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

func NewTestProver

func NewTestProver(
	step int64,
	opcode int64,
	transaction *types.Transaction,
	txctx *vm.Context,
	receipt *types.Receipt,
	rules params.Rules,
	blockNumber uint64,
	transactionIdx uint64,
	committedGlobalState vm.StateDB,
	interState state.InterState,
	blockHashTree *state.BlockHashTree,
) *TestProver

func (*TestProver) CaptureEnd

func (l *TestProver) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, vmerr error) error

func (*TestProver) CaptureEnter

func (l *TestProver) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

func (*TestProver) CaptureExit

func (l *TestProver) CaptureExit(output []byte, gasUsed uint64, vmerr error)

func (*TestProver) CaptureFault

func (l *TestProver) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, vmerr error) error

func (*TestProver) CaptureStart

func (l *TestProver) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error

func (*TestProver) CaptureState

func (l *TestProver) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, rData []byte, depth int, vmerr error) error

func (*TestProver) CaptureTxEnd

func (l *TestProver) CaptureTxEnd(restGas uint64)

func (*TestProver) CaptureTxStart

func (l *TestProver) CaptureTxStart(gasLimit uint64)

func (*TestProver) GetResult

func (l *TestProver) GetResult() (json.RawMessage, error)

Jump to

Keyboard shortcuts

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