* 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>
* 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
* 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>
* 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
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.
* Init `RuntimeLogger` automatically for each runtime api call
This pr change the runtime api in such a way to always and automatically
enable the `RuntimeLogger`. This enables the user to use `log` or
`tracing` from inside the runtime to create log messages. As logging
introduces some extra code and especially increases the size of the wasm
blob. It is advised to disable all logging completely with
`sp-api/disable-logging` when doing the wasm builds for the on-chain
wasm runtime.
Besides these changes, the pr also brings most of the logging found in
frame to the same format "runtime::*".
* Update frame/im-online/src/lib.rs
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Update test-utils/runtime/Cargo.toml
* Fix test
* Don't use tracing in the runtime, as we don't support it :D
* Fixes
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* A clean new attempt
* Checkpoint to move remote.
* A lot of dependency wiring to make it feature gated.
* bad macro, bad macro.
* Undo the DB mess.
* Update frame/support/src/traits.rs
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Apply suggestions from code review
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* unbreak the build
* Better logging and ids for migrations
* Fix doc.
* Test
* Update frame/try-runtime/src/lib.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Update utils/frame/try-runtime/cli/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Update frame/try-runtime/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Address most review grumbles.
* Fix build
* Add some comments
* Remove allowing one pallet at a time.
* Rework the PR
* nit
* Slightly better error handling.
* Remove files
* Update utils/frame/remote-externalities/src/lib.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Update frame/support/src/dispatch.rs
* Update frame/support/src/dispatch.rs
* Fix test
* Make extension trait.
* Bring back try-runtime/std
* remove bincode
* Remove warning
* Change test features
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* contracts: Update README
* contracts: Add CHANGELOG.md
* contracts: Bump version to v3.0.0 and allow publish
* Typos
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Improve wording in the changelog
* contracts: Add reserved field to ContractInfoOf for future proofing
* also bump frame-benchmarking
* update lockfile
Co-authored-by: Andrew Jones <ascjones@gmail.com>
Co-authored-by: Benjamin Kampmann <ben@parity.io>
* contracts: Convert to framev2
* Reduce the API surface of the crate
* Remove unused import
* Merge import block
* Use pallet::metadata to reduce metadata diff
* Remove the explicit "Null" from AccountCounter
* contracts: Consider contract size in weights
* Bump spec version
* Whitespace fix
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Correct pre-charged code weight even in the error case
* Use the instrumented code size in weight calculation
* Charge the cost of re-instrumentation from the gas meter
* Fix benchmark
* 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
* Better documentation of return types
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* Ensure we spawn the block import worker as an essential task
This pr ensures that we spawn the block import worker as an essential
task. This is quite important as we need to bring down the node when the
block import is done. Besides that it adds some debug output to the
block import worker.
* Don't be stupid :D
* A clean new attempt
* Checkpoint to move remote.
* A lot of dependency wiring to make it feature gated.
* bad macro, bad macro.
* Undo the DB mess.
* Update frame/support/src/traits.rs
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* Apply suggestions from code review
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
* unbreak the build
* Update frame/try-runtime/src/lib.rs
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* Update utils/frame/try-runtime/cli/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Update frame/try-runtime/Cargo.toml
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Address most review grumbles.
* Fix build
* Add some comments
* Remove allowing one pallet at a time.
* More grumbles.
* relocate remote-ext
* Fix build
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Fix tracing tests (#8022)
* Fix tracing tests
The tests were not working properly.
1. Some test was setting a global subscriber, this could lead to racy
conditions with other tests.
2. A logging test called `process::exit` which is completly wrong.
* Update client/tracing/src/lib.rs
Co-authored-by: David <dvdplm@gmail.com>
* Review comments
Co-authored-by: David <dvdplm@gmail.com>
* Fix tracing spans are not being forwarded to spawned task (#8009)
* Fix tracing spans are not being forwarded to spawned task
There is a bug that tracing spans are not forwarded to spawned task. The
problem was that only the telemetry span was forwarded. The solution to
this is to use the tracing provided `in_current_span` to capture the
current active span and pass the telemetry span explictely. We will now
always enter the span when the future is polled. This is essentially the
same strategy as tracing is doing with its `Instrumented`, but now
extended for our use case with having multiple spans active.
* More tests
* Proper test for telemetry and prefix span
* WIP
* Fix test (need to create & enter the span at the same time)
* WIP
* Remove telemtry_span from sc_service config
* CLEANUP
* Update comment
* Incorrect indent
* More meaningful name
* Dedent
* Naming XD
* Attempt to make a more complete test
* lint
* Missing licenses
* Remove user data
* CLEANUP
* Apply suggestions from code review
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* CLEANUP
* Apply suggestion
* Update bin/node/cli/tests/telemetry.rs
Co-authored-by: David <dvdplm@gmail.com>
* Wrapping lines
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: David <dvdplm@gmail.com>
* Initial migration of balances pallet
* Fix some errors
* Remove unused imports
* Formatting and removing some todos
* Delete Subtrait
* Add genesis builder impls for tests
* Fix GenesisConfig impl
* Make set_balance visible to tests, rename RawEvent to Event
* Fix tests with Event rename etc.
* More test RawEvent renames
* Even more RawEvent renames
* Rename module to pallet in comments
* Add PalletInfo impl to avid storage collision, fixes tests
* Apply review suggestion: remove trailing a
Co-authored-by: David <dvdplm@gmail.com>
* BalancesEvent alias
* Remove BalancesEvent alias
* Review suggestion: remove redundant comment
* Apply review suggestion: make vis super
* Fis doc links
* Add RawEvent alias
* Add missing Instance parameter to deprecated RawEvent alias
* Fix RawEvent deprecation warnings
Co-authored-by: David <dvdplm@gmail.com>
* contracts: Implement refcounting for wasm code
* contracts: Charge rent for code storage
* contracts: Fix dispatchables erroneously refunding base costs
* Fixed typos in comments.
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Remove awkward empty line
* Fix more typos in docs
* Fix typos in docs
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Split up complicated expression
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* review: Remove unused return value
* Fix typos
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* review: Fix refcount being reset to one on re-instrumentation
* Document evictable_code parameter
* Make Executable::execute consume and store itself
* Added comments about stale values
* Disregard struct size in occupied_storage()
Co-authored-by: Andrew Jones <ascjones@gmail.com>
* Decouple the session validators from im-online
* .
* Add SessionInterface trait in im-online
Add ValidatorId in im-online Trait
Make im-online compile
Make substrate binary compile
* Fix merging issue
* Make all compile
* Fix tests
* Avoid using frame dep in primitives via pallet-session-common
* Merge ValidatorSet into SessionInterface trait
Wrap a few too long lines
Add some docs
* Move pallet-sesion-common into pallet-session
* Move SessionInterface to sp-session and impl it in session pallet
Ref https://github.com/paritytech/substrate/pull/7127#discussion_r494892472
* Split put historical::FullValidatorIdentification trait
* Fix line width
* Fix staking mock
* Fix session doc test
* Simplify <T as ValidatorIdentification<AccountId>>::ValidatorId as ValidatorId<T>
* Nits
* Clean up.
* Make it compile by commenting out report_offence_im_online bench
* Tests
* Nits
* Move OneSessionHandler to sp-session
* Fix tests
* Add some docs
* .
* Fix typo
* Rename to ValidatorSet::session_index()
* Add some more docs
* .
* Remove extra empty line
* Fix line width check
.
* Apply suggestions from code review
* Cleaup Cargo.toml
* Aura has migrated to Pallet now
Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
* Introduce a `Slot` type
Instead of having some type definition that only was used in half of the
code or directly using `u64`, this adds a new unit type wrapper `Slot`.
This makes it especially easy for the outside api to know what type is
expected/returned.
* Change epoch duratioC
* rename all instances of slot number to slot
* Make the constructor private
Co-authored-by: André Silva <andrerfosilva@gmail.com>