Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies to polkadot v1.6.0 #389

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
5,900 changes: 3,606 additions & 2,294 deletions Cargo.lock

Large diffs are not rendered by default.

294 changes: 147 additions & 147 deletions Cargo.toml

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions ownership-chain/node/src/chain_spec/klaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn development_config() -> ChainSpec {
properties.insert("tokenDecimals".into(), 18.into());
properties.insert("ss58Format".into(), 42.into());

// TODO: `from_genesis` will be deprecated in May 2024, use `GenesisBuilder` instead.
ChainSpec::from_genesis(
// Name
"Development",
Expand All @@ -50,6 +51,7 @@ pub fn development_config() -> ChainSpec {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 2001,
},
klaos_ownership_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
)
}

Expand Down Expand Up @@ -91,6 +93,7 @@ pub fn local_testnet_config() -> ChainSpec {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 2001,
},
klaos_ownership_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
)
}

Expand All @@ -101,12 +104,6 @@ fn testnet_genesis(
id: ParaId,
) -> klaos_ownership_runtime::RuntimeGenesisConfig {
klaos_ownership_runtime::RuntimeGenesisConfig {
system: klaos_ownership_runtime::SystemConfig {
code: klaos_ownership_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: klaos_ownership_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1e24 as u128)).collect(),
},
Expand Down
9 changes: 3 additions & 6 deletions ownership-chain/node/src/chain_spec/laos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn development_config() -> ChainSpec {
properties.insert("tokenDecimals".into(), 18.into());
properties.insert("ss58Format".into(), 42.into());

// TODO: `from_genesis` will be deprecated in May 2024, use `GenesisBuilder` instead.
ChainSpec::from_genesis(
// Name
"Development",
Expand All @@ -52,6 +53,7 @@ pub fn development_config() -> ChainSpec {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 2001,
},
laos_ownership_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
)
}

Expand Down Expand Up @@ -93,6 +95,7 @@ pub fn local_testnet_config() -> ChainSpec {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: 2001,
},
laos_ownership_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
)
}

Expand All @@ -117,12 +120,6 @@ fn testnet_genesis(
);

laos_ownership_runtime::RuntimeGenesisConfig {
system: laos_ownership_runtime::SystemConfig {
code: laos_ownership_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: laos_ownership_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1e24 as u128)).collect(),
},
Expand Down
2 changes: 1 addition & 1 deletion ownership-chain/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum Subcommand {
PurgeChain(cumulus_client_cli::PurgeChainCmd),

/// Export the genesis state of the parachain.
ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),
ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),

/// Export the genesis wasm of the parachain.
ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
Expand Down
17 changes: 4 additions & 13 deletions ownership-chain/node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::{net::SocketAddr, sync::Arc};

use cumulus_client_cli::generate_genesis_block;
use cumulus_primitives_core::ParaId;
use fc_db::kv::frontier_database_dir;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use laos_ownership_runtime::Block;
use log::info;
use parity_scale_codec::Encode;
use polkadot_service::RococoChainSpec;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
Expand All @@ -16,8 +14,7 @@ use sc_service::{
config::{BasePath, PrometheusConfig},
DatabaseSource, PartialComponents,
};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use sp_runtime::traits::AccountIdConversion;

#[cfg(feature = "try-runtime")]
use crate::service::ParachainNativeExecutor;
Expand Down Expand Up @@ -250,12 +247,12 @@ pub fn run() -> Result<()> {
cmd.run(config, polkadot_config)
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
Some(Subcommand::ExportGenesisHead(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
let partials = new_partial(&config, &eth_cfg)?;
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
cmd.run::<laos_ownership_runtime::opaque::Block>(&*spec, &*partials.client)

cmd.run(partials.client)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand Down Expand Up @@ -388,19 +385,13 @@ pub fn run() -> Result<()> {
&id,
);

let block: laos_ownership_runtime::opaque::Block =
generate_genesis_block(&*config.chain_spec, sp_runtime::StateVersion::V1)
.map_err(|e| format!("{:?}", e))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

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))?;

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

crate::service::start_parachain_node(
Expand Down
15 changes: 9 additions & 6 deletions ownership-chain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use futures::FutureExt;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
Expand Down Expand Up @@ -387,12 +386,15 @@ async fn start_node_impl(

if let Some(hwbench) = hwbench {
sc_sysinfo::print_hwbench(&hwbench);
// Here you can check whether the hardware meets your chains' requirements. Putting a link
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator {
// Polkadot para-chains should generally use these requirements to ensure that the
// relay-chain will not take longer than expected to import its blocks.
if let Err(err) =
frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench)
{
log::warn!(
"⚠️ The hardware does not meet the minimal requirements for role 'Authority'."
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority' find out more at:\n\
https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware",
err
);
}

Expand Down Expand Up @@ -554,6 +556,7 @@ fn start_consensus(
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
};

let fut =
Expand Down
13 changes: 9 additions & 4 deletions ownership-chain/pallets/parachain-staking/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
};
use frame_support::traits::fungible::Inspect;
use sp_runtime::{
traits::{Saturating, Zero},
traits::{SaturatedConversion, Saturating, Zero},
Perquintill,
};

Expand All @@ -46,8 +46,10 @@ impl<T: Config> Pallet<T> {
BlocksAuthored::<T>::get(&delegator_state.owner).saturating_sub(count_rewarded);
let stake = delegator_state.amount;
// rewards += stake * reward_count * delegator_reward_rate
rewards
.saturating_add(Self::calc_block_rewards_delegator(stake, count_unclaimed.into()))
rewards.saturating_add(Self::calc_block_rewards_delegator(
stake,
count_unclaimed.saturated_into(),
))
} else if Self::is_active_candidate(acc).is_some() {
// #blocks for unclaimed staking rewards equals
// #blocks_authored_by_collator - #blocks_claimed_by_collator
Expand All @@ -56,7 +58,10 @@ impl<T: Config> Pallet<T> {
.map(|state| state.stake)
.unwrap_or_else(BalanceOf::<T>::zero);
// rewards += stake * self_count * collator_reward_rate
rewards.saturating_add(Self::calc_block_rewards_collator(stake, count_unclaimed.into()))
rewards.saturating_add(Self::calc_block_rewards_collator(
stake,
count_unclaimed.saturated_into(),
))
} else {
rewards
}
Expand Down
22 changes: 9 additions & 13 deletions ownership-chain/pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub mod pallet {
fungible::Balanced,
tokens::{
fungible::{Inspect, MutateFreeze},
Fortitude, Preservation,
Balance as BalanceT, Fortitude, Preservation,
},
BuildGenesisConfig, Currency, EstimateNextSessionRotation,
ExistenceRequirement::KeepAlive,
Expand All @@ -152,7 +152,6 @@ pub mod pallet {
use frame_system::pallet_prelude::*;
use pallet_balances::{Freezes, IdAmount};
use pallet_session::ShouldEndSession;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{Convert, One, SaturatedConversion, Saturating, StaticLookup, Zero},
Permill, Perquintill, TokenError,
Expand Down Expand Up @@ -214,19 +213,12 @@ pub mod pallet {
/// Just the `Currency::Balance` type; we have this item to allow us to
/// constrain it to `From<u64>`.
/// Note: Definition taken from pallet_gilt
type CurrencyBalance: sp_runtime::traits::AtLeast32BitUnsigned
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these traits are not needed because they are already included in BalanceT trait

+ parity_scale_codec::FullCodec
+ Copy
+ MaybeSerializeDeserialize
+ sp_std::fmt::Debug
+ Default
type CurrencyBalance: BalanceT
+ From<u64>
+ From<u128>
+ Into<<Self as pallet_balances::Config>::Balance>
+ From<<Self as pallet_balances::Config>::Balance>
+ From<BlockNumberFor<Self>>
+ TypeInfo
+ MaxEncodedLen;
+ From<BlockNumberFor<Self>>;

/// Minimum number of blocks validation rounds can last.
#[pallet::constant]
Expand Down Expand Up @@ -540,6 +532,10 @@ pub mod pallet {
}
}

#[pallet::storage]
pub(crate) type RewardPerBlock<T: Config> =
StorageValue<_, (BalanceOf<T>, BalanceOf<T>), ValueQuery>;

/// The maximum number of collator candidates selected at each round.
#[pallet::storage]
#[pallet::getter(fn max_selected_candidates)]
Expand Down Expand Up @@ -2553,7 +2549,7 @@ pub mod pallet {
Rewards::<T>::mutate(acc, |reward| {
*reward = reward.saturating_add(Self::calc_block_rewards_collator(
stake,
unclaimed_blocks.into(),
unclaimed_blocks.saturated_into(),
));
});
}
Expand All @@ -2576,7 +2572,7 @@ pub mod pallet {
Rewards::<T>::mutate(acc, |reward| {
*reward = reward.saturating_add(Self::calc_block_rewards_delegator(
stake,
unclaimed_blocks.into(),
unclaimed_blocks.saturated_into(),
))
});
}
Expand Down
7 changes: 5 additions & 2 deletions ownership-chain/precompile/asset-metadata-extender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was fixed by upstream frontier

handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(EvmDataWriter::new().build()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ where
handle.record_cost(consumed_gas)?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(
EvmDataWriter::new().write(Address(collection_address.into())).build(),
Expand Down
34 changes: 25 additions & 9 deletions ownership-chain/precompile/evolution-collection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(EvmDataWriter::new().write(token_id).build()))
},
Expand Down Expand Up @@ -232,8 +235,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(sp_std::vec![]))
},
Expand Down Expand Up @@ -263,8 +269,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(EvmDataWriter::new().build()))
},
Expand Down Expand Up @@ -294,8 +303,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
// TODO: Add `ref_time` when precompiles are benchmarked
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(EvmDataWriter::new().build()))
},
Expand Down Expand Up @@ -346,7 +358,11 @@ where
handle.record_cost(GasCalculator::<Runtime>::weight_to_gas(consumed_weight))?;

// Record Substrate related costs
handle.record_external_cost(None, Some(consumed_weight.proof_size()))?;
handle.record_external_cost(
Some(consumed_weight.ref_time()),
Some(consumed_weight.proof_size()),
None,
)?;

Ok(succeed(EvmDataWriter::new().build()))
}
Expand Down
Loading
Loading