Skip to content

Commit 8327d3a

Browse files
BSIP 40: Cleanup, disable sign-compare warnings on g++
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.
1 parent b600cbc commit 8327d3a

File tree

6 files changed

+35
-38
lines changed

6 files changed

+35
-38
lines changed

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ script:
2929
- ccache -s
3030
- programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
3131
- 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 ."
32-
- 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"
32+
- programs/build_helpers/buildstep make.fc 200 "make -j 2 fc"
33+
- programs/build_helpers/buildstep make.custom_auths 1000 "make -j 1 graphene_protocol_custom_auths"
34+
- programs/build_helpers/buildstep make.protocol 700 "make -j 2 graphene_protocol"
35+
- 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"
3336
- programs/build_helpers/buildstep make.chain_test 1000 "make -j 2 chain_test"
3437
- programs/build_helpers/buildstep make.cli_test 200 "make -j 2 cli_test"
3538
- programs/build_helpers/buildstep make.perf_test 120 "make -j 2 performance_test"

libraries/chain/custom_authority_evaluator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void_result custom_authority_create_evaluator::do_evaluate(const custom_authorit
4545
FC_ASSERT((op.valid_to - now).to_seconds() <= config->max_custom_authority_lifetime_seconds,
4646
"Custom authority lifetime exceeds maximum limit");
4747

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

5151
for (const auto& account_weight_pair : op.auth.account_auths)

libraries/protocol/CMakeLists.txt

+19-9
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ list(APPEND SOURCES account.cpp
1717
authority.cpp
1818
special_authority.cpp
1919
custom_authority.cpp
20-
custom_authorities/restriction_predicate.cpp
21-
custom_authorities/list_1.cpp
22-
custom_authorities/list_2.cpp
23-
custom_authorities/list_3.cpp
24-
custom_authorities/list_4.cpp
25-
custom_authorities/list_5.cpp
26-
custom_authorities/list_6.cpp
27-
custom_authorities/list_7.cpp
2820
committee_member.cpp
2921
custom.cpp
3022
market.cpp
@@ -38,8 +30,26 @@ list(APPEND SOURCES account.cpp
3830
htlc.cpp)
3931

4032

33+
list(APPEND CUSTOM_AUTHS_FILES
34+
custom_authorities/restriction_predicate.cpp
35+
custom_authorities/list_1.cpp
36+
custom_authorities/list_2.cpp
37+
custom_authorities/list_3.cpp
38+
custom_authorities/list_4.cpp
39+
custom_authorities/list_5.cpp
40+
custom_authorities/list_6.cpp
41+
custom_authorities/list_7.cpp)
42+
43+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
44+
set_source_files_properties(${CUSTOM_AUTHS_FILES} PROPERTIES COMPILE_FLAGS -Wno-sign-compare)
45+
endif()
46+
47+
add_library( graphene_protocol_custom_auths ${CUSTOM_AUTHS_FILES} )
48+
target_link_libraries( graphene_protocol_custom_auths fc )
49+
target_include_directories( graphene_protocol_custom_auths PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
50+
4151
add_library( graphene_protocol ${SOURCES} ${HEADERS} )
42-
target_link_libraries( graphene_protocol fc )
52+
target_link_libraries( graphene_protocol fc graphene_protocol_custom_auths )
4353
target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
4454

4555
install( TARGETS

libraries/protocol/custom_authorities/list_1.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "restriction_predicate.hxx"
2626

2727
namespace graphene { namespace protocol {
28-
2928
using result_type = object_restriction_predicate<operation>;
3029

3130
result_type get_restriction_predicate_list_1(size_t idx, vector<restriction> rs) {

libraries/protocol/custom_authorities/restriction_predicate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ restriction_predicate_function get_restriction_predicate(vector<restriction> rs,
5050
static_assert(typelist::contains<typelist::concat<operation_list_1::list, operation_list_2::list,
5151
operation_list_3::list, operation_list_4::list,
5252
operation_list_5::list, operation_list_6::list,
53-
operation_list_7::list>, Op>(), "");
53+
operation_list_7::list>, Op>, "");
5454
FC_THROW_EXCEPTION(fc::assert_exception,
5555
"LOGIC ERROR: Operation type not handled by custom authorities implementation. "
5656
"Please report this error.");

libraries/protocol/custom_authorities/restriction_predicate.hxx

+10-25
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ using object_restriction_predicate = std::function<bool(const Field&)>;
102102
// predicate which returns true if any branch of the OR passes
103103
// - create_predicate_function<Field>() -- switches on restriction type to determine which predicate template to use
104104
// going forward
105-
// - restriction_argument_visitor<Field> -- Determines what type the restriction argument is and creates a
106-
// predicate functor for that type
105+
// - make_predicate<Predicate, Field, ArgVariant> -- Determines what type the restriction argument is and creates
106+
// a predicate functor for that type
107107
// - attribute_assertion<Field> -- If the restriction is an attribute assertion, instead of using the
108108
// restriction_argument_visitor, we recurse into restrictions_to_predicate with the current Field as the Object
109+
// - embed_argument<Field, Predicate, Argument>() -- Embeds the argument into the predicate if it is a valid type
110+
// for the predicate, and throws otherwise.
109111
// - predicate_xyz<Argument> -- These are functors implementing the various predicate function types
110112
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
111113

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

309-
// Template to visit the restriction argument, resolving its type, and create the appropriate predicate functor, or
310-
// throw if the types are not compatible for the predicate assertion
311-
template<template<typename> class Predicate, typename Field>
312-
struct restriction_argument_visitor {
313-
using result_type = object_restriction_predicate<Field>;
314-
315-
template<typename Argument,
316-
typename = std::enable_if_t<Predicate<Argument>::template can_evaluate_helper<Field>::value>>
317-
result_type make_predicate(const Argument& a, short) {
318-
return Predicate<Argument>(a);
319-
}
320-
template<typename Argument>
321-
result_type make_predicate(const Argument&, long) {
322-
FC_THROW_EXCEPTION(fc::assert_exception, "Invalid argument types for predicate: ${Field}, ${Argument}",
323-
("Field", fc::get_typename<Field>::name())("Argument", fc::get_typename<Argument>::name()));
324-
}
325-
template<typename Argument>
326-
result_type operator()(const Argument& a) { return make_predicate(a, short()); }
327-
};
328-
329311
// Forward declaration of restrictions_to_predicate, because attribute assertions and logical ORs recurse into it
330312
template<typename Field> object_restriction_predicate<Field> restrictions_to_predicate(vector<restriction>, bool);
331313

@@ -353,21 +335,23 @@ struct attribute_assertion<extension<Extension>> {
353335
}
354336
};
355337

338+
// Embed the argument into the predicate functor
356339
template<typename F, typename P, typename A, typename = std::enable_if_t<P::valid>>
357-
object_restriction_predicate<F> mkpred(P p, A a, short) {
340+
object_restriction_predicate<F> embed_argument(P p, A a, short) {
358341
return std::bind(p, std::placeholders::_1, std::move(a));
359342
}
360343
template<typename F, typename P, typename A>
361-
object_restriction_predicate<F> mkpred(P, A, long) {
344+
object_restriction_predicate<F> embed_argument(P, A, long) {
362345
FC_THROW_EXCEPTION(fc::assert_exception, "Invalid types for predicated");
363346
}
364347

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

@@ -477,6 +461,7 @@ object_restriction_predicate<Object> restrictions_to_predicate(vector<restrictio
477461
}
478462

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

0 commit comments

Comments
 (0)