Skip to content

Commit

Permalink
Fixed RW padding #95
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova committed Dec 4, 2024
1 parent b6424a1 commit 476826c
Show file tree
Hide file tree
Showing 85 changed files with 6,385 additions and 1,554 deletions.
393 changes: 393 additions & 0 deletions crypto3/libs/blueprint/include/nil/blueprint/bbf/exp.hpp

Large diffs are not rendered by default.

304 changes: 304 additions & 0 deletions crypto3/libs/blueprint/include/nil/blueprint/bbf/exp_wrapper.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace nil {

void allocate(TYPE &C, size_t col, size_t row, column_type t) {
if (is_allocated(col, row, t)) {
BOOST_LOG_TRIVIAL(warning) << "RE-allocation of " << t << " cell at col = " << col << ", row = " << row << ".\n";
// BOOST_LOG_TRIVIAL(warning) << "RE-allocation of " << t << " cell at col = " << col << ", row = " << row << ".\n";
}
if (t == column_type::constant) {
auto [has_vars, min_row, max_row] = expression_row_range_visitor<var>::row_range(C);
Expand Down
306 changes: 0 additions & 306 deletions crypto3/libs/blueprint/include/nil/blueprint/zkevm/operations/div.hpp

This file was deleted.

276 changes: 0 additions & 276 deletions crypto3/libs/blueprint/include/nil/blueprint/zkevm/state_selector.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//---------------------------------------------------------------------------//

#pragma once

#include <nil/blueprint/zkevm_bbf/types/hashed_buffers.hpp>
#include <nil/blueprint/zkevm_bbf/subcomponents/bytecode_table.hpp>
#include <nil/blueprint/zkevm_bbf/subcomponents/keccak_table.hpp>
Expand Down
15 changes: 8 additions & 7 deletions crypto3/libs/blueprint/include/nil/blueprint/zkevm_bbf/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace nil {
witness_amount += KeccakTable::get_witness_amount();
witness_amount += CopyTable::get_witness_amount();
nil::crypto3::zk::snark::plonk_table_description<FieldType> desc(witness_amount, 1, 3, 10);
desc.usable_rows_amount = std::max(std::max(max_copy, max_rw), std::max(max_keccak_blocks, max_bytecode));
desc.usable_rows_amount = std::max(std::max(max_copy, max_rw + 1), std::max(max_keccak_blocks + 1, max_bytecode + 1));
return desc;
}
copy(context_type &context_object,
Expand Down Expand Up @@ -107,9 +107,11 @@ namespace nil {
rw_lookup_area.push_back(current_column++);
}

context_type bytecode_ct = context_object.subcontext(bytecode_lookup_area,0,max_bytecode);
context_type keccak_ct = context_object.subcontext( keccak_lookup_area, 0, max_keccak_blocks);
context_type rw_ct = context_object.subcontext(rw_lookup_area,0,max_rw);
// Dynamic lookups shouldn't be placed on 0 row.
context_type bytecode_ct = context_object.subcontext(bytecode_lookup_area,1,max_bytecode + 1);
context_type keccak_ct = context_object.subcontext( keccak_lookup_area, 1, max_keccak_blocks + 1);
context_type rw_ct = context_object.subcontext(rw_lookup_area, 1, max_rw + 1);

context_type copy_ct = context_object.subcontext( copy_lookup_area, 0, max_copy);

BytecodeTable bc_t = BytecodeTable(bytecode_ct, input.bytecodes, max_bytecode);
Expand Down Expand Up @@ -138,9 +140,8 @@ namespace nil {
std::cout
<< "\tCopy event " << copy_op_to_num(cp.source_type)
<< " => " << copy_op_to_num(cp.destination_type)
<< " bytes size " << cp.bytes.size()
<< " bytes size" << cp.bytes.size()
<< std::endl;
assert(cp.bytes.size() > 0);
for( std::size_t i = 0; i < cp.bytes.size(); i++ ){
std::cout << std::hex << std::size_t(cp.bytes[i]) << " " << std::dec;
bytes[current_row] = cp.bytes[i];
Expand Down Expand Up @@ -198,7 +199,7 @@ namespace nil {
std::vector<TYPE> every;
std::vector<TYPE> non_first;

every.push_back(context_object.relativize(is_write[1] * (is_write[1] - 1), -1));
// every.push_back(context_object.relativize(is_write[1] * (is_write[1] - 1), -1));
every.push_back(context_object.relativize(is_first[1] * (is_first[1] - 1), -1));
every.push_back(context_object.relativize(is_last[1] * (is_last[1] - 1), -1));
TYPE type_selector_sum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ namespace nil {
_rw_operations.push_back(stack_rw_operation(call_id, stack.size()-1, rw_counter++, false, stack[stack.size()-1]));
_rw_operations.push_back(stack_rw_operation(call_id, stack.size()-2, rw_counter++, false, stack[stack.size()-2]));
_rw_operations.push_back(stack_rw_operation(call_id, stack_next.size()-1, rw_counter++, true, stack_next[stack_next.size()-1]));
_exponentiations.push_back({stack[stack.size() - 1], stack[stack.size() - 2]});
} else if(opcode == "SIGEXTEND") {
// 0x0b
_rw_operations.push_back(stack_rw_operation(call_id, stack.size()-1, rw_counter++, false, stack[stack.size()-1]));
Expand Down
Loading

0 comments on commit 476826c

Please sign in to comment.