Skip to content

Commit

Permalink
Merge branch 'main' into ci/add_era_benches
Browse files Browse the repository at this point in the history
  • Loading branch information
fkrause98 committed Aug 19, 2024
2 parents 2bbeea0 + ca40330 commit 3f4510d
Show file tree
Hide file tree
Showing 44 changed files with 1,049 additions and 865 deletions.
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[submodule "era-compiler-tester"]
path = era-compiler-tester
url = https://github.com/lambdaclass/era-compiler-tester.git
[submodule "zksync-era"]
path = zksync-era
url = https://github.com/lambdaclass/zksync-era.git
2 changes: 1 addition & 1 deletion era-compiler-tester
Submodule era-compiler-tester updated from d640c6 to 85f5cb
20 changes: 10 additions & 10 deletions src/address_operands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ use zkevm_opcode_defs::{ImmMemHandlerFlags, Operand, RegOrImmFlags};

use crate::{
eravm_error::{EraVmError, OperandError},
state::VMState,
execution::Execution,
utils::LowUnsigned,
value::TaggedValue,
Opcode,
};

fn only_reg_read(vm: &VMState, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
fn only_reg_read(vm: &Execution, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
let src0 = vm.get_register(opcode.src0_index);
let src1 = vm.get_register(opcode.src1_index);
(src0, src1)
}

fn only_imm16_read(vm: &VMState, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
fn only_imm16_read(vm: &Execution, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
let src1 = vm.get_register(opcode.src1_index);
(TaggedValue::new_raw_integer(U256::from(opcode.imm0)), src1)
}

fn reg_and_imm_read(vm: &VMState, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
fn reg_and_imm_read(vm: &Execution, opcode: &Opcode) -> (TaggedValue, TaggedValue) {
let src0 = vm.get_register(opcode.src0_index);
let src1 = vm.get_register(opcode.src1_index);
let offset = opcode.imm0;
Expand All @@ -32,7 +32,7 @@ fn reg_and_imm_read(vm: &VMState, opcode: &Opcode) -> (TaggedValue, TaggedValue)
}

pub fn address_operands_read(
vm: &mut VMState,
vm: &mut Execution,
opcode: &Opcode,
) -> Result<(TaggedValue, TaggedValue), EraVmError> {
let (op1, op2) = match opcode.src0_operand_type {
Expand Down Expand Up @@ -105,7 +105,7 @@ enum OutputOperandPosition {
}

fn only_reg_write(
vm: &mut VMState,
vm: &mut Execution,
opcode: &Opcode,
output_op_pos: OutputOperandPosition,
res: TaggedValue,
Expand All @@ -116,30 +116,30 @@ fn only_reg_write(
}
}

fn dest_stack_address(vm: &mut VMState, opcode: &Opcode) -> TaggedValue {
fn dest_stack_address(vm: &mut Execution, opcode: &Opcode) -> TaggedValue {
let dst0 = vm.get_register(opcode.dst0_index);
let offset = opcode.imm1;
dst0 + TaggedValue::new_raw_integer(U256::from(offset))
}

pub fn address_operands_store(
vm: &mut VMState,
vm: &mut Execution,
opcode: &Opcode,
res: TaggedValue,
) -> Result<(), EraVmError> {
address_operands(vm, opcode, (res, None))
}

pub fn address_operands_div_mul(
vm: &mut VMState,
vm: &mut Execution,
opcode: &Opcode,
res: (TaggedValue, TaggedValue),
) -> Result<(), EraVmError> {
address_operands(vm, opcode, (res.0, Some(res.1)))
}

fn address_operands(
vm: &mut VMState,
vm: &mut Execution,
opcode: &Opcode,
res: (TaggedValue, Option<TaggedValue>),
) -> Result<(), EraVmError> {
Expand Down
27 changes: 8 additions & 19 deletions src/call_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ use std::num::Saturating;
use u256::U256;
use zkevm_opcode_defs::ethereum_types::Address;

use crate::{state::Stack, store::SnapShot, utils::is_kernel};
use crate::{execution::Stack, state::StateSnapshot, utils::is_kernel};

#[derive(Debug, Clone)]
pub struct CallFrame {
pub pc: u64,
pub transient_storage_snapshot: SnapShot,
pub gas_left: Saturating<u32>,
pub exception_handler: u64,
pub sp: u32,
pub storage_snapshot: SnapShot,
pub snapshot: StateSnapshot,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -64,17 +63,11 @@ impl Context {
calldata_heap_id: u32,
exception_handler: u64,
context_u128: u128,
transient_storage_snapshot: SnapShot,
storage_snapshot: SnapShot,
snapshot: StateSnapshot,
is_static: bool,
) -> Self {
Self {
frame: CallFrame::new_far_call_frame(
gas_stipend,
exception_handler,
storage_snapshot,
transient_storage_snapshot,
),
frame: CallFrame::new_far_call_frame(gas_stipend, exception_handler, snapshot),
near_call_frames: vec![],
contract_address,
caller,
Expand All @@ -98,16 +91,14 @@ impl CallFrame {
pub fn new_far_call_frame(
gas_stipend: u32,
exception_handler: u64,
storage_snapshot: SnapShot,
transient_storage_snapshot: SnapShot,
snapshot: StateSnapshot,
) -> Self {
Self {
pc: 0,
gas_left: Saturating(gas_stipend),
transient_storage_snapshot,
exception_handler,
sp: 0,
storage_snapshot,
snapshot,
}
}

Expand All @@ -116,17 +107,15 @@ impl CallFrame {
sp: u32,
pc: u64,
gas_stipend: u32,
transient_storage_snapshot: SnapShot,
exception_handler: u64,
storage_snapshot: SnapShot,
snapshot: StateSnapshot,
) -> Self {
Self {
pc,
gas_left: Saturating(gas_stipend),
transient_storage_snapshot,
exception_handler,
sp,
storage_snapshot,
snapshot,
}
}
}
Loading

0 comments on commit 3f4510d

Please sign in to comment.