Skip to content
Draft
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
18 changes: 0 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ pallet-evm-precompile-blake2 = {git = "https://github.com/moonbeam-foundation/fr
pallet-evm-precompile-batch = {git = "https://github.com/moonbeam-foundation/moonbeam", tag = "runtime-3701", default-features = false}
pallet-evm-precompile-balances-erc20 = {git = "https://github.com/moonbeam-foundation/moonbeam", tag = "runtime-3701", default-features = false}

#ethereum = {version = "0.15.0", default-features = false, features = ["with-codec"]}
ethereum = {git = "https://github.com/rust-ethereum/ethereum", rev = "3be0d8fd4c2ad1ba216b69ef65b9382612efc8ba"}

# Moonbeam
Expand Down Expand Up @@ -255,29 +254,15 @@ substrate-wasm-builder = { version = "25.0.1" }
cumulus-primitives-storage-weight-reclaim = { version = "9.1.0" }
substrate-prometheus-endpoint = { version = "0.17.2" }

#[patch."https://github.com/rust-ethereum/ethereum"]
#ethereum = {version = "0.15.0"}

# XCM
xcm = { version = "15.1.0", package = "staging-xcm" }

#[patch."https://github.com/rust-ethereum/ethereum"]
#ethereum = { git = "https://github.com/rust-ethereum/ethereum", rev = "3be0d8f" }

#[patch."https://github.com/moonbeam-foundation/frontier"]
#fp-ethereum = {git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-stable2412"}
#fp-evm = {git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-stable2412"}
#fp-rpc = {git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-stable2412"}
#fp-self-contained = {git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-stable2412"}
#pallet-evm = {git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-stable2412"}

[patch."https://github.com/moonbeam-foundation/polkadot-sdk"]
staging-xcm-builder = { version = "18.2.1" }
xcm-executor = { version = "18.0.3", package = "staging-xcm-executor" }
pallet-staking = { version = "39.1.0" }
cumulus-primitives-core = { version = "0.17.0" }
polkadot-runtime-common = { version = "18.1.0" }
#pallet-election-provider-multi-phase = { version = "38.2.0" }
sc-block-builder = { version = "0.43.0" }
sc-chain-spec = { version = "41.0.0" }
sc-cli = { version = "0.50.2" }
Expand Down Expand Up @@ -351,9 +336,6 @@ substrate-wasm-builder = { version = "25.0.1" }
cumulus-primitives-storage-weight-reclaim = { version = "9.1.0" }
substrate-prometheus-endpoint = { version = "0.17.2" }

#[patch."https://github.com/rust-ethereum/ethereum"]
#ethereum = {version = "0.15.0"}

# XCM
xcm = { version = "15.1.0", package = "staging-xcm" }

Expand Down
41 changes: 36 additions & 5 deletions runtime/src/configs/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ use sp_runtime::{
};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountKey20Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry,
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
AccountKey20Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
FungibleAdapter, HashedDescription, IsConcrete, NativeAsset, ParentIsPreset,
RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SignedAccountKey20AsNative,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
Expand Down Expand Up @@ -159,14 +159,25 @@ impl Contains<Location> for ParentRelayChain {
}
}

pub struct ParentsTreasury;
impl Contains<Location> for ParentsTreasury {
fn contains(location: &Location) -> bool {
// match the relay chain and any account on it
matches!(location.unpack(), (1, [PalletInstance(14)]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should make this more robust at a certain point, maybe with a separate repo and crate like polkadot_runtime_commons and polkadot_parachains_commons

}
}

pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain,
(
TakeWeightCredit,
AllowKnownQueryResponses<ZKVXcm>,
WithComputedOrigin<
(AllowTopLevelPaidExecutionFrom<ParentRelayChain>,),
(
AllowTopLevelPaidExecutionFrom<ParentRelayChain>,
AllowExplicitUnpaidExecutionFrom<ParentsTreasury>,
),
UniversalLocation,
ConstU32<8>,
>,
Expand All @@ -177,7 +188,7 @@ pub type Barrier = TrailingSetTopicAsId<

pub type TrustedTeleporters = ConcreteAssetFromSystem<RelayLocation>;

pub type WaivedLocations = (Equals<RelayLocation>, Equals<RootLocation>);
pub type WaivedLocations = (Equals<RelayLocation>, Equals<RootLocation>, ParentsTreasury);

pub struct RemoteEVMCall;
impl CallDispatcher<RuntimeCall> for RemoteEVMCall {
Expand Down Expand Up @@ -402,3 +413,23 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type PriceForSiblingDelivery = PriceForSiblingParachainDelivery;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::ZKVEvmWeight<Runtime>;
}

#[test]
fn alice_pubkey_conversion() {
use hex_literal::hex;
use xcm::latest::Junctions::X1;

let loc = Location {
parents: 0,
interior: X1([AccountId32 {
network: None,
id: hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").into(),
}]
.into()),
};
assert_eq!(
LocationAccountId32ToAccountId::convert_location(&loc)
.expect("Cannot convert accountid32; qed"),
hex!("04a99fd6822c8558854ccde39a5684e7a56da27d").into()
);
}
18 changes: 18 additions & 0 deletions runtime/src/tests/constants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ mod runtime_tests {
mod xcm_tests {
use super::*;
use configs::xcm::*;
use hex_literal::hex;
use xcm::latest::prelude::*;
use xcm::opaque::latest::Junctions::X1;
use xcm_executor::traits::ConvertLocation;

#[test]
fn xcm_executor_constants() {
Expand All @@ -225,4 +229,18 @@ mod xcm_tests {
100
);
}

#[test]
fn relay_treasury_account() {
// TODO: replace with zkv_runtime::TreasuryPalletIdx::get() on next zkVerify tag?
let loc = Location {
parents: 1,
interior: X1([PalletInstance(14)].into()), // 14 is the index of the treasury pallet in zkv-runtime
};
assert_eq!(
LocationAccountId32ToAccountId::convert_location(&loc)
.expect("Location is not convertible; qed"),
hex!("f260e064445be1b5e12e5cef1e1c11fc4c4b4963").into(),
);
}
}
1 change: 0 additions & 1 deletion zombienet-config/devnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ name = "zkv-para-evm-parachain-collator01"
command = "./target/release/zkv-para-evm-node"
ws_port = 9933
rpc_port = 8833
#args = ["--rpc-max-connections 10000 -ltrace"]
args = ["-lxcm=trace", "--rpc-max-connections 10000"]

[[parachains.collators]]
Expand Down
Loading