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

Commit 2d00517

Browse files
feat(prover): parse contest submission custom errors (#624)
1 parent 9461b05 commit 2d00517

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

bindings/encoding/custom_error.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ import (
66
)
77

88
// TryParsingCustomError tries to checks whether the given error is one of the
9-
// custom errors defined the TaikoL1 / TaikoL2's ABI, if so, it will return
9+
// custom errors defined the protocol ABIs, if so, it will return
1010
// the matched custom error, otherwise, it simply returns the original error.
1111
func TryParsingCustomError(originalError error) error {
12+
if originalError == nil {
13+
return nil
14+
}
15+
1216
errData := getErrorData(originalError)
1317

1418
// if errData is unparsable and returns 0x, we should not match any errors.

prover/proof_submitter/proof_contester.go

+29-27
Original file line numberDiff line numberDiff line change
@@ -99,35 +99,37 @@ func (c *ProofContester) SubmitContest(
9999
return err
100100
}
101101

102-
return c.sender.Send(
103-
ctx,
104-
&proofProducer.ProofWithHeader{
105-
BlockID: blockID,
106-
Meta: meta,
107-
Header: header,
108-
Proof: []byte{},
109-
Opts: &proofProducer.ProofRequestOptions{
110-
EventL1Hash: l1HeaderProposedIn.Hash(),
111-
StateRoot: header.Root,
112-
},
113-
Tier: tier,
114-
},
115-
c.txBuilder.Build(
102+
return encoding.TryParsingCustomError(
103+
c.sender.Send(
116104
ctx,
117-
blockID,
118-
meta,
119-
&bindings.TaikoDataTransition{
120-
ParentHash: header.ParentHash,
121-
BlockHash: header.Hash(),
122-
StateRoot: header.Root,
123-
Graffiti: c.graffiti,
124-
},
125-
&bindings.TaikoDataTierProof{
126-
Tier: transition.Tier,
127-
Data: []byte{},
105+
&proofProducer.ProofWithHeader{
106+
BlockID: blockID,
107+
Meta: meta,
108+
Header: header,
109+
Proof: []byte{},
110+
Opts: &proofProducer.ProofRequestOptions{
111+
EventL1Hash: l1HeaderProposedIn.Hash(),
112+
StateRoot: header.Root,
113+
},
114+
Tier: tier,
128115
},
129-
c.sender.GetOpts(),
130-
false,
116+
c.txBuilder.Build(
117+
ctx,
118+
blockID,
119+
meta,
120+
&bindings.TaikoDataTransition{
121+
ParentHash: header.ParentHash,
122+
BlockHash: header.Hash(),
123+
StateRoot: header.Root,
124+
Graffiti: c.graffiti,
125+
},
126+
&bindings.TaikoDataTierProof{
127+
Tier: transition.Tier,
128+
Data: []byte{},
129+
},
130+
c.sender.GetOpts(),
131+
false,
132+
),
131133
),
132134
)
133135
}

prover/proof_submitter/proof_submitter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (s *ProofSubmitter) SubmitProof(
170170
}
171171

172172
// Build the TaikoL1.proveBlock transaction and send it to the L1 node.
173-
if err := s.sender.Send(
173+
if err := encoding.TryParsingCustomError(s.sender.Send(
174174
ctx,
175175
proofWithHeader,
176176
s.txBuilder.Build(
@@ -190,7 +190,7 @@ func (s *ProofSubmitter) SubmitProof(
190190
s.sender.GetOpts(),
191191
proofWithHeader.Tier == encoding.TierGuardianID,
192192
),
193-
); err != nil {
193+
)); err != nil {
194194
if err.Error() == transaction.ErrUnretryableSubmission.Error() {
195195
return nil
196196
}

0 commit comments

Comments
 (0)