Commit Graph

5126 Commits

Author SHA1 Message Date
Martin Pugh d6bc59df58 [CI] Require D*-audit labels for any runtime changes (#8345)
* add check for audit labels if runtime change

* fix shellcheck nits

* include lib.sh in check_runtime.sh

* fix check_labels.sh

* fix check_labels.sh

* oops, this is github actions...

* why wont this work

* fetch all refs

* Update check-labels.yml

* print env - wtf is happening

* checkout the PR...

* ffs

* fix

* REVERT ME: test runtime check

* Revert "REVERT ME: test runtime check"

This reverts commit 0fd2b04abeeac12dd8ede4c0708cb796f9e3e722.
2021-03-16 18:09:24 +01:00
Aleksandr Krupenkin 4042dd67fe Update ss58-registry.json (#8351)
Added Plasm Network description
2021-03-16 18:07:32 +01:00
Benjamin Kampmann e64e4b249d Release missing 3.0 crates: pallet-node-authorization sc-finality-grandpa-warp-sync (#8360)
* bump pallet-node-authorization

* prepping sc-finality-grandpa-warp-sync for release

* bump Cargo.lock
2021-03-16 17:01:59 +01:00
Bastian Köcher 2cc9329b09 Update diener to enable polkadot companions that use new crates (#8371)
* Update diener to enable polkadot companions that use new crates

Diener will be updated in the CI image to make it possible to have
companions that add new crates from Substrate.

Besides that the wasm-bindgen is updated, because `0.2.70` is not
available anymore on crates.io.

* update lock

Co-authored-by: kianenigma <kian@parity.io>
2021-03-16 15:42:56 +01:00
Gavin Wood cf108722f5 Document a pub item (#8374) 2021-03-16 14:07:11 +01:00
gabriel klawitter d7ef668a30 alerting-rules: ContinuousTaskEnded alert should not drop all unspecified labels (#8369) 2021-03-16 13:44:05 +01:00
Gavin Wood 363db4f086 staking: Flexible generation of reward curve and associated tweaks (#8327)
* Initial abstraction

* Alter rest of APIs

* Fixes

* Some extra getters in Gilt pallet.

* Refactor Gilt to avoid u128 conversions

* Simplify and improve pow in per_things

* Add scalar division to per_things

* Renaming from_fraction -> from_float, drop _approximation

* Fixes

* Fixes

* Fixes

* Fixes

* Make stuff build

* Fixes

* Fixes

* Fixes

* Fixes

* Update .gitignore

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

* Update frame/gilt/src/lib.rs

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

* Update frame/gilt/src/mock.rs

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

* Fixes

* Fixes

* Fixes

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2021-03-16 12:03:58 +00:00
Kian Paimani b6c626399e Audit fixes for election/staking decoupling part 2 (#8167)
* Base features and traits.

* pallet and unsigned phase

* Undo bad formattings.

* some formatting cleanup.

* Small self-cleanup.

* Make it all build

* self-review

* Some doc tests.

* Some changes from other PR

* Fix session test

* Update Cargo.lock

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

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Some review comments

* Rename + make encode/decode

* Do an assert as well, just in case.

* Fix build

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

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Las comment

* fix staking fuzzer.

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

* Add one last layer of feasibility check as well.

* Last fixes to benchmarks

* Some more docs.

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

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

* Some nits

* 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

* Fix doc

* Mkae ci green

* Audit fixes for election-provider: part 2 signed phase.

* Fix weight

* Some grumbles.

* Try and weigh to get_npos_voters

* Fix build

* Fix line width

* 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

* Fix tests.

* Fix build

* Reorg some stuff

* More reorg.

* Reorg done.

* Fix build

* Another rename

* Fix build

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

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

* nit

* better doc

* Line width

* Fix build

* Self-review

* Self-review

* Fix wan

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

* 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

* fix build and review comments.

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

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* add comment

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
2021-03-16 12:44:30 +01:00
Peter Goodspeed-Niklaus 49be0579db NPoS Challenge Mode (#8236)
* Add PJR challenge functions

- Updates the PJR check to return a counterexample if one exists
- Adds functions to cheaply check counterexamples

This is in support of off-chain PJR challenges: if a miner discovers
that an accepted election solution does not satisfy PJR, it will be
eligible for substantial rewards. This helps ensure that validator
elections have an absolute quality floor, so even if someone manages
to censor well-behaved solutions to give themselves unfair representation,
we can catch them in the act and penalize them.

* counterexample -> counter_example

* reorganize: high -> low abstraction

* reorganize challenges high -> low abstraction

* add note justifying linear search

* Simplify max_pre_score validation

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

* add minor test of pjr challenge validation

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2021-03-16 09:00:03 +00:00
Shaun Wang 844e25522c Support pallet::storage conditional compilation (#8324)
* Support pallet::storage conditional compilation.

* Add docs for cfg attributes.

* Keep strong types for get cfg attrs return.

* Update frame/support/procedural/src/pallet/parse/helper.rs

* Update frame/support/procedural/src/pallet/parse/storage.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-03-16 08:51:51 +00:00
Kian Paimani 900bf2832a Don't log so many stkaing events on genesis block (#8339)
* Don't log so many stkaing events on genesis block

* Clean a few more warn and info logs

* Update frame/staking/src/lib.rs

* Update frame/staking/src/lib.rs
2021-03-15 14:09:56 +00:00
Falco Hirschenberger 249f1503e6 Add more relaxed pallet-name parsing (#8353)
Make it possbible to use the pallet's path name, with `-` separator or crate name with `_` separator.
fixes #8226
2021-03-15 14:47:02 +01:00
Kian Paimani 7c0904e5c2 Don't log to debug for every failed extrinsic. (#8355) 2021-03-15 09:45:48 +01:00
Qinxuan Chen 552d76d531 Remove useless sr-api (#8335)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-03-15 09:35:02 +01:00
Robert Klotzner def7b4dca2 Derive common classes for IfDisconnected. (#8346) 2021-03-12 20:54:44 +01:00
Kian Paimani f725975861 remove whitespaces. (#8341) 2021-03-12 14:23:24 +00:00
André Silva 5182209788 im-online: use EstimateNextSessionRotation to get better estimates of session progress (#8242)
* frame-support: add method to estimate current session progress

* im-online: use EstimateNextSessionRotation trait to delay heartbeats

* node: fix im-online pallet instantiation

* frame-support: fix docs

* frame: fix tests

* pallet-session: last block of periodic session means 100% session progress

* pallet-session: add test for periodic session progress

* pallet-babe: fix epoch progress and add test

* frame-support: return weight with session estimates

* pallet-im-online: add test for session progress logic
2021-03-12 11:50:07 +00:00
Alexander Theißen a4e8875897 contracts: Expose rent parameter to contracts (#8231)
* contracts: Expose rent parameter to contracts

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

* Fix typos

* Improve comments

* Add rent parameter weights

* Allow deploying a new schedule with the same version

* Add storage migration for new schedule

* Only decode the schedule version in storage migration

* Remove confusing docs

* Replace original_code_len() by aggregate_code_len()

Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
2021-03-12 11:21:08 +00:00
Bastian Köcher 3743cec9bd Do not ban peers for sending multiple valid requests (#8325)
We introduced banning of peers who spam us with the same request (more
than 2 times). However, we missed that it is completely legal to send
the same request multiple times as long as we did not provide any
answer. An example for that is the justification request. This request
is send multiple times until we could fetch the justification from one
of our peers. So, the solution to this problem is to tag requests as
fulfilled and to start counting these fulfilled requests. If the number
is higher than what we allow, the peer should be banned.
2021-03-12 11:13:44 +00:00
Bastian Köcher 5d73e960da Convert timestamp to unit type wrapper (#8333)
The timestamp inherent type was up to now just a simple `u64`. This
worked, but doesn't give you that much guarantees at compile time about
the type. This pr changes that by converting this type to a unit type
wrapper, similar to what we have done for `Slot`.

This is required for some future pr that touches quite a lot of the
inherents stuff :)

Besides this unit wrapper type, this pr also moves the `OnTimestampSet`
trait to `frame_support::traits`.
2021-03-11 23:33:34 +01:00
Pierre Krieger 39f3b77f4b Fix #8306 (#8330) 2021-03-11 19:07:52 +00:00
JesseAbram c06e556906 Add on_idle hook (#8209)
* add in idle hook

* remaining weight passed through to on_idle

* added weight return

* remove TODO

* weight adjustment fix

* added adjusted weight into tuple

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* compile errors for on_idle in dispatch

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* on idle tuple clean up

* register reduced weight

* collect and add reduced wait from on idle call

* better demo example

* Update frame/support/procedural/src/pallet/expand/hooks.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* added tests to dispatch.rs

* idle test on executive

* skip on idle if remaining weight is 0

* Update frame/executive/src/lib.rs

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

* Update frame/support/src/dispatch.rs

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

* abstract common logic out to functions

* docs

* remove demo example

* remove debug

* spacing

* docs

* revert template pallet to master

* change reduced weight to used weight

* remove empty line

* lint

* spacing

* Update frame/support/src/traits.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* documentation

* Update frame/support/procedural/src/pallet/expand/hooks.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* docs

* Update frame/support/src/traits.rs

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

* docs

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-03-11 18:04:14 +01:00
Wei Tang fb4b9755bb pallet-staking: add RewardDestination::None for explictly not receiving rewards (#8168) 2021-03-11 16:22:16 +01:00
Pierre Krieger 5f004b4428 Remove legacy network protocol (#8296) 2021-03-11 13:57:06 +00:00
dependabot[bot] 8f2517b06e Bump tracing from 0.1.22 to 0.1.25 (#8263)
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.22 to 0.1.25.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.22...tracing-0.1.25)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-11 14:04:47 +01:00
Cecile Tonglet 8031b6eacb Rework telemetry to replace the use of tracing with an object we pass around (#8143)
polkadot companion: paritytech/polkadot#2535
2021-03-11 11:05:45 +01:00
Andreas Doerr 7aaba0c154 Fix doc build (#8322) 2021-03-11 11:01:26 +01:00
Peter Goodspeed-Niklaus 781f908760 Implement PJR checker (#8160)
* Apply.

* get rid of glob import

* use meaningful generic type name

* pjr_check operates on `Supports` struct used elsewhere

* improve algorithmic complexity of `prepare_pjr_input`

* fix rustdoc warnings

* improve module docs

* typo

* simplify debug assertion

* add test finding the phase-change threshold value for a constructed scenario

* add more threshold scenarios to disambiguate plausible interpretations

* add link to npos paper reference

* docs: staked_assignment -> supports

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

* add utility method for generating npos inputs

* add a fuzzer which asserts that all unbalanced seq_phragmen are PJR

Note that this currently fails. I hope that this can be rectified
by calculating the threshold instead of choosing some arbitrary number.

* assert in all cases, not just debug

* leverage a native solution to choose candidates

* use existing helper methods

* add pjr-check and incorporate into the fuzzer

We should probably have one of the W3F people look at this to ensure
we're not misconstruing any definitions, but this seems like a
fairly straightforward implementation.

* fix compilation errors

* Enable manually setting iteration parameters in single run.

This gives us the ability to reproducably extract cases where
honggfuzz has discovered a panic. For example:

$ cargo run --release --bin phragmen_pjr -- --candidates 569 --voters 100
Tue 23 Feb 2021 11:23:39 AM CET
   Compiling bitflags v1.2.1
   Compiling unicode-width v0.1.8
   Compiling unicode-segmentation v1.7.1
   Compiling ansi_term v0.11.0
   Compiling strsim v0.8.0
   Compiling vec_map v0.8.2
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling textwrap v0.11.0
   Compiling atty v0.2.14
   Compiling heck v0.3.2
   Compiling clap v2.33.3
   Compiling structopt-derive v0.4.14
   Compiling structopt v0.3.21
   Compiling sp-npos-elections-fuzzer v2.0.0-alpha.5 (/home/coriolinus/Documents/Projects/paritytech/substrate/primitives/npos-elections/fuzzer)
    Finished release [optimized] target(s) in 6.15s
     Running `/home/coriolinus/Documents/Projects/paritytech/substrate/target/release/phragmen_pjr -c 569 -v 100`
thread 'main' panicked at 'unbalanced sequential phragmen must satisfy PJR', primitives/npos-elections/fuzzer/src/phragmen_pjr.rs:133:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is still not adequate proof that seq_phragmen is broken; it could
very well be that our PJR checker is doing the wrong thing, or we've
somehow missed a parameter of interest. Still, it's concerning.

* update comment verbiage for accuracy

* it is valid in PJR for an elected candidate to have 0 support

* Fix phragmen_pjr fuzzer

It turns out that the fundamental problem causing previous implementations
of the fuzzer to fail wasn't in `seq_phragmen` _or_ in `pjr_check`: it was
in the rounding errors introduced in the various conversions between the
internal data representation and the external one.

Fixing the fuzzer is then simply an issue of using the internal representation
and staying in that representation. However, that leaves the issue that
`seq_phragmen` occasionally produces an output which is technically not
PJR due to rounding errors. In the future we will need to add some kind of
"close-enough" threshold. However, that is explicitly out of scope of
this PR.

* restart ci; it appears to be stalled

* use necessary import for no-std

* use a more realistic distribution of voters and candidates

This isn't ideal; more realistic numbers would be about twice these.
However, either case generation or voting has nonlinear execution
time, and doubling these values brings iteration time from ~20s to
~180s. Fuzzing 6x as fast should make up for fuzzing cases half the size.

* identify specifically which PJR check may fail

* move candidate collection comment into correct place

* standard_threshold: use a calculation method which cannot overflow

* Apply suggestions from code review (update comments)

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

* clarify the effectiveness bounds for t-pjr check

* how to spell "committee"

* reorganize: high -> low abstraction

* ensure standard threshold calc cannot panic

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

* Apply suggestions from code review

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

Co-authored-by: kianenigma <kian.peymani@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-03-11 09:06:53 +00:00
Robert Habermeier e2960c383e more clear randomness API for BABE (#8180)
* more clear randomness API for BABE

* babe: move randomness utilities to its own file

* node: use babe::RandomnessFromOneEpochAgo in random_seed implementation

* frame-support: annotate randomness trait with block number

* pallet-randomness-collective-flip: fix for new randomness trait

* pallet-society: fix randomness usage

* pallet-lottery: fix randomness usage

* pallet-contracts: fix randomness usage

* pallet-babe: fix randomness usage

we need to track when the current and previous epoch started so that we
know the block number by each existing on-chain was known

* node: fix random_seed

* node-template: fix random_seed

* frame-support: extend docs

* babe: add test for epoch starting block number tracking

* babe: fix epoch randomness docs

* frame: add todos for dealing with randomness api changes

Co-authored-by: André Silva <andrerfosilva@gmail.com>
2021-03-10 16:31:49 +00:00
Tomasz Drwięga f3d4355a20 Custom RPC for Merkle Mountain Range pallet (#8137)
* Add MMR custom RPC.

* Change RuntimeApi to avoid hardcoding leaf type.

* Properly implement the new RuntimeAPI and wire up RPC.

* Extract Offchain DB as separate execution extension.

* Enable offchain DB access for offchain calls.

* Fix offchain_election tests.

* Skip block initialisation for proof generation.

* Fix integration test setup.

* Fix offchain tests. Not sure how I missed them earlier 🤷.

* Fix long line.

* One more test missing.

* Update mock for multi-phase.

* Address review grumbbles.

* Address review grumbles.

* Fix line width of a comment
2021-03-10 15:28:56 +00:00
Denis Pisarev 9637faae0c CI: return docs jobs (#8307)
* CI: return docs jobs allowing them to fail

* CI: refrain from Dwarnings for now

* CI: pass RUSTFLAGS directly; no need removing what wasn't there
2021-03-10 15:53:54 +01:00
Ashley 7ace5e21aa Return babe configuration information in the babe api epoch functions (#8072)
* Make changes

* Add serialize/deserialize, copy babe epoch config defaults from node runtime

* Fix line widths and turn default features off for serde

* Remove ser/deser from Epoch, fix node-cli

* Apply suggestions

* Add comment to BABE_GENESIS_EPOCH_CONFIG in bin

* Apply suggestions

* Add a sketchy migration function

* Add a migration test

* Check for PendingEpochConfigChange as well

* Make epoch_config in node-cli

* Move updating EpochConfig out of the if

* Fix executor tests

* Calculate weight for add_epoch_configurations

* Fix babe test

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Add more asserts to tests, remove unused changes to primitives/slots

* Allow setting the migration pallet prefix

* Rename to BabePalletPrefix

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
2021-03-10 08:40:22 +00:00
Bastian Köcher c33235ac5b Update to latest proc-macro-crate version (#8294) 2021-03-09 22:22:25 +00:00
Bastian Köcher 7599e0d6e8 Introduce new concept of "slot portion for proposing" (#8280)
* Introduce new concept of "slot portion for proposing"

Currently when building a block we actually give the proposer all of the
time in the slot, while this is wrong. The slot is actually split in at
least two phases proposing and propagation or in the polkadot case into
three phases validating pov's, proposing and propagation. As we don't
want to bring that much polkadot concepts into Substrate, we only
support splitting the slot into proposing and propagation. The portion
can now be passed as parameter to AuRa and BABE to configure this value.
However, this slot portion for propagation doesn't mean that the
proposer can not go over this limit. When we miss slots we still apply
the lenience factor to increase the proposing time, so that we have
enough time to build a heavy block.

Besides all what was said above, this is especially required for
parachains. Parachains have a much more constraint proposing window.
Currently the slot duration is at minimum 12 seconds, but we only have
around 500ms for proposing. So, this slot portion for proposing is
really required to make it working without hacks.

* Offgit feedback

* Cast cast cast
2021-03-09 19:14:54 +00:00
Alexander Theißen 7f17082002 Fix typo in generated docs. (#8300) 2021-03-09 16:05:48 +00:00
Liu-Cheng Xu ed7e485365 Simplify the code a little bit (#8295) 2021-03-09 15:51:11 +01:00
Bastian Köcher 85f32e8813 Decrease the peer reputation on invalid block requests (#8260)
* Decrease the peer reputation on invalid block requests

This pr changes the block request handler to decrease the reputation of
peers when they send the same request multiple times or they send us an
invalid block request.

* Review feedback

* Change log target

* Remove unused code
2021-03-09 14:43:19 +01:00
Niklas Adolfsson 0dc9750026 update jsonrpsee to fix a allow(dead_code) (#8302) 2021-03-09 13:42:53 +00:00
Gavin Wood a49210693b Introduce IgnoredIssuance into Gilts (#8299)
* IgnoredIssuance

* Fixes

* Fixes
2021-03-09 14:03:47 +01:00
Gavin Wood 643a0ecd38 Assets: Remove zombies, introduce approvals (#8220)
* Initial work

* Tests for frame system

* Self-sufficient account ref-counting

* Fixes

* Benchmarks building.

* Update frame/system/src/lib.rs

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Test approvals

* Fixes

* Report assets pallet tests

* Tests for approvals & force_cancel_approval

* Use structs rather than tuples for approval data

* Add force_asset_status, force_set_metadata

* Add clear_metadata.

* approval benchmarks

* force_asset_status benchmarks

* final benchmarks

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

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Docs for new approval dispatches.

* Docs for pallet.

* Remove accidental code.

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

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

* Fixes

* Update frame/assets/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumbles.

* Transfer zero works, use DispatchResult

* fix test

* Remove force_destroy

* Remove TODO

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

* transfer_keep_alive

* Fixes

* Fixes

* Fixes

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

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-03-09 13:38:33 +01:00
honeywest b3f8e064f2 Clippy arithmetic new (#8282)
* optimize code

* fix clippy replace = with += or %=

* fix redundant closure found warning

* redundant field names in struct initialization

* fix clippy warning and optimize code

* fix clippy warning

* fix clippy warning

* fix test error
2021-03-08 11:35:26 +01:00
Alexander Theißen f39c2cf3f5 pallet_macro: Generate default documentation for well known types (#8276) 2021-03-07 22:45:53 -04:00
Niklas Adolfsson 6bd09c07bd refactor(remote ext): use jsonrpsee (#8105)
* A clean new attempt

* Checkpoint to move remote.

* A lot of dependency wiring to make it feature gated.

* bad macro, bad macro.

* refactor(remote ext): use jsonrpsee

* refactor(remote ext): use jsonrpsee

* Undo the DB mess.

* fix(remote ext): use max limit `u32::MAX`

* resolve TODOs

* jsonrpsee switch to `hyper` as backend

* Update utils/frame/try-runtime/remote-externalities/src/lib.rs

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

* update jsonrpsee

* remove boiler-plate

* suppress warnings to CI happy

* Unbreak his build

* Use option

* fix nit; make it work again

* fix err message.

* Update utils/frame/remote-externalities/Cargo.toml

* Fix uri stuff

* remove needless clone

Co-authored-by: kianenigma <kian.peymani@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2021-03-06 15:33:22 +00:00
Bastian Köcher b0ebf6498f Do not use Option to wrap GenesisConfig fields (#8275)
Currently we wrap every `GenesisConfig` field in an `Option`, while
we require `Default` being implemented for all pallet genesisconfigs.
Passing `None` also results in the genesis not being initialized, which
is a bug as seen from the perspective of a pallet developer?

This pr changes the fields of the `GenesisConfig` to non `Option` types.
2021-03-06 13:42:21 +00:00
Bastian Köcher 1680422f1f AuRa improvements (#8255)
* AuRa improvements

Hot and fresh AuRa improvements. This pr does the following:

- Move code belonging to the import queue etc to import_queue.rs
- Introduce `ImportQueueParams` and `StartAuraParams` structs to make
it more easier to understand what parameters we pass to AuRa.
- Introduce `CheckForEquivocation` to tell AuRa if it should check for
equivocation on block import. This is required for parachains, because
they are allowed to equivocate when they build two blocks for the same
slot, but for different relay chain parents.

* Update client/consensus/aura/src/import_queue.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Fix compilation

* AAA

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
2021-03-05 17:03:30 +01:00
Guillaume Thiolliere 9c4e4d453c Fix doc build with --all-features (#8277)
* implement

* make default pre/post_upgrade

* simplify Cargo.toml

* revert removal of outdated/private links

* link in pallet-mmr
2021-03-05 16:08:44 +01:00
Bastian Köcher d0530d0f2a Fix warnings related to panic and assert (#8272)
We were using the wrong syntax and that will be dropped with Rust 2021.
The compiler already starts to hint the wrong syntax with warnings. So,
we fix this here.
2021-03-05 10:56:33 +01:00
Robert Habermeier 0c72a8767b babe: introduce a request-answering mechanic (#7833)
* babe: introduce a request-answering mechanic

* gromble

* send method
2021-03-04 20:01:18 +01:00
Guillaume Thiolliere ddbdfc9e57 update nb-connect pin-project-lite rand_core (#8249) 2021-03-04 09:49:49 +01:00
Gavin Wood e993f884fc Self-sufficient account ref-counting (#8221)
* Self-sufficient account ref-counting

* Fixes

* Update frame/system/src/lib.rs

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* fix build

* Update frame/system/src/lib.rs

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

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2021-03-03 22:28:05 +01:00