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

Commit

Permalink
fix most of the clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthDesai committed Oct 30, 2023
1 parent 41167bb commit 42ca261
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 56 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fp-evm = { version = "3.0.0-dev", git = "https://github.com/subspace/frontier",
frame-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" }
futures = "0.3"
hex-literal = "0.4"
once_cell = "1.18.0"
pallet-rewards = { git = "https://github.com/subspace/subspace", rev = "aa2ca80b42b460dd73c1567057d6c07151a626dd" }
pallet-subspace = { git = "https://github.com/subspace/subspace", rev = "aa2ca80b42b460dd73c1567057d6c07151a626dd" }
parity-scale-codec = "3.6.3"
Expand All @@ -32,7 +31,6 @@ sc-consensus-subspace = { git = "https://github.com/subspace/subspace", rev = "a
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" }
sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" }
sc-proof-of-time = { git = "https://github.com/subspace/subspace", rev = "aa2ca80b42b460dd73c1567057d6c07151a626dd" }
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" }
sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false }
sc-storage-monitor = { version = "0.1.0", git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1", default-features = false }
Expand Down
14 changes: 5 additions & 9 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ use sp_core::crypto::{Ss58Codec, UncheckedFrom};
use sp_domains::storage::RawGenesis;
use sp_domains::{OperatorAllowList, RuntimeType};
use sp_runtime::{BuildStorage, Percent};
use subspace_runtime::{
AllowAuthoringBy, BalancesConfig, DomainsConfig, GenesisConfig, MaxDomainBlockSize,
MaxDomainBlockWeight, RuntimeConfigsConfig, SubspaceConfig, SudoConfig, SystemConfig,
VestingConfig, MILLISECS_PER_BLOCK, WASM_BINARY,
};
use subspace_runtime::{AllowAuthoringBy, BalancesConfig, DomainsConfig, MaxDomainBlockSize, MaxDomainBlockWeight, RuntimeConfigsConfig, SubspaceConfig, SudoConfig, SystemConfig, VestingConfig, MILLISECS_PER_BLOCK, WASM_BINARY, RuntimeGenesisConfig};
use subspace_runtime_primitives::{AccountId, Balance, BlockNumber, SSC};

use crate::domains::evm_chain_spec;
Expand Down Expand Up @@ -59,7 +55,7 @@ pub struct GenesisParams {
}

/// Chain spec type for the subspace
pub type ChainSpec = SerializableChainSpec<GenesisConfig>;
pub type ChainSpec = SerializableChainSpec<RuntimeGenesisConfig>;

/// Gemini 3f chain spec
pub fn gemini_3f() -> ChainSpec {
Expand Down Expand Up @@ -344,7 +340,7 @@ fn subspace_genesis_config(
// who, start, period, period_count, per_period
vesting: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>,
genesis_params: GenesisParams,
) -> GenesisConfig {
) -> RuntimeGenesisConfig {
let GenesisParams {
enable_rewards,
enable_storage_access,
Expand All @@ -355,7 +351,7 @@ fn subspace_genesis_config(
confirmation_depth_k,
} = genesis_params;

let (mut domain_genesis_config, genesis_domain_params) =
let (domain_genesis_config, genesis_domain_params) =
evm_chain_spec::get_testnet_genesis_by_spec_id(evm_domain_spec_id);

let raw_genesis_storage = {
Expand All @@ -366,7 +362,7 @@ fn subspace_genesis_config(
raw_genesis.encode()
};

GenesisConfig {
RuntimeGenesisConfig {
domains: DomainsConfig {
genesis_domain: Some(sp_domains::GenesisDomain {
runtime_name: "evm".into(),
Expand Down
5 changes: 0 additions & 5 deletions node/src/domains/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ pub struct ConsensusNodeLink {
Arc<sc_network::NetworkService<CBlock, <CBlock as BlockT>::Hash>>,
/// Reference to the consensus node's network sync service
pub consensus_sync_service: Arc<sc_network_sync::SyncingService<CBlock>>,
/// Consensus node's select chain
pub select_chain: FullSelectChain,
/// Consensus tx pool
pub consensus_transaction_pool:
Arc<FullPool<CBlock, CFullClient<CRuntimeApi, CExecutorDispatch>>>,
Expand Down Expand Up @@ -168,7 +166,6 @@ impl DomainConfig {
new_slot_notification_stream,
consensus_network_service,
consensus_sync_service,
select_chain,
consensus_transaction_pool,
} = consensus_node_link;
let printable_domain_id: u32 = self.domain_id.into();
Expand Down Expand Up @@ -345,15 +342,13 @@ impl DomainConfig {
let domain_starter = DomainInstanceStarter {
service_config,
domain_id: self.domain_id,
relayer_id: self.relayer_id.clone(),
runtime_type,
additional_arguments: self.additional_args.clone(),
consensus_client,
block_importing_notification_stream,
new_slot_notification_stream,
consensus_network_service,
consensus_sync_service,
select_chain,
consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(
consensus_transaction_pool.clone(),
),
Expand Down
11 changes: 3 additions & 8 deletions node/src/domains/domain_instance_starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,24 @@ use sc_consensus_subspace::{BlockImportingNotification, NewSlotNotification};
use sc_service::{BasePath, Configuration, RpcHandlers};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sc_utils::mpsc::{TracingUnboundedReceiver, TracingUnboundedSender};
use sp_core::crypto::AccountId32;
use sp_core::traits::SpawnEssentialNamed;
use sp_domains::{DomainId, RuntimeType};
use sp_messenger::messages::ChainId;
use sp_runtime::traits::{Block as BlockT, Convert, NumberFor};
use sp_runtime::traits::{Block as BlockT, NumberFor};
use subspace_runtime::RuntimeApi as CRuntimeApi;
use subspace_runtime_primitives::opaque::Block as CBlock;
use subspace_service::{FullClient as CFullClient, FullSelectChain};
use subspace_service::FullClient as CFullClient;
use tokio::task::JoinHandle;

use crate::domains::evm_domain_executor_dispatch::EVMDomainExecutorDispatch;
use crate::domains::utils::{AccountId20, AccountId32ToAccountId20Converter};
use crate::domains::utils::AccountId20;
use crate::ExecutorDispatch as CExecutorDispatch;

/// `DomainInstanceStarter` used to start a domain instance node based on the
/// given bootstrap result
pub struct DomainInstanceStarter {
pub service_config: Configuration,
pub domain_id: DomainId,
pub relayer_id: AccountId32,
pub runtime_type: RuntimeType,
pub additional_arguments: Vec<String>,
pub consensus_client: Arc<CFullClient<CRuntimeApi, CExecutorDispatch>>,
Expand All @@ -42,7 +40,6 @@ pub struct DomainInstanceStarter {
pub consensus_network_service:
Arc<sc_network::NetworkService<CBlock, <CBlock as BlockT>::Hash>>,
pub consensus_sync_service: Arc<sc_network_sync::SyncingService<CBlock>>,
pub select_chain: FullSelectChain,
pub consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory<CBlock>,
pub domain_message_sink: TracingUnboundedSender<Vec<u8>>,
pub domain_message_receiver: TracingUnboundedReceiver<Vec<u8>>,
Expand All @@ -57,15 +54,13 @@ impl DomainInstanceStarter {
let DomainInstanceStarter {
domain_id,
runtime_type,
relayer_id,
mut additional_arguments,
service_config,
consensus_client,
block_importing_notification_stream,
new_slot_notification_stream,
consensus_network_service,
consensus_sync_service,
select_chain,
consensus_offchain_tx_pool_factory,
domain_message_receiver,
domain_message_sink,
Expand Down
29 changes: 3 additions & 26 deletions node/src/domains/evm_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ use std::str::FromStr;

use evm_domain_runtime::{
AccountId, BalancesConfig, EVMChainIdConfig, EVMConfig, Precompiles, RuntimeGenesisConfig,
SelfDomainIdConfig, SudoConfig, SystemConfig, WASM_BINARY,
SudoConfig, SystemConfig, WASM_BINARY,
};
use hex_literal::hex;
use once_cell::sync::OnceCell;
use sc_service::{ChainSpec as _, ChainType};
use sc_subspace_chain_specs::ExecutionChainSpec;
use sdk_utils::chain_spec::{
chain_spec_properties, get_account_id_from_seed, get_public_key_from_seed,
chain_spec_properties, get_public_key_from_seed,
};
use sp_core::crypto::UncheckedFrom;
use sp_domains::storage::RawGenesis;
use sp_domains::{DomainId, DomainInstanceData, OperatorPublicKey, RuntimeType};
use sp_runtime::traits::Convert;
use sp_domains::OperatorPublicKey;
use subspace_runtime_primitives::SSC;

use crate::domains::utils::AccountId32ToAccountId20Converter;

/// Chain spec type for the system domain
pub type ChainSpec = ExecutionChainSpec<RuntimeGenesisConfig>;

Expand Down Expand Up @@ -52,11 +48,6 @@ pub fn create_domain_spec(chain_id: &str, raw_genesis: RawGenesis) -> Result<Cha
Ok(chain_spec)
}

// HACK: `ChainSpec::from_genesis` is only allow to create hardcoded spec and
// `RuntimeGenesisConfig` dosen't derive `Clone`, using global variable and
// serialization/deserialization to workaround these limits.
static GENESIS_CONFIG: OnceCell<Vec<u8>> = OnceCell::new();

/// Development keys that will be injected automatically on polkadotjs apps
fn get_dev_accounts() -> Vec<AccountId> {
vec![
Expand All @@ -82,12 +73,6 @@ pub fn get_testnet_genesis_by_spec_id(
accounts.clone(),
// Alith is Sudo
Some(accounts[0]),
vec![(
accounts[0],
AccountId32ToAccountId20Converter::convert(get_account_id_from_seed(
"Alice",
)),
)],
1000,
),
GenesisDomainParams {
Expand All @@ -105,7 +90,6 @@ pub fn get_testnet_genesis_by_spec_id(
sudo_account,
],
Some(sudo_account),
Default::default(),
1002,
),
GenesisDomainParams {
Expand All @@ -125,11 +109,6 @@ pub fn get_testnet_genesis_by_spec_id(
sudo_account,
],
Some(sudo_account),
vec![(
sudo_account,
AccountId::from_str("5b267fd1ba3ace6e3c3234f9576c49c877b5beb9")
.expect("Wrong relayer account address"),
)],
1003,
),
GenesisDomainParams {
Expand All @@ -146,7 +125,6 @@ pub fn get_testnet_genesis_by_spec_id(
accounts.clone(),
// Alith is sudo
Some(accounts[0]),
vec![(accounts[0], accounts[0]), (accounts[1], accounts[1])],
1001,
),
GenesisDomainParams {
Expand Down Expand Up @@ -254,7 +232,6 @@ pub fn devnet_config<F: Fn() -> RuntimeGenesisConfig + 'static + Send + Sync>(
fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
maybe_sudo_account: Option<AccountId>,
relayers: Vec<(AccountId, AccountId)>,
chain_id: u64,
) -> RuntimeGenesisConfig {
// This is the simplest bytecode to revert without returning any data.
Expand Down
7 changes: 3 additions & 4 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub use builder::*;
pub use domains::builder::{DomainConfig, DomainConfigBuilder};
pub use domains::domain::Domain;
pub use subspace_runtime::RuntimeEvent as Event;
use tracing::{log, Instrument};
use tracing::Instrument;

use crate::domains::builder::ConsensusNodeLink;

Expand Down Expand Up @@ -219,7 +219,7 @@ impl<F: Farmer + 'static> Config<F> {
network_service,

backend: _,
select_chain,
select_chain: _,
reward_signing_notification_stream: _,
archived_segment_notification_stream: _,
transaction_pool,
Expand Down Expand Up @@ -280,7 +280,6 @@ impl<F: Farmer + 'static> Config<F> {
new_slot_notification_stream: new_slot_notification_stream.clone(),
consensus_network_service: network_service.clone(),
consensus_sync_service: sync_service.clone(),
select_chain: select_chain.clone(),
consensus_transaction_pool: transaction_pool.clone(),
},
)
Expand Down Expand Up @@ -573,7 +572,7 @@ impl<F: Farmer + 'static> Node<F> {
.build();
let check_synced_backoff = backoff::ExponentialBackoffBuilder::new()
.with_initial_interval(Duration::from_secs(1))
.with_max_elapsed_time(Some(Duration::from_secs(5*60)))
.with_max_elapsed_time(Some(Duration::from_secs(10*60)))
.build();

backoff::future::retry(check_offline_backoff, || {
Expand Down

0 comments on commit 42ca261

Please sign in to comment.