Skip to content

Commit f50de6b

Browse files
authored
Tanssi integration (#361)
Integrated Tanssi runtimes and updated the abstraction macro invocation
1 parent 50d854b commit f50de6b

File tree

31 files changed

+3156
-1206
lines changed

31 files changed

+3156
-1206
lines changed

evm-template/Cargo.lock

Lines changed: 661 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evm-template/Cargo.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ serde_json = "1.0.121"
2828
smallvec = "1.11.0"
2929

3030
# TODO: update to release
31-
openzeppelin-polkadot-wrappers = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
32-
openzeppelin-polkadot-wrappers-proc = { git = "https://github.com/openzeppelin/polkadot-runtime-wrappers", default-features = false, tag = "v0.1-rc1" }
31+
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
32+
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
3333

3434
# Substrate
3535
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -67,6 +67,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features
6767
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
6868
sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
6969
sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
70+
sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
7071
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
7172
sc-network = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
7273
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -120,6 +121,7 @@ cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk",
120121
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
121122
cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
122123
cumulus-client-consensus-proposer = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
124+
cumulus-client-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
123125
cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
124126
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
125127
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -130,6 +132,7 @@ cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk",
130132
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
131133
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
132134
cumulus-primitives-storage-weight-reclaim = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
135+
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
133136
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
134137
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
135138
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -181,6 +184,15 @@ xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch
181184
substrate-runtimes-fuzzers = { git = "https://github.com/srlabs/substrate-runtime-fuzzer.git", default-features = false, tag = "polkadot-v1.12.0" }
182185
ziggy = { version = "0.8", default-features = false }
183186

187+
# Tanssi
188+
ccp-authorities-noting-inherent = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
189+
dp-consensus = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
190+
nimbus-consensus = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
191+
nimbus-primitives = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
192+
pallet-author-inherent = { git = "https://github.com/OpenZeppelin/moonkit", default-features = false, tag = "polkadot-stable2407-1" }
193+
pallet-cc-authorities-noting = { git = "https://github.com/OpenZeppelin/dancekit", default-features = false, tag = "polkadot-stable2407-1" }
194+
tc-consensus = { git = "https://github.com/KitHat/tanssi", branch = "polkadot-stable2407-1", default-features = false }
195+
184196
[workspace.lints.clippy]
185197
large_enum_variant = "allow"
186198
too_many_arguments = "allow"

evm-template/node/Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ sc-cli = { workspace = true }
3434
sc-client-api = { workspace = true }
3535
sc-consensus = { workspace = true }
3636
sc-consensus-aura = { workspace = true }
37+
sc-consensus-slots = { workspace = true }
3738
sc-executor = { workspace = true }
3839
sc-network = { workspace = true }
3940
sc-network-sync = { workspace = true }
@@ -70,10 +71,12 @@ cumulus-client-collator = { workspace = true }
7071
cumulus-client-consensus-aura = { workspace = true }
7172
cumulus-client-consensus-common = { workspace = true }
7273
cumulus-client-consensus-proposer = { workspace = true }
74+
cumulus-client-parachain-inherent = { workspace = true }
7375
cumulus-client-service = { workspace = true }
7476
cumulus-primitives-core = { workspace = true }
7577
cumulus-primitives-parachain-inherent = { workspace = true }
7678
cumulus-relay-chain-interface = { workspace = true }
79+
cumulus-test-relay-sproof-builder = { workspace = true }
7780

7881
# Frontier
7982
fc-api = { workspace = true }
@@ -87,21 +90,19 @@ fp-dynamic-fee = { workspace = true, features = [ "std" ] }
8790
fp-evm = { workspace = true }
8891
fp-rpc = { workspace = true }
8992

93+
# Tanssi
94+
ccp-authorities-noting-inherent = { workspace = true }
95+
nimbus-consensus = { workspace = true }
96+
tc-consensus = { workspace = true }
97+
9098
[build-dependencies]
9199
substrate-build-script-utils = { workspace = true }
92100

93101
[features]
94102
default = []
95103
async-backing = []
96-
runtime-benchmarks = [
97-
"evm-runtime-template/runtime-benchmarks",
98-
"frame-benchmarking-cli/runtime-benchmarks",
99-
"frame-benchmarking/runtime-benchmarks",
100-
"polkadot-cli/runtime-benchmarks",
101-
"polkadot-primitives/runtime-benchmarks",
102-
"sc-service/runtime-benchmarks",
103-
"sp-runtime/runtime-benchmarks",
104-
]
104+
runtime-benchmarks = [ "evm-runtime-template/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "polkadot-cli/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "tc-consensus/runtime-benchmarks" ]
105+
tanssi = []
105106
try-runtime = [
106107
"evm-runtime-template/try-runtime",
107108
"polkadot-cli/try-runtime",

evm-template/node/src/chain_spec.rs

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
use std::collections::BTreeMap;
22

33
use cumulus_primitives_core::ParaId;
4-
use evm_runtime_template::{
5-
AccountId, AuraId, OpenZeppelinPrecompiles as Precompiles, Runtime, Signature,
6-
};
4+
use evm_runtime_template::{AccountId, OpenZeppelinPrecompiles as Precompiles, Runtime};
5+
#[cfg(not(feature = "tanssi"))]
6+
use evm_runtime_template::{AuraId, Signature};
77
use fp_evm::GenesisAccount;
88
use hex_literal::hex;
99
use log::error;
1010
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
1111
use sc_service::ChainType;
1212
use serde::{Deserialize, Serialize};
13-
use sp_core::{ecdsa, Pair, Public, H160};
13+
use sp_core::H160;
14+
#[cfg(not(feature = "tanssi"))]
15+
use sp_core::{ecdsa, Pair, Public};
16+
#[cfg(not(feature = "tanssi"))]
1417
use sp_runtime::traits::{IdentifyAccount, Verify};
1518

1619
use crate::contracts::{parse_contracts, ContractsPath};
@@ -22,6 +25,7 @@ pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
2225
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
2326

2427
/// Helper function to generate a crypto pair from seed
28+
#[cfg(not(feature = "tanssi"))]
2529
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
2630
TPublic::Pair::from_string(&format!("//{}", seed), None)
2731
.expect("static values are valid; qed")
@@ -45,17 +49,20 @@ impl Extensions {
4549
}
4650
}
4751

52+
#[cfg(not(feature = "tanssi"))]
4853
type AccountPublic = <Signature as Verify>::Signer;
4954

5055
/// Generate collator keys from seed.
5156
///
5257
/// This function's return type must always match the session keys of the chain
5358
/// in tuple format.
59+
#[cfg(not(feature = "tanssi"))]
5460
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
5561
get_from_seed::<AuraId>(seed)
5662
}
5763

5864
/// Helper function to generate an account ID from seed
65+
#[cfg(not(feature = "tanssi"))]
5966
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
6067
where
6168
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
@@ -67,6 +74,7 @@ where
6774
///
6875
/// The input must be a tuple of individual keys (a single arg for now since we
6976
/// have just one key).
77+
#[cfg(not(feature = "tanssi"))]
7078
pub fn template_session_keys(keys: AuraId) -> evm_runtime_template::SessionKeys {
7179
evm_runtime_template::SessionKeys { aura: keys }
7280
}
@@ -94,6 +102,7 @@ pub fn development_config(contracts_path: ContractsPath) -> ChainSpec {
94102
.with_chain_type(ChainType::Development)
95103
.with_genesis_config_patch(testnet_genesis(
96104
// initial collators.
105+
#[cfg(not(feature = "tanssi"))]
97106
vec![
98107
(
99108
get_account_id_from_seed::<ecdsa::Public>("Alice"),
@@ -140,6 +149,7 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
140149
.with_chain_type(ChainType::Local)
141150
.with_genesis_config_patch(testnet_genesis(
142151
// initial collators.
152+
#[cfg(not(feature = "tanssi"))]
143153
vec![
144154
(
145155
get_account_id_from_seed::<ecdsa::Public>("Alice"),
@@ -165,6 +175,7 @@ pub fn local_testnet_config(contracts_path: ContractsPath) -> ChainSpec {
165175
.build()
166176
}
167177

178+
#[cfg(not(feature = "tanssi"))]
168179
fn testnet_genesis(
169180
invulnerables: Vec<(AccountId, AuraId)>,
170181
#[cfg(not(feature = "runtime-benchmarks"))] endowed_accounts: Vec<AccountId>,
@@ -245,3 +256,67 @@ fn testnet_genesis(
245256
"sudo": { "key": Some(root) }
246257
})
247258
}
259+
260+
#[cfg(feature = "tanssi")]
261+
fn testnet_genesis(
262+
#[cfg(not(feature = "runtime-benchmarks"))] endowed_accounts: Vec<AccountId>,
263+
#[cfg(feature = "runtime-benchmarks")] mut endowed_accounts: Vec<AccountId>,
264+
root: AccountId,
265+
id: ParaId,
266+
contracts_path: ContractsPath,
267+
) -> serde_json::Value {
268+
let contracts = parse_contracts(contracts_path)
269+
.map_err(|e| error!("Error while parsing contracts: {e:?}"))
270+
.unwrap_or_default();
271+
let precompiles = Precompiles::<Runtime>::used_addresses()
272+
.map(|addr| {
273+
(
274+
addr,
275+
GenesisAccount {
276+
nonce: Default::default(),
277+
balance: Default::default(),
278+
storage: Default::default(),
279+
// bytecode to revert without returning data
280+
// (PUSH1 0x00 PUSH1 0x00 REVERT)
281+
code: vec![0x60, 0x00, 0x60, 0x00, 0xFD],
282+
},
283+
)
284+
})
285+
.into_iter();
286+
let accounts: BTreeMap<H160, GenesisAccount> = contracts
287+
.into_iter()
288+
.map(|(address, contract)| {
289+
(
290+
address,
291+
GenesisAccount {
292+
code: contract.bytecode(),
293+
nonce: Default::default(),
294+
balance: Default::default(),
295+
storage: Default::default(),
296+
},
297+
)
298+
})
299+
.chain(precompiles)
300+
.collect();
301+
#[cfg(feature = "runtime-benchmarks")]
302+
endowed_accounts.push(AccountId::from(hex!("1000000000000000000000000000000000000001")));
303+
serde_json::json!({
304+
"balances": {
305+
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
306+
},
307+
"parachainInfo": {
308+
"parachainId": id,
309+
},
310+
"treasury": {},
311+
"evmChainId": {
312+
"chainId": 9999
313+
},
314+
"evm": {
315+
"accounts": accounts
316+
},
317+
"polkadotXcm": {
318+
"safeXcmVersion": Some(SAFE_XCM_VERSION),
319+
},
320+
"sudo": { "key": Some(root) }
321+
})
322+
}

evm-template/node/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ mod cli;
99
mod command;
1010
mod contracts;
1111
mod eth;
12+
13+
#[cfg_attr(feature = "tanssi", path = "tanssi_rpc/mod.rs")]
1214
mod rpc;
1315

1416
fn main() -> sc_cli::Result<()> {

0 commit comments

Comments
 (0)