Skip to content

Commit

Permalink
merge changes/fixes from v2 back into main (#333)
Browse files Browse the repository at this point in the history
* update version for antora

* improving zombienet guide (#280)

* update docs version to 2.0.1 (#315)

* Change all references from rococo to paseo (#330)

* remove rococo-native featire from cargo.toml and other doc changes

* use evm compatible accounts, and fix properties for chain spec (#326)

* doc changes

* bump node and docs versions

* impl_runtime_apis need to be in the same file with construct runtime for the moment

* account type fix

* zombienet script update

* slot duration fix

---------

Co-authored-by: Nikita Khateev <[email protected]>
Co-authored-by: Özgün Özerk <[email protected]>
Co-authored-by: Gustavo Gonzalez <[email protected]>

---------
  • Loading branch information
ozgunozerk authored Oct 24, 2024
1 parent d074bd9 commit 033cf12
Show file tree
Hide file tree
Showing 31 changed files with 767 additions and 801 deletions.
4 changes: 4 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default]
extend-ignore-re = [
'AccountId::from\(hex!\("[0-9a-fA-F]{40}"\)\)',
]
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: substrate-runtimes
title: Substrate Runtimes
version: 1.1.0
version: 2.0.2
nav:
- modules/ROOT/nav.adoc
asciidoc:
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/guides/async_backing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cargo build --release --features="async-backing"

== How to test

You can always test it against Rococo (it should already have enabled async backing), but the fastest way is to test against a local relay chain. In our repository you can find a script, a config and a link:https://github.com/OpenZeppelin/polkadot-runtime-templates/tree/main/generic-template/zombienet-config[manual] that will run both relay chain and a parachain. To launch a parachain with a relay chain, you will need to run these commands:
You can always test it against Paseo (it should already have enabled async backing), but the fastest way is to test against a local relay chain. In our repository you can find a script, a config and a link:https://github.com/OpenZeppelin/polkadot-runtime-templates/tree/main/generic-template/zombienet-config[manual] that will run both relay chain and a parachain. To launch a parachain with a relay chain, you will need to run these commands:

* Get the Polkadot binaries:
** If you are using some Linux distro, you can download the binaries:
Expand Down
49 changes: 27 additions & 22 deletions docs/modules/ROOT/pages/guides/quick_start.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

= Quick start

* Begin by visiting our link:https://github.com/OpenZeppelin/polkadot-runtime-templates[repository]. You can fork it, use it as a template, or simply clone it to your local directory.
* Begin by visiting our link:https://github.com/OpenZeppelin/polkadot-runtime-templates[repository]. You can fork it, or simply clone it to your local directory.
```bash
git clone [email protected]:OpenZeppelin/polkadot-runtime-templates.git
```

* Move to the directory of the template you want to use. We will use the `generic runtime template` for this tutorial.
* Move to the directory of the template you want to use. We will use the `generic runtime template` for this tutorial, but it is the same for the same applies to the xref:runtimes/evm.adoc[EVM Runtime Template].
```bash
cd generic-template
```
Expand All @@ -19,41 +19,46 @@ cd generic-template
cargo build --release
```

* Receive some `ROC` from the link:https://paritytech.github.io/polkadot-testnet-faucet/[Rococo faucet]
* Receive some `PSO` from the link:https://paritytech.github.io/polkadot-testnet-faucet/[Paseo faucet]

* Reserve a ParaId on Rococo:
* Reserve a ParaId on Paseo:

** Go to link:https://polkadot.js.org/apps[PolkadotJS]. Check that it points to Rococo testnet.
** Go to link:https://polkadot.js.org/apps[PolkadotJS]. Check that it points to Paseo testnet.
** Go to `Network` > `Parachains`
** Go to `Parathreads` tab
** Click the `+ ParaId` button
** Save a `parachain id` for the further usage.
** Save the `parachain id` for the further usage.
** Click `Submit` and `Sign and Submit`.

* Generate and customize a chainspec:

[NOTE]
====
We use the `generic-template-node` executable throughout all the commands since we are using the `generic-template`, but make sure to update the name of the executable if you are using any of the other runtime template.
====

** Generate a plain chainspec with this command:
+
```bash
./target/release/parachain-template-node build-spec --disable-default-bootnode > plain-parachain-chainspec.json
./target/release/generic-template-node build-spec --disable-default-bootnode > plain-parachain-chainspec.json
```

** Edit the chainspec:

*** Update `name`, `id` and `protocolId` to unique values.
*** Change `relay_chain` from `rococo-local` to `rococo`.
*** Change `relay_chain` from `paseo-local` to `paseo`.
*** Change `para_id` and `parachainInfo.parachainId` from `1000` to the previously saved parachain id.

** Generate a raw chainspec with this command:
+
```bash
./target/release/parachain-template-node build-spec --chain plain-parachain-chainspec.json --disable-default-bootnode --raw > raw-parachain-chainspec.json
./target/release/generic-template-node build-spec --chain plain-parachain-chainspec.json --disable-default-bootnode --raw > raw-parachain-chainspec.json
```

* Run two nodes and wait until it syncs with the Rococo relay chain. This can take a fairly long time(up to 2 days), so we can use the `fast-unsafe` flag to make the process faster since we are on a testnet(~ 3 hours). `fast` downloads the blocks without executing the transactions, and `unsafe` skips downloading the state proofs(which we are ok with since it is Rococo).
* Run two nodes and wait until it syncs with the Paseo relay chain. This can take a fairly long time(up to 2 days), so we can use the `fast-unsafe` flag to make the process faster since we are on a testnet(~ 3 hours). `fast` downloads the blocks without executing the transactions, and `unsafe` skips downloading the state proofs(which we are ok with since it is a testnet).
+
```bash
./target/release/parachain-template-node \
./target/release/generic-template-node \
--alice \
--collator \
--force-authoring \
Expand All @@ -63,14 +68,14 @@ cargo build --release
--rpc-port 8844 \
-- \
--execution wasm \
--chain <path to the Rococo chainspec> \
--chain <path to the Paseo chainspec> \
--port 30343 \
--rpc-port 9977 \
--sync fast-unsafe
```
+
```bash
./target/release/parachain-template-node \
./target/release/generic-template-node \
--bob \
--collator \
--force-authoring \
Expand All @@ -80,27 +85,27 @@ cargo build --release
--rpc-port 8845 \
-- \
--execution wasm \
--chain <path to the Rococo chainspec> \
--chain <path to the Paseo chainspec> \
--port 30343 \
--rpc-port 9977 \
--sync fast-unsafe
```
** `<path to datadir>` is where the downloaded chain state will be stored. It can be any folder on your computer.
** `<path to the Rococo chainspec>` is where your Rococo chainspec is stored. You can download this file from the link:https://github.com/paritytech/polkadot-sdk/blob/release-polkadot-v1.10.0/polkadot/node/service/chain-specs/rococo.jsonofficial[official Polkadot sdk repository].
** `<path to the Paseo chainspec>` is where your Paseo chainspec is stored. You can download this file from the link:https://github.com/paritytech/polkadot-sdk/blob/release-polkadot-v1.10.0/polkadot/node/service/chain-specs/paseo.json[official Polkadot sdk repository].

* Register a parathread:

** Generate a genesis state:
+
```bash
./target/release/parachain-template-node export-genesis-state --chain raw-parachain-chainspec.json para-<paraId>-genesis-state
./target/release/generic-template-node export-genesis-state --chain raw-parachain-chainspec.json para-<paraId>-genesis-state
```
** Generate a genesis wasm:
+
```bash
./target/release/parachain-template-node export-genesis-wasm --chain raw-parachain-chainspec.json para-<paraId>-wasm
./target/release/generic-template-node export-genesis-wasm --chain raw-parachain-chainspec.json para-<paraId>-wasm
```
** Go to link:https://polkadot.js.org/apps[PolkadotJS]. Check that it points to Rococo testnet.
** Go to link:https://polkadot.js.org/apps[PolkadotJS]. Check that it points to Paseo testnet.
** Go to `Network` > `Parachains`.
** Go to `Parathreads` tab.
** Click the `+ ParaThread` button.
Expand All @@ -110,16 +115,16 @@ cargo build --release

* When a parachain gets synced with a relaychain, you may start producing blocks as a parathread:
** Create some transaction with a PolkadotJS pointing to your parachain setup.
** With a PolkadotJS pointing to Rococo go to `Developer` > `Extrinsics`.
** With a PolkadotJS pointing to Paseo go to `Developer` > `Extrinsics`.
** Submit an extrinsic `onDemandAssignmentProvider.placeOrderAllowDeath` or `onDemandAssignmentProvider.placeOrderKeepAlive`:
*** `maxAmount` should be not less than 10_000_000 and it is amount of 0.00001 ROC. It is an amount of ROC paid for the block.
*** `maxAmount` should be not less than 10_000_000 and it is amount of 0.00001 PAS. It is an amount of PAS paid for the block.
*** `paraId` should be set to your parachain id.
*** Click `Submit` and `Sign and Submit`.
** In some time your parathread will produce a block and in one of the next blocks of Rococo there will be an inclusion of this block
** In some time your parathread will produce a block and in one of the next blocks of Paseo there will be an inclusion of this block

== What's next?

- Read our general guides to understand more about the concepts of runtime development.

- Learn more about the runtime configuration. Currently, we have two runtime templates: xref:guides/runtimes/generic.adoc[Generic Runtime Template] and xref:runtimes/evm.adoc[EVM Runtime Template].
- Learn more about the runtime configuration. Currently, we have two runtime templates: xref:runtimes/generic.adoc[Generic Runtime Template] and xref:runtimes/evm.adoc[EVM Runtime Template].
- Explore the documentation for pallets. It may be useful if you are considering building a frontend for your parachain.
22 changes: 11 additions & 11 deletions docs/modules/ROOT/pages/guides/testing_with_zombienet.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
In this tutorial, we will demonstrate how to deploy your parachain using Zombienet, and test the functionalities of your parachain.

Below are the main steps of this demo:
. Deploy our parachain against the locally simulated rococo testnet by Zombienet.
. Deploy our parachain against the locally simulated Paseo testnet by Zombienet.
. Deploy a Solidity smart contract on our parachain.
. Successfully invoke the Solidity smart contract deployed on our parachain.

Expand All @@ -25,7 +25,7 @@ cd evm-template
+
```rust
[relaychain]
chain = "rococo-local"
chain = "paseo-local"
default_command = "./bin-v1.6.0/polkadot"

[[relaychain.nodes]]
Expand Down Expand Up @@ -162,12 +162,11 @@ image::zombie-chain-spec.png[Zombie Chain Spec]
--rpc-port 8844 \
-- \
--execution wasm \
--chain /var/folders/...{redacted}.../rococo-local.json \
--chain /var/folders/...{redacted}.../paseo-local.json \
--port 30343 \
--rpc-port 9977
```


. your node should be running without any problem, and should see block production in your node terminal!
+
image::node-success.png[Node Success]
Expand Down Expand Up @@ -221,15 +220,16 @@ import { Web3 } from "web3";
const web3 = new Web3("ws://127.0.0.1:8844");

console.log("Balance:");
web3.eth.getBalance("0xe04cc55ebee1cbce552f250e85c57b70b2e2625b").then(console.log);
// this is the address of `Alith` in our chainspec
web3.eth.getBalance("0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac").then(console.log);

let raw = await web3.eth.accounts.signTransaction({
gas: 21000,
gasPrice: 10000000000,
from: "0xe04cc55ebee1cbce552f250e85c57b70b2e2625b",
to: "0x7c98a1801f0B28dF559bCd828fc67Bd6ab558074",
from: "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac", // Alith's address
to: "0x7c98a1801f0B28dF559bCd828fc67Bd6ab558074", // Baltathar's address
value: '100000000000000000'
}, "0xcb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854");
}, "0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133"); // Alith's private key

let res = await web3.eth.sendSignedTransaction(raw.rawTransaction);
console.log("Transaction details:");
Expand Down Expand Up @@ -289,13 +289,13 @@ export var MyAbi = [
node sanity_check.js
```

. open a terminal instance where the current directory has the `HelloWorld.sol` file, and run:
. open a terminal instance where the current directory has the `HelloWorld.sol` file, and run the below command to deploy the contract with Alith's private key:
+
```solidity
forge create --rpc-url http://localhost:8844 --private-key 0xcb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854 HelloWorld.sol:HelloWorld
forge create --rpc-url http://localhost:9933 --private-key 0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133 HelloWorld.sol:HelloWorld
```
+
* don’t forget to copy the address this contract deployed to!
* don’t forget to copy the address this contract deployed to (shown in the output of the command)!



Expand Down
6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

= Polkadot Parachain Runtimes

A collection of runtimes that describe parachains with different purposes.
A collection of secure runtime templates to build parachains more easily on Polkadot.

=== Runtimes
== Runtimes
* xref:runtimes/generic.adoc[Generic Runtime Template]
* xref:runtimes/evm.adoc[EVM Runtime Template]


=== A Couple of Good Starting Places
== Where to get started
* xref:guides/quick_start.adoc[Quick Start]: a generic parachain runtime that works out of the box. It has all the must have features, and allows further customization based on your project's needs. Generic Runtime Template also serves as the base for our other runtime templates.
* xref:guides/testing_with_zombienet.adoc[Testing with Zombienet]: a more opinionated parachain runtime template that maximizes Ethereum compatibility by using `AccountId20` and configures a local EVM instance. You can easily migrate/deploy Solidity Smart Contracts to this one.

4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/runtimes/evm.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
:source-highlighter: highlight.js
:highlightjs-languages: rust
:github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
= Generic Runtime
= EVM Runtime

== Purpose

EVM Runtime Template is built on top of the link:generic.adoc[Generic Runtime Template].
EVM Runtime Template is built on top of the xref:runtimes/generic.adoc[Generic Runtime Template].

The purpose of this template is to provide EVM compatibilities embedded into the runtime.

Expand Down
2 changes: 1 addition & 1 deletion evm-template/Cargo.lock

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

4 changes: 2 additions & 2 deletions evm-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = { workspace = true }
license = { workspace = true }
publish = false
repository = { workspace = true }
version = "1.0.0"
version = "2.0.0"

[dependencies]
clap = { workspace = true }
Expand Down Expand Up @@ -59,7 +59,7 @@ substrate-frame-rpc-system = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

# Polkadot
polkadot-cli = { workspace = true, features = [ "rococo-native" ] }
polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
xcm = { workspace = true }

Expand Down
51 changes: 21 additions & 30 deletions evm-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ pub fn development_config(contracts_path: ContractsPath) -> ChainSpec {
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());
properties.insert("isEthereum".into(), true.into());
// This is very important for us, it lets us track the usage of our templates, and have no downside for the node/runtime. Please do not remove :)
properties.insert("basedOn".into(), "OpenZeppelin EVM Template".into());

ChainSpec::builder(
evm_runtime_template::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
relay_chain: "paseo-local".into(),
// You MUST set this to the correct network!
para_id: 1000,
},
Expand All @@ -101,25 +102,19 @@ pub fn development_config(contracts_path: ContractsPath) -> ChainSpec {
(get_account_id_from_seed::<ecdsa::Public>("Bob"), get_collator_keys_from_seed("Bob")),
],
vec![
get_account_id_from_seed::<ecdsa::Public>("Alice"),
get_account_id_from_seed::<ecdsa::Public>("Bob"),
get_account_id_from_seed::<ecdsa::Public>("Charlie"),
get_account_id_from_seed::<ecdsa::Public>("Dave"),
get_account_id_from_seed::<ecdsa::Public>("Eve"),
get_account_id_from_seed::<ecdsa::Public>("Ferdie"),
get_account_id_from_seed::<ecdsa::Public>("Alice//stash"),
get_account_id_from_seed::<ecdsa::Public>("Bob//stash"),
get_account_id_from_seed::<ecdsa::Public>("Charlie//stash"),
get_account_id_from_seed::<ecdsa::Public>("Dave//stash"),
get_account_id_from_seed::<ecdsa::Public>("Eve//stash"),
get_account_id_from_seed::<ecdsa::Public>("Ferdie//stash"),
AccountId::from(hex!("33c7c88f2B2Fcb83975fCDB08d2B5bf7eA29FDCE")),
AccountId::from(hex!("c02db867898f227416BCB6d97190126A6b04988A")),
// Alith, Baltathar, Charleth and Dorothy, Ethan
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")),
],
get_account_id_from_seed::<ecdsa::Public>("Alice"),
// Alith
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
1000.into(),
contracts_path,
))
.with_properties(properties)
.build()
}

Expand All @@ -129,12 +124,13 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());
properties.insert("isEthereum".into(), true.into());

#[allow(deprecated)]
ChainSpec::builder(
evm_runtime_template::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
relay_chain: "paseo-local".into(),
// You MUST set this to the correct network!
para_id: 1000,
},
Expand All @@ -152,20 +148,15 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
(get_account_id_from_seed::<ecdsa::Public>("Bob"), get_collator_keys_from_seed("Bob")),
],
vec![
get_account_id_from_seed::<ecdsa::Public>("Alice"),
get_account_id_from_seed::<ecdsa::Public>("Bob"),
get_account_id_from_seed::<ecdsa::Public>("Charlie"),
get_account_id_from_seed::<ecdsa::Public>("Dave"),
get_account_id_from_seed::<ecdsa::Public>("Eve"),
get_account_id_from_seed::<ecdsa::Public>("Ferdie"),
get_account_id_from_seed::<ecdsa::Public>("Alice//stash"),
get_account_id_from_seed::<ecdsa::Public>("Bob//stash"),
get_account_id_from_seed::<ecdsa::Public>("Charlie//stash"),
get_account_id_from_seed::<ecdsa::Public>("Dave//stash"),
get_account_id_from_seed::<ecdsa::Public>("Eve//stash"),
get_account_id_from_seed::<ecdsa::Public>("Ferdie//stash"),
// Alith, Baltathar, Charleth and Dorothy, Ethan
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")),
],
get_account_id_from_seed::<ecdsa::Public>("Alice"),
// Alith
AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
1000.into(),
contracts_path,
))
Expand Down
Loading

0 comments on commit 033cf12

Please sign in to comment.