Skip to content

Commit

Permalink
BSIP 40: Cleanup, disable sign-compare warnings on g++
Browse files Browse the repository at this point in the history
Set travis to build single-threaded and disable signed-unsigned
comparison warnings on g++. If anyone has a real solution to
signed comparisons, I'd love to hear it, but until then, the
warnings are actually so awful that travis breaks over them.
  • Loading branch information
nathanielhourt committed Aug 5, 2019
1 parent b600cbc commit 8327d3a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ script:
- ccache -s
- programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
- programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
- programs/build_helpers/buildstep make.cli_wallet 2200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet witness_node js_operation_serializer get_dev_key network_mapper"
- programs/build_helpers/buildstep make.fc 200 "make -j 2 fc"
- programs/build_helpers/buildstep make.custom_auths 1000 "make -j 1 graphene_protocol_custom_auths"
- programs/build_helpers/buildstep make.protocol 700 "make -j 2 graphene_protocol"
- programs/build_helpers/buildstep make.cli_wallet 800 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet witness_node js_operation_serializer get_dev_key network_mapper"
- programs/build_helpers/buildstep make.chain_test 1000 "make -j 2 chain_test"
- programs/build_helpers/buildstep make.cli_test 200 "make -j 2 cli_test"
- programs/build_helpers/buildstep make.perf_test 120 "make -j 2 performance_test"
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/custom_authority_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void_result custom_authority_create_evaluator::do_evaluate(const custom_authorit
FC_ASSERT((op.valid_to - now).to_seconds() <= config->max_custom_authority_lifetime_seconds,
"Custom authority lifetime exceeds maximum limit");

FC_ASSERT(op.operation_type.value <= config->max_operation_tag,
FC_ASSERT(op.operation_type.value <= (size_t)config->max_operation_tag,
"Cannot create custom authority for operation type which is not yet active");

for (const auto& account_weight_pair : op.auth.account_auths)
Expand Down
28 changes: 19 additions & 9 deletions libraries/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ list(APPEND SOURCES account.cpp
authority.cpp
special_authority.cpp
custom_authority.cpp
custom_authorities/restriction_predicate.cpp
custom_authorities/list_1.cpp
custom_authorities/list_2.cpp
custom_authorities/list_3.cpp
custom_authorities/list_4.cpp
custom_authorities/list_5.cpp
custom_authorities/list_6.cpp
custom_authorities/list_7.cpp
committee_member.cpp
custom.cpp
market.cpp
Expand All @@ -38,8 +30,26 @@ list(APPEND SOURCES account.cpp
htlc.cpp)


list(APPEND CUSTOM_AUTHS_FILES
custom_authorities/restriction_predicate.cpp
custom_authorities/list_1.cpp
custom_authorities/list_2.cpp
custom_authorities/list_3.cpp
custom_authorities/list_4.cpp
custom_authorities/list_5.cpp
custom_authorities/list_6.cpp
custom_authorities/list_7.cpp)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set_source_files_properties(${CUSTOM_AUTHS_FILES} PROPERTIES COMPILE_FLAGS -Wno-sign-compare)
endif()

add_library( graphene_protocol_custom_auths ${CUSTOM_AUTHS_FILES} )
target_link_libraries( graphene_protocol_custom_auths fc )
target_include_directories( graphene_protocol_custom_auths PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

add_library( graphene_protocol ${SOURCES} ${HEADERS} )
target_link_libraries( graphene_protocol fc )
target_link_libraries( graphene_protocol fc graphene_protocol_custom_auths )
target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

install( TARGETS
Expand Down
1 change: 0 additions & 1 deletion libraries/protocol/custom_authorities/list_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "restriction_predicate.hxx"

namespace graphene { namespace protocol {

using result_type = object_restriction_predicate<operation>;

result_type get_restriction_predicate_list_1(size_t idx, vector<restriction> rs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ restriction_predicate_function get_restriction_predicate(vector<restriction> rs,
static_assert(typelist::contains<typelist::concat<operation_list_1::list, operation_list_2::list,
operation_list_3::list, operation_list_4::list,
operation_list_5::list, operation_list_6::list,
operation_list_7::list>, Op>(), "");
operation_list_7::list>, Op>, "");
FC_THROW_EXCEPTION(fc::assert_exception,
"LOGIC ERROR: Operation type not handled by custom authorities implementation. "
"Please report this error.");
Expand Down
35 changes: 10 additions & 25 deletions libraries/protocol/custom_authorities/restriction_predicate.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ using object_restriction_predicate = std::function<bool(const Field&)>;
// predicate which returns true if any branch of the OR passes
// - create_predicate_function<Field>() -- switches on restriction type to determine which predicate template to use
// going forward
// - restriction_argument_visitor<Field> -- Determines what type the restriction argument is and creates a
// predicate functor for that type
// - make_predicate<Predicate, Field, ArgVariant> -- Determines what type the restriction argument is and creates
// a predicate functor for that type
// - attribute_assertion<Field> -- If the restriction is an attribute assertion, instead of using the
// restriction_argument_visitor, we recurse into restrictions_to_predicate with the current Field as the Object
// - embed_argument<Field, Predicate, Argument>() -- Embeds the argument into the predicate if it is a valid type
// for the predicate, and throws otherwise.
// - predicate_xyz<Argument> -- These are functors implementing the various predicate function types
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -306,26 +308,6 @@ struct predicate_has_none<fc::optional<OptionalType>, Argument, void> : predicat
};
////////////////////////////////////////////// END PREDICATE FUNCTORS //////////////////////////////////////////////

// Template to visit the restriction argument, resolving its type, and create the appropriate predicate functor, or
// throw if the types are not compatible for the predicate assertion
template<template<typename> class Predicate, typename Field>
struct restriction_argument_visitor {
using result_type = object_restriction_predicate<Field>;

template<typename Argument,
typename = std::enable_if_t<Predicate<Argument>::template can_evaluate_helper<Field>::value>>
result_type make_predicate(const Argument& a, short) {
return Predicate<Argument>(a);
}
template<typename Argument>
result_type make_predicate(const Argument&, long) {
FC_THROW_EXCEPTION(fc::assert_exception, "Invalid argument types for predicate: ${Field}, ${Argument}",
("Field", fc::get_typename<Field>::name())("Argument", fc::get_typename<Argument>::name()));
}
template<typename Argument>
result_type operator()(const Argument& a) { return make_predicate(a, short()); }
};

// Forward declaration of restrictions_to_predicate, because attribute assertions and logical ORs recurse into it
template<typename Field> object_restriction_predicate<Field> restrictions_to_predicate(vector<restriction>, bool);

Expand Down Expand Up @@ -353,21 +335,23 @@ struct attribute_assertion<extension<Extension>> {
}
};

// Embed the argument into the predicate functor
template<typename F, typename P, typename A, typename = std::enable_if_t<P::valid>>
object_restriction_predicate<F> mkpred(P p, A a, short) {
object_restriction_predicate<F> embed_argument(P p, A a, short) {
return std::bind(p, std::placeholders::_1, std::move(a));
}
template<typename F, typename P, typename A>
object_restriction_predicate<F> mkpred(P, A, long) {
object_restriction_predicate<F> embed_argument(P, A, long) {
FC_THROW_EXCEPTION(fc::assert_exception, "Invalid types for predicated");
}

// Resolve the argument type and make a predicate for it
template<template<typename...> class Predicate, typename Field, typename ArgVariant>
object_restriction_predicate<Field> make_predicate(ArgVariant arg) {
return typelist::runtime::dispatch(typename ArgVariant::list(), arg.which(),
[&arg](auto t) mutable -> object_restriction_predicate<Field> {
using Arg = typename decltype(t)::type;
return mkpred<Field>(Predicate<Field, Arg>(), std::move(arg.template get<Arg>()), short());
return embed_argument<Field>(Predicate<Field, Arg>(), std::move(arg.template get<Arg>()), short());
});
}

Expand Down Expand Up @@ -477,6 +461,7 @@ object_restriction_predicate<Object> restrictions_to_predicate(vector<restrictio
}

// To make the build gentler on RAM, break the operation list into several pieces to build over several files
// Process account create, update, and global parameters update operations separately, as they are the largest
using operation_list_1 = static_variant<typelist::slice<operation::list, 0, 5>>;
using operation_list_2 = static_variant<typelist::slice<operation::list, 5, 10>>;
using operation_list_3 = static_variant<typelist::slice<operation::list, 10, 20>>;
Expand Down

0 comments on commit 8327d3a

Please sign in to comment.