Skip to content

Commit

Permalink
Merge pull request #2121 from OffchainLabs/parse-abi-errors
Browse files Browse the repository at this point in the history
Pull in geth changes to parse ABI errors
  • Loading branch information
joshuacolvin0 committed Feb 5, 2024
2 parents 17468a8 + 17e4fd0 commit bba477f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go-ethereum
8 changes: 2 additions & 6 deletions precompiles/precompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,8 @@ func RenderSolError(solErr abi.Error, data []byte) (string, error) {
if err != nil {
return "", err
}
valsRange, ok := vals.([]interface{})
if !ok {
return "", errors.New("unexpected unpack result")
}
strVals := make([]string, 0, len(valsRange))
for _, val := range valsRange {
strVals := make([]string, 0, len(vals))
for _, val := range vals {
strVals = append(strVals, fmt.Sprintf("%v", val))
}
return fmt.Sprintf("error %v(%v)", solErr.Name, strings.Join(strVals, ", ")), nil
Expand Down
8 changes: 6 additions & 2 deletions system_tests/precompile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package arbtest

import (
"context"
"fmt"
"math/big"
"testing"

Expand Down Expand Up @@ -67,7 +68,9 @@ func TestCustomSolidityErrors(t *testing.T) {
Fatal(t, "customRevert call should have errored")
}
observedMessage := customError.Error()
expectedMessage := "execution reverted: error Custom(1024, This spider family wards off bugs: /\\oo/\\ //\\(oo)/\\ /\\oo/\\, true)"
expectedError := "Custom(1024, This spider family wards off bugs: /\\oo/\\ //\\(oo)/\\ /\\oo/\\, true)"
// The first error is server side. The second error is client side ABI decoding.
expectedMessage := fmt.Sprintf("execution reverted: error %v: %v", expectedError, expectedError)
if observedMessage != expectedMessage {
Fatal(t, observedMessage)
}
Expand All @@ -79,7 +82,8 @@ func TestCustomSolidityErrors(t *testing.T) {
Fatal(t, "out of range ArbBlockHash call should have errored")
}
observedMessage = customError.Error()
expectedMessage = "execution reverted: error InvalidBlockNumber(1000000000, 1)"
expectedError = "InvalidBlockNumber(1000000000, 1)"
expectedMessage = fmt.Sprintf("execution reverted: error %v: %v", expectedError, expectedError)
if observedMessage != expectedMessage {
Fatal(t, observedMessage)
}
Expand Down
3 changes: 2 additions & 1 deletion system_tests/retryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func TestRetryableNoExist(t *testing.T) {
arbRetryableTx, err := precompilesgen.NewArbRetryableTx(common.HexToAddress("6e"), builder.L2.Client)
Require(t, err)
_, err = arbRetryableTx.GetTimeout(&bind.CallOpts{}, common.Hash{})
if err.Error() != "execution reverted: error NoTicketWithID()" {
// The first error is server side. The second error is client side ABI decoding.
if err.Error() != "execution reverted: error NoTicketWithID(): NoTicketWithID()" {
Fatal(t, "didn't get expected NoTicketWithID error")
}
}
Expand Down

0 comments on commit bba477f

Please sign in to comment.