-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Overflow LRU Cache from Exploding (#4801)
* Initial Commit of State LRU Cache * Build State Caches After Reconstruction * Cleanup Duplicated Code in OverflowLRUCache Tests * Added Test for State LRU Cache * Prune Cache of Old States During Maintenance * Address Michael's Comments * Few More Comments * Removed Unused impl * Last touch up * Fix Clippy
- Loading branch information
1 parent
4ad7e15
commit 8660043
Showing
9 changed files
with
577 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
beacon_node/beacon_chain/src/data_availability_checker/error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use kzg::{Error as KzgError, KzgCommitment}; | ||
use strum::IntoStaticStr; | ||
use types::{BeaconStateError, Hash256}; | ||
|
||
#[derive(Debug, IntoStaticStr)] | ||
pub enum Error { | ||
Kzg(KzgError), | ||
KzgNotInitialized, | ||
KzgVerificationFailed, | ||
KzgCommitmentMismatch { | ||
blob_commitment: KzgCommitment, | ||
block_commitment: KzgCommitment, | ||
}, | ||
Unexpected, | ||
SszTypes(ssz_types::Error), | ||
MissingBlobs, | ||
BlobIndexInvalid(u64), | ||
StoreError(store::Error), | ||
DecodeError(ssz::DecodeError), | ||
InconsistentBlobBlockRoots { | ||
block_root: Hash256, | ||
blob_block_root: Hash256, | ||
}, | ||
ParentStateMissing(Hash256), | ||
BlockReplayError(state_processing::BlockReplayError), | ||
RebuildingStateCaches(BeaconStateError), | ||
} | ||
|
||
pub enum ErrorCategory { | ||
/// Internal Errors (not caused by peers) | ||
Internal, | ||
/// Errors caused by faulty / malicious peers | ||
Malicious, | ||
} | ||
|
||
impl Error { | ||
pub fn category(&self) -> ErrorCategory { | ||
match self { | ||
Error::KzgNotInitialized | ||
| Error::SszTypes(_) | ||
| Error::MissingBlobs | ||
| Error::StoreError(_) | ||
| Error::DecodeError(_) | ||
| Error::Unexpected | ||
| Error::ParentStateMissing(_) | ||
| Error::BlockReplayError(_) | ||
| Error::RebuildingStateCaches(_) => ErrorCategory::Internal, | ||
Error::Kzg(_) | ||
| Error::BlobIndexInvalid(_) | ||
| Error::KzgCommitmentMismatch { .. } | ||
| Error::KzgVerificationFailed | ||
| Error::InconsistentBlobBlockRoots { .. } => ErrorCategory::Malicious, | ||
} | ||
} | ||
} | ||
|
||
impl From<ssz_types::Error> for Error { | ||
fn from(value: ssz_types::Error) -> Self { | ||
Self::SszTypes(value) | ||
} | ||
} | ||
|
||
impl From<store::Error> for Error { | ||
fn from(value: store::Error) -> Self { | ||
Self::StoreError(value) | ||
} | ||
} | ||
|
||
impl From<ssz::DecodeError> for Error { | ||
fn from(value: ssz::DecodeError) -> Self { | ||
Self::DecodeError(value) | ||
} | ||
} | ||
|
||
impl From<state_processing::BlockReplayError> for Error { | ||
fn from(value: state_processing::BlockReplayError) -> Self { | ||
Self::BlockReplayError(value) | ||
} | ||
} |
Oops, something went wrong.