Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Changes from 1 commit
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
48558a2
upgrade log crate version to 0.4.13 (#285)
atenjin Jan 13, 2021
7277f7a
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Jan 14, 2021
8976227
Update
cecton Jan 20, 2021
24a3b9c
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Jan 26, 2021
095f127
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Jan 26, 2021
4b69b8d
Update Substrate & Polkadot
bkchr Jan 27, 2021
bd3697d
Tag HRMP messages as sibling for executor (#309)
akru Feb 5, 2021
4710f71
Add call to XCM Handler (#319)
shawntabrizi Feb 8, 2021
5d230a9
Use correct relative path for a parachain (#322)
vgeddes Feb 9, 2021
a5df6c9
bring in author inherent from moonbeam
JoshOrndorff Feb 12, 2021
6dcd63e
Naively brin in author filter - doesn't compile yet
JoshOrndorff Feb 12, 2021
1a9855d
MAke author filter compile (has one nasty workaround regarding random…
JoshOrndorff Feb 12, 2021
e39e924
Make the runtime compile
JoshOrndorff Feb 12, 2021
0ed4be6
ughh that was rough
JoshOrndorff Feb 12, 2021
cd1e815
Start working on chain spec
JoshOrndorff Feb 12, 2021
5f82a35
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Feb 15, 2021
fad35c2
Update Substrate & Polkadot
bkchr Feb 16, 2021
0a0dc9b
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Feb 18, 2021
8e5ca06
bring in u32 fix
JoshOrndorff Feb 18, 2021
e5f8fd4
bump polkadot ref
rphmeier Feb 18, 2021
272b0ea
Something compiles. Only alice can supply author inherent atm
JoshOrndorff Feb 18, 2021
10dbedb
Merge branch 'master' into joshy-reproduce-stall
JoshOrndorff Feb 18, 2021
85e324b
Need two authors to reproduce it clearly.
JoshOrndorff Feb 18, 2021
f01f616
clean cargo toml
JoshOrndorff Feb 18, 2021
762fff0
try to fix test. Setting it aside for now.
JoshOrndorff Feb 18, 2021
42f86ff
Merge branch 'master' into nimbus
JoshOrndorff Feb 18, 2021
3e52825
clean logging
JoshOrndorff Feb 19, 2021
8c5b09b
Merge branch 'master' into nimbus
JoshOrndorff Feb 23, 2021
bf6cd96
use debug
JoshOrndorff Feb 23, 2021
11383b4
Add both height and slot-based filters
JoshOrndorff Feb 23, 2021
d4d30b6
start sketching toward prediction runtime API
JoshOrndorff Feb 23, 2021
6718e65
fill in some blanks
JoshOrndorff Feb 23, 2021
5de12bc
Prune debugging event
JoshOrndorff Feb 23, 2021
44deeea
Implemented runtime API compiles. But does it work?
JoshOrndorff Feb 23, 2021
4e192a9
mirror changes in height filter
JoshOrndorff Feb 23, 2021
ebada41
swap over to our consensus. Ready for hacking.
JoshOrndorff Feb 23, 2021
2bf5485
update to latest polkadot & substrate
rphmeier Feb 23, 2021
cd5f356
bump polkadot and substrate
rphmeier Feb 24, 2021
313bb04
Runtime API takes author as byte array for now
JoshOrndorff Feb 28, 2021
42ca6cb
use tracing::error!
JoshOrndorff Feb 28, 2021
e9f5f7e
Merge branch 'master' into nimbus
JoshOrndorff Feb 28, 2021
db26fed
Merge branch 'master' into nimbus
JoshOrndorff Feb 28, 2021
b44b1e3
call to runtime api compiles
JoshOrndorff Feb 28, 2021
5839850
Demonstrate basic slot prediction works!
JoshOrndorff Mar 1, 2021
e5b1d6a
Wire author id into filtering consensus (doesn't compile)
JoshOrndorff Mar 2, 2021
ca111d9
Finish using generic AuthorId type. But predictions are wrong. I wond…
JoshOrndorff Mar 2, 2021
feed233
Nicer logging and comments
JoshOrndorff Mar 2, 2021
b346d58
oops, where did these files come from?
JoshOrndorff Mar 2, 2021
2ca62ab
More debugging lines - Why don't these print when authoring?
JoshOrndorff Mar 2, 2021
992a543
No need to manually init randomness. That happes for us. Substrate is…
JoshOrndorff Mar 2, 2021
92be201
vocab: staked -> active
JoshOrndorff Mar 2, 2021
49cb8dc
idea about api return type in future
JoshOrndorff Mar 2, 2021
fed6dff
actually skip ineligible slots
JoshOrndorff Mar 2, 2021
25b10e7
minor cleanup
JoshOrndorff Mar 2, 2021
23f9d3a
Add account set pallet to mock staking solution
JoshOrndorff Mar 3, 2021
2f0392b
strip account set from indiviual filters
JoshOrndorff Mar 3, 2021
a76c707
Make it compile
JoshOrndorff Mar 3, 2021
832c684
Split author checking into two parts
JoshOrndorff Mar 3, 2021
99941d3
Add an aura style filter. This really helped me see what the trait ca…
JoshOrndorff Mar 3, 2021
9563149
Clean up log target
JoshOrndorff Mar 3, 2021
a0dd25a
Same procedure as every day (#345)
bkchr Feb 25, 2021
9b0c242
master.into() // Also debugging is busted now :eye_roll:
JoshOrndorff Mar 4, 2021
5d964fb
Fix logging
JoshOrndorff Mar 5, 2021
e013781
Attach a seal
JoshOrndorff Mar 5, 2021
c2aef53
Validators can import
JoshOrndorff Mar 5, 2021
2ded56e
emojify PoV message
JoshOrndorff Mar 5, 2021
193c78a
Verifier works. Multiple paranodes are now supported!
JoshOrndorff Mar 5, 2021
3aea792
comment
JoshOrndorff Mar 5, 2021
dc3caf0
docs
JoshOrndorff Mar 5, 2021
31a7192
typos
JoshOrndorff Mar 5, 2021
dd05793
typo
JoshOrndorff Mar 5, 2021
7151180
Merge branch 'master' into nimbus
JoshOrndorff Mar 8, 2021
c76d151
fix build
JoshOrndorff Mar 8, 2021
3628b5d
shelve the return reason idea
JoshOrndorff Mar 8, 2021
3da7868
Wire keystore into nimbus consensus
JoshOrndorff Mar 8, 2021
492c474
Notes on experimental success
JoshOrndorff Mar 8, 2021
54af784
Abstract over AuthorId type in runtime (client not yet done)
JoshOrndorff Mar 8, 2021
d44f294
Decisions, direction, thoughts after being stuck yesterday
JoshOrndorff Mar 9, 2021
4f2c058
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Mar 9, 2021
288f10c
Update chain specs
bkchr Mar 9, 2021
eb0932f
Use keystore to check for available keys (compiles, not yet tested)
JoshOrndorff Mar 10, 2021
4c2e286
Don't also use the old inherent provider.
JoshOrndorff Mar 10, 2021
c87ee2e
Idea and some minor docs
JoshOrndorff Mar 10, 2021
5c3a224
Change inherent data type to AuthorId. It now compiles and "works". B…
JoshOrndorff Mar 10, 2021
ab0609e
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Mar 10, 2021
24b1ee6
Update Substrate to include some commit
bkchr Mar 10, 2021
8771d94
Update Cargo.lock
bkchr Mar 18, 2021
c9b1fe3
Update Substrate & Polkadot
bkchr Mar 19, 2021
0b8b7fa
Update Substrate & Polkadot
bkchr Mar 22, 2021
33decd6
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Mar 23, 2021
90b1e18
Genesis time
bkchr Mar 23, 2021
10887b7
bump rococo-v1 polkadot
rphmeier Mar 24, 2021
b011122
bump rococo-v1 polkadot
rphmeier Mar 25, 2021
9d89ed6
update collator protocol to take full key
rphmeier Mar 25, 2021
0b4097c
Make it compile on rococo-v1
JoshOrndorff Mar 25, 2021
01752d1
Hook up XcmHandler to the system module (#381)
pepyakin Mar 30, 2021
d38fa53
Add spambot
gavofyork Mar 30, 2021
28f5ec2
Fixes
gavofyork Mar 30, 2021
2fc85fd
Add some extra functions to spambot, bump version
gavofyork Mar 30, 2021
9e09dd0
Fix build
bkchr Mar 31, 2021
7bea3f7
Aggregate HRMP (XCMP/HMP) messages. Payloads for spambot.
gavofyork Mar 31, 2021
8ce15c8
Merge branch 'rococo-v1' of github.com:paritytech/cumulus into rococo-v1
gavofyork Apr 1, 2021
deda3da
Fix tests, bump Polkadot.
gavofyork Apr 1, 2021
dfe1848
Fix HMP tests
gavofyork Apr 1, 2021
b9b9cbd
Rename Hrmp -> Xcmp for handler/sender
gavofyork Apr 1, 2021
b07e041
bump rococo-v1
rphmeier Apr 3, 2021
2d0aade
bump Polkadot and Substrate refs
rphmeier Apr 3, 2021
d7068cc
update polkadot commit ref
rphmeier Apr 4, 2021
3a205e3
bump polkadot ref
rphmeier Apr 5, 2021
85bc817
Update Substrate
bkchr Apr 6, 2021
fd007bb
Improve Storage and Add `set_upgrade_block` to Validation Function Up…
shawntabrizi Mar 31, 2021
2384c2e
bump refs
rphmeier Apr 6, 2021
ce8589a
Update Substrate & Polkadot (#387)
bkchr Apr 2, 2021
2a4769c
Merge branch 'rococo-v1' of https://github.com/paritytech/cumulus int…
rphmeier Apr 6, 2021
dc37cbf
bump spec version
rphmeier Apr 6, 2021
6a75df1
bump refs
rphmeier Apr 6, 2021
651abce
New genesis
bkchr Apr 6, 2021
c5be730
bump refs
rphmeier Apr 7, 2021
519403c
bump refs again
rphmeier Apr 8, 2021
72bcc4a
remove real-overseer and bump refs
rphmeier Apr 8, 2021
5b2393e
bump refs again
rphmeier Apr 8, 2021
aa0f10d
bump refs
rphmeier Apr 9, 2021
b225faf
make test-service compile
rphmeier Apr 9, 2021
8ecbe78
bump refs to include code compression
rphmeier Apr 9, 2021
67f973b
Approve block announcements of backed blocks
bkchr Apr 10, 2021
facd422
Approve block announcement if it comes from the best known block
bkchr Apr 11, 2021
dcf8dc9
Remove pov hash comparison when waiting on a block to announce
bkchr Apr 11, 2021
3db8a38
Fix compilation
bkchr Apr 11, 2021
6ed9632
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Apr 14, 2021
da4c3ba
Merge remote-tracking branch 'origin/master' into rococo-v1
bkchr Apr 27, 2021
fdc45a1
rococo-v1.into() // Doesn't compile yet, but geting close. This is a …
JoshOrndorff Apr 28, 2021
8b6f136
make it compile
JoshOrndorff Apr 28, 2021
80642e2
rebrand as nimbus consensus
JoshOrndorff Apr 28, 2021
9d2b145
start stripping colaltor key flag pathway
JoshOrndorff Apr 28, 2021
2d13f4a
finish stripping manually passed author id
JoshOrndorff Apr 28, 2021
9fcbd01
add polkadot launch config
JoshOrndorff Apr 28, 2021
8f78a4f
relax bounds on author_inherent::Config::AuthorId
JoshOrndorff May 4, 2021
53dd615
fix author inherent tests
JoshOrndorff May 4, 2021
b5a61b6
AuthorInherent: Add test for bad origin
JoshOrndorff May 4, 2021
3289b17
standardize sp-std dependency
JoshOrndorff May 4, 2021
1aebed7
Clean AURA docs for better community understanding
JoshOrndorff May 5, 2021
ded3b22
better trait bounds for inherent data provider
JoshOrndorff May 5, 2021
96b95c5
tiny spacing fixes
JoshOrndorff May 5, 2021
48b8bd8
Make runtime API generic
JoshOrndorff May 5, 2021
d099c83
better primitves crate
JoshOrndorff May 6, 2021
8ea2162
update readme
JoshOrndorff May 6, 2021
fdd6f60
comment about pre-validation possibility
JoshOrndorff May 6, 2021
9e4d721
fix polkadot launch config
JoshOrndorff May 6, 2021
4f287c7
clean up some outdated comments
JoshOrndorff May 6, 2021
0102d7a
remove stray println
JoshOrndorff May 6, 2021
b9a3fa3
clean up a bunch of warnings
JoshOrndorff May 6, 2021
cd68f7a
move executor into pallet author inherent for better reuse.
JoshOrndorff May 7, 2021
061a3aa
begin reworking CanAuthor trait
JoshOrndorff May 10, 2021
e57a477
Remove long-outdated todo
JoshOrndorff May 11, 2021
aea3072
update account-set
JoshOrndorff May 11, 2021
567baf1
runtime compiles
JoshOrndorff May 11, 2021
1a4f022
proper runtime api imp ready for 🖨️🍝
JoshOrndorff May 11, 2021
62d7ec8
sketch a height beacon thatobviates the author height filter
JoshOrndorff May 11, 2021
93d36bb
move SlotBeacon impls to library crate.
JoshOrndorff May 11, 2021
e62db11
move EventHandler to primitives
JoshOrndorff May 12, 2021
bb8fd65
oops missed tihs one
JoshOrndorff May 12, 2021
d3c8613
Note about how inherents are gong to change.
JoshOrndorff May 12, 2021
8f972e7
tiny renaming in primitives
JoshOrndorff May 12, 2021
9f16c89
Don't "check" author inherent
JoshOrndorff May 12, 2021
5e35708
Nicer logging when no keys are available
JoshOrndorff May 12, 2021
60863fb
Collators sign blocks (but don't include sign and nobody checks it)
JoshOrndorff May 12, 2021
c724635
shorten runtime line
JoshOrndorff May 12, 2021
43af6e8
Switch branches
bkchr May 13, 2021
95d81d4
Fix chain spec handling
bkchr May 13, 2021
8dec150
Blocks are now signed, but verifier fails to validate signatures.
JoshOrndorff May 13, 2021
d589570
Signatures now verify on parachain nodes, (not yet on validators)
JoshOrndorff May 13, 2021
0f6397d
checkpoint toward validators checking signatures
JoshOrndorff May 13, 2021
38aacdd
checkpoint
JoshOrndorff May 13, 2021
ac97775
clear outdated comment
JoshOrndorff May 14, 2021
9056a63
Signature verification seems working on validators (gotta make sure)
JoshOrndorff May 14, 2021
838c2b2
clean up custom executor
JoshOrndorff May 14, 2021
3a24da8
Move engine id to primitives
JoshOrndorff May 14, 2021
627210d
Sketch CompatibleDigestItem trait, but don't use it yet
JoshOrndorff May 14, 2021
95b0faa
cleanup percent handling
JoshOrndorff May 14, 2021
c6744d7
update comment
JoshOrndorff May 14, 2021
4b2c515
Introduce `CollectCollationInfo` runtime api (#443)
bkchr May 17, 2021
a25daae
Merge branch 'polkadot-v0.9.1' into nimbus
notlesh May 17, 2021
9c30e45
Fix a couple fallouts from merge
notlesh May 17, 2021
c0949ab
Use substrate's polkadot-v0.9.1 branch
notlesh May 18, 2021
5526fe8
Update Cargo.lock
notlesh May 18, 2021
12d3ddd
Remove duplicated code
notlesh May 18, 2021
25e1a91
`nimbus-consensus` crate compiles
JoshOrndorff May 19, 2021
da6c83f
pallet-author-inherent compiles, primitives kinda sketched
JoshOrndorff May 19, 2021
0881b2e
Rococo parachains runtime compiles
JoshOrndorff May 19, 2021
032170d
Fix some build-dependency weirdnes
JoshOrndorff May 19, 2021
33b4e07
rename to nimbus runtime
JoshOrndorff May 20, 2021
6382bf0
Restore original aura runtime, both compile
JoshOrndorff May 20, 2021
421cd78
Whole project checks again, still no nimbus service
JoshOrndorff May 20, 2021
c31fc93
add function get_nimbus_spec
JoshOrndorff May 20, 2021
1bda44b
sketch command.rs
JoshOrndorff May 20, 2021
7bfd973
sketch `build_import_queue` function
JoshOrndorff May 20, 2021
579d803
update `nimbus-consensus` crate for author inehrent
JoshOrndorff May 20, 2021
a228d02
update `nimbus-primitives`. Hoope the new Send + Sync bounds are okay
JoshOrndorff May 20, 2021
8106d06
everything compiles
JoshOrndorff May 20, 2021
f8c91f2
update launch config (but polkadot launch is not working so far)
JoshOrndorff May 20, 2021
3a136c3
Fix chain spec name and id
JoshOrndorff May 20, 2021
0c5deec
make signature line debug
JoshOrndorff May 20, 2021
aefa55a
Update from polkadot-v0.9.1 -> polkadot-v0.9.2
notlesh May 20, 2021
4b71206
Update branch
bkchr May 21, 2021
cd50542
Merge branch 'polkadot-v0.9.2' into notlesh-nimbus-merge-polkadot-v0.9.2
notlesh May 21, 2021
5635eb7
Add XcmReserveTransferFilter
notlesh May 21, 2021
0877d5e
slap another runtime_version on
JoshOrndorff May 21, 2021
01c2c1e
Associated type for AccoutnLookup.
JoshOrndorff May 24, 2021
c14fd33
Fix genesis config
JoshOrndorff May 24, 2021
e1cdc0c
Remove unused PreliminaryCanAuthor
JoshOrndorff May 24, 2021
00deb5d
Merge branch 'master' into nimbus
JoshOrndorff Jun 7, 2021
eee182f
ParachainBlockImport
JoshOrndorff Jun 7, 2021
f7e2da9
MAke it build
JoshOrndorff Jun 7, 2021
e04181f
fix function naming
JoshOrndorff Jun 7, 2021
4af429e
restore accidentally removed line
JoshOrndorff Jun 7, 2021
7b2c27e
clean outdated comment
JoshOrndorff Jun 7, 2021
0e97258
prune accidentally-added old code
JoshOrndorff Jun 7, 2021
ad58a6f
fix licenses
JoshOrndorff Jun 7, 2021
1771700
cleanup stray commetn
JoshOrndorff Jun 7, 2021
7ccae4e
prune more accidentally re-added code
JoshOrndorff Jun 7, 2021
a5a1c8f
restore standard parachain system lib.rs
JoshOrndorff Jun 7, 2021
9bd4b0d
restore more accidentally-modified files
JoshOrndorff Jun 7, 2021
ea6d132
update commetn
JoshOrndorff Jun 7, 2021
678110f
more cleaning
JoshOrndorff Jun 7, 2021
bc29491
Clean outdated todo
JoshOrndorff Jun 7, 2021
128bbde
cleanup the primitives
JoshOrndorff Jun 7, 2021
20c0e89
Readme in proper place
JoshOrndorff Jun 8, 2021
3815bc4
move account_set to runtime because it should not be copied.
JoshOrndorff Jun 8, 2021
f47d019
Merge commit 'd935b81e7010fcf5c5639e238c78d865c1d6ed67' into nimbus
JoshOrndorff Jun 8, 2021
fb44a30
Merge branch 'master' into nimbus
JoshOrndorff Jun 8, 2021
c2c0b06
remove outdated comment
JoshOrndorff Jun 8, 2021
e640c58
Remove unnecessary hooks and calls
JoshOrndorff Jun 9, 2021
27ba896
Merge branch 'master' into nimbus
JoshOrndorff Jun 14, 2021
730801c
Sketch `CheckInherents`
JoshOrndorff Jun 14, 2021
43d9613
fix warning
JoshOrndorff Jun 14, 2021
65cc3f2
fix and expand long-neglected tests
JoshOrndorff Jun 14, 2021
d2d5af8
Merge branch 'master' into nimbus
JoshOrndorff Jun 18, 2021
6fb9cb3
fix build
JoshOrndorff Jun 22, 2021
3ea480e
Merge branch 'master' into nimbus
JoshOrndorff Jun 22, 2021
6e1dc41
Merge branch 'master' into nimbus
JoshOrndorff Jul 6, 2021
fc7c3ec
impl<T: BlockNumberProvider> SlotBeacon for T
JoshOrndorff Jul 7, 2021
37c38f2
Merge branch 'master' into nimbus
JoshOrndorff Jul 8, 2021
6e4f2b3
Fix prediction initialization from Substrate#8953
JoshOrndorff Jul 9, 2021
8dc44a8
Actually fix prediction properly
JoshOrndorff Jul 9, 2021
0b44d91
`AuthorFilterAPI` versioning
tgmichel Jul 19, 2021
11a4f8a
Fix error handling
tgmichel Jul 19, 2021
9218cef
Fix `ApiRef` re-use
tgmichel Jul 20, 2021
50302c5
Merge commit '4f936689ef3bb503c60694561bddac1db11b2181' into nimbus
JoshOrndorff Aug 21, 2021
7c5c282
Make it build
JoshOrndorff Aug 21, 2021
c0ae4a1
skip_prediction feature.
JoshOrndorff Aug 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs
  • Loading branch information
JoshOrndorff committed Mar 5, 2021
commit dc3caf00efeaf47792204acdcb2f61bb81a1ec04
288 changes: 183 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,201 @@
# Cumulus :cloud:

A set of tools for writing [Substrate](https://substrate.dev/)-based
[Polkadot](https://wiki.polkadot.network/en/)
[parachains](https://wiki.polkadot.network/docs/en/learn-parachains). Refer to the included
[overview](docs/overview.md) for architectural details, and the
[Cumulus workshop](https://substrate.dev/cumulus-workshop) for a hand-holding walkthrough
of using these tools.

It's easy to write blockchains using Substrate, and the overhead of writing parachains'
distribution, p2p, database, and synchronization layers should be just as low. This project aims to
make it easy to write parachains for Polkadot by leveraging the power of Substrate.

Cumulus clouds are shaped sort of like dots; together they form a system that is intricate,
beautiful and functional.

## Consensus

[`cumulus-consensus`](consensus) is a
[consensus engine](https://substrate.dev/docs/en/knowledgebase/advanced/consensus) for Substrate
that follows a Polkadot
[relay chain](https://wiki.polkadot.network/docs/en/learn-architecture#relay-chain). This will run a
Polkadot node internally, and dictate to the client and synchronization algorithms which chain to
follow,
[finalize](https://wiki.polkadot.network/docs/en/learn-consensus#probabilistic-vs-provable-finality),
and treat as best.

## Collator

A Polkadot [collator](https://wiki.polkadot.network/docs/en/learn-collator) for the parachain is
implemented by [`cumulus-collator`](collator).

# Rococo :crown:

[Rococo](https://polkadot.js.org/apps/?rpc=wss://rococo-rpc.polkadot.io) is the testnet for
parachains. It currently runs the parachains
[Tick](https://polkadot.js.org/apps/?rpc=wss://tick-rpc.polkadot.io),
[Trick](https://polkadot.js.org/apps/?rpc=wss://trick-rpc.polkadot.io) and
[Track](https://polkadot.js.org/apps/?rpc=wss://track-rpc.polkadot.io).

Rococo is an elaborate style of design and the name describes the painstaking effort that has gone
into this project. Tick, Trick and Track are the German names for the cartoon ducks known to English
speakers as Huey, Dewey and Louie.

## Build & Launch Rococo Collators

Collators are similar to validators in the relay chain. These nodes build the blocks that will
eventually be included by the relay chain for a parachain.

To run a Rococo collator you will need to compile the following binary:

```
cargo build --release -p rococo-collator
```

Once the executable is built, launch collators for each parachain (repeat once each for chain
`tick`, `trick`, `track`):

```
./target/release/rococo-collator --chain $CHAIN --validator
# Cumulo -- Nimbus ⛈️

Nimbus is a set of tools for building and testing parachain consensus systems on [cumulus](https://github.com/paritytech/cumulus)-based parachains.

Given the regular six-second pulse-like nature of the relay chain, it is natural to think about slot-
based consensus algorithms for parachains. The parachain network is responsible for liveness and
decetralization and the relay chain is responsible for finality. There is a rich design space for such
algorithms, yet some tasks are common to all (or most) or them. These common tasks include:

Signing and signature checking blocks
Injecting authorship information into the parachain
Block authorship and import accounting
Filtering a large (potentially unbounded) set of potential authors to a smaller (but still potentially unbounded) set.
Detecting when it is your turn to author an skipping other slots

Nimbus aims to provide standard implementations for the logistical parts of such consensus engines,
along with helpful traits for implementing the parts that researchers and developers want to customize.

## Try the Demo

While Nimbus is primarily a developer toolkit meant to be included in other projects, it is useful
to see a basic node in action. A example node is included in the `rococo-parachains` directory. You
can build it with `cargo build --release` and launch it like any other cumulus parachian.

Rather than re-iterate how to start a relay-para network here, I'll simply recommend you use the
excellent [Polkadot Launch](https://github.com/paritytech/polkadot-launch) tool.

TODO, provide a config file in this repo.

To learn more about launching relay-para networks, check out the [cumulus workshop](https://substrate.dev/cumulus-workshop)

## Design Overview

This section gives an overview of the architecture and design decisions in Nimubs. If you want to start
using Nimbus in your project, it is worth reading this.

### Author Inherent

The Author inherent pallet provides an inherent in which block authors can insert their identity into
the runtime. It also includes an inherent data provider for the client-side node to create the appropriate
inherents. This feature alone is useful in many blockchains and can be used for things like block rewards.
This piece can be used alone without any other parts of nimbus if all you desire is authoring information
in the runtime.

The author inherent provides two hooks called `PreliminaryCanAuthor` and `FullCanAuthor`. The
preliminary check will be run by non-authoring nodes before importing a block to quickly rule out some
invalid authors. This check should be cheap and should not depend on other runtime state. The full
check will be called during the inherent execution and is the final say for whether an author is eligible.
The preliminary check may rule out authors, but does not guarantee eligibility. Said another way, it
may give false positives, but never false negatives. These two hooks are both optional. If you don't
want to restrict authorship at all, you can just use `()`.

As a concrete example, in a Proof of Stake system the preliminary check may make sure that the claimed
author is staked at all, and if not, they are obviously ineligible. Then the full check will determine
whether the author is eligible at this particular slot. It is possible to be staked without being eligible
at this slot. Because the slot-eligibility depends on other runtime state, that check must be deferred.

Finally, the pallet copies the authorship information into a consensus digest that will stick around
in the block header. This digest can be used by UIs to display the author, and also by the consensus
engine to verify the block authorship.

**Security Notice** If you use the author inhernet alone, the authorship information is not proven,
rather it is a claim by the block author. It is entirely possible that a dishonest node may insert
someone else's identity via the author inherent. In some cases (famously bitcoin), this is all that's
desired. When used in this mode it is more common to use the term "beneficiary" than "author". If you
want your authorship information to be proven, you will need to use more parts of Nimbus; read on.

### Author Filters

Many consensus engines will want to restrict which authors can author. Some may have a static set, others
may rotate the set each era, others may elect an always-changing subset of all potential authors. There
is much space for creativity, research, and design, and Nimbus strives to provide a flexible interface
for this creative work. In the majority of cases, you can express all the interesting parts of your
consensus engine simply by implementing the correct filters. The rest of Nimubs will #JustWork for you.

The repository comes with a few example filters already. The examples are:
* Height filter - This filter takes a finite set (eg a staked set) and filters it down to a pseudo-random
subset at each height. The eligible ratio is configurable in the pallet. This is a good learning example
but not secure, because the authors only rotate at each parachain block. Therefore a small colluding
minority of authors could stall the chain.
* Slot filter - Similar to the height filter, but it uses entropy (currently just the block height,
but in the future the relay randomness beacon) to change the elected subset each time the relay chain
authors a block even if the parachain doesn't author. This avoids the stall mentioned previously.
* Aura - The authority round consensus engine is popular in the Substrate ecosystem because it was one
of the first (and simplest!) engines implemented in Substrate. Aura can be expressed in the Nimbus
filter framework and is included as an example filter.

### Author Filter Runtime API

Nimbus makes the design choice to include the final author checking logic in the runtime. This makes
it relatively straight forward (but still not entirely straight forward; read on) for relay chain validators
to check the authorship information. This is in contrast to the existing implementation of Aura and Babe
where the authorship checks are offchain. Because the checks happen in the runtime, authoring nodes would
need to author complete blocks to learn whether they are eligible. This is inefficient, and leads to
confusing logs for users.

Authoring nodes (collators) should be smart enough to predict whether they will be eligible, and not
author at all if they are ineligible. To achieve this, we provide a runtime API that will allow collator
nodes to call into the runtime, and make the minimal calculation necessary to determine whether they will
be eligible. If they aren't they skip the slot saving energy and keeping the logs free of confusing errors.

### Nimbus Consensus
(currently called filtering consensus in the code. TODO change that)

Nimbus consensus is the primary client-side consensus worker. It implements the shiny new `ParachainConsensus`
trait introduced to cumulus in https://github.com/paritytech/cumulus/pull/329 It is not likely that
you will need to change this code directly to implement your engine as it is entirely abstracted over
the filters you use. The consensus engine performs these tasks:

* Slot prediction - it calls the runtime API mentioned previously to determine whether ti is eligible. If not, it returns early.
* Authorship - It calls into a standard Substrate proposer to construct a block (probably including the author inherent).
* Self import - it imports the block that the proposer created (called the pre-block) into the node's local database.
* Sealing - It adds a seal digest to the block - This is what is used by other nodes to verify the authorship information.
**Warning, the seal does not yet conatain a cryptographic signature; it is just mocked. That is one of the next tasks.**

### Verifier and Import Queue

For a parachain node to import a sealed block authored by one of its peers, it needs to remove the post-
runtime seal digest and check it (same in a standalone blockchain). This is the job of the verifier. It
will remove the nimbus seal and compare it to the nimbus consensus digest from the runtime. If that process fails,
the block is immediately thrown away before the expensive execution even begins. If it succeeds, then
the pre-block (the part that's left after the seal is stripped) is passed into the
[import pipeline](https://substrate.dev/docs/en/knowledgebase/advanced/block-import) for processing
and execution. Finally, the locally produced result is compared to the result received across the network.

### Custom Block Executor

We've already discussed how parachain nodes (both the one that authors a block, and also its peers)
import blocks. In a standalone blockchain, that's the end of the story. But for a parachain, we also
need our relay chain validators to re-execute and validate the parachain block. Validators do this in
a unique way, and entirely in wasm. Providing the `validate_block` function that the validators use
is the job of the `register_validate_block!` macro from Cumulus.

Typically a cumulus runtime invokes that macro like this:
```rust
cumulus_pallet_parachain_system::register_validate_block!(Runtime, Executive);
```

## Parachains
You can see that the validators use the exact same executive that the parachain nodes do. Now that
we have sealed blocks, that must change. The validators need to strip and verify the seal, and re-execute
the pre-block just like the parachain nodes did. And without access to an offchain verifier, they must
do this all in the runtime. For that purpose, we provide and alternate executive which wraps the normal
FRAME executive. The wrapper strips and checks the seal, just like the verifier did, and then and then
passes the pre-block to the inner FRAME executive for re-execution.

The parachains of Rococo all use the same runtime code. The only difference between them is the
parachain ID used for registration with the relay chain:
## Write Your Own Consensus Logic

- Tick: 100
- Trick: 110
- Track: 120
If you have an idea for a new slot-based parachain consensus algorithm, Nimbus is a quick way to get
it working! The fastest way to start hacking is to fork this repo and customize the template node.

The network uses horizontal message passing (HRMP) to enable communication between parachains and
the relay chain and, in turn, between parachains. This means that every message is sent to the relay
chain, and from the relay chain to its destination parachain.
If you'd rather dive in than read one more sentence, then **start hacking in the `author-slot-filter`
pallet.**

## Launch a local setup including a Relay Chain and a Parachain
In most cases, you can use all the off-the-shelf components and simply write your filters. It is also
possible to compose existing filters to build more complex logic from smaller pieces. (composition
interface is subject to change though.)

### Launch the Relay Chain
## Authoring and Import Diagrams

```bash
# Compile Polkadot with the real overseer feature
git clone https://github.com/paritytech/polkadot
git fetch
git checkout rococo-v1
cargo build --release --features=real-overseer
TODO, these should help explain the various processes and how they are coordinated.

# Generate a raw chain spec
./target/release/polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > rococo-local-cfde-real-overseer.json
The gist: One node authors the block, then it is processed in three different ways.

# Alice
./target/release/polkadot --chain rococo-local-cfde-real-overseer.json --alice --tmp
| | Author | Parachain Peer | Relay Validator |
| ------------------- | ------ | -------------- | --------- |
| Predict Eligibility | ✅ | ❌ | ❌ |
| Author Block | ✅ | ❌ | ❌ |
| Runs Verifier | ❌ | ✅ | ❌ |
| Import Pipeline | ✅ | ✅ | ❌ |
| Custom Pre exec | ❌ | ❌ | ✅ |
| Normal FRAME exec | ✅ | ✅ | ✅ |

# Bob (In a separate terminal)
./target/release/polkadot --chain rococo-local-cfde-real-overseer.json --bob --tmp --port 30334
```
## Roadmap

### Launch the Parachain
The Nimbus tools are intended to be standalone and loosely coupled with Cumulus. That goal is realistic
in the medium term (~ a month or two) but during the initial development, it is easier to work as a fork
of the upstream cumulus repository.

```bash
# Compile
git clone https://github.com/paritytech/cumulus
git fetch
git checkout rococo-v1
cargo build --release
Once the core features are complete, and the line is more clear between what belongs in cumulus vs
nimbus, the repos can be separated.

# Export genesis state
# --parachain-id 200 as an example that can be chosen freely. Make sure to everywhere use the same parachain id
./target/release/rococo-collator export-genesis-state --parachain-id 200 > genesis-state
### Core Features Needed
* Author info in seal, and basic seal checking
* Keystore integration
* Cryptographic block signatures
* Filter pallet refactor -- What is common and what needs re-implemented by each author.

# Export genesis wasm
./target/release/rococo-collator export-genesis-wasm > genesis-wasm
### Additional features for maybe someday
* Share code between verifier and wrapper executive
* Maybe moonbeam's dev service should live with nimbus??
* Aurand as an example of composing filters?
* Two different filter traits?
* Current one: Propositional logic style (good for unbounded sets)
* New one: Returns concrete author sets (good for index-based stuff like aura)

# Collator1
./target/release/rococo-collator --collator --tmp --parachain-id <parachain_id_u32_type_range> --port 40335 --ws-port 9946 -- --execution wasm --chain ../polkadot/rococo-local-cfde-real-overseer.json --port 30335
## Contributions Welcome

# Collator2
./target/release/rococo-collator --collator --tmp --parachain-id <parachain_id_u32_type_range> --port 40336 --ws-port 9947 -- --execution wasm --chain ../polkadot/rococo-local-cfde-real-overseer.json --port 30336
Try it out, open issues, submit PRs, review code. Whether you like to tinker with a running node, or
analyze security from an academic perspective, your contributions are welcome.

# Parachain Full Node 1
./target/release/rococo-collator --tmp --parachain-id <parachain_id_u32_type_range> --port 40337 --ws-port 9948 -- --execution wasm --chain ../polkadot/rococo-local-cfde-real-overseer.json --port 30337
```
### Register the parachain
![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png)
I would be happy to support users who want to use nimbus, or want feedback on their consensus engines.