Skip to content

Commit

Permalink
Merge pull request #286 from eosnetworkfoundation/kayan_1.0_to_main_t…
Browse files Browse the repository at this point in the history
…est_savanna

[1.0->main] Kayan 1.0 to main test savanna
  • Loading branch information
taokayan committed Aug 30, 2024
2 parents 18ccfdb + 7ede656 commit bea6629
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
26 changes: 16 additions & 10 deletions tests/nodeos_eos_evm_gasparam_fork_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
Print=Utils.Print
errorExit=Utils.errorExit

def get_raw_transaction(signed_trx):
if hasattr(signed_trx, 'raw_transaction'):
return signed_trx.raw_transaction
else:
return signed_trx.rawTransaction

def analyzeBPs(bps0, bps1, expectDivergence):
start=0
index=None
Expand Down Expand Up @@ -198,7 +204,7 @@ def interact_with_storage_contract(dest, nonce):
chainId=evmChainId
), evmSendKey)

actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
retValue = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name))
assert retValue[0], "pushtx to ETH contract failed."
Utils.Print("\tBlock#", retValue[1]["processed"]["block_num"])
Expand Down Expand Up @@ -486,7 +492,7 @@ def makeReservedEvmAddress(account):
chainId=evmChainId
), evmSendKey)

actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
trans = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name))
prodNode.waitForTransBlockIfNeeded(trans[1], True)

Expand All @@ -512,7 +518,7 @@ def makeReservedEvmAddress(account):
chainId=evmChainId
), evmSendKey)

actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
Utils.Print("Send balance again, with correct nonce")
retValue = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=True)
time.sleep(1.0)
Expand All @@ -532,7 +538,7 @@ def makeReservedEvmAddress(account):
chainId=evmChainId
), evmSendKey)

actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
Utils.Print("Send balance again, with invalid chainid")
retValue = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=True)
time.sleep(1.0)
Expand Down Expand Up @@ -565,7 +571,7 @@ def makeReservedEvmAddress(account):
data=Web3.to_bytes(hexstr='608060405234801561001057600080fd5b506101b6806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b604051610050919061013f565b60405180910390f35b610073600480360381019061006e9190610103565b61007e565b005b60008054905090565b806000819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516100e3919061013f565b60405180910390a350565b6000813590506100fd81610169565b92915050565b60006020828403121561011957610118610164565b5b6000610127848285016100ee565b91505092915050565b6101398161015a565b82525050565b60006020820190506101546000830184610130565b92915050565b6000819050919050565b600080fd5b6101728161015a565b811461017d57600080fd5b5056fea264697066735822122061ba78daf70a6edb2db7cbb1dbac434da1ba14ec0e009d4df8907b8c6ee4d63264736f6c63430008070033'),
chainId=evmChainId
), evmSendKey)
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
retValue = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=True)
time.sleep(1.0)
assert retValue[0], f"push trx should have succeeded: {retValue}"
Expand Down Expand Up @@ -705,7 +711,7 @@ def makeReservedEvmAddress(account):
data=b'',
chainId=evmChainId
), evmSendKey)
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}
trans = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=False)
time.sleep(1.0)
prodNode.waitForTransBlockIfNeeded(trans[1], True)
Expand Down Expand Up @@ -752,7 +758,7 @@ def makeReservedEvmAddress(account):
# Verify header.nonce == 1 (evmversion=1)
evm_block = w3.eth.get_block('latest')
Utils.Print("before fork, the latest evm block is:" + str(evm_block))
assert(evm_block["nonce"].hex() == "0x0000000000000001")
assert(evm_block["nonce"].hex() == "0000000000000001")
assert("consensusParameter" in evm_block)
assert(evm_block["consensusParameter"]["gasFeeParameters"]["gasCodedeposit"] == 477)
assert(evm_block["consensusParameter"]["gasFeeParameters"]["gasNewaccount"] == 165519)
Expand Down Expand Up @@ -911,7 +917,7 @@ def makeReservedEvmAddress(account):
data=b'',
chainId=evmChainId
), evmSendKey)
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.rawTransaction)[2:]}
actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(get_raw_transaction(signed_trx))[2:]}

# push transaction to node0's minor fork (proda, prodb)
trans = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=False)
Expand All @@ -936,7 +942,7 @@ def makeReservedEvmAddress(account):
# verify eos-evm-node get the new gas parameter from the minor fork
evm_block = w3.eth.get_block('latest')
Utils.Print("in minor fork, the latest evm block is:" + str(evm_block))
assert(evm_block["nonce"].hex() == "0x0000000000000001")
assert(evm_block["nonce"].hex() == "0000000000000001")
assert("consensusParameter" in evm_block)

assert(evm_block["consensusParameter"]["gasFeeParameters"]["gasCodedeposit"] == 573)
Expand Down Expand Up @@ -1040,7 +1046,7 @@ def makeReservedEvmAddress(account):

evm_block = w3.eth.get_block('latest')
Utils.Print("after fork resolved, the latest evm block is:" + str(evm_block))
assert(evm_block["nonce"].hex() == "0x0000000000000001")
assert(evm_block["nonce"].hex() == "0000000000000001")
assert("consensusParameter" in evm_block)

assert(evm_block["consensusParameter"]["gasFeeParameters"]["gasCodedeposit"] == 477)
Expand Down
22 changes: 13 additions & 9 deletions tests/nodeos_eos_evm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def toDict(dictToParse):
extraNodeosArgs="--contracts-console --resource-monitor-not-shutdown-on-threshold-exceeded"

Print("Stand up cluster")
if cluster.launch(pnodes=pnodes, totalNodes=total_nodes, extraNodeosArgs=extraNodeosArgs, specificExtraNodeosArgs=specificExtraNodeosArgs,delay=5) is False:
if cluster.launch(pnodes=pnodes, totalNodes=total_nodes, extraNodeosArgs=extraNodeosArgs, specificExtraNodeosArgs=specificExtraNodeosArgs,loadSystemContract=False,activateIF=True,delay=5) is False:
errorExit("Failed to stand up eos cluster.")

Print ("Wait for Cluster stabilization")
Expand All @@ -284,6 +284,10 @@ def toDict(dictToParse):
errorExit("Cluster never stabilized")
Print ("Cluster stabilized")

Utils.Print("make sure instant finality is switched")
info = cluster.biosNode.getInfo(exitOnError=True)
assert (info["head_block_num"] - info["last_irreversible_block_num"]) < 9, "Instant finality enabled LIB diff should be small"

prodNode = cluster.getNode(0)
nonProdNode = cluster.getNode(1)

Expand Down Expand Up @@ -313,16 +317,16 @@ def toDict(dictToParse):
# create accounts via eosio as otherwise a bid is needed
for account in accounts:
Print("Create new account %s via %s" % (account.name, cluster.eosioAccount.name))
trans=nonProdNode.createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=True, stakeNet=10000, stakeCPU=10000, buyRAM=10000000, exitOnError=True)

trans=nonProdNode.createAccount(account, cluster.eosioAccount,0,waitForTransBlock=True)

# max supply 1000000000.0000 (1 Billion)
transferAmount="100000000.0000 {0}".format(CORE_SYMBOL) # 100 Million
transferAmount="60000000.0000 {0}".format(CORE_SYMBOL)
if account.name == evmAcc.name:
transferAmount="58999999.0000 {0}".format(CORE_SYMBOL)

Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, account.name))
nonProdNode.transferFunds(cluster.eosioAccount, account, transferAmount, "test transfer", waitForTransBlock=True)
if account.name == evmAcc.name:
# stake more for evmAcc so it has a smaller balance, during setup of addys below the difference will be transferred in
trans=nonProdNode.delegatebw(account, 20000000.0000 + numAddys*1000000.0000, 20000001.0000, waitForTransBlock=True, exitOnError=True)
else:
trans=nonProdNode.delegatebw(account, 20000000.0000, 20000000.0000, waitForTransBlock=True, exitOnError=True)

contractDir=eosEvmContractRoot + "/evm_runtime"
wasmFile="evm_runtime.wasm"
Expand Down Expand Up @@ -1127,7 +1131,7 @@ def get_block(num):
Utils.Print("test failed, ready to shut down cluster")

finally:
Utils.Print("test success, shutting down cluster")
Utils.Print("shutting down cluster")
TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, dumpErrorDetails=dumpErrorDetails)
if killEosInstances:
Utils.Print("killing EOS instances")
Expand Down

0 comments on commit bea6629

Please sign in to comment.