get ef tests passing after capella rebase

This commit is contained in:
realbigsean 2023-01-11 18:32:15 -05:00
parent 438126f19a
commit f7f351784a
No known key found for this signature in database
GPG Key ID: B372B64D866BF8CC
9 changed files with 69 additions and 47 deletions

1
Cargo.lock generated
View File

@ -401,6 +401,7 @@ dependencies = [
"eth1", "eth1",
"eth2", "eth2",
"eth2_hashing", "eth2_hashing",
"eth2_network_config",
"eth2_ssz", "eth2_ssz",
"eth2_ssz_derive", "eth2_ssz_derive",
"eth2_ssz_types", "eth2_ssz_types",

View File

@ -22,6 +22,8 @@ environment = { path = "../../lighthouse/environment" }
serde_json = "1.0.58" serde_json = "1.0.58"
[dependencies] [dependencies]
serde_json = "1.0.58"
eth2_network_config = { path = "../../common/eth2_network_config"}
merkle_proof = { path = "../../consensus/merkle_proof" } merkle_proof = { path = "../../consensus/merkle_proof" }
store = { path = "../store" } store = { path = "../store" }
parking_lot = "0.12.0" parking_lot = "0.12.0"

View File

@ -23,6 +23,7 @@ use fork_choice::CountUnrealized;
use futures::channel::mpsc::Receiver; use futures::channel::mpsc::Receiver;
pub use genesis::{interop_genesis_state, DEFAULT_ETH1_BLOCK_HASH}; pub use genesis::{interop_genesis_state, DEFAULT_ETH1_BLOCK_HASH};
use int_to_bytes::int_to_bytes32; use int_to_bytes::int_to_bytes32;
use kzg::TrustedSetup;
use merkle_proof::MerkleTree; use merkle_proof::MerkleTree;
use parking_lot::Mutex; use parking_lot::Mutex;
use parking_lot::RwLockWriteGuard; use parking_lot::RwLockWriteGuard;
@ -493,6 +494,10 @@ where
let validator_keypairs = self let validator_keypairs = self
.validator_keypairs .validator_keypairs
.expect("cannot build without validator keypairs"); .expect("cannot build without validator keypairs");
let trusted_setup: TrustedSetup =
serde_json::from_reader(eth2_network_config::TRUSTED_SETUP)
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.unwrap();
let mut builder = BeaconChainBuilder::new(self.eth_spec_instance) let mut builder = BeaconChainBuilder::new(self.eth_spec_instance)
.logger(log.clone()) .logger(log.clone())
@ -509,7 +514,8 @@ where
log.clone(), log.clone(),
5, 5,
))) )))
.monitor_validators(true, vec![], log); .monitor_validators(true, vec![], log)
.trusted_setup(trusted_setup);
builder = if let Some(mutator) = self.initial_mutator { builder = if let Some(mutator) = self.initial_mutator {
mutator(builder) mutator(builder)

View File

@ -889,11 +889,11 @@ impl HttpJsonRpc {
pub async fn supported_apis_v1(&self) -> Result<SupportedApis, Error> { pub async fn supported_apis_v1(&self) -> Result<SupportedApis, Error> {
Ok(SupportedApis { Ok(SupportedApis {
new_payload_v1: true, new_payload_v1: true,
new_payload_v2: cfg!(any(feature = "withdrawals-processing", test)), new_payload_v2: cfg!(test),
forkchoice_updated_v1: true, forkchoice_updated_v1: true,
forkchoice_updated_v2: cfg!(any(feature = "withdrawals-processing", test)), forkchoice_updated_v2: cfg!(test),
get_payload_v1: true, get_payload_v1: true,
get_payload_v2: cfg!(any(feature = "withdrawals-processing", test)), get_payload_v2: cfg!(test),
exchange_transition_configuration_v1: true, exchange_transition_configuration_v1: true,
}) })
} }

View File

@ -74,7 +74,7 @@ pub async fn handle_rpc<T: EthSpec>(
.unwrap()) .unwrap())
} }
} }
ENGINE_NEW_PAYLOAD_V1 | ENGINE_NEW_PAYLOAD_V2 => { ENGINE_NEW_PAYLOAD_V1 | ENGINE_NEW_PAYLOAD_V2 | ENGINE_NEW_PAYLOAD_V3 => {
let request = match method { let request = match method {
ENGINE_NEW_PAYLOAD_V1 => { ENGINE_NEW_PAYLOAD_V1 => {
JsonExecutionPayload::V1(get_param::<JsonExecutionPayloadV1<T>>(params, 0)?) JsonExecutionPayload::V1(get_param::<JsonExecutionPayloadV1<T>>(params, 0)?)
@ -82,7 +82,9 @@ pub async fn handle_rpc<T: EthSpec>(
ENGINE_NEW_PAYLOAD_V2 => { ENGINE_NEW_PAYLOAD_V2 => {
JsonExecutionPayload::V2(get_param::<JsonExecutionPayloadV2<T>>(params, 0)?) JsonExecutionPayload::V2(get_param::<JsonExecutionPayloadV2<T>>(params, 0)?)
} }
// TODO(4844) add that here.. ENGINE_NEW_PAYLOAD_V3 => {
JsonExecutionPayload::V2(get_param::<JsonExecutionPayloadV2<T>>(params, 0)?)
}
_ => unreachable!(), _ => unreachable!(),
}; };
@ -114,7 +116,30 @@ pub async fn handle_rpc<T: EthSpec>(
)); ));
} }
} }
// TODO(4844) add 4844 error checking here ForkName::Eip4844 => {
//FIXME(sean)
if method == ENGINE_NEW_PAYLOAD_V1 {
return Err(format!("{} called after capella fork!", method));
}
if request.withdrawals().is_err()
|| (request.withdrawals().is_ok()
&& request.withdrawals().unwrap().is_none())
{
return Err(format!(
"{} called without `withdrawals` after eip4844 fork!",
method
));
}
if request.excess_data_gas().is_err()
|| (request.excess_data_gas().is_ok()
&& request.excess_data_gas().unwrap().is_none())
{
return Err(format!(
"{} called without `excess_data_gas` after eip4844 fork!",
method
));
}
}
_ => unreachable!(), _ => unreachable!(),
}; };
@ -148,7 +173,7 @@ pub async fn handle_rpc<T: EthSpec>(
Ok(serde_json::to_value(JsonPayloadStatusV1::from(response)).unwrap()) Ok(serde_json::to_value(JsonPayloadStatusV1::from(response)).unwrap())
} }
ENGINE_GET_PAYLOAD_V1 | ENGINE_GET_PAYLOAD_V2 => { ENGINE_GET_PAYLOAD_V1 | ENGINE_GET_PAYLOAD_V2 | ENGINE_GET_PAYLOAD_V3 => {
let request: JsonPayloadIdRequest = get_param(params, 0)?; let request: JsonPayloadIdRequest = get_param(params, 0)?;
let id = request.into(); let id = request.into();
@ -168,7 +193,17 @@ pub async fn handle_rpc<T: EthSpec>(
{ {
return Err(format!("{} called after capella fork!", method)); return Err(format!("{} called after capella fork!", method));
} }
// TODO(4844) add 4844 error checking here // validate method called correctly according to eip4844 fork time
if ctx
.execution_block_generator
.read()
.get_fork_at_timestamp(response.timestamp())
== ForkName::Eip4844
//FIXME(sean)
&& method == ENGINE_GET_PAYLOAD_V1
{
return Err(format!("{} called after capella fork!", method));
}
match method { match method {
ENGINE_GET_PAYLOAD_V1 => Ok(serde_json::to_value( ENGINE_GET_PAYLOAD_V1 => Ok(serde_json::to_value(
@ -224,7 +259,20 @@ pub async fn handle_rpc<T: EthSpec>(
)); ));
} }
} }
// TODO(4844) add 4844 error checking here ForkName::Eip4844 => {
//FIXME(sean)
if method == ENGINE_FORKCHOICE_UPDATED_V1 {
return Err(format!("{} called after capella fork!", method));
}
if pa.withdrawals().is_err()
|| (pa.withdrawals().is_ok() && pa.withdrawals().unwrap().is_none())
{
return Err(format!(
"{} called without `withdrawals` after capella fork!",
method
));
}
}
_ => unreachable!(), _ => unreachable!(),
}; };
} }

View File

@ -477,10 +477,6 @@ pub fn get_expected_withdrawals<T: EthSpec>(
let mut validator_index = state.next_withdrawal_validator_index()?; let mut validator_index = state.next_withdrawal_validator_index()?;
let mut withdrawals = vec![]; let mut withdrawals = vec![];
if cfg!(not(feature = "withdrawals-processing")) {
return Ok(withdrawals.into());
}
let bound = std::cmp::min( let bound = std::cmp::min(
state.validators().len() as u64, state.validators().len() as u64,
spec.max_validators_per_withdrawals_sweep, spec.max_validators_per_withdrawals_sweep,
@ -528,9 +524,6 @@ pub fn process_withdrawals<'payload, T: EthSpec, Payload: AbstractExecPayload<T>
payload: Payload::Ref<'payload>, payload: Payload::Ref<'payload>,
spec: &ChainSpec, spec: &ChainSpec,
) -> Result<(), BlockProcessingError> { ) -> Result<(), BlockProcessingError> {
if cfg!(not(feature = "withdrawals-processing")) {
return Ok(());
}
match state { match state {
BeaconState::Merge(_) => Ok(()), BeaconState::Merge(_) => Ok(()),
BeaconState::Capella(_) | BeaconState::Eip4844(_) => { BeaconState::Capella(_) | BeaconState::Eip4844(_) => {

View File

@ -300,9 +300,6 @@ pub fn process_bls_to_execution_changes<T: EthSpec>(
verify_signatures: VerifySignatures, verify_signatures: VerifySignatures,
spec: &ChainSpec, spec: &ChainSpec,
) -> Result<(), BlockProcessingError> { ) -> Result<(), BlockProcessingError> {
if cfg!(not(feature = "withdrawals-processing")) {
return Ok(());
}
for (i, signed_address_change) in bls_to_execution_changes.iter().enumerate() { for (i, signed_address_change) in bls_to_execution_changes.iter().enumerate() {
verify_bls_to_execution_change(state, signed_address_change, verify_signatures, spec) verify_bls_to_execution_change(state, signed_address_change, verify_signatures, spec)
.map_err(|e| e.into_with_index(i))?; .map_err(|e| e.into_with_index(i))?;

View File

@ -344,10 +344,6 @@ impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
} }
fn is_enabled_for_fork(fork_name: ForkName) -> bool { fn is_enabled_for_fork(fork_name: ForkName) -> bool {
if fork_name == ForkName::Capella && !cfg!(feature = "withdrawals-processing") {
return false;
}
fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge
} }
@ -366,12 +362,7 @@ impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
spec: &ChainSpec, spec: &ChainSpec,
_: &Operations<E, Self>, _: &Operations<E, Self>,
) -> Result<(), BlockProcessingError> { ) -> Result<(), BlockProcessingError> {
//FIXME(sean) remove this once the spec tests sort this out process_withdrawals::<_, FullPayload<_>>(state, self.payload.to_ref(), spec)
if matches!(state, BeaconState::Eip4844(_)) {
Ok(())
} else {
process_withdrawals::<_, FullPayload<_>>(state, self.payload.to_ref(), spec)
}
} }
} }
@ -385,9 +376,6 @@ impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
} }
fn is_enabled_for_fork(fork_name: ForkName) -> bool { fn is_enabled_for_fork(fork_name: ForkName) -> bool {
if fork_name == ForkName::Capella && !cfg!(feature = "withdrawals-processing") {
return false;
}
fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge
} }
@ -401,12 +389,7 @@ impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
spec: &ChainSpec, spec: &ChainSpec,
_extra: &Operations<E, Self>, _extra: &Operations<E, Self>,
) -> Result<(), BlockProcessingError> { ) -> Result<(), BlockProcessingError> {
//FIXME(sean) remove this once the spec tests sort this out process_bls_to_execution_changes(state, &[self.clone()], VerifySignatures::True, spec)
if matches!(state, BeaconState::Eip4844(_)) {
Ok(())
} else {
process_bls_to_execution_changes(state, &[self.clone()], VerifySignatures::True, spec)
}
} }
} }

View File

@ -60,14 +60,6 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
} }
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
if cfg!(feature = "withdrawals-processing") && fork_name == ForkName::Eip4844 {
return Ok(());
}
if !cfg!(feature = "withdrawals-processing") && fork_name == ForkName::Capella {
return Ok(());
}
self.metadata.bls_setting.unwrap_or_default().check()?; self.metadata.bls_setting.unwrap_or_default().check()?;
let mut bulk_state = self.pre.clone(); let mut bulk_state = self.pre.clone();