forked from scroll-tech/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement circuit for
ErrorOutOfGasSHA3
state (scroll-tech#419)
* Implement circuit for `ErrorOutOfGasSHA3` state. * Add `MemoryExpandedAddressGadget` to support memory offset plus length greater than `0x1FFFFFFFE0`.
- Loading branch information
1 parent
29af2d5
commit 4b071a6
Showing
8 changed files
with
483 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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,38 @@ | ||
use crate::{ | ||
circuit_input_builder::{CircuitInputStateRef, ExecStep}, | ||
error::{ExecError, OogError}, | ||
evm::Opcode, | ||
Error, | ||
}; | ||
use eth_types::{evm_types::OpcodeId, GethExecStep}; | ||
|
||
/// Placeholder structure used to implement [`Opcode`] trait over it | ||
/// corresponding to the [`OogError::Sha3`](crate::error::OogError::Sha3). | ||
#[derive(Clone, Copy, Debug)] | ||
pub(crate) struct OOGSha3; | ||
|
||
impl Opcode for OOGSha3 { | ||
fn gen_associated_ops( | ||
state: &mut CircuitInputStateRef, | ||
geth_steps: &[GethExecStep], | ||
) -> Result<Vec<ExecStep>, Error> { | ||
let geth_step = &geth_steps[0]; | ||
debug_assert_eq!(geth_step.op, OpcodeId::SHA3); | ||
|
||
let mut exec_step = state.new_step(geth_step)?; | ||
exec_step.error = Some(ExecError::OutOfGas(OogError::Sha3)); | ||
|
||
for i in 0..2 { | ||
state.stack_read( | ||
&mut exec_step, | ||
geth_step.stack.nth_last_filled(i), | ||
geth_step.stack.nth_last(i)?, | ||
)?; | ||
} | ||
|
||
state.gen_restore_context_ops(&mut exec_step, geth_steps)?; | ||
state.handle_return(geth_step)?; | ||
|
||
Ok(vec![exec_step]) | ||
} | ||
} |
This file contains 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 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 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 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.