Skip to content
Snippets Groups Projects
Unverified Commit 6a6e6240 authored by Wei Tang's avatar Wei Tang Committed by GitHub
Browse files

Add a short-lived public testnet (#71)

parent 00aba960
Branches
No related merge requests found
Pipeline #30906 passed with stages
in 6 minutes and 56 seconds
......@@ -42,7 +42,7 @@ use client::block_builder::api::BlockBuilder as BlockBuilderApi;
use runtime::UncheckedExtrinsic;
use runtime::utils::epoch_to_slot;
use runtime_primitives::{generic::BlockId, Justification, RuntimeString};
use runtime_primitives::traits::{Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, NumberFor};
use runtime_primitives::traits::{Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi};
use primitives::{ValidatorId, H256, Slot, Epoch, BlockNumber, UnsignedAttestation};
use aura_slots::{SlotCompatible, CheckedHeader, SlotWorker, SlotInfo};
use inherents::InherentDataProviders;
......@@ -180,7 +180,7 @@ pub fn start_shasper<B, C, E, I, SO, P, Error, OnExit>(
inherent_data_providers: InherentDataProviders,
) -> Result<impl Future<Item=(), Error=()>, consensus_common::Error> where
B: Block<Hash=H256, Extrinsic=UncheckedExtrinsic>,
NumberFor<B>: From<BlockNumber>,
B::Header: Header<Number=BlockNumber>,
C: Authorities<B> + ChainHead<B> + HeaderBackend<B> + AuxStore + ProvideRuntimeApi,
C::Api: ShasperApi<B>,
B::Extrinsic: CompatibleExtrinsic,
......@@ -228,7 +228,7 @@ struct ShasperWorker<C, E, I, P: PoolChainApi> {
impl<B: Block<Hash=H256, Extrinsic=UncheckedExtrinsic>, C, E, I, P, Error> SlotWorker<B> for ShasperWorker<C, E, I, P> where
C: Authorities<B> + ChainHead<B> + HeaderBackend<B> + ProvideRuntimeApi,
C::Api: ShasperApi<B>,
NumberFor<B>: From<BlockNumber>,
B::Header: Header<Number=BlockNumber>,
E: Environment<B, Error=Error>,
E::Proposer: Proposer<B, Error=Error>,
<<E::Proposer as Proposer<B>>::Create as IntoFuture>::Future: Send + 'static,
......@@ -261,7 +261,7 @@ impl<B: Block<Hash=H256, Extrinsic=UncheckedExtrinsic>, C, E, I, P, Error> SlotW
slot_info: SlotInfo,
) -> Self::OnSlot {
let public_key = self.local_key.public.clone();
let (timestamp, slot_num, slot_duration) =
let (timestamp, _, slot_duration) =
(slot_info.timestamp, slot_info.number, slot_info.duration);
let authorities = match self.client.authorities(&BlockId::Hash(chain_head.hash())) {
......@@ -287,8 +287,11 @@ impl<B: Block<Hash=H256, Extrinsic=UncheckedExtrinsic>, C, E, I, P, Error> SlotW
return Box::new(future::ok(()));
},
};
let slot_num = current_slot;
let current_epoch = runtime::utils::slot_to_epoch(current_slot);
debug!(target: "shasper", "Current slot is {}", current_slot);
if *self.last_proposed_epoch.lock() < current_epoch {
debug!(target: "shasper", "Last proposed epoch {} is less than current epoch {}, submitting a new attestation", *self.last_proposed_epoch.lock(), current_epoch);
let validator_id = ValidatorId::from_public(public_key.clone());
......
......@@ -33,6 +33,8 @@ pub enum Alternative {
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
/// Weekly short-lived public testnet.
PublicShortLived
}
impl Alternative {
......@@ -85,6 +87,28 @@ impl Alternative {
None,
None
),
Alternative::PublicShortLived => ChainSpec::from_genesis(
"Public Short-lived Testnet",
"short-lived",
|| {
use std::str::FromStr;
let alice_id = ValidatorId::from_str("8e9bed908372adcb328d242bc0f03fa527a232d2c7e81daa8b350a7593cf5c89a62795909ef18ed09cf8e24123076ce9").expect("Preloaded key is valid; qed");
let bob_id = ValidatorId::from_str("a5908e909329db6e5ba9083aae10b6b1dd9341ed6f70f3395a59b944b059737cbce745664fb31f087c6d5f74756619a3").expect("Preloaded key is valid; qed");
testnet_genesis(
vec![
alice_id,
bob_id,
]
)
},
vec![],
None,
None,
None,
None
),
})
}
......@@ -92,6 +116,7 @@ impl Alternative {
match s {
"dev" => Some(Alternative::Development),
"local" => Some(Alternative::LocalTestnet),
"short-lived" => Some(Alternative::PublicShortLived),
_ => None,
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment