producer

package
v0.0.0-...-1d04f91 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CircuitsDegree10Txs = 19
	CircuitsDegree80Txs = 21

	CircuitsIdx10Txs = 0
	CircuitsIdx80Txs = 1
)

Variables

This section is empty.

Functions

func DegreeToCircuitsIdx

func DegreeToCircuitsIdx(degree uint64) (uint16, error)

Types

type DummyProofProducer

type DummyProofProducer struct {
	RandomDummyProofDelayLowerBound *time.Duration
	RandomDummyProofDelayUpperBound *time.Duration
}

DummyProofProducer always returns a dummy proof.

func (*DummyProofProducer) Cancel

func (d *DummyProofProducer) Cancel(ctx context.Context, blockID *big.Int) error

Cancel cancels an existing proof generation.

func (*DummyProofProducer) RequestProof

func (d *DummyProofProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta *bindings.MxcDataBlockMetadata,
	header *types.Header,
	resultCh chan *ProofWithHeader,
) error

RequestProof implements the ProofProducer interface.

type ProofProducer

type ProofProducer interface {
	RequestProof(
		ctx context.Context,
		opts *ProofRequestOptions,
		blockID *big.Int,
		meta *bindings.MxcDataBlockMetadata,
		header *types.Header,
		resultCh chan *ProofWithHeader,
	) error
	Cancel(ctx context.Context, blockID *big.Int) error
}

type ProofRequestOptions

type ProofRequestOptions struct {
	Height             *big.Int // the block number
	ProverAddress      common.Address
	ProposeBlockTxHash common.Hash
	L1SignalService    common.Address
	L2SignalService    common.Address
	MxcL2              common.Address
	MetaHash           common.Hash
	BlockHash          common.Hash
	ParentHash         common.Hash
	SignalRoot         common.Hash
	Graffiti           string
	GasUsed            uint64
	ParentGasUsed      uint64
}

ProofRequestOptions contains all options that need to be passed to zkEVM rpcd service.

type ProofWithHeader

type ProofWithHeader struct {
	BlockID *big.Int
	Meta    *bindings.MxcDataBlockMetadata
	Header  *types.Header
	ZkProof []byte
	Degree  uint64
	Opts    *ProofRequestOptions
}

type ProverCmdOutput

type ProverCmdOutput struct {
	Instances []string `json:"instances"`
	Proof     []byte   `json:"proof"`
}

type RequestProofBody

type RequestProofBody struct {
	JsonRPC string                   `json:"jsonrpc"`
	ID      *big.Int                 `json:"id"`
	Method  string                   `json:"method"`
	Params  []*RequestProofBodyParam `json:"params"`
}

RequestProofBody represents the JSON body for requesting the proof.

type RequestProofBodyParam

type RequestProofBodyParam struct {
	Circuit                 string   `json:"circuit"`
	Block                   *big.Int `json:"block"`
	L2RPC                   string   `json:"l2_rpc"`
	Retry                   bool     `json:"retry"`
	Param                   string   `json:"param"`
	VerifyProof             bool     `json:"verify_proof"`
	Mock                    bool     `json:"mock"`
	Aggregate               bool     `json:"aggregate"`
	Prover                  string   `json:"prover"`
	L1SignalService         string   `json:"l1_signal_service"`
	L2SignalService         string   `json:"l2_signal_service"`
	MxcL2                   string   `json:"l2_contract"`
	MetaHash                string   `json:"meta_hash"`
	BlockHash               string   `json:"block_hash"`
	ParentHash              string   `json:"parent_hash"`
	SignalRoot              string   `json:"signal_root"`
	Graffiti                string   `json:"graffiti"`
	GasUsed                 uint64   `json:"gas_used"`
	ParentGasUsed           uint64   `json:"parent_gas_used"`
	BlockMaxGasLimit        uint64   `json:"block_max_gas_limit"`
	MaxTransactionsPerBlock uint64   `json:"max_transactions_per_block"`
	MaxBytesPerTxList       uint64   `json:"max_bytes_per_tx_list"`
}

RequestProofBody represents the JSON body of RequestProofBody's `param` field.

type RequestProofBodyResponse

type RequestProofBodyResponse struct {
	JsonRPC string      `json:"jsonrpc"`
	ID      *big.Int    `json:"id"`
	Result  *RpcdOutput `json:"result"`
	Error   *struct {
		Code    *big.Int `json:"code"`
		Message string   `json:"message"`
	} `json:"error,omitempty"`
}

RequestProofBodyResponse represents the JSON body of the response of the proof requests.

type RpcdOutput

type RpcdOutput struct {
	Circuit struct {
		Instances []string `json:"instance"`
		Proof     string   `json:"proof"`
		Degree    uint64   `json:"k"`
	} `json:"circuit"`
}

RpcdOutput represents the JSON body of RequestProofBodyResponse's `result` field.

type SpecialProofProducer

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

SpecialProofProducer is responsible for generating a fake "zkproof" consisting of a signature of the evidence.

func NewSpecialProofProducer

func NewSpecialProofProducer(
	rpcClient *rpc.Client,
	proverPrivKey *ecdsa.PrivateKey,
	mxcL2Address common.Address,
	protocolSpecialProverAddress common.Address,
	graffiti string,
	isSystemProver bool,
) (*SpecialProofProducer, error)

NewSpecialProofProducer creates a new NewSpecialProofProducer instance, which can be either an oracle proof producer, or a system proofproducer.

func (*SpecialProofProducer) Cancel

func (d *SpecialProofProducer) Cancel(ctx context.Context, blockID *big.Int) error

Cancel cancels an existing proof generation. Since oracle and system proofs are not "real" proofs, there is nothing to cancel.

func (*SpecialProofProducer) RequestProof

func (p *SpecialProofProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta *bindings.MxcDataBlockMetadata,
	header *types.Header,
	resultCh chan *ProofWithHeader,
) error

RequestProof implements the ProofProducer interface.

type ZkevmCmdProducer

type ZkevmCmdProducer struct {
	CmdPath    string
	L2Endpoint string // a L2 execution engine's RPC endpoint
}

ZkevmCmdProducer is responsible for generating zk proofs from the given command line binary file.

func NewZkevmCmdProducer

func NewZkevmCmdProducer(
	cmdPath string,
	l2Endpoint string,
) (*ZkevmCmdProducer, error)

NewZkevmCmdProducer creates a new NewZkevmCmdProducer instance.

func (*ZkevmCmdProducer) Cancel

func (p *ZkevmCmdProducer) Cancel(ctx context.Context, blockID *big.Int) error

Cancel cancels an existing proof generation. Right now, it is just a stub that does nothing, because it is not possible to cnacel the proof with the current zkevm software.

func (*ZkevmCmdProducer) ExecProverCmd

func (p *ZkevmCmdProducer) ExecProverCmd(height *big.Int) ([]byte, error)

func (*ZkevmCmdProducer) RequestProof

func (p *ZkevmCmdProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta *bindings.MxcDataBlockMetadata,
	header *types.Header,
	resultCh chan *ProofWithHeader,
) error

RequestProof implements the ProofProducer interface.

type ZkevmRpcdProducer

type ZkevmRpcdProducer struct {
	RpcdEndpoint    string                         // a proverd RPC endpoint
	Param           string                         // parameter file to use
	L1Endpoint      string                         // a L1 node RPC endpoint
	L2Endpoint      string                         // a L2 execution engine's RPC endpoint
	Retry           bool                           // retry proof computation if error
	CustomProofHook func() ([]byte, uint64, error) // only for testing purposes
	ProofTimeTarget uint64                         // used for calculating proof delay
	ProtocolConfig  *bindings.MxcDataConfig        // protocol configurations
}

ZkevmRpcdProducer is responsible for requesting zk proofs from the given proverd endpoint.

func NewZkevmRpcdProducer

func NewZkevmRpcdProducer(
	rpcdEndpoint string,
	param string,
	l1Endpoint string,
	l2Endpoint string,
	retry bool,
	protocolConfig *bindings.MxcDataConfig,
) (*ZkevmRpcdProducer, error)

NewZkevmRpcdProducer creates a new `ZkevmRpcdProducer` instance.

func (*ZkevmRpcdProducer) Cancel

func (p *ZkevmRpcdProducer) Cancel(ctx context.Context, blockID *big.Int) error

Cancel cancels an existing proof generation. Right now, it is just a stub that does nothing, because it is not possible to cnacel the proof with the current zkevm software.

func (*ZkevmRpcdProducer) RequestProof

func (p *ZkevmRpcdProducer) RequestProof(
	ctx context.Context,
	opts *ProofRequestOptions,
	blockID *big.Int,
	meta *bindings.MxcDataBlockMetadata,
	header *types.Header,
	resultCh chan *ProofWithHeader,
) error

RequestProof implements the ProofProducer interface.

Jump to

Keyboard shortcuts

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