foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.25k stars 1.73k forks source link

cast's rlp decoding is incorrect #9197

Open 0xalpharush opened 1 day ago

0xalpharush commented 1 day ago

Component

Cast

Have you ensured that all of these are up to date?

What version of Foundry are you on?

cast 0.2.0 (2559899 2024-10-25T00:26:46.104971000Z)

What command(s) is the bug in?

cast from-rlp

Operating System

macOS (Apple Silicon)

Describe the bug

The RLP encoding is wrong https://github.com/ethereum/go-ethereum/blob/80bdab757dfb0f6d73fb869d834979536fe474e5/rlp/decode_test.go#L119-L120C5

$ cast from-rlp 820002
"0x0002"
cast from-rlp 00              
"0x00"
mattsse commented 22 hours ago

the limitation here is that we don't know whether the input is supposed to be an int or just raw data, and this decodes as raw data

perhaps we can add a target type or an --int flag to force this?

0xalpharush commented 10 hours ago

yeah it'd be nice to select parsing as a uint with a flag