Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Update to latest susbtrate and contracts pallet (#31)
Browse files Browse the repository at this point in the history
* Update substrate to Alex's WIP framev2 PR branch

* Pin funty

* WIP updating Config trait and parameter types

* cargo update

* Use substrate master now contracts PR merged

* Copied constants from node-runtime

* Fix runtime compilation

* Use latest substrate wasm builder

* Fix up node

* Add key subcommand

* Increment spec version

* Remove master branch specifier

* Remove funty pin from manifest, it should be in the `Cargo.lock`

* Use contracts parameters copied from node-runtime

* Update README substrate commit
  • Loading branch information
ascjones authored Feb 23, 2021
1 parent 58cabc1 commit 4de4830
Show file tree
Hide file tree
Showing 9 changed files with 1,659 additions and 1,199 deletions.
2,646 changes: 1,524 additions & 1,122 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The master branch is currently tracking substrate master in order to include var
If it fails to build/install, use the cargo `--locked` flag to ensures that the most recent working version of
substrate will be used.

Latest commit confirmed working: https://github.com/paritytech/substrate/tree/f884296f7436916909025f8b43c4bbf3e60e4c60
Latest commit confirmed working: https://github.com/paritytech/substrate/tree/e6ac7e72c2251b8a23454c8cf0e3a2ad2c1ed566

## Usage

Expand Down
7 changes: 4 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ targets = ["x86_64-unknown-linux-gnu"]
structopt = "0.3.8"
hex-literal = "0.2.1"

sc-cli = { version = "0.8.0", git = "https://github.com/paritytech/substrate", package = "sc-cli", features = ["wasmtime"] }
sc-cli = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-cli", features = ["wasmtime"] }
sp-core = { git = "https://github.com/paritytech/substrate", package = "sp-core" }
sc-executor = { version = "0.8.0", git = "https://github.com/paritytech/substrate", package = "sc-executor", features = ["wasmtime"] }
sc-service = { version = "0.8.0", git = "https://github.com/paritytech/substrate", package = "sc-service", features = ["wasmtime"] }
sc-executor = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-executor", features = ["wasmtime"] }
sc-service = { version = "0.9.0", git = "https://github.com/paritytech/substrate", package = "sc-service", features = ["wasmtime"] }
sc-telemetry = { git = "https://github.com/paritytech/substrate", package = "sc-telemetry" }
sp-inherents = { git = "https://github.com/paritytech/substrate", package = "sp-inherents" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sc-transaction-pool" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", package = "sp-transaction-pool" }
Expand Down
3 changes: 3 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub struct Cli {

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

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

Expand Down
3 changes: 2 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match &cli.subcommand {
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
Expand Down Expand Up @@ -120,7 +121,7 @@ pub fn run() -> sc_cli::Result<()> {
match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config),
}
}.map_err(sc_cli::Error::Service)
})
}
}
Expand Down
84 changes: 57 additions & 27 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use sc_finality_grandpa::SharedVoterState;
use sc_telemetry::TelemetrySpan;

// Our native executor instance.
native_executor_instance!(
Expand All @@ -33,9 +34,13 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
AuraPair
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
)
>, ServiceError> {
if config.keystore_remote.is_some() {
return Err(ServiceError::Other(
format!("Remote Keystores are not supported.")))
}
let inherent_data_providers = sp_inherents::InherentDataProviders::new();

let (client, backend, keystore_container, task_manager) =
Expand All @@ -46,6 +51,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen

let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_handle(),
client.clone(),
Expand All @@ -65,26 +71,40 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
Some(Box::new(grandpa_block_import.clone())),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
)?;

Ok(sc_service::PartialComponents {
client, backend, task_manager, import_queue, keystore_container,
select_chain, transaction_pool,inherent_data_providers,
client,
backend,
task_manager,
import_queue,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (aura_block_import, grandpa_link),
})
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client, backend, mut task_manager, import_queue, keystore_container,
select_chain, transaction_pool, inherent_data_providers,
client,
backend,
mut task_manager,
import_queue,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link),
} = new_partial(&config)?;

config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -108,7 +128,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let name = config.network.node_name.clone();
let enable_grandpa = !config.disable_grandpa;
let prometheus_registry = config.prometheus_registry().cloned();
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();

let rpc_extensions_builder = {
let client = client.clone();
Expand All @@ -125,18 +144,26 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
})
};

sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend, network_status_sinks, system_rpc_tx, config,
})?;
let telemetry_span = TelemetrySpan::new();
let _telemetry_span_entered = telemetry_span.enter();

let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(
sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend,
network_status_sinks,
system_rpc_tx,
config,
telemetry_span: Some(telemetry_span.clone()),
},
)?;

if role.is_authority() {
let proposer = sc_basic_authorship::ProposerFactory::new(
Expand Down Expand Up @@ -183,7 +210,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
name: Some(name),
observer_enabled: false,
keystore,
is_authority: role.is_network_authority(),
is_authority: role.is_authority(),
};

if enable_grandpa {
Expand All @@ -197,7 +224,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
config: grandpa_config,
link: grandpa_link,
network,
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
Expand All @@ -209,19 +236,19 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
"grandpa-voter",
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?
);
} else {
sc_finality_grandpa::setup_disabled_grandpa(network)?;
}

network_starter.start_network();
Ok(task_manager)
}

/// Builds a new service for a light client.
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError> {
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;

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(
Expand Down Expand Up @@ -249,7 +276,7 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
Some(Box::new(grandpa_block_import)),
client.clone(),
InherentDataProviders::new(),
&task_manager.spawn_handle(),
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
sp_consensus::NeverCanAuthor,
)?;
Expand All @@ -271,20 +298,23 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
);
}

let telemetry_span = TelemetrySpan::new();
let _telemetry_span_entered = telemetry_span.enter();

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(|_, _| ()),
telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(),
config,
client,
keystore: keystore_container.sync_keystore(),
backend,
network,
network_status_sinks,
system_rpc_tx,
telemetry_span: Some(telemetry_span.clone()),
})?;

network_starter.start_network();
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }

pallet-aura = { git = "https://github.com/paritytech/substrate", package = "pallet-aura", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", package = "pallet-balances", default-features = false }
Expand Down Expand Up @@ -43,7 +43,7 @@ pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate",
pallet-contracts-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-rpc-runtime-api", default-features = false }

[build-dependencies]
wasm-builder-runner = { version = "1.0.6", package = "substrate-wasm-builder-runner" }
substrate-wasm-builder = "4.0.0"

[features]
default = ["std"]
Expand Down
3 changes: 1 addition & 2 deletions runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use wasm_builder_runner::WasmBuilder;
use substrate_wasm_builder::WasmBuilder;

fn main() {
WasmBuilder::new()
.with_current_project()
.with_wasm_builder_from_crates("2.0.0")
.export_heap_base()
.import_memory()
.build()
Expand Down
Loading

0 comments on commit 4de4830

Please sign in to comment.