@@ -2,14 +2,14 @@ use std::path::PathBuf;
2
2
3
3
use anyhow:: ensure;
4
4
use e2store:: e2hs:: { E2HSWriter , BLOCKS_PER_E2HS } ;
5
- use ethportal_api:: consensus:: { beacon_block:: BeaconBlockElectra , beacon_state:: HistoricalBatch } ;
5
+ use ethportal_api:: consensus:: {
6
+ beacon_block:: BeaconBlockElectra , beacon_state:: HistoricalBatch ,
7
+ historical_summaries:: historical_summary_index,
8
+ } ;
6
9
use ssz_types:: FixedVector ;
7
10
use tempfile:: TempDir ;
8
11
use tracing:: info;
9
- use trin_validation:: {
10
- constants:: { CAPELLA_FORK_EPOCH , SLOTS_PER_EPOCH , SLOTS_PER_HISTORICAL_ROOT } ,
11
- header_validator:: HeaderValidator ,
12
- } ;
12
+ use trin_validation:: header_validator:: HeaderValidator ;
13
13
14
14
use super :: ethereum_api:: EthereumApi ;
15
15
use crate :: {
@@ -19,7 +19,7 @@ use crate::{
19
19
20
20
struct ProvingAnchors {
21
21
current_historical_batch : HistoricalBatch ,
22
- current_historical_summaries_index : u64 ,
22
+ current_historical_summary_index : usize ,
23
23
header_validator : HeaderValidator ,
24
24
}
25
25
@@ -34,7 +34,7 @@ impl ProvingAnchors {
34
34
block_roots : FixedVector :: default ( ) ,
35
35
state_roots : FixedVector :: default ( ) ,
36
36
} ,
37
- current_historical_summaries_index : 0 ,
37
+ current_historical_summary_index : 0 ,
38
38
header_validator : HeaderValidator :: new_with_historical_summaries ( Default :: default ( ) ) ,
39
39
}
40
40
}
@@ -112,8 +112,9 @@ impl E2HSBuilder {
112
112
113
113
/// If the historical summaries index has changed, update the proving anchors.
114
114
async fn update_proving_anchors ( & mut self , slot : u64 ) -> anyhow:: Result < ( ) > {
115
- let historical_summaries_index = historical_summaries_index ( slot) ;
116
- if historical_summaries_index == self . proving_anchors . current_historical_summaries_index {
115
+ let historical_summary_index = historical_summary_index ( slot)
116
+ . expect ( "Relevant slot must have historical_summary_index" ) ;
117
+ if historical_summary_index == self . proving_anchors . current_historical_summary_index {
117
118
return Ok ( ( ) ) ;
118
119
}
119
120
@@ -122,7 +123,7 @@ impl E2HSBuilder {
122
123
. get_state_for_start_of_next_period ( slot)
123
124
. await ?;
124
125
125
- self . proving_anchors . current_historical_summaries_index = historical_summaries_index ;
126
+ self . proving_anchors . current_historical_summary_index = historical_summary_index ;
126
127
self . proving_anchors . header_validator =
127
128
HeaderValidator :: new_with_historical_summaries ( state. historical_summaries ) ;
128
129
self . proving_anchors . current_historical_batch = HistoricalBatch {
@@ -155,8 +156,3 @@ impl E2HSBuilder {
155
156
} )
156
157
}
157
158
}
158
-
159
- /// Calculate the historical summaries index for a given slot.
160
- pub fn historical_summaries_index ( slot : u64 ) -> u64 {
161
- ( slot - CAPELLA_FORK_EPOCH * SLOTS_PER_EPOCH ) / SLOTS_PER_HISTORICAL_ROOT
162
- }
0 commit comments