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: Do not allow set_finalizers during transition #60

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
6 changes: 4 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,10 @@ struct building_block {
void set_proposed_finalizer_policy(finalizer_policy&& fin_pol)
{
std::visit(overloaded{ [&](building_block_legacy& bb) {
fin_pol.generation = 1; // only allowed to be set once in legacy mode
bb.new_finalizer_policy = std::move(fin_pol);
if (!bb.pending_block_header_state.is_if_transition_block()) {
fin_pol.generation = 1; // only allowed to be set once in legacy mode
bb.new_finalizer_policy = std::move(fin_pol);
}
},
[&](building_block_if& bb) {
bb.new_finalizer_policy = std::move(fin_pol);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def activateInstantFinality(self, biosFinalizer=True, waitForFinalization=True):
transId = Node.getTransId(trans[1])
if waitForFinalization:
if not self.biosNode.waitForTransFinalization(transId, timeout=21*12*3):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a LIB block on server port %d." % (transId, biosNode.port))
Utils.Print("ERROR: Failed to validate setfinalizer transaction %s got rolled into a LIB block on server port %d." % (transId, biosNode.port))
return None, transId
return True, transId

Expand Down
10 changes: 8 additions & 2 deletions tests/transition_to_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
testSuccessful=False

cluster=Cluster(unshared=args.unshared, keepRunning=args.leave_running, keepLogs=args.keep_logs)
walletMgr=WalletMgr(True)
walletMgr=WalletMgr(True, keepRunning=args.leave_running, keepLogs=args.keep_logs)

try:
TestHelper.printSystemInfo("BEGIN")
Expand Down Expand Up @@ -60,9 +60,15 @@
status = cluster.waitForTrxGeneratorsSpinup(nodeId=cluster.getNode(0).nodeId, numGenerators=numTrxGenerators)
assert status is not None and status is not False, "ERROR: Failed to spinup Transaction Generators"

success, transId = cluster.activateInstantFinality(biosFinalizer=False)
success, transId = cluster.activateInstantFinality(biosFinalizer=False, waitForFinalization=False)
assert success, "Activate instant finality failed"

cluster.biosNode.waitForHeadToAdvance()
success, ignoredId = cluster.activateInstantFinality(biosFinalizer=False, waitForFinalization=False)

if not cluster.biosNode.waitForTransFinalization(transId, timeout=21 * 12 * 3):
Utils.Print("ERROR: Failed to validate setfinalizer transaction %s got rolled into a LIB block" % (transId))

assert cluster.biosNode.waitForLibToAdvance(), "Lib should advance after instant finality activated"
assert cluster.biosNode.waitForProducer("defproducera"), "Did not see defproducera"
assert cluster.biosNode.waitForHeadToAdvance(blocksToAdvance=13), "Head did not advance 13 blocks to next producer"
Expand Down
Loading