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

Enable Relay Data Verifier Precompile in Moonriver and Moonbeam #2729

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ std = [
"pallet-evm-precompile-randomness/std",
"pallet-evm-precompile-referenda/std",
"pallet-evm-precompile-registry/std",
"pallet-evm-precompile-relay-verifier/std",
"pallet-evm-precompile-xcm-transactor/std",
"pallet-evm-precompile-xcm-utils/std",
"pallet-evm-precompile-xtokens/std",
Expand Down
6 changes: 1 addition & 5 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,12 +1334,8 @@ impl pallet_multisig::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_multisig::WeightInfo<Runtime>;
}

parameter_types! {
pub const MaxStorageRoots: u32 = 10;
}

impl pallet_relay_storage_roots::Config for Runtime {
type MaxStorageRoots = MaxStorageRoots;
type MaxStorageRoots = ConstU32<30>;
type RelaychainStateProvider = cumulus_pallet_parachain_system::RelaychainDataProvider<Self>;
type WeightInfo = moonbeam_weights::pallet_relay_storage_roots::WeightInfo<Runtime>;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/moonbase/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn verify_pallet_prefixes() {
storage_name: b"RelayStorageRootKeys".to_vec(),
prefix: prefix(b"RelayStorageRoots", b"RelayStorageRootKeys"),
max_values: Some(1),
max_size: Some(41),
max_size: Some(121),
},
]
);
Expand Down
10 changes: 10 additions & 0 deletions runtime/moonbeam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pallet-migrations = { workspace = true }
pallet-moonbeam-lazy-migrations = { workspace = true }
pallet-moonbeam-orbiters = { workspace = true }
pallet-parachain-staking = { workspace = true }
pallet-precompile-benchmarks = { workspace = true }
pallet-proxy-genesis-companion = { workspace = true }
pallet-randomness = { workspace = true }
pallet-xcm-transactor = { workspace = true }
Expand All @@ -62,6 +63,7 @@ pallet-evm-precompile-randomness = { workspace = true }
pallet-evm-precompile-referenda = { workspace = true }
pallet-evm-precompile-registry = { workspace = true }
pallet-evm-precompile-relay-encoder = { workspace = true }
pallet-evm-precompile-relay-verifier = { workspace = true }
pallet-evm-precompile-xcm-transactor = { workspace = true }
pallet-evm-precompile-xcm-utils = { workspace = true }
pallet-evm-precompile-xtokens = { workspace = true }
Expand Down Expand Up @@ -161,6 +163,7 @@ moonkit-xcm-primitives = { workspace = true }
nimbus-primitives = { workspace = true }
pallet-author-inherent = { workspace = true }
pallet-author-slot-filter = { workspace = true }
pallet-relay-storage-roots = { workspace = true }

# Benchmarking
frame-benchmarking = { workspace = true, optional = true }
Expand Down Expand Up @@ -239,6 +242,7 @@ std = [
"pallet-evm-precompile-randomness/std",
"pallet-evm-precompile-referenda/std",
"pallet-evm-precompile-relay-encoder/std",
"pallet-evm-precompile-relay-verifier/std",
"pallet-evm-precompile-xcm-transactor/std",
"pallet-evm-precompile-xcm-utils/std",
"pallet-evm-precompile-xtokens/std",
Expand All @@ -251,11 +255,13 @@ std = [
"pallet-moonbeam-orbiters/std",
"pallet-multisig/std",
"pallet-parachain-staking/std",
"pallet-precompile-benchmarks/std",
"pallet-preimage/std",
"pallet-proxy-genesis-companion/std",
"pallet-proxy/std",
"pallet-randomness/std",
"pallet-referenda/std",
"pallet-relay-storage-roots/std",
"pallet-root-testing/std",
"pallet-scheduler/std",
"pallet-society/std",
Expand Down Expand Up @@ -333,10 +339,12 @@ runtime-benchmarks = [
"pallet-moonbeam-orbiters/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-precompile-benchmarks/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-randomness/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-relay-storage-roots/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
Expand Down Expand Up @@ -371,8 +379,10 @@ try-runtime = [
"pallet-migrations/try-runtime",
"pallet-moonbeam-lazy-migrations/try-runtime",
"pallet-parachain-staking/try-runtime",
"pallet-precompile-benchmarks/try-runtime",
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-relay-storage-roots/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-society/try-runtime",
Expand Down
13 changes: 13 additions & 0 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,16 @@ impl pallet_multisig::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_multisig::WeightInfo<Runtime>;
}

impl pallet_relay_storage_roots::Config for Runtime {
type MaxStorageRoots = ConstU32<30>;
type RelaychainStateProvider = cumulus_pallet_parachain_system::RelaychainDataProvider<Self>;
type WeightInfo = moonbeam_weights::pallet_relay_storage_roots::WeightInfo<Runtime>;
}

impl pallet_precompile_benchmarks::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_precompile_benchmarks::WeightInfo<Runtime>;
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1387,6 +1397,8 @@ construct_runtime! {
EthereumXcm: pallet_ethereum_xcm::{Pallet, Call, Storage, Origin} = 109,
Erc20XcmBridge: pallet_erc20_xcm_bridge::{Pallet} = 110,
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 111,
RelayStorageRoots: pallet_relay_storage_roots::{Pallet, Storage} = 112,
PrecompileBenchmarks: pallet_precompile_benchmarks::{Pallet} = 113,

// Randomness
Randomness: pallet_randomness::{Pallet, Call, Storage, Event<T>, Inherent} = 120,
Expand Down Expand Up @@ -1429,6 +1441,7 @@ mod benches {
[pallet_multisig, Multisig]
[moonbeam_xcm_benchmarks::weights::generic, MoonbeamXcmGenericBench::<Runtime>]
[pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations]
[pallet_relay_storage_roots, RelayStorageRoots]
);
}

Expand Down
6 changes: 6 additions & 0 deletions runtime/moonbeam/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use pallet_evm_precompile_randomness::RandomnessPrecompile;
use pallet_evm_precompile_referenda::ReferendaPrecompile;
use pallet_evm_precompile_registry::PrecompileRegistry;
use pallet_evm_precompile_relay_encoder::RelayEncoderPrecompile;
use pallet_evm_precompile_relay_verifier::RelayDataVerifierPrecompile;
use pallet_evm_precompile_sha3fips::Sha3FIPS256;
use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256};
use pallet_evm_precompile_xcm_transactor::{
Expand Down Expand Up @@ -232,6 +233,11 @@ type MoonbeamPrecompilesAt<R> = (
IdentityPrecompile<R, crate::MaxAdditionalFields>,
(CallableByContract, CallableByPrecompile),
>,
PrecompileAt<
AddressU64<2073>,
RelayDataVerifierPrecompile<R>,
(CallableByContract, CallableByPrecompile),
>,
);

pub struct DisabledLocalAssets<Runtime>(sp_std::marker::PhantomData<Runtime>);
Expand Down
23 changes: 22 additions & 1 deletion runtime/moonbeam/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ fn verify_pallet_prefixes() {
is_pallet_prefix::<moonbeam_runtime::MoonbeamOrbiters>("MoonbeamOrbiters");
is_pallet_prefix::<moonbeam_runtime::TreasuryCouncilCollective>("TreasuryCouncilCollective");
is_pallet_prefix::<moonbeam_runtime::MoonbeamLazyMigrations>("MoonbeamLazyMigrations");
is_pallet_prefix::<moonbeam_runtime::RelayStorageRoots>("RelayStorageRoots");

let prefix = |pallet_name, storage_name| {
let mut res = [0u8; 32];
res[0..16].copy_from_slice(&Twox128::hash(pallet_name));
Expand Down Expand Up @@ -251,6 +253,25 @@ fn verify_pallet_prefixes() {
max_size: None,
},]
);
assert_eq!(
<moonbeam_runtime::RelayStorageRoots as StorageInfoTrait>::storage_info(),
vec![
StorageInfo {
pallet_name: b"RelayStorageRoots".to_vec(),
storage_name: b"RelayStorageRoot".to_vec(),
prefix: prefix(b"RelayStorageRoots", b"RelayStorageRoot"),
max_values: None,
max_size: Some(44),
},
StorageInfo {
pallet_name: b"RelayStorageRoots".to_vec(),
storage_name: b"RelayStorageRootKeys".to_vec(),
prefix: prefix(b"RelayStorageRoots", b"RelayStorageRootKeys"),
max_values: Some(1),
max_size: Some(121),
},
]
);
}

#[test]
Expand Down Expand Up @@ -2429,7 +2450,7 @@ fn precompile_existence() {
let precompile_addresses: std::collections::BTreeSet<_> = vec![
1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 2048, 2049, 2050, 2051, 2052, 2053, 2054,
2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068,
2069, 2070, 2071, 2072,
2069, 2070, 2071, 2072, 2073,
]
.into_iter()
.map(H160::from_low_u64_be)
Expand Down
11 changes: 11 additions & 0 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pallet-migrations = { workspace = true }
pallet-moonbeam-lazy-migrations = { workspace = true }
pallet-moonbeam-orbiters = { workspace = true }
pallet-parachain-staking = { workspace = true }
pallet-precompile-benchmarks = { workspace = true }
pallet-proxy-genesis-companion = { workspace = true }
pallet-randomness = { workspace = true }
pallet-xcm-transactor = { workspace = true }
Expand All @@ -62,6 +63,7 @@ pallet-evm-precompile-randomness = { workspace = true }
pallet-evm-precompile-referenda = { workspace = true }
pallet-evm-precompile-registry = { workspace = true }
pallet-evm-precompile-relay-encoder = { workspace = true }
pallet-evm-precompile-relay-verifier = { workspace = true }
pallet-evm-precompile-xcm-transactor = { workspace = true }
pallet-evm-precompile-xcm-utils = { workspace = true }
pallet-evm-precompile-xtokens = { workspace = true }
Expand Down Expand Up @@ -162,6 +164,7 @@ moonkit-xcm-primitives = { workspace = true }
nimbus-primitives = { workspace = true }
pallet-author-inherent = { workspace = true }
pallet-author-slot-filter = { workspace = true }
pallet-relay-storage-roots = { workspace = true }

# Benchmarking
frame-benchmarking = { workspace = true, optional = true }
Expand Down Expand Up @@ -239,6 +242,8 @@ std = [
"pallet-evm-precompile-preimage/std",
"pallet-evm-precompile-randomness/std",
"pallet-evm-precompile-referenda/std",
"pallet-evm-precompile-relay-encoder/std",
"pallet-evm-precompile-relay-verifier/std",
"pallet-evm-precompile-xcm-transactor/std",
"pallet-evm-precompile-xcm-utils/std",
"pallet-evm-precompile-xtokens/std",
Expand All @@ -250,11 +255,13 @@ std = [
"pallet-moonbeam-orbiters/std",
"pallet-multisig/std",
"pallet-parachain-staking/std",
"pallet-precompile-benchmarks/std",
"pallet-preimage/std",
"pallet-proxy-genesis-companion/std",
"pallet-proxy/std",
"pallet-randomness/std",
"pallet-referenda/std",
"pallet-relay-storage-roots/std",
"pallet-root-testing/std",
"pallet-scheduler/std",
"pallet-society/std",
Expand Down Expand Up @@ -337,10 +344,12 @@ runtime-benchmarks = [
"pallet-moonbeam-orbiters/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-precompile-benchmarks/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-randomness/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-relay-storage-roots/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
Expand Down Expand Up @@ -374,8 +383,10 @@ try-runtime = [
"pallet-migrations/try-runtime",
"pallet-moonbeam-lazy-migrations/try-runtime",
"pallet-parachain-staking/try-runtime",
"pallet-precompile-benchmarks/try-runtime",
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-relay-storage-roots/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-society/try-runtime",
Expand Down
13 changes: 13 additions & 0 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,16 @@ impl pallet_multisig::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_multisig::WeightInfo<Runtime>;
}

impl pallet_relay_storage_roots::Config for Runtime {
type MaxStorageRoots = ConstU32<30>;
type RelaychainStateProvider = cumulus_pallet_parachain_system::RelaychainDataProvider<Self>;
type WeightInfo = moonbeam_weights::pallet_relay_storage_roots::WeightInfo<Runtime>;
}

impl pallet_precompile_benchmarks::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_precompile_benchmarks::WeightInfo<Runtime>;
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1389,6 +1399,8 @@ construct_runtime! {
EthereumXcm: pallet_ethereum_xcm::{Pallet, Call, Storage, Origin} = 109,
Erc20XcmBridge: pallet_erc20_xcm_bridge::{Pallet} = 110,
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 111,
RelayStorageRoots: pallet_relay_storage_roots::{Pallet, Storage} = 112,
PrecompileBenchmarks: pallet_precompile_benchmarks::{Pallet} = 113,

// Randomness
Randomness: pallet_randomness::{Pallet, Call, Storage, Event<T>, Inherent} = 120,
Expand Down Expand Up @@ -1431,6 +1443,7 @@ mod benches {
[pallet_multisig, Multisig]
[moonbeam_xcm_benchmarks::weights::generic, MoonbeamXcmGenericBench::<Runtime>]
[pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations]
[pallet_relay_storage_roots, RelayStorageRoots]
);
}

Expand Down
6 changes: 6 additions & 0 deletions runtime/moonriver/src/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use pallet_evm_precompile_randomness::RandomnessPrecompile;
use pallet_evm_precompile_referenda::ReferendaPrecompile;
use pallet_evm_precompile_registry::PrecompileRegistry;
use pallet_evm_precompile_relay_encoder::RelayEncoderPrecompile;
use pallet_evm_precompile_relay_verifier::RelayDataVerifierPrecompile;
use pallet_evm_precompile_sha3fips::Sha3FIPS256;
use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256};
use pallet_evm_precompile_xcm_transactor::{
Expand Down Expand Up @@ -226,6 +227,11 @@ type MoonriverPrecompilesAt<R> = (
IdentityPrecompile<R, crate::MaxAdditionalFields>,
(CallableByContract, CallableByPrecompile),
>,
PrecompileAt<
AddressU64<2073>,
RelayDataVerifierPrecompile<R>,
(CallableByContract, CallableByPrecompile),
>,
);

/// The PrecompileSet installed in the Moonriver runtime.
Expand Down
Loading
Loading