Skip to content

Commit

Permalink
Merge remote-tracking branch 'spring/main' into GH-570-pause-at-block
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Dec 5, 2024
2 parents a7b65cc + 631fed0 commit 8a47ac5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .cicd/defaults.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cdt":{
"target":"main",
"target":"4.1",
"prerelease":true
},
"referencecontracts":{
Expand Down
15 changes: 0 additions & 15 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,21 +2040,6 @@ struct controller_impl {
// Furthermore, fork_db.root()->block_num() <= lib_num.
// Also, even though blog.head() may still be nullptr, blog.first_block_num() is guaranteed to be lib_num + 1.

auto finish_init = [&](auto& fork_db) {
if( read_mode != db_read_mode::IRREVERSIBLE ) {
auto pending_head = fork_db.head();
if ( pending_head && pending_head->id() != chain_head.id() ) {
// chain_head equal to root means that read_mode was changed from irreversible mode to head/speculative
bool chain_head_is_root = chain_head.id() == fork_db.root()->id();
if (chain_head_is_root) {
ilog( "read_mode has changed from irreversible" );
}
}
}
};

fork_db_.apply<void>(finish_init);

// At Leap startup, we want to provide to our local finalizers the correct safety information
// to use if they don't already have one.
// If we start at a block prior to the IF transition, that information will be provided when
Expand Down
13 changes: 8 additions & 5 deletions libraries/chain/include/eosio/chain/fork_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ namespace eosio::chain {
using block_branch_t = std::vector<signed_block_ptr>;
enum class ignore_duplicate_t { no, yes };
enum class include_root_t { no, yes };
enum class fork_db_add_t { failure, duplicate, added, appended_to_head, fork_switch };
enum class fork_db_add_t {
failure, // add failed
duplicate, // already added and ignore_duplicate=true
added, // inserted into an existing branch or started a new branch, but not best branch
appended_to_head, // new best head of current best branch; no fork switch
fork_switch // new best head of new branch, fork switch to new branch
};

// Used for logging of comparison values used for best fork determination
std::string log_fork_comparison(const block_state& bs);
Expand Down Expand Up @@ -68,10 +74,7 @@ namespace eosio::chain {
/**
* Add block state to fork database.
* Must link to existing block in fork database or the root.
* @returns duplicate - already added and ignore_duplicate=true
* added - inserted into an existing branch or started a new branch, not best branch
* appended_to_head - new best head of current best branch
* fork_switch - new best head of new branch, fork switch to new branch
* @returns fork_db_add_t - result of the add
* @throws unlinkable_block_exception - unlinkable to any branch
* @throws fork_database_exception - no root, n is nullptr, protocol feature error, duplicate when ignore_duplicate=false
*/
Expand Down
13 changes: 8 additions & 5 deletions libraries/chain/include/eosio/chain/wasm_interface_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ struct eosvmoc_tier {
bool attempt_tierup = false;
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
attempt_tierup = eosvmoc && (eosvmoc_tierup == wasm_interface::vm_oc_enable::oc_all || context.should_use_eos_vm_oc());
const bool allow_oc_interrupt = attempt_tierup && context.is_applying_block() && context.trx_context.has_undo();
if (attempt_tierup) {
const chain::eosvmoc::code_descriptor* cd = nullptr;
chain::eosvmoc::code_cache_base::get_cd_failure failure = chain::eosvmoc::code_cache_base::get_cd_failure::temporary;
Expand Down Expand Up @@ -170,17 +169,21 @@ struct eosvmoc_tier {
}
}
#endif
const bool allow_oc_interrupt = attempt_tierup && context.is_applying_block() && context.trx_context.has_undo();
auto ex = fc::make_scoped_exit([&]() {
eos_vm_oc_compile_interrupt = false;
executing_code_hash.store({}); // indicate no longer executing
if (allow_oc_interrupt) {
eos_vm_oc_compile_interrupt = false;
executing_code_hash.store({}); // indicate no longer executing
}
});
executing_code_hash.store(code_hash);
if (allow_oc_interrupt)
executing_code_hash.store(code_hash);
try {
get_instantiated_module(code_hash, vm_type, vm_version, context.trx_context)->apply(context);
} catch (const interrupt_exception& e) {
if (allow_oc_interrupt && eos_vm_oc_compile_interrupt) {
++eos_vm_oc_compile_interrupt_count;
wlog("EOS VM OC compile complete interrupt of ${r} <= ${a}::${act} code ${h}, interrupt #${c}",
dlog("EOS VM OC compile complete interrupt of ${r} <= ${a}::${act} code ${h}, interrupt #${c}",
("r", context.get_receiver())("a", context.get_action().account)
("act", context.get_action().name)("h", code_hash)("c", eos_vm_oc_compile_interrupt_count));
EOS_THROW(interrupt_oc_exception, "EOS VM OC compile complete interrupt of ${r} <= ${a}::${act} code ${h}, interrupt #${c}",
Expand Down
2 changes: 2 additions & 0 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,8 @@ void producer_plugin::process_blocks() {

void producer_plugin::received_block(uint32_t block_num, chain::fork_db_add_t fork_db_add_result) {
my->_received_block = block_num;
// fork_db_add_t::fork_switch means head block of best fork (different from the current branch) is received.
// Since a better fork is available, interrupt current block validation and allow a fork switch to the better branch.
if (fork_db_add_result == fork_db_add_t::fork_switch) {
fc_ilog(_log, "new best fork received");
my->chain_plug->chain().interrupt_apply_block_transaction();
Expand Down
11 changes: 6 additions & 5 deletions tests/separate_prod_fin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
# LIB has advanced, which indicate at least 2 of non-producer finalizers have voted.
block_num = cluster.getNode(1).getIrreversibleBlockNum()
block = cluster.getNode(1).getBlock(block_num)
qc_ext = block["qc_extension"]
Print(f'{qc_ext}')
# "11111" is the representation of a bitset showing which finalizers have voted (we have five total finalizers)
if qc_ext["qc"]["active_policy_sig"]["strong_votes"] == "11111":
break
if "qc_extension" in block:
qc_ext = block["qc_extension"]
Print(f'{qc_ext}')
# "11111" is the representation of a bitset showing which finalizers have voted (we have five total finalizers)
if qc_ext["qc"]["active_policy_sig"]["strong_votes"] == "11111":
break
cluster.getNode(1).waitForLibToAdvance()
i += 1
assert i < 3, "Not all finalizers voted"
Expand Down

0 comments on commit 8a47ac5

Please sign in to comment.