Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Backport Staking Fixes for Polkadot v0.8.31 #9135

Closed
wants to merge 24 commits into from

Conversation

shawntabrizi
Copy link
Member

@shawntabrizi shawntabrizi commented Jun 17, 2021

emostov and others added 14 commits June 17, 2021 13:42
* [pallet-staking] Refund unused weight for `payout_stakers` 

fixes #8428

* Use periods in comments

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Address Shawn's Feedback

* Assert monotomic weights && improve test note

* Remove stray new line

* debug_assert payout_count <= max

* Only track payouts to nominators; not validators

* Trivial comment update

Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* Bring back the on_finalize weighg of stakin.

* Better logs

* Also make a few things pub

* Fix build

* Add assertions

* Add test.

* remove dbg

* Update frame/election-provider-multi-phase/src/unsigned.rs

* Update frame/staking/src/tests.rs

* Fix

* Fix

* Update frame/election-provider-multi-phase/src/unsigned.rs
* helper macro to create storage types on the fly

* Update frame/support/src/lib.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* update lock

* fix test;

* Fix line width

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Removed can_report api from OnOffenceHandler

* Removed DeferredOffences and create a storage migration

* Removed missing comments

* Mock set_deferred_offences and deferred_offences methods

* OnOffenceHandler::on_offence always succeed

* Fix benchmark tests

* Fix runtime-benchmark cfg methods

* Removed 'applied' attribute from Offence event

* refactor deprecated deferred offences getter

* Validate if offences are submited after on_runtime_upgrade

* update changelog

* Remove empty lines

* Fix remove_deferred_storage weights

* Remove Offence::on_runtime_upgrade benchmark

* Revert CHANGELOG.md update

* Deprecate DeferredOffenceOf type

* Update copyright

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add migration logs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix migration log

* Remove unused import

* Add migration tests

* rustfmt

* use generate_storage_alias! macro

* Refactor should_resubmit_deferred_offences test

* Replace spaces by tabs

* Refactor should_resubmit_deferred_offences test

* Removed WeightSoftLimit

* Removed WeightSoftLimit from tests and mocks

* Remove unused imports

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* Emit `Bonded` event when rebonding

* fix borrow checker

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <admin@parity.io>
* Migrate staking pallet to pallet attribute macro.

* HistoryDepth default value.

* Make all calls public.

* Update frame/staking/src/lib.rs

* remove externalities again

* Update lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
…mission. (#8912)

* Implementation but weird initial era in tests

* Emergency mode for elections. (#8918)

* do some testing, some logging.

* some testing apparatus

* genesis election provider (#8970)

* genesis election provider

* fix historical stuff

* Fix test

* remove dbg

* Apply suggestions from code review

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* capitalize comment and name without conflict

* fix log

* Update frame/election-provider-multi-phase/src/lib.rs

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* apply suggestion on tests

* remove testing modifications

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Dmitry Kashitsyn <korvin@deeptown.org>

* apply suggestion

* fix master merge

Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Dmitry Kashitsyn <korvin@deeptown.org>
* start count

* track count

* add max limit

* min bonds for participating

* respect min bond when unbonding

* revert a bit of u32

* fix merge

* more merge fixes

* update to `Current*`

* add helper functions

* Update frame/staking/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* fix

* minbond as storage

* checkpoint

* chill_other

* better bond tracking

* MinBond to MinNominatorBond

* better doc

* use helper function

* oops

* simple hard limits to validators / nominators.

* better doc

* update storage version

* fix tests

* enable migrations

* min bond tests

* chill other tests

* tests for max cap

* check `None` on cap too

* benchmarks

* Update frame/staking/src/lib.rs

* Update frame/staking/src/lib.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* Update frame/staking/src/lib.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* Update frame/staking/src/tests.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* fix benchmark

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* nits

* fix reap_stash benchmark

* remove lower bound to min bond

Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
@github-actions github-actions bot added the A0-please_review Pull request needs code review. label Jun 17, 2021
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff itself is too big, looking into staking and election changes, but commits all look okay.

@shawntabrizi
Copy link
Member Author

Diff itself is too big, looking into staking and election changes, but commits all look okay.

Diff outside of staking should be very reviewable.

@shawntabrizi shawntabrizi added C7-high ❗️ D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Jun 17, 2021
Comment on lines +105 to +106
fn on_runtime_upgrade() -> Weight {
migration::remove_deferred_storage::<T>()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ Migration for Offences

Comment on lines +1385 to 1389
if StorageVersion::<T>::get() == Releases::V6_0_0 {
migrations::v7::migrate::<T>()
} else {
T::DbWeight::get().reads(1)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ Migration for Staking

shawntabrizi and others added 2 commits June 17, 2021 14:52
* unused mmr

* more unused

* dyn in executor

* remove `doc(inline)`

* fix dyn for sp-api-test

* update benchmarks

* Update primitives/core/benches/bench.rs

* Update primitives/core/benches/bench.rs

* update another bench

* fix benchmark?

Co-authored-by: adoerr <0xad@gmx.net>
Copy link
Contributor

@emostov emostov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine to me from eyeballing it. going to use try-runtime to double check the migration

@viniul viniul added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Jun 17, 2021
@shawntabrizi shawntabrizi deleted the shawntabrizi-v0.8.31 branch June 17, 2021 18:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants