Skip to content

Commit

Permalink
chore: keep header accumulator version bump and usage of alloy-primit…
Browse files Browse the repository at this point in the history
…ives
  • Loading branch information
pedrohba1 committed Feb 14, 2025
1 parent 3123e9c commit e74727e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 1 addition & 3 deletions crates/header-accumulator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "header-accumulator"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -11,8 +11,6 @@ base64.workspace = true
clap.workspace = true
ethportal-api.workspace = true
firehose-protos.workspace = true
primitive-types.workspace = true
rlp.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
tracing.workspace = true
Expand Down
10 changes: 7 additions & 3 deletions crates/header-accumulator/src/era_validator.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright 2024-, Semiotic AI, Inc.
// SPDX-License-Identifier: Apache-2.0

use alloy_primitives::FixedBytes;
use ethportal_api::types::execution::accumulator::EpochAccumulator;
use tree_hash::{Hash256, TreeHash};
use tree_hash::TreeHash;
use trin_validation::accumulator::{HistoricalEpochRoots, PreMergeAccumulator};

use crate::{
Expand Down Expand Up @@ -35,7 +36,10 @@ impl EraValidator {
/// # Arguments
///
/// * `epochs`- An array of [`Epoch`].
pub fn validate_eras(&self, epochs: &[&Epoch]) -> Result<Vec<Hash256>, EraValidateError> {
pub fn validate_eras(
&self,
epochs: &[&Epoch],
) -> Result<Vec<FixedBytes<32>>, EraValidateError> {
let mut validated_epochs = Vec::new();
for epoch in epochs {
let root = self.validate_era(epoch)?;
Expand All @@ -53,7 +57,7 @@ impl EraValidator {
///
/// For block post merge, the sync-committee should be used to validate block headers
/// in the canonical blockchain. So this function is not useful for those.
pub fn validate_era(&self, epoch: &Epoch) -> Result<Hash256, EraValidateError> {
pub fn validate_era(&self, epoch: &Epoch) -> Result<FixedBytes<32>, EraValidateError> {
if epoch.number() > FINAL_EPOCH {
return Err(EraValidateError::EpochPostMerge(epoch.number()));
}
Expand Down
6 changes: 3 additions & 3 deletions crates/header-accumulator/src/inclusion_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::{epoch::MAX_EPOCH_SIZE, errors::EraValidateError, Epoch};

use alloy_primitives::FixedBytes;
use ethportal_api::{
types::execution::{
accumulator::EpochAccumulator,
Expand All @@ -12,7 +13,6 @@ use ethportal_api::{
},
Header,
};
use tree_hash::Hash256;
use trin_validation::{
accumulator::PreMergeAccumulator, header_validator::HeaderValidator,
historical_roots_acc::HistoricalRootsAccumulator,
Expand All @@ -24,7 +24,7 @@ const PROOF_SIZE: usize = 15;
#[derive(Clone)]
pub struct InclusionProof {
block_number: u64,
proof: [Hash256; PROOF_SIZE],
proof: [FixedBytes<32>; PROOF_SIZE],
}

impl InclusionProof {
Expand Down Expand Up @@ -119,7 +119,7 @@ fn do_generate_inclusion_proof(
) -> Result<InclusionProof, EraValidateError> {
PreMergeAccumulator::construct_proof(header, epoch_accumulator)
.map(|proof| InclusionProof {
proof,
proof: proof.proof,
block_number: header.number,
})
.map_err(|_| EraValidateError::ProofGenerationFailure)
Expand Down

0 comments on commit e74727e

Please sign in to comment.