diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py index 077bbd71a1..896f74e246 100755 --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -253,7 +253,7 @@ def run_test(self): while current_height + 1 > self.nodes[3].getblockcount(): block_hashes.extend(self.generatetoaddress( self.nodes[3], - nblocks=min(10, current_height + 1 - self.nodes[3].getblockcount()), + nblocks=10, # new address to avoid mining a block that has just been invalidated address=getnewdestination()[2], sync_fun=self.no_op, diff --git a/test/functional/qtum_evm_create2.py b/test/functional/qtum_evm_create2.py index fd29110ee3..6159cdb0aa 100755 --- a/test/functional/qtum_evm_create2.py +++ b/test/functional/qtum_evm_create2.py @@ -52,15 +52,27 @@ def assert_state(self, node, gas, gas_price, gas_used, value, excepted): txids = block['tx'] coinbase_tx = node.getrawtransaction(txids[0], True, blockhash) call_tx = node.getrawtransaction(txids[1], True, blockhash) - input_tx = node.decoderawtransaction(node.gettransaction(call_tx['vin'][0]['txid'])['hex']) - sender_utxo = input_tx['vout'][call_tx['vin'][0]['vout']] - sender_address = sender_utxo['scriptPubKey']['address'] for op_call_vout_index in range(len(call_tx['vout'])): - if call_tx['vout'][op_call_vout_index]['scriptPubKey']['type'] == 'call_sender': + if call_tx['vout'][op_call_vout_index]['scriptPubKey']['type'] in ['call', 'call_sender']: + + sender_utxo = input_tx['vout'][call_tx['vin'][0]['vout']] + sender_address = sender_utxo['scriptPubKey']['address'] + vin0_output = 'OP_DUP OP_HASH160 ' + p2pkh_to_hex_hash(sender_address) + ' OP_EQUALVERIFY OP_CHECKSIG' + + if call_tx['vout'][op_call_vout_index]['scriptPubKey']['type'] == 'call_sender': + sender_utxo = { + 'scriptPubKey': { + 'asm': '' + } + } + sender_hex = call_tx['vout'][op_call_vout_index]['scriptPubKey']['asm'].split(" ")[1] + sender_address = hex_hash_to_p2pkh(sender_hex) + sender_utxo['scriptPubKey']['asm'] = 'OP_DUP OP_HASH160 ' + sender_hex + ' OP_EQUALVERIFY OP_CHECKSIG' + break - + # Check that the transaction receipt is correct receipt = node.gettransactionreceipt(call_tx['txid'])[0] assert_equal(receipt['gasUsed'], gas_used) diff --git a/test/functional/qtum_evm_globals.py b/test/functional/qtum_evm_globals.py index 145cf720ae..bd5224e229 100755 --- a/test/functional/qtum_evm_globals.py +++ b/test/functional/qtum_evm_globals.py @@ -34,20 +34,23 @@ def verify_evm_globals_test(self, use_staking=False): self.node.sendtoaddress(sender, 1) self.node.generate(1) """ - 9950fc69 blockblockhash(uint256) - 18b66ea3 blockcoinbase() - 5df32c47 blockdifficulty() - 805f6831 blockgaslimit() - 05062247 blocknumber() - 8182a11f blocktimestamp() - e9ac31f2 msgdata() - 522a3926 msggas() - 61c99b92 msgsender() - 96acd236 msgsig() - f8184f73 msgvalue() - cc5ea9ad setGlobals() - d76c09ad txgasprice() - 2c7622b0 txorigin() + Function signatures: + + 9950fc69: blockblockhash(uint256) + 18b66ea3: blockcoinbase() + 5df32c47: blockdifficulty() + 805f6831: blockgaslimit() + 05062247: blocknumber() + 8182a11f: blocktimestamp() + cd84980e: chainid() + e9ac31f2: msgdata() + 522a3926: msggas() + 61c99b92: msgsender() + 96acd236: msgsig() + f8184f73: msgvalue() + cc5ea9ad: setGlobals() + d76c09ad: txgasprice() + 2c7622b0: txorigin() """ self.node.sendtocontract(self.contract_address, "cc5ea9ad", 1, 20000000, QTUM_MIN_GAS_PRICE/COIN, sender) @@ -117,6 +120,10 @@ def verify_evm_globals_test(self, use_staking=False): # block.timestamp print(' block.timestamp') assert_equal(block['time'], int(self.get_contract_call_output("8182a11f"), 16)) + + # block.chainid + print(' block.chainid') + assert_equal(8890, int(self.get_contract_call_output("cd84980e"), 16)) # msg.gas print(' msg.gas') @@ -143,7 +150,6 @@ def verify_evm_globals_test(self, use_staking=False): assert_equal(sender_pkh, self.get_contract_call_output("2c7622b0")[24:]) self.sync_all() - def run_test(self): self.node = self.nodes[0] self.connect_nodes(0, 1) @@ -151,9 +157,8 @@ def run_test(self): generatesynchronized(self.node, 10 + COINBASE_MATURITY, address, self.nodes) """ - pragma solidity ^0.4.12; - - + pragma solidity >=0.8.0; + contract TestEVM { address public blockcoinbase; mapping(uint => bytes32) public blockblockhash; @@ -168,46 +173,48 @@ def run_test(self): uint public msgvalue; uint public txgasprice; address public txorigin; - - function setGlobals() payable { + uint public chainid; + + function setGlobals() public payable { for(uint i = 0; i <= 257; ++i) { - blockblockhash[block.number - i] = block.blockhash(block.number - i); + blockblockhash[block.number - i] = blockhash(block.number - i); } - + blockcoinbase = block.coinbase; - - blockdifficulty = block.difficulty; - + + blockdifficulty = block.prevrandao; + blockgaslimit = block.gaslimit; blocknumber = block.number; - + blocktimestamp = block.timestamp; - + + chainid = block.chainid; + msgdata = msg.data; - - msggas = msg.gas; - + + msggas = gasleft(); + msgsender = msg.sender; - + msgsig = msg.sig; - + msgvalue = msg.value; - + txgasprice = tx.gasprice; - + txorigin = tx.origin; } } + """ - bytecode = "6060604052341561000f57600080fd5b5b6108298061001f6000396000f300606060405236156100ce576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305062247146100d357806318b66ea3146100fc5780632c7622b014610151578063522a3926146101a65780635df32c47146101cf57806361c99b92146101f8578063805f68311461024d5780638182a11f1461027657806396acd2361461029f5780639950fc6914610306578063cc5ea9ad14610345578063d76c09ad1461034f578063e9ac31f214610378578063f8184f7314610407575b600080fd5b34156100de57600080fd5b6100e6610430565b6040518082815260200191505060405180910390f35b341561010757600080fd5b61010f610436565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561015c57600080fd5b61016461045b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101b157600080fd5b6101b9610481565b6040518082815260200191505060405180910390f35b34156101da57600080fd5b6101e2610487565b6040518082815260200191505060405180910390f35b341561020357600080fd5b61020b61048d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561025857600080fd5b6102606104b3565b6040518082815260200191505060405180910390f35b341561028157600080fd5b6102896104b9565b6040518082815260200191505060405180910390f35b34156102aa57600080fd5b6102b26104bf565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b341561031157600080fd5b61032760048080359060200190919050506104ee565b60405180826000191660001916815260200191505060405180910390f35b61034d610506565b005b341561035a57600080fd5b6103626106ae565b6040518082815260200191505060405180910390f35b341561038357600080fd5b61038b6106b4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cc5780820151818401525b6020810190506103b0565b50505050905090810190601f1680156103f95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561041257600080fd5b61041a610752565b6040518082815260200191505060405180910390f35b60045481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60025481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b60055481565b600860149054906101000a90047c01000000000000000000000000000000000000000000000000000000000281565b60016020528060005260406000206000915090505481565b6000600190505b61010081111515610545578043034060016000834303815260200190815260200160002081600019169055505b80600101905061050d565b416000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555044600281905550456003819055504360048190555042600581905550600036600691906105b3929190610758565b505a60078190555033600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000357fffffffff0000000000000000000000000000000000000000000000000000000016600860146101000a81548163ffffffff02191690837c010000000000000000000000000000000000000000000000000000000090040217905550346009819055503a600a8190555032600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b600a5481565b60068054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561074a5780601f1061071f5761010080835404028352916020019161074a565b820191906000526020600020905b81548152906001019060200180831161072d57829003601f168201915b505050505081565b60095481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061079957803560ff19168380011785556107c7565b828001600101855582156107c7579182015b828111156107c65782358255916020019190600101906107ab565b5b5090506107d491906107d8565b5090565b6107fa91905b808211156107f65760008160009055506001016107de565b5090565b905600a165627a7a7230582035fd01aecdb713f1bf582f346a4ffe69efe883d4c8744bbd5262505e0d13dfb20029" + bytecode = "608060405234801561000f575f80fd5b50610c258061001d5f395ff3fe6080604052600436106100e7575f3560e01c80638182a11f11610089578063cd84980e11610058578063cd84980e146102ab578063d76c09ad146102d5578063e9ac31f2146102ff578063f8184f7314610329576100e7565b80638182a11f1461021157806396acd2361461023b5780639950fc6914610265578063cc5ea9ad146102a1576100e7565b8063522a3926116100c5578063522a3926146101695780635df32c471461019357806361c99b92146101bd578063805f6831146101e7576100e7565b806305062247146100eb57806318b66ea3146101155780632c7622b01461013f575b5f80fd5b3480156100f6575f80fd5b506100ff610353565b60405161010c9190610652565b60405180910390f35b348015610120575f80fd5b50610129610359565b60405161013691906106aa565b60405180910390f35b34801561014a575f80fd5b5061015361037c565b60405161016091906106aa565b60405180910390f35b348015610174575f80fd5b5061017d6103a1565b60405161018a9190610652565b60405180910390f35b34801561019e575f80fd5b506101a76103a7565b6040516101b49190610652565b60405180910390f35b3480156101c8575f80fd5b506101d16103ad565b6040516101de91906106aa565b60405180910390f35b3480156101f2575f80fd5b506101fb6103d2565b6040516102089190610652565b60405180910390f35b34801561021c575f80fd5b506102256103d8565b6040516102329190610652565b60405180910390f35b348015610246575f80fd5b5061024f6103de565b60405161025c91906106fd565b60405180910390f35b348015610270575f80fd5b5061028b60048036038101906102869190610744565b6103f1565b6040516102989190610787565b60405180910390f35b6102a9610406565b005b3480156102b6575f80fd5b506102bf61059c565b6040516102cc9190610652565b60405180910390f35b3480156102e0575f80fd5b506102e96105a2565b6040516102f69190610652565b60405180910390f35b34801561030a575f80fd5b506103136105a8565b604051610320919061082a565b60405180910390f35b348015610334575f80fd5b5061033d610634565b60405161034a9190610652565b60405180910390f35b60045481565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60025481565b60085f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b60055481565b600860149054906101000a900460e01b81565b6001602052805f5260405f205f915090505481565b5f5b610101811161044f57804361041d9190610877565b4060015f834361042d9190610877565b81526020019081526020015f208190555080610448906108aa565b9050610408565b50415f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504460028190555045600381905550436004819055504260058190555046600c819055505f36600691826104c3929190610b22565b505a6007819055503360085f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505f357fffffffff0000000000000000000000000000000000000000000000000000000016600860146101000a81548163ffffffff021916908360e01c0217905550346009819055503a600a8190555032600b5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600c5481565b600a5481565b600680546105b590610955565b80601f01602080910402602001604051908101604052809291908181526020018280546105e190610955565b801561062c5780601f106106035761010080835404028352916020019161062c565b820191905f5260205f20905b81548152906001019060200180831161060f57829003601f168201915b505050505081565b60095481565b5f819050919050565b61064c8161063a565b82525050565b5f6020820190506106655f830184610643565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6106948261066b565b9050919050565b6106a48161068a565b82525050565b5f6020820190506106bd5f83018461069b565b92915050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6106f7816106c3565b82525050565b5f6020820190506107105f8301846106ee565b92915050565b5f80fd5b6107238161063a565b811461072d575f80fd5b50565b5f8135905061073e8161071a565b92915050565b5f6020828403121561075957610758610716565b5b5f61076684828501610730565b91505092915050565b5f819050919050565b6107818161076f565b82525050565b5f60208201905061079a5f830184610778565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156107d75780820151818401526020810190506107bc565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6107fc826107a0565b61080681856107aa565b93506108168185602086016107ba565b61081f816107e2565b840191505092915050565b5f6020820190508181035f83015261084281846107f2565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6108818261063a565b915061088c8361063a565b92508282039050818111156108a4576108a361084a565b5b92915050565b5f6108b48261063a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036108e6576108e561084a565b5b600182019050919050565b5f82905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061096c57607f821691505b60208210810361097f5761097e610928565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026109e17fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826109a6565b6109eb86836109a6565b95508019841693508086168417925050509392505050565b5f819050919050565b5f610a26610a21610a1c8461063a565b610a03565b61063a565b9050919050565b5f819050919050565b610a3f83610a0c565b610a53610a4b82610a2d565b8484546109b2565b825550505050565b5f90565b610a67610a5b565b610a72818484610a36565b505050565b5b81811015610a9557610a8a5f82610a5f565b600181019050610a78565b5050565b601f821115610ada57610aab81610985565b610ab484610997565b81016020851015610ac3578190505b610ad7610acf85610997565b830182610a77565b50505b505050565b5f82821c905092915050565b5f610afa5f1984600802610adf565b1980831691505092915050565b5f610b128383610aeb565b9150826002028217905092915050565b610b2c83836108f1565b67ffffffffffffffff811115610b4557610b446108fb565b5b610b4f8254610955565b610b5a828285610a99565b5f601f831160018114610b87575f8415610b75578287013590505b610b7f8582610b07565b865550610be6565b601f198416610b9586610985565b5f5b82811015610bbc57848901358255600182019150602085019450602081019050610b97565b86831015610bd95784890135610bd5601f891682610aeb565b8355505b6001600288020188555050505b5050505050505056fea2646970667358221220b2e1918d734a0a91404c986957651f9fc3b565ef079657229494c330769c740d64736f6c63430008150033" self.contract_address = self.node.createcontract(bytecode)['address'] print('verify globals in PoW blocks') self.verify_evm_globals_test(use_staking=True) self.sync_all() - return - #assert(False) generatesynchronized(self.node, 257, None, self.nodes) self.sync_all() @@ -223,10 +230,6 @@ def run_test(self): generatesynchronized(self.node, 257, None, self.nodes) self.sync_all() - print('verify globals in MPoS blocks') - generatesynchronized(self.node, 4999 - self.node.getblockcount(), None, self.nodes) - self.sync_blocks() - for n in self.nodes: n.setmocktime((self.node.getblock(self.node.getbestblockhash())['time']+100) & 0xfffffff0) diff --git a/test/functional/qtum_evm_shanghai_activation.py b/test/functional/qtum_evm_shanghai_activation.py new file mode 100755 index 0000000000..a27f1056d6 --- /dev/null +++ b/test/functional/qtum_evm_shanghai_activation.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * +from test_framework.script import * +from test_framework.p2p import * +from test_framework.address import * +from test_framework.qtum import * +import pprint +import subprocess +import time + +from decimal import Decimal + +pp = pprint.PrettyPrinter() + +class QtumEVMLondonTest(BitcoinTestFramework): + def set_test_params(self): + self.setup_clean_chain = True + self.num_nodes = 4 + shanghai_height=10000 + self.extra_args = [ + ['-txindex', '-logevents=1', '-staking=0','-shanghaiheight={}'.format(shanghai_height), '-addrindex'], + ['-txindex', '-logevents=1', '-staking=1', '-shanghaiheight={}'.format(shanghai_height)], + ['-txindex', '-logevents=1', '-staking=1', '-shanghaiheight={}'.format(shanghai_height)], + ['-txindex', '-logevents=1', '-staking=1', '-shanghaiheight={}'.format(shanghai_height)], + ] + + def skip_test_if_missing_module(self): + self.skip_if_no_wallet() + + def minemempool(self, node): + while node.getmempoolinfo()['size']>0: + generatesynchronized(node, 1) + + def run_test(self): + self.log.info("Setting up chain and nodes") + self.node = self.nodes[0] + for n in self.nodes: n.setmocktime(int(time.time())-10000) + + generatesynchronized(self.node, COINBASE_MATURITY + 20, None, self.nodes[0:(self.num_nodes-1)]) + + + self.node_addresses=[] + bytecode_qrc20 = "6080604052600860ff16600a620000179190620000f7565b7af316271c7fc3908a8bef464e3945ef7a25360a00000000000000006200003f919062000234565b6000553480156200004f57600080fd5b50600054600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550620002db565b6000808291508390505b6001851115620000ee57808604811115620000c657620000c56200029f565b5b6001851615620000d65780820291505b8081029050620000e685620002ce565b9450620000a6565b94509492505050565b6000620001048262000295565b9150620001118362000295565b9250620001407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000148565b905092915050565b6000826200015a57600190506200022d565b816200016a57600090506200022d565b81600181146200018357600281146200018e57620001c4565b60019150506200022d565b60ff841115620001a357620001a26200029f565b5b8360020a915084821115620001bd57620001bc6200029f565b5b506200022d565b5060208310610133831016604e8410600b8410161715620001fe5782820a905083811115620001f857620001f76200029f565b5b6200022d565b6200020d84848460016200009c565b925090508184048111156200022757620002266200029f565b5b81810290505b9392505050565b6000620002418262000295565b91506200024e8362000295565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156200028a57620002896200029f565b5b828202905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160011c9050919050565b610f5380620002eb6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80635a3b7e42116100665780635a3b7e421461015d57806370a082311461017b57806395d89b41146101ab578063a9059cbb146101c9578063dd62ed3e146101f95761009e565b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100f157806323b872dd1461010f578063313ce5671461013f575b600080fd5b6100ab610229565b6040516100b89190610ce0565b60405180910390f35b6100db60048036038101906100d69190610c00565b610262565b6040516100e89190610cc5565b60405180910390f35b6100f961045a565b6040516101069190610d22565b60405180910390f35b61012960048036038101906101249190610bb1565b610460565b6040516101369190610cc5565b60405180910390f35b6101476107d4565b6040516101549190610d3d565b60405180910390f35b6101656107d9565b6040516101729190610ce0565b60405180910390f35b61019560048036038101906101909190610b4c565b610812565b6040516101a29190610d22565b60405180910390f35b6101b361082a565b6040516101c09190610ce0565b60405180910390f35b6101e360048036038101906101de9190610c00565b610863565b6040516101f09190610cc5565b60405180910390f35b610213600480360381019061020e9190610b75565b610a5e565b6040516102209190610d22565b60405180910390f35b6040518060400160405280600881526020017f515243205445535400000000000000000000000000000000000000000000000081525081565b600082600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102cc90610d02565b60405180910390fd5b600083148061036057506000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b61036957600080fd5b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040516104479190610d22565b60405180910390a3600191505092915050565b60005481565b600083600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156104d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104ca90610d02565b60405180910390fd5b83600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610544576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161053b90610d02565b60405180910390fd5b6105ca600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205485610a83565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610693600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205485610a83565b600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061071f600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205485610ad0565b600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040516107bf9190610d22565b60405180910390a36001925050509392505050565b600881565b6040518060400160405280600981526020017f546f6b656e20302e31000000000000000000000000000000000000000000000081525081565b60016020528060005260406000206000915090505481565b6040518060400160405280600381526020017f515443000000000000000000000000000000000000000000000000000000000081525081565b600082600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156108d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108cd90610d02565b60405180910390fd5b61091f600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610a83565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109ab600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610ad0565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051610a4b9190610d22565b60405180910390a3600191505092915050565b6002602052816000526040600020602052806000526040600020600091509150505481565b600081831015610abc577f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b8183610ac89190610dca565b905092915050565b6000808284610adf9190610d74565b905083811015610b18577f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b8091505092915050565b600081359050610b3181610eef565b92915050565b600081359050610b4681610f06565b92915050565b600060208284031215610b5e57600080fd5b6000610b6c84828501610b22565b91505092915050565b60008060408385031215610b8857600080fd5b6000610b9685828601610b22565b9250506020610ba785828601610b22565b9150509250929050565b600080600060608486031215610bc657600080fd5b6000610bd486828701610b22565b9350506020610be586828701610b22565b9250506040610bf686828701610b37565b9150509250925092565b60008060408385031215610c1357600080fd5b6000610c2185828601610b22565b9250506020610c3285828601610b37565b9150509250929050565b610c4581610e10565b82525050565b6000610c5682610d58565b610c608185610d63565b9350610c70818560208601610e53565b610c7981610eb5565b840191505092915050565b6000610c91600f83610d63565b9150610c9c82610ec6565b602082019050919050565b610cb081610e3c565b82525050565b610cbf81610e46565b82525050565b6000602082019050610cda6000830184610c3c565b92915050565b60006020820190508181036000830152610cfa8184610c4b565b905092915050565b60006020820190508181036000830152610d1b81610c84565b9050919050565b6000602082019050610d376000830184610ca7565b92915050565b6000602082019050610d526000830184610cb6565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610d7f82610e3c565b9150610d8a83610e3c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610dbf57610dbe610e86565b5b828201905092915050565b6000610dd582610e3c565b9150610de083610e3c565b925082821015610df357610df2610e86565b5b828203905092915050565b6000610e0982610e1c565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015610e71578082015181840152602081019050610e56565b83811115610e80576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000601f19601f8301169050919050565b7f41646472657373206973204e554c4c0000000000000000000000000000000000600082015250565b610ef881610dfe565b8114610f0357600080fd5b50565b610f0f81610e3c565b8114610f1a57600080fd5b5056fea2646970667358221220428f0675eabb8d19af3d0c2868ed3d1faf18c135df79935059e8f6da0fba00e864736f6c63430008020033" + + create_contract = self.node.createcontract(bytecode_qrc20) + self.contract_address = create_contract['address'] + self.sender = create_contract['sender'] + self.minemempool(self.node) + self.log.info("Distributing coins and tokens") + balances=[] + for i in range(1, self.num_nodes): + self.node_addresses.append(self.nodes[i].getnewaddress()) + self.node.sendtoaddress(address=self.node_addresses[i-1], amount=40000) + self.node.qrc20transfer(self.contract_address, self.sender, self.node_addresses[i-1], "1000000") + balances.append({'address':self.node_addresses[i-1], 'amount':1000000}) + generatesynchronized(self.node, 6, None, self.nodes[0:(self.num_nodes-1)]) + self.nodes[i].splitutxosforaddress(self.node_addresses[i-1], 100, 100, 10000) + generatesynchronized(self.nodes[i], 6, None, self.nodes[0:(self.num_nodes-1)]) + + generatesynchronized(self.node, COINBASE_MATURITY+20, None, self.nodes[0:(self.num_nodes-1)]) + + for n in self.nodes: n.setmocktime(int(time.time())) + + shanghai_height = 4084 + + self.log.info("Restart nodes") + self.stop_nodes() + self.start_node(0, ['-txindex', '-logevents=1', '-staking=0', '-shanghaiheight={}'.format(shanghai_height), '-addrindex']) + for i in range(1, self.num_nodes): + self.start_node(i, ['-txindex', '-logevents=1', '-staking=1', '-shanghaiheight={}'.format(shanghai_height)]) + for i in range(1, self.num_nodes): + self.connect_nodes(i-1, i) + + self.log.info("Waiting for fork to activate (using PoS)") + printforkdone=False + printmempoolwait=False + while True: + for i in range(0, self.num_nodes): + if(not printforkdone and self.node.getblockcount() >= shanghai_height): + self.log.info("Fork active at height {}, generating more transactions".format(shanghai_height)) + printforkdone = True + if i>0 and self.node.getblockcount() <= shanghai_height+30: + self.node.qrc20transfer(self.contract_address, self.sender, self.node_addresses[i-1], "1000000") + balances[i-1]["amount"]+=1000000 + self.nodes[i].sendtoaddress(address=self.node_addresses[i-1], amount=777) + elif self.node.getblockcount() > shanghai_height+30 and printforkdone and not printmempoolwait: + self.log.info("Stopped transactions generation, waiting for mempool to be cleared") + printmempoolwait= True + mempoolclear= True; + for i in range(0, self.num_nodes): + if self.nodes[i].getmempoolinfo()['size']: mempoolclear= False; + if mempoolclear: break + time.sleep(3) + + self.log.info("Checking balances)") + for i in range(1, self.num_nodes): + assert_equal(Decimal(balances[i-1]["amount"]), Decimal(self.nodes[i].qrc20balanceof(self.contract_address, self.node_addresses[i-1]))) + +if __name__ == '__main__': + QtumEVMLondonTest().main() \ No newline at end of file diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index c11bb21804..1faa589b6b 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -81,6 +81,7 @@ # These tests are not run by default. # Longest test should go first, to favor running tests in parallel 'qtum_evm_london_activation.py', + 'qtum_evm_shanghai_activation.py', 'feature_pruning.py', 'feature_dbcrash.py' ]