Skip to content

Commit

Permalink
add bytecode and rw circuit test
Browse files Browse the repository at this point in the history
  • Loading branch information
CblPOK-git committed Jul 29, 2024
1 parent f596f52 commit 29e7ad7
Show file tree
Hide file tree
Showing 4 changed files with 768 additions and 36 deletions.
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

0 comments on commit 29e7ad7

Please sign in to comment.