-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Problem: when we convert Bytecode from revm type to proto type, the jump table is not correctly encoded.
latest release: https://github.com/paradigmxyz/reth-exex-examples/blob/main/remote/src/codec.rs#L354
jump_table: legacy_analyzed
.jump_table()
.as_slice()
.iter()
.copied()
.map(|x| x as u32)
.collect(),
previous release:
reth-exex-examples/remote/src/codec.rs
Line 354 in 6d1dc28
| jump_table: legacy_analyzed |
jump_table: legacy_analyzed
.jump_table()
.table
.iter()
.by_vals()
.map(|x| x.into())
.collect(),
Both return a vec of u32 but the first code interprets and groups the bits as u8's and then cast them as u32, while the other code interpret each bit as a u32 (resulting in a collection of 0 and 1). Therefore the vec's size in the first code is always smaller and when decoding from proto to revm types, we always fail this check: https://github.com/bluealloy/revm/blob/main/crates/bytecode/src/legacy/analyzed.rs#L75
assert!(
original_len <= jump_table.len(),
"jump table length is less than original length"
);
Example of results with a random slice of 10 bytes:
[75, 203]
[1, 1, 0, 1, 0, 0, 1, 0, 1, 1]
If we want to revert, we would need access to the table field of the JumpTable, which is now private in the revm-bytecode crate.