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

Add support for custom errors #1525

Merged
merged 28 commits into from
Jun 16, 2021
Merged

Add support for custom errors #1525

merged 28 commits into from
Jun 16, 2021

Conversation

fvictorio
Copy link
Member

@fvictorio fvictorio commented Jun 8, 2021

Depends on #1452.

@@ -45,6 +46,7 @@ export interface SourceReference {
contract?: string;
function?: string;
line: number;
range: [number, number];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this. Why was this added? Pretty sure I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in ErrorInferrer.filterRedundantFrames

type: StackTraceEntryType.CUSTOM_ERROR;
message: string;
sourceReference: SourceReference;
isInvalidOpcodeError: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this field is necessary. Aren't they always reverts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both for panic and custom errors. I removed it in aced929.

@@ -84,6 +86,13 @@ export interface PanicErrorStackTraceEntry {
isInvalidOpcodeError: boolean;
}

export interface CustomErrorStackTraceEntry {
type: StackTraceEntryType.CUSTOM_ERROR;
message: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the message here? The return data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the already parsed error message. I'll add a comment explaining that.

@@ -0,0 +1,46 @@
import * as abi from "@ethersproject/abi";

export class AbiHelpers {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good. It's even simpler than what I had in mind :)

I'm not sure how to review the tests though. Can you point me to the ones you think are important?

@fvictorio
Copy link
Member Author

I'm not sure how to review the tests though. Can you point me to the ones you think are important?

The two new directories are custom-errors and panic-codes. There's also the (skipped) try-catch-uncaught which is a known bug.

@fvictorio
Copy link
Member Author

I tested this with the recent 0.8.5 release of solidity and there is only one test failing. It's a very specific test, and it fails because a redundant frame is not properly removed. I don't think it's a blocker, though, so I'll open an issue to track that and expand on the failing test and why it fails.

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fvictorio fvictorio merged commit 6cc7269 into master Jun 16, 2021
@fvictorio fvictorio deleted the custom-errors branch June 16, 2021 20:59
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants