From 2e053d5c177f2efde299c171e4c38350e9817a8c Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Tue, 7 May 2024 09:00:59 -0600 Subject: [PATCH] update spec-gen to handle type alias in return type --- ethereum-consensus/src/deneb/spec/mod.rs | 2 +- ethereum-consensus/src/electra/spec/mod.rs | 2 +- spec-gen/src/generator.rs | 32 ++++++++++------------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ethereum-consensus/src/deneb/spec/mod.rs b/ethereum-consensus/src/deneb/spec/mod.rs index b9353cb3d..df6fa7c33 100644 --- a/ethereum-consensus/src/deneb/spec/mod.rs +++ b/ethereum-consensus/src/deneb/spec/mod.rs @@ -37,7 +37,7 @@ pub use crate::{ }, blob_sidecar::{ verify_blob_sidecar_inclusion_proof, Blob, BlobIdentifier, BlobSidecar, BlobsBundle, - VERSIONED_HASH_VERSION_KZG, + VersionedHash, VERSIONED_HASH_VERSION_KZG, }, block_processing::{ process_attestation, process_block, process_execution_payload, process_voluntary_exit, diff --git a/ethereum-consensus/src/electra/spec/mod.rs b/ethereum-consensus/src/electra/spec/mod.rs index 60aac0342..fef97c422 100644 --- a/ethereum-consensus/src/electra/spec/mod.rs +++ b/ethereum-consensus/src/electra/spec/mod.rs @@ -32,7 +32,7 @@ pub use crate::{ }, blob_sidecar::{ verify_blob_sidecar_inclusion_proof, Blob, BlobIdentifier, BlobSidecar, BlobsBundle, - VERSIONED_HASH_VERSION_KZG, + VersionedHash, VERSIONED_HASH_VERSION_KZG, }, helpers::kzg_commitment_to_versioned_hash, light_client::{ diff --git a/spec-gen/src/generator.rs b/spec-gen/src/generator.rs index 7f86ae62c..0f900a447 100644 --- a/spec-gen/src/generator.rs +++ b/spec-gen/src/generator.rs @@ -444,23 +444,21 @@ impl Spec { for name in type_names { if let Some(target_module) = index.get(&name) { let target_module = self.diff.modules.get(target_module).unwrap(); - let container = target_module - .containers - .iter() - .find(|&c| c.name == name) - .expect("internal state integrity"); - - // if we find a newer definition, edit the types of this function - // if not, just import from the earlier fork - if container.fork == self.fork { - let arguments = generics_to_arguments(&container.item.generics); - let mut editor = ArgumentsEditor::new(&container.name, &arguments); - editor.edit(&mut fragment); - - all_arguments.push(arguments); - f.fork = self.fork; - } else { - f.can_import = true; + if let Some(container) = + target_module.containers.iter().find(|&c| c.name == name) + { + // if we find a newer definition, edit the types of this function + // if not, just import from the earlier fork + if container.fork == self.fork { + let arguments = generics_to_arguments(&container.item.generics); + let mut editor = ArgumentsEditor::new(&container.name, &arguments); + editor.edit(&mut fragment); + + all_arguments.push(arguments); + f.fork = self.fork; + } else { + f.can_import = true; + } } } }