Skip to content

Commit

Permalink
Merge branch 'merge-main-01-31-2024' into GH-1510-integration-if-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 31, 2024
2 parents ea00b40 + 276b5cd commit a2ef2e2
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 115 deletions.
6 changes: 0 additions & 6 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4385,12 +4385,6 @@ void controller::set_proposed_finalizers( const finalizer_policy& fin_pol ) {
my->set_proposed_finalizers(fin_pol);
}

void controller::get_finalizer_state( finalizer_state& fs ) const {
// TODO: determine what should be returned from chain_api_plugin get_finalizer_state
// EOS_ASSERT( my->pacemaker, misc_exception, "chain_pacemaker not created" );
// my->pacemaker->get_state(fs);
}

// called from net threads
bool controller::process_vote_message( const vote_message& vote ) {
auto do_vote = [&vote](auto& forkdb) -> std::pair<bool, std::optional<uint32_t>> {
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ namespace eosio::chain {

// called by host function set_finalizers
void set_proposed_finalizers( const finalizer_policy& fin_set );
void get_finalizer_state( finalizer_state& fs ) const;
// called from net threads
bool process_vote_message( const vote_message& msg );

Expand Down
28 changes: 0 additions & 28 deletions libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ namespace eosio::chain {
uint8_t pcounter;
};

struct extended_schedule {
producer_authority_schedule producer_schedule;
std::map<name, fc::crypto::blslib::bls_public_key> bls_pub_keys;
};

struct quorum_certificate_message {
fc::sha256 proposal_id;
std::vector<uint32_t> strong_votes; //bitset encoding, following canonical order
Expand Down Expand Up @@ -97,27 +92,6 @@ namespace eosio::chain {
invalid // invalid message (other reason)
};

struct finalizer_state {
fc::sha256 b_leaf;
fc::sha256 b_lock;
fc::sha256 b_exec;
fc::sha256 b_finality_violation;
block_id_type block_exec;
block_id_type pending_proposal_block;
view_number v_height;
quorum_certificate_message high_qc;
quorum_certificate_message current_qc;
extended_schedule schedule;
std::map<fc::sha256, hs_proposal_message> proposals;

const hs_proposal_message* get_proposal(const fc::sha256& id) const {
auto it = proposals.find(id);
if (it == proposals.end())
return nullptr;
return & it->second;
}
};

using bls_public_key = fc::crypto::blslib::bls_public_key;
using bls_signature = fc::crypto::blslib::bls_signature;
using bls_private_key = fc::crypto::blslib::bls_private_key;
Expand Down Expand Up @@ -242,11 +216,9 @@ namespace eosio::chain {

FC_REFLECT(eosio::chain::view_number, (bheight)(pcounter));
FC_REFLECT(eosio::chain::quorum_certificate_message, (proposal_id)(strong_votes)(weak_votes)(active_agg_sig));
FC_REFLECT(eosio::chain::extended_schedule, (producer_schedule)(bls_pub_keys));
FC_REFLECT(eosio::chain::vote_message, (proposal_id)(strong)(finalizer_key)(sig));
FC_REFLECT(eosio::chain::hs_proposal_message, (proposal_id)(block_id)(parent_id)(final_on_qc)(justify)(phase_counter));
FC_REFLECT(eosio::chain::hs_new_view_message, (high_qc));
FC_REFLECT(eosio::chain::finalizer_state, (b_leaf)(b_lock)(b_exec)(b_finality_violation)(block_exec)(pending_proposal_block)(v_height)(high_qc)(current_qc)(schedule)(proposals));
FC_REFLECT(eosio::chain::hs_message, (msg));
FC_REFLECT(eosio::chain::valid_quorum_certificate, (_proposal_id)(_proposal_digest)(_strong_votes)(_weak_votes)(_sig));
FC_REFLECT(eosio::chain::quorum_certificate, (block_num)(qc));
10 changes: 10 additions & 0 deletions libraries/chain/webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ static constexpr size_t max_message_size = 8192;
static constexpr size_t max_num_fds = 4;

std::tuple<bool, eosvmoc_message, std::vector<wrapped_fd>> read_message_with_fds(boost::asio::local::datagram_protocol::socket& s) {
// read_message_with_fds() is intended to be blocking, and sockets it is used with are never explicitly set to non-blocking mode.
// But when doing an async_wait() on an asio socket, asio will set the underlying file descriptor to non-blocking mode.
// It's not clear why, but in some cases after async_wait() indicates readiness, a recvmsg() on the socket can fail with
// EAGAIN if the file descriptor is still in non-blocking mode (as asio had set it to).
// Always set the file descriptor to blocking mode before performing the recvmsg()
boost::system::error_code ec;
s.native_non_blocking(false, ec);
if(ec)
wlog("Failed to set socket's native blocking mode");

return read_message_with_fds(s.native_handle());
}

Expand Down
6 changes: 1 addition & 5 deletions plugins/chain_api_plugin/chain_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,8 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RO_CALL_WITH_400(get_transaction_status, 200, http_params_types::params_required),
}, appbase::exec_queue::read_only);
}

_http_plugin.add_api({
CHAIN_RO_CALL(get_finalizer_state, 200, http_params_types::no_params)
}, appbase::exec_queue::read_only);
}

void chain_api_plugin::plugin_shutdown() {}

}
}
24 changes: 0 additions & 24 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2598,30 +2598,6 @@ read_only::get_consensus_parameters(const get_consensus_parameters_params&, cons
return results;
}

read_only::get_finalizer_state_results
read_only::get_finalizer_state(const get_finalizer_state_params&, const fc::time_point& deadline ) const {
get_finalizer_state_results results;

chain::finalizer_state fs;
db.get_finalizer_state( fs );
results.b_leaf = fs.b_leaf;
results.b_lock = fs.b_lock;
results.b_exec = fs.b_exec;
results.b_finality_violation = fs.b_finality_violation;
results.block_exec = fs.block_exec;
results.pending_proposal_block = fs.pending_proposal_block;
results.v_height = fs.v_height;
results.high_qc = fs.high_qc;
results.current_qc = fs.current_qc;
results.schedule = fs.schedule;
results.proposals.reserve( fs.proposals.size() );
for (const auto& proposal : fs.proposals) {
const chain::hs_proposal_message& p = proposal.second;
results.proposals.push_back( hs_complete_proposal_message( p ) );
}
return results;
}

} // namespace chain_apis

fc::variant chain_plugin::get_log_trx_trace(const transaction_trace_ptr& trx_trace ) const {
Expand Down
41 changes: 0 additions & 41 deletions plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,45 +823,6 @@ class read_only : public api_base {
std::optional<chain::wasm_config> wasm_config;
};
get_consensus_parameters_results get_consensus_parameters(const get_consensus_parameters_params&, const fc::time_point& deadline) const;

struct hs_complete_proposal_message {
fc::sha256 proposal_id;
chain::block_id_type block_id;
fc::sha256 parent_id;
fc::sha256 final_on_qc;
chain::quorum_certificate_message justify;
uint8_t phase_counter = 0;
uint32_t block_height = 0;
uint64_t view_number = 0;
explicit hs_complete_proposal_message( const chain::hs_proposal_message& p ) {
proposal_id = p.proposal_id;
block_id = p.block_id;
parent_id = p.parent_id;
final_on_qc = p.final_on_qc;
justify = p.justify;
phase_counter = p.phase_counter;
block_height = p.block_num();
view_number = p.get_key();
}
hs_complete_proposal_message() = default; // cleos requires this
};

using get_finalizer_state_params = empty;
struct get_finalizer_state_results {
fc::sha256 b_leaf;
fc::sha256 b_lock;
fc::sha256 b_exec;
fc::sha256 b_finality_violation;
chain::block_id_type block_exec;
chain::block_id_type pending_proposal_block;
chain::view_number v_height;
chain::quorum_certificate_message high_qc;
chain::quorum_certificate_message current_qc;
chain::extended_schedule schedule;
vector<hs_complete_proposal_message> proposals;
};

get_finalizer_state_results get_finalizer_state(const get_finalizer_state_params&, const fc::time_point& deadline) const;
};

class read_write : public api_base {
Expand Down Expand Up @@ -1113,5 +1074,3 @@ FC_REFLECT( eosio::chain_apis::read_only::compute_transaction_results, (transact
FC_REFLECT( eosio::chain_apis::read_only::send_read_only_transaction_params, (transaction))
FC_REFLECT( eosio::chain_apis::read_only::send_read_only_transaction_results, (transaction_id)(processed) )
FC_REFLECT( eosio::chain_apis::read_only::get_consensus_parameters_results, (chain_config)(wasm_config))
FC_REFLECT( eosio::chain_apis::read_only::hs_complete_proposal_message, (proposal_id)(block_id)(parent_id)(final_on_qc)(justify)(phase_counter)(block_height)(view_number))
FC_REFLECT( eosio::chain_apis::read_only::get_finalizer_state_results, (b_leaf)(b_lock)(b_exec)(b_finality_violation)(block_exec)(pending_proposal_block)(v_height)(high_qc)(current_qc)(schedule)(proposals))
1 change: 0 additions & 1 deletion programs/cleos/httpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace eosio { namespace client { namespace http {

const string chain_func_base = "/v1/chain";
const string get_info_func = chain_func_base + "/get_info";
const string get_finalizer_state_func = chain_func_base + "/get_finalizer_state";
const string get_transaction_status_func = chain_func_base + "/get_transaction_status";
const string get_consensus_parameters_func = chain_func_base + "/get_consensus_parameters";
const string send_txn_func = chain_func_base + "/send_transaction";
Expand Down
9 changes: 0 additions & 9 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,10 +2367,6 @@ protocol_features_t get_supported_protocol_features() {
return results;
};

eosio::chain_apis::read_only::get_finalizer_state_results get_finalizer_state() {
return call(::default_url, get_finalizer_state_func).as<eosio::chain_apis::read_only::get_finalizer_state_results>();
}

struct activate_subcommand {
string feature_name_str;
std::string account_str = "eosio";
Expand Down Expand Up @@ -3417,11 +3413,6 @@ int main( int argc, char** argv ) {
std::cout << supported_features.names << std::endl;
});

// get finalizer state
get->add_subcommand("finalizer_state", localized("Get finalizer state"))->callback([] {
std::cout << fc::json::to_pretty_string(get_finalizer_state()) << std::endl;
});

// set subcommand
auto setSubcommand = app.add_subcommand("set", localized("Set or update blockchain state"));
setSubcommand->require_subcommand();
Expand Down

0 comments on commit a2ef2e2

Please sign in to comment.