@@ -30,13 +30,13 @@ cd crates/header-accumulator && cargo doc --open
30
30
- ** ` generate_inclusion_proof ` ** : Generates inclusion proofs for a
31
31
specified range of blocks, useful for verifying the presence of
32
32
specific blocks within a dataset.
33
- - ** ` verify_inclusion_proof ` ** : Verifies inclusion proofs for a
33
+ - ** ` verify_inclusion_proof ` ** : Verifies inclusion proofs for a
34
34
specified range of blocks. Use this to confirm the accuracy of
35
35
inclusion proofs.
36
36
37
37
### Options
38
38
39
- - ` -h, --help ` : Displays a help message that includes usage
39
+ - ` -h, --help ` : Displays a help message that includes usage
40
40
information, commands, and options.
41
41
42
42
## Goals
@@ -64,11 +64,11 @@ cargo test
64
64
use std::{fs::File, io::BufReader};
65
65
use flat_files_decoder::{read_blocks_from_reader, Compression};
66
66
use header_accumulator::{
67
- generate_inclusion_proofs, verify_inclusion_proofs, Epoch, EraValidateError, ExtHeaderRecord ,
67
+ generate_inclusion_proofs, verify_inclusion_proofs, Epoch, EraValidateError, Header ,
68
68
};
69
69
70
70
fn main() -> Result<(), EraValidateError> {
71
- let mut headers: Vec<ExtHeaderRecord > = Vec::new();
71
+ let mut headers: Vec<Header > = Vec::new();
72
72
73
73
for flat_file_number in (0..=8200).step_by(100) {
74
74
let file = format!(
@@ -83,8 +83,8 @@ fn main() -> Result<(), EraValidateError> {
83
83
headers.extend(
84
84
blocks
85
85
.iter()
86
- .map(|block| ExtHeaderRecord ::try_from(block).unwrap())
87
- .collect::<Vec<ExtHeaderRecord >>(),
86
+ .map(|block| Header ::try_from(block).unwrap())
87
+ .collect::<Vec<Header >>(),
88
88
);
89
89
}
90
90
Err(e) => {
@@ -96,10 +96,7 @@ fn main() -> Result<(), EraValidateError> {
96
96
97
97
let start_block = 301;
98
98
let end_block = 402;
99
- let headers_to_prove: Vec<_> = headers[start_block..end_block]
100
- .iter()
101
- .map(|ext| ext.full_header.as_ref().unwrap().clone())
102
- .collect();
99
+ let headers_to_prove = headers[start_block..end_block].to_vec();
103
100
let epoch: Epoch = headers.try_into().unwrap();
104
101
105
102
let inclusion_proof = generate_inclusion_proofs(vec![epoch], headers_to_prove.clone())
@@ -121,7 +118,7 @@ fn main() -> Result<(), EraValidateError> {
121
118
println!("Inclusion proof verified successfully!");
122
119
123
120
Ok(())
124
- }
121
+ }
125
122
```
126
123
127
124
### Era validator
@@ -130,15 +127,15 @@ fn main() -> Result<(), EraValidateError> {
130
127
use std::{fs::File, io::BufReader};
131
128
132
129
use flat_files_decoder::{read_blocks_from_reader, Compression};
133
- use header_accumulator::{Epoch, EraValidateError, EraValidator, ExtHeaderRecord };
130
+ use header_accumulator::{Epoch, EraValidateError, EraValidator, Header };
134
131
use tree_hash::Hash256;
135
132
136
133
fn create_test_reader(path: &str) -> BufReader<File> {
137
134
BufReader::new(File::open(path).unwrap())
138
135
}
139
136
140
137
fn main() -> Result<(), EraValidateError> {
141
- let mut headers: Vec<ExtHeaderRecord > = Vec::new();
138
+ let mut headers: Vec<Header > = Vec::new();
142
139
for number in (0..=8200).step_by(100) {
143
140
let file_name = format!(
144
141
"your-test-assets/ethereum_firehose_first_8200/{:010}.dbin",
@@ -149,12 +146,12 @@ fn main() -> Result<(), EraValidateError> {
149
146
let successful_headers = blocks
150
147
.iter()
151
148
.cloned()
152
- .map(|block| ExtHeaderRecord ::try_from(&block))
149
+ .map(|block| Header ::try_from(&block))
153
150
.collect::<Result<Vec<_>, _>>()?;
154
151
headers.extend(successful_headers);
155
152
}
156
153
assert_eq!(headers.len(), 8300);
157
- assert_eq!(headers[0].block_number , 0);
154
+ assert_eq!(headers[0].number , 0);
158
155
let era_verifier = EraValidator::default();
159
156
let epoch: Epoch = headers.try_into().unwrap();
160
157
let result = era_verifier.validate_era(&epoch)?;
@@ -168,4 +165,4 @@ fn main() -> Result<(), EraValidateError> {
168
165
169
166
Ok(())
170
167
}
171
- ```
168
+ ```
0 commit comments