From 6f4ceb19dc94bd6ee0f35539929e1ec208f05690 Mon Sep 17 00:00:00 2001 From: kayan Date: Tue, 25 Jun 2024 16:17:17 +0800 Subject: [PATCH 1/8] fix estimate gas --- external/silkworm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/silkworm b/external/silkworm index 07f76fa..1897fc5 160000 --- a/external/silkworm +++ b/external/silkworm @@ -1 +1 @@ -Subproject commit 07f76fa242ce30bd9e893197ca22b197cad6371d +Subproject commit 1897fc5e99ecfafa2b56fc3e9640b7a69a32da03 From 0dac1cf1c93fcae2a646fa4cf15a916d8b65d5d8 Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 15:00:39 +0800 Subject: [PATCH 2/8] fix web socket integration test --- tests/nodeos_eos_evm_ws_test_basic.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index 103f161..6a51dea 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -105,7 +105,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(signed_trx.raw_transaction)[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"]) @@ -359,7 +359,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(signed_trx.raw_transaction)[2:]} trans = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name)) prodNode.waitForTransBlockIfNeeded(trans[1], True) @@ -385,7 +385,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(signed_trx.raw_transaction)[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) assert retValue[0], f"push trx should have succeeded: {retValue}" @@ -404,7 +404,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(signed_trx.raw_transaction)[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) assert not retValue[0], f"push trx should have failed: {retValue}" @@ -437,7 +437,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(signed_trx.raw_transaction)[2:]} retValue = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=True) assert retValue[0], f"push trx should have succeeded: {retValue}" contract_addr = makeContractAddress(fromAdd, nonce) @@ -560,7 +560,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(signed_trx.raw_transaction)[2:]} trans = prodNode.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p {0}'.format(minerAcc.name), silentErrors=True) prodNode.waitForTransBlockIfNeeded(trans[1], True) row4=prodNode.getTableRow(evmAcc.name, evmAcc.name, "account", 4) # 4th balance of this integration test From d0a2ae3aefc41f648a68aa26c2a3690d8e11e967 Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 15:57:10 +0800 Subject: [PATCH 3/8] fix web socket test --- tests/nodeos_eos_evm_ws_test_basic.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index 6a51dea..513b3fb 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -208,6 +208,12 @@ def makeReservedEvmAddress(account): c_uint8(account >> 0).value] return "0x" + bytes(bytearr).hex() +def get_raw_transaction(signed_trx): + if hasattr(signed_trx, 'raw_transaction'): + return signed_trx.raw_transaction + else: + return signed_trx.rawTransaction + try: TestHelper.printSystemInfo("BEGIN") @@ -359,7 +365,7 @@ def makeReservedEvmAddress(account): chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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) @@ -385,7 +391,7 @@ def makeReservedEvmAddress(account): chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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) assert retValue[0], f"push trx should have succeeded: {retValue}" @@ -404,7 +410,7 @@ def makeReservedEvmAddress(account): chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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) assert not retValue[0], f"push trx should have failed: {retValue}" @@ -437,7 +443,7 @@ def makeReservedEvmAddress(account): chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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) assert retValue[0], f"push trx should have succeeded: {retValue}" contract_addr = makeContractAddress(fromAdd, nonce) @@ -560,7 +566,7 @@ def makeReservedEvmAddress(account): data=b'', chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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=True) prodNode.waitForTransBlockIfNeeded(trans[1], True) row4=prodNode.getTableRow(evmAcc.name, evmAcc.name, "account", 4) # 4th balance of this integration test From 1a74dece4c8b1d8178b04cc0f3d6c9bacb38b65f Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 16:43:23 +0800 Subject: [PATCH 4/8] output exception --- tests/nodeos_eos_evm_ws_test_basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index 513b3fb..8417fa0 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -780,6 +780,8 @@ def get_raw_transaction(signed_trx): ws.close() testSuccessful= not foundErr +except Exception as ex: + Utils.Print("Exception:" + str(ex)) finally: TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, dumpErrorDetails=dumpErrorDetails) if killEosInstances: From 439cbbe838a52e377a058139320f6618b90df626 Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 17:44:35 +0800 Subject: [PATCH 5/8] fix web socket test --- tests/nodeos_eos_evm_ws_test_basic.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index 8417fa0..bf3b2a8 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -89,6 +89,12 @@ eosEvmMinerPOpen = None wsproxy = None +def get_raw_transaction(signed_trx): + if hasattr(signed_trx, 'raw_transaction'): + return signed_trx.raw_transaction + else: + return signed_trx.rawTransaction + def interact_with_storage_contract(dest, nonce): for i in range(1, 5): # execute a few Utils.Print("Execute ETH contract") @@ -105,7 +111,7 @@ def interact_with_storage_contract(dest, nonce): chainId=evmChainId ), evmSendKey) - actData = {"miner":minerAcc.name, "rlptx":Web3.to_hex(signed_trx.raw_transaction)[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"]) @@ -208,12 +214,6 @@ def makeReservedEvmAddress(account): c_uint8(account >> 0).value] return "0x" + bytes(bytearr).hex() -def get_raw_transaction(signed_trx): - if hasattr(signed_trx, 'raw_transaction'): - return signed_trx.raw_transaction - else: - return signed_trx.rawTransaction - try: TestHelper.printSystemInfo("BEGIN") From 03e1120b11755c5f24ea119e93bb3322b768188d Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 18:29:48 +0800 Subject: [PATCH 6/8] fix web socket test --- tests/nodeos_eos_evm_ws_test_basic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index bf3b2a8..f6b083d 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -649,9 +649,10 @@ def makeReservedEvmAddress(account): for line in lines: Utils.Print("wsStdOutlog:", line) - time.sleep(3.0) + time.sleep(10.0) ws = websocket.WebSocket() + Utils.Print("start to connect ws://127.0.0.1:3333") ws.connect("ws://127.0.0.1:3333", origin="nodeos_eos_evm_test.py") ws.send("{\"method\":\"eth_blockNumber\",\"params\":[\"0x1\",false],\"id\":123}") Utils.Print("send eth_blockNumber to websocket proxy") From 49328ed4b3a868bbc40407c5c0e72770fb3cf074 Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 19:08:07 +0800 Subject: [PATCH 7/8] fix web socket test --- tests/nodeos_eos_evm_ws_test_basic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/nodeos_eos_evm_ws_test_basic.py b/tests/nodeos_eos_evm_ws_test_basic.py index f6b083d..ab267b7 100755 --- a/tests/nodeos_eos_evm_ws_test_basic.py +++ b/tests/nodeos_eos_evm_ws_test_basic.py @@ -649,11 +649,11 @@ def makeReservedEvmAddress(account): for line in lines: Utils.Print("wsStdOutlog:", line) - time.sleep(10.0) + time.sleep(5.0) ws = websocket.WebSocket() - Utils.Print("start to connect ws://127.0.0.1:3333") - ws.connect("ws://127.0.0.1:3333", origin="nodeos_eos_evm_test.py") + Utils.Print("start to connect ws://localhost:3333") + ws.connect("ws://localhost:3333") ws.send("{\"method\":\"eth_blockNumber\",\"params\":[\"0x1\",false],\"id\":123}") Utils.Print("send eth_blockNumber to websocket proxy") From 3e7272425525c608538a5a9cf4a77a2861d41216 Mon Sep 17 00:00:00 2001 From: kayan Date: Wed, 26 Jun 2024 19:53:10 +0800 Subject: [PATCH 8/8] fix web socket fork test --- tests/nodeos_eos_evm_ws_test_fork.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/nodeos_eos_evm_ws_test_fork.py b/tests/nodeos_eos_evm_ws_test_fork.py index 3c74175..633c1c0 100755 --- a/tests/nodeos_eos_evm_ws_test_fork.py +++ b/tests/nodeos_eos_evm_ws_test_fork.py @@ -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 @@ -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"]) @@ -483,7 +489,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) @@ -509,7 +515,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) @@ -529,7 +535,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) @@ -562,7 +568,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}" @@ -690,7 +696,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=True) time.sleep(1.0) prodNode.waitForTransBlockIfNeeded(trans[1], True) @@ -776,10 +782,11 @@ def makeReservedEvmAddress(account): for line in lines: Utils.Print("wsStdOutlog:", line) - time.sleep(3.0) + time.sleep(5.0) ws = websocket.WebSocket() - ws.connect("ws://127.0.0.1:3333", origin="nodeos_eos_evm_test.py") + Utils.Print("start to connect ws://localhost:3333") + ws.connect("ws://localhost:3333") ws.send("{\"method\":\"eth_blockNumber\",\"params\":[\"0x1\",false],\"id\":123}") Utils.Print("send eth_blockNumber to websocket proxy") @@ -1080,6 +1087,8 @@ def makeReservedEvmAddress(account): ws.close() testSuccessful= not foundErr +except Exception as ex: + Utils.Print("Exception:" + str(ex)) finally: TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, dumpErrorDetails=dumpErrorDetails) if killEosInstances: