-
Notifications
You must be signed in to change notification settings - Fork 10
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
proof-producer: introduce command chain #258
base: master
Are you sure you want to change the base?
Conversation
proof-producer/bin/proof-producer/include/nil/proof-generator/type_system.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Outdated
Show resolved
Hide resolved
proof-producer/libs/preset/include/nil/proof-generator/preset/types.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/resources.hpp
Show resolved
Hide resolved
class resources_provider: public resource_provider<Resources>... {}; | ||
|
||
template <typename T, typename... Resources> | ||
concept ProvidesAll = (std::is_base_of_v<resource_provider<Resources>, T> && ...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still might be used, will remove if there will be no need for it
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/preset_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/resources.hpp
Show resolved
Hide resolved
cc366de
to
7f4d86c
Compare
Clang Test Results 174 files ± 0 174 suites ±0 16m 15s ⏱️ +15s Results for commit 7cdb98d. ± Comparison against base commit 331cae7. This pull request removes 6 and adds 103 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
52888e8
to
34eea3c
Compare
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/commands/preprocess_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/commands/gen_proof_command.hpp
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/commands/gen_proof_command.hpp
Outdated
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/resources.hpp
Show resolved
Hide resolved
General question. We have 2 similar terms: proof producer (as top-level directory, Nix derivation name, name of binaries) and proof generator (namespace for source files inside |
cf44b50
to
fe3d57b
Compare
...bin/proof-producer/include/nil/proof-generator/commands/detail/commitment_scheme_factory.hpp
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/commands/detail/proof_gen.hpp
Show resolved
Hide resolved
proof-producer/bin/proof-producer/include/nil/proof-generator/commands/gen_proof_command.hpp
Show resolved
Hide resolved
d029fd5
to
e0408e9
Compare
auto const res = steps_.front()->execute(); | ||
if (!res.succeeded()) | ||
{ | ||
BOOST_LOG_TRIVIAL(error) << "command failed on stage " << stage << " of " << total_stages << ": " << res.error_message(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice to have print here name of the stage together with number
@martun , do you remember why was used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally look good.
Let's wait for @martun review
proof-producer/tests/bin/proof-producer/test_zkevm_bbf_circuits.cpp
Outdated
Show resolved
Hide resolved
2be08a1
to
c3ed5de
Compare
proof-producer/bin/proof-producer/include/nil/proof-generator/command_step.hpp
Show resolved
Hide resolved
// returns reference to the pushed step (non-owning, ownership is guaranteed by the step queue) | ||
template <typename Step, typename... Args> | ||
requires (std::derived_from<Step, command_step> && std::constructible_from<Step, Args...>) | ||
Step& add_step(Args&&... args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a complex way of adding the next step, why not accept a command_step here, and construct it outside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is complicated only here (not in usage) and the pattern is much similar to make_shared
. IMO such approach reduces possible resource leaks caused by unneeded copies of command_step instances outside the queue
}; | ||
|
||
inline constexpr const char* result_code_to_string(ResultCode rc) { | ||
switch (rc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the project is throwing exceptions. You will still need to have a "catch block" at the start of each command to report those exceptions if there will be any. Maybe here too you could just throw standard std::exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last time I saw entire proof-producer is not throwing exceptions, maybe your take is more relevant to the crypto3 internals
I, actually, do not mind switching to an exception-based mechanism of error handling, but it is a topic for a separate discussion
cc @akokoshn
...bin/proof-producer/include/nil/proof-generator/commands/detail/commitment_scheme_factory.hpp
Show resolved
Hide resolved
boost::filesystem::path aggregated_challenge_file; | ||
}; | ||
|
||
AggregatedChallengeCommand(const Args& args): args_(args) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use this "Args" structure somewhere else? Can't we just accept the arguments here, and delete the "Args" structure from everywhere?
If we use the Args, I would suggest to mark somehow which arguments are inputs, which are the outputs, and when printing the error messages from the "execute" function of command_step.hpp, print the name of the command and the parameters it was called with as a part of the error message. This way will use the Args in some way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate args structs will help us to split command line options in future. I thought to do it during the initial refactoring too but amount of LoC made me to reconsider :)
...f-producer/bin/proof-producer/include/nil/proof-generator/commands/agg_challenge_command.hpp
Show resolved
Hide resolved
|
||
template <typename CurveType, typename HashType> | ||
struct AggregatedFriProofGenerator: public command_step | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move the scope { to the previous line.
...cer/bin/proof-producer/include/nil/proof-generator/commands/aggregated_fri_proof_command.hpp
Outdated
Show resolved
Hide resolved
circuit_reader, | ||
table_reader, // for table | ||
table_reader, // for table description | ||
public_preprocessor, // for public data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks a bit strange that we pass the same object twice, because it contains inside it 2 object that class "Prover" will need to access. Why not extract those objects (the public data and LPC scheme) and pass them to this class? The benefit of creating class "resources::resource_provider" is to load the resource from a file only when required? Is it worth it writing so much code for that purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part I am not proud of too :(
I think it could be improved with some another factory methods or some kind of dependency injection but it will bring much more complications to an already complicated logic
add_step<Prover>( | ||
circuit_reader, | ||
table_reader, | ||
table_reader, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate?
2b21cbd
to
e4b6aa3
Compare
e4b6aa3
to
b60a6b0
Compare
@@ -139,7 +139,7 @@ namespace nil { | |||
// clang-format on | |||
po::options_description cmdline_options("nil; Proof Producer"); | |||
cmdline_options.add(generic).add(config); | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: file still has trailing whitespaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually wanted to include 'clang-format' run to this PR but it would turn the whole diff to a mess
I suggest to create a precommit hook with implicit call of it in further development :)
Implemented resource subscription mechanism based on boost::signals + command_chain for achieving smart resource management. Now each step of the executing command keeps its own copy of shared pointer to the data it uses
Rewrote all prover command to the new syntax. Now each command is located into its own file and represented as queue of executing steps (each step releases references to the resources after popping from the queue)
New approach allows:
Related changes in crypto3:
Also added ResultCode types for identifying the exact reason of failure externally