Skip to content

Commit

Permalink
chore(upgrade): v1.10.0 to v1.11.0 (#2117)
Browse files Browse the repository at this point in the history
- Upgrade Polkadot-sdk 1.10.0 to 1.11.0
- Update weights to reflect the new version.

Notable Changes:
- [Apply patch
`run_with_spec`](paritytech/polkadot-sdk#3512)
- [Genesis
Presets](paritytech/polkadot-sdk#2714)
- [Integrate
LiteP2P](paritytech/polkadot-sdk#2944)
- [Template
Simplification](https://github.com/paritytech/polkadot-sdk/pull/3801/files)
- [Remove
try-runtime-cli](https://github.com/paritytech/polkadot-sdk/pull/4017/files#diff-3a3aa5e088741f8ab1ca38fbe314c7a150d18b7466426f4ad2569113017e8439)

For more details, please refer to:

[Release
Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.11.0)

#1957
  • Loading branch information
enddynayn authored Aug 13, 2024
1 parent fc83604 commit 8e49b58
Show file tree
Hide file tree
Showing 38 changed files with 2,114 additions and 1,770 deletions.
1,874 changes: 1,114 additions & 760 deletions Cargo.lock

Large diffs are not rendered by default.

197 changes: 98 additions & 99 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ ignore = [
{ id = "RUSTSEC-2020-0168", reason = "There is no suitable replacement for mach and the mach2 crate has not been vetted." },
{ id = "RUSTSEC-2024-0336", reason = "Only use of rustls@v0.20.9 is in futures-rustls which does not use the effected code" },
{ id = "RUSTSEC-2024-0344", reason = "We are only able to remove this once parity updates its dependencies. Older versions of curve25519-dalek should get replaces with >= 4.1.3" },
{ id = "RUSTSEC-2022-0093", reason = "The vulnerable code is not exploitable in Frequency because the signing function is not exposed in a way that allows the use of arbitrary public keys, ensuring protection against the described vulnerability." },
]
# If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library.
Expand Down
2 changes: 1 addition & 1 deletion e2e/capacity/capacity_rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Capacity RPC', function () {
assert.notEqual(feeDetails.inclusionFee, undefined, 'should have returned a partialFee');
assert(feeDetails.inclusionFee.isSome, 'should have returned a partialFee');
const { baseFee, lenFee, adjustedWeightFee } = feeDetails.inclusionFee.toJSON() as any;
const baseFeeSnapshot = 177812;
const baseFeeSnapshot = 124103;
assert(
Math.abs(baseFee - baseFeeSnapshot) < 50_000,
'The base fee appears to be wrong or have changed more than expected'
Expand Down
4 changes: 1 addition & 3 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sp-inherents = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
sp-timestamp = { workspace = true }
try-runtime-cli = { workspace = true, optional = true }

# Polkadot
polkadot-cli = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
Expand All @@ -73,7 +73,6 @@ cli = [
"sc-service",
"frame-benchmarking-cli",
"frame-benchmarking",
"try-runtime-cli",
]
default = ["std", "cli"]
runtime-benchmarks = [
Expand All @@ -85,7 +84,6 @@ runtime-benchmarks = [
]
try-runtime = [
"frequency-service/try-runtime",
"try-runtime-cli/try-runtime",
"sp-runtime/try-runtime"
]
on-chain-release-build = ["sp-api/disable-logging"]
Expand Down
4 changes: 3 additions & 1 deletion node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ pub fn run() -> Result<()> {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| {
cmd.run::<HashingFor<Block>, ReclaimHostFunctions>(config)
cmd.run_with_spec::<HashingFor<Block>, ReclaimHostFunctions>(Some(
config.chain_spec,
))
})
} else {
return Err("Benchmarking wasn't enabled when building the node. \
Expand Down
4 changes: 2 additions & 2 deletions node/cli/src/run_as_localchain.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::cli::Cli;
use frequency_service::block_sealing::frequency_dev_sealing;
use frequency_service::block_sealing::start_frequency_dev_sealing_node;
use sc_cli::SubstrateCli;

pub fn run_as_localchain(cli: Cli) -> sc_service::Result<(), sc_cli::Error> {
let runner = cli.create_runner(&cli.run.normalize())?;

runner.run_node_until_exit(|config| async move {
frequency_dev_sealing(
start_frequency_dev_sealing_node(
config,
cli.sealing,
u16::from(cli.sealing_interval),
Expand Down
38 changes: 18 additions & 20 deletions node/cli/src/run_as_parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@ use cumulus_primitives_core::ParaId;
use frequency_service::chain_spec;
use log::info;
use sc_cli::SubstrateCli;
use sp_runtime::traits::AccountIdConversion;

pub fn run_as_parachain(cli: Cli) -> sc_service::Result<(), sc_cli::Error> {
let runner = cli.create_runner(&cli.run.normalize())?;
let collator_options = cli.run.collator_options();

runner.run_node_until_exit(|config| async move {
let hwbench = (!cli.no_hardware_benchmarks)
.then_some(config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
}))
.flatten();

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.map(|e: &chain_spec::Extensions| e.para_id)
.ok_or("Could not find parachain ID in chain-spec.")?;
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

let tokio_handle = config.tokio_handle.clone();
let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()),
);

let id = ParaId::from(para_id);

let tokio_handle = config.tokio_handle.clone();

let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

let collator_options = cli.run.collator_options();
let hwbench = if !cli.no_hardware_benchmarks {
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};
info!("Parachain id: {:?}", id);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

return frequency_service::service::start_parachain_node(
config,
polkadot_config,
Expand Down
2 changes: 1 addition & 1 deletion node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sp-wasm-interface = { workspace = true }

substrate-frame-rpc-system = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }
try-runtime-cli = { workspace = true }

# Polkadot
polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
Expand Down
19 changes: 14 additions & 5 deletions node/service/src/block_sealing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use cli_opt::SealingMode;
pub use futures::stream::StreamExt;
use sc_consensus::block_import::BlockImport;

use common_primitives::node::{Block, Hash};
use core::marker::PhantomData;
use futures::Stream;
use sc_client_api::backend::{Backend as ClientBackend, Finalizer};
Expand All @@ -11,19 +12,20 @@ use sc_consensus_manual_seal::{
};

use futures::FutureExt;
use sc_network::NetworkBackend;
use sc_service::{Configuration, TaskManager};
use sc_transaction_pool_api::{OffchainTransactionPoolFactory, TransactionPool};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::{Environment, Proposer, SelectChain};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
use std::task::Poll;
use std::{sync::Arc, task::Poll};

/// Function to start Frequency in dev mode without a relay chain
/// This function is called when --chain dev --sealing= is passed.
#[allow(clippy::expect_used)]
pub fn frequency_dev_sealing(
pub fn start_frequency_dev_sealing_node(
config: Configuration,
sealing_mode: SealingMode,
sealing_interval: u16,
Expand All @@ -36,8 +38,11 @@ pub fn frequency_dev_sealing(
};
log::info!("📎 Development mode (no relay chain) with {} sealing{}", sealing_mode, extra);

let net_config: sc_network::config::FullNetworkConfiguration =
sc_network::config::FullNetworkConfiguration::new(&config.network);
let net_config = sc_network::config::FullNetworkConfiguration::<
_,
_,
sc_network::NetworkWorker<Block, Hash>,
>::new(&config.network);
let sc_service::PartialComponents {
client,
backend,
Expand All @@ -48,6 +53,9 @@ pub fn frequency_dev_sealing(
transaction_pool,
other: (_block_import, mut telemetry, _),
} = new_partial(&config, true)?;
let metrics = sc_network::NetworkWorker::<Block, Hash>::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);

// Build the network components required for the blockchain.
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
Expand All @@ -61,6 +69,7 @@ pub fn frequency_dev_sealing(
block_announce_validator_builder: None,
warp_sync_params: None,
block_relay: None,
metrics,
})?;

// Start off-chain workers if enabled
Expand All @@ -75,7 +84,7 @@ pub fn frequency_dev_sealing(
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
network_provider: Arc::new(network.clone()),
enable_http_requests: true,
custom_extensions: |_| vec![],
});
Expand Down
96 changes: 54 additions & 42 deletions node/service/src/chain_spec/frequency_dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,11 @@ pub fn development_config() -> ChainSpec {
.with_chain_type(ChainType::Development)
.with_protocol_id("dev")
.with_genesis_config(development_genesis(
// initial collators.
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob"),
),
],
// Sudo
Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
// Endowed Accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
common_runtime::constants::TREASURY_PALLET_ID.into_account_truncating(),
],
// Council members
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
],
// Technical Committee members
vec![
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
],
development_invulnerables(),
development_root(),
development_endowed_accounts(),
development_council_members(),
development_technical_committee_members(),
// ParaId
1000.into(),
))
Expand All @@ -94,7 +59,7 @@ fn load_genesis_schemas() -> Vec<frequency_runtime::pallet_schemas::GenesisSchem
#[allow(clippy::unwrap_used)]
fn development_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
root_key: Option<AccountId>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
council_members: Vec<AccountId>,
technical_committee_members: Vec<AccountId>,
Expand Down Expand Up @@ -134,7 +99,7 @@ fn development_genesis(
parachain_system: Default::default(),
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
schemas: frequency_runtime::pallet_schemas::GenesisConfig {
initial_schemas: load_genesis_schemas(),
Expand All @@ -152,3 +117,50 @@ fn development_genesis(

serde_json::to_value(&genesis).unwrap()
}

fn development_endowed_accounts() -> Vec<AccountId> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
common_runtime::constants::TREASURY_PALLET_ID.into_account_truncating(),
]
}

fn development_invulnerables() -> Vec<(AccountId, AuraId)> {
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice"),
),
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_collator_keys_from_seed("Bob")),
]
}

fn development_root() -> AccountId {
get_account_id_from_seed::<sr25519::Public>("Alice")
}

fn development_council_members() -> Vec<AccountId> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
]
}

fn development_technical_committee_members() -> Vec<AccountId> {
vec![
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
]
}
Loading

0 comments on commit 8e49b58

Please sign in to comment.