Skip to content

Commit

Permalink
Merge pull request #82 from NilFoundation/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings about void return in non-void funcs
  • Loading branch information
martun authored Feb 1, 2024
2 parents c5b25f0 + fc96ec5 commit 1d6c8d2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
20 changes: 11 additions & 9 deletions include/nil/crypto3/marshalling/math/types/flat_expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace nil {
std::uint32_t right_index;
};

// Storing the crypto3::math::expression class in a flat way,
// Storing the crypto3::math::expression class in a flat way,
// to be able to use it in marshalling. We put different types of nodes
// into different vectors, and use indexes instead of pointers.
template<typename ExpressionType>
Expand Down Expand Up @@ -99,10 +99,12 @@ namespace nil {
case flat_node_type::BINARY_ARITHMETIC: {
const auto& bin_op = binary_operations[node_index];
return binary_arithmetic_operation_type(
to_expression(bin_op.left_type, bin_op.left_index),
to_expression(bin_op.right_type, bin_op.right_index),
to_expression(bin_op.left_type, bin_op.left_index),
to_expression(bin_op.right_type, bin_op.right_index),
bin_op.op);
}
default:
throw std::invalid_argument("Invalid flat_node_type passed");
}
}

Expand All @@ -112,14 +114,14 @@ namespace nil {

// Type of the base expression.
flat_node_type root_type;

// Index in corresponding array.
// if type == TERM, then this is index in array 'terms'.
std::uint32_t root_index;

};
// Class for creating a flat_expression from expression.

// Class for creating a flat_expression from expression.
template<typename ExpressionType>
class expression_flattener : public boost::static_visitor<void> {
public:
Expand All @@ -135,7 +137,7 @@ namespace nil {
const flat_expression<ExpressionType>& get_result() const {
return result;
}

void operator()(const term_type& term) {
result.terms.push_back(term);

Expand All @@ -157,11 +159,11 @@ namespace nil {

boost::apply_visitor(*this, op.get_expr_left().get_expr());
flat_op.left_type = result.root_type;
flat_op.left_index = result.root_index;
flat_op.left_index = result.root_index;

boost::apply_visitor(*this, op.get_expr_right().get_expr());
flat_op.right_type = result.root_type;
flat_op.right_index = result.root_index;
flat_op.right_index = result.root_index;

result.binary_operations.push_back(flat_op);

Expand Down
41 changes: 21 additions & 20 deletions include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#ifndef CRYPTO3_MARSHALLING_FRI_COMMITMENT_HPP
#define CRYPTO3_MARSHALLING_FRI_COMMITMENT_HPP

#include <ratio>
#include <limits>
#include <map>
#include <ratio>
#include <type_traits>

#include <boost/assert.hpp>
Expand Down Expand Up @@ -101,7 +102,7 @@ namespace nil {
using filled_type = merkle_proof_vector_type<TTypeBase, FRI>;

filled_type filled;


for( size_t i = 0; i < merkle_proofs.size(); i++){
filled.value().push_back(
Expand All @@ -112,7 +113,7 @@ namespace nil {
}

template<typename Endianness, typename FRI>
std::vector<typename FRI::merkle_proof_type>
std::vector<typename FRI::merkle_proof_type>
make_merkle_proof_vector(merkle_proof_vector_type<nil::marshalling::field_type<Endianness>, FRI> &filled) {
std::vector<typename FRI::merkle_proof_type> merkle_proofs;
for( std::size_t i = 0; i < filled.value().size(); i++ ){
Expand All @@ -127,7 +128,7 @@ namespace nil {
// fri::proof_type marshalling
///////////////////////////////////////////////////
template <typename TTypeBase, typename FRI, bool b = FRI::use_grinding> struct fri_proof;
template <typename TTypeBase, typename FRI> struct fri_proof<TTypeBase, FRI, true> {
template <typename TTypeBase, typename FRI> struct fri_proof<TTypeBase, FRI, true> {
using type = nil::marshalling::types::bundle<
TTypeBase,
std::tuple<
Expand All @@ -138,7 +139,7 @@ namespace nil {
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// step_list.
// step_list.
// We'll check is it good for current EVM instance
nil::marshalling::types::array_list<
TTypeBase,
Expand Down Expand Up @@ -168,29 +169,29 @@ namespace nil {
// Fixed size lambda * batches_num
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// Merkle proofs for round proofs
// Fixed size lambda * |step_list|
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// std::select_container<math::polynomial> final_polynomials
// std::select_container<math::polynomial> final_polynomials
// May be different size, because real degree may be less than before. So put int in the end
fri_math_polynomial<TTypeBase, typename FRI::polynomial_type>,


// proof of work. TODO: how to do it optional?
nil::marshalling::types::integral<TTypeBase, typename FRI::grinding_type::output_type> //proof of work*/
>
>;
>;
};
template <typename TTypeBase, typename FRI> struct fri_proof<TTypeBase, FRI, false> {
template <typename TTypeBase, typename FRI> struct fri_proof<TTypeBase, FRI, false> {
using type = nil::marshalling::types::bundle<
TTypeBase,
std::tuple<
Expand All @@ -201,7 +202,7 @@ namespace nil {
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// step_list.
// step_list.
// We'll check is it good for current EVM instance
nil::marshalling::types::array_list<
TTypeBase,
Expand Down Expand Up @@ -231,19 +232,19 @@ namespace nil {
// Fixed size lambda * batches_num
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// Merkle proofs for round proofs
// Fixed size lambda * |step_list|
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
>,

// std::select_container<math::polynomial> final_polynomials
// std::select_container<math::polynomial> final_polynomials
// May be different size, because real degree may be less than before. So put int in the end
fri_math_polynomial<TTypeBase, typename FRI::polynomial_type>
>
Expand Down Expand Up @@ -320,7 +321,7 @@ namespace nil {
// initial merkle proofs
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
> filled_initial_merkle_proofs;
for( std::size_t i = 0; i < FRI::lambda; i++){
Expand All @@ -332,11 +333,11 @@ namespace nil {
);
}
}

// round merkle proofs
nil::marshalling::types::array_list<
TTypeBase,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
typename types::merkle_proof<TTypeBase, typename FRI::merkle_proof_type>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
> filled_round_merkle_proofs;
for( std::size_t i = 0; i < FRI::lambda; i++){
Expand All @@ -356,18 +357,18 @@ namespace nil {
if constexpr(FRI::use_grinding){
return typename fri_proof<nil::marshalling::field_type<Endianness>, FRI>::type(
std::tuple(
filled_fri_roots, filled_step_list, filled_initial_val, filled_round_val,
filled_fri_roots, filled_step_list, filled_initial_val, filled_round_val,
filled_initial_merkle_proofs, filled_round_merkle_proofs, filled_final_polynomial,
nil::marshalling::types::integral<TTypeBase, typename FRI::grinding_type::output_type>(proof.proof_of_work)
)
);
} else {
return typename fri_proof<nil::marshalling::field_type<Endianness>, FRI>::type(
std::tuple(
filled_fri_roots, filled_step_list, filled_initial_val, filled_round_val,
filled_fri_roots, filled_step_list, filled_initial_val, filled_round_val,
filled_initial_merkle_proofs, filled_round_merkle_proofs, filled_final_polynomial
)
);
);
}
}

Expand Down

0 comments on commit 1d6c8d2

Please sign in to comment.