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

Extract revert messages #6226

Merged
merged 31 commits into from
Oct 30, 2023
Merged

Extract revert messages #6226

merged 31 commits into from
Oct 30, 2023

Conversation

emlautarom1
Copy link
Contributor

Fixes #6224

Changes

  • Extract and decode revert error messages.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

Remarks

Some clients like etherjs try to decode error messages on a per client basis in an ad-hoc fashion given that there is currently no standarized way to return errors for eth_estimateGas (see ethereum/execution-apis#463). This PR might affect clients that perform such decoding.

@@ -104,4 +106,36 @@ private string DefaultErrorMessage(ReadOnlySpan<byte> span)
return null;
}
}

private unsafe string? TryUnpackRevertMessage(ReadOnlySpan<byte> span)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be unified with TryGetErrorMessage? Looks similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are similar but not the same:

  • A specific prefix is required.
  • The span has a required minimum length, not a specific length.
  • The returned error message is decoded as UTF8.

Still, maybe there's something to be done to reduce the amount of code. What do you think @benaadams?

@LukaszRozmej
Copy link
Member

We could and maybe should do that with ABI, but this is bigger refactor, so lets go with this for now.

@emlautarom1 emlautarom1 merged commit 594ab98 into master Oct 30, 2023
65 checks passed
@emlautarom1 emlautarom1 deleted the feat/unpack_revert_message branch October 30, 2023 13:15
@@ -18,8 +19,25 @@ public class TransactionSubstate
private const string Revert = "revert";

private const int RevertPrefix = 4;
private const int WordSize = EvmPooledMemory.WordSize;

private const string RevertedErrorMessagePrefix = "Reverted ";
Copy link

Choose a reason for hiding this comment

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

If there was an extra colon in the prefix, i.e. Reverted: {message} this would become compatible with Geth. I want to point it out since you're already making a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's an ongoing discussion on standarization of error messages: ethereum/execution-apis#463.

kamilchodola added a commit that referenced this pull request Jan 21, 2024
LukaszRozmej added a commit that referenced this pull request Jan 21, 2024
# Conflicts:
#	src/Nethermind/Nethermind.Evm/TransactionSubstate.cs
OlegJakushkin added a commit that referenced this pull request Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth_estimateGas does not return decoded revert messages
3 participants