plotchy / evm-cfg

Symbolic stack CFG generator for EVM
178 stars 14 forks source link

Cannot parse bytecode of fib #14

Closed nnsgmsone closed 4 months ago

nnsgmsone commented 5 months ago

When I attempted to run the program to parse a bytecode segment for fib, 5f35600060015b8215601b578181019150909160019003916006565b91505000, I encountered the following error:

 thread 'main' panicked at src/cfg_gen/cfg_graph.rs:215:9: 
Could not find node for pc 6912. 

Do I need to make any modifications, or does the program itself not support parsing this type of bytecode?

plotchy commented 4 months ago

Thanks for reporting. I just pushed an update, but I don't think it would have changed logic that would handle this. I couldn't recreate your error. Could you try again?

evm-cfg 5f35600060015b8215601b578181019150909160019003916006565b91505000 -vvvvvvv -o index.dot

image
plotchy commented 4 months ago

I ended up finding why this happened. There was some improper slicing logic to convert a u8 to u16. made it less fancy and it works now :)

fn get_u16_from_u8_slice(push_val: &[u8]) -> u16 {
    match push_val.len() {
        0 => 0,
        1 => push_val[0] as u16,
        _ => (push_val[0] as u16) << 8 | (push_val[1] as u16),
    }
}