Independence of Slot-based algorithms from system Timestamp (#12224)

* Remove timestamp from SlotInfo

* Expose as millis instead of secs

* Nits

* Fix test after field removal

* Yet another test fix

* On the fly timestamp computation

* Removed slot timestamp from logs

* Removed reference to timestamp from slots subsystem

* Slot based algorithm tests do not require timstamp inherent anymore

* Remove junk files

* Further tests cleanup

* Trigger pipeline

* Apply code suggestions

* Trigger pipeline

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Davide Galassi
2022-09-23 19:51:57 +02:00
committed by GitHub
parent 71438160a1
commit bf97f2a702
9 changed files with 56 additions and 97 deletions
+11 -15
View File
@@ -569,7 +569,7 @@ mod tests {
traits::{Block as BlockT, Header as _},
Digest,
};
use sp_timestamp::InherentDataProvider as TimestampInherentDataProvider;
use sp_timestamp::Timestamp;
use std::{
task::Poll,
time::{Duration, Instant},
@@ -579,6 +579,8 @@ mod tests {
TestClient,
};
const SLOT_DURATION_MS: u64 = 1000;
type Error = sp_blockchain::Error;
struct DummyFactory(Arc<TestClient>);
@@ -619,8 +621,6 @@ mod tests {
}
}
const SLOT_DURATION: u64 = 1000;
type AuraVerifier = import_queue::AuraVerifier<
PeersFullClient,
AuthorityPair,
@@ -628,7 +628,7 @@ mod tests {
dyn CreateInherentDataProviders<
TestBlock,
(),
InherentDataProviders = (TimestampInherentDataProvider, InherentDataProvider),
InherentDataProviders = (InherentDataProvider,),
>,
>,
>;
@@ -648,17 +648,15 @@ mod tests {
let client = client.as_client();
let slot_duration = slot_duration(&*client).expect("slot duration available");
assert_eq!(slot_duration.as_millis() as u64, SLOT_DURATION);
assert_eq!(slot_duration.as_millis() as u64, SLOT_DURATION_MS);
import_queue::AuraVerifier::new(
client,
Box::new(|_, _| async {
let timestamp = TimestampInherentDataProvider::from_system_time();
let slot = InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
SlotDuration::from_millis(6000),
Timestamp::current(),
SlotDuration::from_millis(SLOT_DURATION_MS),
);
Ok((timestamp, slot))
Ok((slot,))
}),
CheckForEquivocation::Yes,
None,
@@ -736,13 +734,12 @@ mod tests {
sync_oracle: DummyOracle,
justification_sync_link: (),
create_inherent_data_providers: |_, _| async {
let timestamp = TimestampInherentDataProvider::from_system_time();
let slot = InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
SlotDuration::from_millis(6000),
Timestamp::current(),
SlotDuration::from_millis(SLOT_DURATION_MS),
);
Ok((timestamp, slot))
Ok((slot,))
},
force_authoring: false,
backoff_authoring_blocks: Some(
@@ -875,7 +872,6 @@ mod tests {
let res = executor::block_on(worker.on_slot(SlotInfo {
slot: 0.into(),
timestamp: 0.into(),
ends_at: Instant::now() + Duration::from_secs(100),
inherent_data: InherentData::new(),
duration: Duration::from_millis(1000),