alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
664 stars 239 forks source link

[Bug] RLP roundtrip fails for Anvil header #1575

Closed Wollac closed 4 weeks ago

Wollac commented 4 weeks ago

Component

consensus, eips, genesis

What version of Alloy are you on?

alloy-consensus v0.5.4

Operating System

None

Describe the bug

After the recent changes in the RLP code of alloy_consensus::Header, the following code fails due to an invalid RLP encoding:

let provider = ProviderBuilder::new().on_anvil();
let block = provider.get_block_by_number(0.into(), false).await.unwrap().unwrap();
let header: alloy_consensus::Header = block.header.try_into().unwrap();

// RLP encode and decode the header
let rlp = alloy_rlp::encode(&header);
alloy_consensus::Header::decode(&mut &rlp[..]).expect("should decode");

This is because the Anvil RPC (observed in various versions including the latest nightly) returns a block that includes blobGasUsed and excessBlobGas, but not withdrawalsRoot. This may be inconsistent or even wrong behavior by Anvil, but I raise it here first because this code worked in previous versions of alloy.

I would like to raise awareness about whether this particular response case should be handled in alloy, or if a failing try_into etc. would be the desired behavior.

klkvr commented 4 weeks ago

Fixed by https://github.com/foundry-rs/foundry/pull/9202 + https://github.com/foundry-rs/foundry/pull/9208