argotorg / argotorg/fe

Incorrect handling of arrays in ABI

Open
#419 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.7k
Forks
218
Avg merge
1d 4h
Merged PRs (30d)
8

Description

### What is wrong?

I *think* I stepped on something that @g-r-a-n-t had mentioned before but I couldn't find it written down so I'm doing a quick brain dump.

Our [guest book](https://github.com/ethereum/fe/blob/master/compiler/tests/cases/demo_guestbook.rs) demo uses a `bytes[100]` type as input. That is an array of `100` bytes.

The ABI type that we produce for this is `bytes100` which seems to indicate a sequence of 100 bytes but not actually formatted as an array (not having an encoded length). However, such a `bytes100` type doesn't actually exist in the [ABI spec](https://docs.soliditylang.org/en/latest/abi-spec.html) and hence it isn't recognized.

```
$ seth send 0x3463a446d824eeaec22fd63a1427d155229240d9 "sign(bytes100)" 0xdeadbeefff000000000000000000000000000000000000000000000000000000
hevm: Data.ByteString.index: index too large: 32, length = 32
CallStack (from HasCallStack):
error, called at libraries/bytestring/Data/ByteString.hs:1887:23 in bytestring-0.10.10.1:Data.ByteString

```

As far as I can tell, using `sign(bytes[100])` won't help here because even though that would be a valid ABI type, it isn't what our method seems to expect.

I *think* that I talked about that with @g-r-a-n-t in the past and that he said rust-evm let's us call the method with an unformatted sequence of 100 bytes but that's due to an overly permissive rust-evm but not actually ABI conform

### How can it be fixed

:man_shrugging:

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with compiler/tests/cases/demo_guestbook.rs and reproduce the shown seth send command for sign(bytes100). Compare the generated bytes100 type with the linked ABI specification and the behavior of sign(bytes[100]). Done means the guestbook ABI uses a recognized, ABI-conformant array representation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.