Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
733 changes: 364 additions & 369 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = 'Apache2'
name = 'integritee-node'
repository = 'https://github.com/integritee-network/integritee-node'
#keep with runtime version
version = '1.0.6'
version = '1.0.7'

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand All @@ -17,12 +17,12 @@ targets = ["x86_64-unknown-linux-gnu"]
name = 'integritee-node'

[dependencies]
structopt = "0.3.8"
clap = { version = "3.0", features = ["derive"] }
serde_json = "1.0.63"
hex = "0.4"

sc-cli = { version = "0.10.0-dev", features = ["wasmtime"], git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "4.1.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-executor = { version = "0.10.0-dev", features = ["wasmtime"], git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-service = { version = "0.10.0-dev", features = ["wasmtime"], git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
Expand All @@ -37,7 +37,7 @@ sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/su
sc-finality-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-finality-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
hex-literal = { version = "0.3.1"}

Expand Down
16 changes: 15 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub fn development_config() -> Result<ChainSpec, String> {
None,
// Protocol ID
None,
// Arbitrary string. Nodes will only synchronize with other nodes that have the same value
// in their `fork_id`. This can be used in order to segregate nodes in cases when multiple
// chains have the same genesis hash.
None,
// Properties
None,
// Extensions
Expand Down Expand Up @@ -141,6 +145,8 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
None,
// Protocol ID
None,
// Fork ID.
None,
// Properties
None,
// Extensions
Expand Down Expand Up @@ -251,6 +257,10 @@ pub fn integritee_solo_fresh_config() -> Result<ChainSpec, String> {
None,
// Protocol ID
Some("teer"),
// Arbitrary string. Nodes will only synchronize with other nodes that have the same value
// in their `fork_id`. This can be used in order to segregate nodes in cases when multiple
// chains have the same genesis hash.
None,
// Properties
Some(
serde_json::from_str(
Expand Down Expand Up @@ -332,6 +342,10 @@ pub fn cranny_fresh_config() -> Result<ChainSpec, String> {
None,
// Protocol ID
Some("teer"),
// Arbitrary string. Nodes will only synchronize with other nodes that have the same value
// in their `fork_id`. This can be used in order to segregate nodes in cases when multiple
// chains have the same genesis hash.
None,
// Properties
Some(
serde_json::from_str(
Expand Down Expand Up @@ -371,7 +385,7 @@ fn genesis_config(
},
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
key: Some(root_key),
},
teerex: TeerexConfig { allow_sgx_debug_mode: true },
claims: Default::default(),
Expand Down
15 changes: 8 additions & 7 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use sc_cli::RunCmd;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
#[derive(Debug, clap::Parser)]
pub struct Cli {
#[structopt(subcommand)]
#[clap(subcommand)]
pub subcommand: Option<Subcommand>,

#[structopt(flatten)]
#[clap(flatten)]
pub run: RunCmd,
}

#[derive(Debug, StructOpt)]
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
/// Key management cli utilities
/// Key management cli utilities.
#[clap(subcommand)]
Key(sc_cli::KeySubcommand),

/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),

Expand All @@ -36,6 +37,6 @@ pub enum Subcommand {
Revert(sc_cli::RevertCmd),

/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
#[clap(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
13 changes: 11 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.

use integritee_node_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::ExecutorProvider;
use sc_client_api::{BlockBackend, ExecutorProvider};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
pub use sc_executor::NativeElseWasmExecutor;
use sc_finality_grandpa::SharedVoterState;
Expand Down Expand Up @@ -181,7 +181,15 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
};
}

config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);

config
.network
.extra_sets
.push(sc_finality_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Expand Down Expand Up @@ -304,6 +312,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore,
local_role: role,
telemetry: telemetry.as_ref().map(|x| x.handle()),
protocol_name: grandpa_protocol_name,
};

if enable_grandpa {
Expand Down
6 changes: 3 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = 'Apache2'
name = 'integritee-node-runtime'
repository = 'https://github.com/integritee-network/integritee-node'
# keep patch revision with spec_version of runtime
version = '1.0.6'
version = '1.0.7'

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down Expand Up @@ -36,10 +36,10 @@ pallet-teeracle = { default-features = false, git = "https://github.com/integrit
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-block-builder = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "4.1.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "5.0.0" , default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master"}
sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-std = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
Expand Down
5 changes: 4 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// Version of the runtime specification. A full-node will not attempt to use its native
/// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
/// `spec_version` and `authoring_version` are the same between Wasm and native.
spec_version: 6,
spec_version: 7,

/// Version of the implementation of the specification. Nodes are free to ignore this; it
/// serves only as an indication that the code is different; as long as the other two versions
Expand All @@ -148,6 +148,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
///
/// It need *not* change when a new module is added or when a dispatchable is added.
transaction_version: 2,
state_version: 0,
};

/// This determines the average expected block time that we are targeting.
Expand Down Expand Up @@ -394,6 +395,7 @@ impl pallet_teeracle::Config for Runtime {
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 100 * MILLITEER;
pub const ProposalBondMaximum: Balance = 500 * TEER;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_percent(1);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
Expand All @@ -411,6 +413,7 @@ impl pallet_treasury::Config for Runtime {
type OnSlash = (); //No proposal
type ProposalBond = ProposalBond; //No proposal
type ProposalBondMinimum = ProposalBondMinimum; //No proposal
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod; //Cannot be 0: Error: Thread 'tokio-runtime-worker' panicked at 'attempt to calculate the remainder with a divisor of zero
type Burn = (); //No burn
type BurnDestination = (); //No burn
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2021-12-10"
channel = "nightly-2022-02-02"
targets = ["wasm32-unknown-unknown"]
profile = "default" # include rustfmt, clippy
profile = "default" # include rustfmt, clippy
27 changes: 27 additions & 0 deletions scripts/dump_wasm_state_and_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Helper script to generate the wasm, state and chain-spec/ -raw.json for a given chain-spec.
#
# Usage: ./scripts/dump_wasm_state_and_spec.sh <chain-spec> <para-id> <collator-binary> <dump-dir>
#
# Example: ./scripts/dump_wasm_state_and_spec.sh shell-kusama-local-dev 2000 collator ./dump_dir
#
# chain-spec is mandatory, the rest is optional.


CHAIN_SPEC=$1
COLLATOR=${2:-./target/release/encointer-collator}
DUMP_DIR=${3:-./chain_dumps}

mkdir -p ${DUMP_DIR}

echo "dumping spec for: $CHAIN_SPEC"
echo "collator: ${COLLATOR}"
echo "dump_dir: ${DUMP_DIR}"
echo ""

$COLLATOR build-spec --chain ${CHAIN_SPEC} >$DUMP_DIR/${CHAIN_SPEC}.json
$COLLATOR build-spec --chain ${CHAIN_SPEC} --raw >$DUMP_DIR/${CHAIN_SPEC}-raw-unsorted.json
jq --sort-keys . $DUMP_DIR/${CHAIN_SPEC}-raw-unsorted.json > $DUMP_DIR/${CHAIN_SPEC}-raw.json

$COLLATOR export-state --chain $DUMP_DIR/${CHAIN_SPEC}-raw.json >$DUMP_DIR/${CHAIN_SPEC}.state
77 changes: 77 additions & 0 deletions scripts/update_hardcoded_chain_specs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3

"""
Simple script to upgrade the hardcoded chain-spec.json files.
This the main purpose is that to automate migration of values from the old files to the new files that can not
be inserted by the rust code, e.g., the `bootNodes`.
Usage: ./scripts/update_hardcoded_specs.py <--migrate-genesis>
Optionally define if the `genesis` field of the chain-spec should also be migrated. This field should be set as follows:
* True, if a completely new chain-spec shall be created. This will create a new genesis state, which is not compatible
with chains running on the old chain-spec.
* False, if we only want to change other fields that are relevant to the node (i.e., the client) only, but not
the runtime. For instance if we update the substrate/polkadot.
"""

import argparse
import json
import os
import subprocess

SPECS = [
{
"chain_id": "cranny",
},
{
"chain_id": "integritee-solo",
}
]
COLLATOR = "target/release/integritee-node"
RES_DIR = "node/res"


def main(regenesis: bool):
for s in SPECS:
chain_spec = s["chain_id"]

ret = subprocess.call(
f'scripts/dump_wasm_state_and_spec.sh {chain_spec}-fresh {COLLATOR} {RES_DIR}',
stdout=subprocess.PIPE,
shell=True
)

print(ret)

orig_file = f'{RES_DIR}/{chain_spec}.json'
new_file_base = f'{RES_DIR}/{chain_spec}-fresh'

with open(orig_file, 'r+') as spec_orig_file:
orig_json = json.load(spec_orig_file)

# migrate old values to new spec
with open(f'{new_file_base}.json', 'r+') as spec_new_file:
new_json = json.load(spec_new_file)

new_json["bootNodes"] = orig_json["bootNodes"]

if not regenesis:
new_json["genesis"] = orig_json["genesis"]

# go to beginning of the file to overwrite
spec_orig_file.seek(0)
json.dump(new_json, spec_orig_file, indent=2)
spec_orig_file.truncate()

# remove side-products
os.remove(f'{new_file_base}.json')
os.remove(f'{new_file_base}-raw.json')
os.remove(f'{new_file_base}-raw-unsorted.json')
os.remove(f'{new_file_base}.state')

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--regenesis', help='Overwrite genesis state in chain spec. Use this for resetting chains entirely', action='store_true')

args = parser.parse_args()
print(f'Updating chain specs. Preserving bootnodes. (re-genesis == {args.regenesis})')

main(args.regenesis)