Merge branch 'unstable' into deneb-free-blobs

# Conflicts:
#	.github/workflows/docker.yml
#	.github/workflows/local-testnet.yml
#	.github/workflows/test-suite.yml
#	Cargo.lock
#	Cargo.toml
#	beacon_node/beacon_chain/src/beacon_chain.rs
#	beacon_node/beacon_chain/src/builder.rs
#	beacon_node/beacon_chain/src/test_utils.rs
#	beacon_node/execution_layer/src/engine_api/json_structures.rs
#	beacon_node/network/src/beacon_processor/mod.rs
#	beacon_node/network/src/beacon_processor/worker/gossip_methods.rs
#	beacon_node/network/src/sync/backfill_sync/mod.rs
#	beacon_node/store/src/config.rs
#	beacon_node/store/src/hot_cold_store.rs
#	common/eth2_network_config/Cargo.toml
#	consensus/ssz/src/decode/impls.rs
#	consensus/ssz_derive/src/lib.rs
#	consensus/ssz_derive/tests/tests.rs
#	consensus/ssz_types/src/serde_utils/mod.rs
#	consensus/tree_hash/src/impls.rs
#	consensus/tree_hash/src/lib.rs
#	consensus/types/Cargo.toml
#	consensus/types/src/beacon_state.rs
#	consensus/types/src/chain_spec.rs
#	consensus/types/src/eth_spec.rs
#	consensus/types/src/fork_name.rs
#	lcli/Cargo.toml
#	lcli/src/main.rs
#	lcli/src/new_testnet.rs
#	scripts/local_testnet/el_bootnode.sh
#	scripts/local_testnet/genesis.json
#	scripts/local_testnet/geth.sh
#	scripts/local_testnet/setup.sh
#	scripts/local_testnet/start_local_testnet.sh
#	scripts/local_testnet/vars.env
#	scripts/tests/doppelganger_protection.sh
#	scripts/tests/genesis.json
#	scripts/tests/vars.env
#	testing/ef_tests/Cargo.toml
#	validator_client/src/block_service.rs
This commit is contained in:
Jimmy Chen
2023-05-30 11:26:33 +10:00
333 changed files with 5930 additions and 13386 deletions

View File

@@ -13,15 +13,15 @@ tokio = { version = "1.14.0", features = ["rt-multi-thread"] }
bls = { path = "../../crypto/bls" }
integer-sqrt = "0.1.5"
itertools = "0.10.0"
eth2_ssz = "0.4.1"
eth2_ssz_derive = "0.3.1"
eth2_ssz_types = "0.2.2"
ethereum_ssz = "0.5.0"
ethereum_ssz_derive = "0.5.0"
ssz_types = "0.5.0"
merkle_proof = { path = "../merkle_proof" }
safe_arith = { path = "../safe_arith" }
tree_hash = "0.4.1"
tree_hash = "0.5.0"
types = { path = "../types", default-features = false }
rayon = "1.4.1"
eth2_hashing = "0.3.0"
ethereum_hashing = "1.0.0-beta.2"
int_to_bytes = { path = "../int_to_bytes" }
smallvec = "1.6.1"
arbitrary = { version = "1.0", features = ["derive"], optional = true }
@@ -39,7 +39,7 @@ arbitrary-fuzz = [
"types/arbitrary-fuzz",
"bls/arbitrary",
"merkle_proof/arbitrary",
"eth2_ssz/arbitrary",
"eth2_ssz_types/arbitrary",
"ethereum_ssz/arbitrary",
"ssz_types/arbitrary",
"tree_hash/arbitrary",
]

View File

@@ -29,7 +29,7 @@ pub struct BlockReplayer<
> {
state: BeaconState<Spec>,
spec: &'a ChainSpec,
state_root_strategy: StateRootStrategy,
state_processing_strategy: StateProcessingStrategy,
block_sig_strategy: BlockSignatureStrategy,
verify_block_root: Option<VerifyBlockRoot>,
pre_block_hook: Option<PreBlockHook<'a, Spec, Error>>,
@@ -60,13 +60,13 @@ impl From<BlockProcessingError> for BlockReplayError {
}
}
/// Defines how state roots should be computed during block replay.
#[derive(PartialEq)]
pub enum StateRootStrategy {
/// Defines how state roots should be computed and whether to perform all state transitions during block replay.
#[derive(PartialEq, Clone, Copy)]
pub enum StateProcessingStrategy {
/// Perform all transitions faithfully to the specification.
Accurate,
/// Don't compute state roots, eventually computing an invalid beacon state that can only be
/// used for obtaining shuffling.
/// Don't compute state roots and process withdrawals, eventually computing an invalid beacon
/// state that can only be used for obtaining shuffling.
Inconsistent,
}
@@ -87,7 +87,7 @@ where
Self {
state,
spec,
state_root_strategy: StateRootStrategy::Accurate,
state_processing_strategy: StateProcessingStrategy::Accurate,
block_sig_strategy: BlockSignatureStrategy::VerifyBulk,
verify_block_root: Some(VerifyBlockRoot::True),
pre_block_hook: None,
@@ -100,12 +100,15 @@ where
}
}
/// Set the replayer's state root strategy different from the default.
pub fn state_root_strategy(mut self, state_root_strategy: StateRootStrategy) -> Self {
if state_root_strategy == StateRootStrategy::Inconsistent {
/// Set the replayer's state processing strategy different from the default.
pub fn state_processing_strategy(
mut self,
state_processing_strategy: StateProcessingStrategy,
) -> Self {
if state_processing_strategy == StateProcessingStrategy::Inconsistent {
self.verify_block_root = None;
}
self.state_root_strategy = state_root_strategy;
self.state_processing_strategy = state_processing_strategy;
self
}
@@ -182,7 +185,7 @@ where
i: usize,
) -> Result<Option<Hash256>, Error> {
// If we don't care about state roots then return immediately.
if self.state_root_strategy == StateRootStrategy::Inconsistent {
if self.state_processing_strategy == StateProcessingStrategy::Inconsistent {
return Ok(Some(Hash256::zero()));
}
@@ -249,7 +252,7 @@ where
// If no explicit policy is set, verify only the first 1 or 2 block roots if using
// accurate state roots. Inaccurate state roots require block root verification to
// be off.
if i <= 1 && self.state_root_strategy == StateRootStrategy::Accurate {
if i <= 1 && self.state_processing_strategy == StateProcessingStrategy::Accurate {
VerifyBlockRoot::True
} else {
VerifyBlockRoot::False
@@ -263,6 +266,7 @@ where
&mut self.state,
block,
self.block_sig_strategy,
self.state_processing_strategy,
verify_block_root,
&mut ctxt,
self.spec,

View File

@@ -1,4 +1,4 @@
use eth2_hashing::hash;
use ethereum_hashing::hash;
use int_to_bytes::int_to_bytes32;
use merkle_proof::{MerkleTree, MerkleTreeError};
use safe_arith::SafeArith;

View File

@@ -27,7 +27,7 @@ pub mod state_advance;
pub mod upgrade;
pub mod verify_operation;
pub use block_replayer::{BlockReplayError, BlockReplayer, StateRootStrategy};
pub use block_replayer::{BlockReplayError, BlockReplayer, StateProcessingStrategy};
pub use consensus_context::{ConsensusContext, ContextError};
pub use genesis::{
eth2_genesis_time, initialize_beacon_state_from_eth1, is_valid_genesis_state,

View File

@@ -41,6 +41,7 @@ mod verify_exit;
mod verify_proposer_slashing;
use crate::common::decrease_balance;
use crate::StateProcessingStrategy;
#[cfg(feature = "arbitrary-fuzz")]
use arbitrary::Arbitrary;
@@ -98,6 +99,7 @@ pub fn per_block_processing<T: EthSpec, Payload: AbstractExecPayload<T>>(
state: &mut BeaconState<T>,
signed_block: &SignedBeaconBlock<T, Payload>,
block_signature_strategy: BlockSignatureStrategy,
state_processing_strategy: StateProcessingStrategy,
verify_block_root: VerifyBlockRoot,
ctxt: &mut ConsensusContext<T>,
spec: &ChainSpec,
@@ -162,7 +164,9 @@ pub fn per_block_processing<T: EthSpec, Payload: AbstractExecPayload<T>>(
// previous block.
if is_execution_enabled(state, block.body()) {
let payload = block.body().execution_payload()?;
process_withdrawals::<T, Payload>(state, payload, spec)?;
if state_processing_strategy == StateProcessingStrategy::Accurate {
process_withdrawals::<T, Payload>(state, payload, spec)?;
}
process_execution_payload::<T, Payload>(state, payload, spec)?;
}

View File

@@ -1,5 +1,5 @@
use crate::{BlockProcessingError, ConsensusContext};
use eth2_hashing::hash_fixed;
use ethereum_hashing::hash_fixed;
use itertools::{EitherOrBoth, Itertools};
use safe_arith::SafeArith;
use ssz::Decode;

View File

@@ -1,11 +1,11 @@
#![cfg(all(test, not(feature = "fake_crypto")))]
use crate::per_block_processing;
use crate::per_block_processing::errors::{
AttestationInvalid, AttesterSlashingInvalid, BlockOperationError, BlockProcessingError,
DepositInvalid, HeaderInvalid, IndexedAttestationInvalid, IntoWithIndex,
ProposerSlashingInvalid,
};
use crate::{per_block_processing, StateProcessingStrategy};
use crate::{
per_block_processing::{process_operations, verify_exit::verify_exit},
BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, VerifySignatures,
@@ -72,6 +72,7 @@ async fn valid_block_ok() {
&mut state,
&block,
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -97,6 +98,7 @@ async fn invalid_block_header_state_slot() {
&mut state,
&SignedBeaconBlock::from_block(block, signature),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -129,6 +131,7 @@ async fn invalid_parent_block_root() {
&mut state,
&SignedBeaconBlock::from_block(block, signature),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -162,6 +165,7 @@ async fn invalid_block_signature() {
&mut state,
&SignedBeaconBlock::from_block(block, Signature::empty()),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -195,6 +199,7 @@ async fn invalid_randao_reveal_signature() {
&mut state,
&signed_block,
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,

View File

@@ -1,7 +1,7 @@
use super::errors::{BlockOperationError, BlsExecutionChangeInvalid as Invalid};
use crate::per_block_processing::signature_sets::bls_execution_change_signature_set;
use crate::VerifySignatures;
use eth2_hashing::hash;
use ethereum_hashing::hash;
use types::*;
type Result<T> = std::result::Result<T, BlockOperationError<Invalid>>;