mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: replace TrieAccount with alloy's (#13397)
This commit is contained in:
@ -21,6 +21,7 @@ alloy-eips.workspace = true
|
||||
alloy-genesis.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rlp.workspace = true
|
||||
alloy-trie.workspace = true
|
||||
revm-primitives.workspace = true
|
||||
|
||||
# op
|
||||
@ -80,7 +81,8 @@ std = [
|
||||
"bytes/std",
|
||||
"derive_more/std",
|
||||
"k256/std",
|
||||
"secp256k1?/std"
|
||||
"secp256k1?/std",
|
||||
"alloy-trie/std"
|
||||
]
|
||||
secp256k1 = ["dep:secp256k1"]
|
||||
test-utils = [
|
||||
@ -99,7 +101,8 @@ arbitrary = [
|
||||
"reth-codecs?/arbitrary",
|
||||
"secp256k1?/global-context",
|
||||
"secp256k1?/rand",
|
||||
"op-alloy-consensus?/arbitrary"
|
||||
"op-alloy-consensus?/arbitrary",
|
||||
"alloy-trie/arbitrary"
|
||||
]
|
||||
serde-bincode-compat = [
|
||||
"serde",
|
||||
@ -120,7 +123,8 @@ serde = [
|
||||
"revm-primitives/serde",
|
||||
"op-alloy-consensus?/serde",
|
||||
"k256/serde",
|
||||
"secp256k1?/serde"
|
||||
"secp256k1?/serde",
|
||||
"alloy-trie/serde"
|
||||
]
|
||||
reth-codec = [
|
||||
"dep:reth-codecs",
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use alloy_consensus::constants::KECCAK_EMPTY;
|
||||
use alloy_genesis::GenesisAccount;
|
||||
use alloy_primitives::{keccak256, Bytes, B256, U256};
|
||||
use alloy_trie::TrieAccount;
|
||||
use derive_more::Deref;
|
||||
use revm_primitives::{AccountInfo, Bytecode as RevmBytecode, BytecodeDecodeError};
|
||||
|
||||
@ -57,6 +58,17 @@ impl Account {
|
||||
pub fn get_bytecode_hash(&self) -> B256 {
|
||||
self.bytecode_hash.unwrap_or(KECCAK_EMPTY)
|
||||
}
|
||||
|
||||
/// Converts the account into a trie account with the given storage root.
|
||||
pub fn into_trie_account(self, storage_root: B256) -> TrieAccount {
|
||||
let Self { nonce, balance, bytecode_hash } = self;
|
||||
TrieAccount {
|
||||
nonce,
|
||||
balance,
|
||||
storage_root,
|
||||
code_hash: bytecode_hash.unwrap_or(KECCAK_EMPTY),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Bytecode for an account.
|
||||
|
||||
Reference in New Issue
Block a user