Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(proof_producer): update request parameters based on new circuits changes #240

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 47 additions & 38 deletions prover/proof_producer/zkevm_rpcd_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ZkevmRpcdProducer struct {
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.TaikoDataConfig // protocol configurations
}

// RequestProofBody represents the JSON body for requesting the proof.
Expand All @@ -43,25 +44,28 @@ type RequestProofBody struct {

// RequestProofBody represents the JSON body of RequestProofBody's `param` field.
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"`
TaikoL2 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"`
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"`
TaikoL2 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"`
}

// RequestProofBodyResponse represents the JSON body of the response of the proof requests.
Expand Down Expand Up @@ -92,6 +96,7 @@ func NewZkevmRpcdProducer(
l2Endpoint string,
retry bool,
proofTimeTarget uint64,
protocolConfig bindings.TaikoDataConfig,
) (*ZkevmRpcdProducer, error) {
return &ZkevmRpcdProducer{
RpcdEndpoint: rpcdEndpoint,
Expand All @@ -100,6 +105,7 @@ func NewZkevmRpcdProducer(
L2Endpoint: l2Endpoint,
Retry: retry,
ProofTimeTarget: proofTimeTarget,
ProtocolConfig: protocolConfig,
}, nil
}

Expand Down Expand Up @@ -200,25 +206,28 @@ func (p *ZkevmRpcdProducer) requestProof(opts *ProofRequestOptions) (*RpcdOutput
ID: common.Big1,
Method: "proof",
Params: []*RequestProofBodyParam{{
Circuit: "pi",
Block: opts.Height,
L2RPC: p.L2Endpoint,
Retry: true,
Param: p.Param,
VerifyProof: true,
Mock: false,
Aggregate: false,
Prover: opts.ProverAddress.Hex()[2:],
L1SignalService: opts.L1SignalService.Hex()[2:],
L2SignalService: opts.L2SignalService.Hex()[2:],
TaikoL2: opts.TaikoL2.Hex()[2:],
MetaHash: opts.MetaHash.Hex()[2:],
BlockHash: opts.BlockHash.Hex()[2:],
ParentHash: opts.ParentHash.Hex()[2:],
SignalRoot: opts.SignalRoot.Hex()[2:],
Graffiti: opts.Graffiti,
GasUsed: opts.GasUsed,
ParentGasUsed: opts.ParentGasUsed,
Circuit: "pi",
Block: opts.Height,
L2RPC: p.L2Endpoint,
Retry: true,
Param: p.Param,
VerifyProof: true,
Mock: false,
Aggregate: false,
Prover: opts.ProverAddress.Hex()[2:],
L1SignalService: opts.L1SignalService.Hex()[2:],
L2SignalService: opts.L2SignalService.Hex()[2:],
TaikoL2: opts.TaikoL2.Hex()[2:],
MetaHash: opts.MetaHash.Hex()[2:],
BlockHash: opts.BlockHash.Hex()[2:],
ParentHash: opts.ParentHash.Hex()[2:],
SignalRoot: opts.SignalRoot.Hex()[2:],
Graffiti: opts.Graffiti,
GasUsed: opts.GasUsed,
ParentGasUsed: opts.ParentGasUsed,
BlockMaxGasLimit: p.ProtocolConfig.BlockMaxGasLimit,
MaxTransactionsPerBlock: p.ProtocolConfig.MaxTransactionsPerBlock,
MaxBytesPerTxList: p.ProtocolConfig.MaxBytesPerTxList,
}},
}

Expand Down
10 changes: 9 additions & 1 deletion prover/proof_producer/zkevm_rpcd_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import (
)

func TestNewZkevmRpcdProducer(t *testing.T) {
dummyZkevmRpcdProducer, err := NewZkevmRpcdProducer("http://localhost:18545", "", "", "", false, 0)
dummyZkevmRpcdProducer, err := NewZkevmRpcdProducer(
"http://localhost:18545",
"",
"",
"",
false,
0,
bindings.TaikoDataConfig{},
)
require.Nil(t, err)

dummyZkevmRpcdProducer.CustomProofHook = func() ([]byte, uint64, error) {
Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
cfg.L2HttpEndpoint,
true,
stateVars.ProofTimeTarget,
protocolConfigs,
); err != nil {
return err
}
Expand Down