Skip to content

Commit

Permalink
Remove Tendermint for GRANDPA
Browse files Browse the repository at this point in the history
Updates to polkadot-v0.9.40, with a variety of dependency updates accordingly.
Substrate thankfully now uses k256 0.13, pathing the way for #256. We couldn't
upgrade to polkadot-v0.9.40 without this due to polkadot-v0.9.40 having
fundamental changes to syncing. While we could've updated tendermint, it's not
worth the continued development effort given its inability to work with
multiple validator sets.

Purges sc-tendermint. Keeps tendermint-machine for #163.

Closes #137, #148, #157, #171. #96 and #99 should be re-scoped/clarified. #134
and #159 also should be clarified. #169 is also no longer a priority since
we're only considering temporal deployments of tendermint. #170 also isn't
since we're looking at effectively sharded validator sets, so there should
be no singular large set needing high performance.
  • Loading branch information
kayabaNerve committed Mar 26, 2023
1 parent 534e1bb commit aea6ac1
Show file tree
Hide file tree
Showing 42 changed files with 1,081 additions and 2,135 deletions.
825 changes: 577 additions & 248 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ members = [
"processor/messages",
"processor",

"tendermint",

"substrate/serai/primitives",
"substrate/serai/client",

Expand All @@ -35,11 +37,6 @@ members = [
"substrate/validator-sets/primitives",
"substrate/validator-sets/pallet",

"substrate/tendermint/machine",
"substrate/tendermint/primitives",
"substrate/tendermint/client",
"substrate/tendermint/pallet",

"substrate/runtime",
"substrate/node",
]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ wallet.
- `processor`: A generic chain processor to process data for Serai and process
events from Serai, executing transactions as expected and needed.

- `tendermint`: An abstracted implementation of the Tendermint BFT algorithm,
planned to be used in our own micro-blockchain for temporal data needed to
coordinate the Serai validators, yet irrelevant to the Serai network as a
whole.

- `substrate`: Substrate crates used to instantiate the Serai network.

- `deploy`: Scripts to deploy a Serai node/test environment.
Expand Down
4 changes: 0 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ exceptions = [

{ allow = ["AGPL-3.0"], name = "validator-sets-pallet" },

{ allow = ["AGPL-3.0"], name = "sp-tendermint" },
{ allow = ["AGPL-3.0"], name = "pallet-tendermint" },
{ allow = ["AGPL-3.0"], name = "sc-tendermint" },

{ allow = ["AGPL-3.0"], name = "serai-runtime" },
{ allow = ["AGPL-3.0"], name = "serai-node" },

Expand Down
2 changes: 1 addition & 1 deletion deploy/serai/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ADD common /serai/common
ADD crypto /serai/crypto
ADD coins /serai/coins
ADD processor /serai/processor
ADD contracts /serai/contracts
ADD tendermint /serai/tendermint
ADD substrate /serai/substrate
ADD Cargo.toml /serai
ADD Cargo.lock /serai
Expand Down
5 changes: 2 additions & 3 deletions substrate/in-instructions/pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

use scale::{Encode, Decode};
use scale::Encode;

use sp_runtime::RuntimeDebug;

Expand All @@ -12,7 +12,7 @@ pub use in_instructions_primitives as primitives;
use primitives::{InInstruction, InInstructionWithBalance, SignedBatch};

#[derive(Clone, Copy, Encode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Decode, thiserror::Error))]
#[cfg_attr(feature = "std", derive(scale::Decode, thiserror::Error))]
pub enum PalletError {
#[cfg_attr(feature = "std", error("batch for unrecognized network"))]
UnrecognizedNetwork,
Expand Down Expand Up @@ -42,7 +42,6 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::generate_store(pub(crate) trait Store)]
pub struct Pallet<T>(PhantomData<T>);

// Latest block number agreed upon for a coin
Expand Down
14 changes: 12 additions & 2 deletions substrate/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ async-trait = "0.1"

clap = { version = "4", features = ["derive"] }

futures = "0.3"
jsonrpsee = { version = "0.16", features = ["server"] }

sp-core = { git = "https://github.com/serai-dex/substrate" }
sp-keyring = { git = "https://github.com/serai-dex/substrate" }
sp-inherents = { git = "https://github.com/serai-dex/substrate" }
sp-timestamp = { git = "https://github.com/serai-dex/substrate" }
sp-runtime = { git = "https://github.com/serai-dex/substrate" }
sp-blockchain = { git = "https://github.com/serai-dex/substrate" }
sp-api = { git = "https://github.com/serai-dex/substrate" }
sp-block-builder = { git = "https://github.com/serai-dex/substrate" }
sp-consensus = { git = "https://github.com/serai-dex/substrate" }
sp-consensus-babe = { git = "https://github.com/serai-dex/substrate" }

frame-benchmarking = { git = "https://github.com/serai-dex/substrate" }
frame-benchmarking-cli = { git = "https://github.com/serai-dex/substrate" }
Expand All @@ -39,9 +42,18 @@ sc-executor = { git = "https://github.com/serai-dex/substrate" }
sc-service = { git = "https://github.com/serai-dex/substrate" }
sc-client-db = { git = "https://github.com/serai-dex/substrate" }
sc-client-api = { git = "https://github.com/serai-dex/substrate" }
sc-network-common = { git = "https://github.com/serai-dex/substrate" }
sc-network = { git = "https://github.com/serai-dex/substrate" }
sc-consensus = { git = "https://github.com/serai-dex/substrate" }

sc-consensus-babe = { git = "https://github.com/serai-dex/substrate" }
sc-consensus-babe-rpc = { git = "https://github.com/serai-dex/substrate" }

sc-consensus-grandpa = { git = "https://github.com/serai-dex/substrate" }
sc-consensus-grandpa-rpc = { git = "https://github.com/serai-dex/substrate" }

sc-authority-discovery = { git = "https://github.com/serai-dex/substrate" }

sc-telemetry = { git = "https://github.com/serai-dex/substrate" }
sc-cli = { git = "https://github.com/serai-dex/substrate" }

Expand All @@ -50,8 +62,6 @@ sc-rpc-api = { git = "https://github.com/serai-dex/substrate" }
substrate-frame-rpc-system = { git = "https://github.com/serai-dex/substrate" }
pallet-transaction-payment-rpc = { git = "https://github.com/serai-dex/substrate" }

sc-tendermint = { path = "../tendermint/client" }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate.git" }

Expand Down
18 changes: 13 additions & 5 deletions substrate/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use sp_core::Pair as PairTrait;
use sc_service::ChainType;

use serai_runtime::{
primitives::*, tokens::primitives::ADDRESS as TOKENS_ADDRESS, tendermint::crypto::Public,
WASM_BINARY, opaque::SessionKeys, GenesisConfig, SystemConfig, BalancesConfig, AssetsConfig,
ValidatorSetsConfig, SessionConfig,
primitives::*, tokens::primitives::ADDRESS as TOKENS_ADDRESS, WASM_BINARY, opaque::SessionKeys,
BABE_GENESIS_EPOCH_CONFIG, GenesisConfig, SystemConfig, BalancesConfig, AssetsConfig,
ValidatorSetsConfig, SessionConfig, BabeConfig, GrandpaConfig, AuthorityDiscoveryConfig,
};

pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
Expand All @@ -21,7 +21,11 @@ fn testnet_genesis(
) -> GenesisConfig {
let session_key = |name| {
let key = account_from_name(name);
(key, key, SessionKeys { tendermint: Public::from(key) })
(
key,
key,
SessionKeys { babe: key.into(), grandpa: key.into(), authority_discovery: key.into() },
)
};

GenesisConfig {
Expand All @@ -47,7 +51,6 @@ fn testnet_genesis(
accounts: vec![],
},

session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
validator_sets: ValidatorSetsConfig {
bond: Amount(1_000_000 * 10_u64.pow(8)),
networks: vec![
Expand All @@ -57,6 +60,11 @@ fn testnet_genesis(
],
participants: validators.iter().map(|name| account_from_name(name)).collect(),
},
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
babe: BabeConfig { authorities: vec![], epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG) },
grandpa: GrandpaConfig { authorities: vec![] },

authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
}
}

Expand Down
30 changes: 18 additions & 12 deletions substrate/node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use serai_runtime::Block;

use sc_service::{PruningMode, PartialComponents};
Expand All @@ -9,7 +11,7 @@ use crate::{
chain_spec,
cli::{Cli, Subcommand},
command_helper::{RemarkBuilder, inherent_benchmark_data},
service,
service::{self, FullClient},
};

impl SubstrateCli for Cli {
Expand Down Expand Up @@ -62,23 +64,23 @@ pub fn run() -> sc_cli::Result<()> {

Some(Subcommand::CheckBlock(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, .. } =
service::new_partial(&config)?.1;
service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
}),

Some(Subcommand::ExportBlocks(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?.1;
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?;
Ok((cmd.run(client, config.database), task_manager))
}),

Some(Subcommand::ExportState(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?.1;
let PartialComponents { client, task_manager, .. } = service::new_partial(&config)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
}),

Some(Subcommand::ImportBlocks(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, .. } =
service::new_partial(&config)?.1;
service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
}),

Expand All @@ -87,15 +89,19 @@ pub fn run() -> sc_cli::Result<()> {
}

Some(Subcommand::Revert(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
let PartialComponents { client, task_manager, backend, .. } =
service::new_partial(&config)?.1;
Ok((cmd.run(client, backend, None), task_manager))
let PartialComponents { client, task_manager, backend, .. } = service::new_partial(&config)?;
let aux_revert = Box::new(|client: Arc<FullClient>, backend, blocks| {
sc_consensus_babe::revert(client.clone(), backend, blocks)?;
sc_consensus_grandpa::revert(client, blocks)?;
Ok(())
});
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
}),

Some(Subcommand::Benchmark(cmd)) => cli.create_runner(cmd)?.sync_run(|config| match cmd {
BenchmarkCmd::Pallet(cmd) => cmd.run::<Block, service::ExecutorDispatch>(config),

BenchmarkCmd::Block(cmd) => cmd.run(service::new_partial(&config)?.1.client),
BenchmarkCmd::Block(cmd) => cmd.run(service::new_partial(&config)?.client),

#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => {
Expand All @@ -104,12 +110,12 @@ pub fn run() -> sc_cli::Result<()> {

#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => {
let PartialComponents { client, backend, .. } = service::new_partial(&config)?.1;
let PartialComponents { client, backend, .. } = service::new_partial(&config)?;
cmd.run(config, client, backend.expose_db(), backend.expose_storage())
}

BenchmarkCmd::Overhead(cmd) => {
let client = service::new_partial(&config)?.1.client;
let client = service::new_partial(&config)?.client;
cmd.run(
config,
client.clone(),
Expand All @@ -120,7 +126,7 @@ pub fn run() -> sc_cli::Result<()> {
}

BenchmarkCmd::Extrinsic(cmd) => {
let client = service::new_partial(&config)?.1.client;
let client = service::new_partial(&config)?.client;
cmd.run(
client.clone(),
inherent_benchmark_data()?,
Expand Down
Loading

0 comments on commit aea6ac1

Please sign in to comment.