mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-02 04:03:35 +00:00
Gloas HTTP API tests passing (#9154)
Get the Gloas HTTP API tests passing, partly through fixes and partly through disabling tests that don't fit the Gloas paradigm. Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com> Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -1883,7 +1883,9 @@ impl<E: EthSpec> FullBlockContents<E> {
|
||||
|
||||
/// SSZ decode with fork variant passed in explicitly.
|
||||
pub fn from_ssz_bytes_for_fork(bytes: &[u8], fork_name: ForkName) -> Result<Self, DecodeError> {
|
||||
if fork_name.deneb_enabled() {
|
||||
// TODO(gloas): revisit when produceBlockV4 PR is finalised
|
||||
// https://github.com/ethereum/beacon-APIs/pull/580
|
||||
if fork_name.deneb_enabled() && !fork_name.gloas_enabled() {
|
||||
let mut builder = ssz::SszDecoderBuilder::new(bytes);
|
||||
|
||||
builder.register_anonymous_variable_length_item()?;
|
||||
@@ -1939,7 +1941,7 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for FullBlockContents<E>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
if context.deneb_enabled() {
|
||||
if context.deneb_enabled() && !context.gloas_enabled() {
|
||||
Ok(FullBlockContents::BlockContents(
|
||||
BlockContents::context_deserialize::<D>(deserializer, context)?,
|
||||
))
|
||||
@@ -2050,15 +2052,19 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for PublishBlockRequest<
|
||||
let value =
|
||||
serde_json::Value::deserialize(deserializer).map_err(serde::de::Error::custom)?;
|
||||
|
||||
SignedBlockContents::<E>::context_deserialize(&value, context)
|
||||
.map(PublishBlockRequest::BlockContents)
|
||||
.or_else(|_| {
|
||||
Arc::<SignedBeaconBlock<E>>::context_deserialize(&value, context)
|
||||
.map(PublishBlockRequest::Block)
|
||||
})
|
||||
.map_err(|_| {
|
||||
serde::de::Error::custom("could not match any variant of PublishBlockRequest")
|
||||
})
|
||||
let res = if context.gloas_enabled() {
|
||||
Arc::<SignedBeaconBlock<E>>::context_deserialize(&value, context)
|
||||
.map(PublishBlockRequest::Block)
|
||||
} else {
|
||||
SignedBlockContents::<E>::context_deserialize(&value, context)
|
||||
.map(PublishBlockRequest::BlockContents)
|
||||
.or_else(|_| {
|
||||
Arc::<SignedBeaconBlock<E>>::context_deserialize(&value, context)
|
||||
.map(PublishBlockRequest::Block)
|
||||
})
|
||||
};
|
||||
|
||||
res.map_err(|_| serde::de::Error::custom("failed to deserialize into PublishBlockRequest"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2124,7 +2130,10 @@ impl<E: EthSpec> PublishBlockRequest<E> {
|
||||
impl<E: EthSpec> TryFrom<Arc<SignedBeaconBlock<E>>> for PublishBlockRequest<E> {
|
||||
type Error = &'static str;
|
||||
fn try_from(block: Arc<SignedBeaconBlock<E>>) -> Result<Self, Self::Error> {
|
||||
if block.message().fork_name_unchecked().deneb_enabled() {
|
||||
let fork = block.message().fork_name_unchecked();
|
||||
// Gloas blocks don't carry blobs (execution data comes via envelopes),
|
||||
// so they can be published as block-only requests like pre-Deneb blocks.
|
||||
if fork.deneb_enabled() && !fork.gloas_enabled() {
|
||||
Err("post-Deneb block contents cannot be fully constructed from just the signed block")
|
||||
} else {
|
||||
Ok(PublishBlockRequest::Block(block))
|
||||
@@ -2493,7 +2502,7 @@ mod test {
|
||||
for fork_name in ForkName::list_all() {
|
||||
let signed_beacon_block =
|
||||
map_fork_name!(fork_name, SignedBeaconBlock, <_>::random_for_test(rng));
|
||||
let request = if fork_name.deneb_enabled() {
|
||||
let request = if fork_name.deneb_enabled() && !fork_name.gloas_enabled() {
|
||||
let kzg_proofs = KzgProofs::<MainnetEthSpec>::random_for_test(rng);
|
||||
let blobs = BlobsList::<MainnetEthSpec>::random_for_test(rng);
|
||||
let block_contents = SignedBlockContents {
|
||||
|
||||
Reference in New Issue
Block a user