Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ pub fn run() -> Result<()> {
collator_options,
id,
rpc_config,
false,
true,
cli.run.block_authoring_duration,
hwbench,
)
Expand Down
7 changes: 6 additions & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ impl-trait-for-tuples = "0.2.1"
log = "0.4"

# Moonbeam
moonbeam-core-primitives = { workspace = true }
moonbeam-xcm-benchmarks = { workspace = true }
pallet-asset-manager = { workspace = true }
pallet-author-mapping = { workspace = true }
Expand All @@ -29,6 +30,7 @@ precompile-utils = { workspace = true }
xcm-primitives = { workspace = true }

# Substrate
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
frame-benchmarking = { workspace = true }
frame-support = { workspace = true }
Expand Down Expand Up @@ -82,9 +84,11 @@ account = { workspace = true }

[features]
std = [
"cumulus-pallet-parachain-system/std",
"fp-ethereum/std",
"fp-evm/std",
"frame-support/std",
"moonbeam-core-primitives/std",
"pallet-asset-manager/std",
"pallet-async-backing/std",
"pallet-author-inherent/std",
Expand All @@ -111,6 +115,7 @@ std = [
"account/std",
]
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
Expand Down Expand Up @@ -143,4 +148,4 @@ runtime-benchmarks = [
"pallet-moonbeam-lazy-migrations/runtime-benchmarks",
"moonbeam-xcm-benchmarks/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime", "pallet-migrations/try-runtime"]
try-runtime = ["cumulus-pallet-parachain-system/try-runtime", "frame-support/try-runtime", "pallet-migrations/try-runtime"]
1 change: 1 addition & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod impl_on_charge_evm_transaction;
mod impl_self_contained_call;
mod impl_xcm_evm_runner;
pub mod migrations;
pub mod timestamp;
pub mod weights;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

//! A way to get a relyable timestamp

use crate::Runtime;
use cumulus_pallet_parachain_system::{
consensus_hook::UnincludedSegmentCapacity,
relay_state_snapshot::{self, ReadEntryErr},
Expand All @@ -39,9 +38,15 @@ impl Time for RelayTimestamp {
}
}

/// A wrapper around the consensus hook to get the relay timlestmap from the relay storage proof
pub struct ConsensusHookWrapperForRelayTimestamp<Inner>(core::marker::PhantomData<Inner>);
impl<Inner: ConsensusHook> ConsensusHook for ConsensusHookWrapperForRelayTimestamp<Inner> {
/// A wrapper around the consensus hook to get the relay timestamp from the relay storage proof
pub struct ConsensusHookWrapperForRelayTimestamp<Runtime, Inner>(
core::marker::PhantomData<(Runtime, Inner)>,
);
impl<Runtime, Inner> ConsensusHook for ConsensusHookWrapperForRelayTimestamp<Runtime, Inner>
where
Runtime: frame_system::Config,
Inner: ConsensusHook,
{
fn on_state_proof(state_proof: &RelayChainStateProof) -> (Weight, UnincludedSegmentCapacity) {
let relay_timestamp: u64 =
match state_proof.read_entry(well_known_relay_keys::TIMESTAMP_NOW, None) {
Expand Down
10 changes: 6 additions & 4 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod asset_config;
pub mod governance;
pub mod timestamp;
pub mod xcm_config;

mod migrations;
Expand Down Expand Up @@ -79,7 +78,10 @@ use frame_support::{
use frame_system::{EnsureRoot, EnsureSigned};
use governance::councils::*;
use moonbeam_rpc_primitives_txpool::TxPoolResponse;
use moonbeam_runtime_common::weights as moonbeam_weights;
use moonbeam_runtime_common::{
timestamp::{ConsensusHookWrapperForRelayTimestamp, RelayTimestamp},
weights as moonbeam_weights,
};
use nimbus_primitives::CanAuthor;
use pallet_ethereum::Call::transact;
use pallet_ethereum::{PostLogContent, Transaction as EthereumTransaction};
Expand Down Expand Up @@ -520,7 +522,7 @@ impl pallet_evm::Config for Runtime {
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type SuicideQuickClearLimit = ConstU32<0>;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = crate::timestamp::RelayTimestamp;
type Timestamp = RelayTimestamp;
type WeightInfo = moonbeam_weights::pallet_evm::WeightInfo<Runtime>;
}

Expand Down Expand Up @@ -739,7 +741,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type XcmpMessageHandler = EmergencyParaXcm;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = EmergencyParaXcm;
type ConsensusHook = crate::timestamp::ConsensusHookWrapperForRelayTimestamp<ConsensusHook>;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp<Runtime, ConsensusHook>;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight<Runtime>;
}
Expand Down
1 change: 1 addition & 0 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ sha3 = { workspace = true, features = ["std"] }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true }

sp-timestamp = { workspace = true }
polkadot-runtime-parachains = { workspace = true }
xcm-simulator = { workspace = true }

Expand Down
12 changes: 8 additions & 4 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ pub use moonbeam_core_primitives::{
Index, Signature,
};
use moonbeam_rpc_primitives_txpool::TxPoolResponse;
use moonbeam_runtime_common::weights as moonbeam_weights;
use moonbeam_runtime_common::{
timestamp::{ConsensusHookWrapperForRelayTimestamp, RelayTimestamp},
weights as moonbeam_weights,
};
use pallet_ethereum::Call::transact;
use pallet_ethereum::{PostLogContent, Transaction as EthereumTransaction};
use pallet_evm::{
Expand Down Expand Up @@ -507,7 +510,7 @@ impl pallet_evm::Config for Runtime {
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
type SuicideQuickClearLimit = ConstU32<0>;
type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio;
type Timestamp = Timestamp;
type Timestamp = RelayTimestamp;
type WeightInfo = moonbeam_weights::pallet_evm::WeightInfo<Runtime>;
}

Expand Down Expand Up @@ -724,8 +727,9 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
type ConsensusHook = cumulus_pallet_parachain_system::ExpectParentIncluded;
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHookWrapperForRelayTimestamp<Runtime, ConsensusHook>;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type WeightInfo = cumulus_pallet_parachain_system::weights::SubstrateWeight<Runtime>;
}
Expand Down
19 changes: 17 additions & 2 deletions runtime/moonriver/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub use moonriver_runtime::{
UncheckedExtrinsic, HOURS, WEEKS,
};
use nimbus_primitives::{NimbusId, NIMBUS_ENGINE_ID};
use polkadot_parachain::primitives::HeadData;
use sp_consensus_slots::Slot;
use sp_core::{Encode, H160};
use sp_runtime::{traits::Dispatchable, BuildStorage, Digest, DigestItem, Perbill, Percent};
Expand Down Expand Up @@ -85,6 +86,8 @@ pub fn run_to_block(n: u32, author: Option<NimbusId>) {
}
}

increase_last_relay_slot_number(1);

// Initialize the new block
AuthorInherent::on_initialize(System::block_number());
ParachainStaking::on_initialize(System::block_number());
Expand Down Expand Up @@ -347,8 +350,20 @@ pub fn root_origin() -> <Runtime as frame_system::Config>::RuntimeOrigin {
pub fn set_parachain_inherent_data() {
use cumulus_primitives_core::PersistedValidationData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
let (relay_parent_storage_root, relay_chain_state) =
RelayStateSproofBuilder::default().into_state_root_and_proof();

let mut relay_sproof = RelayStateSproofBuilder::default();
relay_sproof.para_id = 100u32.into();
relay_sproof.included_para_head = Some(HeadData(vec![1, 2, 3]));

let additional_key_values = vec![(
moonbeam_core_primitives::well_known_relay_keys::TIMESTAMP_NOW.to_vec(),
sp_timestamp::Timestamp::default().encode(),
)];

relay_sproof.additional_key_values = additional_key_values;

let (relay_parent_storage_root, relay_chain_state) = relay_sproof.into_state_root_and_proof();

let vfp = PersistedValidationData {
relay_parent_number: 1u32,
relay_parent_storage_root,
Expand Down
12 changes: 6 additions & 6 deletions runtime/moonriver/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,11 @@ fn reward_block_authors() {
// rewards minted and distributed
assert_eq!(
Balances::usable_balance(AccountId::from(ALICE)),
10101206388888506666666,
11547666666208000000000,
);
assert_eq!(
Balances::usable_balance(AccountId::from(BOB)),
9500047777777156666667,
9557333332588000000000,
);
});
}
Expand Down Expand Up @@ -683,7 +683,7 @@ fn reward_block_authors_with_parachain_bond_reserved() {
// 30% reserved for parachain bond
assert_eq!(
Balances::usable_balance(AccountId::from(CHARLIE)),
1376262500000000000,
452515000000000000000,
);

// Go to round 3
Expand All @@ -692,16 +692,16 @@ fn reward_block_authors_with_parachain_bond_reserved() {
// rewards minted and distributed
assert_eq!(
Balances::usable_balance(AccountId::from(ALICE)),
10100848083729919833333,
11117700475903800000000,
);
assert_eq!(
Balances::usable_balance(AccountId::from(BOB)),
9500029862102786395833,
9535834523343675000000,
);
// 30% reserved for parachain bond again
assert_eq!(
Balances::usable_balance(AccountId::from(CHARLIE)),
1376262500000000000,
910802725000000000000,
);
});
}
Expand Down