Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
22c6da0
wip
ozgunozerk Oct 7, 2024
68f423e
wip
ozgunozerk Oct 8, 2024
d24c968
added trader
ozgunozerk Oct 9, 2024
9e6f81c
some more fixes
ozgunozerk Oct 9, 2024
99dbe4d
added pallets to runtime
ozgunozerk Oct 9, 2024
84f7429
compiles now
ozgunozerk Oct 9, 2024
e6399fd
toml sort
ozgunozerk Oct 14, 2024
0fcaa54
typo and format
ozgunozerk Oct 14, 2024
4a96196
clippy fix
ozgunozerk Oct 21, 2024
cfbc952
typo
ozgunozerk Oct 21, 2024
67c53cd
suggestions
ozgunozerk Oct 21, 2024
56e75a5
logic fix
ozgunozerk Oct 21, 2024
e254dee
Update evm-template/runtime/src/configs/xcm_config.rs
ozgunozerk Oct 22, 2024
88fc959
loosing the logic for bridged assets
ozgunozerk Oct 22, 2024
d86b7a8
note added
ozgunozerk Oct 22, 2024
6b7e3dc
typo
ozgunozerk Oct 23, 2024
3408f97
simplify logic
ozgunozerk Oct 23, 2024
2da2b8b
better inline docs
ozgunozerk Oct 24, 2024
aa60492
match against all X1, X2, etc. variants
ozgunozerk Oct 24, 2024
4b9756a
simplify the xcm config
ozgunozerk Oct 24, 2024
f431486
fmt
ozgunozerk Oct 24, 2024
81bf686
clippy fix
ozgunozerk Oct 24, 2024
da38313
configured xcm transactor using xtoken types on evm
peektism Oct 24, 2024
23625ae
fix
peektism Oct 24, 2024
397f74a
comments fixed
ozgunozerk Oct 25, 2024
63e4e84
enable try runtime for xcm transactor
peektism Oct 26, 2024
e58539e
fix genesis config for template fuzzer
peektism Oct 26, 2024
a4b9f6e
Merge branch 'ozgun-xtokens-config' into amar-xcm-transactor-evm
peektism Oct 26, 2024
33918e8
todos
peektism Oct 26, 2024
97be685
impl from Location for CurrencyId under benchmarking compilation flag
peektism Oct 26, 2024
361370b
replace with latest version converter
peektism Oct 26, 2024
b539b6d
MaybeEquivalence trait into scope
peektism Oct 26, 2024
c7d9d79
init empty
peektism Oct 28, 2024
c046c6f
fix std leak
peektism Oct 28, 2024
fd11b53
save fixes wip
peektism Oct 30, 2024
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
125 changes: 122 additions & 3 deletions evm-template/Cargo.lock

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

8 changes: 8 additions & 0 deletions evm-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", features =
], tag = "polkadot-stable2407-1" }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-1" }

# Cumulus
assets-common = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
Expand Down Expand Up @@ -160,10 +163,15 @@ pallet-evm-precompile-sha3fips = { git = "https://github.com/OpenZeppelin/fronti
pallet-evm-precompile-simple = { git = "https://github.com/OpenZeppelin/frontier", branch = "polkadot-stable2407-1", default-features = false }

# ORML
orml-traits = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-xcm-support = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-xtokens = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }

# Moonbeam
pallet-asset-manager = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
pallet-erc20-xcm-bridge = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
pallet-xcm-transactor = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
pallet-xcm-weight-trader = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }

# Fuzzer
Expand Down
19 changes: 18 additions & 1 deletion evm-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,22 @@ pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }

# ORML
orml-traits = { workspace = true }
orml-xcm-support = { workspace = true }

orml-xtokens = { workspace = true }

# Moonbeam
pallet-asset-manager = { workspace = true }
pallet-erc20-xcm-bridge = { workspace = true }
pallet-xcm-transactor = { workspace = true }
pallet-xcm-weight-trader = { workspace = true }
xcm-primitives = { workspace = true }

[dev-dependencies]
polkadot-runtime-parachains = { workspace = true }
polkadot-core-primitives = { workspace = true }
sp-io = { workspace = true }
xcm-simulator = { workspace = true }

[build-dependencies]
substrate-wasm-builder = { workspace = true }
Expand Down Expand Up @@ -134,6 +141,7 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"orml-xtokens/std",
"pallet-asset-manager/std",
"pallet-assets/std",
"pallet-aura/std",
Expand All @@ -142,6 +150,7 @@ std = [
"pallet-base-fee/std",
"pallet-collator-selection/std",
"pallet-conviction-voting/std",
"pallet-erc20-xcm-bridge/std",
"pallet-ethereum/std",
"pallet-evm-chain-id/std",
"pallet-evm/std",
Expand All @@ -159,6 +168,8 @@ std = [
"pallet-treasury/std",
"pallet-utility/std",
"pallet-whitelist/std",
"pallet-xcm-transactor/std",
"pallet-xcm-weight-trader/std",
"pallet-xcm/std",
"parachain-info/std",
"parachains-common/std",
Expand Down Expand Up @@ -215,6 +226,8 @@ runtime-benchmarks = [
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-whitelist/runtime-benchmarks",
"pallet-xcm-transactor/runtime-benchmarks",
"pallet-xcm-weight-trader/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
Expand All @@ -234,6 +247,7 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"orml-xtokens/try-runtime",
"pallet-asset-manager/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
Expand All @@ -242,6 +256,7 @@ try-runtime = [
"pallet-base-fee/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-erc20-xcm-bridge/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm-chain-id/try-runtime",
"pallet-message-queue/try-runtime",
Expand All @@ -258,6 +273,8 @@ try-runtime = [
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-whitelist/try-runtime",
"pallet-xcm-transactor/try-runtime",
"pallet-xcm-weight-trader/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
"polkadot-runtime-common/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions evm-template/runtime/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ frame_benchmarking::define_benchmarks!(
[pallet_conviction_voting, ConvictionVoting]
[pallet_whitelist, Whitelist]
[pallet_referenda, Referenda]
[pallet_xcm_transactor, XcmTransactor]
);

use cumulus_primitives_core::{ChannelStatus, GetChannelInfo};
Expand Down
40 changes: 39 additions & 1 deletion evm-template/runtime/src/configs/asset_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use frame_support::{
use frame_system::{EnsureRoot, EnsureSigned};
use parity_scale_codec::{Compact, Decode, Encode};
use scale_info::TypeInfo;
use sp_core::H256;
use sp_core::{H160, H256};
use sp_runtime::traits::Hash as THash;
use sp_std::{
convert::{From, Into},
Expand Down Expand Up @@ -184,3 +184,41 @@ impl pallet_asset_manager::Config for Runtime {
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_asset_manager::WeightInfo<Runtime>;
}

/// This trait ensure we can convert AccountIds to AssetIds.
pub trait AccountIdAssetIdConversion<Account, AssetId> {
// Get assetId and prefix from account
fn account_to_asset_id(account: Account) -> Option<(Vec<u8>, AssetId)>;

// Get AccountId from AssetId and prefix
fn asset_id_to_account(prefix: &[u8], asset_id: AssetId) -> Account;
}

const FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX: &[u8] = &[255u8; 4];

// Instruct how to go from an H160 to an AssetID
// We just take the lowest 128 bits
impl AccountIdAssetIdConversion<AccountId, AssetId> for Runtime {
/// The way to convert an account to assetId is by ensuring that the prefix is 0XFFFFFFFF
/// and by taking the lowest 128 bits as the assetId
fn account_to_asset_id(account: AccountId) -> Option<(Vec<u8>, AssetId)> {
let h160_account: H160 = account.into();
let mut data = [0u8; 16];
let (prefix_part, id_part) = h160_account.as_fixed_bytes().split_at(4);
if prefix_part == FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX {
data.copy_from_slice(id_part);
let asset_id: AssetId = u128::from_be_bytes(data);
Some((prefix_part.to_vec(), asset_id))
} else {
None
}
}

// The opposite conversion
fn asset_id_to_account(prefix: &[u8], asset_id: AssetId) -> AccountId {
let mut data = [0u8; 20];
data[0..4].copy_from_slice(prefix);
data[4..20].copy_from_slice(&asset_id.to_be_bytes());
AccountId::from(data)
}
}
Loading