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

upgrade substrate to monthly-2022-01

parent b59eacda
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:
.env:
image: paritytech/ci-linux:production
tags:
- elois-tauon
- elois-boson
fmt_and_clippy:
extends: .env
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_MERGE_REQUEST_ID
- when: on_success
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: manual
stage: quality
script:
- cargo fmt -- --version
......@@ -43,4 +43,5 @@ tests:
- when: manual
stage: tests
script:
- cargo build
- cargo test
This diff is collapsed.
[workspace]
resolver = "2"
members = [
'integration-tests',
'node',
'pallets/certification',
'pallets/identity',
......@@ -9,7 +12,69 @@ members = [
'runtime/gdev',
'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]
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]
authors = ['Axiom-Team Developers <https://axiom-team.fr>']
build = 'build.rs'
......@@ -19,172 +12,185 @@ version = '3.0.0'
[package.metadata.docs.rs]
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]
async-io = "1.3"
futures = { version = "0.3.1", features = ["compat"] }
jsonrpc-core = '15.1.0'
log = "0.4"
maplit = '1.0.2'
# local dependencies
common-runtime = { path = '../runtime/common' }
g1-runtime = { path = '../runtime/g1' }
gdev-runtime = { path = '../runtime/gdev' }
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'
# substrate dependencies
[dependencies.frame-benchmarking]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.frame-benchmarking-cli]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-transaction-payment-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-transaction-payment-rpc-runtime-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-chain-spec]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-cli]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-client-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-consensus-manual-seal]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-executor]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-keystore]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-rpc-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-service]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-telemetry]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sc-transaction-pool-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
[dependencies.serde_json]
version = '1.0.64'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-block-builder]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-blockchain]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-offchain]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-session]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-storage]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-timestamp]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-trie]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.substrate-frame-rpc-system]
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
[[bin]]
name = 'lc-core'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
......@@ -98,10 +98,13 @@ fn devnet_genesis(
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
balances: BalancesConfig {
balances: Vec::with_capacity(0),
balances: initial_identities
.values()
.cloned()
.map(|account_id| (account_id, 1_000))
.collect(),
},
grandpa: GrandpaConfig {
authorities: initial_authorities
......@@ -111,7 +114,7 @@ fn devnet_genesis(
},
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
identity: IdentityConfig {
identities: initial_identities
......@@ -141,7 +144,7 @@ fn devnet_genesis(
},
universal_dividend: UniversalDividendConfig {
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(
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of INITIAL_BALANCE.
......@@ -165,7 +164,7 @@ fn devnet_genesis(
},
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
identity: IdentityConfig {
identities: initial_identities
......@@ -211,7 +210,6 @@ fn testnet_genesis(
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of INITIAL_BALANCE.
......@@ -228,7 +226,7 @@ fn testnet_genesis(
},
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
identity: IdentityConfig {
identities: initial_identities
......
......@@ -82,8 +82,9 @@ impl FromStr for Sealing {
"instant" => Self::Instant,
"manual" => Self::Manual,
s => {
let millis =
u64::from_str_radix(s, 10).map_err(|_| "couldn't decode sealing param")?;
let millis = s
.parse::<u64>()
.map_err(|_| "couldn't decode sealing param")?;
Self::Interval(millis)
}
})
......
......@@ -16,10 +16,10 @@
// limitations under the License.
use crate::cli::{Cli, Subcommand};
use crate::service::{GDevExecutor, GTestExecutor, IdentifyVariant};
use crate::service::{G1Executor, GDevExecutor, GTestExecutor, IdentifyVariant};
use crate::{chain_spec, service};
use gdev_runtime::Block;
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
impl SubstrateCli for Cli {
fn impl_name() -> String {
......@@ -168,7 +168,7 @@ pub fn run() -> sc_cli::Result<()> {
let chain_spec = &runner.config().chain_spec;
if chain_spec.is_main() {
todo!()
runner.sync_run(|config| cmd.run::<Block, G1Executor>(config))
} else if chain_spec.is_test() {
runner.sync_run(|config| cmd.run::<Block, GTestExecutor>(config))
} else if chain_spec.is_dev() {
......@@ -186,17 +186,11 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
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() {
match config.role {
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)
service::new_full::<gtest_runtime::RuntimeApi, GTestExecutor>(config, None)
.map_err(sc_cli::Error::Service)
} else if config.chain_spec.is_dev() {
service::new_full::<gdev_runtime::RuntimeApi, GDevExecutor>(
config,
......
......@@ -47,7 +47,9 @@ pub struct FullDeps<C, P> {
}
/// 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
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
......@@ -91,5 +93,5 @@ where
// to call into the runtime.
// `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));`
io
Ok(io)
}
......@@ -18,16 +18,14 @@
mod client;
pub use sc_executor::NativeExecutor;
use self::client::{Client, RuntimeApiCollection};
use async_io::Timer;
use common_runtime::Block;
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_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_keystore::LocalKeystore;
use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager};
......@@ -38,27 +36,64 @@ use sp_core::H256;
use sp_runtime::traits::BlakeTwo256;
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 FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type LightClient<RuntimeApi, Executor> =
sc_service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;
type LightBackend = sc_service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>;
pub struct GDevExecutor;
impl sc_executor::NativeExecutionDispatch for GDevExecutor {
/// 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)
}
fn native_version() -> sc_executor::NativeVersion {
gdev_runtime::native_version()
}
}
pub struct GTestExecutor;
impl sc_executor::NativeExecutionDispatch for GTestExecutor {
/// 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>> {
gtest_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
gtest_runtime::native_version()
}
}
native_executor_instance!(
pub GDevExecutor,
gdev_runtime::api::dispatch,
gdev_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);
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)
}
native_executor_instance!(
pub GTestExecutor,
gtest_runtime::api::dispatch,
gtest_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);
fn native_version() -> sc_executor::NativeVersion {
g1_runtime::native_version()
}
}
/// Can be called for a `Configuration` to check if it is a configuration for
/// a particular network.
......@@ -101,7 +136,19 @@ pub fn new_chain_ops(
ServiceError,
> {
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() {
let PartialComponents {
client,
......@@ -185,15 +232,25 @@ where
})
.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) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
&config,
sc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
)?;
let client = Arc::new(client);
let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
task_manager
.spawn_handle()
.spawn("telemetry", None, worker.run());
telemetry
});
......@@ -307,6 +364,11 @@ where
.network
.extra_sets
.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) =
sc_service::build_network(sc_service::BuildNetworkParams {
......@@ -315,8 +377,8 @@ where
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: Some(warp_sync),
})?;
if config.offchain_worker.enabled {
......@@ -382,6 +444,7 @@ where
task_manager.spawn_essential_handle().spawn_blocking(
"authorship_task",
Some("block-authoring"),
run_manual_seal(ManualSealParams {
block_import,
env: proposer_factory,
......@@ -431,9 +494,11 @@ where
// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
task_manager
.spawn_essential_handle()
.spawn_blocking("aura", aura);
task_manager.spawn_essential_handle().spawn_blocking(
"aura",
Some("block-authoring"),
aura,
);
}
}
......@@ -449,7 +514,7 @@ where
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
task_manager: &mut task_manager,
transaction_pool,
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend,
system_rpc_tx,
config,
......@@ -508,6 +571,7 @@ where
// if it fails we take down the service with it.
task_manager.spawn_essential_handle().spawn_blocking(
"grandpa-voter",
None,
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
);
}
......@@ -515,144 +579,3 @@ where
network_starter.start_network();
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::{
traits::{BlakeTwo256, Block as BlockT},
Justifications,
};
use sp_storage::{ChildInfo, PrefixedStorageKey, StorageData, StorageKey};
use sp_storage::{ChildInfo, StorageData, StorageKey};
use std::sync::Arc;
/// A client instance.
#[derive(Clone)]
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>>),
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 {
fn usage_info(&self) -> sc_client_api::ClientInfo<Block> {
match self {
Self::GTest(client) => client.usage_info(),
Self::GDev(client) => client.usage_info(),
}
match_client!(self, usage_info())
}
}
......@@ -48,71 +75,47 @@ impl sc_client_api::BlockBackend<Block> for Client {
&self,
id: &BlockId<Block>,
) -> sp_blockchain::Result<Option<Vec<<Block as BlockT>::Extrinsic>>> {
match self {
Self::GTest(client) => client.block_body(id),
Self::GDev(client) => client.block_body(id),
}
match_client!(self, block_body(id))
}
fn block_indexed_body(
&self,
id: &BlockId<Block>,
) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> {
match self {
Self::GTest(client) => client.block_indexed_body(id),
Self::GDev(client) => client.block_indexed_body(id),
}
match_client!(self, block_indexed_body(id))
}
fn block(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<SignedBlock<Block>>> {
match self {
Self::GTest(client) => client.block(id),
Self::GDev(client) => client.block(id),
}
match_client!(self, block(id))
}
fn block_status(&self, id: &BlockId<Block>) -> sp_blockchain::Result<BlockStatus> {
match self {
Self::GTest(client) => client.block_status(id),
Self::GDev(client) => client.block_status(id),
}
match_client!(self, block_status(id))
}
fn justifications(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<Justifications>> {
match self {
Self::GTest(client) => client.justifications(id),
Self::GDev(client) => client.justifications(id),
}
match_client!(self, justifications(id))
}
fn block_hash(
&self,
number: NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self {
Self::GTest(client) => client.block_hash(number),
Self::GDev(client) => client.block_hash(number),
}
match_client!(self, block_hash(number))
}
fn indexed_transaction(
&self,
hash: &<Block as BlockT>::Hash,
) -> sp_blockchain::Result<Option<Vec<u8>>> {
match self {
Self::GTest(client) => client.indexed_transaction(hash),
Self::GDev(client) => client.indexed_transaction(hash),
}
match_client!(self, indexed_transaction(hash))
}
fn has_indexed_transaction(
&self,
hash: &<Block as BlockT>::Hash,
) -> sp_blockchain::Result<bool> {
match self {
Self::GTest(client) => client.has_indexed_transaction(hash),
Self::GDev(client) => client.has_indexed_transaction(hash),
}
match_client!(self, has_indexed_transaction(hash))
}
}
......@@ -122,10 +125,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>,
key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
match self {
Self::GTest(client) => client.storage(id, key),
Self::GDev(client) => client.storage(id, key),
}
match_client!(self, storage(id, key))
}
fn storage_keys(
......@@ -133,10 +133,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> {
match self {
Self::GTest(client) => client.storage_keys(id, key_prefix),
Self::GDev(client) => client.storage_keys(id, key_prefix),
}
match_client!(self, storage_keys(id, key_prefix))
}
fn storage_hash(
......@@ -144,10 +141,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self {
Self::GTest(client) => client.storage_hash(id, key),
Self::GDev(client) => client.storage_hash(id, key),
}
match_client!(self, storage_hash(id, key))
}
fn storage_pairs(
......@@ -155,10 +149,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
id: &BlockId<Block>,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<(StorageKey, StorageData)>> {
match self {
Self::GTest(client) => client.storage_pairs(id, key_prefix),
Self::GDev(client) => client.storage_pairs(id, key_prefix),
}
match_client!(self, storage_pairs(id, key_prefix))
}
fn storage_keys_iter<'a>(
......@@ -169,10 +160,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
) -> sp_blockchain::Result<
KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>,
> {
match self {
Self::GTest(client) => client.storage_keys_iter(id, prefix, start_key),
Self::GDev(client) => client.storage_keys_iter(id, prefix, start_key),
}
match_client!(self, storage_keys_iter(id, prefix, start_key))
}
fn child_storage(
......@@ -181,10 +169,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
match self {
Self::GTest(client) => client.child_storage(id, child_info, key),
Self::GDev(client) => client.child_storage(id, child_info, key),
}
match_client!(self, child_storage(id, child_info, key))
}
fn child_storage_keys(
......@@ -193,10 +178,7 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo,
key_prefix: &StorageKey,
) -> sp_blockchain::Result<Vec<StorageKey>> {
match self {
Self::GTest(client) => client.child_storage_keys(id, child_info, key_prefix),
Self::GDev(client) => client.child_storage_keys(id, child_info, key_prefix),
}
match_client!(self, child_storage_keys(id, child_info, key_prefix))
}
fn child_storage_keys_iter<'a>(
......@@ -208,12 +190,10 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
) -> sp_blockchain::Result<
KeyIterator<'a, <super::FullBackend as sc_client_api::Backend<Block>>::State, Block>,
> {
match self {
Self::GTest(client) => {
client.child_storage_keys_iter(id, child_info, prefix, start_key)
}
Self::GDev(client) => client.child_storage_keys_iter(id, child_info, prefix, start_key),
}
match_client!(
self,
child_storage_keys_iter(id, child_info, prefix, start_key)
)
}
fn child_storage_hash(
......@@ -222,70 +202,29 @@ impl sc_client_api::StorageProvider<Block, super::FullBackend> for Client {
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
match self {
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),
}
match_client!(self, child_storage_hash(id, child_info, key))
}
}
impl sp_blockchain::HeaderBackend<Block> for Client {
fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<Header>> {
match self {
Self::GTest(client) => client.header(&id),
Self::GDev(client) => client.header(&id),
}
let id = &id;
match_client!(self, header(id))
}
fn info(&self) -> sp_blockchain::Info<Block> {
match self {
Self::GTest(client) => client.info(),
Self::GDev(client) => client.info(),
}
match_client!(self, info())
}
fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
match self {
Self::GTest(client) => client.status(id),
Self::GDev(client) => client.status(id),
}
match_client!(self, status(id))
}
fn number(&self, hash: Hash) -> sp_blockchain::Result<Option<BlockNumber>> {
match self {
Self::GTest(client) => client.number(hash),
Self::GDev(client) => client.number(hash),
}
match_client!(self, number(hash))
}
fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> {
match self {
Self::GTest(client) => client.hash(number),
Self::GDev(client) => client.hash(number),
}
match_client!(self, hash(number))
}
}
......
......@@ -24,27 +24,32 @@ std = [
]
try-runtime = ['frame-support/try-runtime']
[dependencies]
# substrate
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.2.0'
version = '2.3.1'
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
git = 'https://github.com/librelois/substrate.git'
optional = true
tag = 'monthly-2021-08'
branch = 'duniter-monthly-2022-01'
[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.serde]
version = "1.0.101"
......@@ -53,18 +58,18 @@ features = ["derive"]
[dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.sp-std]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
### DOC ###
......@@ -80,5 +85,5 @@ version = '1.0.2'
[dev-dependencies.sp-io]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-08'
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
This diff is collapsed.
......@@ -17,7 +17,7 @@
use crate::{self as pallet_certification};
use frame_support::{
parameter_types,
traits::{AllowAll, OnFinalize, OnInitialize},
traits::{Everything, OnFinalize, OnInitialize},
};
use frame_system as system;
use sp_core::H256;
......@@ -51,7 +51,7 @@ parameter_types! {
}
impl system::Config for Test {
type BaseCallFilter = AllowAll;
type BaseCallFilter = Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
......@@ -74,6 +74,7 @@ impl system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
pub struct EnsureRoot;
......@@ -106,7 +107,7 @@ impl pallet_certification::Config for Test {
type MaxByIssuer = MaxByIssuer;
type OnNewcert = ();
type OnRemovedCert = ();
type RenewablePeriod = RenewablePeriod;
type CertRenewablePeriod = RenewablePeriod;
type ValidityPeriod = ValidityPeriod;
}
......
......@@ -14,6 +14,10 @@
// 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/>.
pub trait IsIdtyAllowedToCreateCert<IdtyIndex> {
fn is_idty_allowed_to_create_cert(idty_index: IdtyIndex) -> bool;
}
pub trait OnNewcert<IdtyIndex> {
fn on_new_cert(
issuer: IdtyIndex,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment