Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust to PR comments
Browse files Browse the repository at this point in the history
x-mass committed Jan 8, 2025
1 parent 93f79a7 commit 2c2879b
Showing 10 changed files with 11 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -14,14 +14,15 @@
namespace nil {
namespace proof_generator {

template<typename BlueprintFieldType>
using AssignmentTableFiller = std::function<std::optional<std::string>(
crypto3::zk::snark::plonk_assignment_table<nil::crypto3::algebra::fields::pallas_fq>& assignment_table,
crypto3::zk::snark::plonk_assignment_table<BlueprintFieldType>& assignment_table,
const boost::filesystem::path& trace_base_path,
const AssignerOptions& options)
>;

template<typename BlueprintFieldType>
std::map<const std::string, AssignmentTableFiller> circuit_selector = {
std::map<const std::string, AssignmentTableFiller<BlueprintFieldType>> circuit_selector = {
{circuits::BYTECODE, fill_bytecode_assignment_table<BlueprintFieldType>},
{circuits::RW, fill_rw_assignment_table<BlueprintFieldType>},
{circuits::ZKEVM, fill_zkevm_assignment_table<BlueprintFieldType>},
Original file line number Diff line number Diff line change
@@ -19,8 +19,6 @@ namespace nil {
std::optional<std::string> fill_bytecode_assignment_table(nil::crypto3::zk::snark::plonk_assignment_table<BlueprintFieldType>& assignment_table,
const boost::filesystem::path& trace_base_path,
const AssignerOptions& options) {
// TODO: print full name here, not only base
BOOST_LOG_TRIVIAL(debug) << "fill bytecode table from " << trace_base_path << "\n";

using ComponentType = nil::blueprint::bbf::bytecode<BlueprintFieldType, nil::blueprint::bbf::GenerationStage::ASSIGNMENT>;

@@ -30,6 +28,7 @@ namespace nil {
input.rlc_challenge = limits::RLC_CHALLENGE;

const auto bytecode_trace_path = get_bytecode_trace_path(trace_base_path);
BOOST_LOG_TRIVIAL(debug) << "fill bytecode table from " << bytecode_trace_path << "\n";
const auto contract_bytecodes = deserialize_bytecodes_from_file(bytecode_trace_path, options);
if (!contract_bytecodes) {
return "can't read bytecode trace from file: " + bytecode_trace_path.string();
Original file line number Diff line number Diff line change
@@ -143,10 +143,6 @@ namespace nil {
return res;
}

[[nodiscard]] std::string get_trace_extension(const boost::filesystem::path& trace_path) {
return trace_path.extension().string();
}

using TraceIndex = uint64_t; // value expected to be the same for all traces from the same set
using TraceIndexOpt = std::optional<TraceIndex>;

@@ -160,7 +156,6 @@ namespace nil {
return true;
}


template <typename TraceType>
struct DeserializeResult {
TraceType value;
@@ -197,7 +192,7 @@ namespace nil {
}

return DeserializeResult<BytecodeTraces>{
std::move(contract_bytecodes),
std::move(contract_bytecodes),
pb_traces->trace_idx()
};
}
@@ -265,7 +260,7 @@ namespace nil {
<< "storage " << pb_traces->storage_ops_size() << "\n";

return DeserializeResult<RWTraces>{
std::move(rw_traces),
std::move(rw_traces),
pb_traces->trace_idx()
};
}
@@ -314,7 +309,7 @@ namespace nil {
}

return DeserializeResult<ZKEVMTraces>{
std::move(zkevm_states),
std::move(zkevm_states),
pb_traces->trace_idx()
};
}
@@ -363,7 +358,7 @@ namespace nil {
}

return DeserializeResult<CopyEvents>{
std::move(copy_events),
std::move(copy_events),
pb_traces->trace_idx()
};
}
@@ -392,8 +387,8 @@ namespace nil {
}

return DeserializeResult<ExpTraces>{
std::move(exps),
pb_traces->trace_idx()
std::move(exps),
pb_traces->trace_idx()
};
}
} // namespace proof_generator
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ namespace nil {
}
input.copy_events = std::move(copy_events->value);

// TODO: fix assignment table filling
// const auto exp_trace_path = get_exp_trace_path(trace_base_path);
// const auto exp_operations = deserialize_exp_traces_from_file(exp_trace_path, options, contract_bytecodes->index);
// if (!exp_operations) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -78,25 +78,6 @@ INSTANTIATE_TEST_SUITE_P(MultiTxBytecode, ProverTests, :: testing::Values(Input{
INSTANTIATE_TEST_SUITE_P(MultiTxCopy, ProverTests, ::testing::Values(Input{MultiTxIncrement, COPY}));
INSTANTIATE_TEST_SUITE_P(MultiTxZkevm, ProverTests, ::testing::Values(Input{MultiTxIncrement, ZKEVM}));

// Multiple calls of Counter contract increment function within multiple blocks
// FAILING SO FAR (T.T)
// const std::string MultiBlockIncrement = "increment_multi_block";
// INSTANTIATE_TEST_SUITE_P(MultiBlockRw, ProverTests, ::testing::Values(Input{MultiBlockIncrement, RW}));
// INSTANTIATE_TEST_SUITE_P(MultiBlockBytecode, ProverTests, :: testing::Values(Input{MultiBlockIncrement, BYTECODE}));
// INSTANTIATE_TEST_SUITE_P(MultiBlockCopy, ProverTests, ::testing::Values(Input{MultiBlockIncrement, COPY}));
// INSTANTIATE_TEST_SUITE_P(MultiBlockZkevm, ProverTests, ::testing::Values(Input{MultiBlockIncrement, ZKEVM}));


// Useful commands for traces collection:
// start nild: `./build/bin/nild run --http-port 8529 -l debug --collator-tick-ms 20000`
// `collator-tick-ms` here is how long one block is absorbing transactions.
// compile contract: `solc -o . --bin --abi example/counter.sol --overwrite`
// increase `defaultNewWalletAmount` value in nil/cmd/nil/internal/wallet/new.go to be able to create account with whale balance
// ./build/bin/nil wallet new --amount 100000000000000000
// ./build/bin/nil wallet deploy ./SimpleStorage.bin --abi ./SimpleStorage.abi
// for i in {1..100}; do ./build/bin/nil wallet send-message 0x0001443b27c605cc3975e05e8eb68eef1913777c increment --abi ./SimpleStorage.abi --no-wait; done


// RW trace is picked from another trace set and has different trace_idx
TEST(ProverTest, TraceIndexMismatch) {
const std::string trace_base_path = std::string(TEST_DATA_DIR) + "/broken_index/increment_simple.pb";

0 comments on commit 2c2879b

Please sign in to comment.