Skip to content

Commit

Permalink
Merge branch 'master' into ahmad-foreign-assets-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadkaouk authored Dec 4, 2024
2 parents 445d85d + 99eebab commit ebcbe01
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish Rust Docs

on:
workflow_dispatch:
push:
branches:
- master
Expand All @@ -10,7 +11,7 @@ jobs:
name: Deploy docs
runs-on: bare-metal
permissions:
contents: read
contents: write
steps:
# The protobuf compiler should be pre-installed on bare-metal
#- name: Install tooling
Expand Down
52 changes: 26 additions & 26 deletions Cargo.lock

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

9 changes: 4 additions & 5 deletions runtime/moonbase/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,10 @@ impl xcm_executor::Config for XcmExecutorConfig {
type UniversalLocation = UniversalLocation;
type Barrier = XcmBarrier;
type Weigher = XcmWeigher;
// We use two traders
// When we receive the relative representation of the self-reserve asset,
// we use UsingComponents and the local way of handling fees
// When we receive a non-reserve asset, we use AssetManager to fetch how many
// units per second we should charge
// As trader we use the XcmWeightTrader pallet.
// For each foreign asset, the fee is computed based on its relative price (also
// stored in the XcmWeightTrader pallet) against the native asset.
// For the native asset fee is computed using WeightToFee implementation.
type Trader = pallet_xcm_weight_trader::Trader<Runtime>;
type ResponseHandler = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
Expand Down
16 changes: 8 additions & 8 deletions runtime/moonbeam/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use super::{
governance, AccountId, AssetId, AssetManager, Balance, Balances, EmergencyParaXcm,
Erc20XcmBridge, MaintenanceMode, MessageQueue, OpenTechCommitteeInstance, ParachainInfo,
ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, RuntimeCall, RuntimeEvent,
RuntimeOrigin, Treasury, XcmpQueue,
Erc20XcmBridge, EvmForeignAssets, MaintenanceMode, MessageQueue, OpenTechCommitteeInstance,
ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights,
RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue,
};

use super::moonbeam_weights;
Expand Down Expand Up @@ -158,6 +158,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
// We use all transactors
pub type AssetTransactors = (
LocalAssetTransactor,
EvmForeignAssets,
ForeignFungiblesTransactor,
Erc20XcmBridge,
);
Expand Down Expand Up @@ -275,11 +276,10 @@ impl xcm_executor::Config for XcmExecutorConfig {
type UniversalLocation = UniversalLocation;
type Barrier = XcmBarrier;
type Weigher = XcmWeigher;
// We use two traders
// When we receive the relative representation of the self-reserve asset,
// we use UsingComponents and the local way of handling fees
// When we receive a non-reserve asset, we use AssetManager to fetch how many
// units per second we should charge
// As trader we use the XcmWeightTrader pallet.
// For each foreign asset, the fee is computed based on its relative price (also
// stored in the XcmWeightTrader pallet) against the native asset.
// For the native asset fee is computed using WeightToFee implementation.
type Trader = pallet_xcm_weight_trader::Trader<Runtime>;
type ResponseHandler = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
Expand Down
16 changes: 8 additions & 8 deletions runtime/moonriver/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use super::{
governance, AccountId, AssetId, AssetManager, Balance, Balances, EmergencyParaXcm,
Erc20XcmBridge, MaintenanceMode, MessageQueue, OpenTechCommitteeInstance, ParachainInfo,
ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, RuntimeCall, RuntimeEvent,
RuntimeOrigin, Treasury, XcmpQueue,
Erc20XcmBridge, EvmForeignAssets, MaintenanceMode, MessageQueue, OpenTechCommitteeInstance,
ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights,
RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue,
};

use super::moonriver_weights;
Expand Down Expand Up @@ -166,6 +166,7 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
// we import https://github.com/open-web3-stack/open-runtime-module-library/pull/708
pub type AssetTransactors = (
LocalAssetTransactor,
EvmForeignAssets,
ForeignFungiblesTransactor,
Erc20XcmBridge,
);
Expand Down Expand Up @@ -283,11 +284,10 @@ impl xcm_executor::Config for XcmExecutorConfig {
type UniversalLocation = UniversalLocation;
type Barrier = XcmBarrier;
type Weigher = XcmWeigher;
// We use two traders
// When we receive the relative representation of the self-reserve asset,
// we use UsingComponents and the local way of handling fees
// When we receive a non-reserve asset, we use AssetManager to fetch how many
// units per second we should charge
// As trader we use the XcmWeightTrader pallet.
// For each foreign asset, the fee is computed based on its relative price (also
// stored in the XcmWeightTrader pallet) against the native asset.
// For the native asset fee is computed using WeightToFee implementation.
type Trader = pallet_xcm_weight_trader::Trader<Runtime>;
type ResponseHandler = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
Expand Down
53 changes: 53 additions & 0 deletions test/contracts/src/SelfDestruct.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.24;

contract SelfDestructable {
constructor() {
selfdestruct(payable(address(0)));
}
}

contract SelfDestructAfterCreate2 {
uint constant SALT = 1;

address public deployed1;
address public deployed2;

function step1() public {
bytes memory bytecode = type(SelfDestructable).creationCode;
address contractAddress;
uint contractSize;
assembly {
contractAddress := create2(0, add(bytecode, 32), mload(bytecode), SALT)
contractSize := extcodesize(contractAddress)
}
require(contractSize == 0, "Contract size should be zero");
deployed1 = contractAddress;
}


function step2() public {
bytes memory bytecode = type(SelfDestructable).creationCode;
address contractAddress;
uint contractSize;
assembly {
contractAddress := create2(0, add(bytecode, 32), mload(bytecode), SALT)
contractSize := extcodesize(contractAddress)
}
require(contractSize == 0, "Contract size should be zero");
deployed2 = contractAddress;
require(deployed1 == deployed2, "Addresses not equal");
}

function cannotRecreateInTheSameCall() public {
bytes memory bytecode = type(SelfDestructable).creationCode;
address contractAddress1;
address contractAddress2;
assembly {
contractAddress1 := create2(0, add(bytecode, 32), mload(bytecode), SALT)
contractAddress2 := create2(0, add(bytecode, 32), mload(bytecode), SALT)
}
require(contractAddress1 != address(0), "First address must not be null");
require(contractAddress2 == address(0), "Second address must be null");
}
}
Loading

0 comments on commit ebcbe01

Please sign in to comment.