Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Tendermint implementation #145

Merged
merged 206 commits into from
Dec 3, 2022
Merged
Changes from 1 commit
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
b56c884
Machine without timeouts
kayabaNerve Oct 3, 2022
d081934
Time code
kayabaNerve Oct 13, 2022
ccd4ef1
Move substrate/consensus/tendermint to substrate/tendermint
kayabaNerve Oct 16, 2022
1237c41
Delete the old paper doc
kayabaNerve Oct 16, 2022
a5f1dda
Refactor out external parts to generics
kayabaNerve Oct 16, 2022
f793212
Refactor <V, B> to type V, type B
kayabaNerve Oct 16, 2022
77ba1c0
Successfully compiling
kayabaNerve Oct 16, 2022
079eee9
Calculate timeouts
kayabaNerve Oct 16, 2022
3b2352b
Fix test
kayabaNerve Oct 16, 2022
c53c15f
Finish timeouts
kayabaNerve Oct 16, 2022
a0bc9dc
Misc cleanup
kayabaNerve Oct 16, 2022
85962c0
Define a signature scheme trait
kayabaNerve Oct 16, 2022
987aa51
Implement serialization via parity's scale codec
kayabaNerve Oct 16, 2022
329a48c
Implement usage of the signature scheme
kayabaNerve Oct 16, 2022
1c71e25
Make the infinite test non-infinite
kayabaNerve Oct 16, 2022
b993ff1
Provide a dedicated signature in Precommit of just the block hash
kayabaNerve Oct 17, 2022
6155d12
Dedicated Commit object
kayabaNerve Oct 17, 2022
0501ff2
Tidy README
kayabaNerve Oct 17, 2022
f28d412
Document tendermint
kayabaNerve Oct 17, 2022
5724f52
Sign the ID directly instead of its SCALE encoding
kayabaNerve Oct 17, 2022
8b6eb11
Litany of bug fixes
kayabaNerve Oct 17, 2022
6b56510
Remove async recursion
kayabaNerve Oct 17, 2022
ff41e9f
Correct timing issues
kayabaNerve Oct 20, 2022
cc8284a
Merge branch 'develop' into tendermint
kayabaNerve Oct 20, 2022
3c6ea6e
Replace MultiSignature with sr25519::Signature
kayabaNerve Oct 20, 2022
9db42f7
Minor SignatureScheme API changes
kayabaNerve Oct 20, 2022
975c9d7
Map TM SignatureScheme to Substrate's sr25519
kayabaNerve Oct 20, 2022
eb59dd5
Initial work on an import queue
kayabaNerve Oct 20, 2022
49a26e5
Properly use check_block
kayabaNerve Oct 20, 2022
2806831
Rename import to import_queue
kayabaNerve Oct 20, 2022
5c46edb
Implement tendermint_machine::Block for Substrate Blocks
kayabaNerve Oct 21, 2022
2cf1573
Dummy Weights
kayabaNerve Oct 21, 2022
56afb13
Move documentation to the top of the file
kayabaNerve Oct 21, 2022
bdd0b42
Move logic into TendermintImport itself
kayabaNerve Oct 21, 2022
3b08633
BlockImport, JustificationImport, Verifier, and import_queue function
kayabaNerve Oct 21, 2022
c0432e1
Update consensus/lib.rs from PoW to Tendermint
kayabaNerve Oct 21, 2022
976948e
Update Cargo.tomls for substrate packages
kayabaNerve Oct 21, 2022
fcb9148
Merge branch 'develop' into tendermint
kayabaNerve Oct 21, 2022
123b8ad
Tendermint SelectChain
kayabaNerve Oct 21, 2022
b8bff65
Move the node over to the new SelectChain
kayabaNerve Oct 21, 2022
f153235
Merge branch 'develop' into tendermint
kayabaNerve Oct 21, 2022
0a58d66
Minor tweaks
kayabaNerve Oct 21, 2022
0218db0
Update SelectChain documentation
kayabaNerve Oct 21, 2022
802f873
Remove substrate/node lib.rs
kayabaNerve Oct 21, 2022
5019f4c
Remove unused macro_use
kayabaNerve Oct 21, 2022
422f7e3
Replace panicking todos with stubs and // TODO
kayabaNerve Oct 22, 2022
4bfc8d7
Reduce chain_spec and use more accurate naming
kayabaNerve Oct 22, 2022
e8df74e
Merge branch 'develop' into tendermint
kayabaNerve Oct 22, 2022
adfc9a5
Merge branch 'develop' into tendermint
kayabaNerve Oct 22, 2022
bf5bdb8
Implement block proposal logic
kayabaNerve Oct 22, 2022
5e52817
Modularize to get_proposal
kayabaNerve Oct 22, 2022
8ed0f1f
Trigger block importing
kayabaNerve Oct 22, 2022
193281e
Get the result of block importing
kayabaNerve Oct 22, 2022
39984bd
Split import_queue into a series of files
kayabaNerve Oct 22, 2022
9b0dca0
Provide a way to create the machine
kayabaNerve Oct 22, 2022
4206ed3
Don't import justifications multiple times
kayabaNerve Oct 22, 2022
dee6993
Correct justication import pipeline
kayabaNerve Oct 22, 2022
8a682cd
Announce blocks
kayabaNerve Oct 22, 2022
e8e490d
Add an assert to verify proposed children aren't best
kayabaNerve Oct 22, 2022
4859e8c
Merge branch 'develop' into tendermint
kayabaNerve Oct 24, 2022
b6dddc4
Consolidate C and I generics into a TendermintClient trait alias
kayabaNerve Oct 24, 2022
78fa292
Expand sanity checks
kayabaNerve Oct 24, 2022
b9c091c
When resetting, use the end time of the round which was committed to
kayabaNerve Oct 24, 2022
a7f4804
Move Commit from including the round to including the round's end_time
kayabaNerve Oct 24, 2022
b5cb8a9
Add a TODO on Tendermint
kayabaNerve Oct 24, 2022
05be5c1
Misc bug fixes
kayabaNerve Oct 24, 2022
9b8f2f4
More misc bug fixes
kayabaNerve Oct 24, 2022
5839f44
Clean up lock acquisition
kayabaNerve Oct 25, 2022
285152b
Merge weights and signing scheme into validators, documenting needed …
kayabaNerve Oct 25, 2022
49ab262
Add pallet sessions to runtime, create pallet-tendermint
kayabaNerve Oct 27, 2022
fa7a03b
Update node to use pallet sessions
kayabaNerve Oct 27, 2022
eb41844
Update support URL
kayabaNerve Oct 27, 2022
4c2dd9b
Partial work on correcting pallet calls
kayabaNerve Oct 27, 2022
66f7663
Redo Tendermint folder structure
kayabaNerve Oct 27, 2022
5c08fa9
TendermintApi, compilation fixes
kayabaNerve Oct 27, 2022
f91c081
Fix the stub round robin
kayabaNerve Oct 27, 2022
aec3637
Merge branch 'develop' into tendermint
kayabaNerve Oct 29, 2022
b17aac4
Merge branch 'develop' into tendermint
kayabaNerve Oct 29, 2022
c4c3dcd
Merge branch 'develop' into tendermint
kayabaNerve Oct 29, 2022
a0c892d
Use the validators list from the session pallet
kayabaNerve Oct 29, 2022
f31c457
Merge branch 'develop' into tendermint
kayabaNerve Oct 29, 2022
9a54317
Basic Gossip Validator
kayabaNerve Oct 30, 2022
8d3efd6
Correct Substrate Tendermint start block
kayabaNerve Oct 30, 2022
6838d5c
Clean generics in Tendermint with a monolith with associated types
kayabaNerve Oct 30, 2022
edb2e00
Remove the Future triggering the machine for an async fn
kayabaNerve Oct 30, 2022
1af6117
Move TendermintMachine from start_num, time to last_num, time
kayabaNerve Oct 30, 2022
6c54289
Connect the Tendermint machine to a GossipEngine
kayabaNerve Oct 30, 2022
aee0bde
Connect broadcast
kayabaNerve Oct 30, 2022
f37adf4
Remove machine from TendermintImport
kayabaNerve Oct 30, 2022
066bc40
Merge Verifier into block_import.rs
kayabaNerve Oct 30, 2022
3d7c12a
Create a dedicated file for being a Tendermint authority
kayabaNerve Oct 30, 2022
a0e0545
Deleted comment code related to PoW
kayabaNerve Oct 30, 2022
91ae2b7
Move serai_runtime specific code from tendermint/client to node
kayabaNerve Oct 30, 2022
c005664
Consolidate file structure in sc_tendermint
kayabaNerve Oct 30, 2022
503adfe
Replace best_* with finalized_*
kayabaNerve Oct 30, 2022
c4976ff
Consolidate references to sr25519 in sc_tendermint
kayabaNerve Oct 30, 2022
8f06553
Add documentation to public structs/functions in sc_tendermint
kayabaNerve Oct 30, 2022
45a5d3e
Add another missing comment
kayabaNerve Nov 1, 2022
e38a7e0
Merge branch 'develop' into tendermint
kayabaNerve Nov 1, 2022
2947ef0
Make sign asynchronous
kayabaNerve Nov 1, 2022
19154cf
Move sc_tendermint to async sign
kayabaNerve Nov 1, 2022
aa0a4cf
Implement proper checking of inherents
kayabaNerve Nov 1, 2022
5832007
Take in a Keystore and validator ID
kayabaNerve Nov 2, 2022
9a26ac6
Remove unnecessary PhantomDatas
kayabaNerve Nov 2, 2022
86aaada
Update node to latest sc_tendermint
kayabaNerve Nov 2, 2022
e3fc3f2
Configure node for a multi-node testnet
kayabaNerve Nov 2, 2022
38cee04
Fix handling of the GossipEngine
kayabaNerve Nov 2, 2022
ca043f5
Use a rounded genesis to obtain sufficient synchrony within the Docke…
kayabaNerve Nov 2, 2022
2182b66
Correct Serai d-f names in Docker
kayabaNerve Nov 2, 2022
16065cc
Remove an attempt at caching I don't believe would ever hit
kayabaNerve Nov 2, 2022
40b6cb7
Add an already in chain check to block import
kayabaNerve Nov 2, 2022
5cfe2d5
Update the consensus documentation
kayabaNerve Nov 2, 2022
83caa8b
Add a _ to the validator arg in slash
kayabaNerve Nov 2, 2022
083198e
Make the dev profile a local testnet profile
kayabaNerve Nov 2, 2022
f3e1771
Reduce Arcs in TendermintMachine, split Signer from SignatureScheme
kayabaNerve Nov 3, 2022
2b503b6
Update sc_tendermint per previous commit
kayabaNerve Nov 3, 2022
f4d622a
Restore cache
kayabaNerve Nov 3, 2022
de0e672
Remove error case which shouldn't be an error
kayabaNerve Nov 3, 2022
cf8bdf2
Stop returning errors on already existing blocks entirely
kayabaNerve Nov 3, 2022
131355b
Correct Dave, Eve, and Ferdie to not run as validators
kayabaNerve Nov 3, 2022
63df908
Rename dev to devnet
kayabaNerve Nov 3, 2022
bd08cd3
Add message expiry to the Tendermint gossip
kayabaNerve Nov 3, 2022
2315b3c
Localize the LibP2P protocol to the blockchain
kayabaNerve Nov 3, 2022
1ff51c1
Add a version to sp-runtime in tendermint-machine
kayabaNerve Nov 3, 2022
ea646c8
Add missing trait
kayabaNerve Nov 3, 2022
af63c3e
Bump Substrate dependency
kayabaNerve Nov 4, 2022
1a3b6dc
Implement Schnorr half-aggregation from https://eprint.iacr.org/2021/…
kayabaNerve Nov 4, 2022
55e32e2
Merge branch 'develop' into tendermint
kayabaNerve Nov 4, 2022
c31a55c
cargo update (tendermint)
kayabaNerve Nov 4, 2022
5dab335
Move from polling loops to a pure IO model for sc_tendermint's gossip
kayabaNerve Nov 8, 2022
16a2c9a
Correct protocol name handling
kayabaNerve Nov 8, 2022
56a21ca
Use futures mpsc instead of tokio
kayabaNerve Nov 9, 2022
2cb1d35
Timeout futures
kayabaNerve Nov 9, 2022
1c81922
Move from a yielding loop to select in tendermint-machine
kayabaNerve Nov 9, 2022
f7b1ff9
Update Substrate to the new TendermintHandle
kayabaNerve Nov 9, 2022
7d46daa
Use futures pin instead of tokio
kayabaNerve Nov 9, 2022
6f74bad
Only recheck blocks with non-fatal inherent transaction errors
kayabaNerve Nov 11, 2022
c9334ee
Merge branch 'develop' into tendermint
kayabaNerve Nov 11, 2022
0fb9d43
Merge branch 'develop' into tendermint
kayabaNerve Nov 11, 2022
2411660
Update to the latest substrate
kayabaNerve Nov 11, 2022
fffb7a6
Separate the block processing time from the latency
kayabaNerve Nov 11, 2022
354bcef
Add notes to the runtime
kayabaNerve Nov 11, 2022
dbcddb2
Don't spam slash
kayabaNerve Nov 11, 2022
43b43bd
Support running TendermintMachine when not a validator
kayabaNerve Nov 11, 2022
32ad6de
Properly define and pass around the block size
kayabaNerve Nov 11, 2022
ecde185
Correct the Duration timing
kayabaNerve Nov 12, 2022
ca3a29f
Correct time-adjustment code on round skip
kayabaNerve Nov 12, 2022
b53759c
Have the machine respond to advances made by an external sync loop
kayabaNerve Nov 12, 2022
e2e7a70
Clean up time code in tendermint-machine
kayabaNerve Nov 12, 2022
9e72f87
BlockData and RoundData structs
kayabaNerve Nov 12, 2022
2f3bb88
Rename Round to RoundNumber
kayabaNerve Nov 12, 2022
b7b57ee
Move BlockData to a new file
kayabaNerve Nov 12, 2022
8508783
Move Round to an Option due to the pseudo-uninitialized state we create
kayabaNerve Nov 12, 2022
2de4ab8
Clear the Queue instead of draining and filtering
kayabaNerve Nov 12, 2022
4ba469e
BlockData::new
kayabaNerve Nov 12, 2022
c13e0c7
Move more code into block.rs
kayabaNerve Nov 13, 2022
b7502a7
Have verify_precommit_signature return if it verified the signature
kayabaNerve Nov 13, 2022
0b8181b
Remove the precommit signature hash
kayabaNerve Nov 13, 2022
48b4b68
Slight doc changes
kayabaNerve Nov 13, 2022
33e52ae
Always produce notifications for finalized blocks via origin overrides
kayabaNerve Nov 14, 2022
2408fd8
Correct weird formatting
kayabaNerve Nov 14, 2022
138866f
Update to the latest tendermint-machine
kayabaNerve Nov 14, 2022
8c51bc0
Manually step the Tendermint machine when we synced a block over the …
kayabaNerve Nov 14, 2022
0490157
Ignore finality notifications for old blocks
kayabaNerve Nov 14, 2022
457d11a
Remove a TODO resolved in 8c51bc011d03c8d54ded05011e7f4d1a01e9f873
kayabaNerve Nov 14, 2022
7248a41
Add a TODO comment to slash
kayabaNerve Nov 14, 2022
9dc8f5c
cargo fmt
kayabaNerve Nov 14, 2022
707a177
Use a tmp DB for Serai in Docker
kayabaNerve Nov 14, 2022
7d42c45
Remove panic on slash
kayabaNerve Nov 15, 2022
06c57a1
Add log::error on slash
kayabaNerve Nov 15, 2022
d2e0b58
created shared volume between containers
vrx00 Nov 16, 2022
8c65e1b
Complete the sh scripts
kayabaNerve Nov 17, 2022
426baca
Pass in the genesis time to Substrate
kayabaNerve Nov 17, 2022
1aefa3f
Correct block announcements
kayabaNerve Nov 17, 2022
14fc181
Correct pupulate_end_time
kayabaNerve Nov 17, 2022
b077dc7
Correct gossip channel jumping when a block is synced via Substrate
kayabaNerve Nov 17, 2022
82da7eb
Use a looser check in import_future
kayabaNerve Nov 17, 2022
26ad7c1
Correct race conditions between add_block and step
kayabaNerve Nov 17, 2022
2bbba63
Merge branch 'develop' into tendermint
kayabaNerve Nov 17, 2022
6e992a3
Update cargo deny
kayabaNerve Nov 17, 2022
88aabde
rename genesis-service to genesis
TheArchitect108 Nov 17, 2022
c7e97d9
Update Cargo.lock
kayabaNerve Nov 18, 2022
cbe79eb
Correct runtime Cargo.toml whitespace
kayabaNerve Nov 20, 2022
10aac4a
Correct typo
kayabaNerve Nov 20, 2022
9b51eaf
Document recheck
kayabaNerve Nov 21, 2022
9dfa22d
Misc lints
kayabaNerve Nov 21, 2022
bfe7546
Fix prev commit
kayabaNerve Nov 21, 2022
991ba61
Merge branch 'develop' into tendermint
kayabaNerve Nov 21, 2022
cd9b9c8
Resolve low-hanging review comments
kayabaNerve Nov 21, 2022
92760c0
Mark genesis/entry-dev.sh as executable
kayabaNerve Nov 22, 2022
9065dcc
Merge branch 'develop' into tendermint
kayabaNerve Nov 23, 2022
b042a2a
Prevent a commit from including the same signature multiple times
kayabaNerve Nov 23, 2022
14ce9ef
Update to latest nightly clippy
kayabaNerve Nov 23, 2022
69a9cae
Merge branch 'develop' into tendermint
kayabaNerve Nov 24, 2022
3d20afd
Improve documentation
kayabaNerve Nov 24, 2022
1d45e03
Use clearer variable names
kayabaNerve Nov 24, 2022
3212942
Add log statements
kayabaNerve Nov 24, 2022
849c358
Pair more log statements
kayabaNerve Nov 24, 2022
d757924
Clean TendermintAuthority::authority as possible
kayabaNerve Nov 26, 2022
61b00b3
Fix #158
kayabaNerve Nov 26, 2022
8c2cbff
Rename guard to lock
kayabaNerve Nov 27, 2022
3ea8bec
Have the devnet use the current time as the genesis
kayabaNerve Nov 29, 2022
3dea9e5
Fix gossiping
kayabaNerve Dec 2, 2022
e220163
Misc lints
kayabaNerve Dec 2, 2022
dc4914f
Merge branch 'develop' into tendermint
kayabaNerve Dec 2, 2022
d4e24fc
Merge branch 'develop' into tendermint
kayabaNerve Dec 2, 2022
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
Map TM SignatureScheme to Substrate's sr25519
kayabaNerve committed Oct 20, 2022

Unverified

This user has not yet uploaded their public signing key.
commit 975c9d7456ca7600aefb74c0b877f7e2b94d3aec
41 changes: 41 additions & 0 deletions substrate/consensus/src/signature_scheme.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use sp_application_crypto::{
RuntimePublic as PublicTrait, Pair as PairTrait,
sr25519::{Public, Pair, Signature},
};

use tendermint_machine::ext::SignatureScheme;

pub(crate) struct TendermintSigner {
keys: Pair,
lookup: Vec<Public>,
}

impl SignatureScheme for TendermintSigner {
type ValidatorId = u16;
type Signature = Signature;
type AggregateSignature = Vec<Signature>;

fn sign(&self, msg: &[u8]) -> Signature {
self.keys.sign(msg)
}

fn verify(&self, validator: u16, msg: &[u8], sig: &Signature) -> bool {
self.lookup[usize::try_from(validator).unwrap()].verify(&msg, sig)
}

fn aggregate(sigs: &[Signature]) -> Vec<Signature> {
sigs.to_vec()
}

fn verify_aggregate(&self, validators: &[u16], msg: &[u8], sigs: &Vec<Signature>) -> bool {
if validators.len() != sigs.len() {
return false;
}
for (v, sig) in validators.iter().zip(sigs.iter()) {
if !self.verify(*v, msg, sig) {
return false;
}
}
true
}
}