Move Commit from including the round to including the round's end_time

The round was usable to build the current clock in an accumulated 
fashion, relative to the previous round. The end time is the absolute 
metric of it, which can be used to calculate the round number (with all 
previous end times).

Substrate now builds off the best block, not genesis, using the end time 
included in the justification to start its machine in a synchronized 
state.

Knowing the end time of a round, or the round in which block was 
committed to, is necessary for nodes to sync up with Tendermint. 
Encoding it in the commit ensures it's long lasting and makes it readily 
available, without the load of an entire transaction.
This commit is contained in:
Luke Parker
2022-10-24 05:28:21 -04:00
parent b9c091c5d0
commit a7f4804749
4 changed files with 69 additions and 19 deletions

View File

@@ -24,7 +24,7 @@ use sp_consensus::{Error, BlockOrigin, Proposer, Environment};
use sc_consensus::{ForkChoiceStrategy, BlockImportParams, BlockImport, import_queue::IncomingBlock};
use sc_service::ImportQueue;
use sc_client_api::{Backend, Finalizer};
use sc_client_api::{BlockBackend, Backend, Finalizer};
use tendermint_machine::{
ext::{BlockError, Commit, Network},
@@ -43,6 +43,7 @@ pub trait TendermintClient<B: Block, Be: Backend<B> + 'static>:
Send
+ Sync
+ HeaderBackend<B>
+ BlockBackend<B>
+ BlockImport<B, Transaction = TransactionFor<Self, B>>
+ Finalizer<B, Be>
+ ProvideRuntimeApi<B>
@@ -55,6 +56,7 @@ impl<
C: Send
+ Sync
+ HeaderBackend<B>
+ BlockBackend<B>
+ BlockImport<B, Transaction = TransactionFor<C, B>>
+ Finalizer<B, Be>
+ ProvideRuntimeApi<B>
@@ -379,8 +381,8 @@ where
let info = self.client.info();
assert_eq!(info.best_hash, parent);
assert_eq!(info.finalized_hash, parent);
assert_eq!(info.best_number, number - 1);
assert_eq!(info.finalized_number, number - 1);
assert_eq!(info.best_number, number - 1u8.into());
assert_eq!(info.finalized_number, number - 1u8.into());
}
Ok(())