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: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIs

func APIs(backend Backend) []rpc.API

APIs return the collection of RPC services the tracer package offers.

func GenerateProof

func GenerateProof(ctx context.Context, backend Backend, startState *ExecutionState, config *ProverConfig) (*proof.OneStepProof, error)

GenerateProof serves as an entrypoint for one-step proof generation. There are 6 types of one-step proofs:

  1. BlockState -> InterState: block initiation
  2. InterState -> IntraState: transaction initiation (contract call or creation)
  3. InterState -> InterState: EOA transfer transaction
  4. IntraState -> IntraState: one-step EVM execution (require tracing)
  5. IntraState -> InterState: transaction finalization (require tracing)
  6. InterState -> BlockState: block finalization

Types

type Backend

type Backend interface {
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
	HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
	BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
	BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
	GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
	GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
	RPCGasCap() *big.Int
	ChainConfig() *params.ChainConfig
	Engine() consensus.Engine
	ChainDb() ethdb.Database
	// StateAtBlock returns the state corresponding to the stateroot of the block.
	// N.B: For executing transactions on block N, the required stateRoot is block N-1,
	// so this method should be called with the parent.
	StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, checkLive, preferDisk bool) (*state.StateDB, error)
	StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (core.Message, vm.Context, *state.StateDB, error)
}

Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type ExecutionState

type ExecutionState struct {
	VMHash         common.Hash
	BlockGasUsed   *big.Int
	StateType      proofState.StateType
	Block          *types.Block
	TransactionIdx uint64
	StepIdx        uint64
}

func GenerateStates

func GenerateStates(backend Backend, ctx context.Context, startNum, endNum uint64, config *ProverConfig) ([]*ExecutionState, error)

GenerateStates generates execution states across blocks [startNum, endNum)

For example there are 2 blocks: block A with transactions A1, A2; block B without transactions.

The states are (in order):

  1. the BlockState of the block right before A
  2. the InterState before A1
  3. the IntraStates of A1 if A1 is not an EOA transfer
  4. the InterState before A2 (after A1)
  5. the IntraStates of A2 if A2 is not an EOA transfer
  6. the InterState after A2
  7. the BlockState of the block A
  8. a dummy InterState
  9. the BlockState of the block B

func (*ExecutionState) Hash

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

func (*ExecutionState) MarshalJson

func (s *ExecutionState) MarshalJson() ([]byte, error)

type ProverAPI

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

ProverAPI is the collection of Specular one-step proof APIs.

func NewAPI

func NewAPI(backend Backend) *ProverAPI

NewAPI creates a new API definition for the Specular one-step proof services.

func (*ProverAPI) GenerateProofForOpcode

func (api *ProverAPI) GenerateProofForOpcode(ctx context.Context, fraud bool, hash common.Hash, opcode int64, config *ProverConfig) (json.RawMessage, error)

func (*ProverAPI) GenerateProofForStep

func (api *ProverAPI) GenerateProofForStep(ctx context.Context, fraud bool, hash common.Hash, step int64, config *ProverConfig) (json.RawMessage, error)

func (*ProverAPI) GenerateStateHashes

func (api *ProverAPI) GenerateStateHashes(ctx context.Context, startNum, endNum uint64, config *ProverConfig) ([]common.Hash, error)

func (*ProverAPI) ProveBlocksForBenchmark

func (api *ProverAPI) ProveBlocksForBenchmark(ctx context.Context, startNum, endNum uint64, config *ProverConfig) ([]hexutil.Bytes, error)

func (*ProverAPI) ProveTransaction

func (api *ProverAPI) ProveTransaction(ctx context.Context, hash common.Hash, target common.Hash, config *ProverConfig) (hexutil.Bytes, error)

func (*ProverAPI) SetFraudProof

func (api *ProverAPI) SetFraudProof(ctx context.Context, fraud bool, step, opcode int64, config *ProverConfig) (json.RawMessage, error)

type ProverConfig

type ProverConfig struct {
	Reexec *uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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