-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add block ban flag --invalid-block-roots
#7042
base: release-v7.0.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ use std::borrow::Cow; | |
use std::fmt::Debug; | ||
use std::fs; | ||
use std::io::Write; | ||
use std::str::FromStr; | ||
use std::sync::Arc; | ||
use store::{Error as DBError, HotStateSummary, KeyValueStore, StoreOp}; | ||
use strum::AsRefStr; | ||
|
@@ -146,7 +147,9 @@ pub enum BlockError { | |
/// | ||
/// It's unclear if this block is valid, but it cannot be processed without already knowing | ||
/// its parent. | ||
ParentUnknown { parent_root: Hash256 }, | ||
ParentUnknown { | ||
parent_root: Hash256, | ||
}, | ||
/// The block slot is greater than the present slot. | ||
/// | ||
/// ## Peer scoring | ||
|
@@ -161,7 +164,10 @@ pub enum BlockError { | |
/// ## Peer scoring | ||
/// | ||
/// The peer has incompatible state transition logic and is faulty. | ||
StateRootMismatch { block: Hash256, local: Hash256 }, | ||
StateRootMismatch { | ||
block: Hash256, | ||
local: Hash256, | ||
}, | ||
/// The block was a genesis block, these blocks cannot be re-imported. | ||
GenesisBlock, | ||
/// The slot is finalized, no need to import. | ||
|
@@ -180,7 +186,9 @@ pub enum BlockError { | |
/// | ||
/// It's unclear if this block is valid, but it conflicts with finality and shouldn't be | ||
/// imported. | ||
NotFinalizedDescendant { block_parent_root: Hash256 }, | ||
NotFinalizedDescendant { | ||
block_parent_root: Hash256, | ||
}, | ||
/// Block is already known and valid, no need to re-import. | ||
/// | ||
/// ## Peer scoring | ||
|
@@ -207,7 +215,10 @@ pub enum BlockError { | |
/// ## Peer scoring | ||
/// | ||
/// The block is invalid and the peer is faulty. | ||
IncorrectBlockProposer { block: u64, local_shuffling: u64 }, | ||
IncorrectBlockProposer { | ||
block: u64, | ||
local_shuffling: u64, | ||
}, | ||
/// The `block.proposal_index` is not known. | ||
/// | ||
/// ## Peer scoring | ||
|
@@ -225,7 +236,10 @@ pub enum BlockError { | |
/// ## Peer scoring | ||
/// | ||
/// The block is invalid and the peer is faulty. | ||
BlockIsNotLaterThanParent { block_slot: Slot, parent_slot: Slot }, | ||
BlockIsNotLaterThanParent { | ||
block_slot: Slot, | ||
parent_slot: Slot, | ||
}, | ||
/// At least one block in the chain segment did not have it's parent root set to the root of | ||
/// the prior block. | ||
/// | ||
|
@@ -281,7 +295,10 @@ pub enum BlockError { | |
/// If it's actually our fault (e.g. our execution node database is corrupt) we have bigger | ||
/// problems to worry about than losing peers, and we're doing the network a favour by | ||
/// disconnecting. | ||
ParentExecutionPayloadInvalid { parent_root: Hash256 }, | ||
ParentExecutionPayloadInvalid { | ||
parent_root: Hash256, | ||
}, | ||
KnownInvalidExecutionPayload(Hash256), | ||
/// The block is a slashable equivocation from the proposer. | ||
/// | ||
/// ## Peer scoring | ||
|
@@ -1326,6 +1343,19 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> { | |
chain: &Arc<BeaconChain<T>>, | ||
notify_execution_layer: NotifyExecutionLayer, | ||
) -> Result<Self, BlockError> { | ||
let invalid_holesky_block = { | ||
if let Ok(invalid_block_root) = Hash256::from_str( | ||
"2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f359", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional to hardcode a block here? You can add this block root in the default value of the CLI flag invalid_block_roots |
||
) { | ||
block_root == invalid_block_root && chain.spec.deposit_chain_id == 17000 | ||
} else { | ||
false | ||
} | ||
}; | ||
if chain.config.invalid_block_roots.contains(&block_root) || invalid_holesky_block { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag can be exploited for censoring, you should restrict usage to a specific network |
||
return Err(BlockError::KnownInvalidExecutionPayload(block_root)); | ||
} | ||
|
||
chain | ||
.observed_slashable | ||
.write() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment on top of this variant to have same format