Skip to content

Commit

Permalink
Update-stable2409 (#55)
Browse files Browse the repository at this point in the history
* Update polkadot-sdk to stable2409

* Update frontier and evm pins

* fix breaking changes

* formatting

* fix tests

* fix test_executor_send and some cleanup

* update README.md

* add missing READMEs

---------

Co-authored-by: Agusrodri <[email protected]>
  • Loading branch information
TarekkMA and Agusrodri authored Oct 31, 2024
1 parent 767eb0c commit 002c1a5
Show file tree
Hide file tree
Showing 26 changed files with 1,016 additions and 892 deletions.
1,358 changes: 666 additions & 692 deletions Cargo.lock

Large diffs are not rendered by default.

278 changes: 139 additions & 139 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/consensus/nimbus-consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ where
}

async fn import_block(
&mut self,
&self,
mut block_import_params: sc_consensus::BlockImportParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
// If we are in the parachain context, best block is determined by the relay chain
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
AssetIdOf<Runtime, Instance>: Display,
Runtime::AccountId: Into<H160>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn compute_domain_separator(address: H160, asset_id: AssetIdOf<Runtime, Instance>) -> [u8; 32] {
let asset_name = pallet_assets::Pallet::<Runtime, Instance>::name(asset_id.clone());
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
AssetIdOf<Runtime, Instance>: Display,
Runtime::AccountId: Into<H160>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
/// PrecompileSet discriminant. Allows to knows if the address maps to an asset id,
/// and if this is the case which one.
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ where
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
Metadata: Erc20Metadata,
Instance: InstanceToPrefix + 'static,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
pub fn compute_domain_separator(address: H160) -> [u8; 32] {
let name: H256 = keccak_256(Metadata::name().as_bytes()).into();
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ where
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
Metadata: Erc20Metadata,
Instance: InstanceToPrefix + 'static,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public("totalSupply()")]
#[precompile::view]
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/batch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/call-permit/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ where
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
LocationMatcher: AccountIdToLocationMatcher<<Runtime as frame_system::Config>::AccountId>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public(
"transferAssetsLocation(\
Expand Down
8 changes: 2 additions & 6 deletions precompiles/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl GasWeightMapping for MockGasWeightMapping {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = MockGasWeightMapping;
type WeightPerGas = WeightPerGas;
Expand Down Expand Up @@ -480,14 +481,9 @@ parameter_types! {

pub RelayLocation: Location = Location::parent();

pub RelayAsset: Asset = Asset {
fun: Fungible(10000000),
id: AssetId(Location::parent()),
};

pub LocalAsset: (AssetFilter, Location) = (All.into(), Location::here());
pub TrustedForeignAsset: (AssetFilter, Location) = (ForeignAsset::get().into(), ForeignReserveLocation::get());
pub RelayForeignAsset: (AssetFilter, Location) = (RelayAsset::get().into(), RelayLocation::get());
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
}

pub struct XcmConfig;
Expand Down
5 changes: 4 additions & 1 deletion precompiles/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -86,6 +87,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -147,6 +149,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
/// Register a proxy account for the sender that is able to make calls on its behalf.
/// The dispatch origin for this call must be Signed.
Expand Down Expand Up @@ -180,7 +183,7 @@ where
handle.record_db_read::<Runtime>(
28 + (29 * (<Runtime as pallet_proxy::Config>::MaxProxies::get() as usize)) + 8,
)?;
if ProxyPallet::<Runtime>::proxies(&origin)
if ProxyPallet::<Runtime>::proxies(origin.clone())
.0
.iter()
.any(|pd| pd.delegate == delegate)
Expand Down
1 change: 1 addition & 0 deletions precompiles/proxy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ parameter_types! {
};
}
impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
5 changes: 3 additions & 2 deletions precompiles/xcm-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ xcm-builder = { workspace = true }
[features]
default = [ "std" ]
std = [
"cumulus-primitives-core/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-evm/std",
"pallet-timestamp/std",
"pallet-xcm/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-io/std",
"sp-std/std",
"xcm/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-primitives/std",
Expand Down
2 changes: 2 additions & 0 deletions precompiles/xcm-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -102,6 +103,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public("multilocationToAddress((uint8,bytes[]))")]
#[precompile::view]
Expand Down
15 changes: 9 additions & 6 deletions precompiles/xcm-utils/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ use sp_core::{H256, U256};
use sp_io;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup, TryConvert};
use sp_runtime::BuildStorage;
use xcm::latest::Error as XcmError;
use xcm_builder::AllowUnpaidExecutionFrom;
use xcm_builder::FixedWeightBounds;
use xcm_builder::IsConcrete;
use xcm_builder::SovereignSignedViaLocation;
use xcm::latest::{Error as XcmError, WildAsset::All};
use xcm_builder::{
AllowUnpaidExecutionFrom, Case, FixedWeightBounds, IsConcrete, SovereignSignedViaLocation,
};
use xcm_executor::{
traits::{ConvertLocation, TransactAsset, WeightTrader},
AssetsInHolding,
Expand Down Expand Up @@ -269,6 +268,7 @@ impl GasWeightMapping for MockGasWeightMapping {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = MockGasWeightMapping;
type WeightPerGas = WeightPerGas;
Expand Down Expand Up @@ -403,6 +403,9 @@ parameter_types! {
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainId::get().into()).into()].into();

pub const MaxAssetsIntoHolding: u32 = 64;

pub RelayLocation: Location = Location::parent();
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
}

pub type XcmOriginToTransactDispatchOrigin = (
Expand All @@ -417,7 +420,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = TestSendXcm;
type AssetTransactor = DummyAssetTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = ();
type IsReserve = Case<RelayForeignAsset>;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
Expand Down
127 changes: 117 additions & 10 deletions template/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,121 @@
# Substrate Cumulus Parachain Template
<div align="center">

A new [Cumulus](https://github.com/paritytech/cumulus/)-based Substrate node, ready for hacking ☁️..
# Polkadot SDK's Parachain Template

This project is a fork of the [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
modified to include dependencies required for registering this node as a **parathread** or
**parachain** to the Rococo **relay chain**.
Rococo is [Polkadot's parachain testnet](https://polkadot.network/blog/introducing-rococo-polkadots-parachain-testnet/) 👑.
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_White.png#gh-dark-mode-only"/>
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>

👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains), and
parathreads [here](https://wiki.polkadot.network/docs/learn-parathreads).
> This is a template for creating a [parachain](https://wiki.polkadot.network/docs/learn-parachains) based on Polkadot SDK.
>
> This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
To learn about how to actually use the template to hack together your own parachain check out the
`README` from the [`substrate-parachain-template` repository](https://github.com/substrate-developer-hub/substrate-parachain-template/).
</div>

* ⏫ This template provides a starting point to build a [parachain](https://wiki.polkadot.network/docs/learn-parachains).

* ☁️ It is based on the
[Cumulus](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/cumulus/index.html) framework.

* 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html).

* 👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains)

## Template Structure

A Polkadot SDK based project such as this one consists of:

* 💿 a [Node](./node/README.md) - the binary application.
* 🧮 the [Runtime](./runtime/README.md) - the core logic of the parachain.
* 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.

## Getting Started

* 🦀 The template is using the Rust language.

* 👉 Check the
[Rust installation instructions](https://www.rust-lang.org/tools/install) for your system.

* 🛠️ Depending on your operating system and Rust version, there might be additional
packages required to compile this template - please take note of the Rust compiler output.

### Build

🔨 Use the following command to build the node without launching it:

```sh
cargo build --package parachain-template-node --release
```

🐳 Alternatively, build the docker image:

```sh
docker build . -t polkadot-sdk-parachain-template
```

### Local Development Chain

🧟 This project uses [Zombienet](https://github.com/paritytech/zombienet) to orchestrate the relaychain and parachain nodes.
You can grab a [released binary](https://github.com/paritytech/zombienet/releases/latest) or use an [npm version](https://www.npmjs.com/package/@zombienet/cli).

This template produces a parachain node.
You still need a relaychain node - you can download the `polkadot`
(and the accompanying `polkadot-prepare-worker` and `polkadot-execute-worker`)
binaries from [Polkadot SDK releases](https://github.com/paritytech/polkadot-sdk/releases/latest).

Make sure to bring the parachain node - as well as `polkadot`, `polkadot-prepare-worker`, `polkadot-execute-worker`,
and `zombienet` - into `PATH` like so:

```sh
export PATH="./target/release/:$PATH"
```

This way, we can conveniently use them in the following steps.

👥 The following command starts a local development chain, with a single relay chain node and a single parachain collator:

```sh
zombienet --provider native spawn ./zombienet.toml

# Alternatively, the npm version:
npx --yes @zombienet/cli --provider native spawn ./zombienet.toml
```

Development chains:

* 🧹 Do not persist the state.
* 💰 Are preconfigured with a genesis state that includes several prefunded development accounts.
* 🧑‍⚖️ Development accounts are used as validators, collators, and `sudo` accounts.

### Connect with the Polkadot-JS Apps Front-End

* 🌐 You can interact with your local node using the
hosted version of the Polkadot/Substrate Portal:
[relay chain](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944)
and [parachain](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9988).

* 🪐 A hosted version is also
available on [IPFS](https://dotapps.io/).

* 🧑‍🔧 You can also find the source code and instructions for hosting your own instance in the
[`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository.

## Contributing

* 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).

* ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/parachain).

* 😇 Please refer to the monorepo's
[contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
[Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).

## Getting Help

* 🧑‍🏫 To learn about Polkadot in general, [Polkadot.network](https://polkadot.network/) website is a good starting point.

* 🧑‍🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
the Polkadot SDK documentation resources.

* 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
[Substrate StackExchange](https://substrate.stackexchange.com/).
18 changes: 18 additions & 0 deletions template/node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node

ℹ️ A node - in Polkadot - is a binary executable, whose primary purpose is to execute the [runtime](../runtime/README.md).

🔗 It communicates with other nodes in the network, and aims for
[consensus](https://wiki.polkadot.network/docs/learn-consensus) among them.

⚙️ It acts as a remote procedure call (RPC) server, allowing interaction with the blockchain.

👉 Learn more about the architecture, and the difference between a node and a runtime
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/wasm_meta_protocol/index.html).

👇 Here are the most important files in this node template:

- [`chain_spec.rs`](./src/chain_spec.rs): A chain specification is a source code file that defines the chain's
initial (genesis) state.
- [`service.rs`](./src/service.rs): This file defines the node implementation.
It's a place to configure consensus-related topics.
Loading

0 comments on commit 002c1a5

Please sign in to comment.