mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Spawn an async test per P2P message to try and resolve latency issues
This commit is contained in:
@@ -399,6 +399,8 @@ impl<D: Db, T: TransactionTrait, P: P2p> Network for TendermintNetwork<D, T, P>
|
||||
hex::encode(hash),
|
||||
hex::encode(self.genesis)
|
||||
);
|
||||
// TODO: Use a notification system for when we have a new provided, in order to minimize
|
||||
// latency
|
||||
sleep(Duration::from_secs(Self::block_time().into())).await;
|
||||
}
|
||||
_ => return invalid_block(),
|
||||
|
||||
@@ -189,8 +189,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||
// Push it on to the queue. This is done so we only handle one message at a time, and so we
|
||||
// can handle our own message before broadcasting it. That way, we fail before before
|
||||
// becoming malicious
|
||||
// push_front to prioritize our own messages
|
||||
self.queue.push_front(msg);
|
||||
self.queue.push_back(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,6 +219,12 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||
// Sleep until this round ends
|
||||
let round_end = self.block.end_time[&end_round];
|
||||
let time_until_round_end = round_end.instant().saturating_duration_since(Instant::now());
|
||||
if time_until_round_end == Duration::ZERO {
|
||||
log::trace!(
|
||||
"resetting when prior round ended {}ms ago",
|
||||
Instant::now().saturating_duration_since(round_end.instant()).as_millis(),
|
||||
);
|
||||
}
|
||||
log::trace!("sleeping until round ends in {}ms", time_until_round_end.as_millis());
|
||||
sleep(time_until_round_end).await;
|
||||
|
||||
@@ -575,6 +580,13 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||
Err(TendermintError::Temporal)?;
|
||||
}
|
||||
|
||||
if (msg.block == self.block.number) &&
|
||||
(msg.round == self.block.round().number) &&
|
||||
(msg.data.step() == Step::Propose)
|
||||
{
|
||||
log::trace!("received Propose for block {}, round {}", msg.block.0, msg.round.0);
|
||||
}
|
||||
|
||||
// If this is a precommit, verify its signature
|
||||
self.verify_precommit_signature(signed)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user