More misc bug fixes

This commit is contained in:
Luke Parker 2022-10-24 06:18:16 -04:00
parent 05be5c14c3
commit 9b8f2f4487
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
3 changed files with 9 additions and 8 deletions

View file

@ -3,6 +3,7 @@ use std::{
sync::{Arc, RwLock},
task::{Poll, Context},
future::Future,
time::{UNIX_EPOCH, SystemTime},
};
use sp_core::Decode;
@ -126,7 +127,7 @@ where
)
.map(|commit| commit.end_time)
// TODO: Genesis start time
.unwrap_or(0),
.unwrap_or_else(|_| SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()),
),
import_clone
.get_proposal(&import_clone.client.header(BlockId::Number(0u8.into())).unwrap().unwrap())

View file

@ -367,6 +367,10 @@ impl<N: Network + 'static> TendermintMachine<N> {
&mut self,
msg: Message<N::ValidatorId, N::Block, <N::SignatureScheme as SignatureScheme>::Signature>,
) -> Result<Option<N::Block>, TendermintError<N::ValidatorId>> {
if msg.number != self.number {
Err(TendermintError::Temporal)?;
}
// Verify the end time and signature if this is a precommit
if let Data::Precommit(Some((id, sig))) = &msg.data {
if !self.signer.verify(
@ -379,10 +383,6 @@ impl<N: Network + 'static> TendermintMachine<N> {
}
}
if msg.number != self.number {
Err(TendermintError::Temporal)?;
}
// Only let the proposer propose
if matches!(msg.data, Data::Proposal(..)) &&
(msg.sender != self.weights.proposer(msg.number, msg.round))

View file

@ -1,6 +1,6 @@
use std::{
sync::Arc,
time::{SystemTime, Duration},
time::{UNIX_EPOCH, SystemTime, Duration},
};
use parity_scale_codec::{Encode, Decode};
@ -104,7 +104,7 @@ impl Network for TestNetwork {
}
}
async fn slash(&mut self, validator: TestValidatorId) {
async fn slash(&mut self, _: TestValidatorId) {
dbg!("Slash");
todo!()
}
@ -135,7 +135,7 @@ impl TestNetwork {
write.push(TendermintMachine::new(
TestNetwork(i, arc.clone()),
i,
(BlockNumber(1), SystemTime::now()),
(BlockNumber(1), (SystemTime::now().duration_since(UNIX_EPOCH)).unwrap().as_secs()),
TestBlock { id: 1u32.to_le_bytes(), valid: Ok(()) },
));
}