From 807b99c7de59089eac1437330b933b9a6a18c835 Mon Sep 17 00:00:00 2001 From: bear Date: Wed, 14 Dec 2022 18:10:45 +0800 Subject: [PATCH] Merge balance after update decimal (#128) * Update order * Update README --- tool/state-processor/src/system/README.md | 6 +++--- tool/state-processor/src/system/mod.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tool/state-processor/src/system/README.md b/tool/state-processor/src/system/README.md index 3ced4bf12..d15e83f72 100644 --- a/tool/state-processor/src/system/README.md +++ b/tool/state-processor/src/system/README.md @@ -1,16 +1,16 @@ ### Process steps - take solo account infos and remaining balances - - merge solo remaining balances - adjust solo balance decimals + - merge solo remaining balances - take para account infos - process balances - take solo balances total issuances and locks - prune solo balance locks - prune staking, phragmen election, democracy, vesting, relay authority, fee market locks - - check if there are any other locks - - adjust solo balances items' decimals + - adjust solo balances items' decimals - take para balances total issuances and locks - there should not be any locks on parachain + - check if there are any other locks - use all previous data to build the new accounts and calculate total issuances - merge solo and para account infos - how to deal with the account references? - TODO diff --git a/tool/state-processor/src/system/mod.rs b/tool/state-processor/src/system/mod.rs index 53f34ea6f..703c460f6 100644 --- a/tool/state-processor/src/system/mod.rs +++ b/tool/state-processor/src/system/mod.rs @@ -138,6 +138,14 @@ impl Processor { .take_map(b"Ethereum", b"RemainingRingBalance", &mut remaining_ring, get_hashed_key) .take_map(b"Ethereum", b"RemainingKtonBalance", &mut remaining_kton, get_hashed_key); + log::info!("adjust solo balance decimals"); + account_infos.iter_mut().for_each(|(_, v)| { + v.data.free *= GWEI; + v.data.reserved *= GWEI; + v.data.free_kton_or_misc_frozen *= GWEI; + v.data.reserved_kton_or_fee_frozen *= GWEI; + }); + log::info!("merge solo remaining balances"); remaining_ring.into_iter().for_each(|(k, v)| { if let Some(a) = account_infos.get_mut(&k) { @@ -160,14 +168,6 @@ impl Processor { } }); - log::info!("adjust solo balance decimals"); - account_infos.iter_mut().for_each(|(_, v)| { - v.data.free *= GWEI; - v.data.reserved *= GWEI; - v.data.free_kton_or_misc_frozen *= GWEI; - v.data.reserved_kton_or_fee_frozen *= GWEI; - }); - account_infos }