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

add bytecode and rw circuit test #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions lib/assigner/evmone/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ struct instructions {
state.rw_trace.push_back(stack_operation<BlueprintFieldType>(state.call_id, stack.size(state.stack_space.bottom())-3, state.rw_trace.size(), false, stack[2]));
state.rw_trace.push_back(stack_operation<BlueprintFieldType>(state.call_id, stack.size(state.stack_space.bottom())-2, state.rw_trace.size(), false, stack[1]));
state.rw_trace.push_back(stack_operation<BlueprintFieldType>(state.call_id, stack.size(state.stack_space.bottom())-1, state.rw_trace.size(), false, stack[0]));
const auto& x = stack[0];
const auto& y = stack[1];
auto& m = stack[2];
const auto& x = stack.pop();
const auto& y = stack.pop();
auto& m = stack.top();
m = x.mulmod(y, m);
state.rw_trace.push_back(stack_operation<BlueprintFieldType>(state.call_id, stack.size(state.stack_space.bottom())-1, state.rw_trace.size(), true, stack[0]));
}
Expand Down Expand Up @@ -966,8 +966,8 @@ struct instructions {
if (!check_memory(gas_left, state.memory, index, 1))
return {EVMC_OUT_OF_GAS, gas_left};

const auto addr = (int)index.to_uint64();
state.memory[addr] = value.to_uint64();
const auto addr = index.to_uint64();
value.template store<uint64_t>(&state.memory[addr]);
for(uint64_t j = 0; j < 8; j++){
state.rw_trace.push_back(nil::evm_assigner::memory_operation<BlueprintFieldType>(state.call_id, addr + j, state.rw_trace.size(), true, state.memory[addr + j]));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/assigner/include/bytecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace nil {
} else {
// BYTE
bytecode_table.witness(TAG, start_row_index + cur) = 1;
bytecode_table.witness(INDEX, start_row_index + cur) = j-1;
bytecode_table.witness(INDEX, start_row_index + cur) = j-1; // TODO: why j-1? Index is 0 for both j == 0 and j == 1
bytecode_table.witness(LENGTH_LEFT, start_row_index + cur) = prev_length - 1;
prev_length = prev_length - 1;
if (push_size == 0) {
Expand Down
8 changes: 8 additions & 0 deletions lib/assigner/include/zkevm_word.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ namespace nil {
value = v;
}

zkevm_word(uint32_t v) {
value = v;
}

zkevm_word(int64_t v) {
value = v;
}
Expand All @@ -50,6 +54,10 @@ namespace nil {
value = v;
}

zkevm_word(uint64_t v0,uint64_t v1,uint64_t v2,uint64_t v3) {
value = {v0, v1, v2, v3};
}

zkevm_word(const evmc::uint256be& v) {
value = intx::be::load<intx::uint256>(v);
}
Expand Down
Loading
Loading