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

Commit

Permalink
feat: update sendTxWithBackoff
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jul 23, 2023
1 parent 9d47e92 commit f045d82
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions prover/proof_producer/proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ProofRequestOptions struct {
BlockHash common.Hash
ParentHash common.Hash
SignalRoot common.Hash
EventL1Hash common.Hash
Graffiti string
GasUsed uint64
ParentGasUsed uint64
Expand Down
12 changes: 6 additions & 6 deletions prover/proof_submitter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func sendTxWithBackoff(
ctx context.Context,
cli *rpc.Client,
blockID *big.Int,
eventL1Hash common.Hash,
proposedAt uint64,
meta *bindings.TaikoDataBlockMetadata,
sendTxFunc func() (*types.Transaction, error),
Expand All @@ -81,23 +82,22 @@ func sendTxWithBackoff(
}

// Check if the corresponding L1 block is still in the canonical chain.
l1Header, err := cli.L1.HeaderByNumber(ctx, new(big.Int).SetUint64(meta.L1Height))
l1Header, err := cli.L1.HeaderByNumber(ctx, new(big.Int).SetUint64(meta.L1Height+1))
if err != nil {
log.Warn(
"Failed to fetch L1 block",
"blockID", blockID,
"l1Height", meta.L1Height,
"l1Hash", common.BytesToHash(meta.L1Hash[:]),
"l1Height", meta.L1Height+1,
"error", err,
)
return err
}
if l1Header.Hash() != meta.L1Hash {
if l1Header.Hash() != eventL1Hash {
log.Warn(
"Reorg detected, skip the current proof submission",
"blockID", blockID,
"l1Height", meta.L1Height,
"l1HashOld", common.BytesToHash(meta.L1Hash[:]),
"l1Height", meta.L1Height+1,
"l1HashOld", eventL1Hash,
"l1HashNew", l1Header.Hash(),
)
return nil
Expand Down
2 changes: 2 additions & 0 deletions prover/proof_submitter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (s *ProofSubmitterTestSuite) TestSendTxWithBackoff() {
context.Background(),
s.RpcClient,
common.Big1,
common.Hash{},
0,
meta,
func() (*types.Transaction, error) { return nil, errors.New("L1_TEST") },
Expand All @@ -46,6 +47,7 @@ func (s *ProofSubmitterTestSuite) TestSendTxWithBackoff() {
context.Background(),
s.RpcClient,
common.Big1,
common.Hash{},
0,
meta,
func() (*types.Transaction, error) {
Expand Down
2 changes: 2 additions & 0 deletions prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings.
BlockHash: block.Hash(),
ParentHash: block.ParentHash(),
SignalRoot: signalRoot,
EventL1Hash: event.Raw.BlockHash,
Graffiti: common.Bytes2Hex(s.graffiti[:]),
GasUsed: block.GasUsed(),
ParentGasUsed: parent.GasUsed(),
Expand Down Expand Up @@ -255,6 +256,7 @@ func (s *ValidProofSubmitter) SubmitProof(
ctx,
s.rpc,
blockID,
proofWithHeader.Opts.EventL1Hash,
block.Header().Time,
proofWithHeader.Meta,
sendTx,
Expand Down

0 comments on commit f045d82

Please sign in to comment.