Skip to content

Commit

Permalink
fix: output root version to 32 bytes (#248)
Browse files Browse the repository at this point in the history
* output root version to 32 bytes

* add test todo

* cleanup
  • Loading branch information
zobront authored Jun 14, 2024
1 parent 5d327d2 commit 7b3409d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions bin/programs/client/src/l2/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ where

// Construct the raw output.
let parent_header = self.state.database.parent_block_header();
let mut raw_output = [0u8; 97];
raw_output[0] = OUTPUT_ROOT_VERSION;
raw_output[1..33].copy_from_slice(parent_header.state_root.as_ref());
raw_output[33..65].copy_from_slice(storage_root.as_ref());
raw_output[65..97].copy_from_slice(parent_header.seal().as_ref());
let mut raw_output = [0u8; 128];
raw_output[31] = OUTPUT_ROOT_VERSION;
raw_output[32..64].copy_from_slice(parent_header.state_root.as_ref());
raw_output[64..96].copy_from_slice(storage_root.as_ref());
raw_output[96..128].copy_from_slice(parent_header.seal().as_ref());

// Hash the output and return
Ok(keccak256(raw_output))
Expand Down Expand Up @@ -986,4 +986,10 @@ mod test {
expected_header.hash_slow()
);
}

// TODO: Add a test that uses a block where the output root was confirmed on chain
// to test the `compute_output_root()` function.
// Example (verify at index 8833 on 0xdfe97868233d1aa22e815a266982f2cf17685a27):
// - Block: 121184863
// - Output Root: 0x3ea8b0e09b39e9daa1b1520fe59faef02de3656d230d876544952cbc44d6d71f
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
"c7497198fd71b065148600f8d429f78a1225ea1c748bd52dacf50006d13879cc": "f86f9d20d4f9173e3fb28f9fe9d497fff2a1b892abc4a3ebd43b4da711f040d4b84ff84d808924f866d61e4a4430a1a0623b8a4256e0148a5d8d6f51d4bd7e158ee8b06d1721d315a4f2f6d9b70be40fa01f958654ab06a152993e7a0ae7b6dbb0d4b19265cc9337b8789fe1353bd9dc35",
"00212a9db08b693fec90fc2df485aa56ba72ed267760447d1dffec9c3afe8de0": "f86f9d305bfd393f794ffb72fa82705568eaabce134fb31ba1fe1e3884f9818bb84ff84d808935af9c20be96afddc5a09ca6725859735c5f9c952ac47424409cbdbd152c326a2fb7e9eb8c3c80559937a01f958654ab06a152993e7a0ae7b6dbb0d4b19265cc9337b8789fe1353bd9dc35",
"b7a27b4f2673d087c9a6bd9a989ba07843dd931d60fbf9dbf8e2eb20ddd89ae5": "f8b1808080a048e4e9a9f144e6d5b7eec7e14954e92a94caf71089b5a8a210dbed2acb2ceefa808080a014df8ad7f324065ce8ec91675e9f390bf2875b29b7c025f7af78d6f37661bb128080a04c95cf2cb1d0d7b2548c4b6a16335f4c5ebba6ae74ffcba29096bbcd41cfd309a02dfc613c92fd0306fd7cb5154d91c666663eeab860e77d3170d0c61703fc13858080a002cfa79bb3d07c1925cb839bc75d2af700e78db291f586a85a4eba40368c5d718080"
}
}

0 comments on commit 7b3409d

Please sign in to comment.