## Issue Addressed Closes #2119 ## Proposed Changes Update the slasher schema version to v2 for the breaking changes to the config introduced in #2079. Implement a migration from v1 to v2 so that users can seamlessly upgrade from any version of Lighthouse <=1.0.5. Users who deleted their database for v1.0.5 can upgrade to a release including this patch without any manual intervention. Similarly, any users still on v1.0.4 or earlier can now upgrade without having to drop their database.
89 lines
2.0 KiB
Rust
89 lines
2.0 KiB
Rust
use crate::Config;
|
|
use std::io;
|
|
use types::{Epoch, Hash256};
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
DatabaseError(lmdb::Error),
|
|
DatabaseIOError(io::Error),
|
|
SszDecodeError(ssz::DecodeError),
|
|
BincodeError(bincode::Error),
|
|
ArithError(safe_arith::ArithError),
|
|
ChunkIndexOutOfBounds(usize),
|
|
IncompatibleSchemaVersion {
|
|
database_schema_version: u64,
|
|
software_schema_version: u64,
|
|
},
|
|
ConfigInvalidChunkSize {
|
|
chunk_size: usize,
|
|
history_length: usize,
|
|
},
|
|
ConfigInvalidZeroParameter {
|
|
config: Config,
|
|
},
|
|
ConfigIncompatible {
|
|
on_disk_config: Config,
|
|
config: Config,
|
|
},
|
|
ConfigMissing,
|
|
DistanceTooLarge,
|
|
DistanceCalculationOverflow,
|
|
/// Missing an attester record that we expected to exist.
|
|
MissingAttesterRecord {
|
|
validator_index: u64,
|
|
target_epoch: Epoch,
|
|
},
|
|
AttesterRecordCorrupt {
|
|
length: usize,
|
|
},
|
|
AttesterKeyCorrupt {
|
|
length: usize,
|
|
},
|
|
ProposerKeyCorrupt {
|
|
length: usize,
|
|
},
|
|
IndexedAttestationKeyCorrupt {
|
|
length: usize,
|
|
},
|
|
MissingIndexedAttestation {
|
|
root: Hash256,
|
|
},
|
|
MissingAttesterKey,
|
|
MissingProposerKey,
|
|
MissingIndexedAttestationKey,
|
|
AttesterRecordInconsistentRoot,
|
|
}
|
|
|
|
impl From<lmdb::Error> for Error {
|
|
fn from(e: lmdb::Error) -> Self {
|
|
match e {
|
|
lmdb::Error::Other(os_error) => Error::from(io::Error::from_raw_os_error(os_error)),
|
|
_ => Error::DatabaseError(e),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<io::Error> for Error {
|
|
fn from(e: io::Error) -> Self {
|
|
Error::DatabaseIOError(e)
|
|
}
|
|
}
|
|
|
|
impl From<ssz::DecodeError> for Error {
|
|
fn from(e: ssz::DecodeError) -> Self {
|
|
Error::SszDecodeError(e)
|
|
}
|
|
}
|
|
|
|
impl From<bincode::Error> for Error {
|
|
fn from(e: bincode::Error) -> Self {
|
|
Error::BincodeError(e)
|
|
}
|
|
}
|
|
|
|
impl From<safe_arith::ArithError> for Error {
|
|
fn from(e: safe_arith::ArithError) -> Self {
|
|
Error::ArithError(e)
|
|
}
|
|
}
|