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: eth: correctly encode and simplify native input/output encoding #11382

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Nov 3, 2023

Related Issues

Proposed Changes

When generating eth traces, we encode "native" message inputs/outputs to "solidity ABI" by formatting the inputs/outputs the same way we do in FEVM's "handle_native_method". However, we had quite a few bugs with the implementation:

  1. We were right-aligning 64bit values in 256bit words, instead of left-aligning (as we should given that these values are big-endian).
  2. The return-value encoding wasn't correctly handling lengths.

This patch:

  1. Fixes those bugs.
  2. Deduplicates the logic (we're doing basically the same thing in both cases).
  3. Removes all error paths (these functions can't fail).

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
    • bug in unreleased (I think) code
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

These are shared functions, so I'm moving them to the utils library.
@Stebalien Stebalien requested a review from a team as a code owner November 3, 2023 19:49
@Stebalien Stebalien requested a review from arajasek November 3, 2023 19:49
When generating eth traces, we encode "native" message inputs/outputs
to "solidity ABI" by formatting the inputs/outputs the same way we do in
FEVM's "handle_native_method". However, we had quite a few bugs with the
implementation:

1. We were right-aligning 64bit values in 256bit words, instead of
left-aligning (as we should given that these values are big-endian).
2. The return-value encoding wasn't correctly handling lengths.

This patch:

1. Fixes those bugs.
2. Deduplicates the logic (we're doing _basically_ the same thing in
both cases).
3. Removes all error paths (these functions can't fail).
Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

LGTM, though I'm not independently verifying the correctness of the encoding itself.

@Stebalien Stebalien merged commit cff785f into master Nov 6, 2023
87 checks passed
@Stebalien Stebalien deleted the steb/abi-encoding branch November 6, 2023 17:41
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.

2 participants