Skip to content

Commit 125272c

Browse files
committed
refactor: adapt range execution program outputs
1 parent 4060b02 commit 125272c

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

crates/sp1/evm-exec-types/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ pub struct EvmBlockExecOutput {
1515

1616
#[derive(Serialize, Deserialize, Debug)]
1717
pub struct EvmRangeExecOutput {
18-
// newest_header_hash is the last block's hash on the EVM roll-up.
19-
// TODO: this may be removable.
20-
pub newest_header_hash: [u8; 32],
21-
// oldest_header_hash is the earliest block's hash on the EVM roll-up.
22-
// TODO: this may be removable.
23-
pub oldest_header_hash: [u8; 32],
18+
// TODO: remove in favour of celestia_header_hash (latest)
2419
// celestia_header_hashes is the range of Celestia blocks that include all
2520
// of the blob data the EVM roll-up has posted from oldest_header_hash to
2621
// newest_header_hash.
2722
pub celestia_header_hashes: Vec<[u8; 32]>, // provided by Celestia state machine (eventually x/header)
28-
// newest_state_root is the computed state root of the EVM roll-up after
29-
// processing blocks from oldest_header_hash to newest_header_hash.
30-
pub newest_state_root: [u8; 32],
31-
// newest_height is the most recent block number of the EVM roll-up.
32-
// TODO: this may be removable.
33-
pub newest_height: u64,
23+
// celestia_header_hash is the hash of the celestia header at which new_height is available.
24+
pub celestia_header_hash: [u8; 32],
25+
// trusted_height is the trusted height of the EVM application.
26+
pub trusted_height: u64,
27+
// trusted_state_root is the state commitment root of the EVM application at trusted_height.
28+
pub trusted_state_root: [u8; 32],
29+
// new_height is the EVM application block number after N state transitions.
30+
pub new_height: u64,
31+
// new_state_root is the computed state root of the EVM application after
32+
// executing N blocks from trusted_height to new_height.
33+
pub new_state_root: [u8; 32],
3434
}
3535

3636
/// A buffer of serializable/deserializable objects.

crates/sp1/evm-exec/program/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn main() {
4545
println!("cycle-tracker-start: assert trusted state root");
4646

4747
assert_eq!(
48-
client_executor_input.current_block.state_root.as_slice(),
48+
client_executor_input.parent_state.state_root().as_slice(),
4949
trusted_state_root,
5050
"Current block state root does not match trusted root"
5151
);

crates/sp1/evm-range-exec/program/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn main() {
3131
assert_eq!(
3232
vkeys.len(),
3333
public_values.len(),
34-
"Mismatch between number of verification keys and public value blobs"
34+
"mismatch between number of verification keys and public value blobs"
3535
);
3636

3737
let proof_count = vkeys.len();
@@ -67,7 +67,7 @@ pub fn main() {
6767
assert_eq!(
6868
curr.prev_header_hash,
6969
prev.header_hash,
70-
"Header linkage failed at index {}: expected {:?}, got {:?}",
70+
"verify sequential headers failed at index {}: expected {:?}, got {:?}",
7171
i + 1,
7272
prev.header_hash,
7373
curr.prev_header_hash
@@ -84,11 +84,12 @@ pub fn main() {
8484
let celestia_header_hashes: Vec<_> = outputs.iter().map(|o| o.celestia_header_hash).collect();
8585

8686
let range_output = EvmRangeExecOutput {
87-
oldest_header_hash: first.header_hash,
88-
newest_header_hash: last.header_hash,
89-
newest_state_root: last.state_root,
90-
newest_height: last.height,
91-
celestia_header_hashes,
87+
celestia_header_hashes: celestia_header_hashes,
88+
celestia_header_hash: [0u8; 32], // TODO: assign this correctly
89+
trusted_height: first.height, // should be first.trusted_height
90+
trusted_state_root: first.trusted_state_root,
91+
new_state_root: last.state_root,
92+
new_height: last.height,
9293
};
9394

9495
sp1_zkvm::io::commit(&range_output);

0 commit comments

Comments
 (0)