Skip to content
Snippets Groups Projects
Commit 689b5d00 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'elois-upgrade-substrate' into 'master'

upgrade substrate to monthly-2022-01

See merge request !9
parents b59eacda c98260f5
No related branches found
No related tags found
1 merge request!9upgrade substrate to monthly-2022-01
Showing
with 2430 additions and 2360 deletions
name: Build and Push template
on:
push:
branches:
- master
jobs:
build-push-template:
if: ${{ github.repository == 'substrate-developer-hub/substrate-node-template' }}
runs-on: ubuntu-18.04
steps:
- name: Trigger playground inclusion
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: paritytech/substrate-playground
event-type: template-updated
client-payload: '{"id": "node-template"}'
...@@ -16,15 +16,15 @@ workflow: ...@@ -16,15 +16,15 @@ workflow:
.env: .env:
image: paritytech/ci-linux:production image: paritytech/ci-linux:production
tags: tags:
- elois-tauon - elois-boson
fmt_and_clippy: fmt_and_clippy:
extends: .env extends: .env
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never when: never
- if: $CI_MERGE_REQUEST_ID - if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: on_success - when: manual
stage: quality stage: quality
script: script:
- cargo fmt -- --version - cargo fmt -- --version
...@@ -43,4 +43,5 @@ tests: ...@@ -43,4 +43,5 @@ tests:
- when: manual - when: manual
stage: tests stage: tests
script: script:
- cargo build
- cargo test - cargo test
This diff is collapsed.
[workspace] [workspace]
resolver = "2"
members = [ members = [
'integration-tests',
'node', 'node',
'pallets/certification', 'pallets/certification',
'pallets/identity', 'pallets/identity',
...@@ -9,7 +12,69 @@ members = [ ...@@ -9,7 +12,69 @@ members = [
'runtime/gdev', 'runtime/gdev',
'runtime/gtest' 'runtime/gtest'
] ]
[profile.dev]
opt-level = 3 # The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
# their debug info might be missing) or to require to be frequently recompiled. We compile these
# dependencies with `opt-level=3` even in "dev" mode in order to make "dev" mode more usable.
# The majority of these crates are cryptographic libraries.
#
# This list is only relevant when running `cargo build` from within
# the Duniter-v2s workspace.
#
# If you see an error mentioning "profile package spec ... did not match any packages", it
# probably concerns this list.
#
# This list is ordered alphabetically.
[profile.dev.package]
blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
cranelift-wasm = { opt-level = 3 }
crc32fast = { opt-level = 3 }
crossbeam-deque = { opt-level = 3 }
crypto-mac = { opt-level = 3 }
curve25519-dalek = { opt-level = 3 }
ed25519-dalek = { opt-level = 3 }
flate2 = { opt-level = 3 }
futures-channel = { opt-level = 3 }
hashbrown = { opt-level = 3 }
hash-db = { opt-level = 3 }
hmac = { opt-level = 3 }
httparse = { opt-level = 3 }
integer-sqrt = { opt-level = 3 }
keccak = { opt-level = 3 }
libm = { opt-level = 3 }
librocksdb-sys = { opt-level = 3 }
libsecp256k1 = { opt-level = 3 }
libz-sys = { opt-level = 3 }
mio = { opt-level = 3 }
nalgebra = { opt-level = 3 }
num-bigint = { opt-level = 3 }
parking_lot = { opt-level = 3 }
parking_lot_core = { opt-level = 3 }
percent-encoding = { opt-level = 3 }
primitive-types = { opt-level = 3 }
ring = { opt-level = 3 }
rustls = { opt-level = 3 }
sha2 = { opt-level = 3 }
sha3 = { opt-level = 3 }
smallvec = { opt-level = 3 }
snow = { opt-level = 3 }
twox-hash = { opt-level = 3 }
uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
x25519-dalek = { opt-level = 3 }
yamux = { opt-level = 3 }
zeroize = { opt-level = 3 }
[profile.release] [profile.release]
panic = 'unwind' # Substrate runtime requires unwinding.
panic = "unwind"
[patch.crates-io]
# rw-stream-sink has not been updated for 2 years and uses a too old version of pin-project (v0.4.28)
# For the project to compile, we have to patch this dependency to force the use of pin-project v1.x
rw-stream-sink = { git = "https://github.com/librelois/rw-stream-sink", branch = "master" }
[package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>']
description = 'lc-core integration tests.'
edition = '2018'
homepage = 'https://substrate.dev'
license = 'AGPL-3.0'
name = 'lc-core-integration-tests'
repository = 'https://git.duniter.org/nodes/rust/lc-core-substrate'
version = '3.0.0'
[dev-dependencies]
env_logger = "0.9.0"
parity-scale-codec = "2.3.1"
portpicker = "0.1.1"
serde_json = "1.0.64"
subxt = { git = 'https://github.com/librelois/subxt.git', branch = 'duniter-monthly-2022-01' }
tokio = { version = "1.15.0", features = ["macros"] }
# substrate dev-dependencies
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-01" }
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
use crate::common::*;
use sp_keyring::AccountKeyring;
use subxt::PairSigner;
#[tokio::test]
async fn test_balance_transfer() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
// Spawn a node
let (api, client, _process) = spawn_node().await;
let alice = PairSigner::new(AccountKeyring::Alice.pair());
let dave = AccountKeyring::Dave.to_account_id();
let events = create_block_with_extrinsic(
&client,
api.tx()
.balances()
.transfer(dave.clone().into(), 512)
.create_signed(&alice, ())
.await?,
)
.await?;
println!(
"Balance transfer extrinsic written in blockchain, events: {:?}",
events
);
// verify that Bob's free Balance increased
let dave_post = api.storage().system().account(dave, None).await?;
println!("Bob's Free Balance is now {}\n", dave_post.data.free);
assert_eq!(dave_post.data.free, 512);
Ok(())
}
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
#[subxt::subxt(runtime_metadata_path = "../resources/metadata.scale")]
pub mod node_runtime {}
use serde_json::Value;
use std::process::Command;
use subxt::{ClientBuilder, DefaultConfig, DefaultExtra};
pub type Api = node_runtime::RuntimeApi<DefaultConfig, DefaultExtra<DefaultConfig>>;
pub type Client = subxt::Client<DefaultConfig>;
pub struct Process(std::process::Child);
impl Drop for Process {
fn drop(&mut self) {
self.0.kill().expect("node already down");
}
}
pub async fn spawn_node() -> (Api, Client, Process) {
let p2p_port = portpicker::pick_unused_port().expect("No ports free");
let rpc_port = portpicker::pick_unused_port().expect("No ports free");
let ws_port = portpicker::pick_unused_port().expect("No ports free");
let process = Process(
Command::new("../target/debug/lc-core")
.args([
"--execution=Native",
"--no-telemetry",
"--no-prometheus",
"--dev",
"--sealing=manual",
"--tmp",
"--port",
&p2p_port.to_string(),
"--rpc-port",
&rpc_port.to_string(),
"--ws-port",
&ws_port.to_string(),
])
.spawn()
.expect("failed to spawn node"),
);
std::thread::sleep(std::time::Duration::from_secs(4));
let client = ClientBuilder::new()
.set_url(format!("ws://127.0.0.1:{}", ws_port))
.build()
.await
.expect("fail to connect to node");
let api = client.clone().to_runtime_api::<Api>();
(api, client, process)
}
pub async fn create_block_with_extrinsic(
client: &Client,
extrinsic: subxt::UncheckedExtrinsic<DefaultConfig, DefaultExtra<DefaultConfig>>,
) -> Result<subxt::TransactionEvents<DefaultConfig>, subxt::Error> {
// Get a hash of the extrinsic (we'll need this later).
use subxt::sp_runtime::traits::Hash as _;
let ext_hash = <DefaultConfig as subxt::Config>::Hashing::hash_of(&extrinsic);
// Submit and watch for transaction progress.
let sub = client.rpc().watch_extrinsic(extrinsic).await?;
let watcher = subxt::TransactionProgress::new(sub, client, ext_hash);
// Create a non-empty block
let _: Value = client
.rpc()
.client
.request(
"engine_createBlock",
&[Value::Bool(false), Value::Bool(false), Value::Null],
)
.await?;
// Get extrinsic events
watcher.wait_for_in_block().await?.fetch_events().await
}
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
#[cfg(test)]
mod balance_transfer;
#[cfg(test)]
pub mod common;
[features]
runtime-benchmarks = ['gdev-runtime/runtime-benchmarks']
[build-dependencies.substrate-build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
[package] [package]
authors = ['Axiom-Team Developers <https://axiom-team.fr>'] authors = ['Axiom-Team Developers <https://axiom-team.fr>']
build = 'build.rs' build = 'build.rs'
...@@ -19,172 +12,185 @@ version = '3.0.0' ...@@ -19,172 +12,185 @@ version = '3.0.0'
[package.metadata.docs.rs] [package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu'] targets = ['x86_64-unknown-linux-gnu']
[[bin]]
name = 'lc-core'
[features]
runtime-benchmarks = ['gdev-runtime/runtime-benchmarks']
[build-dependencies]
substrate-build-script-utils = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-01' }
# substrate dev-dependencies
sp-keyring = { git = "https://github.com/librelois/substrate.git", branch = "duniter-monthly-2022-01" }
[dependencies] [dependencies]
async-io = "1.3"
futures = { version = "0.3.1", features = ["compat"] } # local dependencies
jsonrpc-core = '15.1.0'
log = "0.4"
maplit = '1.0.2'
common-runtime = { path = '../runtime/common' } common-runtime = { path = '../runtime/common' }
g1-runtime = { path = '../runtime/g1' } g1-runtime = { path = '../runtime/g1' }
gdev-runtime = { path = '../runtime/gdev' } gdev-runtime = { path = '../runtime/gdev' }
gtest-runtime = { path = '../runtime/gtest' } gtest-runtime = { path = '../runtime/gtest' }
# crates.io dependencies
async-io = "1.3"
futures = { version = "0.3.1", features = ["compat"] }
jsonrpc-core = '18.0.0'
log = "0.4"
maplit = '1.0.2'
serde_json = "1.0.64"
structopt = '0.3.8' structopt = '0.3.8'
# substrate dependencies
[dependencies.frame-benchmarking] [dependencies.frame-benchmarking]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.frame-benchmarking-cli] [dependencies.frame-benchmarking-cli]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-grandpa] [dependencies.pallet-grandpa]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-transaction-payment-rpc] [dependencies.pallet-transaction-payment-rpc]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-transaction-payment-rpc-runtime-api] [dependencies.pallet-transaction-payment-rpc-runtime-api]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-basic-authorship] [dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-chain-spec] [dependencies.sc-chain-spec]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-cli] [dependencies.sc-cli]
features = ['wasmtime'] features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-client-api] [dependencies.sc-client-api]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus] [dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus-aura] [dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus-manual-seal] [dependencies.sc-consensus-manual-seal]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-executor] [dependencies.sc-executor]
features = ['wasmtime'] features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-finality-grandpa] [dependencies.sc-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-keystore] [dependencies.sc-keystore]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-rpc] [dependencies.sc-rpc]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-rpc-api] [dependencies.sc-rpc-api]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-service] [dependencies.sc-service]
features = ['wasmtime'] features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-telemetry] [dependencies.sc-telemetry]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-transaction-pool] [dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sc-transaction-pool-api] [dependencies.sc-transaction-pool-api]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.serde_json]
version = '1.0.64'
[dependencies.sp-api] [dependencies.sp-api]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-block-builder] [dependencies.sp-block-builder]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-blockchain] [dependencies.sp-blockchain]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-consensus] [dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-consensus-aura] [dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-core] [dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-finality-grandpa] [dependencies.sp-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-offchain] [dependencies.sp-offchain]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-inherents] [dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-runtime] [dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-session] [dependencies.sp-session]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-storage] [dependencies.sp-storage]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-timestamp] [dependencies.sp-timestamp]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-transaction-pool] [dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-trie] [dependencies.sp-trie]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.substrate-frame-rpc-system] [dependencies.substrate-frame-rpc-system]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[[bin]]
name = 'lc-core'
...@@ -98,10 +98,13 @@ fn devnet_genesis( ...@@ -98,10 +98,13 @@ fn devnet_genesis(
system: SystemConfig { system: SystemConfig {
// Add Wasm runtime to storage. // Add Wasm runtime to storage.
code: wasm_binary.to_vec(), code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}, },
balances: BalancesConfig { balances: BalancesConfig {
balances: Vec::with_capacity(0), balances: initial_identities
.values()
.cloned()
.map(|account_id| (account_id, 1_000))
.collect(),
}, },
grandpa: GrandpaConfig { grandpa: GrandpaConfig {
authorities: initial_authorities authorities: initial_authorities
...@@ -111,7 +114,7 @@ fn devnet_genesis( ...@@ -111,7 +114,7 @@ fn devnet_genesis(
}, },
sudo: SudoConfig { sudo: SudoConfig {
// Assign network admin rights. // Assign network admin rights.
key: root_key, key: Some(root_key),
}, },
identity: IdentityConfig { identity: IdentityConfig {
identities: initial_identities identities: initial_identities
...@@ -141,7 +144,7 @@ fn devnet_genesis( ...@@ -141,7 +144,7 @@ fn devnet_genesis(
}, },
universal_dividend: UniversalDividendConfig { universal_dividend: UniversalDividendConfig {
first_ud: 1_000, first_ud: 1_000,
initial_monetary_mass: 0, initial_monetary_mass: initial_identities.len() as u64 * 1_000,
}, },
} }
} }
...@@ -148,7 +148,6 @@ fn devnet_genesis( ...@@ -148,7 +148,6 @@ fn devnet_genesis(
system: SystemConfig { system: SystemConfig {
// Add Wasm runtime to storage. // Add Wasm runtime to storage.
code: wasm_binary.to_vec(), code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}, },
balances: BalancesConfig { balances: BalancesConfig {
// Configure endowed accounts with initial balance of INITIAL_BALANCE. // Configure endowed accounts with initial balance of INITIAL_BALANCE.
...@@ -165,7 +164,7 @@ fn devnet_genesis( ...@@ -165,7 +164,7 @@ fn devnet_genesis(
}, },
sudo: SudoConfig { sudo: SudoConfig {
// Assign network admin rights. // Assign network admin rights.
key: root_key, key: Some(root_key),
}, },
identity: IdentityConfig { identity: IdentityConfig {
identities: initial_identities identities: initial_identities
...@@ -211,7 +210,6 @@ fn testnet_genesis( ...@@ -211,7 +210,6 @@ fn testnet_genesis(
system: SystemConfig { system: SystemConfig {
// Add Wasm runtime to storage. // Add Wasm runtime to storage.
code: wasm_binary.to_vec(), code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}, },
balances: BalancesConfig { balances: BalancesConfig {
// Configure endowed accounts with initial balance of INITIAL_BALANCE. // Configure endowed accounts with initial balance of INITIAL_BALANCE.
...@@ -228,7 +226,7 @@ fn testnet_genesis( ...@@ -228,7 +226,7 @@ fn testnet_genesis(
}, },
sudo: SudoConfig { sudo: SudoConfig {
// Assign network admin rights. // Assign network admin rights.
key: root_key, key: Some(root_key),
}, },
identity: IdentityConfig { identity: IdentityConfig {
identities: initial_identities identities: initial_identities
......
...@@ -82,8 +82,9 @@ impl FromStr for Sealing { ...@@ -82,8 +82,9 @@ impl FromStr for Sealing {
"instant" => Self::Instant, "instant" => Self::Instant,
"manual" => Self::Manual, "manual" => Self::Manual,
s => { s => {
let millis = let millis = s
u64::from_str_radix(s, 10).map_err(|_| "couldn't decode sealing param")?; .parse::<u64>()
.map_err(|_| "couldn't decode sealing param")?;
Self::Interval(millis) Self::Interval(millis)
} }
}) })
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
// limitations under the License. // limitations under the License.
use crate::cli::{Cli, Subcommand}; use crate::cli::{Cli, Subcommand};
use crate::service::{GDevExecutor, GTestExecutor, IdentifyVariant}; use crate::service::{G1Executor, GDevExecutor, GTestExecutor, IdentifyVariant};
use crate::{chain_spec, service}; use crate::{chain_spec, service};
use gdev_runtime::Block; use gdev_runtime::Block;
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli}; use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
impl SubstrateCli for Cli { impl SubstrateCli for Cli {
fn impl_name() -> String { fn impl_name() -> String {
...@@ -168,7 +168,7 @@ pub fn run() -> sc_cli::Result<()> { ...@@ -168,7 +168,7 @@ pub fn run() -> sc_cli::Result<()> {
let chain_spec = &runner.config().chain_spec; let chain_spec = &runner.config().chain_spec;
if chain_spec.is_main() { if chain_spec.is_main() {
todo!() runner.sync_run(|config| cmd.run::<Block, G1Executor>(config))
} else if chain_spec.is_test() { } else if chain_spec.is_test() {
runner.sync_run(|config| cmd.run::<Block, GTestExecutor>(config)) runner.sync_run(|config| cmd.run::<Block, GTestExecutor>(config))
} else if chain_spec.is_dev() { } else if chain_spec.is_dev() {
...@@ -186,16 +186,10 @@ pub fn run() -> sc_cli::Result<()> { ...@@ -186,16 +186,10 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(&cli.run)?; let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move { runner.run_node_until_exit(|config| async move {
if config.chain_spec.is_main() { if config.chain_spec.is_main() {
todo!() service::new_full::<gtest_runtime::RuntimeApi, G1Executor>(config, None)
.map_err(sc_cli::Error::Service)
} else if config.chain_spec.is_test() { } else if config.chain_spec.is_test() {
match config.role { service::new_full::<gtest_runtime::RuntimeApi, GTestExecutor>(config, None)
Role::Light => {
service::new_light::<gtest_runtime::RuntimeApi, GTestExecutor>(config)
}
_ => service::new_full::<gtest_runtime::RuntimeApi, GTestExecutor>(
config, None,
),
}
.map_err(sc_cli::Error::Service) .map_err(sc_cli::Error::Service)
} else if config.chain_spec.is_dev() { } else if config.chain_spec.is_dev() {
service::new_full::<gdev_runtime::RuntimeApi, GDevExecutor>( service::new_full::<gdev_runtime::RuntimeApi, GDevExecutor>(
......
...@@ -47,7 +47,9 @@ pub struct FullDeps<C, P> { ...@@ -47,7 +47,9 @@ pub struct FullDeps<C, P> {
} }
/// Instantiate all full RPC extensions. /// Instantiate all full RPC extensions.
pub fn create_full<C, P>(deps: FullDeps<C, P>) -> jsonrpc_core::IoHandler<sc_rpc::Metadata> pub fn create_full<C, P>(
deps: FullDeps<C, P>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc_api::Metadata>, Box<dyn std::error::Error + Send + Sync>>
where where
C: ProvideRuntimeApi<Block>, C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static, C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
...@@ -91,5 +93,5 @@ where ...@@ -91,5 +93,5 @@ where
// to call into the runtime. // to call into the runtime.
// `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));` // `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));`
io Ok(io)
} }
...@@ -18,16 +18,14 @@ ...@@ -18,16 +18,14 @@
mod client; mod client;
pub use sc_executor::NativeExecutor;
use self::client::{Client, RuntimeApiCollection}; use self::client::{Client, RuntimeApiCollection};
use async_io::Timer; use async_io::Timer;
use common_runtime::Block; use common_runtime::Block;
use futures::{Stream, StreamExt}; use futures::{Stream, StreamExt};
use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_client_api::ExecutorProvider;
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams}; use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};
use sc_executor::native_executor_instance; pub use sc_executor::NativeElseWasmExecutor;
use sc_finality_grandpa::SharedVoterState; use sc_finality_grandpa::SharedVoterState;
use sc_keystore::LocalKeystore; use sc_keystore::LocalKeystore;
use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager};
...@@ -38,27 +36,64 @@ use sp_core::H256; ...@@ -38,27 +36,64 @@ use sp_core::H256;
use sp_runtime::traits::BlakeTwo256; use sp_runtime::traits::BlakeTwo256;
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
type FullClient<RuntimeApi, Executor> = sc_service::TFullClient<Block, RuntimeApi, Executor>; type FullClient<RuntimeApi, Executor> =
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>;
type FullBackend = sc_service::TFullBackend<Block>; type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>; type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type LightClient<RuntimeApi, Executor> = pub struct GDevExecutor;
sc_service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>; impl sc_executor::NativeExecutionDispatch for GDevExecutor {
type LightBackend = sc_service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>; /// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
/// Otherwise we only use the default Substrate host functions.
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
gdev_runtime::api::dispatch(method, data)
}
native_executor_instance!( fn native_version() -> sc_executor::NativeVersion {
pub GDevExecutor, gdev_runtime::native_version()
gdev_runtime::api::dispatch, }
gdev_runtime::native_version, }
frame_benchmarking::benchmarking::HostFunctions,
);
native_executor_instance!( pub struct GTestExecutor;
pub GTestExecutor, impl sc_executor::NativeExecutionDispatch for GTestExecutor {
gtest_runtime::api::dispatch, /// Only enable the benchmarking host functions when we actually want to benchmark.
gtest_runtime::native_version, #[cfg(feature = "runtime-benchmarks")]
frame_benchmarking::benchmarking::HostFunctions, type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
); /// Otherwise we only use the default Substrate host functions.
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
gtest_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
gtest_runtime::native_version()
}
}
pub struct G1Executor;
impl sc_executor::NativeExecutionDispatch for G1Executor {
/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
/// Otherwise we only use the default Substrate host functions.
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
g1_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
g1_runtime::native_version()
}
}
/// Can be called for a `Configuration` to check if it is a configuration for /// Can be called for a `Configuration` to check if it is a configuration for
/// a particular network. /// a particular network.
...@@ -101,7 +136,19 @@ pub fn new_chain_ops( ...@@ -101,7 +136,19 @@ pub fn new_chain_ops(
ServiceError, ServiceError,
> { > {
if config.chain_spec.is_main() { if config.chain_spec.is_main() {
todo!() let PartialComponents {
client,
backend,
import_queue,
task_manager,
..
} = new_partial::<g1_runtime::RuntimeApi, G1Executor>(config, false)?;
Ok((
Arc::new(Client::G1(client)),
backend,
import_queue,
task_manager,
))
} else if config.chain_spec.is_test() { } else if config.chain_spec.is_test() {
let PartialComponents { let PartialComponents {
client, client,
...@@ -185,15 +232,25 @@ where ...@@ -185,15 +232,25 @@ where
}) })
.transpose()?; .transpose()?;
let executor = NativeElseWasmExecutor::<Executor>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
config.runtime_cache_size,
);
let (client, backend, keystore_container, task_manager) = let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>( sc_service::new_full_parts::<Block, RuntimeApi, _>(
&config, config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
)?; )?;
let client = Arc::new(client); let client = Arc::new(client);
let telemetry = telemetry.map(|(worker, telemetry)| { let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run()); task_manager
.spawn_handle()
.spawn("telemetry", None, worker.run());
telemetry telemetry
}); });
...@@ -307,6 +364,11 @@ where ...@@ -307,6 +364,11 @@ where
.network .network
.extra_sets .extra_sets
.push(sc_finality_grandpa::grandpa_peers_set_config()); .push(sc_finality_grandpa::grandpa_peers_set_config());
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Vec::default(),
));
let (network, system_rpc_tx, network_starter) = let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams { sc_service::build_network(sc_service::BuildNetworkParams {
...@@ -315,8 +377,8 @@ where ...@@ -315,8 +377,8 @@ where
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue, import_queue,
on_demand: None,
block_announce_validator_builder: None, block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?; })?;
if config.offchain_worker.enabled { if config.offchain_worker.enabled {
...@@ -382,6 +444,7 @@ where ...@@ -382,6 +444,7 @@ where
task_manager.spawn_essential_handle().spawn_blocking( task_manager.spawn_essential_handle().spawn_blocking(
"authorship_task", "authorship_task",
Some("block-authoring"),
run_manual_seal(ManualSealParams { run_manual_seal(ManualSealParams {
block_import, block_import,
env: proposer_factory, env: proposer_factory,
...@@ -431,9 +494,11 @@ where ...@@ -431,9 +494,11 @@ where
// the AURA authoring task is considered essential, i.e. if it // the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it. // fails we take down the service with it.
task_manager task_manager.spawn_essential_handle().spawn_blocking(
.spawn_essential_handle() "aura",
.spawn_blocking("aura", aura); Some("block-authoring"),
aura,
);
} }
} }
...@@ -449,7 +514,7 @@ where ...@@ -449,7 +514,7 @@ where
command_sink_opt: command_sink_opt.clone(), command_sink_opt: command_sink_opt.clone(),
}; };
crate::rpc::create_full(deps) crate::rpc::create_full(deps).map_err(Into::into)
}) })
}; };
...@@ -460,8 +525,6 @@ where ...@@ -460,8 +525,6 @@ where
task_manager: &mut task_manager, task_manager: &mut task_manager,
transaction_pool, transaction_pool,
rpc_extensions_builder, rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend, backend,
system_rpc_tx, system_rpc_tx,
config, config,
...@@ -508,6 +571,7 @@ where ...@@ -508,6 +571,7 @@ where
// if it fails we take down the service with it. // if it fails we take down the service with it.
task_manager.spawn_essential_handle().spawn_blocking( task_manager.spawn_essential_handle().spawn_blocking(
"grandpa-voter", "grandpa-voter",
None,
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?, sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
); );
} }
...@@ -515,144 +579,3 @@ where ...@@ -515,144 +579,3 @@ where
network_starter.start_network(); network_starter.start_network();
Ok(task_manager) Ok(task_manager)
} }
/// Builds a new service for a light client.
pub fn new_light<RuntimeApi, Executor>(
mut config: Configuration,
) -> Result<TaskManager, ServiceError>
where
RuntimeApi: sp_api::ConstructRuntimeApi<Block, LightClient<RuntimeApi, Executor>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<LightBackend, Block>>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
{
let telemetry = config
.telemetry_endpoints
.clone()
.filter(|x| !x.is_empty())
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
let worker = TelemetryWorker::new(16)?;
let telemetry = worker.handle().new_telemetry(endpoints);
Ok((worker, telemetry))
})
.transpose()?;
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(
&config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let mut telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
telemetry
});
config
.network
.extra_sets
.push(sc_finality_grandpa::grandpa_peers_set_config());
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
config.prometheus_registry(),
task_manager.spawn_essential_handle(),
client.clone(),
on_demand.clone(),
));
let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
select_chain,
telemetry.as_ref().map(|x| x.handle()),
)?;
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let import_queue =
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import)),
client: client.clone(),
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
slot_duration,
);
Ok((timestamp, slot))
},
spawner: &task_manager.spawn_essential_handle(),
can_author_with: sp_consensus::NeverCanAuthor,
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
})?;
let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
})?;
if config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&config,
task_manager.spawn_handle(),
client.clone(),
network.clone(),
);
}
let enable_grandpa = !config.disable_grandpa;
if enable_grandpa {
let name = config.network.node_name.clone();
let config = sc_finality_grandpa::Config {
gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512,
name: Some(name),
observer_enabled: false,
keystore: None,
local_role: config.role.clone(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
};
task_manager.spawn_handle().spawn_blocking(
"grandpa-observer",
sc_finality_grandpa::run_grandpa_observer(config, grandpa_link, network.clone())?,
);
}
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
remote_blockchain: Some(backend.remote_blockchain()),
transaction_pool,
task_manager: &mut task_manager,
on_demand: Some(on_demand),
rpc_extensions_builder: Box::new(|_, _| ()),
config,
client,
keystore: keystore_container.sync_keystore(),
backend,
network,
system_rpc_tx,
telemetry: telemetry.as_mut(),
})?;
network_starter.start_network();
Ok(task_manager)
}
...@@ -23,23 +23,50 @@ use sp_runtime::{ ...@@ -23,23 +23,50 @@ use sp_runtime::{
traits::{BlakeTwo256, Block as BlockT}, traits::{BlakeTwo256, Block as BlockT},
Justifications, Justifications,
}; };
use sp_storage::{ChildInfo, PrefixedStorageKey, StorageData, StorageKey}; use sp_storage::{ChildInfo, StorageData, StorageKey};
use std::sync::Arc; use std::sync::Arc;
/// A client instance. /// A client instance.
#[derive(Clone)] #[derive(Clone)]
pub enum Client { pub enum Client {
//G1(Arc<super::FullClient<g1_runtime::RuntimeApi, super::G1Executor>>), G1(Arc<super::FullClient<g1_runtime::RuntimeApi, super::G1Executor>>),
GTest(Arc<super::FullClient<gtest_runtime::RuntimeApi, super::GTestExecutor>>), GTest(Arc<super::FullClient<gtest_runtime::RuntimeApi, super::GTestExecutor>>),
GDev(Arc<super::FullClient<gdev_runtime::RuntimeApi, super::GDevExecutor>>), GDev(Arc<super::FullClient<gdev_runtime::RuntimeApi, super::GDevExecutor>>),
} }
impl From<Arc<super::FullClient<g1_runtime::RuntimeApi, super::G1Executor>>> for Client {
fn from(client: Arc<super::FullClient<g1_runtime::RuntimeApi, super::G1Executor>>) -> Self {
Self::G1(client)
}
}
impl From<Arc<super::FullClient<gtest_runtime::RuntimeApi, super::GTestExecutor>>> for Client {
fn from(
client: Arc<super::FullClient<gtest_runtime::RuntimeApi, super::GTestExecutor>>,
) -> Self {
Self::GTest(client)
}
}
impl From<Arc<super::FullClient<gdev_runtime::RuntimeApi, super::GDevExecutor>>> for Client {
fn from(client: Arc<super::FullClient<gdev_runtime::RuntimeApi, super::GDevExecutor>>) -> Self {
Self::GDev(client)
}
}
macro_rules! match_client {
($self:ident, $method:ident($($param:ident),*)) => {
match $self {
Self::G1(client) => client.$method($($param),*),
Self::GTest(client) => client.$method($($param),*),
Self::GDev(client) => client.$method($($param),*),
}
};
}
impl sc_client_api::UsageProvider<Block> for Client { impl sc_client_api::UsageProvider<Block> for Client {
fn usage_info(&self) -> sc_client_api::ClientInfo<Block> { fn usage_info(&self) -> sc_client_api::ClientInfo<Block> {
match self { match_client!(self, usage_info())
Self::GTest(client) => client.usage_info(),
Self::GDev(client) => client.usage_info(),
}
} }
} }
...@@ -48,71 +75,47 @@ impl sc_client_api::BlockBackend<Block> for Client { ...@@ -48,71 +75,47 @@ impl sc_client_api::BlockBackend<Block> for Client {
&self, &self,
id: &BlockId<Block>, id: &BlockId<Block>,
) -> sp_blockchain::Result<Option<Vec<<Block as BlockT>::Extrinsic>>> { ) -> sp_blockchain::Result<Option<Vec<<Block as BlockT>::Extrinsic>>> {
match self { match_client!(self, block_body(id))
Self::GTest(client) => client.block_body(id),
Self::GDev(client) => client.block_body(id),
}
} }
fn block_indexed_body( fn block_indexed_body(
&self, &self,
id: &BlockId<Block>, id: &BlockId<Block>,
) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> { ) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> {
match self { match_client!(self, block_indexed_body(id))
Self::GTest(client) => client.block_indexed_body(id),
Self::GDev(client) => client.block_indexed_body(id),
}
} }
fn block(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<SignedBlock<Block>>> { fn block(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<SignedBlock<Block>>> {
match self { match_client!(self, block(id))
Self::GTest(client) => client.block(id),
Self::GDev(client) => client.block(id),
}
} }
fn block_status(&self, id: &BlockId<Block>) -> sp_blockchain::Result<BlockStatus> { fn block_status(&self, id: &BlockId<Block>) -> sp_blockchain::Result<BlockStatus> {
match self { match_client!(self, block_status(id))
Self::GTest(client) => client.block_status(id),
Self::GDev(client) => client.block_status(id),
}
} }
fn justifications(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<Justifications>> { fn justifications(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<Justifications>> {
match self { match_client!(self, justifications(id))
Self::GTest(client) => client.justifications(id),
Self::GDev(client) => client.justifications(id),
}
} }
fn block_hash( fn block_hash(
&self, &self,
number: NumberFor<Block>, number: NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> { ) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self { match_client!(self, block_hash(number))
Self::GTest(client) => client.block_hash(number),
Self::GDev(client) => client.block_hash(number),
}
} }
fn indexed_transaction( fn indexed_transaction(
&self, &self,
hash: &<Block as BlockT>::Hash, hash: &<Block as BlockT>::Hash,
) -> sp_blockchain::Result<Option<Vec<u8>>> { ) -> sp_blockchain::Result<Option<Vec<u8>>> {
match self { match_client!(self, indexed_transaction(hash))
Self::GTest(client) => client.indexed_transaction(hash),
Self::GDev(client) => client.indexed_transaction(hash),
}
} }
fn has_indexed_transaction( fn has_indexed_transaction(
&self, &self,
hash: &<Block as BlockT>::Hash, hash: &<Block as BlockT>::Hash,
) -> sp_blockchain::Result<bool> { ) -> sp_blockchain::Result<bool> {
match self { match_client!(self, has_indexed_transaction(hash))
Self::GTest(client) => client.has_indexed_transaction(hash),
Self::GDev(client) => client.has_indexed_transaction(hash),
}
} }
} }
...@@ -122,10 +125,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -122,10 +125,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>, id: &BlockId<Block>,
key: &StorageKey, key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> { ) -> sp_blockchain::Result<Option<StorageData>> {
match self { match_client!(self, storage(id, key))
Self::GTest(client) => client.storage(id, key),
Self::GDev(client) => client.storage(id, key),
}
} }
fn storage_keys( fn storage_keys(
...@@ -133,10 +133,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -133,10 +133,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>, id: &BlockId<Block>,
key_prefix: &StorageKey, key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> { ) -> sp_blockchain::Result<Vec<StorageKey>> {
match self { match_client!(self, storage_keys(id, key_prefix))
Self::GTest(client) => client.storage_keys(id, key_prefix),
Self::GDev(client) => client.storage_keys(id, key_prefix),
}
} }
fn storage_hash( fn storage_hash(
...@@ -144,10 +141,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -144,10 +141,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>, id: &BlockId<Block>,
key: &StorageKey, key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> { ) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self { match_client!(self, storage_hash(id, key))
Self::GTest(client) => client.storage_hash(id, key),
Self::GDev(client) => client.storage_hash(id, key),
}
} }
fn storage_pairs( fn storage_pairs(
...@@ -155,10 +149,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -155,10 +149,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>, id: &BlockId<Block>,
key_prefix: &StorageKey, key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<(StorageKey, StorageData)>> { ) -> sp_blockchain::Result<Vec<(StorageKey, StorageData)>> {
match self { match_client!(self, storage_pairs(id, key_prefix))
Self::GTest(client) => client.storage_pairs(id, key_prefix),
Self::GDev(client) => client.storage_pairs(id, key_prefix),
}
} }
fn storage_keys_iter<'a>( fn storage_keys_iter<'a>(
...@@ -169,10 +160,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -169,10 +160,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
) -> sp_blockchain::Result< ) -> sp_blockchain::Result<
KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>, KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>,
> { > {
match self { match_client!(self, storage_keys_iter(id, prefix, start_key))
Self::GTest(client) => client.storage_keys_iter(id, prefix, start_key),
Self::GDev(client) => client.storage_keys_iter(id, prefix, start_key),
}
} }
fn child_storage( fn child_storage(
...@@ -181,10 +169,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -181,10 +169,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo, child_info: &ChildInfo,
key: &StorageKey, key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> { ) -> sp_blockchain::Result<Option<StorageData>> {
match self { match_client!(self, child_storage(id, child_info, key))
Self::GTest(client) => client.child_storage(id, child_info, key),
Self::GDev(client) => client.child_storage(id, child_info, key),
}
} }
fn child_storage_keys( fn child_storage_keys(
...@@ -193,10 +178,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -193,10 +178,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo, child_info: &ChildInfo,
key_prefix: &StorageKey, key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> { ) -> sp_blockchain::Result<Vec<StorageKey>> {
match self { match_client!(self, child_storage_keys(id, child_info, key_prefix))
Self::GTest(client) => client.child_storage_keys(id, child_info, key_prefix),
Self::GDev(client) => client.child_storage_keys(id, child_info, key_prefix),
}
} }
fn child_storage_keys_iter<'a>( fn child_storage_keys_iter<'a>(
...@@ -208,12 +190,10 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -208,12 +190,10 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
) -> sp_blockchain::Result< ) -> sp_blockchain::Result<
KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>, KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>,
> { > {
match self { match_client!(
Self::GTest(client) => { self,
client.child_storage_keys_iter(id, child_info, prefix, start_key) child_storage_keys_iter(id, child_info, prefix, start_key)
} )
Self::GDev(client) => client.child_storage_keys_iter(id, child_info, prefix, start_key),
}
} }
fn child_storage_hash( fn child_storage_hash(
...@@ -222,70 +202,29 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client { ...@@ -222,70 +202,29 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo, child_info: &ChildInfo,
key: &StorageKey, key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> { ) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self { match_client!(self, child_storage_hash(id, child_info, key))
Self::GTest(client) => client.child_storage_hash(id, child_info, key),
Self::GDev(client) => client.child_storage_hash(id, child_info, key),
}
}
fn max_key_changes_range(
&self,
first: NumberFor<Block>,
last: BlockId<Block>,
) -> sp_blockchain::Result<Option<(NumberFor<Block>, BlockId<Block>)>> {
match self {
Self::GTest(client) => client.max_key_changes_range(first, last),
Self::GDev(client) => client.max_key_changes_range(first, last),
}
}
fn key_changes(
&self,
first: NumberFor<Block>,
last: BlockId<Block>,
storage_key: Option<&PrefixedStorageKey>,
key: &StorageKey,
) -> sp_blockchain::Result<Vec<(NumberFor<Block>, u32)>> {
match self {
Self::GTest(client) => client.key_changes(first, last, storage_key, key),
Self::GDev(client) => client.key_changes(first, last, storage_key, key),
}
} }
} }
impl sp_blockchain::HeaderBackend<Block> for Client { impl sp_blockchain::HeaderBackend<Block> for Client {
fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<Header>> { fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<Header>> {
match self { let id = &id;
Self::GTest(client) => client.header(&id), match_client!(self, header(id))
Self::GDev(client) => client.header(&id),
}
} }
fn info(&self) -> sp_blockchain::Info<Block> { fn info(&self) -> sp_blockchain::Info<Block> {
match self { match_client!(self, info())
Self::GTest(client) => client.info(),
Self::GDev(client) => client.info(),
}
} }
fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> { fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
match self { match_client!(self, status(id))
Self::GTest(client) => client.status(id),
Self::GDev(client) => client.status(id),
}
} }
fn number(&self, hash: Hash) -> sp_blockchain::Result<Option<BlockNumber>> { fn number(&self, hash: Hash) -> sp_blockchain::Result<Option<BlockNumber>> {
match self { match_client!(self, number(hash))
Self::GTest(client) => client.number(hash),
Self::GDev(client) => client.number(hash),
}
} }
fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> { fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> {
match self { match_client!(self, hash(number))
Self::GTest(client) => client.hash(number),
Self::GDev(client) => client.hash(number),
}
} }
} }
......
...@@ -24,27 +24,32 @@ std = [ ...@@ -24,27 +24,32 @@ std = [
] ]
try-runtime = ['frame-support/try-runtime'] try-runtime = ['frame-support/try-runtime']
[dependencies]
# substrate
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
[dependencies.codec] [dependencies.codec]
default-features = false default-features = false
features = ['derive'] features = ['derive']
package = 'parity-scale-codec' package = 'parity-scale-codec'
version = '2.2.0' version = '2.3.1'
[dependencies.frame-benchmarking] [dependencies.frame-benchmarking]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
optional = true optional = true
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.frame-support] [dependencies.frame-support]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.frame-system] [dependencies.frame-system]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.serde] [dependencies.serde]
version = "1.0.101" version = "1.0.101"
...@@ -53,18 +58,18 @@ features = ["derive"] ...@@ -53,18 +58,18 @@ features = ["derive"]
[dependencies.sp-core] [dependencies.sp-core]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-runtime] [dependencies.sp-runtime]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
[dependencies.sp-std] [dependencies.sp-std]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
### DOC ### ### DOC ###
...@@ -80,5 +85,5 @@ version = '1.0.2' ...@@ -80,5 +85,5 @@ version = '1.0.2'
[dev-dependencies.sp-io] [dev-dependencies.sp-io]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/librelois/substrate.git'
tag = 'monthly-2021-08' branch = 'duniter-monthly-2022-01'
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
use crate::{self as pallet_certification}; use crate::{self as pallet_certification};
use frame_support::{ use frame_support::{
parameter_types, parameter_types,
traits::{AllowAll, OnFinalize, OnInitialize}, traits::{Everything, OnFinalize, OnInitialize},
}; };
use frame_system as system; use frame_system as system;
use sp_core::H256; use sp_core::H256;
...@@ -51,7 +51,7 @@ parameter_types! { ...@@ -51,7 +51,7 @@ parameter_types! {
} }
impl system::Config for Test { impl system::Config for Test {
type BaseCallFilter = AllowAll; type BaseCallFilter = Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
...@@ -74,6 +74,7 @@ impl system::Config for Test { ...@@ -74,6 +74,7 @@ impl system::Config for Test {
type SystemWeightInfo = (); type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix; type SS58Prefix = SS58Prefix;
type OnSetCode = (); type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
} }
pub struct EnsureRoot; pub struct EnsureRoot;
...@@ -106,7 +107,7 @@ impl pallet_certification::Config for Test { ...@@ -106,7 +107,7 @@ impl pallet_certification::Config for Test {
type MaxByIssuer = MaxByIssuer; type MaxByIssuer = MaxByIssuer;
type OnNewcert = (); type OnNewcert = ();
type OnRemovedCert = (); type OnRemovedCert = ();
type RenewablePeriod = RenewablePeriod; type CertRenewablePeriod = RenewablePeriod;
type ValidityPeriod = ValidityPeriod; type ValidityPeriod = ValidityPeriod;
} }
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
pub trait IsIdtyAllowedToCreateCert<IdtyIndex> {
fn is_idty_allowed_to_create_cert(idty_index: IdtyIndex) -> bool;
}
pub trait OnNewcert<IdtyIndex> { pub trait OnNewcert<IdtyIndex> {
fn on_new_cert( fn on_new_cert(
issuer: IdtyIndex, issuer: IdtyIndex,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment