mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 17:23:08 +00:00
Lints
This commit is contained in:
parent
7ab0bba559
commit
448bc719d8
@ -76,7 +76,13 @@ pub fn eval_ext_circuit_exit_kernel<F: RichField + Extendable<D>, const D: usize
|
||||
// See detailed comments in the packed implementation.
|
||||
{
|
||||
let stack_len_check_aux = lv.general.exit_kernel().stack_len_check_aux;
|
||||
let lhs = builder.arithmetic_extension(F::ONE, -F::from_canonical_u32(1026), lv.stack_len, stack_len_check_aux, stack_len_check_aux);
|
||||
let lhs = builder.arithmetic_extension(
|
||||
F::ONE,
|
||||
-F::from_canonical_u32(1026),
|
||||
lv.stack_len,
|
||||
stack_len_check_aux,
|
||||
stack_len_check_aux,
|
||||
);
|
||||
let constr = builder.add_extension(lhs, input[1]);
|
||||
let constr = builder.mul_sub_extension(filter, constr, filter);
|
||||
yield_constr.constraint(builder, constr);
|
||||
|
||||
@ -11,11 +11,11 @@ use crate::cpu::kernel::constants::txn_fields::NormalizedTxnField;
|
||||
use crate::memory::segments::Segment;
|
||||
|
||||
pub(crate) mod context_metadata;
|
||||
mod exc_bitfields;
|
||||
pub(crate) mod global_metadata;
|
||||
pub(crate) mod journal_entry;
|
||||
pub(crate) mod trie_type;
|
||||
pub(crate) mod txn_fields;
|
||||
mod exc_bitfields;
|
||||
|
||||
/// Constants that are accessible to our kernel assembly code.
|
||||
pub fn evm_constants() -> HashMap<String, U256> {
|
||||
|
||||
@ -508,7 +508,10 @@ pub(crate) fn generate_syscall<F: Field>(
|
||||
if state.registers.stack_len < stack_values_read {
|
||||
return Err(ProgramError::StackUnderflow);
|
||||
}
|
||||
if stack_len_increased && !state.registers.is_kernel && state.registers.stack_len >= MAX_USER_STACK_SIZE {
|
||||
if stack_len_increased
|
||||
&& !state.registers.is_kernel
|
||||
&& state.registers.stack_len >= MAX_USER_STACK_SIZE
|
||||
{
|
||||
return Err(ProgramError::StackOverflow);
|
||||
}
|
||||
|
||||
@ -593,7 +596,8 @@ pub(crate) fn generate_exit_kernel<F: Field>(
|
||||
if is_kernel_mode {
|
||||
row.general.exit_kernel_mut().stack_len_check_aux = F::ZERO;
|
||||
} else {
|
||||
let diff = F::from_canonical_usize(state.registers.stack_len + 1) - F::from_canonical_u32(1026);
|
||||
let diff =
|
||||
F::from_canonical_usize(state.registers.stack_len + 1) - F::from_canonical_u32(1026);
|
||||
if let Some(inv) = diff.try_inverse() {
|
||||
row.general.exit_kernel_mut().stack_len_check_aux = inv;
|
||||
} else {
|
||||
@ -713,8 +717,8 @@ pub(crate) fn generate_exception<F: Field>(
|
||||
let handler_addr = (handler_addr0 << 16) + (handler_addr1 << 8) + handler_addr2;
|
||||
let new_program_counter = handler_addr.as_usize();
|
||||
|
||||
let exc_info = U256::from(state.registers.program_counter)
|
||||
+ (U256::from(state.registers.gas_used) << 192);
|
||||
let exc_info =
|
||||
U256::from(state.registers.program_counter) + (U256::from(state.registers.gas_used) << 192);
|
||||
let log_out = stack_push_log_and_fill(state, &mut row, exc_info)?;
|
||||
|
||||
state.registers.program_counter = new_program_counter;
|
||||
|
||||
@ -207,7 +207,9 @@ fn perform_op<F: Field>(
|
||||
Operation::Not => generate_not(state, row)?,
|
||||
Operation::Shl => generate_shl(state, row)?,
|
||||
Operation::Shr => generate_shr(state, row)?,
|
||||
Operation::Syscall(opcode, stack_values_read, stack_len_increased) => generate_syscall(opcode, stack_values_read, stack_len_increased, state, row)?,
|
||||
Operation::Syscall(opcode, stack_values_read, stack_len_increased) => {
|
||||
generate_syscall(opcode, stack_values_read, stack_len_increased, state, row)?
|
||||
}
|
||||
Operation::Eq => generate_eq(state, row)?,
|
||||
Operation::BinaryLogic(binary_logic_op) => {
|
||||
generate_binary_logic_op(binary_logic_op, state, row)?
|
||||
@ -327,16 +329,18 @@ fn handle_error<F: Field>(state: &mut GenerationState<F>, err: ProgramError) ->
|
||||
ProgramError::InvalidJumpDestination => 3,
|
||||
ProgramError::InvalidJumpiDestination => 4,
|
||||
ProgramError::StackOverflow => 5,
|
||||
_ => bail!("TODO: figure out what to do with this...")
|
||||
_ => bail!("TODO: figure out what to do with this..."),
|
||||
};
|
||||
|
||||
let checkpoint = state.checkpoint();
|
||||
|
||||
let (row, _) = base_row(state);
|
||||
generate_exception(exc_code, state, row).map_err(|_| anyhow::Error::msg("error handling errored..."))?;
|
||||
generate_exception(exc_code, state, row)
|
||||
.map_err(|_| anyhow::Error::msg("error handling errored..."))?;
|
||||
|
||||
state.memory
|
||||
.apply_ops(state.traces.mem_ops_since(checkpoint.traces));
|
||||
state
|
||||
.memory
|
||||
.apply_ops(state.traces.mem_ops_since(checkpoint.traces));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user