Commit Graph

52 Commits

Author SHA1 Message Date
Alexander Popiak e304662f04 Upstream Statemine Release v5 Changes to Master (#720)
* Update references

* update deps

* set substrate deps for pallet-asset-tx-payment

* add DisabledValidatorsThreshold to parachain template

* add DisabledValidatorsThreshold to statemint runtimes

* adjust imports

* update Cargo-lock

* add DisabledValidatorsThreshold to mock config

* cargo +nightly fmt

* adjust on_disabled type

* remove on_chain_votes function in ParachainHost impl

* remove ScrapedOnChainVotes

* bump polkadot-collator version

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* update Cargo.lock

* set spec_versions to 500

* Statemine cannot execute.

* disallow XCM execute on statemint

* cargo fmt

* remove unnecessary dep on node-primitives

* select parachains-common/std feature when building rococo-runtime with std

* adjust Statemint to the three digit spec_version format

* Add script to generate simple changelogs (#668)

* Update weights from v4 for v5 comparison (#673)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* Fix benchmarks after Parachain Template (#677)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* benchmarks fix for parachain template

* Weights updates for Statemine v5 (#682)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* weights updates for statemine v5

* mention Storage in construct_runtime macro for pallet-xcm (#680)

* Use pallet-xcm for version wrapping (#689)

* use PolkadotXcm for XcmRouter WrapVersion

* use PolkadotXcm for version wrapping

Co-authored-by: Bryan Chen <xlchen1291@gmail.com>

* patch weight for batch_all from rerun

* Runtime version bump to v503 (#694)

* adjust genesis value generation scripts to output entries array + add script to derive encoded call

* add script to generate shell spec from runtime wasm

* Ensure a bad datastream cannot cause problems (#701)

* Ensure a bad datastream cannot cause problems

* Formatting

* Formatting

* update Polkadot (to 0.9.11 169bab55d)

* bump spec versions

* Allow Queries and Subscriptions

Fixes

Formatting

* fix build

* make fmt happy

* statemint imports

* slight naming changes in script

* add shell genesis data + wasm + chainspec

* adjust generated shell spec with production config values

* update Substrate and Polkadot to master

* fix deps

* swap out bootnodes for statemint shell

* add a script for verifying the shell chain spec

* add sha checksum for head data

* remove verification script

* remove hex wasm file

* update Substrate and Polkadot again and fix compilation

* update and fix lock file

* formatting

* remove redundant dispatch_as weight

Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: Gav Wood <gavin@parity.io>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Bryan Chen <xlchen1291@gmail.com>
Co-authored-by: joepetrowski <joe@parity.io>
2021-11-08 15:52:47 +01:00
Sergei Shulepov 9379cd6c18 Look at the upgrade go-ahead and restriction signals (#517)
* Look at the upgrade go-ahead and restriction signals

* Update Cargo.toml

* Drop old docs for validation code

* Update tests

* Fix typo

* Add doc-comments for read_optional_entry

* Add a note about ValidationData

* Introduce migration for removing unused storage entry

* Fix indentation

* Use intra-doc link syntax

* Double-check that GoAhead signal is not spurious

* fmt

* Drop commented code

* Fix typos

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

* Add a weight for StorageVersion write

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Chris Sosnin <chris125_@live.com>
Co-authored-by: Chris Sosnin <48099298+slumber@users.noreply.github.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-10-12 18:08:23 +02:00
Bastian Köcher 0fad3ae44c Same procedure as not every day (#636)
* Same procedure as not every day

* Remove warning

* Update
2021-10-01 13:23:56 +02:00
Keith Yeung 1aab3349cc Use DecodeLimit for decoding XCM messages (#605)
* Use DecodeLimit for decoding XCM messages

* Use decode_all_with_depth_limit in appropriate places

* Use decode_all while decoding byte vector

* cargo fmt
2021-09-19 15:29:34 +03:00
Chevdor 1dd000a011 ci: add quick-check with rustfmt (#615)
* ci: add quick-check with clippy and rustfmt

* chore: rustfmt round

* chore: set the same rustfmt config than substrate

* chore: fix formatting

* cI: remove clippy

* ci: switch to nightly for the checks

* ci: fix toolchains and naming

* ci: Limit the check to formatting

* chore: fix formatting

* Update .rustfmt.toml

* Update .rustfmt.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-09-16 16:57:52 +02:00
Andrew Jones 035a576008 Metadata v14 (companion to #3336) (#564)
* Remove event pallet::metadata attributes

* Add scale-info deps, TypeInfo derives, update call variants

* Update metadata runtime APIs

* Add missing scale_info dependency, update rococo runtime API

* Add missing scale_info dependency

* Remove pushed diener patches

* Cargo.lock

* Add missing scale-info dependencies

* Fixes

* Statemint runtime fixes

* Call struct variant empty matches

* Add missing scale-info dependency

* Fixes

* scale-info 1.0

* cargo update -p xcm

* update lock

* Update Cargo.lock

* update to latest polkadot

* remove rpc_http_threads

https://github.com/paritytech/substrate/pull/9737

* replace task executor with tokio handler

https://github.com/paritytech/substrate/pull/9737

* fix test compilation?

* Update Cargo.lock

* cargo update

* remove unused

* Update substrate and polkadot

* Update test/client/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-09-16 12:11:05 +02:00
Squirrel a0532634e1 less deps (#606) 2021-09-12 23:22:14 +02:00
Gavin Wood 276e5bdd38 Companion for #3629 (XCM v2) (#571)
* Update .gitignore and bring into line with XCM v2's SendError

* type

* Some work

* Weighed responses

* extra fields to xcm pallet

* Fixes

* Bump
2021-08-28 15:51:49 +02:00
Keith Yeung 906bf97321 Use new MultiLocation syntax everywhere (#570)
* Use new MultiLocation syntax everywhere

* Make tests compile
2021-08-12 11:26:49 +02:00
Gavin Wood b3c38f0926 Companion to #9514 (Remove Filter and use Contains instead) (#566)
* Remove Filter and use Contains instead

* Fixes

* Remove patch

* Bump Polkadot

* bump
2021-08-09 18:07:37 +02:00
Gavin Wood 6283c1fce9 Support XCM v1 (Companion to #2815) (#561)
* support for XCM v1

* Fixes

* Fix.

* Use `xcm::latest`

* Bump Polkadot

Co-authored-by: Bastian Köcher <info@kchr.de>
2021-08-06 19:13:33 +00:00
Shaun Wang 47b368ea5c Polkadot companion (XCM-simulator) (#560)
* Use definitions from polkadot.

* Remove unused imports.

* Rerun CI.
2021-08-05 08:43:51 +02:00
Bastian Köcher d0b57c1ad4 Update Substrate & Polkadot (#523) 2021-07-05 23:35:28 +02:00
Joshy Orndorff 1bb5e2ae4b Adds a mock provider for the parachain inherent (#484)
* Bring in code from moonbeam

* move it to mock.rs

* Actually build it 🤦
2021-06-23 10:37:50 +02:00
Bastian Köcher d3b4279f14 Adds support for checking the timestamp inherent while validating a block (#494)
* Adds support for checking the timestamp inherent while validating a block

This adds support for checking the timestamp inherent while validating a
block. This will use the relay chain slot number * relay chain slot
duration to calculate a timestamp. This timestamp is used to check the
timestamp in the timestamp inherent.

* Update polkadot-parachains/rococo-runtime/src/lib.rs

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

* Update polkadot-parachains/statemine-runtime/src/lib.rs

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

* Update primitives/timestamp/src/lib.rs

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

* Fix warnings

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
2021-06-16 10:53:47 +02:00
Bastian Köcher d54fdd788e Bring support for calling check_inherents (#490)
* Start

* More work

* Add proc-macro for `validate_block`

* Make everything compile

* Add some test
2021-06-12 20:21:46 +02:00
Bastian Köcher 2f88be0874 Use polkadot-client instead of polkadot service where possible (#489) 2021-06-11 12:56:14 +02:00
cheme d935b81e70 Compact proof. (#295)
* compact, need to be made optional and look into/compress child trie
roots/state.

* proto with child trie support

* Missing set_offchain_storage overload.

* right name

* Ignore offchain indexing in validation function.

* patch trie-db

* decompress from iter

* use compressed proof

* remove wasm blob from proof (no inject plugged yet)

* change lock

* update trie

* change in toml

* Revert "change in toml"

This reverts commit aa5c56850ef461ce3cb774213a92af4b1dd6cee5.

* use patch to branches

* i

* i:wq

* switch branch

* ii

* ok, needed to patch the runtime by putting substrate patch in polkadot
project.

* test passing with this conf

* actual lazy code fetch

* patch issue

* Code reorg

* restore commented tests.

* update deps.

* remove polka patch

* fixes

* remove patch

* revert cargo.lock

* cargo update -p sp-trie polkadot-service

* fix collator test (using parent state root).

* Update pallets/parachain-system/src/validate_block/implementation.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove encode_witness test function.

* Update pallets/parachain-system/src/validate_block/implementation.rs

* Fix compilation

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Bastian Köcher <info@kchr.de>
2021-06-08 11:51:32 +02:00
Bastian Köcher 7ffb205b0d Pov recovery for parachains (#445)
* Start with a failing integration test & some refactorings

* More work

* Make it "work"

* Add `NullConsensus` for the test

* More refactorings

* Move stuff over to its own crate

* Refactorings

* Integrate it into `service` and make the test working

* Docs and some exit condition

* Use the real import queue

* Fix tests

* Update client/pov-recovery/src/active_candidate_recovery.rs

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>

* Fetch slot duration from the relay chain

* Docs

* Fixes

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
2021-05-26 15:02:42 +02:00
Bastian Köcher 6674430f6e Introduce CollectCollationInfo runtime api (#443)
* Introduce `CollectCollationInfo` runtime api

Instead of using well known keys to communicate information about a
collation between the runtime and the collator, we now use a runtime api
for this.

* Fixes bug

* Apply suggestions from code review

Co-authored-by: Sergei Shulepov <sergei@parity.io>

* Doc update

Co-authored-by: Sergei Shulepov <sergei@parity.io>
2021-05-17 16:33:33 +02:00
Bastian Köcher d01bc247cb Aura consensus for parachains (#371)
* Update polkadot

* Migrate all uses of MQC heads to merkle proofs

* Mass rename `relay_parent_storage_root`

* Restore parachain-system tests

* Update polkadot and libp2p swarm for testing

* Collapse match into an if let

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Start with something

* Update Substrate & Polkadot

* Start to make it compile

* Make it compile

* Begin with something

* Yep

* I'm a hacker

* Bring back the builder

* Make it work in some way

* Compile

* Parachains use their own "slot"

* Adds cumulus-pallet-aura

* Wrap AuRa import queue to disable equivocation checking by default

* Pass slot duration

* Check the seal when validating a block

* Adds missing file

* Try to make the seal working

* Fix it

* Some fixes

* Bring in the latest features to cleanup the code

* Update and make it compile

* Improve the import

* Start fixing

* More work

* Fix fix fix

* Make everything compile

* Small cleanups

* Rename and more docs

* Docs

* Fixes fixes fixes

* Update rococo-parachains/src/chain_spec.rs

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

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

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

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

* Update primitives/parachain-inherent/Cargo.toml

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

* Update primitives/parachain-inherent/Cargo.toml

* Update primitives/parachain-inherent/Cargo.toml

* Update primitives/parachain-inherent/Cargo.toml

Co-authored-by: Sergei Shulepov <sergei@parity.io>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
2021-05-10 14:43:00 +02:00
Gavin Wood 3f687171c2 DMP Queue pallet (#416)
* Introduce the converter into the hub

* Parachain recognises Rococo governance body as admin

* Whitespace

* Use UsingComponents for fee payment in XCM

* Fixes

* Fixes for XCM permissions

* Remove encode_call test

* Fixes

* Rococo Collator supports Shell runtime

* Fixes

* Fixes

* Initial draft of DMP Queue pallet

* DMP Queue builds.

* Companion for Polkadot gav-allow-xcm-exec

* Bump

* Fix std

* Fixes

* fix and improve docs

* fix compile errors in tests

* add test for try_service_message

* update cargo.lock

* Fixes

* Make test name read well

* Fixes

* Add a couple of simple tests

* Tests

* Tests

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Chain ID and ParaID don't collide

* Fixes

* Update pallets/dmp-queue/src/lib.rs

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

* Update pallets/dmp-queue/src/lib.rs

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

* Fixes

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-05-02 16:11:58 +02:00
Gavin Wood 5fe32eb0d4 XCM revamp & Ping pallet (#391)
* Add spambot

* Fixes

* Add some extra functions to spambot, bump version

* Lock..

* Aggregate HRMP (XCMP/HMP) messages. Payloads for spambot.

* Fix tests, bump Polkadot.

* Fix HMP tests

* Rename Hrmp -> Xcmp for handler/sender

* Use master branch

* Test Xcm message passing & rename away from HMP

* Docs

* Introduce fee payment mechanics into XCM.

* Rename spambot -> ping

* Lock

* XCMP message dispatch system reimagining

- Moved most of the logic into xcm-handler pallet
- Altered the outgoing XCMP API from push to pull
- Changed underlying outgoing queue data structures to avoid multi-page read/writes
- Introduced queuing for incoming messages
- Introduced signal messages as a flow-control sub-stream
- Introduced flow-control with basic threshold back-pressure
- Introduced overall weight limitation on messages executed
- Additonal alterations to XCM APIs for the new system

* Should process any remaining XCM messages when we're not doing anything else.

* Update API usage and preparation for the big build.

* Some build fixes

* Build fixes

* xcm-handler builds

* Fix warnings

* Docs

* Parachains system builds

* Parachain runtime building

* Fix build

* Introduce transfer_asset specialisation.

* Fixes

* Two-stage upgrade for parachains.

* Fixes

* Fixes

* Updates for message sending.

* Repotting/renaming. Add primitives/utility.

* Remove real-overseer and bump refs

* Configure & document Rococo XCM runtime.

* Add shell runtime, some companion changes for #8589

* Bumps & fixes

* Fix test

* Build fix

* Update pallets/xcmp-queue/src/lib.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* Make tests compile

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* remove unused

* remove unused event stuff

* Adds proper validation-worker to make integration tests work

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* import saturating

* remove panic test

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <info@kchr.de>
2021-04-14 09:36:59 +02:00
Cecile Tonglet 5cdbd7c42d Add a command to purge the relay chain only (#306)
* Add a command to purge the relay chain only

* WIP

* Update rococo-parachains/src/cli.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Move cli stuff to its own crate

* Copyright dates

* Test not working for some reason...

* WIP

* Revert "WIP"

This reverts commit f97cd63742c7df822e4a6e52a29db5e0f56b7bfa.

* Fix test to use provided relay chain

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Add hint about which database could not be purged

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-03-03 13:40:22 +01:00
Bastian Köcher f511757069 Change the way we store, handle and validate the validation data (#342)
Currently validation data is shared by using a well known key between
the parachain system pallet and the validate block implementation. This
pr changes this by passing the parachain system directly to the validate
block implementation to make use of it. Besides that, we also store the
validation params in some thread local variable to make it inspectable
by parachain system. This moves the validation of validation data and
validation params to the parachain system pallet directly, instead of
having this hidden inside the validate block implementation.

Fixes: https://github.com/paritytech/cumulus/issues/217
2021-02-27 18:46:25 +01:00
Bastian Köcher 886a1e1c76 Move parachain inherent data into its own crate (#326)
This renames and moves the `SystemInherentData` into its own crate.
The struct is now called `ParachainInherentData`. Besides moving the
struct, this also moves the code for creating this struct into this crate.
2021-02-11 13:05:17 +01:00
Bastian Köcher fbacfe7937 The great refactor (#325)
* Move pallets to pallets folder and rename them

* Move genesis file to service

* Rename primitives to primitives-core

* Delete cumulus-runtime

* Move stuff to client folder and rename
2021-02-10 13:07:21 +01:00
Sergei Shulepov 309bc92b78 MQC authorization (#308)
* MQC auth

Update polkadot

WIP

* Update polkadot

* Silly syntax errors

* Fix typo

* Leave some comments and docs

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Introduce the MessageQueueChain structure

* Move the HRMP channel relevance check below

* Fix the `receive_hrmp_after_pause` test

* ValidationData is passed by reference

* Replace "to cumulus" with "to the collator"

* Update the test so that they are same as in polkadot

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-02-02 18:12:20 +00:00
Cecile Tonglet 6438d328b8 Complete telemetry for parachain & relaychain (#301)
* Complete telemetry for parachain & relaychain

* Update Substrate & Polkadot
2021-01-29 16:02:31 +01:00
Sergei Shulepov b5f6580da1 parachain-system (#296)
* rename parachain-{upgrade -> system}

* Merge message-broker into parachain-system

* Remove message-broker and clean up

* Update docs

* Test upward messages sending

And also update the relay-sproof-builder so that it allows to set the
relay dispatch queue size for the given parachain.

* Test horizontal message sending

* Remove old inherent definitions
2021-01-21 15:53:00 +01:00
Sergei Shulepov d6a7bc4e30 Replace ValidationData with PersistedValidationData (#291)
* Replace ValidationData with PersistedValidationData

* Update polkadot
2021-01-19 15:20:12 +01:00
Black3HDF 8b815c759b eliminate space (#288) 2021-01-14 17:06:57 +01:00
Sergei Shulepov 464e54affd Inform the PVF with the latest relevant relay chain state (#279)
* Update polkadot

* Extend cumulus primitives with some relay chain exports

Follow https://github.com/paritytech/polkadot/pull/2194 to see the
polkadot PR

* collator: collect the state proof

This commit changes cumulus-collator so that it takes the relay chain
state at the relay parent and creates a storage proof that contains all
the required data for PVF.

* parachain-upgrade: use the proofs instead

This change is needed to make cumulus logic to not longer depend on the
transient validation data. As part of this change, in order to preserve
the current behavior `code_upgrade_allowed` now is computed on the
parachain side, rather than provided by polkadot.

Turned out that this requires to know the self parachain id so it was
added where needed.

* message-broker: use relay state to track limits

this should make sending messages safe from accidentally running over
the relay chain limits that were previously unknown.

* Update polkadot

So that `relay_storage_root` is available through `ValidationParams`

* Check `relay_storage_root` matches expected

Check that `relay_storage_root` submitted by the collator matches the
one that we receive in `validate_block` through `ValidationParams`

* Add a missing check for `dmq_mqc_head` while we are at it

* Update polkadot

* Fix tests that use the relay storage root

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update message-broker/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove unneeded (&_)

* Fix unwraps

* Polish basti's suggestion

* Fix merge

* Bring back the System::can_set_code check

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-01-13 14:40:26 +01:00
Sergei Shulepov 0a5b53cdce Plumb polkadot backend into cumulus-collator (#269)
* The problem in the nutshell

* Make it compile

* make tests pass

* Update the parachain-upgrade module

* Fix collator tests

Co-authored-by: Bastian Köcher <git@kchr.de>
2020-12-21 20:27:54 +01:00
Shawn Tabrizi 4f1c6baf8e Add XCM Handler (#267)
* initial mock

* integrate xcm-handler into runtime

* expose xcm send error

* oops

* better comment
2020-12-17 18:42:00 +01:00
Alexander Krupenkin a060991bbe Update to latest polkadot & substrate (#266) 2020-12-16 10:50:05 +01:00
Sergei Shulepov aba8f46ec9 Integrate HRMP (#258)
* HRMP message ingestion

* Plumb hrmp_watermark to build_collation

* Plumb hrmp_watermark to ValidationResult

* Plumb hrmp outbound messages

* Implement message-broker part of HRMP

* Kill UPWARD_MESSAGES as well

Otherwise, they will get resent each block

* Add sudo versions for easier testing

* Remove the xcmp module

Not useful for the moment

* Doc for HRMP message handler

* Estimate the weight upper bound for on_finalize

* Remove a redundant type annotation

* fix spelling of a method

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Deabbreviate dmp and hrmp in the message ingestion type

* Don't use binary_search since it's broken by a following rotate

Instead use the linear search. We can afford linear search here since
due to limited scalability of HRMP we can only have at most a couple of
dozens of channels.

* Fix the watermark

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-12-15 04:42:31 +00:00
Bastian Köcher 63efcc49c3 Wait for relay chain block import before validatiing a block announcement (#227)
* Start with something

* Whatever

* Update

* MOARE

* Make cumulus-network compile and tests work

* Update more and fixes

* More stuff

* More fixes

* Make collator build

* Make test almost work

* Remove contracts runtime

* More test work

* Make service compile

* Fix test-service

* Fix test client

* More fixes

* Fix collator test

* Fix network tests (again)

* Make everything compile, finally

* Fix tests

* Write test that should fail

* Add `WaitOnRelayChainBlock`

* Update git versions

* Make it all work

* Update logging

* Switch to provided method for pushing an extrinsic

* Try to debug CI

* Aaaa

* Only use Debug

* Updates

* Use native execution to hopefully make CI happy...
2020-11-23 00:21:02 +01:00
Sergei Shulepov 0239b58e84 Integrate UMP into message-broker (#244) 2020-11-20 21:32:58 +01:00
Sergei Shulepov f92e41925f Resurrect (a minimal version of) message-broker (#234)
This is mostly a copy of the predating version with exception of some
renaming and alterations (e.g. the message handler takes an inbound
downward message by value, not by reference).
2020-11-16 14:18:46 +01:00
Sergei Shulepov 572b4710d6 Integrate DMP into collation, take 2 (#233)
* Integrate DMP into collation

* Integrate processed_downward_messages as well
2020-11-11 12:27:09 +01:00
Bastian Köcher 182109ef5f Switch to polkadot master branch (#230)
* Switch to polkadot master branch

* Fix compilation
2020-11-09 13:05:00 +01:00
Bastian Köcher 76f9ecae47 Update Cumulus for Parachains V1 (#224)
* Start with something

* Whatever

* Update

* MOARE

* Make cumulus-network compile and tests work

* Update more and fixes

* More stuff

* More fixes

* Make collator build

* Make test almost work

* Remove contracts runtime

* More test work

* Make service compile

* Fix test-service

* Fix test client

* More fixes

* Fix collator test

* Fix network tests (again)

* Make everything compile, finally

* Fix tests

* Update to latest masters

* Remove ignore

* Switch to different branch in polkadot for now

* Update reference

* Make it compile with latest changes

* Update collator/src/lib.rs

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>

* Update to latest upstream

* Update to latest master

* Fix test

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
2020-11-08 22:18:09 +01:00
Cecile Tonglet 4d150a0199 Uniformize tests (#220)
* Initial commit

Forked at: 5bbab68f02
Parent branch: origin/master

* Copy runtime module from rococo

Forked at: 5bbab68f02
Parent branch: origin/master

* Also copy dependencies pallets and primitives

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* test-service

* Move integration test

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* Not sure what went wrong...

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* fmt

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* Remove pallet contracts (not used)

* Remove pallet parachain-info and token-dealer (not used)

* Sort dependencies alphabetically

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* CumulusTestNode for testing

* Speed up block generation

* Fix improper shutdown

* rustfmt

* runtime: replace const by storage

* Fix for previous commit

* Remove some generics

* Move generate_genesis_state to cumulus-primitives

* fmt

* Remove message_example

* fixup! Remove message_example

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* Half the solution to previous commit :(

* Revert "Fix for previous commit"

This reverts commit 60010bab6797487093ac8c790b3a536f7ca0895b.

* Revert "runtime: replace const by storage"

This reverts commit c64b3a46f0325a98922015e0cbf3570e2e431774.

Not working for some reason...

* Use helper

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* Remove test-primitives

* Revert "Half the solution to previous commit :("

This reverts commit 9a8f89f9f06252198e6405057043c6b313f1aea4.

* Revert "Revert "Half the solution to previous commit :(""

This reverts commit 6a93f0f09d74ccdc3738dd78a777c483427c03ce.

* Test with some extra extrinsics

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* WIP

Forked at: 5bbab68f02
Parent branch: origin/master

* CLEANUP

Forked at: 5bbab68f02
Parent branch: origin/master

* Remove message broker
2020-10-07 08:51:01 +00:00
Bastian Köcher 6f50d0928d Add parachains for rococo (#144)
* Add parachains for rococo

* Fix chain specs

* Update to revert log rotation

* Support selecting the chain in `export-genesis-state`

* Add subcommand for exporting the genesis wasm of a Parachain

* Update stuff

* Fix `export-genesis-wasm`

* Update the polkadot ref

* Add bootNodes address

* Add bootNodes address - track

* Add bootNodes address - trick

* Fix incorrect peer id (trick)

* Fixes https://github.com/paritytech/cumulus/issues/157

* Update chainspecs

* Update specs again

* Set correct sudo account

* Update properties

* Update readme

* Update `Cargo.lock`

* Switch to rococo-branch

Co-authored-by: Evaldo <contato@evaldofelipe.com>
Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com>
2020-08-04 17:33:20 +02:00
Cecile Tonglet f26dd45e78 Collate only if --validator is given (#161) 2020-07-29 20:49:31 +02:00
Bastian Köcher 62c22b88b9 Implement basic upward & downward messages (#118)
* Start by replacing branch names and set `DownwardMessage`

* Add the upward-message crate

* Add Kusama & Polkadot

* More work on getting the upward messages working

* Fix build

* Begin to integrate it into the test Parachain

* Update

* Make everything compile again

* Switch to westend and print parachain account on startup

* Use MultiSignature etc

* Fix validate block

* Some downward messages work

* Update git reference

* More downward messages integration

* Update test runtime for downward messages

* Enable downward message handler and withdraw send tokens

* Add some docs

* Begin to implement simple XCMP

* More work

* Fixes and make parachain id configurable

* Make parachain ID be part of the genesis

* Finishing the XCMP message demo

* Update and fixes tests

* Update branch
2020-06-18 12:10:20 +02:00
Cecile Tonglet 1afdba7464 Reject blocks without justification which don't have the best number (#105)
* Initial commit

Forked at: 8f02e233da
Parent branch: origin/master

* Reject blocks without justification

* Revert "Reject blocks without justification"

This reverts commit ee60e12097939d4ccfe987a71db9a876319ae5ba.

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* CLEANUP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* CLEANUP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* WIP

Forked at: 8f02e233da
Parent branch: origin/master

* Move HeadData to primitives

* Update network/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update network/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* CLEANUP

Forked at: 8f02e233da
Parent branch: origin/master

* fix

* CLEANUP

Forked at: 8f02e233da
Parent branch: origin/master

* messages

* for the greater good

* Update primitives/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update network/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update network/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update network/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-06-03 14:15:52 +02:00
Bastian Köcher e183d8bd30 Put cumulus-parachain-upgrade into the test parachain (#98)
This ensures that the crate compiles for `no_std`. Besides this, there
are some fixes to the crate code itself.
2020-05-15 16:10:22 +02:00
Peter Goodspeed-Niklaus 45a7fe2a94 runtime upgrade (#70)
* Initial commit

* Update to 3e65111

* Add cfg_attr ... no_std

* Fix version

* WIP: add really simple validate_block insert validity check

* WIP: create a parachain upgrade pallet

This pallet will eventually make life much easier for people attempting
to upgrade parachains on their validator nodes, but for the moment,
key sections remain unimplemented while dependency details are worked
out.

* Implement basic admin-auth pallet functionality.

This compiles, which means it's probably mostly correct. However,
it's pretty far from being finished. Work yet to come:

- Integrate with the democracy pallet somehow to eliminate the
  requirement for the root user to initiate this process.
- Figure out what to do in the event that the parachain blocks
  and relay chain blocks get out of sync / delayed.
- Add testing... somehow. (What's reasonable to test?)

Open questions:

- Is the block number parameter in `on_initialize` the parachain
  block number, or the relay chain block number? If, as I suspect,
  it's the parachain block number, how do we deal with the fact that
  the real upgrade should happen on a very specific parachain block
  number?
- In line 68, is it reasonable to use `if n >= apply_block`, or should
  that line require strict equality?
- Is it reasonable to store/retrieve `CurrentBlockNumber` on every block,
  or is there a more streamlined way to pass that data between functions?
  Maybe it can be inserted into `struct Module` somehow?
- Can we somehow parametrize ValidationUpgradeDelayBlocks by T in
  order to eliminate the `.into()` call?

* use a better storage name

* Add checks ensuring runtime versions increase

Largely cribbed from https://github.com/paritytech/substrate/blob/a439a7aa5a9a3df2a42d9b25ea04288d3a0866e8/frame/system/src/lib.rs#L467-L494

* fix tests

* WIP: add tests from frame/system set_code

Currently doesn't build: line 230 is the problem. Removing or
commenting that line results in the new tests failing due to a
missing block number. Adding it, in an attempt to fix the problem,
fails to compile with this error:

```
   Compiling parachain-upgrade-pallet v2.0.0 (/home/coriolinus/Documents/Projects/coriolinus/parachain-upgrade-pallet)
error[E0599]: no function or associated item named `set_block_number` found for struct `Module<tests::Test>` in the current scope
   --> src/lib.rs:230:21
    |
47  | / decl_module! {
48  | |     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
49  | |         // Initializing events
50  | |         // this is needed only if you are using events in your pallet
...   |
100 | |     }
101 | | }
    | |_- function or associated item `set_block_number` not found for this
...
230 |               System::set_block_number(123);
    |                       ^^^^^^^^^^^^^^^^
    |                       |
    |                       function or associated item not found in `Module<tests::Test>`
    |                       help: there is a method with a similar name: `current_block_number`
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `parachain-upgrade-pallet`.
```

That error is very weird, because the function does in fact exist:
https://github.com/paritytech/substrate/blob/a439a7aa5a9a3df2a42d9b25ea04288d3a0866e8/frame/system/src/lib.rs#L897

* cause tests to pass

Turns out that in fact there was some setup required in order to
get everything testing properly, but now we have a set of passing
unit tests which test some of the more common error cases.

* Add overlapping upgrades test

This currently fails, and I don't yet know why. TODO!

* Fix some logic errors

- In particular, only remove the pending validation function from
  storage when it's time to apply it.
- Don't store our own copy of the current block number.

* WIP: delegate most code upgrade permissions checks

They're defined in System::can_set_code, so may as well use them.

Unfortunately, the tests all fail for this right now, and I don't
yet understand why. Pushing to get immutable line number references.

* fix tests after delegating runtime checks to can_set_code

* WIP: events test

Right now, the events struct doesn't seem to contain enough information
to validate the particular events that we should have fired. Almost
certainly, this is a usage error on my part.

* fully initialize and finalize in event test

This doesn't change the results, though.

* fix events test

This was complicated to figure out. For the record, testing events
requires:

- a private module which publicly exports the crate's event type
- impl_outer_event macro to construct an enum wrapping the event
  types from the listed modules
- system::Trait and local Trait both declare `type Event = TestEvent;`
- (optional) group events with `System::<Test>::initialize(...)` and
  `System::<Test>::finalize()` calls.

It's not entirely clear why both events show up during the initialization
phase; my suspicion is that this is an artifact of not mocking a
particular extrinsic, such that they end up in initialization by default.

* cleanup and move crate to subdirectory

this prepares us to merge this pallet into the cumulus repo

* provisionally incorporate polkadot changes to hook everything together

This feels like the logical next step, and compiles, at least. Still,
there are some big TODOs remaining:

- merge the polkadot PR upstream and reset the polkadot branch in
  `runtime/Cargo.toml`
- in `runtime/src/validate_block/implementation.rs:116`, we should
  almost certainly return `Some(something)` sometime. When, precisely,
  and how to keep track of the appropriate data are all still open
  questions.

* WIP: further updates to work with the polkadot implementation

Hopefully we can upstream `ValidationFunctionParams` into the
polkadot trait defs so we can just copy the struct out of
`ValidationParams`, but no huge loss if not.

This should be more or less everything required at this level.
Next up: fix up `pallet-parachain-upgrade` so it reads from
`VALIDATION_FUNCTION_PARAMS` to determine upgrade legality and
upgrade block, and writes to `NEW_VALIDATION_CODE` when appropriate.

* update pallet-parachain-upgrade appropriately to handle new expectations

Implements the pallet side of the new flow. Basic tests appear to work.

Next up:

- make the "real blob" test work
- add a bunch of additional tests of all the corners

* remove test which set a real WASM blob

This test didn't directly test any of the code in this pallet;
it existed because we were just copying tests out of the substrate
implementation. Now that we have real code of our own to test,
(and because it's not compatible with the `BlockTests` abstraction,)
we don't need that test anymore.

Also added a `Drop` impl to `BlockTests` ensuring they get run at
least once.

* add test that storage gets manipulated as expected

* get validate_block tests compiling again

* Check validation function size against polkadot parameters

Generate a user-handlable error message if it's too big, so that
nothing panics later.

* demonstrate that block tests run

* don't actually store any magic values in parachain storage

We're allowed to use it as a transport layer between validate_block
and the parachain upgrade pallet, but actually editing it or, in
particular, attempting to persist data there which didn't originate
in the extrinsic, breaks things.

This means that we can't keep the :code insertion check, because
the validate_block layer doesn't know when it is legal to actually
upgrade the parachain. However, the rest of the features survive,
and all tests currently pass, so I'm counting it as a win.

Next up: look into adding an inherent which publishes the
ValidationFunctionParams struct to arbitrary pallets.

* Add reference to polkadot_client to Collator

This enables us to get the validation function parameters at
runtime, which unblocks creating an inherent containing them.

* remove unused imports

* Remove VFPX; build VFP from existing data structures

I almost don't want to know how long both global_validation
and local_validation have existed in the produce_candidate
function signature; they were precisely what I needed,
without needing to add anything to the Collator struct at all.

Oh well, at least I noticed it before putting the PR up for review.

Next up: create a proper inherent definition for the
ValidationFunctionParams.

* WIP: add cumulus-validation-function-params crate

Modeled on the substrate timestamp crate.
It's not currently obvious to me why it is desirable to publish
an entire crate for what amounts to a single const definition;
going to ask about that.

* refactor: get rid of validation-function-params crate

Everything about the VFPs has been moved into a module of runtime

* WIP: get VFP from inherent, when possible

Doesn't compile for weird trait errors; probable next steps: just
copy over the relevant code directly.

* ensure VFPs are available during block production and validation

* cleanup in preparation for review request

* Copy cumulus-primitives crate from bkchr-message-broker

That branch is visible as #80; this message copies the crate as of
d4b2045573796955de4e5bf8f74b6c48b44c3bee.

This isn't even a cherry-pick, because the commit which introduced
the primitives crate also did some work which from the perspective
of this PR is irrelevant. With any luck, by coping the crate directly,
there won't be too many merge conflicts when the second of these
open PRs is merged.

* move mod validation_function_params to cumulus_primitives

There is some very weird behavior going on with cargo check: every
individual crate checks out fine, as verified with this invocation:

for crate in $(fd Cargo.toml | xargs dirname); do
    if [ "$crate" == . ] || [[ "$crate" == *test* ]]; then continue; fi;
    name=$(toml2json "$crate/Cargo.toml" | jq -r '.package.name')
    if ! cargo check -p "$name" >/dev/null 2>/dev/null; then
        echo "failed to build $name"
    fi
done

However, `cargo check .` no longer works; it is suddenly demanding
clang in order to build an indirect dependency. I'm not going to
keep messing around with this anymore; it's more profitable for the
moment to knock out the rest of the requested changes. Still, this
behavior is weird enough that I really don't have any idea why
it might be happening.

* convert indentation to tabs

* rename parachain upgrade pallet per PR review

* use compact form for dependencies

* remove pallet readme

Move pertinent documentation into pallet's rustdoc.

* Add weight data in compliance with updated substrate requirements

The substrate API changed, so now we _have_ to invent some kind of
weight data for the dispatchables. This commit does so, with the
caveat that the numbers are pulled straight out of nowhere. Benchmarking
remains a TODO item.

* use anonymous fatal error type for brevity

* Create, use a Call for setting VFPs

Modeled on Timestamp; makes the ProvideInherent impl work much better.

* fix pallet tests

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* fix formatting

* add license header

* refactor primitive inherents / keys into appropriate modules

* impl From<(GlobalValidationSchedule, LocalValidationData)> for ValidationFunctionParams

* extract inherent data vfp injection into a function

* collapse parachain dependency into compact form

* always store vfps under same storage key

* fix docs

* use minimum weight for VFP inherent

* rename module methods for clarity

* fix tests: set_code -> schedule_upgrade

* Apply pending validation function at inherent creation, not init

Initialization happens before inherent creation, which means that
at the time of `on_initialize`, the VFPs for the current block
have not yet been loaded. This is a problem, because it means that
updates would happen one block late, every time.

Moving that logic into inherent creation means that we always have
current information to work with.

* typo: default_features -> default-features

* do not panic in create_inherent

* revert f741cf0f2bc; don't change behavior, but use correct spelling

* move block initialization logic from inherent creation into the inherent

* re-disable default features

It is very difficult to come up with a coherent theory of what's
going on with these default features. Builds were all broken as of
3eb1618. Renaming them in f741cf0 seemed to fix that behavior.
Then they broke again locally, prompting aaee1c0. This commit
restores the status quo as of f741cf0; with any luck, the build
will succeed both locally and in CI.

* regenerate Cargo.lock

This updates several packages, but by inspection, they are all published
crates from crates.io; by semver, this should not cause any behavioral
changes.

This also updates the lockfile format to the new format.

The point of this commit is to deal with the fact that `sc-client`
no longer exists.

* fix checks given new dependencies

Appropriate weight declarations have changed; this follows them,
still using timestamp examples.

Note that these weights are almost certainly wrong.

* fix tests given new dependencies

* add another check preventing block VFPs from contaminating validity checks

* Add OnValidationFunctionParams trait so other modules can callback

There isn't yet an obvious use case for other modules to get the
validation function params from this one, but we may as well support
it on the off chance.

* Add get_validation_function_params

This getter allows other modules to simply get the validation
function parameters, if they have been updated for this block.
Otherwise, it returns None, and they can try again later.

* upgrade substrate: panic on div by 0

* Apply whitespace suggestions from code review

These suggestions should make no semantic difference.

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply semantic from code review

These changes affect the semantics of the code; I'll follow up by ensuring that everything still works.

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* add documentation to ValidationFunction type

* removing panicing private fn validation_function_params()

* expect validation function params to be in inherent data

* move OnValidationFunctionParams to primitives

* resolve weird formatting

* move mod validation_function_params into its own file

* add license to new file

Co-authored-by: Ricardo Rius <ricardo@parity.io>
Co-authored-by: Ricardo Rius <9488369+riusricardo@users.noreply.github.com>
Co-authored-by: Joshy Orndorff <admin@joshyorndorff.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-05-05 16:00:43 +02:00