Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
7a956fb
WIP
cecton Jun 12, 2020
9dd9118
WIP
cecton Jun 12, 2020
ffa95f1
WIP
cecton Jun 15, 2020
b5ee29e
CLEANUP
cecton Jun 15, 2020
d2428b4
CLEANUP
cecton Jun 15, 2020
587870d
CLEANUP
cecton Jun 15, 2020
886d76f
Rename to polkadot-test-service and rename dir
cecton Jun 15, 2020
6306561
Merge commit b2c9c14971f1f06400c6522e40d02e79c0f11a05 (no conflict)
cecton Jun 15, 2020
6c95310
Bump spec_version
cecton Jun 15, 2020
555715a
Move code to macro to avoid adding pub fn to API
cecton Jun 15, 2020
4a3b4b0
CLEANUP
cecton Jun 15, 2020
0d506a1
Fixed missing import
cecton Jun 15, 2020
16f1c67
Fix missing import
cecton Jun 15, 2020
9e1bf51
WIP
cecton Jun 15, 2020
186a764
CLEANUP
cecton Jun 15, 2020
528b2ed
WIP Attempt to make a test
cecton Jun 15, 2020
88c57d3
Change most const to storage
cecton Jun 16, 2020
b5b219e
Add Get impl
cecton Jun 16, 2020
9aba20a
Move everything to the test crate to create an API
cecton Jun 16, 2020
83d9bf3
create chain spec
cecton Jun 16, 2020
84fe08a
Parametrize storage update
cecton Jun 16, 2020
df43948
CLEANUP
cecton Jun 16, 2020
7a27276
regex to the rescue
cecton Jun 16, 2020
29b8a34
Improving API
cecton Jun 16, 2020
4ca5082
format
cecton Jun 16, 2020
f67af13
WIP
cecton Jun 17, 2020
5ae1794
WIP
cecton Jun 17, 2020
0061afe
WIP
cecton Jun 18, 2020
2fd2d71
WIP
cecton Jun 18, 2020
899505d
use memory
cecton Jun 18, 2020
25eb924
fixing last commit
cecton Jun 19, 2020
780fbdf
WIP
cecton Jun 19, 2020
302fa9a
max allowed time
cecton Jun 19, 2020
a3ba37b
CLEANUP
cecton Jun 19, 2020
d36cdc2
fmt
cecton Jun 19, 2020
960f1f1
Revert Cargo.lock
cecton Jun 19, 2020
de25f24
CLEANUP
cecton Jun 19, 2020
ee93ecd
Added sudo
cecton Jun 19, 2020
cd96ffb
Merge commit b0b444ce5439849cbffea1d07dd710957402c064 (no conflict)
cecton Jun 19, 2020
d42d727
Merge commit a16cc4da50fa0205187c4babecc34f695918b63e (conflicts)
cecton Jun 19, 2020
95e1a87
Merge commit 79a0df2f77f9d896b7b1790d04fb09355b6cccd2 (no conflict)
cecton Jun 19, 2020
30c0dd7
Merge commit daf0073759f66a63b17abe1f8cdcaec93640afc9 (conflicts)
cecton Jun 19, 2020
f48b071
fix merge upgrade
cecton Jun 19, 2020
9c04748
Cargo.lock
cecton Jun 19, 2020
4730489
Merge commit fb66e42fe51d70d93688461aa6654cd87bc61db2 (no conflict)
cecton Jun 19, 2020
3a0eee3
Fixed slot_duration for test w/ and w/out service
cecton Jun 22, 2020
f2444bc
increase spec version
cecton Jun 22, 2020
fb62093
Merge commit 4f79b770dc9d891739cc8dbadd62f7d9d8e36a58 (no conflict)
cecton Jun 22, 2020
acb88cc
better fix
cecton Jun 22, 2020
6e5e060
Update runtime/test-runtime/client/src/lib.rs
cecton Jun 22, 2020
3de82c2
Added doc and simplified API
cecton Jun 30, 2020
8f4245d
Make wait_for_blocks more generic to avoid duplication in cumulus
cecton Jun 30, 2020
605da30
Merge commit 39a3605224791f0b8fcd41af2f9636b83403780e (no conflict)
cecton Jun 30, 2020
9467bd8
Merge commit b05bb8f6336928dd9fb5711036f98c38a854650a (conflicts)
cecton Jun 30, 2020
b723dea
Merge commit 0762de59f975fe2392fd6ca28dc3bd904df7f3a8 (no conflict)
cecton Jun 30, 2020
be679dd
Merge commit 51ce2b31230d6debdcd04f6bf9b345ec92544b94 (conflicts)
cecton Jun 30, 2020
4816880
Removed base_path as this is not needed anymore
cecton Jun 30, 2020
f35262e
Helper to send transaction more easily
cecton Jun 30, 2020
74ab47c
Fix indent
cecton Jul 1, 2020
be3889b
Added test for send-transaction
cecton Jul 1, 2020
73ae473
Ensure task_manager dropped after task finish
cecton Jul 1, 2020
b8ec09d
Improve logging by using informant prefix
cecton Jul 1, 2020
36fec81
Update polkadot-test-service/src/lib.rs
cecton Jul 1, 2020
178ab7b
Update polkadot-test-service/src/lib.rs
cecton Jul 1, 2020
de65c05
Update polkadot-test-service/src/lib.rs
cecton Jul 1, 2020
abf0f35
Replace asserts with expects
cecton Jul 1, 2020
6bae984
Merged imports
cecton Jul 1, 2020
261c552
Revert slot duration change
cecton Jul 1, 2020
4fc1a58
Helper to call a function
cecton Jul 1, 2020
5796cd5
Update substrate branch to cecton-testing-helpers
cecton Jul 2, 2020
91bf6bb
CLEANUP
cecton Jul 2, 2020
a6a54b5
Revert "Update substrate branch to cecton-testing-helpers"
cecton Jul 2, 2020
3092be3
Merge commit 90d5dbe564ae795d68aff1c936cbdd1f98c9d536 (no conflict)
cecton Jul 2, 2020
6dce9b1
Update substrate branch to cecton-testing-helpers
cecton Jul 2, 2020
a8fe1dd
CLEANUP
cecton Jul 2, 2020
df63aa1
CLEANUP
cecton Jul 2, 2020
0cdda37
Add test runtime to command
cecton Jun 30, 2020
5b4fcfd
replaced panic with clean error
cecton Jul 2, 2020
36c8c65
Simplify test
cecton Jul 2, 2020
cf3fb7b
rename test
cecton Jul 2, 2020
2bbe1b6
Revert "Add test runtime to command"
cecton Jul 3, 2020
f97dd0c
increase kusama
cecton Jul 3, 2020
523366e
Update substrate
cecton Jul 3, 2020
6be349f
Revert to master
cecton Jul 3, 2020
fb41215
Merge commit aeb79d47345e2e5d6320e0f2c11cb70df1e614e4 (no conflict)
cecton Jul 3, 2020
5550cbb
Merge commit 0a7d04d00edc50488b2d6c34db685dac2234d749 (no conflict)
cecton Jul 3, 2020
c4cd5fb
Cargo.lock again
cecton Jul 3, 2020
a44b1c0
removed unused id prefix
cecton Jul 3, 2020
e8573ae
fix update
cecton Jul 3, 2020
fd8a9d7
Merge commit 21f31f78de36c6a36defb0fa0ee0052df35a0d0f (no conflict)
cecton Jul 5, 2020
fc00d0c
Merge commit 78e6e08e9e4524faddad463bbadbaf2c70e47256 (conflicts)
cecton Jul 5, 2020
5916b39
Update runtime/test-runtime/src/lib.rs
cecton Jul 6, 2020
d620fc6
Update polkadot-test-service/src/lib.rs
cecton Jul 6, 2020
f108a3f
apply suggestions
cecton Jul 6, 2020
602814a
add missing license
cecton Jul 7, 2020
00316bd
Merge commit 8348cc4cb0aea625cd6868dcc4faa6633d0f8d9e (no conflict)
cecton Jul 7, 2020
42545d5
Move polkadot-test-service to node/test-service
cecton Jul 7, 2020
c94459c
Sort dependencies and group
cecton Jul 7, 2020
1637455
Attempt to remove genesismap
cecton Jul 7, 2020
90750a1
Pass parameters
cecton Jul 7, 2020
35e8ab1
Merge commit 891767bcd28a4a53fbc17ba87c2cc2d48758e35f (no conflict)
cecton Jul 7, 2020
5fb41d2
another attempt to fix the test
cecton Jul 7, 2020
7fa0a85
Merge remote-tracking branch 'origin/master' into cecton-polkadot-tes…
bkchr Jul 9, 2020
6a65f87
Revert "another attempt to fix the test"
bkchr Jul 9, 2020
c74756a
Fix tests
bkchr Jul 9, 2020
f94de16
Update substrate
cecton Jul 9, 2020
e606833
adapt code
cecton Jul 9, 2020
4e65412
fix
cecton Jul 9, 2020
b44f302
unused import
cecton Jul 9, 2020
f3b3142
WIP
cecton Jul 9, 2020
d32f811
replace async_std with tokio
cecton Jul 9, 2020
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
3,754 changes: 2,724 additions & 1,030 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"erasure-coding",
"network",
"network/test",
"polkadot-test",
"primitives",
"runtime/common",
"runtime/parachains",
Expand Down
71 changes: 71 additions & 0 deletions polkadot-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[package]
name = "polkadot-test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to polkadot-test-service and move the folder also

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 886d76f

version = "0.8.2"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
parking_lot = "0.9.0"
serde = { version = "1.0.102", features = ["derive"] }
lazy_static = "1.4.0"
log = "0.4.8"
futures = "0.3.4"
slog = "2.5.2"
hex-literal = "0.2.1"
av_store = { package = "polkadot-availability-store", path = "../availability-store", optional = true }
consensus = { package = "polkadot-validation", path = "../validation", optional = true }
polkadot-primitives = { path = "../primitives" }
polkadot-runtime = { path = "../runtime/polkadot" }
kusama-runtime = { path = "../runtime/kusama" }
westend-runtime = { path = "../runtime/westend" }
polkadot-test-runtime = { path = "../runtime/test-runtime" }
polkadot-network = { path = "../network", optional = true }
polkadot-rpc = { path = "../rpc" }
polkadot-service = { path = "../service" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
authority-discovery = { package = "sc-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
codec = { package = "parity-scale-codec", version = "1.3.0" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }

[dev-dependencies]
polkadot-test-runtime-client = { path = "../runtime/test-runtime/client" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
env_logger = "0.7.0"

[features]
default = ["db", "full-node"]
db = ["service/db"]
runtime-benchmarks = ["polkadot-runtime/runtime-benchmarks", "kusama-runtime/runtime-benchmarks", "westend-runtime/runtime-benchmarks"]
full-node = ["av_store", "consensus", "polkadot-network"]
92 changes: 92 additions & 0 deletions polkadot-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot 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 General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Polkadot service. Specialized wrapper over substrate service.

//pub mod chain_spec;
//mod grandpa_support;
//mod client;

use std::sync::Arc;
use std::time::Duration;
use polkadot_primitives::{parachain, Hash, BlockId, AccountId, Nonce, Balance};
#[cfg(feature = "full-node")]
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
use service::{error::Error as ServiceError, ServiceBuilder};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use sc_executor::native_executor_instance;
use log::info;
pub use service::{
AbstractService, Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis,
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
Configuration, ChainSpec, ServiceBuilderCommand,
};
pub use service::config::{DatabaseConfig, PrometheusConfig};
pub use sc_executor::NativeExecutionDispatch;
pub use sc_client_api::{Backend, ExecutionStrategy, CallExecutor};
pub use sc_consensus::LongestChain;
pub use sp_api::{Core as CoreApi, ConstructRuntimeApi, ProvideRuntimeApi, StateBackend};
pub use sp_runtime::traits::{HashFor, NumberFor};
pub use consensus_common::{SelectChain, BlockImport, block_validation::Chain};
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
pub use polkadot_primitives::Block;
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
pub use polkadot_service::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
#[cfg(feature = "full-node")]
pub use consensus::run_validation_worker;
pub use codec::Codec;
pub use polkadot_runtime;
pub use kusama_runtime;
pub use westend_runtime;
pub use polkadot_test_runtime;
use prometheus_endpoint::Registry;
pub use polkadot_service::PolkadotClient;
pub use polkadot_service::{grandpa_support, new_full, new_full_start, FullNodeHandles, IdentifyVariant, PolkadotExecutor};

/// Create a new Polkadot test service for a full node.
pub fn polkadot_test_new_full(
mut config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
max_block_data_size: Option<u64>,
authority_discovery_enabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
informant_prefix: Option<String>,
)
-> Result<(
impl AbstractService,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
polkadot_test_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (service, client, handles) = new_full!(
config,
collating_for,
max_block_data_size,
authority_discovery_enabled,
slot_duration,
grandpa_pause,
polkadot_test_runtime::RuntimeApi,
PolkadotExecutor,
informant_prefix,
);

Ok((service, client, handles))
}
6 changes: 6 additions & 0 deletions runtime/test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ serde = { version = "1.0.102", default-features = false }
serde_derive = { version = "1.0.102", optional = true }
smallvec = "1.4.0"

authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -27,6 +29,7 @@ version = { package = "sp-version", git = "https://github.com/paritytech/substra
tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

authority-discovery = { package = "pallet-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
authorship = { package = "pallet-authorship", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
balances = { package = "pallet-balances", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -69,6 +72,8 @@ default = ["std"]
no_std = []
only-staking = []
std = [
"authority-discovery-primitives/std",
"authority-discovery/std",
"bitvec/std",
"primitives/std",
"rustc-hex/std",
Expand All @@ -79,6 +84,7 @@ std = [
"sp-api/std",
"tx-pool-api/std",
"block-builder-api/std",
"offchain-primitives/std",
"rstd/std",
"sp-io/std",
"frame-support/std",
Expand Down
1 change: 1 addition & 0 deletions runtime/test-runtime/src/genesismap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl GenesisConfig {
parachains: None,
registrar: None,
vesting: None,
authority_discovery: None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this file anymore. This handled by chain_spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem of dependency then because chain_spec is in polkadot-test-service and polkadot-test-service depends on polkadot-test-runtime

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you are saying?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood this: we don't need the file runtime/test-runtime/src/genesismap.rs because it is handled by the file polkadot-test-service/src/chain_spec.rs.

So I tried to remove this file and replace its use in here by this one but it is not possible because polkadot-test-service uses test-runtime in its dependency and I would need to add polkadot-test-service to test-runtime's dependencies.

};
config.assimilate_storage(&mut storage).expect("Adding `system::GensisConfig` to the genesis");

Expand Down
18 changes: 18 additions & 0 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ use frame_support::{
traits::{KeyOwnerProofSystem, Randomness},
weights::Weight,
};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use session::historical as session_historical;

Expand Down Expand Up @@ -435,6 +436,8 @@ impl offences::Trait for Runtime {
type WeightSoftLimit = OffencesWeightSoftLimit;
}

impl authority_discovery::Trait for Runtime {}

parameter_types! {
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
pub const QueueSize: usize = 2;
Expand Down Expand Up @@ -512,6 +515,7 @@ construct_runtime! {
Historical: session_historical::{Module},
Session: session::{Module, Call, Storage, Event, Config<T>},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
AuthorityDiscovery: authority_discovery::{Module, Call, Config},

// Claims. Usable initially.
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
Expand Down Expand Up @@ -618,6 +622,20 @@ sp_api::impl_runtime_apis! {
}
}

impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(header: &<Block as BlockT>::Header) {
Executive::offchain_worker(header)
}
}

impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> {
// TODO and to fix
//AuthorityDiscovery::authorities()
Vec::new()
}
}

impl parachain::ParachainHost<Block> for Runtime {
fn validators() -> Vec<parachain::ValidatorId> {
Parachains::authorities()
Expand Down
4 changes: 2 additions & 2 deletions service/src/grandpa_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
/// same last finalized block) after a given block at height `N` has been
/// finalized and for a delay of `M` blocks, i.e. until the best block reaches
/// `N` + `M`, the voter will keep voting for block `N`.
pub(crate) struct PauseAfterBlockFor<N>(pub(crate) N, pub(crate) N);
pub struct PauseAfterBlockFor<N>(pub N, pub N);

impl<Block, B> grandpa::VotingRule<Block, B> for PauseAfterBlockFor<NumberFor<Block>> where
Block: BlockT,
Expand Down Expand Up @@ -96,7 +96,7 @@ impl<Block, B> grandpa::VotingRule<Block, B> for PauseAfterBlockFor<NumberFor<Bl
/// intermediary pending changes are replaced with a static list comprised of
/// w3f validators and randomly selected validators from the latest session (at
/// #1500988).
pub(crate) fn kusama_hard_forks() -> Vec<(
pub fn kusama_hard_forks() -> Vec<(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also not be required for tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I am going to fix this as it is inside the macro 🤔 I will think of a way...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

grandpa_primitives::SetId,
(Hash, polkadot_primitives::BlockNumber),
grandpa_primitives::AuthorityList,
Expand Down
11 changes: 7 additions & 4 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Polkadot service. Specialized wrapper over substrate service.

pub mod chain_spec;
mod grandpa_support;
pub mod grandpa_support;
mod client;

use std::sync::Arc;
Expand Down Expand Up @@ -51,6 +51,8 @@ pub use codec::Codec;
pub use polkadot_runtime;
pub use kusama_runtime;
pub use westend_runtime;
#[cfg(feature = "test")]
pub use polkadot_test_runtime;
use prometheus_endpoint::Registry;
pub use self::client::PolkadotClient;

Expand Down Expand Up @@ -136,7 +138,7 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
}

// If we're using prometheus, use a registry with a prefix of `polkadot`.
fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceError> {
pub fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need prometheus in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() {
*registry = Registry::new_custom(Some("polkadot".into()), None)?;
}
Expand All @@ -148,9 +150,10 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
#[macro_export]
macro_rules! new_full_start {
($config:expr, $runtime:ty, $executor:ty, $informant_prefix:expr $(,)?) => {{
set_prometheus_registry(&mut $config)?;
$crate::set_prometheus_registry(&mut $config)?;

let mut import_setup = None;
let mut rpc_setup = None;
Expand Down Expand Up @@ -552,7 +555,7 @@ macro_rules! new_full {
#[macro_export]
macro_rules! new_light {
($config:expr, $runtime:ty, $dispatch:ty) => {{
crate::set_prometheus_registry(&mut $config)?;
$crate::set_prometheus_registry(&mut $config)?;
let inherent_data_providers = inherents::InherentDataProviders::new();

ServiceBuilder::new_light::<Block, $runtime, $dispatch>($config)?
Expand Down