Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Remove DKG, update to polkadot v1.1.0 #86

Merged
merged 11 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
/Cargo.lock
.vscode

target
.env
Expand Down
156 changes: 72 additions & 84 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/consensus-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ eth2-serde-utils = { package = "webb-eth2-serde-utils", path = "../serde-utils",

bitvec = { workspace = true, features = ["atomic", "alloc"] }
hex = { workspace = true }
codec = { package = "parity-scale-codec", workspace = true }
codec = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true }
rlp = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tree-hash = { package = "webb-tree-hash", path = "../tree-hash", default-featur
tree-hash-derive = { package = "webb-tree-hash-derive", path = "../tree-hash-derive", default-features = false }
eth2-serde-utils = { package = "webb-eth2-serde-utils", path = "../serde-utils", default-features = false, optional = true }
hex = { workspace = true }
codec = { package = "parity-scale-codec", workspace = true }
codec = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true }
rlp = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/eth2-hashing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Paul Hauner <[email protected]>, Webb Developers <[email protected]
description = "Hashing primitives used in Ethereum 2.0"

[dependencies]
lazy_static = { workspace = true, optional = true,features = ["spin_no_std"] }
lazy_static = { workspace = true, optional = true, features = ["spin_no_std"] }
ring = { workspace = true, optional = true }
sha2 = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion gadget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ eth2-pallet-init = { package = "webb-eth2-pallet-init", path = "../crates/eth2-p
lc-relayer-context = { package = "webb-lc-relayer-context", path = "../crates/lc-relayer-context" }
lc-relay-config = { package = "webb-lc-relay-config", path = "../crates/lc-relay-config" }
# Webb
webb-proposals = { workspace = true, features = ["scale", "evm"] }
webb-proposals = { workspace = true, features = ["scale", "evm"], default-features = true }
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ frame-benchmarking-cli = { workspace = true }
try-runtime-cli = { workspace = true, optional = true }

[build-dependencies]
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

[features]
default = []
Expand Down
7 changes: 2 additions & 5 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic(
self.client.as_ref(),
acc,
BalancesCall::transfer_keep_alive {
dest: self.dest.clone().into(),
value: self.value.into(),
}
.into(),
BalancesCall::transfer_keep_alive { dest: self.dest.clone().into(), value: self.value }
.into(),
nonce,
)
.into();
Expand Down
27 changes: 8 additions & 19 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use node_template_runtime::{
opaque::SessionKeys, AccountId, Balance, BalancesConfig, DKGConfig, DKGId, Eth2ClientConfig,
IndicesConfig, MaxNominations, RuntimeGenesisConfig, SessionConfig, Signature, StakingConfig,
SudoConfig, SystemConfig, DOLLARS, WASM_BINARY,
opaque::SessionKeys, AccountId, Balance, BalancesConfig, Eth2ClientConfig, IndicesConfig,
MaxNominations, RuntimeGenesisConfig, SessionConfig, Signature, StakingConfig, SudoConfig,
SystemConfig, DOLLARS, WASM_BINARY,
};
use pallet_staking::StakerStatus;
use sc_service::ChainType;
Expand Down Expand Up @@ -39,18 +39,17 @@ where
}

/// Helper function to generate stash, controller and session key from seed
pub fn authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, AuraId, DKGId) {
pub fn authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, AuraId) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<AuraId>(seed),
get_from_seed::<DKGId>(seed),
)
}

fn session_keys(grandpa: GrandpaId, aura: AuraId, dkg: DKGId) -> SessionKeys {
SessionKeys { grandpa, aura, dkg }
fn session_keys(grandpa: GrandpaId, aura: AuraId) -> SessionKeys {
SessionKeys { grandpa, aura }
}

fn development_config_genesis() -> RuntimeGenesisConfig {
Expand Down Expand Up @@ -110,7 +109,7 @@ pub fn local_testnet_config() -> ChainSpec {
/// Configure initial storage state for FRAME modules.
fn testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, AccountId, GrandpaId, AuraId, DKGId)>,
initial_authorities: Vec<(AccountId, AccountId, GrandpaId, AuraId)>,
initial_nominators: Vec<AccountId>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
Expand Down Expand Up @@ -154,7 +153,6 @@ fn testnet_genesis(
let nominations = initial_authorities
.as_slice()
.choose_multiple(&mut rng, count)
.into_iter()
.map(|choice| choice.0.clone())
.collect::<Vec<_>>();
(x.clone(), x.clone(), STASH, StakerStatus::Nominator(nominations))
Expand All @@ -177,9 +175,7 @@ fn testnet_genesis(
session: SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone()))
})
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone())))
.collect::<Vec<_>>(),
},
staking: StakingConfig {
Expand All @@ -204,12 +200,5 @@ fn testnet_genesis(
],
phantom: std::marker::PhantomData,
},
dkg: DKGConfig {
authorities: initial_authorities.iter().map(|(.., x)| x.clone()).collect::<_>(),
keygen_threshold: 2,
signature_threshold: 1,
authority_ids: initial_authorities.iter().map(|(x, ..)| x.clone()).collect::<_>(),
},
dkg_proposals: Default::default(),
}
}
36 changes: 12 additions & 24 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpS
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use std::{sync::Arc, time::Duration};
use std::sync::Arc;
use webb_proposals::TypedChainId;

/// The minimum period of blocks on which justifications will be
/// imported and generated.
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;

// Our native executor instance.
pub struct ExecutorDispatch;

Expand Down Expand Up @@ -45,7 +49,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::GrandpaBlockImport<
Expand All @@ -71,7 +75,7 @@ pub fn new_partial(
})
.transpose()?;

let executor = sc_service::new_native_or_wasm_executor(&config);
let executor = sc_service::new_native_or_wasm_executor(config);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
Expand All @@ -97,7 +101,8 @@ pub fn new_partial(

let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
GRANDPA_JUSTIFICATION_PERIOD,
&client,
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
Expand Down Expand Up @@ -296,22 +301,6 @@ pub fn new_full(
},
),
);

// // Start Eth2 Light client Relayer Gadget - (GOERLI TESTNET RELAYER)
// task_manager.spawn_handle().spawn(
// "goerli-relayer-gadget",
// None,
// pallet_eth2_light_client_relayer_gadget::start_gadget(
// pallet_eth2_light_client_relayer_gadget::Eth2LightClientParams {
// local_keystore: keystore_container.local_keystore(),
// ew_config_dir: relayer_cmd.relayer_config_dir,
// lc_config_path: relayer_cmd.light_client_config_path,
// database_path,
// rpc_addr,
// eth2_chain_id: TypedChainId::Evm(5),
// },
// ),
// );
}

if enable_grandpa {
Expand All @@ -320,13 +309,12 @@ pub fn new_full(
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };

let grandpa_config = sc_consensus_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
gossip_duration: std::time::Duration::from_millis(333),
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
name: Some(name),
observer_enabled: false,
keystore,
local_role: role,
local_role: role.clone(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
protocol_name: grandpa_protocol_name,
};
Expand Down
12 changes: 8 additions & 4 deletions pallets/eth2-light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ consensus = { package = "webb-consensus-types", path = "../../crates/consensus-t
frame-support = { workspace = true, default-features = false }
frame-system = { workspace = true }
pallet-balances = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
sp-core = { workspace = true }

log = { workspace = true }
serde = { workspace = true, optional = true }
codec = { package = "parity-scale-codec",workspace = true, features = ["derive", "max-encoded-len"] }
codec = { workspace = true, features = ["derive", "max-encoded-len"] }
scale-info = { workspace = true }
webb-proposals = { workspace = true, features = ["scale", "evm", "substrate"] }
webb-proposals = { workspace = true, features = ["evm", "substrate"] }
ethereum-types = { workspace = true }
derive_more = { workspace = true }
rlp = { workspace = true }
Expand All @@ -38,8 +39,8 @@ webb-light-client-primitives = { workspace = true }
anyhow = { workspace = true }
lazy_static = { workspace = true }
serde_json = { workspace = true }
eth2-pallet-init = { package = "webb-eth2-pallet-init", path = "../../crates/eth2-pallet-init" }
async-trait = { workspace = true }
eth2-pallet-init = { package = "webb-eth2-pallet-init", optional = true, path = "../../crates/eth2-pallet-init" }
async-trait = { workspace = true, optional = true }

[features]
default = ["std"]
Expand All @@ -54,6 +55,7 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"sp-core/std",
Expand All @@ -66,6 +68,8 @@ std = [
"eth2-ssz/std",
"tree-hash/std",
"merkle-proof/std",
"async-trait",
"eth2-pallet-init",

]
testing = [
Expand Down
2 changes: 1 addition & 1 deletion pallets/eth2-light-client/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", workspace = true }
codec = { workspace = true }
sp-api = { workspace = true }
webb-proposals = { workspace = true }
eth-types = { path = "../../../crates/eth-types", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions pallets/eth2-light-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ pub mod pallet {
let unfinalized_head_execution_header =
UnfinalizedHeadExecutionHeader::<T>::get(typed_chain_id)
.ok_or(Error::<T>::UnfinalizedHeaderNotPresent)?;
frame_support::log::debug!(
log::debug!(
target: "light-client",
"Current finalized block number: {:?}, New finalized block number: {:?}",
finalized_execution_header.block_number,
Expand Down Expand Up @@ -559,7 +559,7 @@ pub mod pallet {
UnfinalizedTailExecutionHeader::<T>::insert(typed_chain_id, block_info);
}

frame_support::log::debug!(
log::debug!(
target: "light-client",
"Submitted header number {:?}, hash {:#?}",
block_header.number, block_hash
Expand Down Expand Up @@ -936,7 +936,7 @@ impl<T: Config> Pallet<T> {
NextSyncCommittee::<T>::insert(typed_chain_id, next_sync_committee);
}

frame_support::log::debug!(
log::debug!(
target: "light-client",
"Current finalized slot: {:?}, New finalized slot: {:?}",
finalized_beacon_header.header.slot,
Expand Down
2 changes: 1 addition & 1 deletion pallets/eth2-light-client/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;
use crate as pallet_eth2_light_client;

use consensus::network_config::{Network, NetworkConfig};
use frame_support::{parameter_types, sp_io};
use frame_support::parameter_types;
use frame_system as system;
use sp_core::H256;
use sp_runtime::{
Expand Down
25 changes: 19 additions & 6 deletions pallets/eth2-light-client/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use crate::{mock::*, test_utils::*, Error, Lsb0, Paused};
use bitvec::bitarr;
use consensus::{EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH};
use eth_types::{eth2::LightClientUpdate, pallet::InitInput, BlockHeader, U256};
use crate::{mock::*, test_utils::*};

use eth_types::{eth2::LightClientUpdate, pallet::InitInput, BlockHeader};
use frame_support::assert_ok;

use eth_types::H256;
use frame_support::assert_err;
use sp_runtime::AccountId32;

use webb_proposals::TypedChainId;
Expand Down Expand Up @@ -48,8 +45,18 @@ pub fn get_test_context(

mod generic_tests {
use super::*;
use crate::{
mock::new_test_ext,
tests::{get_test_context, GOERLI_CHAIN},
Error, Paused,
};
use bitvec::{bitarr, order::Lsb0};
use consensus::{EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH};
use eth_types::{H256, U256};
use frame_support::assert_err;
use hex::FromHex;
use tree_hash::TreeHash;

#[test]
pub fn test_header_root() {
let header =
Expand Down Expand Up @@ -483,6 +490,12 @@ mod generic_tests {

mod mainnet_tests {
use super::*;
use crate::{
tests::{new_test_ext, ALICE, MAINNET_CHAIN},
Error,
};
use frame_support::assert_err;

#[test]
pub fn test_panic_on_init_in_trustless_mode_without_bls_on_mainnet() {
new_test_ext().execute_with(|| {
Expand Down
Loading
Loading