feat: implement compact for eof bytecode variant (#9654)

This commit is contained in:
Matthias Seitz
2024-07-25 10:43:41 +02:00
committed by GitHub
parent 527cc4460b
commit bc7b5ff35e

View File

@ -61,6 +61,10 @@ impl Bytecode {
/// Create new bytecode from raw bytes.
///
/// No analysis will be performed.
///
/// # Panics
///
/// Panics if bytecode is EOF and has incorrect format.
pub fn new_raw(bytes: Bytes) -> Self {
Self(RevmBytecode::new_raw(bytes))
}
@ -87,10 +91,10 @@ impl Compact for Bytecode {
buf.put_slice(map);
1 + 8 + map.len()
}
RevmBytecode::Eof(_) => {
// buf.put_u8(3);
// TODO(EOF)
todo!("EOF")
RevmBytecode::Eof(eof) => {
buf.put_u8(3);
buf.put_slice(eof.raw().as_ref());
1 + eof.raw().as_ref().len()
}
};
len + bytecode.len() + 4
@ -114,8 +118,10 @@ impl Compact for Bytecode {
JumpTable::from_slice(buf),
)
}),
// TODO(EOF)
3 => todo!("EOF"),
3 => {
// EOF bytecode object will be decoded from the raw bytecode
Self(RevmBytecode::new_raw(bytes))
}
_ => unreachable!("Junk data in database: unknown Bytecode variant"),
};
(decoded, &[])