alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
794 stars 155 forks source link

[Bug] Fail to validate calldata with sol type #685

Closed jqphu closed 4 months ago

jqphu commented 4 months ago

Component

other

What version of Alloy are you on?

cargo tree | grep alloy repro_alloy v0.1.0 (/private/tmp/repro_alloy) ├── alloy-primitives v0.7.7 └── alloy-sol-types v0.7.7 ├── alloy-primitives v0.7.7 () ├── alloy-sol-macro v0.7.7 (proc-macro) │ ├── alloy-sol-macro-expander v0.7.7 │ │ ├── alloy-sol-macro-input v0.7.7 │ ├── alloy-sol-macro-input v0.7.7 ()

Operating System

macOS (Apple Silicon)

Describe the bug

gmeow,

trying to decode a function signature.

Defined the ABI as:

sol! {

[derive(Debug)]

function startBridgeTokensViaAcross(
    BridgeData memory bridgeData,
    AcrossData calldata acrossData
);

... }

Calling it with validate: false works:

    let result = abi::startBridgeTokensViaAcrossCall::abi_decode(&tx.data, false)?;

However, when I set validate: true

I get "reserialization did not match original". What is validating doing under the hood any why is it erroring?

Discussed with Dani here: https://t.me/ethers_rs/39183 Repro: https://github.com/jqphu/abi_decode_validate_fails/blob/main/src/main.rs

DaniPopes commented 4 months ago

Looks like the original data contains these extra 28 bytes at the end, which apparently are ignored in Solidity: d00dfeeddeadbeef and an address 8932eb23bad9bddb5cf81426f78279a53c6c3b71

image

jqphu commented 4 months ago

Looks like the original data contains these extra 28 bytes at the end, which apparently are ignored in Solidity: d00dfeeddeadbeef and an address 8932eb23bad9bddb5cf81426f78279a53c6c3b71

image

weird, I wonder if this is a quirk with the protocol where it manually uses this extra data somewhere off chain.

Either way, happy to close this and just use validate: false for now.