Skip to content

Commit 3c4df6a

Browse files
authored
Merge pull request #380 from eosnetworkfoundation/yarkin/merge_2.0_exit_on_failure
[2.0->main] Exit instead of silently continue for exceptions when processing blocks
2 parents cd07f41 + eebd16e commit 3c4df6a

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

external/silkworm

src/blockchain_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class blockchain_plugin_impl : std::enable_shared_from_this<blockchain_plugin_im
7878
}
7979

8080
void shutdown() {
81-
exec_engine->close();
8281
exec_engine->stop();
82+
exec_engine->close();
8383
}
8484

8585
using txn_t = std::unique_ptr<silkworm::db::RWTxn>;

src/channels.hpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,26 @@ namespace channels {
4141
std::optional<native_action> new_config = std::nullopt;
4242
std::vector<native_trx> transactions;
4343
};
44+
45+
// Dispatch Policy that exit on exception
46+
struct exit_on_exceptions {
47+
exit_on_exceptions() = default;
48+
using result_type = void;
49+
50+
template<typename InputIterator>
51+
result_type operator()(InputIterator first, InputIterator last) {
52+
while (first != last) {
53+
try {
54+
*first;
55+
} catch (...) {
56+
SILK_CRIT << "Caught exception when processing channel callbacks.";
57+
appbase::app().quit();
58+
}
59+
++first;
60+
}
61+
}
62+
};
4463

45-
using native_blocks = appbase::channel_decl<struct native_blocks_tag, std::shared_ptr<native_block>>;
46-
using evm_blocks = appbase::channel_decl<struct evm_blocks_tag, std::shared_ptr<silkworm::Block>>;
64+
using native_blocks = appbase::channel_decl<struct native_blocks_tag, std::shared_ptr<native_block>, exit_on_exceptions>;
65+
using evm_blocks = appbase::channel_decl<struct evm_blocks_tag, std::shared_ptr<silkworm::Block>, exit_on_exceptions>;
4766
} // ns channels

src/engine_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class engine_plugin_impl : std::enable_shared_from_this<engine_plugin_impl> {
124124
}
125125

126126
inline void shutdown() {
127-
eth->close();
128127
server->shutdown();
128+
eth->close();
129129
SILK_INFO << "Stopped Engine Server";
130130
}
131131

0 commit comments

Comments
 (0)