From d01d974a4e62b968afd73d1ea47e835341f61b54 Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Fri, 30 Jun 2023 17:14:25 -0300 Subject: [PATCH 1/5] Add python integration tests --- tests/antelope_name.py | 33 + tests/nodeos_eos_evm_server.py | 442 ++ tests/nodeos_eos_evm_server/PERFORMANCE.md | 144 + tests/nodeos_eos_evm_server/README.md | 9 + .../contracts/BlockNum.sol | 36 + .../contracts/Blockhash.sol | 42 + .../contracts/Eventor.sol | 10 + .../nodeos_eos_evm_server/contracts/Lock.sol | 34 + .../contracts/Recursive.sol | 13 + .../contracts/Storage.sol | 29 + .../nodeos_eos_evm_server/contracts/Token.sol | 11 + .../nodeos_eos_evm_server/contracts/WEOS.sol | 756 ++ .../extract-logtime-cmd.sh | 3 + tests/nodeos_eos_evm_server/hardhat.config.js | 369 + tests/nodeos_eos_evm_server/package.json | 23 + .../performance-measurements-0.5.0.md | 42 + .../scripts/deploy-blockhash.js | 25 + .../scripts/deploy-blocknum.js | 25 + .../scripts/deploy-eventor.js | 25 + .../scripts/deploy-recursive.js | 25 + .../scripts/deploy-token.js | 25 + .../scripts/deploy-uniswap.js | 55 + tests/nodeos_eos_evm_server/scripts/deploy.js | 50 + tests/nodeos_eos_evm_server/yarn.lock | 6156 +++++++++++++++++ tests/nodeos_eos_evm_test.py | 687 ++ 25 files changed, 9069 insertions(+) create mode 100644 tests/antelope_name.py create mode 100644 tests/nodeos_eos_evm_server.py create mode 100644 tests/nodeos_eos_evm_server/PERFORMANCE.md create mode 100644 tests/nodeos_eos_evm_server/README.md create mode 100644 tests/nodeos_eos_evm_server/contracts/BlockNum.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Blockhash.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Eventor.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Lock.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Recursive.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Storage.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/Token.sol create mode 100644 tests/nodeos_eos_evm_server/contracts/WEOS.sol create mode 100644 tests/nodeos_eos_evm_server/extract-logtime-cmd.sh create mode 100644 tests/nodeos_eos_evm_server/hardhat.config.js create mode 100644 tests/nodeos_eos_evm_server/package.json create mode 100644 tests/nodeos_eos_evm_server/performance-measurements-0.5.0.md create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-blockhash.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-blocknum.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-eventor.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-recursive.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-token.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy-uniswap.js create mode 100644 tests/nodeos_eos_evm_server/scripts/deploy.js create mode 100644 tests/nodeos_eos_evm_server/yarn.lock create mode 100644 tests/nodeos_eos_evm_test.py diff --git a/tests/antelope_name.py b/tests/antelope_name.py new file mode 100644 index 0000000..2334e05 --- /dev/null +++ b/tests/antelope_name.py @@ -0,0 +1,33 @@ +def convert_name_to_value(name): + def value_of_char(c: str): + assert len(c) == 1 + if c >= 'a' and c <= 'z': + return ord(c) - ord('a') + 6 + if c >= '1' and c <= '5': + return ord(c) - ord('1') + 1 + if c == '.': + return 0 + raise ValueError("invalid Antelope name: character '{0}' is not allowed".format(c)) + + name_length = len(name) + + if name_length > 13: + raise ValueError("invalid Antelope name: cannot exceed 13 characters") + + thirteen_char_value = 0 + if name_length == 13: + thirteen_char_value = value_of_char(name[12]) + if thirteen_char_value > 15: + raise ValueError("invalid Antelope name: 13th character cannot be letter past j") + + normalized_name = name[:12].ljust(12,'.') # truncate/extend to at exactly 12 characters since the 13th character is handled differently + + def convert_to_value(str): + value = 0 + for c in str: + value <<= 5 + value |= value_of_char(c) + + return value + + return (convert_to_value(normalized_name) << 4) | thirteen_char_value diff --git a/tests/nodeos_eos_evm_server.py b/tests/nodeos_eos_evm_server.py new file mode 100644 index 0000000..1082cfc --- /dev/null +++ b/tests/nodeos_eos_evm_server.py @@ -0,0 +1,442 @@ +#!/usr/bin/env python3 +import random +import os +import sys +import json +import time +import signal +import calendar +from datetime import datetime + +from flask import Flask, request, jsonify +from flask_cors import CORS +from eth_hash.auto import keccak +import requests +import json + +from binascii import unhexlify + +sys.path.append(os.getcwd()) +sys.path.append(os.path.join(os.getcwd(), "tests")) + +from TestHarness import Cluster, TestHelper, Utils, WalletMgr +from TestHarness.TestHelper import AppArgs +from TestHarness.testUtils import ReturnType +from core_symbol import CORE_SYMBOL + +from antelope_name import convert_name_to_value + +############################################################### +# nodeos_eos_evm_server +# +# Set up a EOS EVM env +# +# This test sets up 2 producing nodes and one "bridge" node using test_control_api_plugin. +# One producing node has 3 of the elected producers and the other has 1 of the elected producers. +# All the producers are named in alphabetical order, so that the 3 producers, in the one production node, are +# scheduled first, followed by the 1 producer in the other producer node. Each producing node is only connected +# to the other producing node via the "bridge" node. +# The bridge node has the test_control_api_plugin, which exposes a restful interface that the test script uses to kill +# the "bridge" node when /fork endpoint called. +# +# --eos-evm-contract-root should point to root of EOS EVM Contract build dir +# --genesis-json file to save generated EVM genesis json +# --read-endpoint eos-evm-rpc endpoint (read endpoint) +# +# Example: +# cd ~/ext/leap/build +# ~/ext/eos-evm/tests/leap/nodeos_eos_evm_server.py --eos-evm-contract-root ~/ext/eos-evm/contract/build --leave-running +# +# Launches wallet at port: 9899 +# Example: bin/cleos --wallet-url http://127.0.0.1:9899 ... +# +# Sets up endpoint on port 5000 +# / - for req['method'] == "eth_sendRawTransaction" +# /fork - create forked chain, does not return until a fork has started +# /restore - resolve fork and stabilize chain +# +# Dependencies: +# pip install eth-hash requests flask flask-cors +############################################################### + +Print=Utils.Print +errorExit=Utils.errorExit + +appArgs=AppArgs() +appArgs.add(flag="--eos-evm-contract-root", type=str, help="EOS EVM Contract build dir", default=None) +appArgs.add(flag="--genesis-json", type=str, help="File to save generated genesis json", default="eos-evm-genesis.json") +appArgs.add(flag="--read-endpoint", type=str, help="EVM read endpoint (eos-evm-rpc)", default="http://localhost:8881") + +args=TestHelper.parse_args({"--keep-logs","--dump-error-details","-v","--leave-running","--clean-run" }, applicationSpecificArgs=appArgs) +debug=args.v +killEosInstances= not args.leave_running +dumpErrorDetails=args.dump_error_details +keepLogs=args.keep_logs +killAll=args.clean_run +eosEvmContractRoot=args.eos_evm_contract_root +gensisJson=args.genesis_json +readEndpoint=args.read_endpoint + +assert eosEvmContractRoot is not None, "--eos-evm-contract-root is required" + +totalProducerNodes=2 +totalNonProducerNodes=1 +totalNodes=totalProducerNodes+totalNonProducerNodes +maxActiveProducers=21 +totalProducers=maxActiveProducers + +seed=1 +Utils.Debug=debug +testSuccessful=False + +random.seed(seed) # Use a fixed seed for repeatability. +cluster=Cluster(walletd=True) +walletMgr=WalletMgr(True) + + +try: + TestHelper.printSystemInfo("BEGIN") + + cluster.setWalletMgr(walletMgr) + cluster.killall(allInstances=killAll) + cluster.cleanup() + walletMgr.killall(allInstances=killAll) + walletMgr.cleanup() + + # *** setup topogrophy *** + + # "bridge" shape connects defprocera through defproducerc (3 in node0) to each other and defproduceru (1 in node01) + # and the only connection between those 2 groups is through the bridge node + + specificExtraNodeosArgs={} + # Connect SHiP to node01 so it will switch forks as they are resolved + specificExtraNodeosArgs[1]="--plugin eosio::state_history_plugin --state-history-endpoint 127.0.0.1:8999 --trace-history --chain-state-history --disable-replay-opts " + # producer nodes will be mapped to 0 through totalProducerNodes-1, so the number totalProducerNodes will be the non-producing node + specificExtraNodeosArgs[totalProducerNodes]="--plugin eosio::test_control_api_plugin " + extraNodeosArgs="--contracts-console" + if useEosVmOC: + extraNodeosArgs += " --wasm-runtime eos-vm-jit --eos-vm-oc-enable" + + Print("Stand up cluster") + if cluster.launch(topo="bridge", pnodes=totalProducerNodes, + totalNodes=totalNodes, totalProducers=totalProducers, + useBiosBootFile=False, extraNodeosArgs=extraNodeosArgs, specificExtraNodeosArgs=specificExtraNodeosArgs) is False: + Utils.cmdError("launcher") + Utils.errorExit("Failed to stand up eos cluster.") + + Print("Validating system accounts after bootstrap") + cluster.validateAccounts(None) + + Print ("Wait for Cluster stabilization") + # wait for cluster to start producing blocks + if not cluster.waitOnClusterBlockNumSync(3): + errorExit("Cluster never stabilized") + Print ("Cluster stabilized") + + prodNode = cluster.getNode(0) + prodNode0 = prodNode + prodNode1 = cluster.getNode(1) + nonProdNode = cluster.getNode(2) + + accounts=cluster.createAccountKeys(6) + if accounts is None: + Utils.errorExit("FAILURE - create keys") + + evmAcc = accounts[0] + evmAcc.name = "evmevmevmevm" + evmAcc.activePrivateKey="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" + evmAcc.activePublicKey="EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" + accounts[1].name="tester111111" # needed for voting + accounts[2].name="tester222222" # needed for voting + accounts[3].name="tester333333" # needed for voting + accounts[4].name="tester444444" # needed for voting + accounts[5].name="tester555555" # needed for voting + + testWalletName="test" + + Print("Creating wallet \"%s\"." % (testWalletName)) + testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount,accounts[0],accounts[1],accounts[2],accounts[3],accounts[4],accounts[5]]) + + for _, account in cluster.defProducerAccounts.items(): + walletMgr.importKey(account, testWallet, ignoreDupKeyWarning=True) + + for i in range(0, totalNodes): + node=cluster.getNode(i) + node.producers=Cluster.parseProducers(i) + numProducers=len(node.producers) + for prod in node.producers: + prodName = cluster.defProducerAccounts[prod].name + if prodName == "defproducera" or prodName == "defproducerb" or prodName == "defproducerc" or prodName == "defproduceru": + Print("Register producer %s" % cluster.defProducerAccounts[prod].name) + trans=node.regproducer(cluster.defProducerAccounts[prod], "http::/mysite.com", 0, waitForTransBlock=False, exitOnError=True) + + # create accounts via eosio as otherwise a bid is needed + for account in accounts: + Print("Create new account %s via %s with private key: %s" % (account.name, cluster.eosioAccount.name, account.activePrivateKey)) + trans=nonProdNode.createInitializeAccount(account, cluster.eosioAccount, stakedDeposit=0, waitForTransBlock=True, stakeNet=10000, stakeCPU=10000, buyRAM=10000000, exitOnError=True) + # max supply 1000000000.0000 (1 Billion) + transferAmount="100000000.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) + trans=nonProdNode.delegatebw(account, 20000000.0000, 20000000.0000, waitForTransBlock=False, exitOnError=True) + + # *** vote using accounts *** + + cluster.waitOnClusterSync(blockAdvancing=3) + + # vote a,b,c u + voteProducers=[] + voteProducers.append("defproducera") + voteProducers.append("defproducerb") + voteProducers.append("defproducerc") + voteProducers.append("defproduceru") + for account in accounts: + Print("Account %s vote for producers=%s" % (account.name, voteProducers)) + trans=prodNode.vote(account, voteProducers, exitOnError=True, waitForTransBlock=False) + + #verify nodes are in sync and advancing + cluster.waitOnClusterSync(blockAdvancing=3) + Print("Shutdown unneeded bios node") + cluster.biosNode.kill(signal.SIGTERM) + + # setup evm + + contractDir=eosEvmContractRoot + "/evm_runtime" + wasmFile="evm_runtime.wasm" + abiFile="evm_runtime.abi" + Utils.Print("Publish evm_runtime contract") + prodNode.publishContract(evmAcc, contractDir, wasmFile, abiFile, waitForTransBlock=True) + + # add eosio.code permission + cmd="set account permission evmevmevmevm active --add-code -p evmevmevmevm@active" + prodNode.processCleosCmd(cmd, cmd, silentErrors=True, returnType=ReturnType.raw) + + trans = prodNode.pushMessage(evmAcc.name, "init", '{"chainid":15555, "fee_params": {"gas_price": "150000000000", "miner_cut": 10000, "ingress_bridge_fee": null}}', '-p evmevmevmevm') + + prodNode.waitForTransBlockIfNeeded(trans[1], True) + + transId=prodNode.getTransId(trans[1]) + blockNum = prodNode.getBlockNumByTransId(transId) + block = prodNode.getBlock(blockNum) + Utils.Print("Block Id: ", block["id"]) + Utils.Print("Block timestamp: ", block["timestamp"]) + + genesis_info = { + "alloc": { + "0x0000000000000000000000000000000000000000" : {"balance":"0x00"} + }, + "coinbase": "0x0000000000000000000000000000000000000000", + "config": { + "chainId": 15555, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "trust": {} + }, + "difficulty": "0x01", + "extraData": "EOSEVM", + "gasLimit": "0x7ffffffffff", + "mixHash": "0x"+block["id"], + "nonce": f'{convert_name_to_value(evmAcc.name):#0x}', + "timestamp": hex(int(calendar.timegm(datetime.strptime(block["timestamp"].split(".")[0], '%Y-%m-%dT%H:%M:%S').timetuple()))) + } + + Utils.Print("Send small balance to special balance to allow the bridge to work") + transferAmount="1.0000 {0}".format(CORE_SYMBOL) + Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, evmAcc.name)) + nonProdNode.transferFunds(cluster.eosioAccount, evmAcc, transferAmount, evmAcc.name, waitForTransBlock=True) + + # accounts: { + # mnemonic: "test test test test test test test test test test test junk", + # path: "m/44'/60'/0'/0", + # initialIndex: 0, + # count: 20, + # passphrase: "", + # } + + addys = { + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266":"0x038318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed75,0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "0x70997970C51812dc3A010C7d01b50e0d17dc79C8":"0x02ba5734d8f7091719471e7f7ed6b9df170dc70cc661ca05e688601ad984f068b0,0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", + "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC":"0x039d9031e97dd78ff8c15aa86939de9b1e791066a0224e331bc962a2099a7b1f04,0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a", + "0x90F79bf6EB2c4f870365E785982E1f101E93b906":"0x0220b871f3ced029e14472ec4ebc3c0448164942b123aa6af91a3386c1c403e0eb,0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6", + "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65":"0x03bf6ee64a8d2fdc551ec8bb9ef862ef6b4bcb1805cdc520c3aa5866c0575fd3b5,0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a", + "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc":"0x0337b84de6947b243626cc8b977bb1f1632610614842468dfa8f35dcbbc55a515e,0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba", + "0x976EA74026E726554dB657fA54763abd0C3a0aa9":"0x029a4ab212cb92775d227af4237c20b81f4221e9361d29007dfc16c79186b577cb,0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e", + "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955":"0x0201f2bf1fa920e77a43c7aec2587d0b3814093420cc59a9b3ad66dd5734dda7be,0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356", + "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f":"0x03931e7fda8da226f799f791eefc9afebcd7ae2b1b19a03c5eaa8d72122d9fe74d,0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97", + "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720":"0x023255458e24278e31d5940f304b16300fdff3f6efd3e2a030b5818310ac67af45,0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6", + "0xBcd4042DE499D14e55001CcbB24a551F3b954096":"0x030bb316cf4dbaeff8df7c6a8f3c55a11c72f7f2f8d79c274f27cdce2220f36371,0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897", + "0x71bE63f3384f5fb98995898A86B02Fb2426c5788":"0x02e393c954d127d79d56b594a46df6b2e053f49446759eac612dbe12ade3095c67,0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82", + "0xFABB0ac9d68B0B445fB7357272Ff202C5651694a":"0x02463e7db0f9c35ba7ae68a8098f1024019b90191281276eeef294acb3f1354b0a,0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1", + "0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec":"0x037805be0fc5186c4437306b531c8e981d3922e5fc81d72d527931b995445fb78e,0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd", + "0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097":"0x03407a862c69cbc66dceea40079757697abcf931043f5a5f128a56ae6e51bdbce7,0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa", + "0xcd3B766CCDd6AE721141F452C550Ca635964ce71":"0x02d5ab34891bfe989bfa557f983cb5d031c4acc845ad990baaefb58ca1db0e7716,0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61", + "0x2546BcD3c84621e976D8185a91A922aE77ECEc30":"0x0364c1c85d9aa8081a8ef94c35379fa7532942b2d8cbbd1e3ea71c0e3609b96cc0,0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0", + "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E":"0x02c216848622dfc38a2ad2a921f524103cf654a22b8679736ecedc4901453ea3f7,0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd", + "0xdD2FD4581271e230360230F9337D5c0430Bf44C0":"0x02302a94bd084ff317493db7c2fe07e0935c0f6d3e6772d6af3c58e92abebfb402,0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0", + "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199":"0x027bf824b28c4bf11ce553fa746a18754949ab4959e2ea73465778d14179211f8c,0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e", + "0x09DB0a93B389bEF724429898f539AEB7ac2Dd55f":"0x02ecc9c3f6303fddcd44f5c9ecaa225eafaa18b8464a022389a4c4be474e4557a9,0xeaa861a9a01391ed3d587d8a5a84ca56ee277629a8b02c22093a419bf240e65d", + "0x02484cb50AAC86Eae85610D6f4Bf026f30f6627D":"0x031a7044a0e2549a114c92dfa83a25bfc17f4b7c2db4a7e7e48d35ed67c285de3b,0xc511b2aa70776d4ff1d376e8537903dae36896132c90b91d52c1dfbae267cd8b", + "0x08135Da0A343E492FA2d4282F2AE34c6c5CC1BbE":"0x02abca850bc9472d92402203e9cbafc2e8dedb19f1103911a62b11ba2a4370e635,0x224b7eb7449992aac96d631d9677f7bf5888245eef6d6eeda31e62d2f29a83e4", + "0x5E661B79FE2D3F6cE70F5AAC07d8Cd9abb2743F1":"0x02092a3ba818f25a71a947d3daa7f9d501c3f18296057c928bc5feffa8b61d54f3,0x4624e0802698b9769f5bdb260a3777fbd4941ad2901f5966b854f953497eec1b", + "0x61097BA76cD906d2ba4FD106E757f7Eb455fc295":"0x030b1d683d363d0704f04e4fb59a33b6e22bd0187303f9cce881d0809d3a535f28,0x375ad145df13ed97f8ca8e27bb21ebf2a3819e9e0a06509a812db377e533def7", + "0xDf37F81dAAD2b0327A0A50003740e1C935C70913":"0x02da995e8954b8c4681db2986bc3004f403c8f5600d1d33a949a63045c50abf41d,0x18743e59419b01d1d846d97ea070b5a3368a3e7f6f0242cf497e1baac6972427", + "0x553BC17A05702530097c3677091C5BB47a3a7931":"0x027bc620a41c572668c4d7b508e020cd8f4e9e50074016c461370e7995838b5dbd,0xe383b226df7c8282489889170b0f68f66af6459261f4833a781acd0804fafe7a", + "0x87BdCE72c06C21cd96219BD8521bDF1F42C78b5e":"0x0335aafbd21e02e958638c90c562dc048df89452b743dd7c3c7eadb8a223925895,0xf3a6b71b94f5cd909fb2dbb287da47badaa6d8bcdc45d595e2884835d8749001", + "0x40Fc963A729c542424cD800349a7E4Ecc4896624":"0x032cd2af66ea588191488e7a647190584a3999630e2db8d5abba0ac290fbd291ab,0x4e249d317253b9641e477aba8dd5d8f1f7cf5250a5acadd1229693e262720a19", + "0x9DCCe783B6464611f38631e6C851bf441907c710":"0x0329fdd393d57616eafdf67ebb6272a8ddb2ebf1eaa9b95b9e0702de79bf90da02,0x233c86e887ac435d7f7dc64979d7758d69320906a0d340d2b6518b0fd20aa998", + "0x1BcB8e569EedAb4668e55145Cfeaf190902d3CF2":"0x02a3b615dcceb0b919884b12fed0d3125c5324dd01e95fd0e5dfbee1fc51cbbe15,0x85a74ca11529e215137ccffd9c95b2c72c5fb0295c973eb21032e823329b3d2d", + "0x8263Fce86B1b78F95Ab4dae11907d8AF88f841e7":"0x02352c8ff139eb4b92f0b24d60e434c365ee202acc25aaa4f438852fce49eb41c8,0xac8698a440d33b866b6ffe8775621ce1a4e6ebd04ab7980deb97b3d997fc64fb", + "0xcF2d5b3cBb4D7bF04e3F7bFa8e27081B52191f91":"0x02eb8d75ab6953483cb4df4fae49e0199a220b3cd204852960e55e1f1dbb3cfa21,0xf076539fbce50f0513c488f32bf81524d30ca7a29f400d68378cc5b1b17bc8f2", + "0x86c53Eb85D0B7548fea5C4B4F82b4205C8f6Ac18":"0x0353db5e250d783f4368322de94bab64276c80a7284b9db0eae18bcae1f3eb0e28,0x5544b8b2010dbdbef382d254802d856629156aba578f453a76af01b81a80104e", + "0x1aac82773CB722166D7dA0d5b0FA35B0307dD99D":"0x02e749e4fb83ae7afc7d19acdfc6a97ec5ae677019decf2c46758096a679021c6c,0x47003709a0a9a4431899d4e014c1fd01c5aad19e873172538a02370a119bae11", + "0x2f4f06d218E426344CFE1A83D53dAd806994D325":"0x022a04ffd79e7334daa2724d9227d11ecf8124f0f2e2ae82b78cbfba14bca47577,0x9644b39377553a920edc79a275f45fa5399cbcf030972f771d0bca8097f9aad3", + "0x1003ff39d25F2Ab16dBCc18EcE05a9B6154f65F4":"0x023f1e0c738f9604febf39304f7a8c918da05a7d0fc574cca239893b1f24e10639,0xcaa7b4a2d30d1d565716199f068f69ba5df586cf32ce396744858924fdf827f0", + "0x9eAF5590f2c84912A08de97FA28d0529361Deb9E":"0x0354d2c78f37e8efe3014735fcca95cabae6a1e7901262a3f4e71355b1b406e555,0xfc5a028670e1b6381ea876dd444d3faaee96cffae6db8d93ca6141130259247c", + "0x11e8F3eA3C6FcF12EcfF2722d75CEFC539c51a1C":"0x023e21c805452630d51c2116c0be5d78586f09f0239e5e0c78c1301bca129dd60a,0x5b92c5fe82d4fabee0bc6d95b4b8a3f9680a0ed7801f631035528f32c9eb2ad5", + "0x7D86687F980A56b832e9378952B738b614A99dc6":"0x03cae5771b32d2b0639db908805738158abd3943623f23eaf875cc7e7eaefa9662,0xb68ac4aa2137dd31fd0732436d8e59e959bb62b4db2e6107b15f594caf0f405f", + "0x9eF6c02FB2ECc446146E05F1fF687a788a8BF76d":"0x036fa7e0bea88907ab4753030c9e2bde73f1740ade3e134eba7414729be25eddbf,0xc95eaed402c8bd203ba04d81b35509f17d0719e3f71f40061a2ec2889bc4caa7", + "0x08A2DE6F3528319123b25935C92888B16db8913E":"0x033f52ffb1962b253b7b62f5a3a6e68b71f25fa8f5e3eeeeeb666c3fb73eac90f2,0x55afe0ab59c1f7bbd00d5531ddb834c3c0d289a4ff8f318e498cb3f004db0b53", + "0xe141C82D99D85098e03E1a1cC1CdE676556fDdE0":"0x0389b4c6ccde6226f5efdaad52831601004334d110e5eceb8060143a8adf234a12,0xc3f9b30f83d660231203f8395762fa4257fa7db32039f739630f87b8836552cc", + "0x4b23D303D9e3719D6CDf8d172Ea030F80509ea15":"0x039141c8858729dd0c6849821158bce66f986cc07c8f02915798b559b0bfd54d4f,0x3db34a7bcc6424e7eadb8e290ce6b3e1423c6e3ef482dd890a812cd3c12bbede", + "0xC004e69C5C04A223463Ff32042dd36DabF63A25a":"0x03a4c793122ddb400993b158b5fc2c49537892aca278a78800d901ced771af1b49,0xae2daaa1ce8a70e510243a77187d2bc8da63f0186074e4a4e3a7bfae7fa0d639", + "0x5eb15C0992734B5e77c888D713b4FC67b3D679A2":"0x02a634ff1801b05722f7c5d1f90c49a9647bbb1687ff78f6def5aa37b3fe99e4f3,0x5ea5c783b615eb12be1afd2bdd9d96fae56dda0efe894da77286501fd56bac64", + "0x7Ebb637fd68c523613bE51aad27C35C4DB199B9c":"0x02f339bf0e15d6b2fff7b2770bca8b08204cde82272e8c86116996aba7ac9f86aa,0xf702e0ff916a5a76aaf953de7583d128c013e7f13ecee5d701b49917361c5e90", + "0x3c3E2E178C69D4baD964568415a0f0c84fd6320A":"0x02a7dbabe4d7d8ce4b97b2a6d35d7e3258f02cc961d2c83477dbaeadbc04627c9b,0x7ec49efc632757533404c2139a55b4d60d565105ca930a58709a1c52d86cf5d3", + "0x35304262b9E87C00c430149f28dD154995d01207":"0x03e719f368cc8eb4573b9d22e88141ae459d886145219064923ff564afb432c9ac,0x755e273950f5ae64f02096ae99fe7d4f478a28afd39ef2422068ee7304c636c0", + "0xD4A1E660C916855229e1712090CcfD8a424A2E33":"0x021a7791080bafa8601bb57bd37697f6791b525476b97289b71da04ab3a4a2b30c,0xaf6ecabcdbbfb2aefa8248b19d811234cd95caa51b8e59b6ffd3d4bbc2a6be4c", + "0xEe7f6A930B29d7350498Af97f0F9672EaecbeeFf":"0x03d41afe51df3bc945686fc68692bbf1b842625d237f37fc6be7e7f48b12dd179a,0x70c2bd1b41084c2e2238551eace483321f8c1a413a471c3b49c8a5d1d6b3d0c4", + "0x145e2dc5C8238d1bE628F87076A37d4a26a78544":"0x024982335a4f5adc6a12deb2e993b4a3a758c934cfd7f039f9b7f2da9bba3584e5,0xcb8e373c93609268cdcec93450f3578b92bb20c3ac2e77968d106025005f97b5", + "0xD6A098EbCc5f8Bd4e174D915C54486B077a34A51":"0x03a3d9eb25c55ec1b2f806bf74467179ba5dafc0b60a71df8584186bb5e00d33e9,0x6f29f6e0b750bcdd31c3403f48f11d72215990375b6d23380b39c9bbf854a7d3", + "0x042a63149117602129B6922ecFe3111168C2C323":"0x0324b9bda0e580b02d781560fd0e0cbfd2eaeba437385f8cdef34be6ec9bd8a3e5,0xff249f7eba6d8d3a65794995d724400a23d3b0bd1714265c965870ef47808be8", + "0xa0EC9eE47802CeB56eb58ce80F3E41630B771b04":"0x02293160c8d9443c5005f079f69c8d6ccd300bb6ca602047d441cadd34fce69e6a,0x5599a7be5589682da3e0094806840e8510dae6493665a701b06c59cbe9d97968", + "0xe8B1ff302A740fD2C6e76B620d45508dAEc2DDFf":"0x02e9c73d939eca4abac1a04ae265b74ff31cdd24be067aae13dcd54128e649161f,0x93de2205919f5b472723722fedb992e962c34d29c4caaedd82cd33e16f1fd3cf", + "0xAb707cb80e7de7C75d815B1A653433F3EEc44c74":"0x026d93cfa091c70da11e27ee30dbcca537002ed21b19e05ac93e7d851a96138046,0xd20ecf81c6c3ad87a4e8dbeb7ceef41dd0eebc7a1657efb9d34e47217694b5cb", + "0x0d803cdeEe5990f22C2a8DF10A695D2312dA26CC":"0x026af2062598d0630cc1c6f5353e66932434d1eb575bafab8da38741e34e82e281,0xe4058704ed240d68a94b6fb226824734ddabd4b1fe37bc85ce22f5b17f98830e", + "0x1c87Bb9234aeC6aDc580EaE6C8B59558A4502220":"0x02505ad7c2117c6a2eef85f5b70fb590a8f13f9f37b01f7e5b10139186bef06f2a,0x4ae4408221b5042c0ee36f6e9e6b586a00d0452aa89df2e7f4f5aec42152ec43", + "0x4779d18931B35540F84b0cd0e9633855B84df7b8":"0x03dd485c6f4db4f3978db121fba82550acef94eaf7f5ab88ecc3f6715b903c7184,0x0e7c38ba429fa5081692121c4fcf6304ca5895c6c86d31ed155b0493c516107f", + "0xC0543b0b980D8c834CBdF023b2d2A75b5f9D1909":"0x0270f7e08d92e184babc782d65b155a9b7dfbc0b671cc7b1a8c164e279df10524c,0xd5df67c2e4da3ff9c8c6045d9b7c41581efeb2a3660921ad4ba863cc4b8c211c", + "0x73B3074ac649A8dc31c2C90a124469456301a30F":"0x02f8660f6999a86ebe5cd7a3d70406e9a40b91b2adb9f5a4c0bc417d9782fdda90,0x92456ac1fa1ef65a04fb4689580ad5e4cda7369f3620ef3a02fa4015725f460a", + "0x265188114EB5d5536BC8654d8e9710FE72C28c4d":"0x037e2b32c6115bd151f79cb03a02eda9a8e358fb6be1eaec990ea5a60edc5371dc,0x65b10e7d7315bb8b7f7c6eefcbd87b36ad4007c4ade9c032354f016e84ad9c5e", + "0x924Ba5Ce9f91ddED37b4ebf8c0dc82A40202fc0A":"0x02744c74fdfbaf21ce24cb7b8b388cbdbb5d5f6cb17cbd8947937c101b5ddabd72,0x365820b3376c77dab008476d49f7cd7af87fc7bbd57dc490378106c3353b2b33", + "0x64492E25C30031EDAD55E57cEA599CDB1F06dad1":"0x027aba8dcc8f89805a671b6f5c9cb045bbdffcc34be8d67c08676834be4e05108e,0xb07579b9864bb8e69e8b6e716284ab5b5f39fe5bb57ae4c83af795a242390202", + "0x262595fa2a3A86adACDe208589614d483e3eF1C0":"0x03d886c44c0449efb2b3e8786b84526b145312be2218b0df7e9cd36acfab8a7906,0xbf071d2b017426fcbf763cce3b3efe3ffc9663a42c77a431df521ef6c79cacad", + "0xDFd99099Fa13541a64AEe9AAd61c0dbf3D32D492":"0x02261caf03c748989a5d7d540b2fbf31f1a7e073a79f44b970ab2eb6de8aefe618,0x8bbffff1588b3c4eb8d415382546f6f6d5f0f61087c3be7c7c4d9e0d41d97258", + "0x63c3686EF31C03a641e2Ea8993A91Ea351e5891a":"0x03ed764675312dedf399f1bc201d3793228ccf560d0af20ea647362c82232838be,0xb658f0575a14a7ac05075cb0f8727f0aae168a091dfb32d92514d1a7c11cf498", + "0x9394cb5f737Bd3aCea7dcE90CA48DBd42801EE5d":"0x02317b1f8a1fbe4fe6f797c699557e934c32ba84124b84d96c5169739aea200aee,0x228330af91fa515d7514cf5ac6594ab90b296cbd8ff7bc4567306aa66cacd79f", + "0x344dca30F5c5f74F2f13Dc1d48Ad3A9069d13Ad9":"0x033faa1f92cfcc003fb2881ebc43ec06afb7e827affb98e31ee4322730351cc422,0xe6f80f9618311c0cd58f6a3fc6621cdbf6da4a72cc42e2974c98829343e7927b", + "0xF23E054D8b4D0BECFa22DeEF5632F27f781f8bf5":"0x0364c2c11140a075eb0091cf670323d36e13befec4e8a10cba171a9a2de9f1ab45,0x36d0435aa9a2c24d72a0aa69673b3acc2649969c38a581103df491aac6c33dd4", + "0x6d69F301d1Da5C7818B5e61EECc745b30179C68b":"0x03c550d4a3aaabcf2489acc382f8f8809b1e1601115564e39b239348690ae701bc,0xf3ed98f9148171cfed177aef647e8ac0e2579075f640d05d37df28e6e0551083", + "0xF0cE7BaB13C99bA0565f426508a7CD8f4C247E5a":"0x03a5d94447bc763e337e2dd4a88a4d5be5bda78f7ebb891ed9ed9cdf9d49a01ec4,0x8fc20c439fd7cf4f36217471a5db7594188540cf9997a314520a018de27544dd", + "0x011bD5423C5F77b5a0789E27f922535fd76B688F":"0x0351ee10626b0a786de6055e2ae0d5425ba3f17059b40219fe8820946d16249e1e,0x549078aab3adafeff862b2d40b6b27756c5c4669475c3367edfb8dcf63ea1ae5", + "0xD9065f27e9b706E5F7628e067cC00B288dddbF19":"0x0229157c9e5a73e54e55a062cf19104f6061dbcb11a23e31f60913d0b12c553d3d,0xacf192decb2e4ddd8ad61693ab8edd67e3620b2ed79880ff4e1e04482c52c916", + "0x54ccCeB38251C29b628ef8B00b3cAB97e7cAc7D5":"0x03feca36c85fc354f47dfcc23f0e5baca85357c64bbe8616560675cd3333b8acbc,0x47dc59330fb8c356ef61c55c11f9bb49ee463df50cbfe59f389de7637037b029", + "0xA1196426b41627ae75Ea7f7409E074BE97367da2":"0x0352536b2204dc725b8b98c2931079fcb912bc702215da262e9d5cd444d226cc68,0xf0050439b33fd77f7183f44375bc43a869a9880dca82a187fab9be91e020d029", + "0xE74cEf90b6CF1a77FEfAd731713e6f53e575C183":"0x026ffa4ca4e8e4e9e9426f2b762e31a9b0b3586f8eafb470bb32aca6e5fd46ffcd,0xe995cc7ea38e5c2927b97607765c2a20f4a6052d6810a3a1102e84d77c0df13b", + "0x7Df8Efa6d6F1CB5C4f36315e0AcB82b02Ae8BA40":"0x03c85a8ab2a97379d1c3ff45e28815a7dc5485d2246362bd4823fceee257b7e798,0x8232e778c8e32eddb268e12aee5e82c7bb540cc176e150d64f35ee4ae2faf2b2", + "0x9E126C57330FA71556628e0aabd6B6B6783d99fA":"0x034d7b61c8dd53a761ab44d1e06be6b1338de4095c620112494b8830792c84f64b,0xba8c9ff38e4179748925335a9891b969214b37dc3723a1754b8b849d3eea9ac0" + } + + # init with 100,000 EOS + for i,k in enumerate(addys): + print("addys: [{0}] [{1}] [{2}]".format(i,k[2:].lower(), len(k[2:]))) + transferAmount="100000.0000 {0}".format(CORE_SYMBOL) + Print("Transfer funds %s from account %s to %s" % (transferAmount, cluster.eosioAccount.name, evmAcc.name)) + trans = prodNode.transferFunds(cluster.eosioAccount, evmAcc, transferAmount, "0x" + k[2:].lower(), waitForTransBlock=False) + if not (i+1) % 20: time.sleep(1) + prodNode.waitForTransBlockIfNeeded(trans, True) + + if gensisJson[0] != '/': gensisJson = os.path.realpath(gensisJson) + f=open(gensisJson,"w") + f.write(json.dumps(genesis_info)) + f.close() + Utils.Print("#####################################################") + Utils.Print("Generated EVM json genesis file in: %s" % gensisJson) + Utils.Print("") + Utils.Print("You can now run:") + Utils.Print(" eos-evm-node --plugin=blockchain_plugin --ship-endpoint=127.0.0.1:8999 --genesis-json=%s --chain-data=/tmp --verbosity=4" % gensisJson) + Utils.Print(" eos-evm-rpc --eos-evm-node=127.0.0.1:8080 --http-port=0.0.0.0:8881 --chaindata=/tmp --api-spec=eth,debug,net,trace") + Utils.Print("") + Utils.Print("Web3 endpoint:") + Utils.Print(" http://localhost:5000") + + app = Flask(__name__) + CORS(app) + + @app.route("/fork", methods=["POST"]) + def fork(): + Print("Sending command to kill bridge node to separate the 2 producer groups.") + forkAtProducer="defproducera" + prodNode1Prod="defproduceru" + preKillBlockNum=nonProdNode.getBlockNum() + preKillBlockProducer=nonProdNode.getBlockProducerByNum(preKillBlockNum) + nonProdNode.killNodeOnProducer(producer=forkAtProducer, whereInSequence=1) + Print("Current block producer %s fork will be at producer %s" % (preKillBlockProducer, forkAtProducer)) + prodNode0.waitForProducer(forkAtProducer) + prodNode1.waitForProducer(prodNode1Prod) + if nonProdNode.verifyAlive(): # if on defproducera, need to wait again + prodNode0.waitForProducer(forkAtProducer) + prodNode1.waitForProducer(prodNode1Prod) + + if nonProdNode.verifyAlive(): + Print("Bridge did not shutdown") + return "Bridge did not shutdown" + + Print("Fork started") + return "Fork started" + + @app.route("/restore", methods=["POST"]) + def restore(): + Print("Relaunching the non-producing bridge node to connect the producing nodes again") + + if nonProdNode.verifyAlive(): + return "bridge is already running" + + if not nonProdNode.relaunch(): + Utils.errorExit("Failure - (non-production) node %d should have restarted" % (nonProdNode.nodeNum)) + + return "restored fork should resolve" + + @app.route("/", methods=["POST"]) + def default(): + def forward_request(req): + if req['method'] == "eth_sendRawTransaction": + actData = {"miner":"evmevmevmevm", "rlptx":req['params'][0][2:]} + prodNode1.pushMessage(evmAcc.name, "pushtx", json.dumps(actData), '-p evmevmevmevm') + return { + "id": req['id'], + "jsonrpc": "2.0", + "result": '0x'+keccak(unhexlify(req['params'][0][2:])).hex() + } + + if req['method'] == "eth_gasPrice": + gas_price=int(prodNode1.getTable(evmAcc.name, evmAcc.name, "config")['rows'][0]['gas_price']) + return { + "id": req['id'], + "jsonrpc": "2.0", + "result": f'{gas_price:#0x}' + } + + return requests.post(readEndpoint, json.dumps(req), headers={"Content-Type":"application/json"}).json() + + request_data = request.get_json() + if type(request_data) == dict: + return jsonify(forward_request(request_data)) + + res = [] + for r in request_data: + res.append(forward_request(r)) + + return jsonify(res) + + app.run(host='0.0.0.0', port=5000) + +finally: + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killEosInstances, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) + +exitCode = 0 if testSuccessful else 1 +exit(exitCode) diff --git a/tests/nodeos_eos_evm_server/PERFORMANCE.md b/tests/nodeos_eos_evm_server/PERFORMANCE.md new file mode 100644 index 0000000..374fef1 --- /dev/null +++ b/tests/nodeos_eos_evm_server/PERFORMANCE.md @@ -0,0 +1,144 @@ +# Mesuring EVM contract performance + +### Create working folder +``` +mkdir ~/evmperf +cd ~/evmperf +``` + + +### Build EVM contract +_set stack-size in src/CMakeList.txt to_ **16384** _before building_ + +``` +cd ~/evmperf +git clone https://github.com/eosnetworkfoundation/eos-evm +cd eos-evm/contract +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DWITH_LOGTIME=ON .. +make -j4 +``` + +### Build eos-evm-node and eos-evm-rpc +``` +cd ~/evmperf/eos-evm +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j4 eos-evm-node eos-evm-rpc +``` + + +### Build leap v3.2.2-logtime +``` +cd ~/evmperf +git clone https://github.com/elmato/leap +cd leap +git checkout v3.2.2-logtime +git submodules update --init --recursive +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j4 +``` + +### Setup nodeos_eos_evm_server.py python env +``` +cd ~/evmperf/leap/build/tests +ln -s ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server.py nodeos_eos_evm_server.py +sed -i 's/SYS/EOS/g' core_symbol.py +python3 -m venv venv +source venv/bin/activate +pip install 'web3<6' flask flask-cors +``` + + +### Launch nodeos and deploy EVM contract +_use --use-eos-vm-oc=1 when launching **nodeos_eos_evm_server.py** if you want to measure OC performance_ + +``` +cd ~/evmperf/leap/build/tests +source venv/bin/activate +cd .. +./tests/nodeos_eos_evm_server.py --leave-running --eos-evm-contract-root ~/evmperf/eos-evm/contract/build +``` + +(_wait until nodeos_eos_evm_server start listening at localhost:5000_) + +### Launch eos-evm-node +``` +cd ~/evmperf/eos-evm/build/cmd +rm -rf chaindata etl-temp config-dir +./eos-evm-node --plugin=blockchain_plugin --ship-endpoint=127.0.0.1:8999 --genesis-json=$HOME/evmperf/leap/build/eos-evm-genesis.json --verbosity=4 +``` + +### Launch eos-evm-rpc +``` +cd ~/evmperf/eos-evm/build/cmd +./eos-evm-rpc --eos-evm-node=127.0.0.1:8080 --http-port=0.0.0.0:8881 --chaindata=./ --api-spec=eth,debug,net,trace --verbosity=4 +``` + +### Install scripts dependencies +``` +cd ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server +yarn install +``` + + +### Deploy Uniswap V2 +``` +cd ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server +npx hardhat run scripts/deploy-uniswap.js +``` + +### Deploy Recursive contract +``` +cd ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server +npx hardhat run scripts/deploy-recursive.js +``` + +### Allow Uniswap router to transfer AAA tokens +``` +cd ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server +npx hardhat approve --erc20 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 --router 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 --amount 10000 +``` + +### Tail logs _(separate console)_ +``` +cd ~/evmperf/eos-evm/tests/leap/nodeos_eos_evm_server +./extract-logtime-cmd.sh ~/evmperf/leap/build/var/lib/node_01/stderr.txt +``` + +### Execute AAA=>BBB swaps +``` +while true +do +npx hardhat swap --router 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 --path 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9 --amount 0.5 +done + +``` + +### Execute AAA=>BBB=>CCC swaps +``` +while true +do +npx hardhat swap --router 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 --path 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9,0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9,0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 --amount 0.5 +done +``` + +### Execute erc20 transfers +``` +while true +do +npx hardhat transfer --from 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --contract 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 --amount 0.1 +done +``` + +### Execute native transfers +``` +while true +do +npx hardhat native-transfer --from 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --amount 1 +done +``` \ No newline at end of file diff --git a/tests/nodeos_eos_evm_server/README.md b/tests/nodeos_eos_evm_server/README.md new file mode 100644 index 0000000..3de572d --- /dev/null +++ b/tests/nodeos_eos_evm_server/README.md @@ -0,0 +1,9 @@ +# Sample Hardhat Project + +This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. + +Try running some of the following tasks: + +```shell +npx hardhat run scripts/deploy.js +``` diff --git a/tests/nodeos_eos_evm_server/contracts/BlockNum.sol b/tests/nodeos_eos_evm_server/contracts/BlockNum.sol new file mode 100644 index 0000000..3456e24 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/BlockNum.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +/** + * @title Storage + * @dev Store & retrieve value in a variable + * @custom:dev-run-script ./scripts/deploy_with_ethers.ts + */ +contract BlockNum { + uint256 public blockNumber; + uint256 public timestamp; + uint256 public difficulty; + address public coinbase; + constructor() { + blockNumber = block.number; + timestamp = block.timestamp; + difficulty = block.difficulty; + coinbase = block.coinbase; + } + function setValues() public payable { + blockNumber = block.number; + timestamp = block.timestamp; + difficulty = block.difficulty; + coinbase = block.coinbase; + } + function estimateBlockNumber() public view returns (uint256) { + return block.number; + } + function estimateTimestamp() public view returns (uint256) { + return block.timestamp; + } + function kill(address payable _to) public payable { + selfdestruct(_to); + } +} diff --git a/tests/nodeos_eos_evm_server/contracts/Blockhash.sol b/tests/nodeos_eos_evm_server/contracts/Blockhash.sol new file mode 100644 index 0000000..262989f --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Blockhash.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.8.2 <0.9.0; + +contract Blockhash { + + uint256 curr_block; + bytes32 prev1; + bytes32 prev2; + bytes32 prev3; + bytes32 prev4; + bytes32 prev5; + + function go() public { + curr_block = block.number; + prev1 = blockhash(block.number-1); + prev2 = blockhash(block.number-2); + prev3 = blockhash(block.number-3); + prev4 = blockhash(block.number-4); + prev5 = blockhash(block.number-5); + } + + function r_curr_block() public view returns (uint256){ + return curr_block; + } + function r_prev1() public view returns (bytes32){ + return prev1; + } + function r_prev2() public view returns (bytes32){ + return prev2; + } + function r_prev3() public view returns (bytes32){ + return prev3; + } + function r_prev4() public view returns (bytes32){ + return prev4; + } + function r_prev5() public view returns (bytes32){ + return prev5; + } + +} \ No newline at end of file diff --git a/tests/nodeos_eos_evm_server/contracts/Eventor.sol b/tests/nodeos_eos_evm_server/contracts/Eventor.sol new file mode 100644 index 0000000..890ac0a --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Eventor.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract Eventor { + event Deposit(address indexed _from, bytes32 indexed _id, uint _value); + function deposit(bytes32 _id, uint256 _value) public { + emit Deposit(msg.sender, _id, _value); + } +} diff --git a/tests/nodeos_eos_evm_server/contracts/Lock.sol b/tests/nodeos_eos_evm_server/contracts/Lock.sol new file mode 100644 index 0000000..50935f6 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Lock.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.9; + +// Uncomment this line to use console.log +// import "hardhat/console.sol"; + +contract Lock { + uint public unlockTime; + address payable public owner; + + event Withdrawal(uint amount, uint when); + + constructor(uint _unlockTime) payable { + require( + block.timestamp < _unlockTime, + "Unlock time should be in the future" + ); + + unlockTime = _unlockTime; + owner = payable(msg.sender); + } + + function withdraw() public { + // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal + // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); + + require(block.timestamp >= unlockTime, "You can't withdraw yet"); + require(msg.sender == owner, "You aren't the owner"); + + emit Withdrawal(address(this).balance, block.timestamp); + + owner.transfer(address(this).balance); + } +} diff --git a/tests/nodeos_eos_evm_server/contracts/Recursive.sol b/tests/nodeos_eos_evm_server/contracts/Recursive.sol new file mode 100644 index 0000000..dc399b2 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Recursive.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.7.0 <0.9.0; + +contract Recursive { + + event Call(uint256 _value); + function start(uint256 _depth) public { + emit Call(_depth); + if( _depth == 0 ) + return; + Recursive(this).start(_depth-1); + } +} \ No newline at end of file diff --git a/tests/nodeos_eos_evm_server/contracts/Storage.sol b/tests/nodeos_eos_evm_server/contracts/Storage.sol new file mode 100644 index 0000000..4797fb2 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Storage.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +/** + * @title Storage + * @dev Store & retrieve value in a variable + * @custom:dev-run-script ./scripts/deploy_with_ethers.ts + */ +contract Storage { + + uint256 number; + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } +} diff --git a/tests/nodeos_eos_evm_server/contracts/Token.sol b/tests/nodeos_eos_evm_server/contracts/Token.sol new file mode 100644 index 0000000..1d8b627 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/Token.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract Token is ERC20 { + constructor (string memory _name, string memory _symbol) ERC20(_name, _symbol) { + _mint(msg.sender, 1000000 * (10 ** uint256(decimals()))); + } +} diff --git a/tests/nodeos_eos_evm_server/contracts/WEOS.sol b/tests/nodeos_eos_evm_server/contracts/WEOS.sol new file mode 100644 index 0000000..7d51299 --- /dev/null +++ b/tests/nodeos_eos_evm_server/contracts/WEOS.sol @@ -0,0 +1,756 @@ +// Copyright (C) 2015, 2016, 2017 Dapphub + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pragma solidity >=0.4.22 <0.6; + +contract WEOS9 { + string public name = "Wrapped EOS"; + string public symbol = "WEOS"; + uint8 public decimals = 18; + + event Approval(address indexed src, address indexed guy, uint wad); + event Transfer(address indexed src, address indexed dst, uint wad); + event Deposit(address indexed dst, uint wad); + event Withdrawal(address indexed src, uint wad); + + mapping (address => uint) public balanceOf; + mapping (address => mapping (address => uint)) public allowance; + + function() external payable { + deposit(); + } + function deposit() public payable { + balanceOf[msg.sender] += msg.value; + emit Deposit(msg.sender, msg.value); + } + function withdraw(uint wad) public { + require(balanceOf[msg.sender] >= wad); + balanceOf[msg.sender] -= wad; + msg.sender.transfer(wad); + emit Withdrawal(msg.sender, wad); + } + + function totalSupply() public view returns (uint) { + return address(this).balance; + } + + function approve(address guy, uint wad) public returns (bool) { + allowance[msg.sender][guy] = wad; + emit Approval(msg.sender, guy, wad); + return true; + } + + function transfer(address dst, uint wad) public returns (bool) { + return transferFrom(msg.sender, dst, wad); + } + + function transferFrom(address src, address dst, uint wad) + public + returns (bool) + { + require(balanceOf[src] >= wad); + + if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) { + require(allowance[src][msg.sender] >= wad); + allowance[src][msg.sender] -= wad; + } + + balanceOf[src] -= wad; + balanceOf[dst] += wad; + + emit Transfer(src, dst, wad); + + return true; + } +} + + +/* + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + +*/ diff --git a/tests/nodeos_eos_evm_server/extract-logtime-cmd.sh b/tests/nodeos_eos_evm_server/extract-logtime-cmd.sh new file mode 100644 index 0000000..879040b --- /dev/null +++ b/tests/nodeos_eos_evm_server/extract-logtime-cmd.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo INIT,DECODE,RECOVER,EXECUTE,SAVE,CLEANUP,TOTAL +tail -f $1 | grep --line-buffered -Po "tx: \K\{(.*)\}" | jq -r '[.timelogs[0][1], .timelogs[1][1]-.timelogs[0][1], .timelogs[2][1]-.timelogs[1][1], .timelogs[3][1]-.timelogs[2][1], .timelogs[4][1]-.timelogs[3][1], .elapsed-.timelogs[4][1], .elapsed] | join(",")' diff --git a/tests/nodeos_eos_evm_server/hardhat.config.js b/tests/nodeos_eos_evm_server/hardhat.config.js new file mode 100644 index 0000000..a9ebda1 --- /dev/null +++ b/tests/nodeos_eos_evm_server/hardhat.config.js @@ -0,0 +1,369 @@ +require("@nomicfoundation/hardhat-toolbox"); +require("@nomiclabs/hardhat-web3"); +require("@onmychain/hardhat-uniswap-v2-deploy-plugin"); + +// task action function receives the Hardhat Runtime Environment as second argument +task("accounts", "Prints accounts", async (_, { web3 }) => { + console.log(await web3.eth.getAccounts()); +}); + +task("blockNumber", "Prints the current block number", async (_, { web3 }) => { + console.log(await web3.eth.getBlockNumber()); +}); + +task("gasPrice", "Prints the current gas price", async (_, { web3 }) => { + console.log(await web3.eth.getGasPrice()); +}); + +task("block", "Prints block") + .addParam("blocknum", "The block number") + .setAction(async (taskArgs) => { + const block = await ethers.provider.getBlockWithTransactions(taskArgs.blocknum); + console.log(block); +}); + +task("balance", "Prints an account's balance") + .addParam("account", "The account's address") + .setAction(async (taskArgs) => { + const balance = await ethers.provider.getBalance(taskArgs.account); + console.log(ethers.utils.formatEther(balance), "ETH"); +}); + +task("nonce", "Prints an account's nonce") + .addParam("account", "The account's address") + .setAction(async (taskArgs) => { + const nonce = await ethers.provider.getTransactionCount(taskArgs.account); + console.log(nonce); +}); + +task("native-transfer", "Send native tokens") + .addParam("from", "from account") + .addParam("to", "to account") + .addParam("amount", "amount to trasfer") + .setAction(async (taskArgs) => { + const signer = await ethers.getSigner(taskArgs.from); + const res = await signer.sendTransaction({ + to: taskArgs.to, + value: eth(taskArgs.amount) + }); + console.log(res.hash); +}); + + +task("transfer", "Send ERC20 tokens") + .addParam("from", "from account") + .addParam("to", "to account") + .addParam("contract", "ERC20 token address") + .addParam("amount", "amount to trasfer") + .setAction(async (taskArgs) => { + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.contract) + const res = await token.connect(await ethers.getSigner(taskArgs.from)).transfer(taskArgs.to, ethers.utils.parseEther(taskArgs.amount.toString())); + console.log(res.hash); +}); + +task("send-loop", "Send ERC20 token in a loop") + .addParam("contract", "Token contract address") + .setAction(async (taskArgs) => { + const accounts = await web3.eth.getAccounts(); + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.contract) + while(true) { + let res = []; + for(let source_index=0; source_index{ + console.log("txhash => ", r.hash); + }); + } +}); + +task("emit-event", "Emit event") + .addParam("from", "Sender address") + .addParam("contract", "Eventor contract address") + .addParam("id", "Deposit id") + .addParam("value", "Deposit value") + .setAction(async (taskArgs) => { + const Eventor = await ethers.getContractFactory('Eventor') + const eventor = Eventor.attach(taskArgs.contract).connect(await ethers.getSigner(taskArgs.from)); + + const res = await eventor.deposit( + ethers.utils.hexZeroPad(ethers.BigNumber.from(taskArgs.id).toHexString(), 32), + taskArgs.value + ); + console.log("############################################ EMIT #######"); +}); + +task("test-blockhash", "Test blockhash") + .addParam("contract", "Blockhash contract address") + .setAction(async (taskArgs) => { + const Blockhash = await ethers.getContractFactory('Blockhash') + const blockhash = Blockhash.attach(taskArgs.contract).connect(await ethers.getSigner(0)); + + const res = await blockhash.go(); + console.log("############################################ GO #######"); + console.log(res); +}); + +task("storage-loop", "Store incremental values to the storage contract") + .addParam("contract", "Token contract address") + .setAction(async (taskArgs) => { + const Storage = await ethers.getContractFactory('Storage') + const storage = Storage.attach(taskArgs.contract) + let value = 1; + while(true) { + const res = await storage.store(value, {gasLimit:50000}) + console.log("############################################ "+ value +" STORED #######"); + ++value; + } +}); + + +task("load-erc20", "Load erc20 tokens on every account") + .addParam("contract", "Token contract address") + .setAction(async (taskArgs) => { + const accounts = await web3.eth.getAccounts(); + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.contract); + + for(let i=0; i<7; ++i) { + const amount = ethers.utils.parseEther((1e6/8).toString()); + const r = await token.connect(await ethers.getSigner(0)).transfer(accounts[i+1], amount); + console.log(`0 => ${i+1} : ${r.hash}`); + } + + for(let i=0; i<10; ++i) { + const amount = ethers.utils.parseEther((1e6/8/10).toString()); + + let res = []; + for(let j=0; j<8; ++j) { + res.push(token.connect(await ethers.getSigner(j)).transfer(accounts[i*8+j], amount)); + } + + const r = await Promise.all(res); + console.log(`${i+1}/10`); + } +}); + +task("erc20-balance", "Prints erc20 balance") + .addParam("contract", "The erc20 contract address") + .addParam("account", "The account's address") + .setAction(async (taskArgs) => { + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.contract) + const balance = await token.balanceOf(taskArgs.account); + console.log(balance) +}); + +task("all-erc20-balance", "Prints erc20 balance of all accounts") + .addParam("contract", "The erc20 contract address") + .setAction(async (taskArgs) => { + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.contract) + const accounts = await web3.eth.getAccounts(); + + let res = [] + for(let i=0; i { + console.log(accounts[i], b); + }); + +}); + +function eth(n) { + return ethers.utils.parseEther(n.toString()); +} + +task("swap4eth", "Swap exact tokens for ETH") +.addParam("erc20", "The erc20 contract address") +.addParam("weth9", "The weth9 contract address") +.addParam("router", "The router contract address") +.setAction(async (taskArgs) => { + + const signer = await ethers.getSigner(0); + + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.erc20) + + const ROUTER = require("@uniswap/v2-periphery/build/UniswapV2Router02.json"); + const WETH9 = require("@uniswap/v2-periphery/build/WETH9.json"); + + const Router = new ethers.ContractFactory(ROUTER.abi, ROUTER.bytecode); + const router = Router.attach(taskArgs.router).connect(signer); + + const Weth9 = new ethers.ContractFactory(WETH9.abi, WETH9.bytecode); + const weth9 = Weth9.attach(taskArgs.weth9).connect(signer); + + //TODO: check allowance + await token.approve(router.address, eth(1)); + + const receipt = await router.swapExactTokensForETH( + eth(1), //amountIn + 0, //amountOutMin + [token.address, weth9.address], //path + signer.address, //to + Date.now() + 1000*60*10, + ); + + console.log(receipt.hash); +}); + +task("approve", "") +.addParam("erc20", "erc20 contract") +.addParam("router", "The router contract address") +.addParam("amount", "amount to approve") +.setAction(async (taskArgs) => { + const signer = await ethers.getSigner(0); + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.erc20); + + const ROUTER = require("@uniswap/v2-periphery/build/UniswapV2Router02.json"); + const Router = new ethers.ContractFactory(ROUTER.abi, ROUTER.bytecode); + const router = Router.attach(taskArgs.router).connect(signer); + + const receipt = await token.approve(router.address, eth(taskArgs.amount)); + console.log(receipt.hash); +}); + +task("swap", "swap two erc20") +.addParam("path", "erc20 contract address path") +.addParam("router", "The router contract address") +.addParam("amount", "Amount-in") +.setAction(async (taskArgs) => { + const signer = await ethers.getSigner(0); + + const Token = await ethers.getContractFactory('Token') + + var tokens = []; + taskArgs.path.split(',').forEach((address) => { + tokens.push({token:Token.attach(address)}) + }); + + const ROUTER = require("@uniswap/v2-periphery/build/UniswapV2Router02.json"); + const WETH9 = require("@uniswap/v2-periphery/build/WETH9.json"); + + const Router = new ethers.ContractFactory(ROUTER.abi, ROUTER.bytecode); + const router = Router.attach(taskArgs.router).connect(signer); + + const receipt = await router.swapExactTokensForTokens( + eth(taskArgs.amount), //amountIn + 0, //amountOutMin + taskArgs.path.split(','), //path + signer.address, //to + Date.now() + 1000*60*10, + ); + + console.log(receipt.hash); +}); + + +task("add-liquidity", "Adds liquidity to an ERC-20⇄WETH pool with ETH") + .addParam("weth9", "The weth9 contract address") + .addParam("erc20", "The erc20 contract address") + .addParam("router", "The router contract address") + .setAction(async (taskArgs) => { + const signer = await ethers.getSigner(0); + //console.log(signer); + + const Token = await ethers.getContractFactory('Token') + const token = Token.attach(taskArgs.erc20) + + const ROUTER = require("@uniswap/v2-periphery/build/UniswapV2Router02.json"); + const WETH9 = require("@uniswap/v2-periphery/build/WETH9.json"); + + //await ethers.getSigner + const Router = new ethers.ContractFactory(ROUTER.abi, ROUTER.bytecode); + const router = Router.attach(taskArgs.router).connect(signer); + + const Weth9 = new ethers.ContractFactory(WETH9.abi, WETH9.bytecode); + const weth9 = Weth9.attach(taskArgs.weth9).connect(signer); + + const AMOUNT_WETH9 = eth(1000); + const AMOUNT_TOKEN = eth(1000); + + const r1 = await weth9.approve(router.address, AMOUNT_WETH9); + const r2 = await token.approve(router.address, AMOUNT_TOKEN); + + const receipt = await router.addLiquidityETH( + token.address, + eth(1000), + eth(1000), + eth(100), + signer.address, + ethers.constants.MaxUint256, + { value: eth(1000) } + ); + + console.log(receipt.hash); + +}); + +task("call-recursive", "Call recursive contract") + .addParam("contract", "The contract address") + .addParam("depth", "Call depth") + .setAction(async (taskArgs) => { + const signer = await ethers.getSigner(0); + //console.log(signer); + + const Recursive = await ethers.getContractFactory('Recursive') + const recursive = Recursive.attach(taskArgs.contract) + + const receipt = await recursive.start(taskArgs.depth); + console.log(receipt.hash); +}); + + + +/** @type import('hardhat/config').HardhatUserConfig */ +module.exports = { + defaultNetwork: "EOSEVMLocalTestnet", + networks: { + EOSEVMLocalTestnet: { + url: "http://localhost:5000", + accounts: { + mnemonic: "test test test test test test test test test test test junk", + path: "m/44'/60'/0'/0", + initialIndex: 0, + count: 80, + passphrase: "", + }, + }, + EOSEVMTestnet: { + url: "https://api.testnet.evm.eosnetwork.com", + accounts: { + mnemonic: "test test test test test test test test test test test junk", + path: "m/44'/60'/0'/0", + initialIndex: 0, + count: 80, + passphrase: "", + }, + } + }, + solidity: { + compilers : [ + { + version: "0.8.17", + }, + { + version: "0.5.16", + settings: { + "optimizer": { + "enabled": false, + "runs": 200, + } + }, + } + ] + } +}; diff --git a/tests/nodeos_eos_evm_server/package.json b/tests/nodeos_eos_evm_server/package.json new file mode 100644 index 0000000..4d1f85b --- /dev/null +++ b/tests/nodeos_eos_evm_server/package.json @@ -0,0 +1,23 @@ +{ + "devDependencies": { + "@onmychain/hardhat-uniswap-v2-deploy-plugin": "^1.0.4", + "@ethersproject/abi": "^5.4.7", + "@ethersproject/providers": "^5.4.7", + "@nomicfoundation/hardhat-chai-matchers": "^1.0.0", + "@nomicfoundation/hardhat-network-helpers": "^1.0.0", + "@nomicfoundation/hardhat-toolbox": "^2.0.0", + "@nomiclabs/hardhat-ethers": "^2.0.0", + "@nomiclabs/hardhat-etherscan": "^3.0.0", + "@nomiclabs/hardhat-web3": "^2.0.0", + "@openzeppelin/contracts": "^4.8.0", + "@typechain/ethers-v5": "^10.1.0", + "@typechain/hardhat": "^6.1.2", + "chai": "^4.2.0", + "ethers": "^5.4.7", + "hardhat": "^2.12.2", + "hardhat-gas-reporter": "^1.0.8", + "solidity-coverage": "^0.8.0", + "typechain": "^8.1.0", + "web3": "^1.8.0" + } +} diff --git a/tests/nodeos_eos_evm_server/performance-measurements-0.5.0.md b/tests/nodeos_eos_evm_server/performance-measurements-0.5.0.md new file mode 100644 index 0000000..9b93a2d --- /dev/null +++ b/tests/nodeos_eos_evm_server/performance-measurements-0.5.0.md @@ -0,0 +1,42 @@ +### EVM 0.5.0 performance measurements + +The numbers presented in the table below are derived from an analysis performed on the EVM transaction execution inside the EVM runtime contract following the instructions in the [PERFORMANCE](PERFORMANCE.md) document. + +The detailed spreadsheet can be accessed at [this link](https://docs.google.com/spreadsheets/d/1AcfoAmHvSWM6iv2zMpj81Erm0mH0gb28Zjve8d1Zjtc/edit?usp=sharing). + +Each column on the spreadsheet corresponds to a different aspect of the transaction processing time: + +- **Init**: This measures the time it takes from when the transaction is received by the chain controller until control is passed to the smart contract. + +- **Decode**: Time taken to decode the EVM transaction. + +- **Recover**: Time taken to recover the sender of the EVM transaction. + +- **Execute**: This records the actual transaction execution time. + +- **Save**: This column captures the duration of the finalization phase where the changes are committed to the blockchain state. + +- **Cleanup**: This measures the time taken to tear down the execution environment once the transaction has been processed. + +- **Total**: The sum of all the times recorded (time billed by the chain) + +Below is a table with the best times recorded in microseconds (us) for `eos-vm-jit` and `eos-vm-jit (OC)`: + +```markdown + | eos-vm-jit | eos-vm-jit (OC) | +|:-----------------:|:----------:|:---------------:| +| native transfer | 167 us | 124 us | +| erc20 transfer | 343 us | 171 us | +| uniswap v2 swap | 1602 us | 424 us | +``` + +#### Measurement Environment + +The measurements for this analysis were taken on a machine with the following specifications: + +- **CPU**: Intel(R) Xeon(R) E-2286G @ 4.00GHz +- **Memory**: 32GB RAM +- **Operating System**: Ubuntu 22.04 + +The version of Leap used for these tests was `3.2.2-logtime`. + diff --git a/tests/nodeos_eos_evm_server/scripts/deploy-blockhash.js b/tests/nodeos_eos_evm_server/scripts/deploy-blockhash.js new file mode 100644 index 0000000..a39d5bd --- /dev/null +++ b/tests/nodeos_eos_evm_server/scripts/deploy-blockhash.js @@ -0,0 +1,25 @@ +// We require the Hardhat Runtime Environment explicitly here. This is optional +// but useful for running the script in a standalone fashion through `node