We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d5f15b commit 43a984dCopy full SHA for 43a984d
trace_decoder/src/decoding.rs
@@ -30,7 +30,7 @@ use crate::{
30
OtherBlockData, TrieRootHash, TxnIdx, EMPTY_ACCOUNT_BYTES_RLPED,
31
ZERO_STORAGE_SLOT_VAL_RLPED,
32
},
33
- utils::{hash, optional_field, optional_field_hex, update_val_if_some},
+ utils::{eth_to_gwei, hash, optional_field, optional_field_hex, update_val_if_some},
34
};
35
36
/// Stores the result of parsing tries. Returns a [TraceParsingError] upon
@@ -563,8 +563,13 @@ impl ProcessedBlockTrace {
563
fn add_withdrawals_to_txns(
564
txn_ir: &mut [GenerationInputs],
565
final_trie_state: &mut PartialTrieState,
566
- withdrawals: Vec<(Address, U256)>,
+ mut withdrawals: Vec<(Address, U256)>,
567
) -> TraceParsingResult<()> {
568
+ // Scale withdrawals amounts.
569
+ for (_addr, amt) in withdrawals.iter_mut() {
570
+ *amt = eth_to_gwei(*amt)
571
+ }
572
+
573
let withdrawals_with_hashed_addrs_iter = || {
574
withdrawals
575
.iter()
trace_decoder/src/utils.rs
@@ -1,4 +1,4 @@
1
-use ethereum_types::H256;
+use ethereum_types::{H256, U256};
2
use keccak_hash::keccak;
3
use log::trace;
4
use mpt_trie::{
@@ -8,6 +8,11 @@ use mpt_trie::{
8
9
use crate::types::HashedStorageAddr;
10
11
+pub(crate) fn eth_to_gwei(eth: U256) -> U256 {
12
+ // 1 ether = 10^9 gwei.
13
+ eth * U256::from(10).pow(9.into())
14
+}
15
16
pub(crate) fn hash(bytes: &[u8]) -> H256 {
17
H256::from(keccak(bytes).0)
18
}
0 commit comments