chore: remove revm/compat from reth-primitives (#8960)

This commit is contained in:
joshieDo
2024-06-19 18:42:54 +02:00
committed by GitHub
parent a21a2b72eb
commit b5b15f03a0
10 changed files with 54 additions and 75 deletions

View File

@ -5,7 +5,7 @@ use byteorder::{BigEndian, ReadBytesExt};
use bytes::Buf;
use derive_more::Deref;
use reth_codecs::{main_codec, Compact};
use revm_primitives::{Bytecode as RevmBytecode, JumpTable};
use revm_primitives::{AccountInfo, Bytecode as RevmBytecode, JumpTable};
use serde::{Deserialize, Serialize};
/// An Ethereum account.
@ -122,6 +122,28 @@ impl Compact for Bytecode {
}
}
impl From<AccountInfo> for Account {
fn from(revm_acc: AccountInfo) -> Self {
let code_hash = revm_acc.code_hash;
Self {
balance: revm_acc.balance,
nonce: revm_acc.nonce,
bytecode_hash: (code_hash != KECCAK_EMPTY).then_some(code_hash),
}
}
}
impl From<Account> for AccountInfo {
fn from(reth_acc: Account) -> Self {
Self {
balance: reth_acc.balance,
nonce: reth_acc.nonce,
code_hash: reth_acc.bytecode_hash.unwrap_or(KECCAK_EMPTY),
code: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;