This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
148 additions
and
53 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
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
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,78 @@ | ||
use std::marker::PhantomData; | ||
|
||
use crate::evm_circuit::{ | ||
execution::ExecutionGadget, | ||
step::ExecutionState, | ||
util::{ | ||
constraint_builder::{EVMConstraintBuilder, StepStateTransition}, | ||
CachedRegion, | ||
}, | ||
witness::{Block, Call, ExecStep, Transaction}, | ||
}; | ||
use eth_types::Field; | ||
use halo2_proofs::plonk::Error; | ||
|
||
#[derive(Clone, Debug)] | ||
pub(crate) struct PaddingGadget<F> { | ||
_phantom: PhantomData<F>, | ||
} | ||
|
||
impl<F: Field> ExecutionGadget<F> for PaddingGadget<F> { | ||
const NAME: &'static str = "Padding"; | ||
|
||
const EXECUTION_STATE: ExecutionState = ExecutionState::Padding; | ||
|
||
fn configure(cb: &mut EVMConstraintBuilder<F>) -> Self { | ||
cb.require_step_state_transition(StepStateTransition { | ||
..StepStateTransition::same() | ||
}); | ||
|
||
Self { | ||
_phantom: PhantomData, | ||
} | ||
} | ||
|
||
fn assign_exec_step( | ||
&self, | ||
_region: &mut CachedRegion<'_, '_, F>, | ||
_offset: usize, | ||
_block: &Block<F>, | ||
_: &Transaction, | ||
_: &Call, | ||
_step: &ExecStep, | ||
) -> Result<(), Error> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use crate::test_util::CircuitTestBuilder; | ||
|
||
use eth_types::bytecode; | ||
|
||
use mock::TestContext; | ||
|
||
fn test_circuit(evm_circuit_pad_to: usize) { | ||
let bytecode = bytecode! { | ||
PUSH1(0) | ||
STOP | ||
}; | ||
|
||
let ctx = TestContext::<2, 1>::simple_ctx_with_bytecode(bytecode).unwrap(); | ||
|
||
// finish required tests using this witness block | ||
CircuitTestBuilder::<2, 1>::new_from_test_ctx(ctx) | ||
.block_modifier(Box::new(move |block| { | ||
block.circuits_params.max_evm_rows = evm_circuit_pad_to | ||
})) | ||
.run(); | ||
} | ||
|
||
// Test where the EVM circuit has a fixed size and contains several Padding | ||
// at the end after the trace steps | ||
#[test] | ||
fn padding() { | ||
test_circuit(50); | ||
} | ||
} |
Oops, something went wrong.