Skip to content

Commit

Permalink
Merge remote-tracking branch 'spring/main' into GH-5-diff-policies
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed May 8, 2024
2 parents 8000be2 + e044793 commit 560eb78
Show file tree
Hide file tree
Showing 22 changed files with 1,285 additions and 1,095 deletions.
38 changes: 21 additions & 17 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2956,12 +2956,12 @@ struct controller_impl {
} FC_CAPTURE_AND_RETHROW((trace))
} /// push_transaction

void start_block( block_timestamp_type when,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
controller::block_status s,
const std::optional<block_id_type>& producer_block_id,
const fc::time_point& deadline )
transaction_trace_ptr start_block( block_timestamp_type when,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
controller::block_status s,
const std::optional<block_id_type>& producer_block_id,
const fc::time_point& deadline )
{
EOS_ASSERT( !pending, block_validate_exception, "pending block already exists" );

Expand Down Expand Up @@ -3000,6 +3000,8 @@ struct controller_impl {

auto& bb = std::get<building_block>(pending->_block_stage);

transaction_trace_ptr onblock_trace;

// block status is either ephemeral or incomplete. Modify state of speculative block only if we are building a
// speculative incomplete block (otherwise we need clean state for head mode, ephemeral block)
if ( pending->_block_status != controller::block_status::ephemeral ) {
Expand Down Expand Up @@ -3106,10 +3108,11 @@ struct controller_impl {
in_trx_requiring_checks = old_value;
});
in_trx_requiring_checks = true;
auto trace = push_transaction( onbtrx, fc::time_point::maximum(), fc::microseconds::maximum(),
gpo.configuration.min_transaction_cpu_usage, true, 0 );
if( trace->except ) {
wlog("onblock ${block_num} is REJECTING: ${entire_trace}",("block_num", chain_head.block_num() + 1)("entire_trace", trace));
onblock_trace = push_transaction( onbtrx, fc::time_point::maximum(), fc::microseconds::maximum(),
gpo.configuration.min_transaction_cpu_usage, true, 0 );
if( onblock_trace->except ) {
wlog("onblock ${block_num} is REJECTING: ${entire_trace}",
("block_num", chain_head.block_num() + 1)("entire_trace", onblock_trace));
}
} catch( const std::bad_alloc& e ) {
elog( "on block transaction failed due to a std::bad_alloc" );
Expand All @@ -3132,6 +3135,7 @@ struct controller_impl {
}

guard_pending.cancel();
return onblock_trace;
} /// start_block

void assemble_block(bool validating, std::optional<qc_data_t> validating_qc_data, const block_state_ptr& validating_bsp)
Expand Down Expand Up @@ -4938,11 +4942,11 @@ void controller::validate_protocol_features( const vector<digest_type>& features
features_to_activate );
}

void controller::start_block( block_timestamp_type when,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
block_status bs,
const fc::time_point& deadline )
transaction_trace_ptr controller::start_block( block_timestamp_type when,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
block_status bs,
const fc::time_point& deadline )
{
validate_db_available_size();

Expand All @@ -4952,8 +4956,8 @@ void controller::start_block( block_timestamp_type when,

EOS_ASSERT( bs == block_status::incomplete || bs == block_status::ephemeral, block_validate_exception, "speculative block type required" );

my->start_block( when, confirm_block_count, new_protocol_feature_activations,
bs, std::optional<block_id_type>(), deadline );
return my->start_block( when, confirm_block_count, new_protocol_feature_activations,
bs, std::optional<block_id_type>(), deadline );
}

void controller::assemble_and_complete_block( block_report& br, const signer_callback_type& signer_callback ) {
Expand Down
11 changes: 6 additions & 5 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ namespace eosio::chain {

/**
* Starts a new pending block session upon which new transactions can be pushed.
* returns the trace for the on_block action
*/
void start_block( block_timestamp_type time,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
block_status bs,
const fc::time_point& deadline = fc::time_point::maximum() );
transaction_trace_ptr start_block( block_timestamp_type time,
uint16_t confirm_block_count,
const vector<digest_type>& new_protocol_feature_activations,
block_status bs,
const fc::time_point& deadline = fc::time_point::maximum() );

/**
* @return transactions applied in aborted block
Expand Down
2 changes: 1 addition & 1 deletion libraries/chainbase
14 changes: 7 additions & 7 deletions libraries/libfc/include/fc/network/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct listener_base<boost::asio::local::stream_protocol> {
/// detail for fc::create_listener().
///
/////////////////////////////////////////////////////////////////////////////////////////////
template <typename Protocol, typename CreateSession>
struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener<Protocol, CreateSession>> {
template <typename Protocol, typename Executor, typename CreateSession>
struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener<Protocol, Executor, CreateSession>> {
private:
typename Protocol::acceptor acceptor_;
boost::asio::deadline_timer accept_error_timer_;
Expand All @@ -71,7 +71,7 @@ struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener

public:
using endpoint_type = typename Protocol::endpoint;
listener(boost::asio::io_context& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
listener(Executor& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
const std::string& local_address, const endpoint_type& endpoint,
const std::string& extra_listening_log_info, const CreateSession& create_session)
: listener_base<Protocol>(local_address), acceptor_(executor, endpoint), accept_error_timer_(executor),
Expand Down Expand Up @@ -159,8 +159,8 @@ struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener
///
/// @tparam Protocol either \c boost::asio::ip::tcp or \c boost::asio::local::stream_protocol
/// @throws std::system_error or boost::system::system_error
template <typename Protocol, typename CreateSession>
void create_listener(boost::asio::io_context& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
template <typename Protocol, typename Executor, typename CreateSession>
void create_listener(Executor& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
const std::string& address, const std::string& extra_listening_log_info,
const CreateSession& create_session) {
using tcp = boost::asio::ip::tcp;
Expand All @@ -186,7 +186,7 @@ void create_listener(boost::asio::io_context& executor, logger& logger, boost::p
auto create_listener = [&](const auto& endpoint) {
const auto& ip_addr = endpoint.address();
try {
auto listener = std::make_shared<fc::listener<Protocol, CreateSession>>(
auto listener = std::make_shared<fc::listener<Protocol, Executor, CreateSession>>(
executor, logger, accept_timeout, address, endpoint, extra_listening_log_info, create_session);
listener->log_listening(endpoint, address);
listener->do_accept();
Expand Down Expand Up @@ -256,7 +256,7 @@ void create_listener(boost::asio::io_context& executor, logger& logger, boost::p
fs::remove(sock_path);
}

auto listener = std::make_shared<fc::listener<stream_protocol, CreateSession>>(
auto listener = std::make_shared<fc::listener<stream_protocol, Executor, CreateSession>>(
executor, logger, accept_timeout, address, endpoint, extra_listening_log_info, create_session);
listener->log_listening(endpoint, address);
listener->do_accept();
Expand Down
16 changes: 9 additions & 7 deletions libraries/state_history/include/eosio/state_history/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static constexpr int state_history_log_header_serial_size = sizeof(state_history
sizeof(state_history_log_header::payload_size);
static_assert(sizeof(state_history_log_header) == state_history_log_header_serial_size);

static constexpr unsigned ship_log_iostreams_buffer_size = 64*1024;

namespace state_history {
struct prune_config {
uint32_t prune_blocks; //number of blocks to prune to when doing a prune
Expand Down Expand Up @@ -108,16 +110,16 @@ struct locked_decompress_stream {
template <typename StateHistoryLog>
void init(StateHistoryLog&& log, fc::cfile& stream, uint64_t compressed_size) {
auto istream = std::make_unique<bio::filtering_istreambuf>();
istream->push(bio::zlib_decompressor());
istream->push(bio::restrict(bio::file_source(stream.get_file_path().string()), stream.tellp(), compressed_size));
istream->push(bio::zlib_decompressor(), ship_log_iostreams_buffer_size);
istream->push(bio::restrict(bio::file_source(stream.get_file_path().string()), stream.tellp(), compressed_size), ship_log_iostreams_buffer_size);
buf = std::move(istream);
}

template <typename LogData>
void init(LogData&& log, fc::datastream<const char*>& stream, uint64_t compressed_size) {
auto istream = std::make_unique<bio::filtering_istreambuf>();
istream->push(bio::zlib_decompressor());
istream->push(bio::restrict(bio::file_source(log.filename), stream.pos() - log.data(), compressed_size));
istream->push(bio::zlib_decompressor(), ship_log_iostreams_buffer_size);
istream->push(bio::restrict(bio::file_source(log.filename), stream.pos() - log.data(), compressed_size), ship_log_iostreams_buffer_size);
buf = std::move(istream);
}

Expand Down Expand Up @@ -433,9 +435,9 @@ class state_history_log {
detail::counter cnt;
{
bio::filtering_ostreambuf buf;
buf.push(boost::ref(cnt));
buf.push(bio::zlib_compressor(boost::iostreams::zlib::no_compression));
buf.push(bio::file_descriptor_sink(stream.fileno(), bio::never_close_handle));
buf.push(boost::ref(cnt), ship_log_iostreams_buffer_size);
buf.push(bio::zlib_compressor(bio::zlib::no_compression, ship_log_iostreams_buffer_size));
buf.push(bio::file_descriptor_sink(stream.fileno(), bio::never_close_handle), ship_log_iostreams_buffer_size);
pack_to(buf);
}

Expand Down
Loading

0 comments on commit 560eb78

Please sign in to comment.