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 and davidtaikocha committed Aug 9, 2023
1 parent 97a3b0f commit 3825166
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 @@ -85,6 +85,11 @@ var (
Category: proverCategory,
Value: 100_000_000,
}
ProveBlockTxGasLimit = &cli.Uint64Flag{
Name: "prover.proveBlockTxGasLimit",
Usage: "Gas limit will be used for TaikoL1.proveBlock transactions",
Category: proverCategory,
}
)

// All prover flags.
Expand All @@ -105,4 +110,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
SystemProverPrivateKey,
Graffiti,
ExpectedReward,
ProveBlockTxGasLimit,
})
8 changes: 8 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Config struct {
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
RPCTimeout *time.Duration
ProveBlockGasLimit *uint64
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -125,6 +126,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 All @@ -149,5 +156,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
RPCTimeout: timeout,
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 @@ -26,21 +26,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
isSystemProver bool
graffiti [32]byte
expectedReward uint64
retryInterval 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
isSystemProver bool
graffiti [32]byte
expectedReward uint64
retryInterval time.Duration
proveBlockTxGasLimit *uint64
}

// NewValidProofSubmitter creates a new ValidProofSubmitter instance.
Expand All @@ -56,6 +57,7 @@ func NewValidProofSubmitter(
graffiti string,
expectedReward uint64,
retryInterval time.Duration,
proveBlockTxGasLimit *uint64,
) (*ValidProofSubmitter, error) {
anchorValidator, err := anchorTxValidator.New(taikoL2Address, rpcClient.L2ChainID, rpcClient)
if err != nil {
Expand All @@ -78,21 +80,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,
isSystemProver: isSystemProver,
graffiti: rpc.StringToBytes32(graffiti),
expectedReward: expectedReward,
retryInterval: retryInterval,
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,
isSystemProver: isSystemProver,
graffiti: rpc.StringToBytes32(graffiti),
expectedReward: expectedReward,
retryInterval: retryInterval,
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 @@ -50,6 +50,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
"test",
0,
12*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 @@ -210,6 +210,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.cfg.Graffiti,
p.cfg.ExpectedReward,
p.cfg.BackOffRetryInterval,
p.cfg.ProveBlockGasLimit,
); err != nil {
return err
}
Expand Down

0 comments on commit 3825166

Please sign in to comment.