mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 20:59:23 +00:00
More misc bug fixes
This commit is contained in:
@@ -3,6 +3,7 @@ use std::{
|
|||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
task::{Poll, Context},
|
task::{Poll, Context},
|
||||||
future::Future,
|
future::Future,
|
||||||
|
time::{UNIX_EPOCH, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
use sp_core::Decode;
|
use sp_core::Decode;
|
||||||
@@ -126,7 +127,7 @@ where
|
|||||||
)
|
)
|
||||||
.map(|commit| commit.end_time)
|
.map(|commit| commit.end_time)
|
||||||
// TODO: Genesis start time
|
// TODO: Genesis start time
|
||||||
.unwrap_or(0),
|
.unwrap_or_else(|_| SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()),
|
||||||
),
|
),
|
||||||
import_clone
|
import_clone
|
||||||
.get_proposal(&import_clone.client.header(BlockId::Number(0u8.into())).unwrap().unwrap())
|
.get_proposal(&import_clone.client.header(BlockId::Number(0u8.into())).unwrap().unwrap())
|
||||||
|
|||||||
@@ -367,6 +367,10 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
msg: Message<N::ValidatorId, N::Block, <N::SignatureScheme as SignatureScheme>::Signature>,
|
msg: Message<N::ValidatorId, N::Block, <N::SignatureScheme as SignatureScheme>::Signature>,
|
||||||
) -> Result<Option<N::Block>, TendermintError<N::ValidatorId>> {
|
) -> 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
|
// Verify the end time and signature if this is a precommit
|
||||||
if let Data::Precommit(Some((id, sig))) = &msg.data {
|
if let Data::Precommit(Some((id, sig))) = &msg.data {
|
||||||
if !self.signer.verify(
|
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
|
// Only let the proposer propose
|
||||||
if matches!(msg.data, Data::Proposal(..)) &&
|
if matches!(msg.data, Data::Proposal(..)) &&
|
||||||
(msg.sender != self.weights.proposer(msg.number, msg.round))
|
(msg.sender != self.weights.proposer(msg.number, msg.round))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{SystemTime, Duration},
|
time::{UNIX_EPOCH, SystemTime, Duration},
|
||||||
};
|
};
|
||||||
|
|
||||||
use parity_scale_codec::{Encode, Decode};
|
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");
|
dbg!("Slash");
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ impl TestNetwork {
|
|||||||
write.push(TendermintMachine::new(
|
write.push(TendermintMachine::new(
|
||||||
TestNetwork(i, arc.clone()),
|
TestNetwork(i, arc.clone()),
|
||||||
i,
|
i,
|
||||||
(BlockNumber(1), SystemTime::now()),
|
(BlockNumber(1), (SystemTime::now().duration_since(UNIX_EPOCH)).unwrap().as_secs()),
|
||||||
TestBlock { id: 1u32.to_le_bytes(), valid: Ok(()) },
|
TestBlock { id: 1u32.to_le_bytes(), valid: Ok(()) },
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user