Fixed moar tests (#3774)

This commit is contained in:
ethDreamer 2022-12-04 16:08:55 -06:00 committed by GitHub
parent 5282e200be
commit b6486e809d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 75 deletions

View File

@ -2122,7 +2122,7 @@ impl ApiTester {
self
}
pub async fn test_blinded_block_production<Payload: ExecPayload<E>>(&self) {
pub async fn test_blinded_block_production<Payload: AbstractExecPayload<E>>(&self) {
let fork = self.chain.canonical_head.cached_head().head_fork();
let genesis_validators_root = self.chain.genesis_validators_root;
@ -2182,7 +2182,7 @@ impl ApiTester {
}
}
pub async fn test_blinded_block_production_no_verify_randao<Payload: ExecPayload<E>>(
pub async fn test_blinded_block_production_no_verify_randao<Payload: AbstractExecPayload<E>>(
self,
) -> Self {
for _ in 0..E::slots_per_epoch() {
@ -2206,7 +2206,9 @@ impl ApiTester {
self
}
pub async fn test_blinded_block_production_verify_randao_invalid<Payload: ExecPayload<E>>(
pub async fn test_blinded_block_production_verify_randao_invalid<
Payload: AbstractExecPayload<E>,
>(
self,
) -> Self {
let fork = self.chain.canonical_head.cached_head().head_fork();
@ -2664,7 +2666,7 @@ impl ApiTester {
let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2673,14 +2675,11 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
let expected_fee_recipient = Address::from_low_u64_be(proposer_index as u64);
assert_eq!(
payload.execution_payload_header.fee_recipient,
expected_fee_recipient
);
assert_eq!(payload.execution_payload_header.gas_limit, 11_111_111);
assert_eq!(payload.fee_recipient(), expected_fee_recipient);
assert_eq!(payload.gas_limit(), 11_111_111);
// If this cache is empty, it indicates fallback was not used, so the payload came from the
// mock builder.
@ -2707,7 +2706,7 @@ impl ApiTester {
let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2716,14 +2715,11 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
let expected_fee_recipient = Address::from_low_u64_be(proposer_index as u64);
assert_eq!(
payload.execution_payload_header.fee_recipient,
expected_fee_recipient
);
assert_eq!(payload.execution_payload_header.gas_limit, 30_000_000);
assert_eq!(payload.fee_recipient(), expected_fee_recipient);
assert_eq!(payload.gas_limit(), 30_000_000);
// This cache should not be populated because fallback should not have been used.
assert!(self
@ -2753,7 +2749,7 @@ impl ApiTester {
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2762,12 +2758,9 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
assert_eq!(
payload.execution_payload_header.fee_recipient,
test_fee_recipient
);
assert_eq!(payload.fee_recipient(), test_fee_recipient);
// This cache should not be populated because fallback should not have been used.
assert!(self
@ -2801,11 +2794,11 @@ impl ApiTester {
.beacon_state
.latest_execution_payload_header()
.unwrap()
.block_hash;
.block_hash();
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2814,12 +2807,9 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
assert_eq!(
payload.execution_payload_header.parent_hash,
expected_parent_hash
);
assert_eq!(payload.parent_hash(), expected_parent_hash);
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -2856,7 +2846,7 @@ impl ApiTester {
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2865,12 +2855,9 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
assert_eq!(
payload.execution_payload_header.prev_randao,
expected_prev_randao
);
assert_eq!(payload.prev_randao(), expected_prev_randao);
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -2901,12 +2888,12 @@ impl ApiTester {
.beacon_state
.latest_execution_payload_header()
.unwrap()
.block_number
.block_number()
+ 1;
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2915,12 +2902,9 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
assert_eq!(
payload.execution_payload_header.block_number,
expected_block_number
);
assert_eq!(payload.block_number(), expected_block_number);
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -2951,11 +2935,11 @@ impl ApiTester {
.beacon_state
.latest_execution_payload_header()
.unwrap()
.timestamp;
.timestamp();
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -2964,9 +2948,9 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
assert!(payload.execution_payload_header.timestamp > min_expected_timestamp);
assert!(payload.timestamp() > min_expected_timestamp);
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -2991,7 +2975,7 @@ impl ApiTester {
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -3000,7 +2984,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -3028,7 +3012,7 @@ impl ApiTester {
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -3037,7 +3021,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -3071,7 +3055,7 @@ impl ApiTester {
.get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch()))
.await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
.await
@ -3080,7 +3064,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// This cache should not be populated because fallback should not have been used.
assert!(self
@ -3100,7 +3084,7 @@ impl ApiTester {
.get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch()))
.await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
.await
@ -3109,7 +3093,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -3149,7 +3133,7 @@ impl ApiTester {
.get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch()))
.await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
.await
@ -3158,7 +3142,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -3188,7 +3172,7 @@ impl ApiTester {
.get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch()))
.await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
.await
@ -3197,7 +3181,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// This cache should not be populated because fallback should not have been used.
assert!(self
@ -3231,7 +3215,7 @@ impl ApiTester {
let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -3240,13 +3224,10 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
let expected_fee_recipient = Address::from_low_u64_be(proposer_index as u64);
assert_eq!(
payload.execution_payload_header.fee_recipient,
expected_fee_recipient
);
assert_eq!(payload.fee_recipient(), expected_fee_recipient);
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self
@ -3275,7 +3256,7 @@ impl ApiTester {
let (_, randao_reveal) = self.get_test_randao(slot, epoch).await;
let payload = self
let payload: BlindedPayload<E> = self
.client
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
.await
@ -3284,7 +3265,7 @@ impl ApiTester {
.body()
.execution_payload()
.unwrap()
.clone();
.into();
// If this cache is populated, it indicates fallback to the local EE was correctly used.
assert!(self

View File

@ -38,8 +38,7 @@ pub type Withdrawals<T> = VariableList<Withdrawal, <T as EthSpec>::MaxWithdrawal
)]
#[derive(Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Derivative)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(untagged)]
#[serde(bound = "T: EthSpec")]
#[serde(bound = "T: EthSpec", untagged)]
#[ssz(enum_behaviour = "transparent")]
#[tree_hash(enum_behaviour = "transparent")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]

View File

@ -33,7 +33,7 @@ use BeaconStateError;
)]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")]
#[serde(bound = "T: EthSpec", untagged)]
#[tree_hash(enum_behaviour = "transparent")]
#[ssz(enum_behaviour = "transparent")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]

View File

@ -166,11 +166,10 @@ impl<'a, T: EthSpec> From<FullPayloadRef<'a, T>> for ExecutionPayload<T> {
// FIXME: can this be implemented as Deref or Clone somehow?
impl<'a, T: EthSpec> From<FullPayloadRef<'a, T>> for FullPayload<T> {
fn from(full_payload_ref: FullPayloadRef<'a, T>) -> Self {
match full_payload_ref {
FullPayloadRef::Merge(payload_ref) => FullPayload::Merge(payload_ref.clone()),
FullPayloadRef::Capella(payload_ref) => FullPayload::Capella(payload_ref.clone()),
FullPayloadRef::Eip4844(payload_ref) => FullPayload::Eip4844(payload_ref.clone()),
}
map_full_payload_ref!(&'a _, full_payload_ref, move |payload, cons| {
cons(payload);
payload.clone().into()
})
}
}
@ -451,6 +450,15 @@ pub struct BlindedPayload<T: EthSpec> {
pub execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
}
impl<'a, T: EthSpec> From<BlindedPayloadRef<'a, T>> for BlindedPayload<T> {
fn from(blinded_payload_ref: BlindedPayloadRef<'a, T>) -> Self {
map_blinded_payload_ref!(&'a _, blinded_payload_ref, move |payload, cons| {
cons(payload);
payload.clone().into()
})
}
}
impl<T: EthSpec> ExecPayload<T> for BlindedPayload<T> {
fn block_type() -> BlockType {
BlockType::Blinded