Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sec/MAS-1455 - Stability Upgrades #35

Merged
merged 8 commits into from
Apr 13, 2020
9 changes: 7 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2550,12 +2550,15 @@ namespace eosio {
validate_reversible_available_size();
my->push_block(block_state_future);
}
bool controller::in_immutable_mode()const {
return (db_mode_is_immutable(get_read_mode()));
}

transaction_trace_ptr controller::push_transaction(const transaction_metadata_ptr &trx, fc::time_point deadline,
uint32_t billed_cpu_time_us) {
validate_db_available_size();
EOS_ASSERT(get_read_mode() != chain::db_read_mode::READ_ONLY, transaction_type_exception,
"push transaction not allowed in read-only mode");
EOS_ASSERT( !in_immutable_mode(), transaction_type_exception,
"push transaction not allowed in read-only mode" );
EOS_ASSERT(trx && !trx->implicit && !trx->scheduled, transaction_type_exception,
"Implicit/Scheduled transaction not allowed");
return my->push_transaction(trx, deadline, billed_cpu_time_us, billed_cpu_time_us > 0);
Expand All @@ -2564,6 +2567,8 @@ namespace eosio {
transaction_trace_ptr
controller::push_scheduled_transaction(const transaction_id_type &trxid, fc::time_point deadline,
uint32_t billed_cpu_time_us) {
EOS_ASSERT( !in_immutable_mode(), transaction_type_exception,
"push scheduled transaction not allowed in read-only mode" );
validate_db_available_size();
return my->push_scheduled_transaction(trxid, deadline, billed_cpu_time_us, billed_cpu_time_us > 0);
}
Expand Down
6 changes: 6 additions & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ namespace eosio {
IRREVERSIBLE
};

inline bool db_mode_is_immutable(db_read_mode m) {
return db_read_mode::READ_ONLY == m || db_read_mode::IRREVERSIBLE ==m;
}

enum class validation_mode {
FULL,
LIGHT
Expand Down Expand Up @@ -344,6 +348,8 @@ namespace eosio {

validation_mode get_validation_mode() const;

bool in_immutable_mode() const;

void set_subjective_cpu_leeway(fc::microseconds leeway);

void set_greylist_limit(uint32_t limit);
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
Submodule fc updated 1 files
+4 −2 src/log/logger_config.cpp
4 changes: 2 additions & 2 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ if( options.count(name) ) { \
}

void chain_apis::read_write::validate() const {
EOS_ASSERT(db.get_read_mode() != chain::db_read_mode::READ_ONLY, missing_chain_api_plugin_exception,
"Not allowed, node in read-only mode");
EOS_ASSERT( !db.in_immutable_mode(), missing_chain_api_plugin_exception,
"Not allowed, node in read-only mode" );
}

void chain_plugin::accept_block(const signed_block_ptr &block) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ namespace eosio {
if (my->thread_pool) {
my->thread_pool->stop();
}

app().post( 0, [me = my](){} ); // keep my pointer alive until queue is drained
}

void http_plugin::add_handler(const string &url, const url_handler &handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace eosio {
get_supported_apis_result get_supported_apis() const;

private:
std::unique_ptr<class http_plugin_impl> my;
std::shared_ptr<class http_plugin_impl> my;
};

/**
Expand Down
18 changes: 9 additions & 9 deletions plugins/net_plugin/include/eosio/net_plugin/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace eosio {
chain_id_type chain_id; ///< used to identify chain
fc::sha256 node_id; ///< used to identify peers and prevent self-connect
chain::public_key_type key; ///< authentication key; may be a producer or peer key, or empty
tstamp time;
tstamp time{0};
fc::sha256 token; ///< digest of time to prove we own the private key of the key above
chain::signature_type sig; ///< signature for the digest
string p2p_address;
Expand All @@ -36,7 +36,7 @@ namespace eosio {
block_id_type head_id;
string os;
string agent;
int16_t generation;
int16_t generation{0};
};


Expand Down Expand Up @@ -75,15 +75,15 @@ namespace eosio {

struct go_away_message {
go_away_message (go_away_reason r = no_reason) : reason(r), node_id() {}
go_away_reason reason;
go_away_reason reason{no_reason};
fc::sha256 node_id; ///< for duplicate notification
};

struct time_message {
tstamp org; //!< origin timestamp
tstamp rec; //!< receive timestamp
tstamp xmt; //!< transmit timestamp
mutable tstamp dst; //!< destination timestamp
tstamp org{0}; //!< origin timestamp
tstamp rec{0}; //!< receive timestamp
tstamp xmt{0}; //!< transmit timestamp
mutable tstamp dst{0}; //!< destination timestamp
};

enum id_list_modes {
Expand Down Expand Up @@ -128,8 +128,8 @@ namespace eosio {
};

struct sync_request_message {
uint32_t start_block;
uint32_t end_block;
uint32_t start_block{0};
uint32_t end_block{0};
};

using net_message = static_variant<handshake_message,
Expand Down
Loading