diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 73f1e2d9..7013aedf 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -16,7 +16,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2022-12-26 + toolchain: nightly-2023-07-16 components: clippy override: true @@ -25,7 +25,7 @@ jobs: uses: actions-rs/toolchain@master with: profile: minimal - toolchain: nightly-2022-12-26 + toolchain: nightly-2023-07-16 target: wasm32-unknown-unknown - name: Install protobuf-compiler diff --git a/crates/bls/Cargo.toml b/crates/bls/Cargo.toml index 9dbc9e7b..a7ebbf32 100644 --- a/crates/bls/Cargo.toml +++ b/crates/bls/Cargo.toml @@ -13,7 +13,7 @@ eth2-serde-utils = { package = "webb-eth2-serde-utils", path = "../serde-utils", milagro_bls = { git = "https://github.com/Snowfork/milagro_bls", default-features = false } rand = { version = "0.7.3", default-features = false } rand_chacha = { version = "0.3.1", default-features = false } -serde = { version = "1.0.101", features = ["derive"], optional = true, default-features = false} +serde = { version = "1.0.152", features = ["derive"], default-features = false} hex = { version = "0.4.2", default-features = false, features = ["alloc"] } ethereum-types = { version = "0.14.1", default-features = false } @@ -22,7 +22,7 @@ zeroize = { version = "1.4.2", features = ["zeroize_derive"], default-features = [features] default = ["std"] std = [ - "serde", + "serde/std", "rand/std", "rand_chacha/std", "hex/std", diff --git a/crates/bls/src/generic_aggregate_signature.rs b/crates/bls/src/generic_aggregate_signature.rs index b67e715e..5d7f9f04 100644 --- a/crates/bls/src/generic_aggregate_signature.rs +++ b/crates/bls/src/generic_aggregate_signature.rs @@ -276,7 +276,7 @@ where } /// Hashes the `self.serialize()` bytes. -#[allow(clippy::derive_hash_xor_eq)] +#[allow(clippy::derived_hash_with_manual_eq)] impl Hash for GenericAggregateSignature where Sig: TSignature, diff --git a/crates/bls/src/zeroize_hash.rs b/crates/bls/src/zeroize_hash.rs index a782e169..cf8c5b59 100644 --- a/crates/bls/src/zeroize_hash.rs +++ b/crates/bls/src/zeroize_hash.rs @@ -1,11 +1,10 @@ use super::SECRET_KEY_BYTES_LEN; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use zeroize::Zeroize; /// Provides a wrapper around a `[u8; SECRET_KEY_BYTES_LEN]` that implements `Zeroize` on `Drop`. -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "std", serde(transparent))] +#[derive(Serialize, Deserialize)] +#[serde(transparent)] #[derive(Zeroize)] #[zeroize(drop)] pub struct ZeroizeHash([u8; SECRET_KEY_BYTES_LEN]); diff --git a/crates/consensus-types/Cargo.toml b/crates/consensus-types/Cargo.toml index fd9356b8..a229a10c 100644 --- a/crates/consensus-types/Cargo.toml +++ b/crates/consensus-types/Cargo.toml @@ -5,7 +5,9 @@ authors = ["Webb Developers"] edition = "2021" [dependencies] -serde = { version = "1.0.116", default-features = false, optional = true, features = ["derive"] } + +serde = { version = "1.0.152", default-features = false, features = ["derive"] } + rlp = { version = "0.5.0", default-features = false } rlp-derive = { version = "0.1.0", default-features = false } ethereum-types = { version = "0.14.1", features = ["codec", "rlp", "serialize"], default-features = false } @@ -29,7 +31,6 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive" [features] default = ["std"] std = [ - "serde", "tree-hash/std", "eth-types/std", "bitvec/std", diff --git a/crates/consensus-types/src/network_config.rs b/crates/consensus-types/src/network_config.rs index 2475e4a6..aedd18f3 100644 --- a/crates/consensus-types/src/network_config.rs +++ b/crates/consensus-types/src/network_config.rs @@ -3,9 +3,9 @@ use alloc::string::String; use codec::{Decode, Encode}; use core::str::FromStr; use eth_types::eth2::{Epoch, ForkVersion, Slot}; +use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, Encode, Decode, scale_info::TypeInfo)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug, PartialEq, Encode, Decode, scale_info::TypeInfo, Serialize, Deserialize)] pub enum Network { Mainnet, Goerli, @@ -22,8 +22,7 @@ impl FromStr for Network { } } -#[derive(Clone, Debug, PartialEq, Encode, Decode, scale_info::TypeInfo)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug, PartialEq, Encode, Decode, scale_info::TypeInfo, Serialize, Deserialize)] pub struct NetworkConfig { pub genesis_validators_root: [u8; 32], pub bellatrix_fork_version: ForkVersion, diff --git a/crates/eth-types/Cargo.toml b/crates/eth-types/Cargo.toml index 853771f2..2699d851 100644 --- a/crates/eth-types/Cargo.toml +++ b/crates/eth-types/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Near Inc ", "Webb Developers for $name { diff --git a/crates/eth2-pallet-init/Cargo.toml b/crates/eth2-pallet-init/Cargo.toml index 83ea144d..ea3e3553 100644 --- a/crates/eth2-pallet-init/Cargo.toml +++ b/crates/eth2-pallet-init/Cargo.toml @@ -29,6 +29,6 @@ webb = { version = "0.7.3", default-features = false, features = [ ]} scale = { package = "parity-scale-codec", version = "3", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", default-features = false, features = ["scale", "evm"] } +webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", rev="a960eaf", default-features = false, features = ["scale", "evm"] } tokio = { version = "1.1", default-features = false, features = ["macros", "rt", "time"] } dotenvy = "0.15.7" \ No newline at end of file diff --git a/eth2substrate-block-relay-rs/Cargo.toml b/eth2substrate-block-relay-rs/Cargo.toml index 170cb623..815d2724 100644 --- a/eth2substrate-block-relay-rs/Cargo.toml +++ b/eth2substrate-block-relay-rs/Cargo.toml @@ -23,7 +23,7 @@ webb = { version = "0.5.17", features = [ "evm-runtime", "substrate-runtime" ]} -webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", default-features = false, features = ["scale", "evm"] } +webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git",rev="a960eaf", default-features = false, features = ["scale", "evm"] } anyhow = "1.0" funty = "2.0.0" diff --git a/eth2substrate-block-relay-rs/src/test_utils.rs b/eth2substrate-block-relay-rs/src/test_utils.rs index ecbb0b91..54b51b67 100644 --- a/eth2substrate-block-relay-rs/src/test_utils.rs +++ b/eth2substrate-block-relay-rs/src/test_utils.rs @@ -242,7 +242,7 @@ pub async fn get_client_pallet( let typed_chain_id = get_typed_chain_id(config_for_test); let mut eth_client_pallet = EthClientPallet::new(api, typed_chain_id); - let mut config = get_init_config(config_for_test, ð_client_pallet); + let config = get_init_config(config_for_test, ð_client_pallet); match from_file { true => test_utils::init_pallet_from_files(&mut eth_client_pallet, config_for_test).await, diff --git a/gadget/Cargo.toml b/gadget/Cargo.toml index b1cac912..fa5dda75 100644 --- a/gadget/Cargo.toml +++ b/gadget/Cargo.toml @@ -31,7 +31,7 @@ eth2-to-substrate-relay = { path = "../eth2substrate-block-relay-rs" } eth2-pallet-init = { package = "webb-eth2-pallet-init", path = "../crates/eth2-pallet-init" } # DKG -dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", default-features = false } +dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.1", default-features = false } # Webb -webb-proposals = { git = "https://github.com/webb-tools/webb-rs", features = ["scale", "evm"] } \ No newline at end of file +webb-proposals = { git = "https://github.com/webb-tools/webb-rs", rev="a960eaf", features = ["scale", "evm"] } \ No newline at end of file diff --git a/gadget/src/lib.rs b/gadget/src/lib.rs index 39ea9be3..8b42ed54 100644 --- a/gadget/src/lib.rs +++ b/gadget/src/lib.rs @@ -1,6 +1,7 @@ //! Webb Relayer Gadget //! //! Integrates the Webb Relayer into the Substrate Node. +#![allow(dead_code)] use dkg_runtime_primitives::crypto; use eth2_pallet_init::{init_pallet, substrate_pallet_client::EthClientPallet}; use eth2_to_substrate_relay::eth2substrate_relay::Eth2SubstrateRelay; @@ -11,9 +12,6 @@ use sp_keystore::Keystore; use std::{net::SocketAddr, path::PathBuf, sync::Arc}; use subxt::OnlineClient; use webb_proposals::TypedChainId; -use webb_relayer::service; -use webb_relayer_context::RelayerContext; - pub mod errors; use errors::*; @@ -36,9 +34,7 @@ pub struct Eth2LightClientParams { } pub async fn start_gadget(relayer_params: Eth2LightClientParams) { - /// /// - /// ------------------ Light Client Relayer ------------------ /// - /// /// + // Light Client Relayer let lc_relay_config = match relayer_params.lc_relay_config_path.as_ref() { Some(p) => loads_light_client_relayer_config(p).expect("failed to load light client config"), diff --git a/node/Cargo.toml b/node/Cargo.toml index 5e1924f5..cd4fe521 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -22,6 +22,7 @@ futures = { version = "0.3.21", features = ["thread-pool"]} rand = "0.7.2" sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } +sc-offchain = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } @@ -57,7 +58,7 @@ sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/parity substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", default-features = false, features = ["scale", "evm"] } +webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", rev="a960eaf", default-features = false, features = ["scale", "evm"] } webb-consensus-types = { path = "../crates/consensus-types" } pallet-eth2-light-client-relayer-gadget = { path = "../gadget" } pallet-eth2-light-client-relayer-gadget-cli = { path = "../gadget/cli" } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 8700dbc4..d9f87dcf 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,6 +1,6 @@ use node_template_runtime::{ opaque::SessionKeys, AccountId, Balance, BalancesConfig, DKGConfig, DKGId, Eth2ClientConfig, - GenesisConfig, IndicesConfig, MaxNominations, SessionConfig, Signature, StakingConfig, + IndicesConfig, MaxNominations, RuntimeGenesisConfig, SessionConfig, Signature, StakingConfig, SudoConfig, SystemConfig, DOLLARS, WASM_BINARY, }; use pallet_staking::StakerStatus; @@ -19,7 +19,7 @@ use webb_proposals::TypedChainId; // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = sc_service::GenericChainSpec; +pub type ChainSpec = sc_service::GenericChainSpec; /// Generate a crypto pair from seed. pub fn get_from_seed(seed: &str) -> ::Public { @@ -53,7 +53,7 @@ fn session_keys(grandpa: GrandpaId, aura: AuraId, dkg: DKGId) -> SessionKeys { SessionKeys { grandpa, aura, dkg } } -fn development_config_genesis() -> GenesisConfig { +fn development_config_genesis() -> RuntimeGenesisConfig { let wasm_binary = WASM_BINARY.unwrap(); testnet_genesis( wasm_binary, @@ -80,7 +80,7 @@ pub fn development_config() -> ChainSpec { ) } -fn local_testnet_genesis() -> GenesisConfig { +fn local_testnet_genesis() -> RuntimeGenesisConfig { let wasm_binary = WASM_BINARY.unwrap(); testnet_genesis( wasm_binary, @@ -114,7 +114,7 @@ fn testnet_genesis( initial_nominators: Vec, root_key: AccountId, endowed_accounts: Option>, -) -> GenesisConfig { +) -> RuntimeGenesisConfig { let mut endowed_accounts: Vec = endowed_accounts.unwrap_or_else(|| { vec![ get_account_id_from_seed::("Alice"), @@ -163,10 +163,11 @@ fn testnet_genesis( const ENDOWMENT: Balance = 10_000_000 * DOLLARS; const STASH: Balance = ENDOWMENT / 1000; - GenesisConfig { + RuntimeGenesisConfig { system: SystemConfig { // Add Wasm runtime to storage. code: wasm_binary.to_vec(), + ..Default::default() }, balances: BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. diff --git a/node/src/command.rs b/node/src/command.rs index aa517e84..d33f1f49 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -6,7 +6,7 @@ use crate::{ }; use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; use node_template_runtime::{Block, EXISTENTIAL_DEPOSIT}; -use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli}; +use sc_cli::SubstrateCli; use sc_service::PartialComponents; use sp_keyring::Sr25519Keyring; @@ -46,10 +46,6 @@ impl SubstrateCli for Cli { Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), }) } - - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &node_template_runtime::VERSION - } } /// Parse and run command line arguments @@ -124,7 +120,7 @@ pub fn run() -> sc_cli::Result<()> { ) } - cmd.run::(config) + cmd.run::(config) }, BenchmarkCmd::Block(cmd) => { let PartialComponents { client, .. } = service::new_partial(&config)?; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 981f375d..53c59bc0 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use jsonrpsee::RpcModule; -use node_template_runtime::{opaque::Block, AccountId, Balance, Index}; +use node_template_runtime::{opaque::Block, AccountId, Balance, Nonce}; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; @@ -34,7 +34,7 @@ where C: ProvideRuntimeApi, C: HeaderBackend + HeaderMetadata + 'static, C: Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, diff --git a/node/src/service.rs b/node/src/service.rs index 9e761e68..cf6e1e13 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,12 +1,14 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. +use futures::FutureExt; use node_template_runtime::{self, opaque::Block, RuntimeApi}; -use sc_client_api::BlockBackend; +use sc_client_api::{Backend, BlockBackend}; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_grandpa::SharedVoterState; pub use sc_executor::NativeElseWasmExecutor; use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams}; 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 webb_proposals::TypedChainId; @@ -185,15 +187,6 @@ pub fn new_full( warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), })?; - if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - let role = config.role.clone(); let force_authoring = config.force_authoring; let backoff_authoring_blocks: Option<()> = None; @@ -201,6 +194,27 @@ pub fn new_full( let enable_grandpa = !config.disable_grandpa; let prometheus_registry = config.prometheus_registry().cloned(); + if config.offchain_worker.enabled { + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "offchain-work", + sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { + runtime_api_provider: client.clone(), + keystore: Some(keystore_container.keystore()), + offchain_db: backend.offchain_storage(), + transaction_pool: Some(OffchainTransactionPoolFactory::new( + transaction_pool.clone(), + )), + network_provider: network.clone(), + is_validator: role.is_authority(), + enable_http_requests: true, + custom_extensions: move |_| vec![], + }) + .run(client.clone(), task_manager.spawn_handle()) + .boxed(), + ); + } + let rpc_extensions_builder = { let client = client.clone(); let pool = transaction_pool.clone(); @@ -231,7 +245,7 @@ pub fn new_full( let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), - transaction_pool, + transaction_pool.clone(), prometheus_registry.as_ref(), telemetry.as_ref().map(|x| x.handle()), ); @@ -340,6 +354,7 @@ pub fn new_full( prometheus_registry, shared_voter_state: SharedVoterState::empty(), telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), }; // the GRANDPA voter task is considered infallible, i.e. diff --git a/pallets/eth2-light-client/Cargo.toml b/pallets/eth2-light-client/Cargo.toml index 3398d22b..f960c554 100644 --- a/pallets/eth2-light-client/Cargo.toml +++ b/pallets/eth2-light-client/Cargo.toml @@ -10,7 +10,7 @@ targets = ["x86_64-unknown-linux-gnu"] serde = { version = "1.0.101", default-features = false, features = ["derive"], optional = true } codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", default-features = false, features = ["scale", "evm", "substrate"] } +webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", rev="a960eaf",default-features = false, features = ["scale", "evm", "substrate"] } ethereum-types = { version = "0.14.1", default-features = false } derive_more = { version = "^0.99.2", default-features = false } rlp = { version = "0.5.0", default-features = false } diff --git a/pallets/eth2-light-client/runtime-api/Cargo.toml b/pallets/eth2-light-client/runtime-api/Cargo.toml index 99eaccab..aa0365f8 100644 --- a/pallets/eth2-light-client/runtime-api/Cargo.toml +++ b/pallets/eth2-light-client/runtime-api/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false } sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", default-features = false, features = ["scale", "evm"] } +webb-proposals = { git = "https://github.com/webb-tools/webb-rs.git", rev="a960eaf", default-features = false, features = ["scale", "evm"] } eth-types = { path = "../../../crates/eth-types", default-features = false } [features] diff --git a/pallets/eth2-light-client/src/mock.rs b/pallets/eth2-light-client/src/mock.rs index 56b5d8df..13eb0ce6 100644 --- a/pallets/eth2-light-client/src/mock.rs +++ b/pallets/eth2-light-client/src/mock.rs @@ -2,31 +2,24 @@ use super::*; use crate as pallet_eth2_light_client; use consensus::network_config::{Network, NetworkConfig}; -use frame_support::{parameter_types, sp_io, traits::GenesisBuild}; +use frame_support::{parameter_types, sp_io}; use frame_system as system; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, - AccountId32, MultiSignature, + AccountId32, BuildStorage, MultiSignature, }; use sp_std::convert::{TryFrom, TryInto}; pub type Signature = MultiSignature; pub type AccountId = <::Signer as IdentifyAccount>::AccountId; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Event}, - Eth2Client: pallet_eth2_light_client::{Pallet, Call, Storage, Event}, + pub enum Test { + System: frame_system, + Balances: pallet_balances, + Eth2Client: pallet_eth2_light_client, } ); @@ -41,15 +34,14 @@ impl system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockHashCount = BlockHashCount; type BlockLength = (); - type BlockNumber = u64; + type Nonce = u64; + type Block = frame_system::mocking::MockBlock; type BlockWeights = (); type RuntimeCall = RuntimeCall; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; - type Index = u64; type Lookup = IdentityLookup; type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); @@ -75,15 +67,17 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); type FreezeIdentifier = (); type MaxHolds = (); type MaxFreezes = (); type WeightInfo = (); + type RuntimeHoldReason = RuntimeHoldReason; } parameter_types! { + #[derive(serde::Serialize, serde::Deserialize)] pub const MaxAdditionalFields: u32 = 5; + #[derive(serde::Serialize, serde::Deserialize)] pub const MaxResources: u32 = 32; pub const StoragePricePerByte: u128 = 1; pub const Eth2ClientPalletId: PalletId = PalletId(*b"py/eth2c"); @@ -98,7 +92,7 @@ impl pallet_eth2_light_client::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - let mut storage = system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = pallet_balances::GenesisConfig:: { balances: vec![ (AccountId32::new([1u8; 32]), 10u128.pow(18)), diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a166d3c5..7141704c 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -63,10 +63,10 @@ pallet-eth2-light-client = { path = "../pallets/eth2-light-client", default-feat pallet-eth2-light-client-runtime-api = { path = "../pallets/eth2-light-client/runtime-api", default-features = false } # DKG Substrate Dependencies -dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", default-features = false } -pallet-dkg-metadata = { git = "https://github.com/webb-tools/dkg-substrate.git", default-features = false } -pallet-dkg-proposal-handler = { git = "https://github.com/webb-tools/dkg-substrate.git", default-features = false } -pallet-dkg-proposals = { git = "https://github.com/webb-tools/dkg-substrate.git", default-features = false } +dkg-runtime-primitives = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.1", default-features = false } +pallet-dkg-metadata = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.1", default-features = false } +pallet-dkg-proposal-handler = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.1", default-features = false } +pallet-dkg-proposals = { git = "https://github.com/webb-tools/dkg-substrate.git", tag = "v0.4.1", default-features = false } [build-dependencies] substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 28a3806f..cbce1e91 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -14,7 +14,7 @@ use dkg_runtime_primitives::{ use frame_election_provider_support::{ onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight, }; -use frame_support::{dispatch::DispatchClass, traits::U128CurrencyToVote, PalletId}; +use frame_support::{dispatch::DispatchClass, PalletId}; use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, @@ -34,8 +34,8 @@ use sp_runtime::{ generic::Era, impl_opaque_keys, traits::{ - self, AccountIdLookup, BlakeTwo256, Block as BlockT, Get, IdentifyAccount, NumberFor, One, - OpaqueKeys, SaturatedConversion, StaticLookup, Verify, + self, BlakeTwo256, Block as BlockT, Get, IdentifyAccount, NumberFor, One, OpaqueKeys, + SaturatedConversion, StaticLookup, Verify, }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, Percent, @@ -51,7 +51,8 @@ use pallet_session::historical as pallet_session_historical; pub use frame_support::{ construct_runtime, parameter_types, traits::{ - ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo, + ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, + StorageInfo, }, weights::{ constants::{ @@ -93,7 +94,7 @@ pub type AccountId = <::Signer as IdentifyAccount>::Account pub type Balance = u128; /// Index of a transaction in the chain. -pub type Index = u32; +pub type Nonce = u32; /// A hash of some data used by the chain. pub type Hash = sp_core::H256; @@ -201,16 +202,12 @@ impl frame_system::Config for Runtime { type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = Indices; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Block = Block; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. - type Header = generic::Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -295,7 +292,7 @@ impl pallet_staking::Config for Runtime { type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = Timestamp; - type CurrencyToVote = U128CurrencyToVote; + type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote; type RewardRemainder = (); type RuntimeEvent = RuntimeEvent; type Slash = (); @@ -316,7 +313,7 @@ impl pallet_staking::Config for Runtime { type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = HistoryDepth; - type OnStakerSlash = (); + type EventListeners = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; type BenchmarkingConfig = StakingBenchmarkingConfig; } @@ -479,8 +476,7 @@ parameter_types! { pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS; } -type VoterBagsListInstance = pallet_bags_list::Instance1; -impl pallet_bags_list::Config for Runtime { +impl pallet_bags_list::Config for Runtime { type RuntimeEvent = RuntimeEvent; /// The voter bags-list is loosely kept up to date, and the real source of truth for the score /// of each node is the staking pallet. @@ -494,6 +490,7 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = ConstU32<32>; + type AllowMultipleBlocksPerSlot = ConstBool; } parameter_types! { @@ -544,7 +541,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = (); } @@ -678,7 +675,7 @@ where call: RuntimeCall, public: ::Signer, account: AccountId, - nonce: Index, + nonce: Nonce, ) -> Option<(RuntimeCall, ::SignaturePayload)> { let tip = 0; // take the biggest period possible. @@ -727,12 +724,7 @@ where // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: frame_system, Timestamp: pallet_timestamp, Indices: pallet_indices, @@ -743,7 +735,7 @@ construct_runtime!( Sudo: pallet_sudo, Utility: pallet_utility, ElectionProviderMultiPhase: pallet_election_provider_multi_phase, - VoterList: pallet_bags_list, + VoterList: pallet_bags_list, Staking: pallet_staking, Session: pallet_session, Historical: pallet_session_historical, @@ -964,8 +956,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } }