Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking V3 #1611

Merged
merged 21 commits into from
Nov 12, 2024
Merged

Staking V3 #1611

merged 21 commits into from
Nov 12, 2024

Conversation

AurevoirXavier
Copy link
Member

@AurevoirXavier AurevoirXavier commented Oct 16, 2024

  • Remove all unused storage
  • Simplify election & reward logic
  • Use on_idle to distribute reward in background
  • Use on_idle to migrate un-migrated accounts in background
  • Benchmark
  • Migration

Closes:

@AurevoirXavier AurevoirXavier marked this pull request as ready for review October 21, 2024 04:48
@AurevoirXavier AurevoirXavier added Bk-Storage [Break] This changes Storage; next release should be major. Bk-API [Break] This changes API; next release should be major. S-Need Audit PR contains changes to fund-managing logic that should be properly reviewed and externally audited C-Pallet [Component] Something about pallet C-Runtime [Component] Something about runtime labels Oct 21, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

runtime/crab/src/pallets/evm.rs Outdated Show resolved Hide resolved
runtime/darwinia/src/pallets/evm.rs Outdated Show resolved Hide resolved
runtime/koi/src/pallets/evm.rs Outdated Show resolved Hide resolved
pallet/ethtx-forwarder/src/lib.rs Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

* Account migration adaptation

Signed-off-by: Xavier Lau <x@acg.box>

* Limit tasks

---------

Signed-off-by: Xavier Lau <x@acg.box>
@AurevoirXavier AurevoirXavier added S-Audited [Security] Audited and removed S-Need Audit PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Oct 30, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Signed-off-by: Xavier Lau <x@acg.box>

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

Check 298afe2 darwinia-dev

Check runtime version

Check runtime storage

Copy link

Check 298afe2 crab-dev

Check runtime version

Check runtime storage

Copy link

Check 298afe2 koi-dev

Check runtime version

RuntimeVersion {
    spec_name: "Darwinia Koi",
    impl_name: "DarwiniaOfficialRust",
    authoring_version: 0,
-   spec_version: 6710,
+   spec_version: 6720,
    impl_version: 0,
    transaction_version: 0,
    state_version: 0,
}

Check runtime storage

Pallet DarwiniaStaking
+ Entry: StorageEntryMetadata { name: "AuthoredBlockCount", modifier: Default, ty: Plain(UntrackedSymbol { id: 371, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 0, 0, 0, 0], docs: [" Number of blocks authored by the collator within current session."] }
- Entry: StorageEntryMetadata { name: "AuthoredBlocksCount", modifier: Default, ty: Plain(UntrackedSymbol { id: 377, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 0, 0, 0, 0], docs: [" Number of blocks authored by the collator within current session."] }
- Entry: StorageEntryMetadata { name: "CacheStates", modifier: Default, ty: Plain(UntrackedSymbol { id: 372, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 1, 2], docs: [" Collator/Exposure cache states.", "", " To avoid extra DB RWs during new session, such as:", " ```nocompile", " previous = current;", " current = next;", " next = elect();", " ```", "", " Now, with data:", " ```nocompile", " cache1 == previous;", " cache2 == current;", " cache3 == next;", " ```", " Just need to shift the marker and write the storage map once:", " ```nocompile", " mark(cache3, current);", " mark(cache2, previous);", " mark(cache1, next);", " cache1 = elect();", " ```"] }
- Entry: StorageEntryMetadata { name: "Collators", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 42, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" The map from (wannabe) collator to the preferences of that collator."] }
- Entry: StorageEntryMetadata { name: "CollatorsCache0", modifier: Default, ty: Plain(UntrackedSymbol { id: 74, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0], docs: [" Exposure cache 0."] }
- Entry: StorageEntryMetadata { name: "CollatorsCache1", modifier: Default, ty: Plain(UntrackedSymbol { id: 74, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0], docs: [" Exposure cache 1."] }
- Entry: StorageEntryMetadata { name: "CollatorsCache2", modifier: Default, ty: Plain(UntrackedSymbol { id: 74, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0], docs: [" Exposure cache 2."] }
- Entry: StorageEntryMetadata { name: "ExposureCache0", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 374, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" Exposure cache 0."] }
- Entry: StorageEntryMetadata { name: "ExposureCache1", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 374, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" Exposure cache 1."] }
- Entry: StorageEntryMetadata { name: "ExposureCache2", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 374, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" Exposure cache 2."] }
+ Entry: StorageEntryMetadata { name: "Ledgers", modifier: Optional, ty: Map { hashers: [Blake2_128Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 369, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" All staking ledgers."] }
- Entry: StorageEntryMetadata { name: "Ledgers", modifier: Optional, ty: Map { hashers: [Blake2_128Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 370, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" All staking ledgers."] }
- Entry: StorageEntryMetadata { name: "MigrationStartPoint", modifier: Default, ty: Plain(UntrackedSymbol { id: 6, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [" Migration start point."] }
- Entry: StorageEntryMetadata { name: "Nominators", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> }, value: UntrackedSymbol { id: 0, marker: PhantomData<fn() -> core::any::TypeId> } }, default: [0], docs: [" The map from nominator to their nomination preferences, namely the collator that", " they wish to support."] }
- Entry: StorageEntryMetadata { name: "RateLimit", modifier: Default, ty: Plain(UntrackedSymbol { id: 6, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [" Rate limit.", "", " The maximum amount of RING that can be staked or unstaked in one session."] }
- Entry: StorageEntryMetadata { name: "RateLimitState", modifier: Default, ty: Plain(UntrackedSymbol { id: 381, marker: PhantomData<fn() -> core::any::TypeId> }), default: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [" Rate limit state.", "", " Tracks the rate limit state in a session."] }

@AurevoirXavier AurevoirXavier merged commit e9e1155 into main Nov 12, 2024
10 checks passed
@AurevoirXavier AurevoirXavier deleted the xavier/staking-v3 branch November 12, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bk-API [Break] This changes API; next release should be major. Bk-Storage [Break] This changes Storage; next release should be major. C-Pallet [Component] Something about pallet C-Runtime [Component] Something about runtime S-Audited [Security] Audited
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants