Skip to content

Commit 002c1a5

Browse files
TarekkMAAgusrodri
andauthored
Update-stable2409 (Moonsong-Labs#55)
* 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]>
1 parent 767eb0c commit 002c1a5

File tree

26 files changed

+1016
-892
lines changed

26 files changed

+1016
-892
lines changed

Cargo.lock

+666-692
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+139-139
Large diffs are not rendered by default.

client/consensus/nimbus-consensus/src/import_queue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ where
263263
}
264264

265265
async fn import_block(
266-
&mut self,
266+
&self,
267267
mut block_import_params: sc_consensus::BlockImportParams<Block>,
268268
) -> Result<sc_consensus::ImportResult, Self::Error> {
269269
// If we are in the parachain context, best block is determined by the relay chain

precompiles/assets-erc20/src/eip2612.rs

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ where
123123
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
124124
AssetIdOf<Runtime, Instance>: Display,
125125
Runtime::AccountId: Into<H160>,
126+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
126127
{
127128
fn compute_domain_separator(address: H160, asset_id: AssetIdOf<Runtime, Instance>) -> [u8; 32] {
128129
let asset_name = pallet_assets::Pallet::<Runtime, Instance>::name(asset_id.clone());

precompiles/assets-erc20/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ where
111111
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
112112
AssetIdOf<Runtime, Instance>: Display,
113113
Runtime::AccountId: Into<H160>,
114+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
114115
{
115116
/// PrecompileSet discriminant. Allows to knows if the address maps to an asset id,
116117
/// and if this is the case which one.

precompiles/assets-erc20/src/mock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ parameter_types! {
170170
}
171171

172172
impl pallet_evm::Config for Runtime {
173+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
173174
type FeeCalculator = ();
174175
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
175176
type WeightPerGas = WeightPerGas;

precompiles/balances-erc20/src/eip2612.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ where
4545
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
4646
Metadata: Erc20Metadata,
4747
Instance: InstanceToPrefix + 'static,
48+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
4849
{
4950
pub fn compute_domain_separator(address: H160) -> [u8; 32] {
5051
let name: H256 = keccak_256(Metadata::name().as_bytes()).into();

precompiles/balances-erc20/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ where
187187
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
188188
Metadata: Erc20Metadata,
189189
Instance: InstanceToPrefix + 'static,
190+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
190191
{
191192
#[precompile::public("totalSupply()")]
192193
#[precompile::view]

precompiles/balances-erc20/src/mock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ parameter_types! {
119119
}
120120

121121
impl pallet_evm::Config for Runtime {
122+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
122123
type FeeCalculator = ();
123124
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
124125
type WeightPerGas = WeightPerGas;

precompiles/batch/src/mock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ parameter_types! {
134134
}
135135

136136
impl pallet_evm::Config for Runtime {
137+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
137138
type FeeCalculator = ();
138139
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
139140
type WeightPerGas = WeightPerGas;

precompiles/call-permit/src/mock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ parameter_types! {
120120
}
121121

122122
impl pallet_evm::Config for Runtime {
123+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
123124
type FeeCalculator = ();
124125
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
125126
type WeightPerGas = WeightPerGas;

precompiles/pallet-xcm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ where
7474
From<Option<Runtime::AccountId>>,
7575
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
7676
LocationMatcher: AccountIdToLocationMatcher<<Runtime as frame_system::Config>::AccountId>,
77+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
7778
{
7879
#[precompile::public(
7980
"transferAssetsLocation(\

precompiles/pallet-xcm/src/mock.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ impl GasWeightMapping for MockGasWeightMapping {
252252
}
253253

254254
impl pallet_evm::Config for Runtime {
255+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
255256
type FeeCalculator = ();
256257
type GasWeightMapping = MockGasWeightMapping;
257258
type WeightPerGas = WeightPerGas;
@@ -480,14 +481,9 @@ parameter_types! {
480481

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

483-
pub RelayAsset: Asset = Asset {
484-
fun: Fungible(10000000),
485-
id: AssetId(Location::parent()),
486-
};
487-
488484
pub LocalAsset: (AssetFilter, Location) = (All.into(), Location::here());
489485
pub TrustedForeignAsset: (AssetFilter, Location) = (ForeignAsset::get().into(), ForeignReserveLocation::get());
490-
pub RelayForeignAsset: (AssetFilter, Location) = (RelayAsset::get().into(), RelayLocation::get());
486+
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
491487
}
492488

493489
pub struct XcmConfig;

precompiles/proxy/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ where
5454
<Runtime as frame_system::Config>::RuntimeCall:
5555
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
5656
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
57+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
5758
{
5859
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
5960
match selector {
@@ -86,6 +87,7 @@ where
8687
<Runtime as frame_system::Config>::RuntimeCall:
8788
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
8889
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
90+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
8991
{
9092
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
9193
match selector {
@@ -147,6 +149,7 @@ where
147149
<Runtime as frame_system::Config>::RuntimeCall:
148150
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
149151
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
152+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
150153
{
151154
/// Register a proxy account for the sender that is able to make calls on its behalf.
152155
/// The dispatch origin for this call must be Signed.
@@ -180,7 +183,7 @@ where
180183
handle.record_db_read::<Runtime>(
181184
28 + (29 * (<Runtime as pallet_proxy::Config>::MaxProxies::get() as usize)) + 8,
182185
)?;
183-
if ProxyPallet::<Runtime>::proxies(&origin)
186+
if ProxyPallet::<Runtime>::proxies(origin.clone())
184187
.0
185188
.iter()
186189
.any(|pd| pd.delegate == delegate)

precompiles/proxy/src/mock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ parameter_types! {
157157
};
158158
}
159159
impl pallet_evm::Config for Runtime {
160+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
160161
type FeeCalculator = ();
161162
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
162163
type WeightPerGas = WeightPerGas;

precompiles/xcm-utils/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,17 @@ xcm-builder = { workspace = true }
5454
[features]
5555
default = [ "std" ]
5656
std = [
57+
"cumulus-primitives-core/std",
5758
"frame-support/std",
5859
"frame-system/std",
59-
"pallet-balances/std",
6060
"pallet-evm/std",
61-
"pallet-timestamp/std",
61+
"pallet-xcm/std",
6262
"parity-scale-codec/std",
6363
"precompile-utils/std",
6464
"sp-core/std",
6565
"sp-io/std",
6666
"sp-std/std",
67+
"xcm/std",
6768
"xcm-builder/std",
6869
"xcm-executor/std",
6970
"xcm-primitives/std",

precompiles/xcm-utils/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ where
7171
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
7272
From<Option<Runtime::AccountId>>,
7373
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
74+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
7475
{
7576
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
7677
match selector {
@@ -102,6 +103,7 @@ where
102103
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
103104
From<Option<Runtime::AccountId>>,
104105
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
106+
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
105107
{
106108
#[precompile::public("multilocationToAddress((uint8,bytes[]))")]
107109
#[precompile::view]

precompiles/xcm-utils/src/mock.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ use sp_core::{H256, U256};
3131
use sp_io;
3232
use sp_runtime::traits::{BlakeTwo256, IdentityLookup, TryConvert};
3333
use sp_runtime::BuildStorage;
34-
use xcm::latest::Error as XcmError;
35-
use xcm_builder::AllowUnpaidExecutionFrom;
36-
use xcm_builder::FixedWeightBounds;
37-
use xcm_builder::IsConcrete;
38-
use xcm_builder::SovereignSignedViaLocation;
34+
use xcm::latest::{Error as XcmError, WildAsset::All};
35+
use xcm_builder::{
36+
AllowUnpaidExecutionFrom, Case, FixedWeightBounds, IsConcrete, SovereignSignedViaLocation,
37+
};
3938
use xcm_executor::{
4039
traits::{ConvertLocation, TransactAsset, WeightTrader},
4140
AssetsInHolding,
@@ -269,6 +268,7 @@ impl GasWeightMapping for MockGasWeightMapping {
269268
}
270269

271270
impl pallet_evm::Config for Runtime {
271+
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
272272
type FeeCalculator = ();
273273
type GasWeightMapping = MockGasWeightMapping;
274274
type WeightPerGas = WeightPerGas;
@@ -403,6 +403,9 @@ parameter_types! {
403403
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainId::get().into()).into()].into();
404404

405405
pub const MaxAssetsIntoHolding: u32 = 64;
406+
407+
pub RelayLocation: Location = Location::parent();
408+
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
406409
}
407410

408411
pub type XcmOriginToTransactDispatchOrigin = (
@@ -417,7 +420,7 @@ impl xcm_executor::Config for XcmConfig {
417420
type XcmSender = TestSendXcm;
418421
type AssetTransactor = DummyAssetTransactor;
419422
type OriginConverter = XcmOriginToTransactDispatchOrigin;
420-
type IsReserve = ();
423+
type IsReserve = Case<RelayForeignAsset>;
421424
type IsTeleporter = ();
422425
type UniversalLocation = UniversalLocation;
423426
type Barrier = Barrier;

template/README.md

+117-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,121 @@
1-
# Substrate Cumulus Parachain Template
1+
<div align="center">
22

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

5-
This project is a fork of the [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
6-
modified to include dependencies required for registering this node as a **parathread** or
7-
**parachain** to the Rococo **relay chain**.
8-
Rococo is [Polkadot's parachain testnet](https://polkadot.network/blog/introducing-rococo-polkadots-parachain-testnet/) 👑.
5+
<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"/>
6+
<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"/>
97

10-
👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains), and
11-
parathreads [here](https://wiki.polkadot.network/docs/learn-parathreads).
8+
> This is a template for creating a [parachain](https://wiki.polkadot.network/docs/learn-parachains) based on Polkadot SDK.
9+
>
10+
> This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
1211
13-
To learn about how to actually use the template to hack together your own parachain check out the
14-
`README` from the [`substrate-parachain-template` repository](https://github.com/substrate-developer-hub/substrate-parachain-template/).
12+
</div>
13+
14+
* ⏫ This template provides a starting point to build a [parachain](https://wiki.polkadot.network/docs/learn-parachains).
15+
16+
* ☁️ It is based on the
17+
[Cumulus](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/cumulus/index.html) framework.
18+
19+
* 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
20+
such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html).
21+
22+
* 👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains)
23+
24+
## Template Structure
25+
26+
A Polkadot SDK based project such as this one consists of:
27+
28+
* 💿 a [Node](./node/README.md) - the binary application.
29+
* 🧮 the [Runtime](./runtime/README.md) - the core logic of the parachain.
30+
* 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.
31+
32+
## Getting Started
33+
34+
* 🦀 The template is using the Rust language.
35+
36+
* 👉 Check the
37+
[Rust installation instructions](https://www.rust-lang.org/tools/install) for your system.
38+
39+
* 🛠️ Depending on your operating system and Rust version, there might be additional
40+
packages required to compile this template - please take note of the Rust compiler output.
41+
42+
### Build
43+
44+
🔨 Use the following command to build the node without launching it:
45+
46+
```sh
47+
cargo build --package parachain-template-node --release
48+
```
49+
50+
🐳 Alternatively, build the docker image:
51+
52+
```sh
53+
docker build . -t polkadot-sdk-parachain-template
54+
```
55+
56+
### Local Development Chain
57+
58+
🧟 This project uses [Zombienet](https://github.com/paritytech/zombienet) to orchestrate the relaychain and parachain nodes.
59+
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).
60+
61+
This template produces a parachain node.
62+
You still need a relaychain node - you can download the `polkadot`
63+
(and the accompanying `polkadot-prepare-worker` and `polkadot-execute-worker`)
64+
binaries from [Polkadot SDK releases](https://github.com/paritytech/polkadot-sdk/releases/latest).
65+
66+
Make sure to bring the parachain node - as well as `polkadot`, `polkadot-prepare-worker`, `polkadot-execute-worker`,
67+
and `zombienet` - into `PATH` like so:
68+
69+
```sh
70+
export PATH="./target/release/:$PATH"
71+
```
72+
73+
This way, we can conveniently use them in the following steps.
74+
75+
👥 The following command starts a local development chain, with a single relay chain node and a single parachain collator:
76+
77+
```sh
78+
zombienet --provider native spawn ./zombienet.toml
79+
80+
# Alternatively, the npm version:
81+
npx --yes @zombienet/cli --provider native spawn ./zombienet.toml
82+
```
83+
84+
Development chains:
85+
86+
* 🧹 Do not persist the state.
87+
* 💰 Are preconfigured with a genesis state that includes several prefunded development accounts.
88+
* 🧑‍⚖️ Development accounts are used as validators, collators, and `sudo` accounts.
89+
90+
### Connect with the Polkadot-JS Apps Front-End
91+
92+
* 🌐 You can interact with your local node using the
93+
hosted version of the Polkadot/Substrate Portal:
94+
[relay chain](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944)
95+
and [parachain](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9988).
96+
97+
* 🪐 A hosted version is also
98+
available on [IPFS](https://dotapps.io/).
99+
100+
* 🧑‍🔧 You can also find the source code and instructions for hosting your own instance in the
101+
[`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository.
102+
103+
## Contributing
104+
105+
* 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
106+
107+
* ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/parachain).
108+
109+
* 😇 Please refer to the monorepo's
110+
[contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
111+
[Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).
112+
113+
## Getting Help
114+
115+
* 🧑‍🏫 To learn about Polkadot in general, [Polkadot.network](https://polkadot.network/) website is a good starting point.
116+
117+
* 🧑‍🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
118+
the Polkadot SDK documentation resources.
119+
120+
* 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
121+
[Substrate StackExchange](https://substrate.stackexchange.com/).

template/node/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Node
2+
3+
ℹ️ A node - in Polkadot - is a binary executable, whose primary purpose is to execute the [runtime](../runtime/README.md).
4+
5+
🔗 It communicates with other nodes in the network, and aims for
6+
[consensus](https://wiki.polkadot.network/docs/learn-consensus) among them.
7+
8+
⚙️ It acts as a remote procedure call (RPC) server, allowing interaction with the blockchain.
9+
10+
👉 Learn more about the architecture, and the difference between a node and a runtime
11+
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/wasm_meta_protocol/index.html).
12+
13+
👇 Here are the most important files in this node template:
14+
15+
- [`chain_spec.rs`](./src/chain_spec.rs): A chain specification is a source code file that defines the chain's
16+
initial (genesis) state.
17+
- [`service.rs`](./src/service.rs): This file defines the node implementation.
18+
It's a place to configure consensus-related topics.

0 commit comments

Comments
 (0)