mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
* use B256, B160 and U256 from revm * fix U256 from_str * use U256::ZERO * use temporary commit for revm and interpreter * more U256::ZERO * more changes for revm/ruint types * clippy * change revm and revm-interpreter repo * remove H160 wrap * minor cleanup * remove unused * fix MIN_PROTOCOL_BASE_FEE
44 lines
977 B
Rust
44 lines
977 B
Rust
use crate::{H256, U256};
|
|
use reth_codecs::{main_codec, Compact};
|
|
|
|
/// An Ethereum account.
|
|
#[main_codec]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
|
pub struct Account {
|
|
/// Account nonce.
|
|
pub nonce: u64,
|
|
/// Account balance.
|
|
pub balance: U256,
|
|
/// Hash of the account's bytecode.
|
|
pub bytecode_hash: Option<H256>,
|
|
}
|
|
|
|
impl Account {
|
|
/// Whether the account has bytecode.
|
|
pub fn has_bytecode(&self) -> bool {
|
|
self.bytecode_hash.is_some()
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use crate::{Account, U256};
|
|
use reth_codecs::Compact;
|
|
|
|
#[test]
|
|
fn test_account() {
|
|
let mut buf = vec![];
|
|
let mut acc = Account::default();
|
|
let len = acc.to_compact(&mut buf);
|
|
assert_eq!(len, 2);
|
|
|
|
acc.balance = U256::from(2);
|
|
let len = acc.to_compact(&mut buf);
|
|
assert_eq!(len, 3);
|
|
|
|
acc.nonce = 2;
|
|
let len = acc.to_compact(&mut buf);
|
|
assert_eq!(len, 4);
|
|
}
|
|
}
|