-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Changes from 17 commits
19bf92e
1f47508
6859ee5
61f7fe5
619b9a5
e53a74d
6d69cdd
5c7bdae
d1abde9
22d418a
273cbcc
529dd97
d8015cc
cc212fe
cad6f2b
7aec77b
a092883
0ba5a70
3206a77
40e4ca1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,8 @@ import ( | |||||||||||||||||||||||||||||||||
"github.com/filecoin-project/go-jsonrpc" | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const executionRevertedDefaultMsg = "execution reverted" | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const ( | ||||||||||||||||||||||||||||||||||
EOutOfGas = iota + jsonrpc.FirstUserCode | ||||||||||||||||||||||||||||||||||
EActorNotFound | ||||||||||||||||||||||||||||||||||
|
@@ -17,6 +19,7 @@ const ( | |||||||||||||||||||||||||||||||||
EF3ParticipationTooManyInstances | ||||||||||||||||||||||||||||||||||
EF3ParticipationTicketStartBeforeExisting | ||||||||||||||||||||||||||||||||||
EF3NotReady | ||||||||||||||||||||||||||||||||||
EExecutionRevertedWithData | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
var ( | ||||||||||||||||||||||||||||||||||
|
@@ -47,6 +50,7 @@ var ( | |||||||||||||||||||||||||||||||||
_ error = (*errF3ParticipationTicketExpired)(nil) | ||||||||||||||||||||||||||||||||||
_ error = (*errF3ParticipationIssuerMismatch)(nil) | ||||||||||||||||||||||||||||||||||
_ error = (*errF3NotReady)(nil) | ||||||||||||||||||||||||||||||||||
_ error = (*ErrExecutionRevertedWithData)(nil) | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
func init() { | ||||||||||||||||||||||||||||||||||
|
@@ -59,6 +63,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 { | ||||||||||||||||||||||||||||||||||
|
@@ -110,3 +115,22 @@ func (errF3ParticipationTicketStartBeforeExisting) Error() string { | |||||||||||||||||||||||||||||||||
type errF3NotReady struct{} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
func (errF3NotReady) Error() string { return "f3 isn't yet ready to participate" } | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
type ErrExecutionRevertedWithData struct { | ||||||||||||||||||||||||||||||||||
message string | ||||||||||||||||||||||||||||||||||
data string | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// Error returns the error message. | ||||||||||||||||||||||||||||||||||
func (e *ErrExecutionRevertedWithData) Error() string { return e.message } | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// ErrorData returns the error data. | ||||||||||||||||||||||||||||||||||
func (e *ErrExecutionRevertedWithData) ErrorData() interface{} { return e.data } | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
// NewErrExecutionRevertedWithData creates a new ErrExecutionRevertedWithData. | ||||||||||||||||||||||||||||||||||
func NewErrExecutionRevertedWithData(data string) *ErrExecutionRevertedWithData { | ||||||||||||||||||||||||||||||||||
return &ErrExecutionRevertedWithData{ | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Does jsonrpc bork still on non-interface? Not a big deal but if we can avoid pointer receivers where they are not necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rvagg They are necessary as of now because we are registering the errors as I am trying to figure out a way, so we can get the code without worrying if the error is pointer type or not. |
||||||||||||||||||||||||||||||||||
message: executionRevertedDefaultMsg, | ||||||||||||||||||||||||||||||||||
data: data, | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.