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

Commit

Permalink
feat(prover): prove block tx gas limit (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Aug 9, 2023
1 parent ffe2f90 commit 8ed4da2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 30 deletions.
6 changes: 6 additions & 0 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ var (
Category: proverCategory,
Value: false,
}
ProveBlockTxGasLimit = &cli.Uint64Flag{
Name: "prover.proveBlockTxGasLimit",
Usage: "Gas limit will be used for TaikoL1.proveBlock transactions",
Category: proverCategory,
}
)

// All prover flags.
Expand All @@ -121,4 +126,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
TaikoProverPoolL1Address,
CheckProofWindowExpiredInterval,
ProveUnassignedBlocks,
ProveBlockTxGasLimit,
})
8 changes: 8 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Config struct {
ProveUnassignedBlocks bool
RPCTimeout *time.Duration
WaitReceiptTimeout time.Duration
ProveBlockGasLimit *uint64
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -109,6 +110,12 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
timeout = &duration
}

var proveBlockTxGasLimit *uint64
if c.IsSet(flags.ProveBlockTxGasLimit.Name) {
gasLimit := c.Uint64(flags.ProveBlockTxGasLimit.Name)
proveBlockTxGasLimit = &gasLimit
}

return &Config{
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
Expand Down Expand Up @@ -138,5 +145,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
RPCTimeout: timeout,
WaitReceiptTimeout: time.Duration(c.Uint64(flags.WaitReceiptTimeout.Name)) * time.Second,
ProveBlockGasLimit: proveBlockTxGasLimit,
}, nil
}
67 changes: 37 additions & 30 deletions prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,22 @@ var _ ProofSubmitter = (*ValidProofSubmitter)(nil)
// ValidProofSubmitter is responsible requesting zk proofs for the given valid L2
// blocks, and submitting the generated proofs to the TaikoL1 smart contract.
type ValidProofSubmitter struct {
rpc *rpc.Client
proofProducer proofProducer.ProofProducer
resultCh chan *proofProducer.ProofWithHeader
anchorTxValidator *anchorTxValidator.AnchorTxValidator
proverPrivKey *ecdsa.PrivateKey
proverAddress common.Address
taikoL2Address common.Address
l1SignalService common.Address
l2SignalService common.Address
mutex *sync.Mutex
isOracleProver bool
graffiti [32]byte
submissionMaxRetry uint64
retryInterval time.Duration
waitReceiptTimeout time.Duration
rpc *rpc.Client
proofProducer proofProducer.ProofProducer
resultCh chan *proofProducer.ProofWithHeader
anchorTxValidator *anchorTxValidator.AnchorTxValidator
proverPrivKey *ecdsa.PrivateKey
proverAddress common.Address
taikoL2Address common.Address
l1SignalService common.Address
l2SignalService common.Address
mutex *sync.Mutex
isOracleProver bool
graffiti [32]byte
submissionMaxRetry uint64
retryInterval time.Duration
waitReceiptTimeout time.Duration
proveBlockTxGasLimit *uint64
}

// NewValidProofSubmitter creates a new ValidProofSubmitter instance.
Expand All @@ -58,6 +59,7 @@ func NewValidProofSubmitter(
submissionMaxRetry uint64,
retryInterval time.Duration,
waitReceiptTimeout time.Duration,
proveBlockTxGasLimit *uint64,
) (*ValidProofSubmitter, error) {
anchorValidator, err := anchorTxValidator.New(taikoL2Address, rpcClient.L2ChainID, rpcClient)
if err != nil {
Expand All @@ -75,21 +77,22 @@ func NewValidProofSubmitter(
}

return &ValidProofSubmitter{
rpc: rpcClient,
proofProducer: proofProducer,
resultCh: resultCh,
anchorTxValidator: anchorValidator,
proverPrivKey: proverPrivKey,
proverAddress: crypto.PubkeyToAddress(proverPrivKey.PublicKey),
l1SignalService: l1SignalService,
l2SignalService: l2SignalService,
taikoL2Address: taikoL2Address,
mutex: mutex,
isOracleProver: isOracleProver,
graffiti: rpc.StringToBytes32(graffiti),
submissionMaxRetry: submissionMaxRetry,
retryInterval: retryInterval,
waitReceiptTimeout: waitReceiptTimeout,
rpc: rpcClient,
proofProducer: proofProducer,
resultCh: resultCh,
anchorTxValidator: anchorValidator,
proverPrivKey: proverPrivKey,
proverAddress: crypto.PubkeyToAddress(proverPrivKey.PublicKey),
l1SignalService: l1SignalService,
l2SignalService: l2SignalService,
taikoL2Address: taikoL2Address,
mutex: mutex,
isOracleProver: isOracleProver,
graffiti: rpc.StringToBytes32(graffiti),
submissionMaxRetry: submissionMaxRetry,
retryInterval: retryInterval,
waitReceiptTimeout: waitReceiptTimeout,
proveBlockTxGasLimit: proveBlockTxGasLimit,
}, nil
}

Expand Down Expand Up @@ -252,6 +255,10 @@ func (s *ValidProofSubmitter) SubmitProof(
return err
}

if s.proveBlockTxGasLimit != nil {
txOpts.GasLimit = *s.proveBlockTxGasLimit
}

sendTx := func() (*types.Transaction, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
Expand Down
1 change: 1 addition & 0 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
1,
12*time.Second,
10*time.Second,
nil,
)
s.Nil(err)

Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.cfg.ProofSubmissionMaxRetry,
p.cfg.BackOffRetryInterval,
p.cfg.WaitReceiptTimeout,
p.cfg.ProveBlockGasLimit,
); err != nil {
return err
}
Expand Down

0 comments on commit 8ed4da2

Please sign in to comment.