-
Notifications
You must be signed in to change notification settings - Fork 146
fix(l2): override execution witness endpoint #5063
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| use ethrex_rpc::{ | ||
| RpcErr, | ||
| debug::execution_witness::{ExecutionWitnessRequest, RpcExecutionWitness}, | ||
| }; | ||
| use serde_json::Value; | ||
| use tracing::debug; | ||
|
|
||
| use crate::rpc::RpcApiContext; | ||
|
|
||
| /// Copy of the L1 handler for execution witness, but | ||
| /// fetches fee configs from the rollup store, as they can vary from block to block. | ||
| pub async fn handle_execution_witness( | ||
| request: &ExecutionWitnessRequest, | ||
| context: RpcApiContext, | ||
| ) -> Result<Value, RpcErr> { | ||
| let from_block_number = request | ||
| .from | ||
| .resolve_block_number(&context.l1_ctx.storage) | ||
| .await? | ||
| .ok_or(RpcErr::Internal( | ||
| "Failed to resolve block number".to_string(), | ||
| ))?; | ||
| let to_block_number = request | ||
| .to | ||
| .as_ref() | ||
| .unwrap_or(&request.from) | ||
| .resolve_block_number(&context.l1_ctx.storage) | ||
| .await? | ||
| .ok_or(RpcErr::Internal( | ||
| "Failed to resolve block number".to_string(), | ||
| ))?; | ||
|
|
||
| if from_block_number > to_block_number { | ||
| return Err(RpcErr::BadParams( | ||
| "From block number is greater than To block number".to_string(), | ||
| )); | ||
| } | ||
|
|
||
| if request.to.is_some() { | ||
| debug!("Requested execution witness from block: {from_block_number} to {to_block_number}",); | ||
| } else { | ||
| debug!("Requested execution witness for block: {from_block_number}",); | ||
| } | ||
|
|
||
| let mut blocks = Vec::new(); | ||
| let mut fee_configs = Vec::new(); | ||
| for block_number in from_block_number..=to_block_number { | ||
| let header = context | ||
| .l1_ctx | ||
| .storage | ||
| .get_block_header(block_number)? | ||
| .ok_or(RpcErr::Internal("Could not get block header".to_string()))?; | ||
| let block = context | ||
| .l1_ctx | ||
| .storage | ||
| .get_block_by_hash(header.hash()) | ||
| .await? | ||
| .ok_or(RpcErr::Internal("Could not get block body".to_string()))?; | ||
| let fee_config = context | ||
| .rollup_store | ||
| .get_fee_config_by_block(block_number) | ||
| .await | ||
| .map_err(|e| RpcErr::Internal(format!("Failed to get fee config {e}")))? | ||
| .ok_or(RpcErr::Internal(format!( | ||
| "Fee config not found for block {}", | ||
| block_number | ||
| )))?; | ||
|
|
||
| blocks.push(block); | ||
| fee_configs.push(fee_config); | ||
| } | ||
|
|
||
| let execution_witness = context | ||
| .l1_ctx | ||
| .blockchain | ||
| .generate_witness_for_blocks_with_fee_configs(&blocks, Some(&fee_configs)) | ||
| .await | ||
| .map_err(|e| RpcErr::Internal(format!("Failed to build execution witness {e}")))?; | ||
|
|
||
| let rpc_execution_witness = RpcExecutionWitness::from(execution_witness); | ||
|
|
||
| serde_json::to_value(rpc_execution_witness).map_err(|error| RpcErr::Internal(error.to_string())) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| pub mod batch; | ||
| pub mod execution_witness; | ||
| pub mod fees; | ||
| pub mod l1_message; | ||
| pub mod transaction; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was unused