Skip to content

Commit

Permalink
remove utils.sol if no helper functions generated #45 NilFoundation/e…
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed Nov 5, 2023
1 parent 7cfbf39 commit 5738468
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions include/nil/blueprint/transpiler/evm_verifier_gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ namespace nil {
boost::replace_all(result, "$GATE_LIB_ID$", to_string(gate_modules_count));
boost::replace_all(result, "$CONSTRAINT_SERIES_CODE$", code);
boost::replace_all(result, "$MODULUS$", to_string(PlaceholderParams::field_type::modulus));
boost::replace_all(result, "$UTILS_LIBRARY_IMPORT$", _term_powers.size() >0? "import \"./utils.sol\";" : "");


std::ofstream out;
out.open(_folder_name + "/gate_" + to_string(gate_modules_count) + ".sol");
Expand All @@ -614,19 +616,21 @@ namespace nil {
}
}

std::stringstream power_functions;
for(std::size_t power: _term_powers) {
power_functions << generate_power_function(power);
}
if (_term_powers.size() > 0) {
std::stringstream power_functions;
for(std::size_t power: _term_powers) {
power_functions << generate_power_function(power);
}

std::string utils_library(utils_library_template);
boost::replace_all(utils_library, "$MODULUS$", to_string(PlaceholderParams::field_type::modulus));
boost::replace_all(utils_library, "$POWER_FUNCTIONS$", power_functions.str());
boost::replace_all(utils_library, "$TEST_NAME$", _test_name);
std::ofstream utils;
utils.open(_folder_name + "/utils.sol");
utils << utils_library;
utils.close();
std::string utils_library(utils_library_template);
boost::replace_all(utils_library, "$MODULUS$", to_string(PlaceholderParams::field_type::modulus));
boost::replace_all(utils_library, "$POWER_FUNCTIONS$", power_functions.str());
boost::replace_all(utils_library, "$TEST_NAME$", _test_name);
std::ofstream utils;
utils.open(_folder_name + "/utils.sol");
utils << utils_library;
utils.close();
}

for ( i = 0; i < gate_modules_count; ++i ) {
std::string gate_eval_string = gate_call_template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace nil {
pragma solidity >=0.8.4;
import "../../../contracts/basic_marshalling.sol";
import "./utils.sol";
$UTILS_LIBRARY_IMPORT$
library gate_$TEST_NAME$_$GATE_LIB_ID${
uint256 constant modulus = $MODULUS$;
Expand Down

0 comments on commit 5738468

Please sign in to comment.