Skip to content

Commit

Permalink
Merge branch 'main' into fix/deploy-contract-using-hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
asiniscalchi authored Nov 20, 2024
2 parents 047c1a4 + 744ee44 commit ca7fd7b
Show file tree
Hide file tree
Showing 26 changed files with 149 additions and 1,058 deletions.
27 changes: 0 additions & 27 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/pol
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
parachain-info = { package = "staging-parachain-info", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }

Expand All @@ -194,7 +191,6 @@ cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branc
cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
cumulus-client-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
cumulus-client-consensus-proposer = {git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0"}
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
Expand Down
3 changes: 0 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ cumulus-client-collator = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-consensus-relay-chain = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }

# Frontier
Expand Down
70 changes: 22 additions & 48 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ use cumulus_client_service::{
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
StartRelayChainTasksParams,
};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
ParaId,
};
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

// Substrate Imports
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
use fc_rpc::{StorageOverride, StorageOverrideHandler};
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use futures::FutureExt;
use laos_runtime::{
configs::cumulus_parachain_system::RELAY_CHAIN_SLOT_DURATION_MILLIS, RuntimeApi,
};
use laos_runtime::RuntimeApi;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::{
Expand All @@ -56,11 +50,9 @@ use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::{Slot, SlotDuration};
use sp_core::U256;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;

// Frontier
use crate::eth::{
db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, EthConfiguration,
Expand Down Expand Up @@ -318,6 +310,8 @@ async fn start_node_impl(
fc_mapping_sync::EthereumBlockNotification<Block>,
> = Default::default();
let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let target_gas_price = eth_config.target_gas_price;

// for ethereum-compatibility rpc.
parachain_config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
Expand Down Expand Up @@ -350,33 +344,15 @@ async fn start_node_impl(
execute_gas_limit_multiplier: eth_config.execute_gas_limit_multiplier,
forced_parent_hashes: None,
pending_create_inherent_data_providers: move |_, ()| async move {
// Patch from https://github.com/darwinia-network/darwinia/pull/1608
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let relay_chain_slot = Slot::from_timestamp(
timestamp.timestamp(),
SlotDuration::from_millis(RELAY_CHAIN_SLOT_DURATION_MILLIS.into()),
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current.timestamp().as_millis() + slot_duration.as_millis();
let timestamp = sp_timestamp::InherentDataProvider::new(next_slot.into());
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);

let state_proof_builder = cumulus_test_relay_sproof_builder::RelayStateSproofBuilder {
para_id,
current_slot: relay_chain_slot,
included_para_head: Some(polkadot_primitives::HeadData(vec![])),
..Default::default()
};
let (relay_parent_storage_root, relay_chain_state) =
state_proof_builder.into_state_root_and_proof();
let parachain_inherent_data =
cumulus_primitives_parachain_inherent::ParachainInherentData {
validation_data: cumulus_primitives_core::PersistedValidationData {
relay_parent_number: u32::MAX,
relay_parent_storage_root,
..Default::default()
},
relay_chain_state,
downward_messages: Default::default(),
horizontal_messages: Default::default(),
};
Ok((timestamp, parachain_inherent_data))
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))
},
};

Expand Down Expand Up @@ -420,7 +396,7 @@ async fn start_node_impl(
spawn_frontier_tasks(
&task_manager,
client.clone(),
backend.clone(),
backend,
frontier_backend,
filter_pool,
overrides,
Expand Down Expand Up @@ -487,7 +463,6 @@ async fn start_node_impl(
if validator {
start_consensus(
client.clone(),
backend.clone(),
block_import,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
Expand Down Expand Up @@ -549,7 +524,6 @@ fn build_import_queue(
#[allow(clippy::too_many_arguments)]
fn start_consensus(
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
block_import: ParachainBlockImport,
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
Expand All @@ -564,6 +538,10 @@ fn start_consensus(
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
) -> Result<(), sc_service::Error> {
use cumulus_client_consensus_aura::collators::basic::{
self as basic_aura, Params as BasicAuraParams,
};

// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
// when starting the network.

Expand All @@ -584,15 +562,11 @@ fn start_consensus(
client.clone(),
);

let params = AuraParams {
let params = BasicAuraParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
block_import,
para_client: client.clone(),
para_backend: backend.clone(),
para_client: client,
relay_client: relay_chain_interface,
code_hash_provider: move |block_hash| {
client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash())
},
sync_oracle,
keystore,
collator_key,
Expand All @@ -602,12 +576,12 @@ fn start_consensus(
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
};

let fut =
aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _, _, _>(
basic_aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _>(
params,
);
task_manager.spawn_essential_handle().spawn("aura", None, fut);
Expand Down
22 changes: 8 additions & 14 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight};
use frame_support::weights::IdentityFee;
use frame_system::limits;
pub use parachains_common::NORMAL_DISPATCH_RATIO;
pub use parachains_common::{MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
use sp_core::Hasher as HasherT;
use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, Verify};

/// We allow for 2 seconds of compute with a 6 second average block.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

/// Authority ID used in parachain.
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;

Expand Down Expand Up @@ -84,12 +78,12 @@ mod tests {
let weights = RuntimeBlockWeights::get();

assert_eq!(weights.base_block, Weight::from_parts(453383000, 0));
assert_eq!(weights.max_block, Weight::from_parts(2000000000000, 5242880));
assert_eq!(weights.max_block, Weight::from_parts(500000000000, 5242880));

let normal = weights.per_class.get(DispatchClass::Normal);
assert_eq!(normal.base_extrinsic, Weight::from_parts(107074000, 0));
assert_eq!(normal.max_extrinsic, Some(Weight::from_parts(1299892926000, 3407872)));
assert_eq!(normal.max_total, Some(Weight::from_parts(1500000000000, 3932160)));
assert_eq!(normal.max_extrinsic, Some(Weight::from_parts(324892926000, 3407872)));
assert_eq!(normal.max_total, Some(Weight::from_parts(375000000000, 3932160)));
assert_eq!(normal.reserved, Some(Weight::from_parts(0, 0)));

let mandatory = weights.per_class.get(DispatchClass::Mandatory);
Expand All @@ -100,8 +94,8 @@ mod tests {

let operational = weights.per_class.get(DispatchClass::Operational);
assert_eq!(operational.base_extrinsic, Weight::from_parts(107074000, 0));
assert_eq!(operational.max_extrinsic, Some(Weight::from_parts(1799892926000, 4718592)));
assert_eq!(operational.max_total, Some(Weight::from_parts(2000000000000, 5242880)));
assert_eq!(operational.reserved, Some(Weight::from_parts(500000000000, 1310720)));
assert_eq!(operational.max_extrinsic, Some(Weight::from_parts(449892926000, 4718592)));
assert_eq!(operational.max_total, Some(Weight::from_parts(500000000000, 5242880)));
assert_eq!(operational.reserved, Some(Weight::from_parts(125000000000, 1310720)));
}
}
2 changes: 0 additions & 2 deletions runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-timestamp = { workspace = true }
cumulus-primitives-utility = { workspace = true }
cumulus-primitives-aura = { workspace = true }
parachain-info = { workspace = true }
parachains-common = { workspace = true }

Expand Down Expand Up @@ -139,7 +138,6 @@ std = [
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"cumulus-primitives-aura/std",
"parachains-common/std",
"frame-executive/std",
"frame-support/std",
Expand Down
6 changes: 3 additions & 3 deletions runtime/laos/src/configs/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with LAOS. If not, see <http://www.gnu.org/licenses/>.

use crate::{AuraId, Runtime, SLOT_DURATION};
use crate::{AuraId, Runtime, MILLISECS_PER_BLOCK};
use frame_support::parameter_types;
use sp_core::ConstU64;

parameter_types! {
pub const MaxAuthorities : u32 = 100_000;
pub const AllowMultipleBlocksPerSlot: bool = true;
pub const AllowMultipleBlocksPerSlot: bool = false;
}

impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
type AllowMultipleBlocksPerSlot = AllowMultipleBlocksPerSlot;
type SlotDuration = ConstU64<SLOT_DURATION>;
type SlotDuration = ConstU64<MILLISECS_PER_BLOCK>;
}
15 changes: 7 additions & 8 deletions runtime/laos/src/configs/collective.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use crate::{
weights, AccountId, BlockNumber, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, DAYS,
MINUTES,
};
use crate::{weights, AccountId, BlockNumber, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
use frame_support::{pallet_prelude::Weight, parameter_types};
use frame_system::EnsureRoot;
use laos_primitives::RuntimeBlockWeights;
use parachains_common::{DAYS, MINUTES};
use polkadot_runtime_common::prod_or_fast;
use sp_runtime::Perbill;

parameter_types! {
pub const MotionDuration: BlockNumber = prod_or_fast!(7 * DAYS, 5 * MINUTES);
pub const MaxProposals: u32 = 7;
pub const MaxMembers: u32 = 20;
pub const MaxProposals: u32 = 20;
pub const MaxMembersCouncil: u32 = 7;
pub const MaxMembersTechnicalCommittee: u32 = 5;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}

Expand All @@ -31,7 +30,7 @@ pub type AllOfTechnicalCommittee =
pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime {
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type MaxMembers = MaxMembers;
type MaxMembers = MaxMembersCouncil;
type MaxProposalWeight = MaxProposalWeight;
type MaxProposals = MaxProposals;
type MotionDuration = MotionDuration;
Expand All @@ -45,7 +44,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
pub type TechnicalCommittee = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCommittee> for Runtime {
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type MaxMembers = MaxMembers;
type MaxMembers = MaxMembersTechnicalCommittee;
type MaxProposalWeight = MaxProposalWeight;
type MaxProposals = MaxProposals;
type MotionDuration = MotionDuration;
Expand Down
7 changes: 3 additions & 4 deletions runtime/laos/src/configs/cumulus_parachain_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedDmpWeight = ReservedDmpWeight;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
type ConsensusHook = ConsensusHook;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
Expand All @@ -52,9 +51,9 @@ const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// number of blocks authored per slot.
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;

pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
Expand Down
Loading

0 comments on commit ca7fd7b

Please sign in to comment.