Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Feature/add rpc frontier layer (#40)
Browse files Browse the repository at this point in the history
* Initial commit

* Clean code

* Crib some basic QA stuff from recipes

* Add parachain info

* Update to Cumulus 96da14c

* Update README.md

Co-authored-by: Dan Forbes <[email protected]>

* Update to Cumulus 35f60b1

* Tailor the README More Specifically to this Project (#5)

* prune incorrect file headers

* Update to Cumulus 4e7f138

* Add Polkadot JS types

* Update to rococo-v1

* Update to CUmulus 4b69b8d

* chore: update to use Rococov1 branch

* fix: template pallet and tests to run

* docs: compile polkadot with real-overseer feat

* fix: update rustc version in gha

* enable ocw (#13)

* fix:match cumulus refactoring (#14)

* fix enable ocw (#15)

* Update Cargo.lock

* Update to Cumulus 28f5ec2 (#18)

* Update to work with latest version of Polkadot and Cumulus

* more clear steps 

more clear steps

* clarify era waiting period

clarify era waiting period

* Fix build

* try again

Co-authored-by: Dan Shields <[email protected]>
Co-authored-by: Ricardo Rius <[email protected]>

* Update template to cumulus@6ed9632 (#21)

* compile to cumulus@6ed9632

* update docs

* fix test

* Update github actions

* Update node/src/command.rs

Co-authored-by: Ricardo Rius <[email protected]>

* Update node/src/command.rs

Co-authored-by: Ricardo Rius <[email protected]>

* Update runtime/src/lib.rs

Co-authored-by: Ricardo Rius <[email protected]>

Co-authored-by: Ricardo Rius <[email protected]>
Co-authored-by: Ricardo Rius <[email protected]>

* Updating versions

* update readme instructions, create stong indication of rococo testnet compatablility

* update readme

* Update README.md

fix minor typo

* Update rococo-v1 -> polkadot-v0.9.3 (#33)

* update cargo.toml files to new use branches, remove explicit versions

* use compact dependency notation, and only single quotes in cargo files

* build deps

* 0.9.2 deps. compact pallet deps. cargo update environmental

* update CLI to cumulus (statemint reference)

* add benchmarking (ref node template & statemint) , deps polish

* update collator service

* update runtime, in progress (not building)

* runtime builds!

* service builds

* progress on service & chainspec

* get commands and service working, aura chainspec

* builds no errors!

* readme updates. Westend in use, but era is too long for testing!

* update to 0.9.3 (#38)

* update to rococo-local relay chain use, readme polish

* readme updates

* readme on chain specs for live networks

* update

* readme updated with output. Working!

Co-authored-by: Sam Elamin <[email protected]>

* add editorconfig & rustfmt.toml,  run `rustfmt && eclint fix` (#42)

* add editorconfig

* rustfmt

* fix missing doc comment lint

* CLI note

* use substrate editorconfig, ran `eclint fix`

* add rustfmt hard tabs

* rustfmt edition

Co-authored-by: Dan Shields <[email protected]>

* Update to polkadot-v.0.9.6 (#46)

* Expect para_id on load_spec for parachain (#48)

* remove polkadot-cli features (#52)

these are not needed for collators.

* Updated to polkadot v0.9.7 (#50)

* updated to v0.9.7

* Further enhancement

- Further enhancement on the README.
- Added a diagram on doing the sudo extrinsic.
- In command.rs removing code that defaulting ParaId to 200 or 2000.

Co-authored-by: Dan Shields <[email protected]>

* rollback expect para_id (#57)

* rollback expect para_id

* Update node/src/command.rs

* Update node/src/command.rs

* Update node/src/command.rs

Co-authored-by: Dan Shields <[email protected]>

* Update to 0.9.8 (#58)

* Add rustfmt, run `cargo +nightly fmt` (#61)

* Update to `polkadot-v0.9.9` (#65)

* update deps, no other modifications

* fix deps

* builds, no warnings

* disable teleporting

* remove relay root origin for XCM (#75)

* Update to `polkadot-v0.9.10` (#73)

* update cargo deps

* update runtime, builds

* cargo +nightly fmt

* spelling

* clear lock file, builds!

* patch minor gripes from issues

* rm extra constant

* Update rust ci

Co-authored-by: Ricardo Rius <[email protected]>

* Fix XCM config

* Update to `polkadot-0.9.11` (#80)

* * replace all source with upstream 0.9.11 tag
* tweaks for use with the template on devhub stand-alone

* remove Cargo.lock, build from scratch

* upstream rustfmt

* .editorconfig update

* update ignores

* pub mod rpc

* node lib.rs rm

* port from upstream cumulus #690

* fmt

* * comments for clarity
* XcmExecuteFilter = Nothing

* tweaks from review

* Fix compilation errors

* Alex review edits

* more tweaks

Co-authored-by: Keith Yeung <[email protected]>

* Update to `polkadot-v0.9.12` (#82)

* Port diff from upstream
* rm various superfluous files, scripts
* DisabledValidatorsThreshold removed
* Remove RandomnessCollectiveFlip
* Remove CLI para_id selection, default 1000

* Update template to `polkadot-v0.9.13`  (#85)

* Port changes from Cumulus template upstream
* Update CI

* update to polkadot-v0.9.15 (#90)

* update to polkadot v0.9.15-1 (#91)

* Direct pull from Cumulus upstream polkadot-v0.9.16 branch (#93)

* Direct pull from Cumulus upstream polkadot-v0.9.16 branch
* bump cargo.lock

* Ds/0.9.16 (#94)

* state version 0

* rm lock and rebuild post Polkadot v0.9.16 release (#96)

* fix runtime-benchmarks compile

* polkadot-v0.9.17  (#101)

* update to polkadot-v0.9.17 deps
* `wasmtime` features enabled

* Update to `polkadot-v0.9.18` (#103)

* RPC for relay chain exposed for colllator paritytech/cumulus#963
* Weights files added for runtime
* SCALE version 3 used
* `scale-info` version 2 used

* Update to upstream polkadot-v0.9.19 (#108)

- xcm configuramtion updates
- tweaks on commands for benchmarks, try-runtime

* update to polkadot-v0.9.20 upstream (#110)

* update to polkadot-v0.9.22 (#111)

* update to include backport in lockfile (#112)

* update to polkadot-v0.9.23 (#113)

* Update to polkadot-v0.9.24 (#115)

* Update to polkadot-v0.9.25 (#121)

* Update to polkadot-v0.9.26 (#122)

* update ci - no fixed nightly , ubuntu-latest

Co-authored-by: Dan Shields <[email protected]>

* Auto-Update node-template from polkadot-v0.9.27 (#123)

Co-authored-by: Dan Shields <[email protected]>

* Auto-Update substrate-parachain-template from polkadot-v0.9.28 (#124)

Co-authored-by: substrate-developer-hub <[email protected]>

* update lock only 0.9.28

* clean lock

* Auto-Update substrate-parachain-template from polkadot-v0.9.29 (#129)

Co-authored-by: substrate-developer-hub <[email protected]>
Co-authored-by: Dan Shields <[email protected]>

* bump lock to get cargo c working (#132)

* Update test-code.yml

* Auto-Update substrate-parachain-template from polkadot-v0.9.30 (#133)

Co-authored-by: substrate-developer-hub <[email protected]>

* Auto-Update substrate-parachain-template from polkadot-v0.9.32 (#138)

* Auto-Update substrate-parachain-template from polkadot-v0.9.32
* upstream PRs 1882 and 1860 included

Co-authored-by: substrate-developer-hub <[email protected]>
Co-authored-by: Dan Shields <[email protected]>

* Auto-Update substrate-parachain-template from polkadot-v0.9.36 (#145)

* Auto-Update substrate-parachain-template from polkadot-v0.9.36

* fix spacing

* fix toml files

Co-authored-by: substrate-developer-hub <[email protected]>
Co-authored-by: Sacha Lansky <[email protected]>

* Auto-Update substrate-parachain-template from polkadot-v0.9.37 (#149)

* create CODEOWNERS (#151)

* Auto-Update substrate-parachain-template from polkadot-v0.9.40 (#153)

Co-authored-by: substrate-developer-hub <[email protected]>

* Fix typo in `.gitignore` (#156)

* Auto-Update substrate-parachain-template from polkadot-v0.9.42 (#158)

Co-authored-by: substrate-developer-hub <[email protected]>

* Release pipeline for multiarch binaries and an image (#159)

* add release ci; add dependabot config; add Containerfile

* fix binary name

* fix user

* add docs

* don't cache the release

* Update README.md

Co-authored-by: Sacha Lansky <[email protected]>

* Update README.md

Co-authored-by: Sacha Lansky <[email protected]>

* Update README.md

Co-authored-by: Sacha Lansky <[email protected]>

---------

Co-authored-by: Sacha Lansky <[email protected]>

* Auto-Update substrate-parachain-template from polkadot-v0.9.43 (#174)

Co-authored-by: substrate-developer-hub <[email protected]>

* integrate evm and ethereum pallets

* runtime api added; wip netapi rpc

* frontier extrinsic missing

* net api

* fixes derived from updating to v0.9.43

* remove unused files

* remove pallet template files

* add rococo relay chain spec as raw

* Working evm rpc

* try fix clippy

* File clippy

* Fix more clippy errors

* remove unnecessary delimiter

* Redundant clone

* Fix compile issue

---------

Co-authored-by: Ricardo Rius <[email protected]>
Co-authored-by: Joshy Orndorff <[email protected]>
Co-authored-by: Ricardo Rius <[email protected]>
Co-authored-by: Dan Forbes <[email protected]>
Co-authored-by: Joshy Orndorff <[email protected]>
Co-authored-by: bwty <[email protected]>
Co-authored-by: junius zhou <[email protected]>
Co-authored-by: stanly-johnson <[email protected]>
Co-authored-by: Black3HDF <[email protected]>
Co-authored-by: John Whitton <[email protected]>
Co-authored-by: Dan Shields <[email protected]>
Co-authored-by: al3mart <[email protected]>
Co-authored-by: Dan Shields <[email protected]>
Co-authored-by: David R <[email protected]>
Co-authored-by: Sam Elamin <[email protected]>
Co-authored-by: Dan Shields <[email protected]>
Co-authored-by: Jimmy Chu <[email protected]>
Co-authored-by: Keith Yeung <[email protected]>
Co-authored-by: Shawn Tabrizi <[email protected]>
Co-authored-by: Bruno Galvao <[email protected]>
Co-authored-by: Paritytech CI <[email protected]>
Co-authored-by: substrate-developer-hub <[email protected]>
Co-authored-by: Sacha Lansky <[email protected]>
Co-authored-by: xrelkd <[email protected]>
Co-authored-by: Denis Pisarev <[email protected]>
Co-authored-by: magecnion <[email protected]>
Co-authored-by: Dastan Samatov <[email protected]>
  • Loading branch information
1 parent 9dc2088 commit ffa9a78
Show file tree
Hide file tree
Showing 14 changed files with 2,555 additions and 688 deletions.
1,889 changes: 1,306 additions & 583 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ build = "build.rs"

[dependencies]
clap = { version = "4.2.7", features = ["derive"] }
futures = "0.3.25"
log = "0.4.17"
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.163", features = ["derive"] }
jsonrpsee = { version = "0.16.2", features = ["server"] }
hex-literal = { version = "0.4.1" }

# Local
parachain-template-runtime = { path = "../runtime" }
Expand Down Expand Up @@ -67,17 +69,37 @@ cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/c
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
color-print = "0.3.4"

# Frontier
fc-cli = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43", features = [ "rpc-binary-search-estimate" ] }
fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43", default-features = false }
fp-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }
fp-dynamic-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.43" }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }

[features]
default = []
runtime-benchmarks = [
"try-runtime-cli/try-runtime",
"parachain-template-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
]
try-runtime = [
"try-runtime-cli/try-runtime",
"parachain-template-runtime/try-runtime"
"parachain-template-runtime/try-runtime",
"polkadot-cli/try-runtime",
"polkadot-service/try-runtime",
"sp-runtime/try-runtime",
]
107 changes: 98 additions & 9 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use cumulus_primitives_core::ParaId;
use parachain_template_runtime::{AccountId, AuraId, Signature, SudoConfig, EXISTENTIAL_DEPOSIT};
use parachain_template_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_core::{sr25519, Pair, Public, H160, U256};
use sp_runtime::traits::{IdentifyAccount, Verify};
use std::{collections::BTreeMap, str::FromStr};

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec =
Expand All @@ -15,7 +16,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
Expand Down Expand Up @@ -101,8 +102,9 @@ pub fn development_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
// Give Alice root privileges
Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
1000.into(),
get_account_id_from_seed::<sr25519::Public>("Alice"),
)
},
Vec::new(),
Expand Down Expand Up @@ -157,8 +159,9 @@ pub fn local_testnet_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
// Give Alice root privileges
Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
1000.into(),
get_account_id_from_seed::<sr25519::Public>("Alice"),
)
},
// Bootnodes
Expand All @@ -182,18 +185,44 @@ pub fn local_testnet_config() -> ChainSpec {
fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
root_key: Option<AccountId>,
id: ParaId,
root_key: AccountId,
) -> parachain_template_runtime::GenesisConfig {
// let alice = get_from_seed::<sr25519::Public>("Alice");
// let bob = get_from_seed::<sr25519::Public>("Bob");

parachain_template_runtime::GenesisConfig {
system: parachain_template_runtime::SystemConfig {
code: parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
// Configure additional assets here
// For example, this configures asset "ALT1" & "ALT2" with owners, alice and bob, respectively
// assets: parachain_template_runtime::AssetsConfig {
// assets: vec![
// (1, alice.into(), true, 10_000_000_0000),
// (2, bob.into(), true, 10_000_000_0000),
// ],
// // Genesis metadata: Vec<(id, name, symbol, decimals)>
// metadata: vec![
// (1, "asset-1".into(), "ALT1".into(), 10),
// (2, "asset-2".into(), "ALT2".into(), 10),
// ],
// // Genesis accounts: Vec<(id, account_id, balance)>
// accounts: vec![(1, alice.into(), 50_000_000_0000), (2, bob.into(), 50_000_000_0000)],
// },
balances: parachain_template_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
},
// council: parachain_template_runtime::CouncilConfig {
// phantom: PhantomData,
// members: endowed_accounts
// .iter()
// .enumerate()
// .filter_map(|(idx, acc)| if idx % 2 == 0 { Some(acc.clone()) } else { None })
// .collect::<Vec<_>>(),
// },
parachain_info: parachain_template_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: parachain_template_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
Expand All @@ -220,10 +249,70 @@ fn testnet_genesis(
polkadot_xcm: parachain_template_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
sudo: parachain_template_runtime::SudoConfig { key: root_key },
transaction_payment: Default::default(),
sudo: SudoConfig {
// Assign network admin rights.
key: Some(root_key),
// EVM compatibility
evm_chain_id: parachain_template_runtime::EVMChainIdConfig { chain_id: 1000 },
evm: parachain_template_runtime::EVMConfig {
accounts: {
let mut map = BTreeMap::new();
map.insert(
// H160 address of Alice dev account
// Derived from SS58 (42 prefix) address
// SS58: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
// hex: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
// Using the full hex key, truncating to the first 20 bytes (the first 40 hex chars)
H160::from_str("d43593c715fdd31c61141abd04a99fd6822c8558")
.expect("internal H160 is valid; qed"),
fp_evm::GenesisAccount {
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);
map.insert(
// H160 address of CI test runner account
H160::from_str("6be02d1d3665660d22ff9624b7be0551ee1ac91b")
.expect("internal H160 is valid; qed"),
fp_evm::GenesisAccount {
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);
map.insert(
// H160 address for benchmark usage
H160::from_str("1000000000000000000000000000000000000001")
.expect("internal H160 is valid; qed"),
fp_evm::GenesisAccount {
nonce: U256::from(1),
balance: U256::from(1_000_000_000_000_000_000_000_000u128),
storage: Default::default(),
code: vec![0x00],
},
);
map.insert(
// H160 address of dev account
// Private key : 0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df
H160::from_str("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")
.expect("internal H160 is valid; qed"),
fp_evm::GenesisAccount {
balance: U256::from_str("0xef000000000000000000000000000")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);
map
},
},
ethereum: Default::default(),
// dynamic_fee: Default::default(),
base_fee: Default::default(),
}
}
21 changes: 8 additions & 13 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::eth::EthConfiguration;
use std::path::PathBuf;

/// Sub-commands supported by the collator.
Expand Down Expand Up @@ -43,27 +44,17 @@ pub enum Subcommand {
/// Errors since the binary was not build with `--features try-runtime`.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,

/// Db meta columns information.
FrontierDb(fc_cli::FrontierDbCmd),
}

const AFTER_HELP_EXAMPLE: &str = color_print::cstr!(
r#"<bold><underline>Examples:</></>
<bold>parachain-template-node build-spec --disable-default-bootnode > plain-parachain-chainspec.json</>
Export a chainspec for a local testnet in json format.
<bold>parachain-template-node --chain plain-parachain-chainspec.json --tmp -- --chain rococo-local</>
Launch a full node with chain specification loaded from plain-parachain-chainspec.json.
<bold>parachain-template-node</>
Launch a full node with default parachain <italic>local-testnet</> and relay chain <italic>rococo-local</>.
<bold>parachain-template-node --collator</>
Launch a collator with default parachain <italic>local-testnet</> and relay chain <italic>rococo-local</>.
"#
);
#[derive(Debug, clap::Parser)]
#[command(
propagate_version = true,
args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true
)]
#[clap(after_help = AFTER_HELP_EXAMPLE)]
pub struct Cli {
#[command(subcommand)]
pub subcommand: Option<Subcommand>,
Expand All @@ -84,6 +75,10 @@ pub struct Cli {
/// Relay chain arguments
#[arg(raw = true)]
pub relay_chain_args: Vec<String>,

// Frontier arguments
#[command(flatten)]
pub eth: EthConfiguration,
}

#[derive(Debug)]
Expand Down
Loading

0 comments on commit ffa9a78

Please sign in to comment.