Skip to content

Commit

Permalink
Stage/testnet v0.9.2 (paritytech#335)
Browse files Browse the repository at this point in the history
* Update chainpool/substrate to 6244ecd

* remove panic in service start for get pub key from storage

* Update chainpool/substrate to fe056d3

* promote runtime log print

* Filter these have set up trustee based on the candidates of validators (paritytech#334)

Close paritytech#333

* update version

* 2 sessions_per_era for now
  • Loading branch information
liuchengxu authored Feb 23, 2019
1 parent c00b1bb commit 48bdbff
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 122 deletions.
99 changes: 50 additions & 49 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx"
version = "0.9.2"
version = "0.9.3"
build = "build.rs"
authors = ["Chainpool <https://www.chainx.org>"]

Expand Down
2 changes: 1 addition & 1 deletion cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn local_testnet_genesis() -> GenesisConfig {
/// Local testnet config (multivalidator Alice + Bob)
pub fn local_testnet_config() -> ChainSpec {
ChainSpec::from_genesis(
"ChainX V0.9.2",
"ChainX V0.9.3",
"chainx_testnet",
local_testnet_genesis,
vec![],
Expand Down
Binary file modified cli/src/chainx_runtime_wasm.compact.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions cli/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
let gavin = ed25519::Pair::from_seed(b"Gavin ").public();
let satoshi = ed25519::Pair::from_seed(b"Satoshi ").public();
let funding = hex!["c4387fd74bc774db3f9a2f6ea37b99218b1412677f20e25df4ff9043ed54e9ce"].into();
let sudo_address = hex!["c4387fd74bc774db3f9a2f6ea37b99218b1412677f20e25df4ff9043ed54e9ce"].into();
let sudo_address =
hex!["c4387fd74bc774db3f9a2f6ea37b99218b1412677f20e25df4ff9043ed54e9ce"].into();

let auth1 = alice.into();
let auth2 = bob.into();
Expand Down Expand Up @@ -144,7 +145,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
.collect::<Vec<_>>();

let blocks_per_session = 150; // 150 blocks per session
let sessions_per_era = 12; // update validators set per 12 sessions
let sessions_per_era = 2; // update validators set per 12 sessions
let sessions_per_epoch = sessions_per_era * 10; // update trustees set per 12*10 sessions
let bonding_duration = blocks_per_session * sessions_per_era; // freeze 150*12 blocks for non-intention
let intention_bonding_duration = bonding_duration * 10; // freeze 150*12*10 blocks for intention
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where

if config.roles == ServiceRoles::AUTHORITY {
let name = custom_args.validator_name.expect("if in AUTHORITY mode, must point the validator name!");
info!("Validator name: {:?}", name);
info!("Validator name: {:}", name);
set_validator_name(name);
}

Expand Down
36 changes: 21 additions & 15 deletions cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,34 @@ construct_service_factory! {
// use validator name to get accountid and sessionkey from runtime storage
let name = get_validator_name().expect("must get validator name is AUTHORITY mode");
let best_hash = client.info()?.chain.best_hash;
let (accountid, sessionkey_option) = client
let ret = client
.runtime_api()
.pubkeys_for_validator_name(&BlockId::Hash(best_hash), name.as_bytes().to_vec())
.expect(&format!("can't get accountid for this name:[{:}]", name))
.expect(&format!("can't get accountid for this name:[{:}]", name));
if accountid != accountid_from_localkey {
if let Some(sessionkey) = sessionkey_option {
let sessionkey: AccountId = sessionkey.into();
if sessionkey != accountid_from_localkey {
error!("the sessionkey is not equal to local_key, sessionkey:[{:}], local_key:[{:?}]", sessionkey, accountid_from_localkey);
panic!("he sessionkey is not equal to local_key");
.expect("access runtime data error");

let producer = if let Some((accountid, sessionkey_option)) = ret {
// check, only print warning log
if accountid != accountid_from_localkey {
if let Some(sessionkey) = sessionkey_option {
let sessionkey: AccountId = sessionkey.into();
if sessionkey != accountid_from_localkey {
warn!("the sessionkey is not equal to local_key, sessionkey:[{:}], local_key:[{:?}]", sessionkey, accountid_from_localkey);
}
} else {
warn!("the accountid is not equal to local_key, accountid:[{:}], local_key:[{:?}]", accountid, accountid_from_localkey);
}
}
// anyway, return accountid as producer
accountid
} else {
error!("the accountid is not equal to local_key, accountid:[{:}], local_key:[{:?}]", accountid, accountid_from_localkey);
panic!("the accountid is not equal to local_key");
}
}
// do not get accountid from local state database, use localkey as producer
warn!("validator name[{:}] is not in current state, use --key|keystore's pri to pub as producer", name);
accountid_from_localkey
};

// set blockproducer for accountid

service.config.custom.inherent_data_providers
.register_provider(XSystemInherentDataProvider::new(&accountid)).expect("blockproducer set err; qed");
.register_provider(XSystemInherentDataProvider::new(&producer)).expect("blockproducer set err; qed");

executor.spawn(start_aura(
SlotDuration::get_or_compute(&*client)?,
Expand Down
62 changes: 31 additions & 31 deletions runtime/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Loading

0 comments on commit 48bdbff

Please sign in to comment.