-
Notifications
You must be signed in to change notification settings - Fork 131
refactor(l2): decouple guest program IO #5314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5f0a6cb
f777ec9
9a0a319
fc26c10
970723b
5356bc4
d969a55
e3554db
aa05276
ca31545
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,19 +3,17 @@ use serde::{Deserialize, Serialize}; | |||||
|
|
||||||
| /// Public output variables exposed by the zkVM execution program. Some of these are part of | ||||||
| /// the program input. | ||||||
| #[cfg(feature = "l2")] | ||||||
| #[derive(Serialize, Deserialize)] | ||||||
| pub struct ProgramOutput { | ||||||
| /// initial state trie root hash | ||||||
| pub initial_state_hash: H256, | ||||||
| /// final state trie root hash | ||||||
| pub final_state_hash: H256, | ||||||
| #[cfg(feature = "l2")] | ||||||
| /// merkle root of all messages in a batch | ||||||
| pub l1messages_merkle_root: H256, | ||||||
| #[cfg(feature = "l2")] | ||||||
| /// hash of all the privileged transactions made in a batch | ||||||
| pub privileged_transactions_hash: H256, | ||||||
| #[cfg(feature = "l2")] | ||||||
| /// blob commitment versioned hash | ||||||
| pub blob_versioned_hash: H256, | ||||||
| /// hash of the last block in a batch | ||||||
|
|
@@ -26,16 +24,14 @@ pub struct ProgramOutput { | |||||
| pub non_privileged_count: U256, | ||||||
| } | ||||||
|
|
||||||
| #[cfg(feature = "l2")] | ||||||
| impl ProgramOutput { | ||||||
| pub fn encode(&self) -> Vec<u8> { | ||||||
| [ | ||||||
| self.initial_state_hash.to_fixed_bytes(), | ||||||
| self.final_state_hash.to_fixed_bytes(), | ||||||
| #[cfg(feature = "l2")] | ||||||
| self.l1messages_merkle_root.to_fixed_bytes(), | ||||||
| #[cfg(feature = "l2")] | ||||||
| self.privileged_transactions_hash.to_fixed_bytes(), | ||||||
| #[cfg(feature = "l2")] | ||||||
| self.blob_versioned_hash.to_fixed_bytes(), | ||||||
| self.last_block_hash.to_fixed_bytes(), | ||||||
| self.chain_id.to_big_endian(), | ||||||
|
|
@@ -44,3 +40,34 @@ impl ProgramOutput { | |||||
| .concat() | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// Public output variables exposed by the zkVM execution program. Some of these are part of | ||||||
| /// the program input. | ||||||
| #[cfg(not(feature = "l2"))] | ||||||
| #[derive(Serialize, Deserialize)] | ||||||
| pub struct ProgramOutput { | ||||||
| /// initial state trie root hash | ||||||
| pub initial_state_hash: H256, | ||||||
| /// final state trie root hash | ||||||
| pub final_state_hash: H256, | ||||||
| /// hash of the last block in a batch | ||||||
|
||||||
| /// hash of the last block in a batch | |
| /// hash of the block |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The L1 ProgramOutput struct and its encode() implementation are duplicated from the L2 version. Consider using a macro or shared implementation to reduce code duplication and make maintenance easier. For example, you could define common fields in a macro and compose the different variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment starts with a lowercase letter "blocks to execute" while the corresponding L1 comment starts with an uppercase "Block to execute". For consistency, consider capitalizing this to "Blocks to execute".