Skip to content
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

feat: A0-A4 - LOG0-4 Opcode #322

Merged
merged 42 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
92561a1
mstore tests impl
Quentash Sep 6, 2023
b6804f5
made exec_mstore panic
Quentash Sep 6, 2023
80edce9
corrected test case error
Quentash Sep 6, 2023
a4f4597
mstore opcode impl
Quentash Sep 6, 2023
80264ac
review correction + add 2 tests
Quentash Sep 6, 2023
16cfa56
Merge branch 'feat/mstoretests' into feat/mstoreimpl
Quentash Sep 6, 2023
3b06efa
correction test case
Quentash Sep 6, 2023
e24598d
Merge branch 'feat/mstoretests' into feat/mstoreimpl
Quentash Sep 6, 2023
0224cfe
used pop_n instead
Quentash Sep 6, 2023
6042b2e
corrected #263 succeed into succeeded
Quentash Sep 6, 2023
ae6c067
Merge branch 'main' into feat/mstoreimpl
Quentash Sep 7, 2023
86cc9b1
reverted to single pop + removed tests
Quentash Sep 7, 2023
bab2bff
Merge branch 'main' into feat/mstoreimpl
Quentash Sep 7, 2023
34c0d3b
first commit
Quentash Sep 7, 2023
29015b2
Merge branch 'main' into feat/lognopcode
Quentash Sep 8, 2023
0a6cea7
removed print and used default for array
Quentash Sep 8, 2023
45f9e27
added readonly test & cleaned imports
Quentash Sep 8, 2023
c31e984
added internal get_datas
Quentash Sep 13, 2023
211719b
need to merge main
Quentash Sep 15, 2023
17e0f35
Merge branch 'main' into feat/lognopcode
Quentash Sep 15, 2023
c221d5c
removed ',' from merge
Quentash Sep 15, 2023
1f13db4
check load vs loadn
Quentash Sep 15, 2023
89b4872
switch data array from felt to u8
Quentash Sep 22, 2023
9d1c40c
Merge branch 'main' into feat/lognopcode
Quentash Sep 22, 2023
a800070
cleaned code/tests
Quentash Sep 22, 2023
f8bce7a
review correction
Quentash Sep 25, 2023
c54baa1
Merge branch 'main' into feat/lognopcode
Quentash Sep 25, 2023
b9512c4
compare all bytes in tests + inlined app_event
Quentash Sep 25, 2023
2e8de3c
stop useless slicing
Quentash Sep 25, 2023
717a6e4
added tests cases
Quentash Sep 25, 2023
a16352c
Merge branch 'main' into feat/lognopcode
Eikix Sep 27, 2023
e3e79dc
simplified expected array
Quentash Sep 27, 2023
68dabd6
Merge branch 'main' into feat/lognopcode
Quentash Sep 27, 2023
84e6771
Merge branch 'main' into feat/lognopcode
Quentash Oct 2, 2023
eec7854
merge correction
Quentash Oct 3, 2023
8be21f6
cleaned imports
Quentash Oct 3, 2023
9ef47fd
Merge branch 'main' into feat/lognopcode
Quentash Oct 3, 2023
2d7917c
scarb fmt did that
Quentash Oct 3, 2023
bffc21e
dupl app_event + setup_readonly
Quentash Oct 3, 2023
54cc27e
change error message + setup with readonly
Quentash Oct 4, 2023
6fc92f5
Merge branch 'main' into feat/lognopcode
Quentash Oct 4, 2023
e2844c0
correction rebase
Quentash Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/evm/src/context.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,9 @@ impl ExecutionContextImpl of ExecutionContextTrait {
fn pc(self: @ExecutionContext) -> u32 {
*self.program_counter
}

#[inline(always)]
fn append_event(ref self: ExecutionContext, event: Event) {
self.events.append(event);
}
}
11 changes: 1 addition & 10 deletions crates/evm/src/machine.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,10 @@ impl MachineCurrentContextImpl of MachineCurrentContextTrait {
current_call_ctx.read_only()
}

#[inline(always)]
fn set_read_only(ref self: Machine, value: bool) {
let mut current_call_ctx = self.call_context();
let mut current_execution_ctx = self.current_context.unbox();
current_call_ctx.read_only = value;
current_execution_ctx.call_context = BoxTrait::new(current_call_ctx);
self.current_context = BoxTrait::new(current_execution_ctx);
}

#[inline(always)]
fn append_event(ref self: Machine, event: Event) {
Quentash marked this conversation as resolved.
Show resolved Hide resolved
let mut current_execution_ctx = self.current_context.unbox();
current_execution_ctx.events.append(event);
current_execution_ctx.append_event(event);
self.current_context = BoxTrait::new(current_execution_ctx);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use evm::instructions::LoggingOperationsTrait;
use evm::machine::{Machine, MachineCurrentContextTrait};
use evm::memory::MemoryTrait;
use evm::stack::StackTrait;
use evm::tests::test_utils::setup_machine;
use evm::tests::test_utils::{setup_machine, setup_machine_with_read_only};
use integer::BoundedInt;
use utils::helpers::u256_to_bytes_array;

Expand Down Expand Up @@ -180,8 +180,7 @@ fn test_exec_log4() {
#[available_gas(20000000)]
fn test_exec_log1_read_only_context() {
// Given
let mut machine = setup_machine();
machine.set_read_only(true);
let mut machine = setup_machine_with_read_only();

machine.memory.store(BoundedInt::<u256>::max(), 0);

Expand Down
40 changes: 40 additions & 0 deletions crates/evm/src/tests/test_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,43 @@ fn setup_machine_with_calldata(calldata: Span<u8>) -> Machine {
storage_journal: Default::default(),
}
}

fn setup_machine_with_read_only() -> Machine {
Machine {
Eikix marked this conversation as resolved.
Show resolved Hide resolved
current_context: BoxTrait::new(setup_execution_context_with_read_only()),
ctx_count: 1,
stack: Default::default(),
memory: Default::default(),
storage_journal: Default::default(),
}
}

fn setup_execution_context_with_read_only() -> ExecutionContext {
let context_id = 0;
let call_context = setup_call_context_with_read_only();
let starknet_address: ContractAddress = starknet_address();
let evm_address: EthAddress = evm_address();
let return_data = Default::default();

ExecutionContextTrait::new(
context_id,
evm_address,
starknet_address,
call_context,
Default::default(),
Default::default(),
return_data,
)
}

fn setup_call_context_with_read_only() -> CallContext {
let bytecode: Span<u8> = array![1, 2, 3].span();
let calldata: Span<u8> = array![4, 5, 6].span();
let value: u256 = callvalue();
let address = evm_address();
let read_only = true;
let gas_price = 0xaaaaaa;
let gas_limit = 0xffffff;

CallContextTrait::new(address, bytecode, calldata, value, read_only, gas_limit, gas_price)
}