-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
logic errors fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this other than the final comments.
…te into gav-composite-account
Co-Authored-By: Shawn Tabrizi <[email protected]>
Co-Authored-By: Shawn Tabrizi <[email protected]>
…te into gav-composite-account
* Basic account composition. * Add try_mutate_exists * De-duplicate * Refactor away the UpdateBalanceOutcome * Expunge final UpdateBalanceOutcome refs * Refactor transfer * Refactor reservable currency stuff. * Test with the alternative setup. * Fixes * Test with both setups. * Fixes * Fix * Fix macros * Make indices opt-in * Remove CreationFee, and make indices opt-in. * Fix construct_runtime * Fix last few bits * Fix tests * Update trait impls * Don't hardcode the system event * Make tests build and fix some stuff. * Pointlessly bump runtime version * Fix benchmark * Another fix * Whitespace * Make indices module economically safe * Migrations for indices. * Fix * Whilespace * Trim defunct migrations * Remove unused storage item * More contains_key fixes * Docs. * Bump runtime * Remove unneeded code * Fix test * Fix test * Update frame/balances/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Fix ED logic * Repatriate reserved logic * Typo * Fix typo * Update frame/system/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Update frame/system/src/lib.rs Co-Authored-By: Shawn Tabrizi <[email protected]> * Last few fixes * Another fix * Build fix Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Jaco Greeff <[email protected]> Co-authored-by: Shawn Tabrizi <[email protected]>
@@ -761,9 +760,6 @@ decl_storage! { | |||
|
|||
/// The earliest era for which we have a pending, unapplied slash. | |||
EarliestUnappliedSlash: Option<EraIndex>; | |||
|
|||
/// The version of storage for upgrade. | |||
StorageVersion: u32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect the storage version hasn't been removed from storage in kusama
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if I query on kusama the key twox128("Staking") ++ twox128("StorageVersion") == 0x5f3e4907f716ac89b6347d15ececedca308ce9615de0775a82f8a94dc3d285a1
then I get no value, and I can't understand why yet.
EDIT: I got my answer about Kusama, migration feature was off
* Amalgamate pieces of balance module * Fixes for vesting split * Refactoring for vesting/balances split * Build fixes * Remove on_free_balance_zero and some docs. * Indentation. * Revert branch * Fix. * Update substrate: fixes after CLI refactoring * Reverting removal of exit * Removed too much again * Update Cargo.lock * Cargo.lock * Update Substrate, ready for paritytech#4820 * Fixes * Update to latest substrate master * Fix network tests * Update lock * Fix tests * Update futures to get bug fixes * Fix tests for new balances/vesting logic * Cargo fix * Another fix Co-authored-by: Cecile Tonglet <[email protected]> Co-authored-by: Robert Habermeier <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
This brings in the final element of my balance refactorings, namely to avoid the (pessimising) spreading of typically co-accessed account data between multiple trie keys. This is particularly annoying for nonce and balance, which for all normal transactions are always mutated and yet are split between two separate trie items.
This provides an extensible framework, via a trait
StoredMap
, which allows an item to be stored somewhere, without specifying whether it's stored in its own storage item or in a shared composite storage item with other (probably related) values. It is used by the system module to allow for arbitrary data to be stored alongside the account nonce.Concretely, this merges the balances of an account with the nonce, reducing the number of trie accesses for a typical transfer from 3 to 2.
Until we know the exact tradeoff between bulking up a single key with lots of data that may possibly not tend to be co-accessed versus having multiple, smaller, trie keys, then we'll keep it lean, but benchmarking typical use-cases with "fat account items" might lead to further optimisations.
TODO
Additionally...
In addition to this, it makes the system of account indices opt-in; this means that accounts need not have indexes despite being funded. Two calls for registering indices are provided, as well as a third call for giving an index up and a forth for administrating indices by root.
The upshot to this is that there no longer needs to be a separate
AccountCreationFee
. All transfers work in the same way.^^^ CC @jacogr @pepyakin
Indices were originally brought in to provide for a means of enumerating all accounts (e.g. for migrations). This is no longer needed since we improved the storage interface. Their other usage was for minimising the size of a transaction, at the cost of an additional storage lookup. This additional looking is in reality an extra cost that must be borne out through conditional weighting, increasing code complexity and attack surface. The reality is that the extra bytes fee for putting an normal address is likely smaller than the fee for the extra lookup, meaning it will never be used. Its third usage is in terms of usability, allowing users to pass around smaller addresses. This is slightly dangerous in the previous usage, due to address reclaiming, and needs careful UI provisions. The cost, as it has been implemented, is an ever-growing state or significant fees.
This is mitigated in the current PR by having a single storage entry per index and a deposit, where the deposit can be reclaimed.
Upgrading Pallets & Runtimes
If you're using
decl_event
in your tests, you'll now need to includesystem<T>
as an item, sodecl_event!(my_pallet<T>);
would becomedecl_event!(system<T>, my_pallet<T>);
.system::Trait
is now the place to put anyOnNewAccount
orOnReapAccount
hooks; these will need moving frombalances::Trait
. You should include at least theBalances
handler in the reap account, so:Additionally, there's a new item in
system::Trait
calledAccountData
and a new item inbalances::Trait
calledAccountStore
. These can be wired together in order to let system store your account balances, which will be more efficient than balances storing them itself:Several config trait items are gone, they can be removed:
pallet_balances::Trait::OnNewAccount
(now inframe_system
)pallet_balances::Trait::OnReapAccount
(now inframe_system
)pallet_balances::Trait::OnFreeBalanceZero
(just useOnReapAccount
)pallet_balances::Trait::CreationFee
(removed)pallet_balances::Trait::TransferFee
(removed)