Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Add ExpanderEntryPoint to avoid solidity abi #590

Merged
merged 2 commits into from
May 2, 2023

Conversation

voltrevo
Copy link
Collaborator

@voltrevo voltrevo commented Apr 27, 2023

Dependent PR

This PR depends on #584.

After that's merged, toggle the target branch back and forth or push an empty commit to fix the diff. (Preview of this PR's changes.)

What is this PR doing?

Before:

Screen Shot 2023-04-24 at 3 33 17 pm

3a276523
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000056
- ABI overhead

010007000000010cb730027900000001003092cbb31e
- Compressed operation

0b018b1989c5c62d43b0a0427f04781f2a4e201ab2c938ad23aa2d0a6c0a284a
03f37bd9fbdac1b34f3046363244c0e47a2a73add7cdfac41c2f134285256dfc
- BLS Signature

00000000000000000000
- ABI overhead

Explorer link

After:

Screen Shot 2023-04-27 at 11 17 48 am

010007000000020cb7300281000000010010a1ceebf4ae0a
- Compressed operation

0b1eaa43dcf48118dd1572d57b353103c2260c40c583132d0203139aa03b8ad7
0d122b7ca7f5af2d7b01cf50ff027d38f84426da4727216101cd62b25fd5aa7a
- BLS Signature

Explorer link

This is achieved by using ExpanderEntryPoint which uses fallback() in order to accept calldata bytes directly. This is superior to a function that takes a bytes argument, because the solidity ABI adds a surprising amount of stuff to encode that:

  • 4 bytes for a method ID
  • 32 bytes for the calldata offset location of the bytes argument
  • 32 bytes for the length of the bytes argument
  • 0-31 bytes padding at the end to ensure the calldata length is a multiple of 32

By using fallback(), we just accept the raw calldata directly. No method ID necessary. There is no calldata offset because we just get the full calldata unmodified. The length doesn't need to be encoded because there's an EVM instruction to get the calldata length. And the padding simply isn't needed.

How can these changes be manually tested?

(Replicating this test isn't required.)

Register the source BLS key and address and destination address, and do an ETH transfer. View the calldata in the block explorer (or otherwise) and confirm it's under 100 bytes.

Does this PR resolve or contribute to any issues?

Resolves #589.

Checklist

  • I have manually tested these changes
  • Post a link to the PR in the group chat

Guidelines

  • If your PR is not ready, mark it as a draft
  • The resolve conversation button is for reviewers, not authors
    • (But add a 'done' comment or similar)

@github-actions github-actions bot added aggregator Aggregator backend related clients contracts Smart contract related labels Apr 27, 2023
@blakecduncan blakecduncan changed the base branch from contract-updates to main May 2, 2023 14:48
@blakecduncan blakecduncan changed the base branch from main to contract-updates May 2, 2023 14:48
Copy link
Contributor

@blakecduncan blakecduncan left a comment

Choose a reason for hiding this comment

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

👍

@blakecduncan blakecduncan merged commit 0d52ddb into contract-updates May 2, 2023
@blakecduncan blakecduncan deleted the bw-589-avoid-solidity-abi branch May 2, 2023 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
aggregator Aggregator backend related clients contracts Smart contract related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants