Skip to content

Commit

Permalink
Merge pull request libbitcoin#382 from evoskuil/master
Browse files Browse the repository at this point in the history
Use chain::max_block_weight for deserialization fail dump limit.
  • Loading branch information
evoskuil authored Mar 6, 2024
2 parents 36a4706 + b0c2f2d commit 776116d
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ jobs:
$BC_TEST_SINGLETON = $BC_TEST_EXES.FullName;
Write-Host "Executing $BC_TEST_SINGLETON $env:BOOST_UNIT_TEST_OPTIONS" -ForegroundColor Yellow;
try {
Invoke-Expression "$BC_TEST_SINGLETON --log_level=warning --run_test=${{ matrix.tests }} $env:BOOST_UNIT_TEST_OPTIONS"
Invoke-Expression "$BC_TEST_SINGLETON --run_test=${{ matrix.tests }} $env:BOOST_UNIT_TEST_OPTIONS"
}
catch {
$ERR = $_;
Expand Down
17 changes: 8 additions & 9 deletions builds/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,55 +45,55 @@ set( CMAKE_CXX_STANDARD_REQUIRED ON )
# Warn on all stuff.
check_cxx_compiler_flag( "-Wall" HAS_FLAG_WALL )
if ( HAS_FLAG_WALL )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wall> )
add_compile_options( "-Wall" )
else()
message( FATAL_ERROR "Compiler does not support -Wall" )
endif()

# Warn on extra stuff.
check_cxx_compiler_flag( "-Wextra" HAS_FLAG_WEXTRA )
if ( HAS_FLAG_WEXTRA )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wextra> )
add_compile_options( "-Wextra" )
else()
message( FATAL_ERROR "Compiler does not support -Wextra" )
endif()

# Disallow warning on style order of declarations.
check_cxx_compiler_flag( "-Wno-reorder" HAS_FLAG_WNO-REORDER )
if ( HAS_FLAG_WNO-REORDER )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder> )
add_compile_options( "-Wno-reorder" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-reorder" )
endif()

# Suppress warning for incomplete field initialization.
check_cxx_compiler_flag( "-Wno-missing-field-initializers" HAS_FLAG_WNO-MISSING-FIELD-INITIALIZERS )
if ( HAS_FLAG_WNO-MISSING-FIELD-INITIALIZERS )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-field-initializers> )
add_compile_options( "-Wno-missing-field-initializers" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-missing-field-initializers" )
endif()

# Conform to style.
check_cxx_compiler_flag( "-Wno-missing-braces" HAS_FLAG_WNO-MISSING-BRACES )
if ( HAS_FLAG_WNO-MISSING-BRACES )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-braces> )
add_compile_options( "-Wno-missing-braces" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-missing-braces" )
endif()

# Ignore comments within comments or commenting of backslash extended lines.
check_cxx_compiler_flag( "-Wno-comment" HAS_FLAG_WNO-COMMENT )
if ( HAS_FLAG_WNO-COMMENT )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-comment> )
add_compile_options( "-Wno-comment" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-comment" )
endif()

# Suppress warning for copy of implicitly generated copy constructor.
check_cxx_compiler_flag( "-Wno-deprecated-copy" HAS_FLAG_WNO-DEPRECATED-COPY )
if ( HAS_FLAG_WNO-DEPRECATED-COPY )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy> )
add_compile_options( "-Wno-deprecated-copy" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-deprecated-copy" )
endif()
Expand All @@ -102,7 +102,7 @@ endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
check_cxx_compiler_flag( "-Wno-mismatched-tags" HAS_FLAG_WNO-MISMATCHED-TAGS )
if ( HAS_FLAG_WNO-MISMATCHED-TAGS )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:-Wno-mismatched-tags> )
add_compile_options( "-Wno-mismatched-tags" )
else()
message( FATAL_ERROR "Compiler does not support -Wno-mismatched-tags" )
endif()
Expand Down Expand Up @@ -419,7 +419,6 @@ if (with-tests)

add_test( NAME libbitcoin-network-test COMMAND libbitcoin-network-test
--run_test=*
--log_level=warning
--show_progress=no
--detect_memory_leak=0
--report_level=no
Expand Down
4 changes: 2 additions & 2 deletions builds/cmake/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"description": "Factored size optimization settings.",
"hidden": true,
"cacheVariables": {
"CMAKE_C_FLAGS": "$env{CMAKE_C_FLAGS} -Os",
"CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -Os"
"CMAKE_C_FLAGS": "$env{CMAKE_C_FLAGS} -Os -s",
"CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -Os -s"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PreprocessorDefinitions Condition="'$(DefaultLinkage)' == 'dynamic'">BOOST_TEST_DYN_LINK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<PostBuildEvent Condition="'$(DebugOrRelease)' == 'release'">
<Command>"$(TargetPath)" --log_level=warning --run_test=* --show_progress=no --build_info=yes</Command>
<Command>"$(TargetPath)" --run_test=* --show_progress=no --build_info=yes</Command>
</PostBuildEvent>
</ItemDefinitionGroup>

Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/network/protocols/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BCT_API protocol
DELETE_COPY_MOVE(protocol);

/// The channel is stopping (called on strand by stop subscription).
/// The stopped flag is set before this is invoked by subscriber stop.
/// This must be called only from the channel strand (not thread safe).
virtual void stopping(const code& ec) NOEXCEPT;

Expand Down
34 changes: 0 additions & 34 deletions install-cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,7 @@ build_from_tarball_boost()
display_message "BOOST_OPTIONS : $*"
display_message "--------------------------------------------------------------------"

guessed_toolset=`./tools/build/src/engine/build.sh --guess-toolset`
CXXFLAGS="-w" ./tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w"
cp tools/build/src/engine/b2 .

./bootstrap.sh \
"--with-bjam=./b2" \
"--prefix=$PREFIX" \
"--with-icu=$ICU_PREFIX"

Expand All @@ -877,7 +872,6 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
"warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
Expand All @@ -901,27 +895,13 @@ build_from_tarball_boost()
build_all()
{
unpack_from_tarball "$ICU_ARCHIVE" "$ICU_URL" gzip "$BUILD_ICU"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${ICU_FLAGS[@]}"
build_from_tarball "$ICU_ARCHIVE" source "$PARALLEL" "$BUILD_ICU" "${ICU_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS
export CPPFLAGS=$SAVE_CPPFLAGS
unpack_from_tarball "$BOOST_ARCHIVE" "$BOOST_URL" bzip2 "$BUILD_BOOST"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BOOST_FLAGS[@]}"
build_from_tarball_boost "$BOOST_ARCHIVE" "$PARALLEL" "$BUILD_BOOST" "${BOOST_OPTIONS[@]}"
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin secp256k1 version8 "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${SECP256K1_FLAGS[@]}"
build_from_github secp256k1 "$PARALLEL" false "yes" "${SECP256K1_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin libbitcoin-system master "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_SYSTEM_FLAGS[@]}"
build_from_github_cmake libbitcoin-system "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@"
export CPPFLAGS=$SAVE_CPPFLAGS
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_NETWORK_FLAGS[@]}"
if [[ ! ($CI == true) ]]; then
create_from_github libbitcoin libbitcoin-network master "yes"
build_from_github_cmake libbitcoin-network "$PARALLEL" true "yes" "${BITCOIN_NETWORK_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@"
Expand All @@ -932,7 +912,6 @@ build_all()
pop_directory
pop_directory
fi
export CPPFLAGS=$SAVE_CPPFLAGS
}


Expand All @@ -954,19 +933,6 @@ set_with_boost_prefix

remove_install_options

# Define build flags.
#==============================================================================
# Define icu flags.
#------------------------------------------------------------------------------
ICU_FLAGS=(
"-w")

# Define secp256k1 flags.
#------------------------------------------------------------------------------
SECP256K1_FLAGS=(
"-w")


# Define build options.
#==============================================================================
# Define icu options.
Expand Down
34 changes: 0 additions & 34 deletions install-cmakepresets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -914,12 +914,7 @@ build_from_tarball_boost()
display_message "BOOST_OPTIONS : $*"
display_message "--------------------------------------------------------------------"

guessed_toolset=`./tools/build/src/engine/build.sh --guess-toolset`
CXXFLAGS="-w" ./tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w"
cp tools/build/src/engine/b2 .

./bootstrap.sh \
"--with-bjam=./b2" \
"--prefix=$PREFIX" \
"--with-icu=$ICU_PREFIX"

Expand All @@ -937,7 +932,6 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
"warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
Expand All @@ -961,28 +955,14 @@ build_from_tarball_boost()
build_all()
{
unpack_from_tarball "$ICU_ARCHIVE" "$ICU_URL" gzip "$BUILD_ICU"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${ICU_FLAGS[@]}"
build_from_tarball "$ICU_ARCHIVE" source "$PARALLEL" "$BUILD_ICU" "${ICU_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS
export CPPFLAGS=$SAVE_CPPFLAGS
unpack_from_tarball "$BOOST_ARCHIVE" "$BOOST_URL" bzip2 "$BUILD_BOOST"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BOOST_FLAGS[@]}"
build_from_tarball_boost "$BOOST_ARCHIVE" "$PARALLEL" "$BUILD_BOOST" "${BOOST_OPTIONS[@]}"
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin secp256k1 version8 "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${SECP256K1_FLAGS[@]}"
build_from_github secp256k1 "$PARALLEL" false "yes" "${SECP256K1_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin libbitcoin-system master "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_SYSTEM_FLAGS[@]}"
display_message "libbitcoin-system PRESET ${REPO_PRESET[libbitcoin-system]}"
build_from_github_cmake libbitcoin-system ${REPO_PRESET[libbitcoin-system]} "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@"
export CPPFLAGS=$SAVE_CPPFLAGS
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_NETWORK_FLAGS[@]}"
if [[ ! ($CI == true) ]]; then
create_from_github libbitcoin libbitcoin-network master "yes"
display_message "libbitcoin-network PRESET ${REPO_PRESET[libbitcoin-network]}"
Expand All @@ -995,7 +975,6 @@ build_all()
pop_directory
pop_directory
fi
export CPPFLAGS=$SAVE_CPPFLAGS
}


Expand All @@ -1017,19 +996,6 @@ set_with_boost_prefix

remove_install_options

# Define build flags.
#==============================================================================
# Define icu flags.
#------------------------------------------------------------------------------
ICU_FLAGS=(
"-w")

# Define secp256k1 flags.
#------------------------------------------------------------------------------
SECP256K1_FLAGS=(
"-w")


# Define build options.
#==============================================================================
# Define icu options.
Expand Down
34 changes: 0 additions & 34 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,7 @@ build_from_tarball_boost()
display_message "BOOST_OPTIONS : $*"
display_message "--------------------------------------------------------------------"

guessed_toolset=`./tools/build/src/engine/build.sh --guess-toolset`
CXXFLAGS="-w" ./tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w"
cp tools/build/src/engine/b2 .

./bootstrap.sh \
"--with-bjam=./b2" \
"--prefix=$PREFIX" \
"--with-icu=$ICU_PREFIX"

Expand All @@ -752,7 +747,6 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
"warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
Expand All @@ -776,27 +770,13 @@ build_from_tarball_boost()
build_all()
{
unpack_from_tarball "$ICU_ARCHIVE" "$ICU_URL" gzip "$BUILD_ICU"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${ICU_FLAGS[@]}"
build_from_tarball "$ICU_ARCHIVE" source "$PARALLEL" "$BUILD_ICU" "${ICU_OPTIONS[@]}" "$@"
export CPPFLAGS=$SAVE_CPPFLAGS
unpack_from_tarball "$BOOST_ARCHIVE" "$BOOST_URL" bzip2 "$BUILD_BOOST"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BOOST_FLAGS[@]}"
build_from_tarball_boost "$BOOST_ARCHIVE" "$PARALLEL" "$BUILD_BOOST" "${BOOST_OPTIONS[@]}"
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin secp256k1 version8 "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${SECP256K1_FLAGS[@]}"
build_from_github secp256k1 "$PARALLEL" false "yes" "${SECP256K1_OPTIONS[@]}" "$@"
export CPPFLAGS=$SAVE_CPPFLAGS
create_from_github libbitcoin libbitcoin-system master "yes"
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_SYSTEM_FLAGS[@]}"
build_from_github libbitcoin-system "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" "$@"
export CPPFLAGS=$SAVE_CPPFLAGS
local SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS ${BITCOIN_NETWORK_FLAGS[@]}"
if [[ ! ($CI == true) ]]; then
create_from_github libbitcoin libbitcoin-network master "yes"
build_from_github libbitcoin-network "$PARALLEL" true "yes" "${BITCOIN_NETWORK_OPTIONS[@]}" "$@"
Expand All @@ -807,7 +787,6 @@ build_all()
pop_directory
pop_directory
fi
export CPPFLAGS=$SAVE_CPPFLAGS
}


Expand All @@ -828,19 +807,6 @@ set_pkgconfigdir
set_with_boost_prefix


# Define build flags.
#==============================================================================
# Define icu flags.
#------------------------------------------------------------------------------
ICU_FLAGS=(
"-w")

# Define secp256k1 flags.
#------------------------------------------------------------------------------
SECP256K1_FLAGS=(
"-w")


# Define build options.
#==============================================================================
# Define icu options.
Expand Down
1 change: 0 additions & 1 deletion libbitcoin-network-test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#==============================================================================
BOOST_UNIT_TEST_OPTIONS=\
"--run_test=* "\
"--log_level=warning "\
"--show_progress=no "\
"--detect_memory_leak=0 "\
"--report_level=no "\
Expand Down
3 changes: 2 additions & 1 deletion src/net/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using namespace messages;
using namespace std::placeholders;

// Dump up to this size of payload as hex in order to diagnose failure.
static constexpr size_t invalid_payload_dump_size = chain::max_block_size;
static constexpr size_t invalid_payload_dump_size = chain::max_block_weight;
static constexpr uint32_t http_magic = 0x20544547;
static constexpr uint32_t https_magic = 0x02010316;

Expand Down Expand Up @@ -292,6 +292,7 @@ void proxy::handle_read_payload(const code& ec, size_t LOG_ONLY(payload_size),

if (code)
{
// TODO: specialize for header/block/tx messages and provide hash.
LOGR("Invalid " << head->command << " payload from [" << authority()
<< "] (" << encode_base16({ payload_buffer_.begin(),
std::next(payload_buffer_.begin(), std::min(payload_size,
Expand Down

0 comments on commit 776116d

Please sign in to comment.