Fix ef tests

This commit is contained in:
realbigsean
2023-06-08 09:21:04 -04:00
parent 13919058d5
commit 8da95ac9c6
4 changed files with 43 additions and 23 deletions

View File

@@ -1105,19 +1105,18 @@ impl HttpJsonRpc {
execution_payload: ExecutionPayload<T>, execution_payload: ExecutionPayload<T>,
versioned_hashes_opt: Option<Vec<VersionedHash>>, versioned_hashes_opt: Option<Vec<VersionedHash>>,
) -> Result<PayloadStatusV1, Error> { ) -> Result<PayloadStatusV1, Error> {
let engine_capabilities = self.get_engine_capabilities(None).await?; // TODO(sean): opting to just use one struct one endpoint approach for simplicity,
if engine_capabilities.new_payload_v3 { // also this is in the pipeline:https://github.com/ethereum/execution-apis/pull/418/files
let Some(versioned_hashes) = versioned_hashes_opt else { match execution_payload {
return Err(Error::IncorrectStateVariant); ExecutionPayload::Merge(_) => self.new_payload_v1(execution_payload).await,
}; ExecutionPayload::Capella(_) => self.new_payload_v2(execution_payload).await,
self.new_payload_v3(execution_payload, versioned_hashes) ExecutionPayload::Deneb(_) => {
.await let Some(versioned_hashes) = versioned_hashes_opt else {
} else if engine_capabilities.new_payload_v2 { return Err(Error::IncorrectStateVariant);
self.new_payload_v2(execution_payload).await };
} else if engine_capabilities.new_payload_v1 { self.new_payload_v3(execution_payload, versioned_hashes)
self.new_payload_v1(execution_payload).await .await
} else { }
Err(Error::RequiredMethodUnsupported("engine_newPayload"))
} }
} }

View File

@@ -54,7 +54,8 @@ excluded_paths = [
# FIXME(sean) # FIXME(sean)
"tests/mainnet/capella/light_client/single_merkle_proof/BeaconBlockBody/*", "tests/mainnet/capella/light_client/single_merkle_proof/BeaconBlockBody/*",
"tests/mainnet/deneb/light_client/single_merkle_proof/BeaconBlockBody/*", "tests/mainnet/deneb/light_client/single_merkle_proof/BeaconBlockBody/*",
"tests/general/deneb/kzg" "tests/general/deneb/kzg",
"tests/.*/eip6110"
] ]

View File

@@ -20,9 +20,10 @@ use state_processing::{
use std::fmt::Debug; use std::fmt::Debug;
use std::path::Path; use std::path::Path;
use types::{ use types::{
map_fork_name, map_fork_name_with, Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyCapella,
BeaconState, BlindedPayload, ChainSpec, Deposit, EthSpec, ExecutionPayload, ForkName, BeaconBlockBodyDeneb, BeaconBlockBodyMerge, BeaconState, BlindedPayload, ChainSpec, Deposit,
FullPayload, ProposerSlashing, SignedBlsToExecutionChange, SignedVoluntaryExit, SyncAggregate, EthSpec, ExecutionPayload, ForkName, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
SignedVoluntaryExit, SyncAggregate,
}; };
#[derive(Debug, Clone, Default, Deserialize)] #[derive(Debug, Clone, Default, Deserialize)]
@@ -275,7 +276,12 @@ impl<E: EthSpec> Operation<E> for BeaconBlockBody<E, FullPayload<E>> {
fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> { fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
ssz_decode_file_with(path, |bytes| { ssz_decode_file_with(path, |bytes| {
Ok(map_fork_name!(fork_name, Self, <_>::from_ssz_bytes(bytes)?)) Ok(match fork_name {
ForkName::Merge => BeaconBlockBody::Merge(<_>::from_ssz_bytes(bytes)?),
ForkName::Capella => BeaconBlockBody::Capella(<_>::from_ssz_bytes(bytes)?),
ForkName::Deneb => BeaconBlockBody::Deneb(<_>::from_ssz_bytes(bytes)?),
_ => panic!(),
})
}) })
} }
@@ -311,7 +317,21 @@ impl<E: EthSpec> Operation<E> for BeaconBlockBody<E, BlindedPayload<E>> {
fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> { fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
ssz_decode_file_with(path, |bytes| { ssz_decode_file_with(path, |bytes| {
Ok(map_fork_name!(fork_name, Self, <_>::from_ssz_bytes(bytes)?)) Ok(match fork_name {
ForkName::Merge => {
let inner = <BeaconBlockBodyMerge<E, FullPayload<E>>>::from_ssz_bytes(bytes)?;
BeaconBlockBody::Merge(inner.clone_as_blinded())
}
ForkName::Capella => {
let inner = <BeaconBlockBodyCapella<E, FullPayload<E>>>::from_ssz_bytes(bytes)?;
BeaconBlockBody::Capella(inner.clone_as_blinded())
}
ForkName::Deneb => {
let inner = <BeaconBlockBodyDeneb<E, FullPayload<E>>>::from_ssz_bytes(bytes)?;
BeaconBlockBody::Deneb(inner.clone_as_blinded())
}
_ => panic!(),
})
}) })
} }

View File

@@ -72,14 +72,14 @@ fn operations_sync_aggregate() {
#[test] #[test]
fn operations_execution_payload_full() { fn operations_execution_payload_full() {
OperationsHandler::<MinimalEthSpec, FullPayload<_>>::default().run(); OperationsHandler::<MinimalEthSpec, BeaconBlockBody<_, FullPayload<_>>>::default().run();
OperationsHandler::<MainnetEthSpec, FullPayload<_>>::default().run(); OperationsHandler::<MainnetEthSpec, BeaconBlockBody<_, FullPayload<_>>>::default().run();
} }
#[test] #[test]
fn operations_execution_payload_blinded() { fn operations_execution_payload_blinded() {
OperationsHandler::<MinimalEthSpec, BlindedPayload<_>>::default().run(); OperationsHandler::<MinimalEthSpec, BeaconBlockBody<_, BlindedPayload<_>>>::default().run();
OperationsHandler::<MainnetEthSpec, BlindedPayload<_>>::default().run(); OperationsHandler::<MainnetEthSpec, BeaconBlockBody<_, BlindedPayload<_>>>::default().run();
} }
#[test] #[test]