Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle error and revert data in EthEstimateGas and EthCall #12553

Merged
merged 27 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
19bf92e
fix: handle error and revert data in EthEstimateGas and EthCall
virajbhartiya Oct 4, 2024
1f47508
feat: itests
virajbhartiya Oct 4, 2024
6859ee5
feat: Add EthCallError struct and tests
virajbhartiya Oct 7, 2024
61f7fe5
refactor: eth call error
akaladarshi Oct 9, 2024
619b9a5
fix: handle error and revert data in EthCall
virajbhartiya Oct 11, 2024
e53a74d
feat: Refactor EthCall to handle invalid block number
virajbhartiya Oct 11, 2024
6d69cdd
refactor: eth call error to execution reverted error
akaladarshi Oct 11, 2024
5c7bdae
address comments
akaladarshi Oct 15, 2024
d1abde9
small change
akaladarshi Oct 15, 2024
22d418a
update changelog
akaladarshi Oct 15, 2024
273cbcc
update tests
virajbhartiya Oct 15, 2024
529dd97
remove go-jsonrpc
virajbhartiya Oct 15, 2024
d8015cc
add test for ethEstimateGas and addressed changes
virajbhartiya Oct 16, 2024
cc212fe
rename error
virajbhartiya Oct 16, 2024
cad6f2b
fix lint errors
virajbhartiya Oct 16, 2024
7aec77b
refactor: execution reverted error
akaladarshi Oct 16, 2024
a092883
Merge branch 'master' into jsonrpc
akaladarshi Oct 17, 2024
0ba5a70
implement error codec interface
akaladarshi Oct 22, 2024
3206a77
fix ci tests
akaladarshi Oct 22, 2024
6a7b6c1
update go mod
akaladarshi Oct 22, 2024
762d719
address comments
akaladarshi Oct 23, 2024
a88c3fe
small fix
akaladarshi Oct 23, 2024
35519c0
Merge branch 'master' into jsonrpc
akaladarshi Oct 23, 2024
0992e7e
address comments
akaladarshi Oct 24, 2024
2264607
Update go.mod dependencies
virajbhartiya Oct 24, 2024
cd7455e
Update go-jsonrpc version to v0.7.0
virajbhartiya Oct 24, 2024
5ed6352
Merge branch 'master' into jsonrpc
rvagg Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Reduce size of embedded genesis CAR files by removing WASM actor blocks and compressing with zstd. This reduces the `lotus` binary size by approximately 10 MiB. ([filecoin-project/lotus#12439](https://github.com/filecoin-project/lotus/pull/12439))
- Add ChainSafe operated Calibration archival node to the bootstrap list ([filecoin-project/lotus#12517](https://github.com/filecoin-project/lotus/pull/12517))
- Fix hotloop in F3 pariticpation API ([filecoin-project/lotus#12575](https://github.com/filecoin-project/lotus/pull/12575))
- Return data with `eth_call` and `eth_estimateGas` APIs `execution reverted` error ([filecoin-project/lotus#12553](https://github.com/filecoin-project/lotus/pull/12553))
rvagg marked this conversation as resolved.
Show resolved Hide resolved
- `lotus chain head` now supports a `--height` flag to print just the epoch number of the current chain head ([filecoin-project/lotus#12609](https://github.com/filecoin-project/lotus/pull/12609))
- `lotus-shed indexes inspect-indexes` now performs a comprehensive comparison of the event index data for each message by comparing the AMT root CID from the message receipt with the root of a reconstructed AMT. Previously `inspect-indexes` simply compared event counts, comparing AMT roots confirms all the event data is byte-perfect. ([filecoin-project/lotus#12570](https://github.com/filecoin-project/lotus/pull/12570))

Expand Down
63 changes: 56 additions & 7 deletions api/api_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"errors"
"reflect"

"golang.org/x/xerrors"

"github.com/filecoin-project/go-jsonrpc"
)

const executionRevertedDefaultMsg = "execution reverted"

const (
EOutOfGas = iota + jsonrpc.FirstUserCode
EActorNotFound
Expand All @@ -17,6 +21,7 @@ const (
EF3ParticipationTooManyInstances
EF3ParticipationTicketStartBeforeExisting
EF3NotReady
EExecutionRevertedWithData
)

var (
Expand All @@ -40,13 +45,15 @@ var (
// should back off and try again later.
ErrF3NotReady = errF3NotReady{}

_ error = (*ErrOutOfGas)(nil)
_ error = (*ErrActorNotFound)(nil)
_ error = (*errF3Disabled)(nil)
_ error = (*errF3ParticipationTicketInvalid)(nil)
_ error = (*errF3ParticipationTicketExpired)(nil)
_ error = (*errF3ParticipationIssuerMismatch)(nil)
_ error = (*errF3NotReady)(nil)
_ error = (*ErrOutOfGas)(nil)
_ error = (*ErrActorNotFound)(nil)
_ error = (*errF3Disabled)(nil)
_ error = (*errF3ParticipationTicketInvalid)(nil)
_ error = (*errF3ParticipationTicketExpired)(nil)
_ error = (*errF3ParticipationIssuerMismatch)(nil)
_ error = (*errF3NotReady)(nil)
_ error = (*ErrExecutionRevertedWithData)(nil)
_ jsonrpc.RPCErrorCodec = (*ErrExecutionRevertedWithData)(nil)
)

func init() {
Expand All @@ -59,6 +66,7 @@ func init() {
RPCErrors.Register(EF3ParticipationTooManyInstances, new(*errF3ParticipationTooManyInstances))
RPCErrors.Register(EF3ParticipationTicketStartBeforeExisting, new(*errF3ParticipationTicketStartBeforeExisting))
RPCErrors.Register(EF3NotReady, new(*errF3NotReady))
RPCErrors.Register(EExecutionRevertedWithData, new(*ErrExecutionRevertedWithData))
}

func ErrorIsIn(err error, errorTypes []error) bool {
Expand Down Expand Up @@ -110,3 +118,44 @@ func (errF3ParticipationTicketStartBeforeExisting) Error() string {
type errF3NotReady struct{}

func (errF3NotReady) Error() string { return "f3 isn't yet ready to participate" }

type ErrExecutionRevertedWithData struct {
rvagg marked this conversation as resolved.
Show resolved Hide resolved
Message string
Data string
}

// Error returns the error message.
func (e *ErrExecutionRevertedWithData) Error() string { return e.Message }

// FromJSONRPCError converts a JSONRPCError to ErrExecutionRevertedWithData.
func (e *ErrExecutionRevertedWithData) FromJSONRPCError(jerr jsonrpc.JSONRPCError) error {
if jerr.Code != EExecutionRevertedWithData {
return nil
rvagg marked this conversation as resolved.
Show resolved Hide resolved
}

data, ok := jerr.Data.(string)
rvagg marked this conversation as resolved.
Show resolved Hide resolved
if !ok {
return xerrors.Errorf("expected string data in execution reverted error, got %T", jerr.Data)
}

e.Message = jerr.Message
e.Data = data
return nil
}

// ToJSONRPCError converts ErrExecutionRevertedWithData to a JSONRPCError.
func (e *ErrExecutionRevertedWithData) ToJSONRPCError() (jsonrpc.JSONRPCError, error) {
return jsonrpc.JSONRPCError{
Code: EExecutionRevertedWithData,
Message: e.Message,
Data: e.Data,
}, nil
}

// NewErrExecutionRevertedWithData creates a new ErrExecutionRevertedWithData.
func NewErrExecutionRevertedWithData(data string) *ErrExecutionRevertedWithData {
return &ErrExecutionRevertedWithData{
Message: executionRevertedDefaultMsg,
Data: data,
}
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ replace github.com/filecoin-project/test-vectors => ./extern/test-vectors // pro

replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi // provided via a git submodule

replace github.com/filecoin-project/go-jsonrpc => github.com/virajbhartiya/go-jsonrpc v0.0.0-20241022141239-e8dc77abf0ab

require (
contrib.go.opencensus.io/exporter/prometheus v0.4.2
github.com/BurntSushi/toml v1.3.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1/go.mod h1:gXpNmr3oQx8l3o7qkGy
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBwFmYdT8SOFUwB3ovSUfG1Ux0g=
github.com/filecoin-project/go-hamt-ipld/v3 v3.4.0 h1:nYs6OPUF8KbZ3E8o9p9HJnQaE8iugjHR5WYVMcicDJc=
github.com/filecoin-project/go-hamt-ipld/v3 v3.4.0/go.mod h1:s0qiHRhFyrgW0SvdQMSJFQxNa4xEIG5XvqCBZUEgcbc=
github.com/filecoin-project/go-jsonrpc v0.6.0 h1:/fFJIAN/k6EgY90m7qbyfY28woMwyseZmh2gVs5sYjY=
github.com/filecoin-project/go-jsonrpc v0.6.0/go.mod h1:/n/niXcS4ZQua6i37LcVbY1TmlJR0UIK9mDFQq2ICek=
github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs=
github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ=
github.com/filecoin-project/go-paramfetch v0.0.4 h1:H+Me8EL8T5+79z/KHYQQcT8NVOzYVqXIi7nhb48tdm8=
Expand Down Expand Up @@ -1281,6 +1279,8 @@ github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8W
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/virajbhartiya/go-jsonrpc v0.0.0-20241022141239-e8dc77abf0ab h1:kwYsIGo0hxWwwuhcpvxKqxK1odAuaRJs9tqvIUF67w4=
github.com/virajbhartiya/go-jsonrpc v0.0.0-20241022141239-e8dc77abf0ab/go.mod h1:lAUpS8BSVtKaA8+/CFUMA5dokMiSM7n0ehf8bHOFdpE=
github.com/warpfork/go-testmark v0.12.1 h1:rMgCpJfwy1sJ50x0M0NgyphxYYPMOODIJHhsXyEHU0s=
github.com/warpfork/go-testmark v0.12.1/go.mod h1:kHwy7wfvGSPh1rQJYKayD4AbtNaeyZdcGi9tNJTaa5Y=
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
Expand Down
Loading