Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Fix late transactions #4905

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
61 changes: 34 additions & 27 deletions tests/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="ne
return True

Utils.Print("Bootstrap cluster.")
if not Cluster.bootstrap(totalNodes, prodCount, Cluster.__BiosHost, Cluster.__BiosPort, dontKill, onlyBios):
self.biosNode=Cluster.bootstrap(totalNodes, prodCount, Cluster.__BiosHost, Cluster.__BiosPort, dontKill, onlyBios)
if self.biosNode is None:
Utils.Print("ERROR: Bootstrap failed.")
return False

Expand Down Expand Up @@ -691,21 +692,21 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
biosNode=Node(biosHost, biosPort)
if not biosNode.checkPulse():
Utils.Print("ERROR: Bios node doesn't appear to be running...")
return False
return None

producerKeys=Cluster.parseClusterKeys(totalNodes)
# should have totalNodes node plus bios node
if producerKeys is None or len(producerKeys) < (totalNodes+1):
Utils.Print("ERROR: Failed to parse private keys from cluster config files.")
return False
return None

walletMgr=WalletMgr(True)
walletMgr.killall()
walletMgr.cleanup()

if not walletMgr.launch():
Utils.Print("ERROR: Failed to launch bootstrap wallet.")
return False
return None
biosNode.setWalletEndpointArgs(walletMgr.walletEndpointArgs)

try:
Expand All @@ -721,7 +722,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio

if not walletMgr.importKey(eosioAccount, ignWallet):
Utils.Print("ERROR: Failed to import %s account keys into ignition wallet." % (eosioName))
return False
return None

contract="eosio.bios"
contractDir="contracts/%s" % (contract)
Expand All @@ -731,7 +732,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.publishContract(eosioAccount.name, contractDir, wastFile, abiFile, waitForTransBlock=True)
if trans is None:
Utils.Print("ERROR: Failed to publish contract %s." % (contract))
return False
return None

Node.validateTransaction(trans)

Expand All @@ -748,14 +749,14 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.createAccount(initx, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (name))
return False
return None
Node.validateTransaction(trans)
accounts.append(initx)

transId=Node.getTransId(trans)
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
return None

Utils.Print("Validating system accounts within bootstrap")
biosNode.validateAccounts(accounts)
Expand All @@ -772,7 +773,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
myTrans=biosNode.pushMessage("eosio", "setprods", setProdsStr, opts)
if myTrans is None or not myTrans[0]:
Utils.Print("ERROR: Failed to set producers.")
return False
return None
else:
counts=dict.fromkeys(range(totalNodes), 0) #initialize node prods count to 0
setProdsStr='{"schedule": ['
Expand All @@ -798,54 +799,54 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.pushMessage("eosio", "setprods", setProdsStr, opts)
if trans is None or not trans[0]:
Utils.Print("ERROR: Failed to set producer %s." % (keys["name"]))
return False
return None

trans=trans[1]
transId=Node.getTransId(trans)
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
return None

# wait for block production handover (essentially a block produced by anyone but eosio).
lam = lambda: biosNode.getInfo(exitOnError=True)["head_block_producer"] != "eosio"
ret=Utils.waitForBool(lam)
if not ret:
Utils.Print("ERROR: Block production handover failed.")
return False
return None

eosioTokenAccount=copy.deepcopy(eosioAccount)
eosioTokenAccount.name="eosio.token"
trans=biosNode.createAccount(eosioTokenAccount, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (eosioTokenAccount.name))
return False
return None

eosioRamAccount=copy.deepcopy(eosioAccount)
eosioRamAccount.name="eosio.ram"
trans=biosNode.createAccount(eosioRamAccount, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (eosioRamAccount.name))
return False
return None

eosioRamfeeAccount=copy.deepcopy(eosioAccount)
eosioRamfeeAccount.name="eosio.ramfee"
trans=biosNode.createAccount(eosioRamfeeAccount, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (eosioRamfeeAccount.name))
return False
return None

eosioStakeAccount=copy.deepcopy(eosioAccount)
eosioStakeAccount.name="eosio.stake"
trans=biosNode.createAccount(eosioStakeAccount, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (eosioStakeAccount.name))
return False
return None

Node.validateTransaction(trans)
transId=Node.getTransId(trans)
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
return None

contract="eosio.token"
contractDir="contracts/%s" % (contract)
Expand All @@ -855,7 +856,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.publishContract(eosioTokenAccount.name, contractDir, wastFile, abiFile, waitForTransBlock=True)
if trans is None:
Utils.Print("ERROR: Failed to publish contract %s." % (contract))
return False
return None

# Create currency0000, followed by issue currency0000
contract=eosioTokenAccount.name
Expand All @@ -866,13 +867,13 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
Utils.Print("ERROR: Failed to push create action to eosio contract.")
return False
return None

Node.validateTransaction(trans[1])
transId=Node.getTransId(trans[1])
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
return None

contract=eosioTokenAccount.name
Utils.Print("push issue action to %s contract" % (contract))
Expand All @@ -882,7 +883,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
Utils.Print("ERROR: Failed to push issue action to eosio contract.")
return False
return None

Node.validateTransaction(trans[1])
Utils.Print("Wait for issue action transaction to become finalized.")
Expand All @@ -892,15 +893,15 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
timeout = .5 * 12 * 2 * len(producerKeys) + 60
if not biosNode.waitForTransFinalization(transId, timeout=timeout):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a finalized block on server port %d." % (transId, biosNode.port))
return False
return None

expectedAmount="1000000000.0000 {0}".format(CORE_SYMBOL)
Utils.Print("Verify eosio issue, Expected: %s" % (expectedAmount))
actualAmount=biosNode.getAccountEosBalanceStr(eosioAccount.name)
if expectedAmount != actualAmount:
Utils.Print("ERROR: Issue verification failed. Excepted %s, actual: %s" %
(expectedAmount, actualAmount))
return False
return None

contract="eosio.system"
contractDir="contracts/%s" % (contract)
Expand All @@ -910,7 +911,7 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.publishContract(eosioAccount.name, contractDir, wastFile, abiFile, waitForTransBlock=True)
if trans is None:
Utils.Print("ERROR: Failed to publish contract %s." % (contract))
return False
return None

Node.validateTransaction(trans)

Expand All @@ -925,23 +926,23 @@ def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBio
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
Utils.Print("ERROR: Failed to transfer funds from %s to %s." % (eosioTokenAccount.name, name))
return False
return None

Node.validateTransaction(trans[1])

Utils.Print("Wait for last transfer transaction to become finalized.")
transId=Node.getTransId(trans[1])
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
return None

Utils.Print("Cluster bootstrap done.")
finally:
if not dontKill:
walletMgr.killall()
walletMgr.cleanup()

return True
return biosNode


# Populates list of EosInstanceInfo objects, matched to actual running instances
Expand Down Expand Up @@ -1115,3 +1116,9 @@ def createAccounts(self, creator, waitForTransBlock=True, stakedDeposit=1000):

return True

def reportStatus(self):
if hasattr(self, "biosNode") and self.biosNode is not None:
self.biosNode.reportStatus()
if hasattr(self, "nodes"):
for node in self.nodes:
node.reportStatus()
Loading