Example #1
0
    def create(self, name, accounts=None, exitOnError=True):
        wallet=self.wallets.get(name)
        if wallet is not None:
            if Utils.Debug: Utils.Print("Wallet \"%s\" already exists. Returning same." % name)
            return wallet
        p = re.compile(r'\n\"(\w+)\"\n', re.MULTILINE)
        cmd="%s %s wallet create --name %s --to-console" % (Utils.ETAClientPath, self.endpointArgs, name)
        if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
        retStr=Utils.checkOutput(cmd.split())
        #Utils.Print("create: %s" % (retStr))
        m=p.search(retStr)
        if m is None:
            if exitOnError:
                Utils.cmdError("could not create wallet %s" % (name))
                errorExit("Failed  to create wallet %s" % (name))

            Utils.Print("ERROR: wallet password parser failure")
            return None
        p=m.group(1)
        wallet=Wallet(name, p, self.host, self.port)
        self.wallets[name] = wallet

        if accounts:
            self.importKeys(accounts,wallet)

        return wallet
def verifyProductionRounds(trans, node, prodsActive, rounds):
    temp = Utils.Debug
    Utils.Debug = False

    prods = []
    for k,v in prodsActive.items():
        if v:
            prods.append(k)
    maxBlocks = (schedulePeriodFactor + 1) * totalProducers * 2 + ((totalProducers*2//3)+1)*2
    blockNum, synced = node.waitActiveSchedule(prods, maxBlocks)
    if not synced:
        blockNum = syncWithShuffle(node, blockNum)

    Utils.Print("Verify %s complete rounds of all producers producing" % (rounds))
    for i in range(0, rounds):
        prodsSeen = {}
        reserveMax = reserve_producers
        for j in range(0, totalProducers):
            reserveMax = validBlockProducer(prodsActive, prodsSeen, blockNum, node, reserveMax)
            blockNum += 1

        # make sure that we have seen all `top_producers` producers
        prodsSeenKeys=prodsSeen.keys()
        if len(prodsSeenKeys)!=top_producers:
            Utils.cmdError("only saw %s producers of expected %i. At blockNum %s only the following producers were seen: %s" % (
                len(prodsSeenKeys), top_producers, blockNum, ",".join(prodsSeenKeys)))
            Utils.errorExit("Failed because of missing block producers")

    Utils.Debug = temp
Example #3
0
def vote(node, account, producers):
    Print("Votes for %s" % (account.name))
    trans=node.vote(account, producers, waitForTransBlock=False)
    if trans is None:
        Utils.cmdError("voting with %s" % (account.name))
        errorExit("Failed to vote with account %s" % (account.name))
    return trans
Example #4
0
def vote(node, account, producers):
    Print("Votes for %s" % (account.name))
    trans = node.vote(account, producers, waitForTransBlock=False)
    if trans is None:
        Utils.cmdError("voting with %s" % (account.name))
        errorExit("Failed to vote with account %s" % (account.name))
    return trans
Example #5
0
 def getNode(self, nodeId=0, exitOnError=True):
     if exitOnError and nodeId >= len(self.nodes):
         Utils.cmdError("cluster never created node %d" % (nodeId))
         errorExit("Failed to retrieve node %d" % (nodeId))
     if exitOnError and self.nodes[nodeId] is None:
         Utils.cmdError("cluster has None value for node %d" % (nodeId))
         errorExit("Failed to retrieve node %d" % (nodeId))
     return self.nodes[nodeId]
Example #6
0
def getBlockProducer(node, blockNum):
    node.waitForBlock(blockNum)
    block=node.getBlock(blockNum, exitOnError=True)
    blockProducer=block["producer"]
    if blockProducer is None:
        Utils.cmdError("could not get producer for block number %s" % (blockNum))
        errorExit("Failed to get block's producer")
    return blockProducer
Example #7
0
def validBlockProducer(prodsActive, prodsSeen, blockNum, node):
    blockProducer=getBlockProducer(node, blockNum)
    if blockProducer not in prodsActive:
        Utils.cmdError("unexpected block producer %s at blockNum=%s" % (blockProducer,blockNum))
        errorExit("Failed because of invalid block producer")
    if not prodsActive[blockProducer]:
        Utils.cmdError("block producer %s for blockNum=%s not elected, belongs to node %s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
        errorExit("Failed because of incorrect block producer")
    prodsSeen[blockProducer]=True
Example #8
0
def validBlockProducer(prodsActive, prodsSeen, blockNum, node):
    blockProducer=getBlockProducer(node, blockNum)
    if blockProducer not in prodsActive:
        Utils.cmdError("unexpected block producer %s at blockNum=%s" % (blockProducer,blockNum))
        errorExit("Failed because of invalid block producer")
    if not prodsActive[blockProducer]:
        Utils.cmdError("block producer %s for blockNum=%s not elected, belongs to node %s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
        errorExit("Failed because of incorrect block producer")
    prodsSeen[blockProducer]=True
Example #9
0
    def create(self, name, accounts=None, exitOnError=True):
        wallet=self.wallets.get(name)
        if wallet is not None:
            if Utils.Debug: Utils.Print("Wallet \"%s\" already exists. Returning same." % name)
            return wallet
        p = re.compile(r'\n\"(\w+)\"\n', re.MULTILINE)
        cmdDesc="wallet create"
        cmd="%s %s %s --name %s --to-console" % (Utils.GstClientPath, self.getArgs(), cmdDesc, name)
        if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
        retStr=None
        maxRetryCount=4
        retryCount=0
        while True:
            try:
                retStr=Utils.checkOutput(cmd.split())
                break
            except subprocess.CalledProcessError as ex:
                retryCount+=1
                if retryCount<maxRetryCount:
                    delay=10
                    pgrepCmd=Utils.pgrepCmd(Utils.GstWalletName)
                    psOut=Utils.checkOutput(pgrepCmd.split())
                    portStatus="N/A"
                    if self.isLocal():
                        if Utils.arePortsAvailable(self.port):
                            portStatus="AVAILABLE"
                        else:
                            portStatus="NOT AVAILABLE"
                    if Utils.Debug: Utils.Print("%s was not accepted, delaying for %d seconds and trying again. port %d is %s. %s - {%s}" % (cmdDesc, delay, self.port, pgrepCmd, psOut))
                    time.sleep(delay)
                    continue

                msg=ex.output.decode("utf-8")
                errorMsg="ERROR: Failed to create wallet - %s. %s" % (name, msg)
                if exitOnError:
                    Utils.errorExit("%s" % (errorMsg))
                Utils.Print("%s" % (errorMsg))
                return None

        m=p.search(retStr)
        if m is None:
            if exitOnError:
                Utils.cmdError("could not create wallet %s" % (name))
                Utils.errorExit("Failed  to create wallet %s" % (name))

            Utils.Print("ERROR: wallet password parser failure")
            return None
        p=m.group(1)
        wallet=Wallet(name, p, self.host, self.port)
        self.wallets[name] = wallet

        if accounts:
            self.importKeys(accounts,wallet)

        return wallet
Example #10
0
def getBlockProducer(node, blockNum):
    node.waitForBlock(blockNum)
    block=node.getBlock(blockNum)
    if block is None:
        Utils.cmdError("could not get block number %s" % (blockNum))
        errorExit("Failed to get block")
    blockProducer=block["producer"]
    if blockProducer is None:
        Utils.cmdError("could not get producer for block number %s" % (blockNum))
        errorExit("Failed to get block's producer")
    return blockProducer
Example #11
0
def validBlockProducer(prodsActive, prodsSeen, blockNum, node, reserveMax):
    blockProducer=node.getBlockProducerByNum(blockNum)
    if blockProducer not in prodsActive:
        Utils.cmdError("unexpected block producer %s at blockNum=%s" % (blockProducer,blockNum))
        Utils.errorExit("Failed because of invalid block producer")
    if not prodsActive[blockProducer]:
        reserveMax -= 1
        if reserveMax < 0:
            Utils.cmdError("block producer %s for blockNum=%s not elected, belongs to node %s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
            Utils.errorExit("Failed because of incorrect block producer")
        else:
            Utils.Print("found reserve block producer %s for blockNum=%s; max:%i" % (blockProducer, blockNum, reserveMax))
        return reserveMax
    if blockProducer in prodsSeen:
        Utils.cmdError("block producer %s for blockNum=%s already produced in this round" % (blockProducer, blockNum))
        Utils.errorExit("Failed because of incorrect block producer")
    prodsSeen[blockProducer]=True
    return reserveMax
Example #12
0
CliName = "vectrum-cli"

try:
    TestHelper.printSystemInfo("BEGIN")
    cluster.setWalletMgr(walletMgr)

    cluster.killall(allInstances=killAll)
    cluster.cleanup()
    Print("Stand up cluster")
    if cluster.launch(prodCount=prodCount,
                      onlyBios=False,
                      pnodes=totalNodes,
                      totalNodes=totalNodes,
                      totalProducers=totalNodes * 21,
                      useBiosBootFile=False) is False:
        Utils.cmdError("launcher")
        Utils.errorExit("Failed to stand up VECTRUM cluster.")

    Print("Validating system accounts after bootstrap")
    cluster.validateAccounts(None)

    accounts = cluster.createAccountKeys(5)
    if accounts is None:
        Utils.errorExit("FAILURE - create keys")
    accounts[0].name = "tester111111"
    accounts[1].name = "tester222222"
    accounts[2].name = "tester333333"
    accounts[3].name = "tester444444"
    accounts[4].name = "tester555555"

    testWalletName = "test"
Example #13
0
WalletdName="kETAd"
ClientName="clETA"

try:
    TestHelper.printSystemInfo("BEGIN")

    cluster.killall(allInstances=killAll)
    cluster.cleanup()
    Print("Stand up cluster")
    minRAMFlag="--chain-state-db-guard-size-mb"
    minRAMValue=1002
    maxRAMFlag="--chain-state-db-size-mb"
    maxRAMValue=1010
    extraNodETAArgs=" %s %d %s %d " % (minRAMFlag, minRAMValue, maxRAMFlag, maxRAMValue)
    if cluster.launch(onlyBios=False, dontKill=dontKill, pnodes=totalNodes, totalNodes=totalNodes, totalProducers=totalNodes, extraNodETAArgs=extraNodETAArgs) is False:
        Utils.cmdError("launcher")
        errorExit("Failed to stand up ETA cluster.")

    Print("Validating system accounts after bootstrap")
    cluster.validateAccounts(None)

    Print("creating accounts")
    namedAccounts=NamedAccounts(cluster,10)
    accounts=namedAccounts.accounts

    testWalletName="test"

    Print("Creating wallet \"%s\"." % (testWalletName))
    walletMgr.killall(allInstances=killAll)
    walletMgr.cleanup()
    if walletMgr.launch() is False:
Example #14
0
WalletdName = "enuwallet"
ClientName = "enucli"

try:
    TestHelper.printSystemInfo("BEGIN")

    cluster.killall(allInstances=killAll)
    cluster.cleanup()
    Print("Stand up cluster")
    if cluster.launch(prodCount=prodCount,
                      onlyBios=False,
                      dontKill=dontKill,
                      pnodes=totalNodes,
                      totalNodes=totalNodes,
                      totalProducers=totalNodes * 21) is False:
        Utils.cmdError("launcher")
        errorExit("Failed to stand up enu cluster.")

    Print("Validating system accounts after bootstrap")
    cluster.validateAccounts(None)

    accounts = cluster.createAccountKeys(5)
    if accounts is None:
        errorExit("FAILURE - create keys")
    accounts[0].name = "tester111111"
    accounts[1].name = "tester222222"
    accounts[2].name = "tester333333"
    accounts[3].name = "tester444444"
    accounts[4].name = "tester555555"

    testWalletName = "test"
Example #15
0
def verifyProductionRounds(trans, node, prodsActive, rounds):
    blockNum=getNextCleanProductionCycle(trans, node)
    Utils.Print("Validating blockNum=%s" % (blockNum))

    temp=Utils.Debug
    Utils.Debug=False
    Utils.Print("FIND VALID BLOCK PRODUCER")
    blockProducer=getBlockProducer(node, blockNum)
    lastBlockProducer=blockProducer
    adjust=False
    while not isValidBlockProducer(prodsActive, blockNum, node):
        adjust=True
        blockProducer=getBlockProducer(node, blockNum)
        if lastBlockProducer!=blockProducer:
            Utils.Print("blockProducer=%s for blockNum=%s is for node=%s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
        lastBlockProducer=blockProducer
        blockNum+=1

    Utils.Print("VALID BLOCK PRODUCER")
    saw=0
    sawHigh=0
    startingFrom=blockNum
    doPrint=0
    invalidCount=0
    while adjust:
        invalidCount+=1
        if lastBlockProducer==blockProducer:
            saw+=1;
        else:
            if saw>=12:
                startingFrom=blockNum
                if saw>12:
                    Utils.Print("ERROR!!!!!!!!!!!!!!      saw=%s, blockProducer=%s, blockNum=%s" % (saw,blockProducer,blockNum))
                break
            else:
                if saw > sawHigh:
                    sawHigh = saw
                    Utils.Print("sawHigh=%s" % (sawHigh))
                if doPrint < 5:
                    doPrint+=1
                    Utils.Print("saw=%s, blockProducer=%s, blockNum=%s" % (saw,blockProducer,blockNum))
                lastBlockProducer=blockProducer
                saw=1
        blockProducer=getBlockProducer(node, blockNum)
        blockNum+=1

    if adjust:
        blockNum-=1

    Utils.Print("ADJUSTED %s blocks" % (invalidCount-1))

    prodsSeen=None
    Utils.Print("Verify %s complete rounds of all producers producing" % (rounds))
    for i in range(0, rounds):
        prodsSeen={}
        lastBlockProducer=None
        for j in range(0, 21):
            # each new set of 12 blocks should have a different blockProducer 
            if lastBlockProducer is not None and lastBlockProducer==getBlockProducer(node, blockNum):
                Utils.cmdError("expected blockNum %s to be produced by any of the valid producers except %s" % (blockNum, lastBlockProducer))
                errorExit("Failed because of incorrect block producer order")

            # make sure that the next set of 12 blocks all have the same blockProducer
            lastBlockProducer=getBlockProducer(node, blockNum)
            for k in range(0, 12):
                validBlockProducer(prodsActive, prodsSeen, blockNum, node1)
                blockProducer=getBlockProducer(node, blockNum)
                if lastBlockProducer!=blockProducer:
                    printStr=""
                    newBlockNum=blockNum-18
                    for l in range(0,36):
                        printStr+="%s" % (newBlockNum)
                        printStr+=":"
                        newBlockProducer=getBlockProducer(node, newBlockNum)
                        printStr+="%s" % (newBlockProducer)
                        printStr+="  "
                        newBlockNum+=1
                    Utils.cmdError("expected blockNum %s (started from %s) to be produced by %s, but produded by %s: round=%s, prod slot=%s, prod num=%s - %s" % (blockNum, startingFrom, lastBlockProducer, blockProducer, i, j, k, printStr))
                    errorExit("Failed because of incorrect block producer order")
                blockNum+=1

    # make sure that we have seen all 21 producers
    prodsSeenKeys=prodsSeen.keys()
    if len(prodsSeenKeys)!=21:
        Utils.cmdError("only saw %s producers of expected 21. At blockNum %s only the following producers were seen: %s" % (len(prodsSeenKeys), blockNum, ",".join(prodsSeenKeys)))
        errorExit("Failed because of missing block producers")

    Utils.Debug=temp
Example #16
0
try:
    TestHelper.printSystemInfo("BEGIN")

    cluster.killall(allInstances=killAll)
    cluster.cleanup()
    Print("Stand up cluster")
    if cluster.launch(prodCount=prodCount,
                      onlyBios=False,
                      dontKill=dontKill,
                      pnodes=totalNodes,
                      totalNodes=totalNodes,
                      totalProducers=totalNodes * 21,
                      p2pPlugin=p2pPlugin,
                      useBiosBootFile=False) is False:
        Utils.cmdError("launcher")
        Utils.errorExit("Failed to stand up enu cluster.")

    Print("Validating system accounts after bootstrap")
    cluster.validateAccounts(None)

    accounts = cluster.createAccountKeys(5)
    if accounts is None:
        Utils.errorExit("FAILURE - create keys")
    accounts[0].name = "tester111111"
    accounts[1].name = "tester222222"
    accounts[2].name = "tester333333"
    accounts[3].name = "tester444444"
    accounts[4].name = "tester555555"

    testWalletName = "test"
Example #17
0
def verifyProductionRounds(trans, node, prodsActive, rounds):
    blockNum = node.getNextCleanProductionCycle(trans)
    Utils.Print("Validating blockNum=%s" % (blockNum))

    temp = Utils.Debug
    Utils.Debug = False
    Utils.Print("FIND VALID BLOCK PRODUCER")
    blockProducer = node.getBlockProducerByNum(blockNum)
    lastBlockProducer = blockProducer
    adjust = False
    while not isValidBlockProducer(prodsActive, blockNum, node):
        adjust = True
        blockProducer = node.getBlockProducerByNum(blockNum)
        if lastBlockProducer != blockProducer:
            Utils.Print(
                "blockProducer=%s for blockNum=%s is for node=%s" %
                (blockProducer, blockNum, ProducerToNode.map[blockProducer]))
        lastBlockProducer = blockProducer
        blockNum += 1

    Utils.Print("VALID BLOCK PRODUCER")
    saw = 0
    sawHigh = 0
    startingFrom = blockNum
    doPrint = 0
    invalidCount = 0
    while adjust:
        invalidCount += 1
        if lastBlockProducer == blockProducer:
            saw += 1
        else:
            if saw >= 12:
                startingFrom = blockNum
                if saw > 12:
                    Utils.Print(
                        "ERROR!!!!!!!!!!!!!!      saw=%s, blockProducer=%s, blockNum=%s"
                        % (saw, blockProducer, blockNum))
                break
            else:
                if saw > sawHigh:
                    sawHigh = saw
                    Utils.Print("sawHigh=%s" % (sawHigh))
                if doPrint < 5:
                    doPrint += 1
                    Utils.Print("saw=%s, blockProducer=%s, blockNum=%s" %
                                (saw, blockProducer, blockNum))
                lastBlockProducer = blockProducer
                saw = 1
        blockProducer = node.getBlockProducerByNum(blockNum)
        blockNum += 1

    if adjust:
        blockNum -= 1

    Utils.Print("ADJUSTED %s blocks" % (invalidCount - 1))

    prodsSeen = None
    Utils.Print("Verify %s complete rounds of all producers producing" %
                (rounds))
    for i in range(0, rounds):
        prodsSeen = {}
        lastBlockProducer = None
        for j in range(0, 21):
            # each new set of 12 blocks should have a different blockProducer
            if lastBlockProducer is not None and lastBlockProducer == node.getBlockProducerByNum(
                    blockNum):
                Utils.cmdError(
                    "expected blockNum %s to be produced by any of the valid producers except %s"
                    % (blockNum, lastBlockProducer))
                Utils.errorExit(
                    "Failed because of incorrect block producer order")

            # make sure that the next set of 12 blocks all have the same blockProducer
            lastBlockProducer = node.getBlockProducerByNum(blockNum)
            for k in range(0, 12):
                validBlockProducer(prodsActive, prodsSeen, blockNum, node1)
                blockProducer = node.getBlockProducerByNum(blockNum)
                if lastBlockProducer != blockProducer:
                    printStr = ""
                    newBlockNum = blockNum - 18
                    for l in range(0, 36):
                        printStr += "%s" % (newBlockNum)
                        printStr += ":"
                        newBlockProducer = node.getBlockProducerByNum(
                            newBlockNum)
                        printStr += "%s" % (newBlockProducer)
                        printStr += "  "
                        newBlockNum += 1
                    Utils.cmdError(
                        "expected blockNum %s (started from %s) to be produced by %s, but produded by %s: round=%s, prod slot=%s, prod num=%s - %s"
                        % (blockNum, startingFrom, lastBlockProducer,
                           blockProducer, i, j, k, printStr))
                    Utils.errorExit(
                        "Failed because of incorrect block producer order")
                blockNum += 1

    # make sure that we have seen all 21 producers
    prodsSeenKeys = prodsSeen.keys()
    if len(prodsSeenKeys) != 21:
        Utils.cmdError(
            "only saw %s producers of expected 21. At blockNum %s only the following producers were seen: %s"
            % (len(prodsSeenKeys), blockNum, ",".join(prodsSeenKeys)))
        Utils.errorExit("Failed because of missing block producers")

    Utils.Debug = temp
Example #18
0
walletMgr=WalletMgr(True)
testSuccessful=False
killEosInstances=not dontKill
killWallet=not dontKill

WalletdName="keosd"
ClientName="cleos"

try:
    TestHelper.printSystemInfo("BEGIN")

    cluster.killall(allInstances=killAll)
    cluster.cleanup()
    Print("Stand up cluster")
    if cluster.launch(prodCount=prodCount, onlyBios=False, dontKill=dontKill, pnodes=totalNodes, totalNodes=totalNodes, totalProducers=totalNodes*21) is False:
        Utils.cmdError("launcher")
        errorExit("Failed to stand up eos cluster.")

    Print("Validating system accounts after bootstrap")
    cluster.validateAccounts(None)

    accounts=cluster.createAccountKeys(5)
    if accounts is None:
        errorExit("FAILURE - create keys")
    accounts[0].name="tester111111"
    accounts[1].name="tester222222"
    accounts[2].name="tester333333"
    accounts[3].name="tester444444"
    accounts[4].name="tester555555"

    testWalletName="test"