Skip to content

Commit

Permalink
Merge balance after update decimal (#128)
Browse files Browse the repository at this point in the history
* Update order

* Update README
  • Loading branch information
boundless-forest authored Dec 14, 2022
1 parent 5b5a7d9 commit 807b99c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tool/state-processor/src/system/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions tool/state-processor/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down

0 comments on commit 807b99c

Please sign in to comment.