Skip to content

TryFrom<&reth::revm::bytecode::Bytecode> for proto::Bytecode is broken in latest commit. #48

@Gaon3

Description

@Gaon3

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions