mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -4,10 +4,10 @@ use crate::interchange::{
|
||||
};
|
||||
use crate::signed_attestation::InvalidAttestation;
|
||||
use crate::signed_block::InvalidBlock;
|
||||
use crate::{signing_root_from_row, NotSafe, Safe, SignedAttestation, SignedBlock, SigningRoot};
|
||||
use crate::{NotSafe, Safe, SignedAttestation, SignedBlock, SigningRoot, signing_root_from_row};
|
||||
use filesystem::restrict_file_permissions;
|
||||
use r2d2_sqlite::SqliteConnectionManager;
|
||||
use rusqlite::{params, OptionalExtension, Transaction, TransactionBehavior};
|
||||
use rusqlite::{OptionalExtension, Transaction, TransactionBehavior, params};
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
@@ -356,15 +356,15 @@ impl SlashingDatabase {
|
||||
.prepare("SELECT MIN(slot) FROM signed_blocks WHERE validator_id = ?1")?
|
||||
.query_row(params![validator_id], |row| row.get(0))?;
|
||||
|
||||
if let Some(min_slot) = min_slot {
|
||||
if slot <= min_slot {
|
||||
return Err(NotSafe::InvalidBlock(
|
||||
InvalidBlock::SlotViolatesLowerBound {
|
||||
block_slot: slot,
|
||||
bound_slot: min_slot,
|
||||
},
|
||||
));
|
||||
}
|
||||
if let Some(min_slot) = min_slot
|
||||
&& slot <= min_slot
|
||||
{
|
||||
return Err(NotSafe::InvalidBlock(
|
||||
InvalidBlock::SlotViolatesLowerBound {
|
||||
block_slot: slot,
|
||||
bound_slot: min_slot,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Safe::Valid)
|
||||
@@ -467,30 +467,30 @@ impl SlashingDatabase {
|
||||
.prepare("SELECT MIN(source_epoch) FROM signed_attestations WHERE validator_id = ?1")?
|
||||
.query_row(params![validator_id], |row| row.get(0))?;
|
||||
|
||||
if let Some(min_source) = min_source {
|
||||
if att_source_epoch < min_source {
|
||||
return Err(NotSafe::InvalidAttestation(
|
||||
InvalidAttestation::SourceLessThanLowerBound {
|
||||
source_epoch: att_source_epoch,
|
||||
bound_epoch: min_source,
|
||||
},
|
||||
));
|
||||
}
|
||||
if let Some(min_source) = min_source
|
||||
&& att_source_epoch < min_source
|
||||
{
|
||||
return Err(NotSafe::InvalidAttestation(
|
||||
InvalidAttestation::SourceLessThanLowerBound {
|
||||
source_epoch: att_source_epoch,
|
||||
bound_epoch: min_source,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
let min_target = txn
|
||||
.prepare("SELECT MIN(target_epoch) FROM signed_attestations WHERE validator_id = ?1")?
|
||||
.query_row(params![validator_id], |row| row.get(0))?;
|
||||
|
||||
if let Some(min_target) = min_target {
|
||||
if att_target_epoch <= min_target {
|
||||
return Err(NotSafe::InvalidAttestation(
|
||||
InvalidAttestation::TargetLessThanOrEqLowerBound {
|
||||
target_epoch: att_target_epoch,
|
||||
bound_epoch: min_target,
|
||||
},
|
||||
));
|
||||
}
|
||||
if let Some(min_target) = min_target
|
||||
&& att_target_epoch <= min_target
|
||||
{
|
||||
return Err(NotSafe::InvalidAttestation(
|
||||
InvalidAttestation::TargetLessThanOrEqLowerBound {
|
||||
target_epoch: att_target_epoch,
|
||||
bound_epoch: min_target,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Everything has been checked, return Valid
|
||||
@@ -1218,9 +1218,10 @@ mod tests {
|
||||
assert_eq!(db.conn_pool.max_size(), POOL_SIZE);
|
||||
assert_eq!(db.conn_pool.connection_timeout(), CONNECTION_TIMEOUT);
|
||||
let conn = db.conn_pool.get().unwrap();
|
||||
assert!(conn
|
||||
.pragma_query_value(None, "foreign_keys", |row| { row.get::<_, bool>(0) })
|
||||
.unwrap());
|
||||
assert!(
|
||||
conn.pragma_query_value(None, "foreign_keys", |row| { row.get::<_, bool>(0) })
|
||||
.unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
conn.pragma_query_value(None, "locking_mode", |row| { row.get::<_, String>(0) })
|
||||
.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user