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

IF: Integration tests enabled for instant-finality (Part 1) #2124

Merged
merged 29 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1cf678d
GH-1510 Add extra logging to help debug unlinkable block exceptions
heifner Jan 22, 2024
93d2151
GH-1510 Enable auto_bp_peering_test.py for instant finality
heifner Jan 22, 2024
1bb46d7
GH-1510 Add eosio bls key. Fix finality setting
heifner Jan 23, 2024
a6d42a8
GH-1510 Add block_log_retain_blocks_if_test
heifner Jan 23, 2024
9088f33
GH-1510 Add block_log_util_if_test
heifner Jan 23, 2024
14dad4b
GH-1510 Add cluster_launcher_if test
heifner Jan 23, 2024
cc11309
GH-1510 Remove unneeded threshold reduction
heifner Jan 23, 2024
a18eb0f
GH-1510 Add distributed-transactions-if-test. Switch compute_transact…
heifner Jan 23, 2024
f087acd
GH-1510 Exclude bios node from finalizer set unless needed
heifner Jan 24, 2024
eca46af
GH-1510 Allow test to indicate if bios node should be a finalizer
heifner Jan 24, 2024
6b0e1cd
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-15…
heifner Jan 24, 2024
68ec165
GH-1510 Handle common case of nodes killed during a test
heifner Jan 24, 2024
1244d15
GH-1510 Add larger_lib_if_test
heifner Jan 24, 2024
7e58cf7
GH-1510 Remove hs_ nomenclature
heifner Jan 24, 2024
10f8949
GH-1510 Add light_validation_sync_if_test
heifner Jan 24, 2024
8da1041
GH-1510 Add nodeos_chainbase_allocation_if_test and nodeos_contrl_c_i…
heifner Jan 25, 2024
b1c6b42
GH-1510 Run nodeos_extra_packed_data_test.py in instant-finality mode
heifner Jan 25, 2024
c00bf81
GH-1510 Enabled long running distributed-transactions-test, add distr…
heifner Jan 25, 2024
707dac7
Merge remote-tracking branch 'origin/qc_is_needed' into GH-1510-tests-if
heifner Jan 25, 2024
37bc9aa
GH-1510 Add nodeos_forked_chain_if_lr_test. Remove distributed_transa…
heifner Jan 25, 2024
b1e8eaf
GH-1510 Add nodeos_high_transaction_if_lr_test
heifner Jan 25, 2024
37f0263
GH-1510 nodeos_irreversible_mode_if_lr_test requires GH-2141
heifner Jan 25, 2024
cd13c78
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-15…
heifner Jan 25, 2024
f02142c
GH-1510 Added nodeos_producer_watermark_if_lr_test
heifner Jan 25, 2024
75f94b4
Merge remote-tracking branch 'origin/reject_invalid_qc' into GH-1510-…
heifner Jan 25, 2024
88714b0
GH-1510 Added nodeos_read_terminate_at_block_if_lr_test commented out…
heifner Jan 26, 2024
4642207
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-15…
heifner Jan 26, 2024
bdaf0e0
GH-1510 Extra logging to help debug test failures.
heifner Jan 26, 2024
029b265
Merge branch 'hotstuff_integration' into GH-1510-tests-if
heifner Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ namespace eosio {
void on_irreversible_block( const block_id_type& id, uint32_t block_num );

void bcast_vote_message( const std::optional<uint32_t>& exclude_peer, const chain::vote_message& msg );
void warn_hs_message( uint32_t sender_peer, const chain::hs_message_warning& code );
void warn_message( uint32_t sender_peer, const chain::hs_message_warning& code );

void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr<connection> from_connection);
void start_expire_timer();
Expand Down Expand Up @@ -1188,7 +1188,7 @@ namespace eosio {

void operator()( const chain::vote_message& msg ) const {
// continue call to handle_message on connection strand
peer_dlog( c, "handle hs_vote_message" );
peer_dlog( c, "handle vote_message" );
c->handle_message( msg );
}
};
Expand Down Expand Up @@ -3729,6 +3729,7 @@ namespace eosio {
// called from connection strand
void connection::handle_message( const block_id_type& id, signed_block_ptr ptr ) {
// post to dispatcher strand so that we don't have multiple threads validating the block header
peer_dlog(this, "posting block ${n} to dispatcher strand", ("n", ptr->block_num()));
my_impl->dispatcher->strand.post([id, c{shared_from_this()}, ptr{std::move(ptr)}, cid=connection_id]() mutable {
controller& cc = my_impl->chain_plug->chain();

Expand Down Expand Up @@ -3774,6 +3775,7 @@ namespace eosio {
my_impl->dispatcher->bcast_block( obt->block(), obt->id() );
}

fc_dlog(logger, "posting block ${n} to app thread", ("n", ptr->block_num()));
app().executor().post(priority::medium, exec_queue::read_write, [ptr{std::move(ptr)}, obt{std::move(obt)}, id, c{std::move(c)}]() mutable {
c->process_signed_block( id, std::move(ptr), obt );
});
Expand Down Expand Up @@ -3968,7 +3970,7 @@ namespace eosio {
});
}

void net_plugin_impl::warn_hs_message( uint32_t sender_peer, const chain::hs_message_warning& code ) {
void net_plugin_impl::warn_message( uint32_t sender_peer, const chain::hs_message_warning& code ) {
// potentially react to (repeated) receipt of invalid, irrelevant, duplicate, etc. hotstuff messages from sender_peer (connection ID) here
}

Expand Down Expand Up @@ -4318,8 +4320,6 @@ namespace eosio {
void net_plugin_impl::plugin_startup() {
fc_ilog( logger, "my node_id is ${id}", ("id", node_id ));

controller& cc = chain_plug->chain();

producer_plug = app().find_plugin<producer_plugin>();
set_producer_accounts(producer_plug->producer_accounts());

Expand Down
36 changes: 34 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resource_monitor_plugin_test.py ${CMA
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/light_validation_sync_test.py ${CMAKE_CURRENT_BINARY_DIR}/light_validation_sync_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/trace_plugin_test.py ${CMAKE_CURRENT_BINARY_DIR}/trace_plugin_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nested_container_multi_index_test.py ${CMAKE_CURRENT_BINARY_DIR}/nested_container_multi_index_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/large-lib-test.py ${CMAKE_CURRENT_BINARY_DIR}/large-lib-test.py COPYONLY)
linh2931 marked this conversation as resolved.
Show resolved Hide resolved
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/auto_bp_peering_test.py ${CMAKE_CURRENT_BINARY_DIR}/auto_bp_peering_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/auto_bp_peering_test_shape.json ${CMAKE_CURRENT_BINARY_DIR}/auto_bp_peering_test_shape.json COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gelf_test.py ${CMAKE_CURRENT_BINARY_DIR}/gelf_test.py COPYONLY)
Expand All @@ -95,8 +94,12 @@ add_test(NAME nodeos_lib_if_test COMMAND tests/nodeos_lib_test.py -n 4 -p 3 -s r
set_property(TEST nodeos_lib_if_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME block_log_util_test COMMAND tests/block_log_util_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST block_log_util_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME block_log_util_if_test COMMAND tests/block_log_util_test.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST block_log_util_if_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME block_log_retain_blocks_test COMMAND tests/block_log_retain_blocks_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST block_log_retain_blocks_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME block_log_retain_blocks_if_test COMMAND tests/block_log_retain_blocks_test.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST block_log_retain_blocks_if_test PROPERTY LABELS nonparallelizable_tests)

option(ABIEOS_ONLY_LIBRARY "define and build the ABIEOS library" ON)
set(ABIEOS_INSTALL_COMPONENT "dev")
Expand All @@ -121,6 +124,8 @@ target_link_libraries(ship_streamer abieos Boost::program_options Boost::system

add_test(NAME cluster_launcher COMMAND tests/cluster_launcher.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST cluster_launcher PROPERTY LABELS nonparallelizable_tests)
add_test(NAME cluster_launcher_if COMMAND tests/cluster_launcher.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST cluster_launcher_if PROPERTY LABELS nonparallelizable_tests)

add_test(NAME ship_test COMMAND tests/ship_test.py -v --num-clients 10 --num-requests 5000 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST ship_test PROPERTY LABELS nonparallelizable_tests)
Expand Down Expand Up @@ -156,6 +161,8 @@ add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactio
set_property(TEST distributed-transactions-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME distributed-transactions-speculative-test COMMAND tests/distributed-transactions-test.py -d 2 -p 4 -n 6 --speculative -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST distributed-transactions-speculative-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME distributed-transactions-if-test COMMAND tests/distributed-transactions-test.py -d 2 -p 4 -n 6 --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST distributed-transactions-if-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME restart-scenarios-test-resync COMMAND tests/restart-scenarios-test.py -c resync -p4 -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST restart-scenarios-test-resync PROPERTY LABELS nonparallelizable_tests)
add_test(NAME restart-scenarios-test-hard_replay COMMAND tests/restart-scenarios-test.py -c hardReplay -p4 -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down Expand Up @@ -202,14 +209,21 @@ set_property(TEST p2p_sync_throttle_test PROPERTY LABELS nonparallelizable_tests
#add_test(NAME p2p_high_latency_test COMMAND tests/p2p_high_latency_test.py -v WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_property(TEST p2p_high_latency_test PROPERTY LABELS nonparallelizable_tests)

# This test is too much for CI/CD machines. We do run it with fewer nodes as a nonparallelizable_tests above
#add_test(NAME distributed_transactions_lr_test COMMAND tests/distributed-transactions-test.py -d 2 -p 21 -n 21 -v WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_property(TEST distributed_transactions_lr_test PROPERTY LABELS long_running_tests)
#add_test(NAME distributed_transactions_if_lr_test COMMAND tests/distributed-transactions-test.py -d 2 -p 21 -n 21 --activate-if -v WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_property(TEST distributed_transactions_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_forked_chain_lr_test COMMAND tests/nodeos_forked_chain_test.py -v --wallet-port 9901 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_forked_chain_lr_test PROPERTY LABELS long_running_tests)
add_test(NAME nodeos_forked_chain_if_lr_test COMMAND tests/nodeos_forked_chain_test.py -v --activate-if --wallet-port 9901 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_forked_chain_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_contrl_c_test COMMAND tests/nodeos_contrl_c_test.py -v --wallet-port 9901 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_contrl_c_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME nodeos_contrl_c_if_test COMMAND tests/nodeos_contrl_c_test.py --activate-if -v --wallet-port 9901 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_contrl_c_if_test PROPERTY LABELS nonparallelizable_tests)

add_test(NAME nodeos_voting_lr_test COMMAND tests/nodeos_voting_test.py -v --wallet-port 9902 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_voting_lr_test PROPERTY LABELS long_running_tests)
Expand All @@ -219,12 +233,20 @@ set_property(TEST nodeos_under_min_avail_ram_lr_test PROPERTY LABELS long_runnin

add_test(NAME nodeos_irreversible_mode_lr_test COMMAND tests/nodeos_irreversible_mode_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_irreversible_mode_lr_test PROPERTY LABELS long_running_tests)
# requires https://github.com/AntelopeIO/leap/issues/2141
#add_test(NAME nodeos_irreversible_mode_if_lr_test COMMAND tests/nodeos_irreversible_mode_test.py -v --activate-if ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_property(TEST nodeos_irreversible_mode_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_read_terminate_at_block_lr_test COMMAND tests/nodeos_read_terminate_at_block_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_read_terminate_at_block_lr_test PROPERTY LABELS long_running_tests)
# requires https://github.com/AntelopeIO/leap/issues/2057 because running in irreversible mode currently switches different than non-irreversible mode
#add_test(NAME nodeos_read_terminate_at_block_if_lr_test COMMAND tests/nodeos_read_terminate_at_block_test.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
#set_property(TEST nodeos_read_terminate_at_block_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_chainbase_allocation_test COMMAND tests/nodeos_chainbase_allocation_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_chainbase_allocation_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME nodeos_chainbase_allocation_if_test COMMAND tests/nodeos_chainbase_allocation_test.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_chainbase_allocation_if_test PROPERTY LABELS nonparallelizable_tests)

add_test(NAME nodeos_startup_catchup_lr_test COMMAND tests/nodeos_startup_catchup.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_startup_catchup_lr_test PROPERTY LABELS long_running_tests)
Expand All @@ -240,9 +262,13 @@ set_property(TEST nodeos_extra_packed_data_test PROPERTY LABELS nonparallelizabl

add_test(NAME nodeos_producer_watermark_lr_test COMMAND tests/nodeos_producer_watermark_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_producer_watermark_lr_test PROPERTY LABELS long_running_tests)
add_test(NAME nodeos_producer_watermark_if_lr_test COMMAND tests/nodeos_producer_watermark_test.py -v --activate-if ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_producer_watermark_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_high_transaction_lr_test COMMAND tests/nodeos_high_transaction_test.py -v -p 4 -n 8 --num-transactions 10000 --max-transactions-per-second 500 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME nodeos_high_transaction_lr_test COMMAND tests/nodeos_high_transaction_test.py -p 4 -n 8 --num-transactions 10000 --max-transactions-per-second 500 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_high_transaction_lr_test PROPERTY LABELS long_running_tests)
add_test(NAME nodeos_high_transaction_if_lr_test COMMAND tests/nodeos_high_transaction_test.py --activate-if -p 4 -n 8 --num-transactions 10000 --max-transactions-per-second 500 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_high_transaction_if_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_retry_transaction_lr_test COMMAND tests/nodeos_retry_transaction_test.py -v --num-transactions 100 --max-transactions-per-second 10 --total-accounts 5 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_retry_transaction_lr_test PROPERTY LABELS long_running_tests)
Expand All @@ -252,6 +278,8 @@ set_property(TEST cli_test PROPERTY LABELS nonparallelizable_tests)

add_test(NAME larger_lib_test COMMAND tests/large-lib-test.py ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST larger_lib_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME larger_lib_if_test COMMAND tests/large-lib-test.py --activate-if ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST larger_lib_if_test PROPERTY LABELS nonparallelizable_tests)

add_test(NAME leap_util_bls_test COMMAND tests/leap_util_bls_test.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

Expand Down Expand Up @@ -279,9 +307,13 @@ set_property(TEST nodeos_repeat_transaction_lr_test PROPERTY LABELS long_running

add_test(NAME light_validation_sync_test COMMAND tests/light_validation_sync_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST light_validation_sync_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME light_validation_sync_if_test COMMAND tests/light_validation_sync_test.py --activate-if -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST light_validation_sync_if_test PROPERTY LABELS nonparallelizable_tests)

add_test(NAME auto_bp_peering_test COMMAND tests/auto_bp_peering_test.py -v ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST auto_bp_peering_test PROPERTY LABELS long_running_tests)
add_test(NAME auto_bp_peering_if_test COMMAND tests/auto_bp_peering_test.py -v --activate-if ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST auto_bp_peering_if_test PROPERTY LABELS long_running_tests)

add_test(NAME gelf_test COMMAND tests/gelf_test.py ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST gelf_test PROPERTY LABELS nonparallelizable_tests)
Expand Down
33 changes: 25 additions & 8 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def setAlternateVersionLabels(self, file):
# pylint: disable=too-many-statements
def launch(self, pnodes=1, unstartedNodes=0, totalNodes=1, prodCount=21, topo="mesh", delay=2, onlyBios=False, dontBootstrap=False,
totalProducers=None, sharedProducers=0, extraNodeosArgs="", specificExtraNodeosArgs=None, specificNodeosInstances=None, onlySetProds=False,
pfSetupPolicy=PFSetupPolicy.FULL, alternateVersionLabelsFile=None, associatedNodeLabels=None, loadSystemContract=True, activateIF=False,
pfSetupPolicy=PFSetupPolicy.FULL, alternateVersionLabelsFile=None, associatedNodeLabels=None, loadSystemContract=True,
activateIF=False, biosFinalizer=True,
nodeosLogPath=Path(Utils.TestLogRoot) / Path(f'{Path(sys.argv[0]).stem}{os.getpid()}'), genesisPath=None,
maximumP2pPerHost=0, maximumClients=25, prodsEnableTraceApi=True):
"""Launch cluster.
Expand All @@ -190,6 +191,8 @@ def launch(self, pnodes=1, unstartedNodes=0, totalNodes=1, prodCount=21, topo="m
alternateVersionLabelsFile: Supply an alternate version labels file to use with associatedNodeLabels.
associatedNodeLabels: Supply a dictionary of node numbers to use an alternate label for a specific node.
loadSystemContract: indicate whether the eosio.system contract should be loaded
activateIF: Activate/enable instant-finality by setting finalizers
biosFinalizer: True if the biosNode should act as a finalizer
genesisPath: set the path to a specific genesis.json to use
maximumP2pPerHost: Maximum number of client nodes from any single IP address. Defaults to totalNodes if not set.
maximumClients: Maximum number of clients from which connections are accepted, use 0 for no limit. Defaults to 25.
Expand Down Expand Up @@ -520,7 +523,7 @@ def connectGroup(group, producerNodes, bridgeNodes) :
return True

Utils.Print("Bootstrap cluster.")
if not self.bootstrap(launcher, self.biosNode, self.startedNodesCount, prodCount + sharedProducers, totalProducers, pfSetupPolicy, onlyBios, onlySetProds, loadSystemContract, activateIF):
if not self.bootstrap(launcher, self.biosNode, self.startedNodesCount, prodCount + sharedProducers, totalProducers, pfSetupPolicy, onlyBios, onlySetProds, loadSystemContract, activateIF, biosFinalizer):
Utils.Print("ERROR: Bootstrap failed.")
return False

Expand Down Expand Up @@ -992,17 +995,31 @@ def parseClusterKeys(totalNodes):
Utils.Print(f'Found {len(producerKeys)} producer keys')
return producerKeys

def activateInstantFinality(self, launcher, pnodes):
def activateInstantFinality(self, launcher, biosFinalizer, pnodes):
# call setfinalizer
numFins = pnodes
numFins = 0
for n in launcher.network.nodes.values():
if n.keys[0].blspubkey is None:
continue
if len(n.producers) == 0:
continue
if n.index == Node.biosNodeId and not biosFinalizer:
continue
numFins = numFins + 1

threshold = int(numFins * 2 / 3 + 1)
if threshold >= pnodes:
threshold = pnodes - 1
if threshold > 2 and threshold == numFins:
# nodes are often stopped, so do not require all node votes
threshold = threshold - 1
# pnodes does not include biosNode
if Utils.Debug: Utils.Print(f"threshold: {threshold}, numFins: {numFins}, pnodes: {pnodes}")
setFinStr = f'{{"finalizer_policy": {{'
setFinStr += f' "threshold": {threshold}, '
setFinStr += f' "finalizers": ['
finNum = 1
for n in launcher.network.nodes.values():
if n.index == Node.biosNodeId and not biosFinalizer:
continue
if n.keys[0].blspubkey is None:
continue
if len(n.producers) == 0:
Expand Down Expand Up @@ -1030,7 +1047,7 @@ def activateInstantFinality(self, launcher, pnodes):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a LIB block on server port %d." % (transId, biosNode.port))
return None

def bootstrap(self, launcher, biosNode, totalNodes, prodCount, totalProducers, pfSetupPolicy, onlyBios=False, onlySetProds=False, loadSystemContract=True, activateIF=False):
def bootstrap(self, launcher, biosNode, totalNodes, prodCount, totalProducers, pfSetupPolicy, onlyBios=False, onlySetProds=False, loadSystemContract=True, activateIF=False, biosFinalizer=True):
"""Create 'prodCount' init accounts and deposits 10000000000 SYS in each. If prodCount is -1 will initialize all possible producers.
Ensure nodes are inter-connected prior to this call. One way to validate this will be to check if every node has block 1."""

Expand Down Expand Up @@ -1094,7 +1111,7 @@ def bootstrap(self, launcher, biosNode, totalNodes, prodCount, totalProducers,
return None

if activateIF:
self.activateInstantFinality(launcher, self.productionNodesCount)
self.activateInstantFinality(launcher, biosFinalizer, self.productionNodesCount)

Utils.Print("Creating accounts: %s " % ", ".join(producerKeys.keys()))
producerKeys.pop(eosioName)
Expand Down
Loading
Loading