getwax / bls-wallet

Core components to use layer 2 smart contract wallets with the BLS signature scheme
MIT License
178 stars 47 forks source link

Add `ExpanderEntryPoint` to avoid solidity abi #590

Closed voltrevo closed 1 year ago

voltrevo commented 1 year ago

Dependent PR

This PR depends on https://github.com/web3well/bls-wallet/pull/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:

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

Guidelines