Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .cicd/platforms/gcc.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ COPY <<-EOF /extras.cmake
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "gcc-14" CACHE STRING "")
set(CMAKE_CXX_COMPILER "g++-14" CACHE STRING "")
set(CMAKE_C_FLAGS "-Wall -Wextra -fdiagnostics-color=always" CACHE STRING "")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -fdiagnostics-color=always" CACHE STRING "")
# Permit unused callback parameters and partial aggregates that use member defaults.
set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-color=always" CACHE STRING "")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-color=always" CACHE STRING "")
EOF

ENV SYSIO_PLATFORM_HAS_EXTRAS_CMAKE=1
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/external_chain_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class chain {
const auto [seen, fresh] = received_.emplace(id, message.SerializeAsString());
FC_ASSERT(fresh || seen->second == message.SerializeAsString(), "conflicting return replay");
if (paid_requests_.contains(id)) return false;
const auto amount = message.amount().amount();
const auto amount = static_cast<uint64_t>(message.amount().amount());
const auto [it, inserted] = pending_.emplace(id, amount);
FC_ASSERT(inserted || it->second == amount, "conflicting return replay");
return settle(id);
Expand Down
4 changes: 3 additions & 1 deletion contracts/tests/kicker_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "sysio_liq_tester.hpp"
#include <sysio.kicker/kicker_math.hpp>
#include "kicker_test_reference.hpp"
#include <utility>
namespace kicker_test_support {
namespace math = sysio::kicker_math;
using kicker_test_reference::wide;
Expand Down Expand Up @@ -168,7 +169,8 @@ class kicker_tester : public sysio_liq_tester {
const auto row = stat_row(sym);
const auto observation = pool(sym);
const auto span = (control->pending_block_time() - observation["price_time"].as<time_point>()).count();
if (span < configuration()[kicker::field::twap_window_sec].as_uint64() * math::micros_per_sec) return 0;
const auto window_us = configuration()[kicker::field::twap_window_sec].as_uint64() * math::micros_per_sec;
if (std::cmp_less(span, window_us)) return 0;
const auto sized_supply = std::min(observation["supply_snapshot"].as_int64(),
row["supply"].as<asset>().get_amount());
const wide accrued = wide(sized_supply) * observation["rate_bps"].as_uint64() *
Expand Down
4 changes: 0 additions & 4 deletions contracts/tests/sysio.bond_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ constexpr std::string_view nothing_msg = "nothing to claim";
constexpr std::string_view wire_no_yield_msg = "WIRE collateral earns no shadow yield";
constexpr std::string_view prune_limit_msg = "limit exceeds the most requests one prune examines";

/// The memo of the one transfer that pays the issuer an INVALID request's bonds.
constexpr std::string_view forfeit_memo = "sysio.bond::forfeit";
/// The memo of the transfer that pays a claim in the request's token.
constexpr std::string_view claim_memo = "sysio.bond::claim";

/// `request_state` names as the ABI renders them.
constexpr std::string_view STATE_OPEN = "OPEN";
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/sysio.kicker_math_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(spot_deviation_threshold) {
BOOST_CHECK(!math::spot_deviates(0, 0, 1));
// Prices near 2^128 times 10,000 overflow 128 bits; the comparison stays exact against a wide oracle.
const math::u128 top = ~math::u128{0};
for (const auto [spot, twap, bps] : {std::tuple<math::u128, math::u128, uint16_t>{top, top / 2, 10'000},
for (const auto& [spot, twap, bps] : {std::tuple<math::u128, math::u128, uint16_t>{top, top / 2, 10'000},
{top / 2, top, 5'000}, {top / 2, top, 4'999}, {top, top - 1, 1}}) {
const wide gap = spot > twap ? wide(spot) - wide(twap) : wide(twap) - wide(spot);
BOOST_CHECK_EQUAL(gap * 10'000 > wide(twap) * bps, math::spot_deviates(spot, twap, bps));
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/sysio.kicker_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE(spot_deviation_threshold_is_inclusive) {
BOOST_CHECK_EQUAL(0, t.paid());
BOOST_CHECK(after.deviation);
BOOST_CHECK_EQUAL(gift, after.shortfall);
BOOST_CHECK(after.observed == t.control->head_block_time());
BOOST_CHECK(after.observed == t.control->head().block_time());
// The clock and the observation are held.
BOOST_CHECK(after.clock == observation.clock);
BOOST_CHECK(after.price_time == observation.price_time);
Expand Down
5 changes: 0 additions & 5 deletions contracts/tests/sysio.opreg_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ constexpr auto kEligibilityBatchOperator = "batchop.a"_n;
/// Producer account used by focused eligibility tests.
constexpr auto kEligibilityProducer = "producer.a"_n;

/// Ethereum chain and token codename used by focused collateral tests.
constexpr std::string_view kEthCodename = "ETH";

/// Native WIRE chain and token codename used by focused collateral tests.
constexpr std::string_view kWireCodename = "WIRE";
Expand Down Expand Up @@ -314,9 +312,6 @@ constexpr std::string_view kYieldNotCoveredError =
"assertion failure with message: owed yield is rounding dust the WIRE received from sysio.liq does not "
"cover; only later slack can cover it";

/// Recent-actions reason `depositinle` records when it drops a credit naming the depot chain.
constexpr std::string_view kDepotChainCreditReason =
"depot-chain collateral is bonded through deposit, never credited from an outpost";

/// Account with no stake in the yield cases that cranks `claimyield` for someone else.
constexpr auto kYieldKeeper = "uwrit.a"_n;
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/sysio.swap_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ BOOST_FIXTURE_TEST_CASE( yield_tick_sells_the_reservoir_over_the_horizon, sysio_
BOOST_REQUIRE_EQUAL( wasm_assert_msg("yield tick parameters not set"), tickyield( SHEO ) );
BOOST_REQUIRE_EQUAL( success(), setyield( SHEO, horizon_sec, cap_bps, clip_floor ) );
const int64_t set_at = last_tick_us( SHEO );
BOOST_REQUIRE_EQUAL( control->head_block_time().time_since_epoch().count(), set_at ); // setyield starts the clock
BOOST_REQUIRE_EQUAL( control->head().block_time().time_since_epoch().count(), set_at ); // setyield starts the clock

// An empty reservoir: the tick is a no-op and the clock is untouched.
auto before = system_balance( SHEO.value );
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/sysio/chain/vote_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class vote_processor_t {
for (auto i = idx.begin(); i != idx.end();) {
if (stopped)
return;
vote v = std::move(*i);
vote v = *i;
idx.erase(i);
auto bsp = get_block(v.msg->block_id, g);
// g is unlocked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class code_cache_async : public code_cache_base {
//If code is in cache: returns pointer & bumps to front of MRU list
//If code is not in cache, and not blacklisted, and not currently compiling: return nullptr and kick off compile
//otherwise: return nullptr
const code_descriptor* const get_descriptor_for_code(mode m, account_name receiver, const digest_type& code_id,
const code_descriptor* get_descriptor_for_code(mode m, account_name receiver, const digest_type& code_id,
const uint8_t& vm_version, get_cd_failure& failure);

private:
Expand All @@ -144,7 +144,7 @@ class code_cache_sync : public code_cache_base {
~code_cache_sync();

//Can still fail and return nullptr if, for example, there is an expected instantiation failure
const code_descriptor* const get_descriptor_for_code_sync(mode m, account_name receiver,
const code_descriptor* get_descriptor_for_code_sync(mode m, account_name receiver,
const digest_type& code_id, const uint8_t& vm_version);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class memory {
memory(const memory&) = delete;
memory& operator=(const memory&) = delete;

uint8_t* const zero_page_memory_base() const { return zeropage_base; }
uint8_t* const full_page_memory_base() const { return fullpage_base; }
uint8_t* zero_page_memory_base() const { return zeropage_base; }
uint8_t* full_page_memory_base() const { return fullpage_base; }

control_block* const get_control_block() const { return reinterpret_cast<control_block* const>(zeropage_base - cb_offset);}
control_block* get_control_block() const { return reinterpret_cast<control_block*>(zeropage_base - cb_offset);}

//these two are really only inteded for SEGV handling
uint8_t* const start_of_memory_slices() const { return mapbase; }
uint8_t* start_of_memory_slices() const { return mapbase; }
size_t size_of_memory_slice_mapping() const { return mapsize; }

//to obtain memory protected for n wasm-pages, use the pointer computed from:
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/wasm_sysio_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void globals_validation_visitor::validate( const Module& m ) {
case ValueType::i64:
case ValueType::f64:
mutable_globals_total_size += 4;
[[fallthrough]];
case ValueType::i32:
case ValueType::f32:
mutable_globals_total_size += 4;
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/webassembly/runtimes/sys-vm-oc/code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ std::tuple<size_t, size_t> code_cache_async::consume_compile_thread_queue() {
}


const code_descriptor* const
const code_descriptor*
code_cache_async::get_descriptor_for_code(mode m, account_name receiver, const digest_type& code_id, const uint8_t& vm_version, get_cd_failure& failure) {
//if there are any outstanding compiles, process the result queue now
//When app is in write window, all tasks are running sequentially and read-only threads
Expand Down Expand Up @@ -243,7 +243,7 @@ code_cache_sync::~code_cache_sync() {
elog("unexpected response from SYS VM OC compile monitor during shutdown");
}

const code_descriptor* const code_cache_sync::get_descriptor_for_code_sync(mode m, account_name receiver, const digest_type& code_id, const uint8_t& vm_version) {
const code_descriptor* code_cache_sync::get_descriptor_for_code_sync(mode m, account_name receiver, const digest_type& code_id, const uint8_t& vm_version) {
//check for entry in cache
code_cache_index::index<by_hash>::type::iterator it = _cache_index.get<by_hash>().find(code_id);
if(it != _cache_index.get<by_hash>().end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void run_compile(wrapped_fd&& response_sock, wrapped_fd&& wasm_code, uint64_t st
if(!global.type.isMutable)
continue;
prologue_it -= 8;
global_union* const u = (global_union* const)&*prologue_it;
global_union* const u = (global_union*)&*prologue_it;

switch(global.initializer.type) {
case InitializerExpression::Type::i32_const: u->i32 = global.initializer.i32; break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ int32_t sys_vm_oc_grow_memory(int32_t grow, int32_t max) {
uint64_t previous_page_count = cb_ptr->current_linear_memory_pages;
int32_t grow_amount = grow;
uint64_t max_pages = max;
if(max_pages > cb_ptr->max_linear_memory_pages)
if(max_pages > (uint64_t)cb_ptr->max_linear_memory_pages)
max_pages = cb_ptr->max_linear_memory_pages;
if(grow == 0)
return (int32_t)cb_ptr->current_linear_memory_pages;
if(previous_page_count + grow_amount > max_pages)
return (int32_t)-1;

int64_t max_segments = cb_ptr->execution_thread_memory_length / SYS_VM_OC_MEMORY_STRIDE - 1;
int was_extended = previous_page_count > max_segments;
int will_be_extended = previous_page_count + grow_amount > max_segments;
int was_extended = previous_page_count > (uint64_t)max_segments;
int will_be_extended = previous_page_count + grow_amount > (uint64_t)max_segments;
char* extended_memory_start = cb_ptr->full_linear_memory_start + max_segments * 64*1024;
int64_t gs_diff;
if(will_be_extended && grow_amount > 0) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/webassembly/runtimes/sys-vm-oc/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ memory::memory(uint64_t sliced_pages) {
fullpage_base = last + memory_prologue_size;

//layout the intrinsic jump table
uintptr_t* const intrinsic_jump_table = reinterpret_cast<uintptr_t* const>(zeropage_base - first_intrinsic_offset);
uintptr_t* const intrinsic_jump_table = reinterpret_cast<uintptr_t*>(zeropage_base - first_intrinsic_offset);
const intrinsic_map_t& intrinsics = get_intrinsic_map();
for(const auto& intrinsic : intrinsics)
intrinsic_jump_table[-(int)intrinsic.second.ordinal] = (uintptr_t)intrinsic.second.function_ptr;
Expand Down
3 changes: 2 additions & 1 deletion libraries/chaindb/test/undo_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ struct undo_index_in_segment {
segment_manager.destroy_ptr(p);
}

undo_index_t* const operator->() {
/// Access the stored index without applying an ignored qualifier to the returned pointer.
undo_index_t* operator->() {
return p;
}

Expand Down
6 changes: 4 additions & 2 deletions libraries/libfc/include/fc/bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ struct bitset {
static constexpr size_type bits_per_block = 8;
static constexpr size_type npos = static_cast<size_type>(-1);

/// Round up the storage requirement without overflowing at the maximum bit count.
static constexpr size_type calc_num_blocks(size_type num_bits) {
return (num_bits + bits_per_block - 1) / bits_per_block;
return num_bits / bits_per_block + (num_bits % bits_per_block != 0);
}

static size_type block_index(size_type pos) noexcept { return pos / bits_per_block; }
Expand Down Expand Up @@ -123,13 +124,14 @@ struct bitset {
return *this;
}

/// Clear padding only when a final storage block exists.
void zero_unused_bits() {
assert (m_bits.size() == calc_num_blocks(m_num_bits));

// if != 0 this is the number of bits used in the last block
const size_type extra_bits = bit_index(size());

if (extra_bits != 0)
if (!m_bits.empty() && extra_bits != 0)
m_bits.back() &= (uint8_t(1) << extra_bits) - 1;
}

Expand Down
19 changes: 15 additions & 4 deletions libraries/libfc/include/fc/exception/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,21 @@ namespace fc
throw e; \
}

#define FC_LOG_AND_DROP( FORMAT, ... ) \
catch( const boost::interprocess::bad_alloc& ) {\
throw;\
} catch( fc::exception& er ) { \
/// Log ordinary failures while allowing shared-memory allocation failures to propagate.
#define FC_LOG_AND_DROP( FORMAT, ... ) \
catch( const boost::interprocess::bad_alloc& ) { \
throw; \
} FC_DETAIL_LOG_AND_DROP( FORMAT, ##__VA_ARGS__ )

/// Preserve the fail-fast allocation policy in a noexcept cleanup operation.
#define FC_LOG_AND_DROP_NOEXCEPT( FORMAT, ... ) \
catch( const boost::interprocess::bad_alloc& ) { \
std::terminate(); \
} FC_DETAIL_LOG_AND_DROP( FORMAT, ##__VA_ARGS__ )

/// Common logging handlers; callers decide how to handle interprocess allocation failures.
#define FC_DETAIL_LOG_AND_DROP( FORMAT, ... ) \
catch( fc::exception& er ) { \
wlog( FORMAT " {}", ##__VA_ARGS__, er.to_detail_string() ); \
} catch( const std::exception& e ) { \
fc::std_exception_wrapper sew( \
Expand Down
1 change: 1 addition & 0 deletions libraries/libfc/include/fc/io/json_relaxed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ namespace fc { namespace json_relaxed
case 'r':
if( strict )
FC_THROW_EXCEPTION( parse_error_exception, "raw strings not supported in strict mode" );
[[fallthrough]];
case 'R':
in.get();
c2 = in.peek();
Expand Down
3 changes: 2 additions & 1 deletion libraries/libfc/include/fc/io/random_access_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,12 @@ class random_access_file {
return write(&c, sizeof(char));
}

/// Flush pending bytes, dropping write errors and retaining fail-fast shared-memory OOM handling.
~write_datastream() {
try {
if(ctx)
do_write();
} FC_LOG_AND_DROP("write failure ignored");
} FC_LOG_AND_DROP_NOEXCEPT("write failure ignored");
}

private:
Expand Down
2 changes: 2 additions & 0 deletions libraries/libfc/include/fc/safe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace fc {
safe( O o ):value(o){}
safe(){}
safe( const safe& o ):value(o.value){}
/// Assign the checked value without changing its representation.
safe& operator=(const safe&) = default;

static safe min()
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/libfc/src/crypto/elliptic_em.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class public_key_impl {
_init_lib();
}

/// Preserve memberwise key assignment alongside the custom copy constructor.
public_key_impl& operator=(const public_key_impl&) = default;

public_key_data _key{};
};

Expand Down
1 change: 1 addition & 0 deletions libraries/libfc/src/crypto/ethereum/ethereum_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fc::em::public_key to_em_public_key(const std::string& pubkey_hex) {
switch (pubkey_byte_count) {
case 64:
copy_to_offset = 1;
[[fallthrough]];
case 65: {
em::public_key_data_uncompressed pubkey_data;
std::copy_n(pubkey_bytes.data(), pubkey_bytes.size(), pubkey_data.data() + copy_to_offset);
Expand Down
6 changes: 6 additions & 0 deletions libraries/libfc/src/io/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ namespace fc
if (dot)
FC_THROW_EXCEPTION(parse_error_exception, "Can't parse a number with two decimal places");
dot = true;
[[fallthrough]];
case '0':
case '1':
case '2':
Expand Down Expand Up @@ -563,26 +564,31 @@ namespace fc
out += "\\t";
break;
}
[[fallthrough]];
case '\n': // \x0a
if( escape_control_chars ) {
out += "\\n";
break;
}
[[fallthrough]];
case '\r': // \x0d
if( escape_control_chars ) {
out += "\\r";
break;
}
[[fallthrough]];
case '\\':
if( escape_control_chars ) {
out += "\\\\";
break;
}
[[fallthrough]];
case '\"':
if( escape_control_chars ) {
out += "\\\"";
break;
}
[[fallthrough]];
default:
out += *itr;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/libfc/test/io/test_secure_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ constexpr long minimum_long_filename_name_max = 64;
/**
* Owns an open file stream and closes its underlying descriptor when a test scope exits.
*/
using file_stream_ptr = std::unique_ptr<std::FILE, decltype(&std::fclose)>;
using file_stream_ptr = std::unique_ptr<std::FILE, int (*)(std::FILE*)>;

/**
* Restores the process umask when a test scope exits.
Expand Down
6 changes: 3 additions & 3 deletions libraries/libfc/test/network/test_http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,13 @@ class tls_test_material {

/** Write one PEM certificate. */
void write_certificate(std::string_view name, X509& certificate) {
std::unique_ptr<FILE, decltype(&std::fclose)> output(std::fopen(path(name).c_str(), "w"), &std::fclose);
std::unique_ptr<FILE, int (*)(std::FILE*)> output(std::fopen(path(name).c_str(), "w"), &std::fclose);
FC_ASSERT(output && PEM_write_X509(output.get(), &certificate) == 1, "Failed to write TLS test certificate");
}

/** Write one unencrypted PEM private key. */
void write_key(std::string_view name, EVP_PKEY& key) {
std::unique_ptr<FILE, decltype(&std::fclose)> output(std::fopen(path(name).c_str(), "w"), &std::fclose);
std::unique_ptr<FILE, int (*)(std::FILE*)> output(std::fopen(path(name).c_str(), "w"), &std::fclose);
FC_ASSERT(output && PEM_write_PrivateKey(output.get(), &key, nullptr, nullptr, 0, nullptr, nullptr) == 1,
"Failed to write TLS test private key");
}
Expand Down Expand Up @@ -745,7 +745,7 @@ bool supports_ipv6_loopback() {

/** Return the OpenSSL hashed-directory filename for @p certificate. */
std::string certificate_hash_filename(const std::filesystem::path& certificate) {
std::unique_ptr<FILE, decltype(&std::fclose)> input(std::fopen(certificate.c_str(), "r"), &std::fclose);
std::unique_ptr<FILE, int (*)(std::FILE*)> input(std::fopen(certificate.c_str(), "r"), &std::fclose);
BOOST_REQUIRE(input);
std::unique_ptr<X509, decltype(&X509_free)> parsed(PEM_read_X509(input.get(), nullptr, nullptr, nullptr),
&X509_free);
Expand Down
Loading
Loading