Skip to content

Commit

Permalink
GH-1837 Add test to verify only one start block per block unless inte…
Browse files Browse the repository at this point in the history
…rrupted
  • Loading branch information
heifner committed Oct 31, 2023
1 parent 2bc2081 commit 4fb6c11
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
}

void restart_speculative_block() {
fc_dlog(_log, "Restarting exhausted speculative block #${n}", ("n", chain_plug->chain().head_block_num() + 1));
// abort the pending block
abort_block();

schedule_production_loop();
}

Expand Down
29 changes: 29 additions & 0 deletions tests/TestHarness/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,35 @@ def findInLog(self, searchStr):
return True
return False

# verify only one 'Starting block' per block number unless block is restarted
def verifyOnlyOneStartingBlock(self):
dataDir=Utils.getNodeDataDir(self.nodeId)
files=Node.findStderrFiles(dataDir)
for f in files:
blockNumbers = set()
duplicatesFound = False
lastRestartBlockNum = 0

with open(f, 'r') as file:
for line in file:
match = re.match(r".*Restarting exhausted speculative block #(\d+)", line)
if match:
lastRestartBlockNum = match.group(1)
if re.match(r".*unlinkable_block_exception", line):
lastRestartBlockNum = blockNumber
match = re.match(r".*Starting block #(\d+)", line)
if match:
blockNumber = match.group(1)
if blockNumber != lastRestartBlockNum and blockNumber in blockNumbers:
print(f"Duplicate Staring block found: {blockNumber} in {f}")
duplicatesFound = True
blockNumbers.add(blockNumber)

if duplicatesFound:
return False

return True

def analyzeProduction(self, specificBlockNum=None, thresholdMs=500):
dataDir=Utils.getNodeDataDir(self.nodeId)
files=Node.findStderrFiles(dataDir)
Expand Down
5 changes: 5 additions & 0 deletions tests/distributed-transactions-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@

cluster.compareBlockLogs()

# verify only one start block per block unless interrupted
for node in cluster.getAllNodes():
if not node.verifyOnlyOneStartingBlock():
errorExit("Found more than one Starting block in logs")

testSuccessful=True
finally:
TestHelper.shutdown(cluster, walletMgr, testSuccessful, dumpErrorDetails)
Expand Down

0 comments on commit 4fb6c11

Please sign in to comment.