Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(forknet): fix account shard assignment for forknet v2 (#12837)
the `fork-network amend-validators` command changes the accounts and keys for use with the `mirror` tx sending tool. This will change all the implicit accounts so that we can control them in the forked chain. But after this mapping, the account might not be in the same shard as it was before, in which case it's left in the trie for the wrong shard. Here we fix it by keeping a list of updates for every shard in each `StorageMutator`, and then writing updates to the right shard's trie when `commit()` is called. To synchronize this across the threads that are each iterating over different shards, we put the ongoing state roots in a `Mutex` that we lock whenever we want to commit changes to the shard. We also introduce a new type `DelayedReceiptTracker` that will remember the mapping from `(source shard, receipt index)` to `target shard`, and then after all threads have finished iterating over the whole trie in their shards, we write all delayed receipts in one thread with `write_delayed_receipts()` One other small change we make here is passing the same height to `MemTries::delete_until_height()` as we did to the previous call to `apply_memtrie_changes()`, because the garbage collection condition in that function gets rid of anything below the specified height. So with the previous code, we were keeping one extra update's worth of unnecessary nodes
- Loading branch information