From 9e286e1c337319f47b2b04e9e1022ac05470a296 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 13:32:47 +0100 Subject: [PATCH 1/9] updated tests --- tests/files/StateTests/stInitCodeTest.json | 870 ++++++++++++++++++ tests/files/StateTests/stRefundTest.json | 252 +++++ .../StateTests/stSystemOperationsTest.json | 2 +- tests/files/StateTests/stTransactionTest.json | 277 ++++++ tests/files/VMTests/vmArithmeticTest.json | 294 +++--- 5 files changed, 1547 insertions(+), 148 deletions(-) create mode 100644 tests/files/StateTests/stInitCodeTest.json create mode 100644 tests/files/StateTests/stRefundTest.json create mode 100644 tests/files/StateTests/stTransactionTest.json diff --git a/tests/files/StateTests/stInitCodeTest.json b/tests/files/StateTests/stInitCodeTest.json new file mode 100644 index 000000000..67aa42853 --- /dev/null +++ b/tests/files/StateTests/stInitCodeTest.json @@ -0,0 +1,870 @@ +{ + "CallRecursiveContract" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "04110d816c380812a427968ece99b1c963dfbce6" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x04110d816c380812a427968ece99b1c963dfbce6" + } + }, + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1", + "code" : "0x3060025560206000600039602060006000f0", + "nonce" : "1", + "storage" : { + "0x02" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" + } + }, + "0a517d755cebbf66312b30fff713666a9cb917e0" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x0a517d755cebbf66312b30fff713666a9cb917e0" + } + }, + "24dd378f51adc67a50e339e8031fe9bd4aafab36" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x24dd378f51adc67a50e339e8031fe9bd4aafab36" + } + }, + "293f982d000532a7861ab122bdc4bbfd26bf9030" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x293f982d000532a7861ab122bdc4bbfd26bf9030" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "2cf5732f017b0cf1b1f13a1478e10239716bf6b5" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x2cf5732f017b0cf1b1f13a1478e10239716bf6b5" + } + }, + "31c640b92c21a1f1465c91070b4b3b4d6854195f" : { + "balance" : "0", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "37f998764813b136ddf5a754f34063fd03065e36" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x37f998764813b136ddf5a754f34063fd03065e36" + } + }, + "37fa399a749c121f8a15ce77e3d9f9bec8020d7a" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x37fa399a749c121f8a15ce77e3d9f9bec8020d7a" + } + }, + "4f36659fa632310b6ec438dea4085b522a2dd077" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x4f36659fa632310b6ec438dea4085b522a2dd077" + } + }, + "62c01474f089b07dae603491675dc5b5748f7049" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x62c01474f089b07dae603491675dc5b5748f7049" + } + }, + "729af7294be595a0efd7d891c9e51f89c07950c7" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x729af7294be595a0efd7d891c9e51f89c07950c7" + } + }, + "83e3e5a16d3b696a0314b30b2534804dd5e11197" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x83e3e5a16d3b696a0314b30b2534804dd5e11197" + } + }, + "8703df2417e0d7c59d063caa9583cb10a4d20532" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x8703df2417e0d7c59d063caa9583cb10a4d20532" + } + }, + "8dffcd74e5b5923512916c6a64b502689cfa65e1" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x8dffcd74e5b5923512916c6a64b502689cfa65e1" + } + }, + "95a4d7cccb5204733874fa87285a176fe1e9e240" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x95a4d7cccb5204733874fa87285a176fe1e9e240" + } + }, + "99b2fcba8120bedd048fe79f5262a6690ed38c39" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x99b2fcba8120bedd048fe79f5262a6690ed38c39" + } + }, + "a4202b8b8afd5354e3e40a219bdc17f6001bf2cf" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xa4202b8b8afd5354e3e40a219bdc17f6001bf2cf" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "89999", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + }, + "a9647f4a0a14042d91dc33c0328030a7157c93ae" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xa9647f4a0a14042d91dc33c0328030a7157c93ae" + } + }, + "aa6cffe5185732689c18f37a7f86170cb7304c2a" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xaa6cffe5185732689c18f37a7f86170cb7304c2a" + } + }, + "aae4a2e3c51c04606dcb3723456e58f3ed214f45" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xaae4a2e3c51c04606dcb3723456e58f3ed214f45" + } + }, + "c37a43e940dfb5baf581a0b82b351d48305fc885" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xc37a43e940dfb5baf581a0b82b351d48305fc885" + } + }, + "d2571607e241ecf590ed94b12d87c94babe36db6" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xd2571607e241ecf590ed94b12d87c94babe36db6" + } + }, + "f735071cbee190d76b704ce68384fc21e389fbe7" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xf735071cbee190d76b704ce68384fc21e389fbe7" + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "0", + "code" : "0x3060025560206000600039602060006000f0", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x00", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + "CallTheContractToCreateContractWithInitCode" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "04110d816c380812a427968ece99b1c963dfbce6" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x04110d816c380812a427968ece99b1c963dfbce6" + } + }, + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "10001", + "code" : "0x3060025560206000600039602060006000f0", + "nonce" : "1", + "storage" : { + "0x02" : "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" + } + }, + "0a517d755cebbf66312b30fff713666a9cb917e0" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x0a517d755cebbf66312b30fff713666a9cb917e0" + } + }, + "24dd378f51adc67a50e339e8031fe9bd4aafab36" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x24dd378f51adc67a50e339e8031fe9bd4aafab36" + } + }, + "293f982d000532a7861ab122bdc4bbfd26bf9030" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x293f982d000532a7861ab122bdc4bbfd26bf9030" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "2cf5732f017b0cf1b1f13a1478e10239716bf6b5" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x2cf5732f017b0cf1b1f13a1478e10239716bf6b5" + } + }, + "31c640b92c21a1f1465c91070b4b3b4d6854195f" : { + "balance" : "0", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "37f998764813b136ddf5a754f34063fd03065e36" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x37f998764813b136ddf5a754f34063fd03065e36" + } + }, + "37fa399a749c121f8a15ce77e3d9f9bec8020d7a" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x37fa399a749c121f8a15ce77e3d9f9bec8020d7a" + } + }, + "4f36659fa632310b6ec438dea4085b522a2dd077" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x4f36659fa632310b6ec438dea4085b522a2dd077" + } + }, + "62c01474f089b07dae603491675dc5b5748f7049" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x62c01474f089b07dae603491675dc5b5748f7049" + } + }, + "729af7294be595a0efd7d891c9e51f89c07950c7" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x729af7294be595a0efd7d891c9e51f89c07950c7" + } + }, + "83e3e5a16d3b696a0314b30b2534804dd5e11197" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x83e3e5a16d3b696a0314b30b2534804dd5e11197" + } + }, + "8703df2417e0d7c59d063caa9583cb10a4d20532" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x8703df2417e0d7c59d063caa9583cb10a4d20532" + } + }, + "8dffcd74e5b5923512916c6a64b502689cfa65e1" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x8dffcd74e5b5923512916c6a64b502689cfa65e1" + } + }, + "95a4d7cccb5204733874fa87285a176fe1e9e240" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x95a4d7cccb5204733874fa87285a176fe1e9e240" + } + }, + "99b2fcba8120bedd048fe79f5262a6690ed38c39" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0x99b2fcba8120bedd048fe79f5262a6690ed38c39" + } + }, + "a4202b8b8afd5354e3e40a219bdc17f6001bf2cf" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xa4202b8b8afd5354e3e40a219bdc17f6001bf2cf" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "89999", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + }, + "a9647f4a0a14042d91dc33c0328030a7157c93ae" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xa9647f4a0a14042d91dc33c0328030a7157c93ae" + } + }, + "aa6cffe5185732689c18f37a7f86170cb7304c2a" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xaa6cffe5185732689c18f37a7f86170cb7304c2a" + } + }, + "aae4a2e3c51c04606dcb3723456e58f3ed214f45" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xaae4a2e3c51c04606dcb3723456e58f3ed214f45" + } + }, + "c37a43e940dfb5baf581a0b82b351d48305fc885" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xc37a43e940dfb5baf581a0b82b351d48305fc885" + } + }, + "d2571607e241ecf590ed94b12d87c94babe36db6" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xd2571607e241ecf590ed94b12d87c94babe36db6" + } + }, + "f735071cbee190d76b704ce68384fc21e389fbe7" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + "0x02" : "0xf735071cbee190d76b704ce68384fc21e389fbe7" + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "10000", + "code" : "0x3060025560206000600039602060006000f0", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x00", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + "CallTheContractToCreateEmptyContract" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1", + "code" : "0x602060006000f0", + "nonce" : "1", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "605", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "99394", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + }, + "d2571607e241ecf590ed94b12d87c94babe36db6" : { + "balance" : "0", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "0", + "code" : "0x602060006000f0", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x00", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "1" + } + }, + "NotEnoughCashContractCreation" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "2", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "2", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c6000396000f200600160008035811a8100", + "gasLimit" : "599", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + }, + "OutOfGasContractCreation" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "1770", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "8229", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c6000396000f200600160008035811a8100", + "gasLimit" : "590", + "gasPrice" : "3", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + }, + "TransactionContractCreation" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "599", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "99400", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c6000396000f200600160008035811a8100", + "gasLimit" : "599", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + }, + "TransactionCreateSuicideContract" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "1000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "8999", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c6000396000f200ff600160008035811a81", + "gasLimit" : "1000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + }, + "TransactionStopInitCode" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "599", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9400", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c600039600000f20000600160008035811a81", + "gasLimit" : "1000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + }, + "TransactionSuicideInitCode" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "0000000000000000000000000000000000000000" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "611", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9388", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "0x600a80600c6000396000fff2ffff600160008035811a81", + "gasLimit" : "1000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "1" + } + } +} \ No newline at end of file diff --git a/tests/files/StateTests/stRefundTest.json b/tests/files/StateTests/stRefundTest.json new file mode 100644 index 000000000..c558a2292 --- /dev/null +++ b/tests/files/StateTests/stRefundTest.json @@ -0,0 +1,252 @@ +{ + "refund_NoOOG_1" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "402", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "502", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "502", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, + "refund_OOG" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x01" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "500", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "500", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "500", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, + "refund_changeNonZeroStorage" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000010", + "code" : "0x6017600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x17" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "602", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "388", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6017600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + }, + "refund_getEtherBack" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000010", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "402", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "588", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6000600155", + "nonce" : "0", + "storage" : { + "0x01" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + } +} \ No newline at end of file diff --git a/tests/files/StateTests/stSystemOperationsTest.json b/tests/files/StateTests/stSystemOperationsTest.json index a74d32ae5..612331ae3 100644 --- a/tests/files/StateTests/stSystemOperationsTest.json +++ b/tests/files/StateTests/stSystemOperationsTest.json @@ -5827,4 +5827,4 @@ "value" : "100000" } } -} +} \ No newline at end of file diff --git a/tests/files/StateTests/stTransactionTest.json b/tests/files/StateTests/stTransactionTest.json new file mode 100644 index 000000000..0de850797 --- /dev/null +++ b/tests/files/StateTests/stTransactionTest.json @@ -0,0 +1,277 @@ +{ + "EmptyTransaction" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "", + "gasPrice" : "", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "" + } + }, + "TransactionFromCoinbaseNotEnoughFounds" : { + "env" : { + "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1100", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "600", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "502" + } + }, + "TransactionSendingToEmpty" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "500", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { + "balance" : "0", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "99500", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "500", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "" + } + }, + "TransactionSendingToZero" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "0000000000000000000000000000000000000000" : { + "balance" : "1", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "500", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "99499", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "5000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "0000000000000000000000000000000000000000", + "value" : "1" + } + }, + "TransactionToItself" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "500", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "99500", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "5000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "1" + } + }, + "TransactionToItselfNotEnoughFounds" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1101", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1101", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "600", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "502" + } + } +} \ No newline at end of file diff --git a/tests/files/VMTests/vmArithmeticTest.json b/tests/files/VMTests/vmArithmeticTest.json index 2cc165f5d..88d209dfa 100644 --- a/tests/files/VMTests/vmArithmeticTest.json +++ b/tests/files/VMTests/vmArithmeticTest.json @@ -12,12 +12,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -57,12 +57,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60047fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -102,12 +102,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "10000", @@ -146,12 +146,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000600001600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -190,12 +190,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600101600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -234,12 +234,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60026002600108600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9695", @@ -279,12 +279,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60026002600003600160000308600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9691", @@ -324,12 +324,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600660000308600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9693", @@ -369,12 +369,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600660000308600360056000030714600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9887", @@ -413,12 +413,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600660000308600360056000030614600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9687", @@ -458,12 +458,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036000036001600408600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9693", @@ -503,12 +503,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60026003600003600160040814600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9891", @@ -547,12 +547,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6002600504600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -592,12 +592,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6018601704600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -636,12 +636,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6018600004600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -680,12 +680,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6001600104600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -725,12 +725,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000600204600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -769,12 +769,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x600260020a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9695", @@ -814,12 +814,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9664", @@ -859,12 +859,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x637fffffff637fffffff0a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9692", @@ -904,12 +904,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x637fffffff60000a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9892", @@ -948,12 +948,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000637fffffff0a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -993,12 +993,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60016101010a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9695", @@ -1038,12 +1038,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x61010160010a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -1083,12 +1083,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x61010160020a600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9894", @@ -1127,12 +1127,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600206600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1172,12 +1172,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff06600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1217,12 +1217,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600006600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -1261,12 +1261,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000600306600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -1305,12 +1305,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600260000306600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -1350,12 +1350,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600202600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1395,12 +1395,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1440,12 +1440,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6017600002600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -1484,12 +1484,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6001601702600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1529,12 +1529,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f800000000000000000000000000000000000000000000000000000000000000002600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1574,12 +1574,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7f80000000000000000000000000000000000000000000000000000000000000007f800000000000000000000000000000000000000000000000000000000000000002600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -1618,12 +1618,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -1663,12 +1663,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60026002600109600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9895", @@ -1707,12 +1707,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036002600003600160000309600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9891", @@ -1751,12 +1751,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600560000309600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9693", @@ -1796,12 +1796,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600560000309600360056000030714600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9887", @@ -1840,12 +1840,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036001600560000309600360056000030614600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9687", @@ -1885,12 +1885,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60036000036001600509600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9693", @@ -1930,12 +1930,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60026003600003600160050914600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9891", @@ -1974,12 +1974,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60000305600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -2019,12 +2019,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -2064,12 +2064,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6004600003600260000305600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9892", @@ -2108,12 +2108,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6002600003600405600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -2153,12 +2153,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000600003600360000305600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9892", @@ -2197,12 +2197,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60000305600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9894", @@ -2241,12 +2241,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x62126af460500b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2286,12 +2286,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x600060000b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -2330,12 +2330,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60000b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2375,12 +2375,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2420,12 +2420,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2465,12 +2465,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60ff68f000000000000000010b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2510,12 +2510,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9896", @@ -2554,12 +2554,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x62122f6a60000b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2599,12 +2599,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x62126af460010b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2644,12 +2644,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6212faf460010b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2689,12 +2689,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x66f000000000000161ffff0b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2734,12 +2734,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x62122ff460000b600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -2779,12 +2779,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600003600560000307600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9692", @@ -2824,12 +2824,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600003600507600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -2869,12 +2869,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600560000307600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9694", @@ -2914,12 +2914,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600260000307600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9894", @@ -2958,12 +2958,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6000600260000307600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9894", @@ -3002,12 +3002,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x00", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "10000", @@ -3046,12 +3046,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6001601703600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -3091,12 +3091,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6003600203600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -3136,12 +3136,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x6017600003600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -3181,12 +3181,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600003600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -3226,12 +3226,12 @@ }, "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", "code" : "0x60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03600055", "data" : "0x", "gas" : "10000", "gasPrice" : "100000000000000", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "gas" : "9696", @@ -3258,4 +3258,4 @@ } } } -} \ No newline at end of file +} From db494170dc819b1eb0d267b6e1ab36c6cfb63569 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 15:18:13 +0100 Subject: [PATCH 2/9] Created generic message (easy for testing) --- cmd/mist/gui.go | 16 +++---- core/block_manager.go | 4 +- core/state_transition.go | 98 ++++++++++++++++++++++++++------------- core/transaction_pool.go | 17 +++---- core/types/transaction.go | 88 ++++++++++++++++++++++------------- core/vm_env.go | 10 ++-- miner/miner.go | 6 +-- xeth/hexface.go | 4 +- xeth/js_types.go | 10 ++-- xeth/pipe.go | 8 ++-- 10 files changed, 159 insertions(+), 102 deletions(-) diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 773688ffc..46f264f35 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -305,13 +305,13 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) { var ( ptx = xeth.NewJSTx(tx, pipe.World().State()) - send = nameReg.Storage(tx.Sender()) - rec = nameReg.Storage(tx.Recipient) + send = nameReg.Storage(tx.From()) + rec = nameReg.Storage(tx.To()) s, r string ) if tx.CreatesContract() { - rec = nameReg.Storage(tx.CreationAddress(pipe.World().State())) + rec = nameReg.Storage(core.AddressFromMessage(tx)) } if send.Len() != 0 { @@ -323,9 +323,9 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) { r = strings.Trim(rec.Str(), "\x00") } else { if tx.CreatesContract() { - r = ethutil.Bytes2Hex(tx.CreationAddress(pipe.World().State())) + r = ethutil.Bytes2Hex(core.AddressFromMessage(tx)) } else { - r = ethutil.Bytes2Hex(tx.Recipient) + r = ethutil.Bytes2Hex(tx.To()) } } ptx.Sender = s @@ -449,11 +449,11 @@ func (gui *Gui) update() { object := state.GetAccount(gui.address()) if bytes.Compare(tx.Sender(), gui.address()) == 0 { - object.SubAmount(tx.Value) + object.SubAmount(tx.Value()) gui.txDb.Put(tx.Hash(), tx.RlpEncode()) - } else if bytes.Compare(tx.Recipient, gui.address()) == 0 { - object.AddAmount(tx.Value) + } else if bytes.Compare(tx.To(), gui.address()) == 0 { + object.AddAmount(tx.Value()) gui.txDb.Put(tx.Hash(), tx.RlpEncode()) } diff --git a/core/block_manager.go b/core/block_manager.go index 794c87f52..aa845a007 100644 --- a/core/block_manager.go +++ b/core/block_manager.go @@ -111,7 +111,7 @@ done: // If we are mining this block and validating we want to set the logs back to 0 state.EmptyLogs() - txGas := new(big.Int).Set(tx.Gas) + txGas := new(big.Int).Set(tx.Gas()) cb := state.GetStateObject(coinbase.Address()) st := NewStateTransition(cb, tx, state, block) @@ -134,7 +134,7 @@ done: } txGas.Sub(txGas, st.gas) - cumulativeSum.Add(cumulativeSum, new(big.Int).Mul(txGas, tx.GasPrice)) + cumulativeSum.Add(cumulativeSum, new(big.Int).Mul(txGas, tx.GasPrice())) // Update the state with pending changes state.Update(txGas) diff --git a/core/state_transition.go b/core/state_transition.go index 820ba66e6..a6b654842 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -5,6 +5,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/vm" ) @@ -27,7 +29,7 @@ import ( */ type StateTransition struct { coinbase, receiver []byte - tx *types.Transaction + msg Message gas, gasPrice *big.Int value *big.Int data []byte @@ -35,10 +37,42 @@ type StateTransition struct { block *types.Block cb, rec, sen *state.StateObject + + Env vm.Environment } -func NewStateTransition(coinbase *state.StateObject, tx *types.Transaction, state *state.StateDB, block *types.Block) *StateTransition { - return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil} +type Message interface { + Hash() []byte + + CreatesContract() bool + + From() []byte + To() []byte + + GasValue() *big.Int + GasPrice() *big.Int + Gas() *big.Int + Value() *big.Int + + Nonce() uint64 + Data() []byte +} + +func AddressFromMessage(msg Message) []byte { + // Generate a new address + return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:] +} + +func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition { + return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil} +} + +func (self *StateTransition) VmEnv() vm.Environment { + if self.Env == nil { + self.Env = NewEnv(self.state, self.msg, self.block) + } + + return self.Env } func (self *StateTransition) Coinbase() *state.StateObject { @@ -49,17 +83,17 @@ func (self *StateTransition) Coinbase() *state.StateObject { self.cb = self.state.GetOrNewStateObject(self.coinbase) return self.cb } -func (self *StateTransition) Sender() *state.StateObject { +func (self *StateTransition) From() *state.StateObject { if self.sen != nil { return self.sen } - self.sen = self.state.GetOrNewStateObject(self.tx.Sender()) + self.sen = self.state.GetOrNewStateObject(self.msg.From()) return self.sen } -func (self *StateTransition) Receiver() *state.StateObject { - if self.tx != nil && self.tx.CreatesContract() { +func (self *StateTransition) To() *state.StateObject { + if self.msg != nil && self.msg.CreatesContract() { return nil } @@ -67,7 +101,7 @@ func (self *StateTransition) Receiver() *state.StateObject { return self.rec } - self.rec = self.state.GetOrNewStateObject(self.tx.Recipient) + self.rec = self.state.GetOrNewStateObject(self.msg.To()) return self.rec } @@ -87,41 +121,41 @@ func (self *StateTransition) AddGas(amount *big.Int) { func (self *StateTransition) BuyGas() error { var err error - sender := self.Sender() - if sender.Balance().Cmp(self.tx.GasValue()) < 0 { - return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.tx.GasValue(), sender.Balance()) + sender := self.From() + if sender.Balance().Cmp(self.msg.GasValue()) < 0 { + return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.msg.GasValue(), sender.Balance()) } coinbase := self.Coinbase() - err = coinbase.BuyGas(self.tx.Gas, self.tx.GasPrice) + err = coinbase.BuyGas(self.msg.Gas(), self.msg.GasPrice()) if err != nil { return err } - self.AddGas(self.tx.Gas) - sender.SubAmount(self.tx.GasValue()) + self.AddGas(self.msg.Gas()) + sender.SubAmount(self.msg.GasValue()) return nil } func (self *StateTransition) RefundGas() { - coinbase, sender := self.Coinbase(), self.Sender() - coinbase.RefundGas(self.gas, self.tx.GasPrice) + coinbase, sender := self.Coinbase(), self.From() + coinbase.RefundGas(self.gas, self.msg.GasPrice()) // Return remaining gas - remaining := new(big.Int).Mul(self.gas, self.tx.GasPrice) + remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice()) sender.AddAmount(remaining) } func (self *StateTransition) preCheck() (err error) { var ( - tx = self.tx - sender = self.Sender() + msg = self.msg + sender = self.From() ) // Make sure this transaction's nonce is correct - if sender.Nonce != tx.Nonce { - return NonceError(tx.Nonce, sender.Nonce) + if sender.Nonce != msg.Nonce() { + return NonceError(msg.Nonce(), sender.Nonce) } // Pre-pay gas / Buy gas of the coinbase account @@ -133,7 +167,7 @@ func (self *StateTransition) preCheck() (err error) { } func (self *StateTransition) TransitionState() (err error) { - statelogger.Debugf("(~) %x\n", self.tx.Hash()) + statelogger.Debugf("(~) %x\n", self.msg.Hash()) // XXX Transactions after this point are considered valid. if err = self.preCheck(); err != nil { @@ -141,8 +175,8 @@ func (self *StateTransition) TransitionState() (err error) { } var ( - tx = self.tx - sender = self.Sender() + msg = self.msg + sender = self.From() ) defer self.RefundGas() @@ -169,15 +203,15 @@ func (self *StateTransition) TransitionState() (err error) { } var ret []byte - vmenv := NewEnv(self.state, self.tx, self.block) + vmenv := self.VmEnv() var ref vm.ClosureRef - if tx.CreatesContract() { - self.rec = MakeContract(tx, self.state) + if msg.CreatesContract() { + self.rec = MakeContract(msg, self.state) - ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.tx.Data, self.gas, self.gasPrice, self.value) + ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value) ref.SetCode(ret) } else { - ret, err = vmenv.Call(self.Sender(), self.Receiver().Address(), self.tx.Data, self.gas, self.gasPrice, self.value) + ret, err = vmenv.Call(self.From(), self.To().Address(), self.msg.Data(), self.gas, self.gasPrice, self.value) } if err != nil { statelogger.Debugln(err) @@ -187,11 +221,11 @@ func (self *StateTransition) TransitionState() (err error) { } // Converts an transaction in to a state object -func MakeContract(tx *types.Transaction, state *state.StateDB) *state.StateObject { - addr := tx.CreationAddress(state) +func MakeContract(msg Message, state *state.StateDB) *state.StateObject { + addr := AddressFromMessage(msg) contract := state.GetOrNewStateObject(addr) - contract.InitCode = tx.Data + contract.InitCode = msg.Data() return contract } diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 36b0beb28..da91ec568 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -112,8 +112,8 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { return fmt.Errorf("No last block on the block chain") } - if len(tx.Recipient) != 0 && len(tx.Recipient) != 20 { - return fmt.Errorf("Invalid recipient. len = %d", len(tx.Recipient)) + if len(tx.To()) != 0 && len(tx.To()) != 20 { + return fmt.Errorf("Invalid recipient. len = %d", len(tx.To())) } v, _, _ := tx.Curve() @@ -124,15 +124,15 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { // Get the sender sender := pool.chainManager.State().GetAccount(tx.Sender()) - totAmount := new(big.Int).Set(tx.Value) + totAmount := new(big.Int).Set(tx.Value()) // Make sure there's enough in the sender's account. Having insufficient // funds won't invalidate this transaction but simple ignores it. if sender.Balance().Cmp(totAmount) < 0 { - return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.Sender()) + return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From()) } if tx.IsContract() { - if tx.GasPrice.Cmp(big.NewInt(minGasPrice)) < 0 { + if tx.GasPrice().Cmp(big.NewInt(minGasPrice)) < 0 { return fmt.Errorf("Gasprice too low, %s given should be at least %d.", tx.GasPrice, minGasPrice) } } @@ -160,10 +160,7 @@ func (self *TxPool) Add(tx *types.Transaction) error { self.addTransaction(tx) - tmp := make([]byte, 4) - copy(tmp, tx.Recipient) - - txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.Sender()[:4], tmp, tx.Value, tx.Hash()) + txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.From()[:4], tx.To()[:4], tx.Value, tx.Hash()) // Notify the subscribers go self.eventMux.Post(TxPreEvent{tx}) @@ -200,7 +197,7 @@ func (pool *TxPool) RemoveInvalid(state *state.StateDB) { tx := e.Value.(*types.Transaction) sender := state.GetAccount(tx.Sender()) err := pool.ValidateTransaction(tx) - if err != nil || sender.Nonce >= tx.Nonce { + if err != nil || sender.Nonce >= tx.Nonce() { pool.pool.Remove(e) } } diff --git a/core/types/transaction.go b/core/types/transaction.go index 63edef756..4b75d3abd 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" - "github.com/ethereum/go-ethereum/state" "github.com/obscuren/secp256k1-go" ) @@ -18,12 +17,12 @@ func IsContractAddr(addr []byte) bool { } type Transaction struct { - Nonce uint64 - Recipient []byte - Value *big.Int - Gas *big.Int - GasPrice *big.Int - Data []byte + nonce uint64 + recipient []byte + value *big.Int + gas *big.Int + gasPrice *big.Int + data []byte v byte r, s []byte @@ -32,11 +31,11 @@ type Transaction struct { } func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction { - return &Transaction{Recipient: nil, Value: value, Gas: gas, GasPrice: gasPrice, Data: script, contractCreation: true} + return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script, contractCreation: true} } func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction { - return &Transaction{Recipient: to, Value: value, GasPrice: gasPrice, Gas: gas, Data: data, contractCreation: IsContractAddr(to)} + return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data, contractCreation: IsContractAddr(to)} } func NewTransactionFromBytes(data []byte) *Transaction { @@ -54,20 +53,52 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction { } func (self *Transaction) GasValue() *big.Int { - return new(big.Int).Mul(self.Gas, self.GasPrice) + return new(big.Int).Mul(self.gas, self.gasPrice) } func (self *Transaction) TotalValue() *big.Int { v := self.GasValue() - return v.Add(v, self.Value) + return v.Add(v, self.value) } func (tx *Transaction) Hash() []byte { - data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data} + data := []interface{}{tx.Nonce, tx.gasPrice, tx.gas, tx.recipient, tx.Value, tx.Data} return crypto.Sha3(ethutil.NewValue(data).Encode()) } +func (self *Transaction) Data() []byte { + return self.data +} + +func (self *Transaction) Gas() *big.Int { + return self.gas +} + +func (self *Transaction) GasPrice() *big.Int { + return self.gasPrice +} + +func (self *Transaction) Value() *big.Int { + return self.value +} + +func (self *Transaction) Nonce() uint64 { + return self.nonce +} + +func (self *Transaction) SetNonce(nonce uint64) { + self.nonce = nonce +} + +func (self *Transaction) From() []byte { + return self.Sender() +} + +func (self *Transaction) To() []byte { + return self.recipient +} + func (tx *Transaction) CreatesContract() bool { return tx.contractCreation } @@ -77,11 +108,6 @@ func (tx *Transaction) IsContract() bool { return tx.CreatesContract() } -func (tx *Transaction) CreationAddress(state *state.StateDB) []byte { - // Generate a new address - return crypto.Sha3(ethutil.NewValue([]interface{}{tx.Sender(), tx.Nonce}).Encode())[12:] -} - func (tx *Transaction) Curve() (v byte, r []byte, s []byte) { v = tx.v r = ethutil.LeftPadBytes(tx.r, 32) @@ -136,7 +162,7 @@ func (tx *Transaction) Sign(privk []byte) error { } func (tx *Transaction) RlpData() interface{} { - data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data} + data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.recipient, tx.Value, tx.Data} // TODO Remove prefixing zero's @@ -156,18 +182,18 @@ func (tx *Transaction) RlpDecode(data []byte) { } func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) { - tx.Nonce = decoder.Get(0).Uint() - tx.GasPrice = decoder.Get(1).BigInt() - tx.Gas = decoder.Get(2).BigInt() - tx.Recipient = decoder.Get(3).Bytes() - tx.Value = decoder.Get(4).BigInt() - tx.Data = decoder.Get(5).Bytes() + tx.nonce = decoder.Get(0).Uint() + tx.gasPrice = decoder.Get(1).BigInt() + tx.gas = decoder.Get(2).BigInt() + tx.recipient = decoder.Get(3).Bytes() + tx.value = decoder.Get(4).BigInt() + tx.data = decoder.Get(5).Bytes() tx.v = byte(decoder.Get(6).Uint()) tx.r = decoder.Get(7).Bytes() tx.s = decoder.Get(8).Bytes() - if IsContractAddr(tx.Recipient) { + if IsContractAddr(tx.recipient) { tx.contractCreation = true } } @@ -188,12 +214,12 @@ func (tx *Transaction) String() string { S: 0x%x `, tx.Hash(), - len(tx.Recipient) == 0, + len(tx.recipient) == 0, tx.Sender(), - tx.Recipient, - tx.Nonce, - tx.GasPrice, - tx.Gas, + tx.recipient, + tx.nonce, + tx.gasPrice, + tx.gas, tx.Value, tx.Data, tx.v, @@ -221,5 +247,5 @@ func (s Transactions) GetRlp(i int) []byte { return ethutil.Rlp(s[i]) } type TxByNonce struct{ Transactions } func (s TxByNonce) Less(i, j int) bool { - return s.Transactions[i].Nonce < s.Transactions[j].Nonce + return s.Transactions[i].nonce < s.Transactions[j].nonce } diff --git a/core/vm_env.go b/core/vm_env.go index 9e1815188..0b6744972 100644 --- a/core/vm_env.go +++ b/core/vm_env.go @@ -11,26 +11,26 @@ import ( type VMEnv struct { state *state.StateDB block *types.Block - tx *types.Transaction + msg Message depth int } -func NewEnv(state *state.StateDB, tx *types.Transaction, block *types.Block) *VMEnv { +func NewEnv(state *state.StateDB, msg Message, block *types.Block) *VMEnv { return &VMEnv{ state: state, block: block, - tx: tx, + msg: msg, } } -func (self *VMEnv) Origin() []byte { return self.tx.Sender() } +func (self *VMEnv) Origin() []byte { return self.msg.From() } func (self *VMEnv) BlockNumber() *big.Int { return self.block.Number } func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash } func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase } func (self *VMEnv) Time() int64 { return self.block.Time } func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty } func (self *VMEnv) BlockHash() []byte { return self.block.Hash() } -func (self *VMEnv) Value() *big.Int { return self.tx.Value } +func (self *VMEnv) Value() *big.Int { return self.msg.Value() } func (self *VMEnv) State() *state.StateDB { return self.state } func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit } func (self *VMEnv) Depth() int { return self.depth } diff --git a/miner/miner.go b/miner/miner.go index dc69dddc0..f63096b63 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -237,8 +237,8 @@ func (self *Miner) finiliseTxs() types.Transactions { key := self.eth.KeyManager() for i, ltx := range self.localTxs { tx := types.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data) - tx.Nonce = state.GetNonce(self.Coinbase) - state.SetNonce(self.Coinbase, tx.Nonce+1) + tx.SetNonce(state.GetNonce(self.Coinbase)) + state.SetNonce(self.Coinbase, tx.Nonce()+1) tx.Sign(key.PrivateKey()) @@ -247,7 +247,7 @@ func (self *Miner) finiliseTxs() types.Transactions { // Faster than append for _, tx := range self.eth.TxPool().CurrentTransactions() { - if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 { + if tx.GasPrice().Cmp(self.MinAcceptedGasPrice) >= 0 { txs[actualSize] = tx actualSize++ } diff --git a/xeth/hexface.go b/xeth/hexface.go index 75ec5f43d..8fb42b4db 100644 --- a/xeth/hexface.go +++ b/xeth/hexface.go @@ -216,7 +216,7 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr return "", err } if types.IsContractAddr(to) { - return ethutil.Bytes2Hex(tx.CreationAddress(nil)), nil + return ethutil.Bytes2Hex(core.AddressFromMessage(tx)), nil } return ethutil.Bytes2Hex(tx.Hash()), nil @@ -229,7 +229,7 @@ func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) { return nil, err } - return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(self.World().State()), tx.Hash(), tx.Sender()), nil + return NewJSReciept(tx.CreatesContract(), core.AddressFromMessage(tx), tx.Hash(), tx.From()), nil } func (self *JSXEth) CompileMutan(code string) string { diff --git a/xeth/js_types.go b/xeth/js_types.go index da26439cf..2d6ee91bc 100644 --- a/xeth/js_types.go +++ b/xeth/js_types.go @@ -97,21 +97,21 @@ type JSTransaction struct { func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction { hash := ethutil.Bytes2Hex(tx.Hash()) - receiver := ethutil.Bytes2Hex(tx.Recipient) + receiver := ethutil.Bytes2Hex(tx.To()) if receiver == "0000000000000000000000000000000000000000" { - receiver = ethutil.Bytes2Hex(tx.CreationAddress(state)) + receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx)) } sender := ethutil.Bytes2Hex(tx.Sender()) createsContract := tx.CreatesContract() var data string if tx.CreatesContract() { - data = strings.Join(core.Disassemble(tx.Data), "\n") + data = strings.Join(core.Disassemble(tx.Data()), "\n") } else { - data = ethutil.Bytes2Hex(tx.Data) + data = ethutil.Bytes2Hex(tx.Data()) } - return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: receiver, Contract: tx.CreatesContract(), Gas: tx.Gas.String(), GasPrice: tx.GasPrice.String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data)} + return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value()), Address: receiver, Contract: tx.CreatesContract(), Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data())} } func (self *JSTransaction) ToString() string { diff --git a/xeth/pipe.go b/xeth/pipe.go index 1e4d0ec60..06820cc86 100644 --- a/xeth/pipe.go +++ b/xeth/pipe.go @@ -134,7 +134,7 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et state := self.chainManager.TransState() nonce := state.GetNonce(key.Address()) - tx.Nonce = nonce + tx.SetNonce(nonce) tx.Sign(key.PrivateKey) // Do some pre processing for our "pre" events and hooks @@ -150,7 +150,7 @@ func (self *XEth) Transact(key *crypto.KeyPair, to []byte, value, gas, price *et state.SetNonce(key.Address(), nonce+1) if contractCreation { - addr := tx.CreationAddress(self.World().State()) + addr := core.AddressFromMessage(tx) pipelogger.Infof("Contract addr %x\n", addr) } @@ -163,8 +163,8 @@ func (self *XEth) PushTx(tx *types.Transaction) ([]byte, error) { return nil, err } - if tx.Recipient == nil { - addr := tx.CreationAddress(self.World().State()) + if tx.To() == nil { + addr := core.AddressFromMessage(tx) pipelogger.Infof("Contract addr %x\n", addr) return addr, nil } From 5ad473d7581b92811c3a3e035274a82fc5568f57 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 15:33:22 +0100 Subject: [PATCH 3/9] Moved methods to messages --- cmd/mist/gui.go | 4 ++-- core/state_transition.go | 10 ++++++---- core/transaction_pool.go | 6 ------ core/types/transaction.go | 23 ++--------------------- xeth/hexface.go | 2 +- xeth/js_types.go | 6 +++--- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 46f264f35..7775889cc 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -310,7 +310,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) { s, r string ) - if tx.CreatesContract() { + if core.MessageCreatesContract(tx) { rec = nameReg.Storage(core.AddressFromMessage(tx)) } @@ -322,7 +322,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) { if rec.Len() != 0 { r = strings.Trim(rec.Str(), "\x00") } else { - if tx.CreatesContract() { + if core.MessageCreatesContract(tx) { r = ethutil.Bytes2Hex(core.AddressFromMessage(tx)) } else { r = ethutil.Bytes2Hex(tx.To()) diff --git a/core/state_transition.go b/core/state_transition.go index a6b654842..61c9558e3 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -44,8 +44,6 @@ type StateTransition struct { type Message interface { Hash() []byte - CreatesContract() bool - From() []byte To() []byte @@ -63,6 +61,10 @@ func AddressFromMessage(msg Message) []byte { return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:] } +func MessageCreatesContract(msg Message) bool { + return len(msg.To()) == 0 +} + func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition { return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil} } @@ -93,7 +95,7 @@ func (self *StateTransition) From() *state.StateObject { return self.sen } func (self *StateTransition) To() *state.StateObject { - if self.msg != nil && self.msg.CreatesContract() { + if self.msg != nil && MessageCreatesContract(self.msg) { return nil } @@ -205,7 +207,7 @@ func (self *StateTransition) TransitionState() (err error) { var ret []byte vmenv := self.VmEnv() var ref vm.ClosureRef - if msg.CreatesContract() { + if MessageCreatesContract(msg) { self.rec = MakeContract(msg, self.state) ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value) diff --git a/core/transaction_pool.go b/core/transaction_pool.go index da91ec568..58c2255a4 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -131,12 +131,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { return fmt.Errorf("Insufficient amount in sender's (%x) account", tx.From()) } - if tx.IsContract() { - if tx.GasPrice().Cmp(big.NewInt(minGasPrice)) < 0 { - return fmt.Errorf("Gasprice too low, %s given should be at least %d.", tx.GasPrice, minGasPrice) - } - } - // Increment the nonce making each tx valid only once to prevent replay // attacks diff --git a/core/types/transaction.go b/core/types/transaction.go index 4b75d3abd..21d455f2e 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -9,11 +9,8 @@ import ( "github.com/obscuren/secp256k1-go" ) -var ContractAddr = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - func IsContractAddr(addr []byte) bool { return len(addr) == 0 - //return bytes.Compare(addr, ContractAddr) == 0 } type Transaction struct { @@ -25,17 +22,14 @@ type Transaction struct { data []byte v byte r, s []byte - - // Indicates whether this tx is a contract creation transaction - contractCreation bool } func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction { - return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script, contractCreation: true} + return &Transaction{recipient: nil, value: value, gas: gas, gasPrice: gasPrice, data: script} } func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction { - return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data, contractCreation: IsContractAddr(to)} + return &Transaction{recipient: to, value: value, gasPrice: gasPrice, gas: gas, data: data} } func NewTransactionFromBytes(data []byte) *Transaction { @@ -99,15 +93,6 @@ func (self *Transaction) To() []byte { return self.recipient } -func (tx *Transaction) CreatesContract() bool { - return tx.contractCreation -} - -/* Deprecated */ -func (tx *Transaction) IsContract() bool { - return tx.CreatesContract() -} - func (tx *Transaction) Curve() (v byte, r []byte, s []byte) { v = tx.v r = ethutil.LeftPadBytes(tx.r, 32) @@ -192,10 +177,6 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) { tx.r = decoder.Get(7).Bytes() tx.s = decoder.Get(8).Bytes() - - if IsContractAddr(tx.recipient) { - tx.contractCreation = true - } } func (tx *Transaction) String() string { diff --git a/xeth/hexface.go b/xeth/hexface.go index 8fb42b4db..bfd2dddd9 100644 --- a/xeth/hexface.go +++ b/xeth/hexface.go @@ -229,7 +229,7 @@ func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) { return nil, err } - return NewJSReciept(tx.CreatesContract(), core.AddressFromMessage(tx), tx.Hash(), tx.From()), nil + return NewJSReciept(core.MessageCreatesContract(tx), core.AddressFromMessage(tx), tx.Hash(), tx.From()), nil } func (self *JSXEth) CompileMutan(code string) string { diff --git a/xeth/js_types.go b/xeth/js_types.go index 2d6ee91bc..62867d6a9 100644 --- a/xeth/js_types.go +++ b/xeth/js_types.go @@ -102,16 +102,16 @@ func NewJSTx(tx *types.Transaction, state *state.StateDB) *JSTransaction { receiver = ethutil.Bytes2Hex(core.AddressFromMessage(tx)) } sender := ethutil.Bytes2Hex(tx.Sender()) - createsContract := tx.CreatesContract() + createsContract := core.MessageCreatesContract(tx) var data string - if tx.CreatesContract() { + if createsContract { data = strings.Join(core.Disassemble(tx.Data()), "\n") } else { data = ethutil.Bytes2Hex(tx.Data()) } - return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value()), Address: receiver, Contract: tx.CreatesContract(), Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data())} + return &JSTransaction{ref: tx, Hash: hash, Value: ethutil.CurrencyToString(tx.Value()), Address: receiver, Contract: createsContract, Gas: tx.Gas().String(), GasPrice: tx.GasPrice().String(), Data: data, Sender: sender, CreatesContract: createsContract, RawData: ethutil.Bytes2Hex(tx.Data())} } func (self *JSTransaction) ToString() string { From 198cc69357a0f25ae486a041786e1239c6f5ab0f Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 21:58:26 +0100 Subject: [PATCH 4/9] Gas corrections and vm fixes --- core/block_manager.go | 2 +- core/state_transition.go | 73 ++++++++++++++++++++------------------- core/types/transaction.go | 9 ----- state/state.go | 30 ++++++---------- tests/helper/vm.go | 37 +++++++++++++++++--- tests/vm/gh_test.go | 26 +++++++++++++- vm/common.go | 2 +- vm/vm_debug.go | 20 +++++------ 8 files changed, 116 insertions(+), 83 deletions(-) diff --git a/core/block_manager.go b/core/block_manager.go index aa845a007..8d319f84e 100644 --- a/core/block_manager.go +++ b/core/block_manager.go @@ -115,7 +115,7 @@ done: cb := state.GetStateObject(coinbase.Address()) st := NewStateTransition(cb, tx, state, block) - err = st.TransitionState() + _, err = st.TransitionState() if err != nil { switch { case IsNonceErr(err): diff --git a/core/state_transition.go b/core/state_transition.go index 61c9558e3..34d8cca74 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -31,6 +31,7 @@ type StateTransition struct { coinbase, receiver []byte msg Message gas, gasPrice *big.Int + initialGas *big.Int value *big.Int data []byte state *state.StateDB @@ -47,7 +48,6 @@ type Message interface { From() []byte To() []byte - GasValue() *big.Int GasPrice() *big.Int Gas() *big.Int Value() *big.Int @@ -65,8 +65,12 @@ func MessageCreatesContract(msg Message) bool { return len(msg.To()) == 0 } +func MessageGasValue(msg Message) *big.Int { + return new(big.Int).Mul(msg.Gas(), msg.GasPrice()) +} + func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition { - return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil} + return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), new(big.Int), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil} } func (self *StateTransition) VmEnv() vm.Environment { @@ -78,33 +82,16 @@ func (self *StateTransition) VmEnv() vm.Environment { } func (self *StateTransition) Coinbase() *state.StateObject { - if self.cb != nil { - return self.cb - } - - self.cb = self.state.GetOrNewStateObject(self.coinbase) - return self.cb + return self.state.GetOrNewStateObject(self.coinbase) } func (self *StateTransition) From() *state.StateObject { - if self.sen != nil { - return self.sen - } - - self.sen = self.state.GetOrNewStateObject(self.msg.From()) - - return self.sen + return self.state.GetOrNewStateObject(self.msg.From()) } func (self *StateTransition) To() *state.StateObject { if self.msg != nil && MessageCreatesContract(self.msg) { return nil } - - if self.rec != nil { - return self.rec - } - - self.rec = self.state.GetOrNewStateObject(self.msg.To()) - return self.rec + return self.state.GetOrNewStateObject(self.msg.To()) } func (self *StateTransition) UseGas(amount *big.Int) error { @@ -124,8 +111,8 @@ func (self *StateTransition) BuyGas() error { var err error sender := self.From() - if sender.Balance().Cmp(self.msg.GasValue()) < 0 { - return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.msg.GasValue(), sender.Balance()) + if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 { + return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", MessageGasValue(self.msg), sender.Balance()) } coinbase := self.Coinbase() @@ -135,20 +122,12 @@ func (self *StateTransition) BuyGas() error { } self.AddGas(self.msg.Gas()) - sender.SubAmount(self.msg.GasValue()) + self.initialGas.Set(self.msg.Gas()) + sender.SubAmount(MessageGasValue(self.msg)) return nil } -func (self *StateTransition) RefundGas() { - coinbase, sender := self.Coinbase(), self.From() - coinbase.RefundGas(self.gas, self.msg.GasPrice()) - - // Return remaining gas - remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice()) - sender.AddAmount(remaining) -} - func (self *StateTransition) preCheck() (err error) { var ( msg = self.msg @@ -168,7 +147,7 @@ func (self *StateTransition) preCheck() (err error) { return nil } -func (self *StateTransition) TransitionState() (err error) { +func (self *StateTransition) TransitionState() (ret []byte, err error) { statelogger.Debugf("(~) %x\n", self.msg.Hash()) // XXX Transactions after this point are considered valid. @@ -204,7 +183,6 @@ func (self *StateTransition) TransitionState() (err error) { return } - var ret []byte vmenv := self.VmEnv() var ref vm.ClosureRef if MessageCreatesContract(msg) { @@ -231,3 +209,26 @@ func MakeContract(msg Message, state *state.StateDB) *state.StateObject { return contract } + +func (self *StateTransition) RefundGas() { + coinbaseSub := new(big.Int).Set(self.gas) + uhalf := new(big.Int).Div(self.GasUsed(), ethutil.Big2) + for addr, refs := range self.state.Refunds() { + for _, ref := range refs { + coinbaseSub.Add(self.gas, ref) + refund := ethutil.BigMin(uhalf, ref) + self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice())) + } + } + + coinbase, sender := self.Coinbase(), self.From() + coinbase.RefundGas(coinbaseSub, self.msg.GasPrice()) + + // Return remaining gas + remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice()) + sender.AddAmount(remaining) +} + +func (self *StateTransition) GasUsed() *big.Int { + return new(big.Int).Sub(self.initialGas, self.gas) +} diff --git a/core/types/transaction.go b/core/types/transaction.go index 21d455f2e..c64fb69f0 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -46,15 +46,6 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction { return tx } -func (self *Transaction) GasValue() *big.Int { - return new(big.Int).Mul(self.gas, self.gasPrice) -} - -func (self *Transaction) TotalValue() *big.Int { - v := self.GasValue() - return v.Add(v, self.value) -} - func (tx *Transaction) Hash() []byte { data := []interface{}{tx.Nonce, tx.gasPrice, tx.gas, tx.recipient, tx.Value, tx.Data} diff --git a/state/state.go b/state/state.go index ca3f2af9c..682e233c1 100644 --- a/state/state.go +++ b/state/state.go @@ -23,14 +23,14 @@ type StateDB struct { manifest *Manifest - refund map[string][]refund + refund map[string][]*big.Int logs Logs } // Create a new state from a given trie func New(trie *trie.Trie) *StateDB { - return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string][]refund)} + return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string][]*big.Int)} } func (self *StateDB) EmptyLogs() { @@ -55,12 +55,8 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int { return ethutil.Big0 } -type refund struct { - gas, price *big.Int -} - -func (self *StateDB) Refund(addr []byte, gas, price *big.Int) { - self.refund[string(addr)] = append(self.refund[string(addr)], refund{gas, price}) +func (self *StateDB) Refund(addr []byte, gas *big.Int) { + self.refund[string(addr)] = append(self.refund[string(addr)], gas) } func (self *StateDB) AddBalance(addr []byte, amount *big.Int) { @@ -273,23 +269,17 @@ func (s *StateDB) Sync() { func (self *StateDB) Empty() { self.stateObjects = make(map[string]*StateObject) - self.refund = make(map[string][]refund) + self.refund = make(map[string][]*big.Int) +} + +func (self *StateDB) Refunds() map[string][]*big.Int { + return self.refund } func (self *StateDB) Update(gasUsed *big.Int) { var deleted bool - // Refund any gas that's left - // XXX THIS WILL CHANGE IN POC8 - uhalf := new(big.Int).Div(gasUsed, ethutil.Big2) - for addr, refs := range self.refund { - for _, ref := range refs { - refund := ethutil.BigMin(uhalf, ref.gas) - - self.GetStateObject([]byte(addr)).AddBalance(refund.Mul(refund, ref.price)) - } - } - self.refund = make(map[string][]refund) + self.refund = make(map[string][]*big.Int) for _, stateObject := range self.stateObjects { if stateObject.remove { diff --git a/tests/helper/vm.go b/tests/helper/vm.go index 0c77e87fb..11bcedc49 100644 --- a/tests/helper/vm.go +++ b/tests/helper/vm.go @@ -44,6 +44,7 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues env.time = ethutil.Big(envValues["currentTimestamp"]).Int64() env.difficulty = ethutil.Big(envValues["currentDifficulty"]) env.gasLimit = ethutil.Big(envValues["currentGasLimit"]) + env.Gas = new(big.Int) return env } @@ -110,7 +111,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log return ret, vmenv.logs, vmenv.Gas, err } -func RunState(state *state.StateDB, env, tx map[string]string) ([]byte, state.Logs, *big.Int, error) { +func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.Logs, *big.Int, error) { var ( keyPair, _ = crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"]))) to = FromHex(tx["to"]) @@ -118,13 +119,39 @@ func RunState(state *state.StateDB, env, tx map[string]string) ([]byte, state.Lo gas = ethutil.Big(tx["gasLimit"]) price = ethutil.Big(tx["gasPrice"]) value = ethutil.Big(tx["value"]) + caddr = FromHex(env["currentCoinbase"]) ) - caller := state.GetOrNewStateObject(keyPair.Address()) + coinbase := statedb.GetOrNewStateObject(caddr) + coinbase.SetGasPool(ethutil.Big(env["currentGasLimit"])) - vmenv := NewEnvFromMap(state, env, tx) - vmenv.origin = caller.Address() - ret, err := vmenv.Call(caller, to, data, gas, price, value) + message := NewMessage(keyPair.Address(), to, data, value, gas, price) + Log.DebugDetailf("message{ to: %x, from %x, value: %v, gas: %v, price: %v }\n", message.to[:4], message.from[:4], message.value, message.gas, message.price) + st := core.NewStateTransition(coinbase, message, statedb, nil) + vmenv := NewEnvFromMap(statedb, env, tx) + vmenv.origin = keyPair.Address() + st.Env = vmenv + ret, err := st.TransitionState() + statedb.Update(vmenv.Gas) return ret, vmenv.logs, vmenv.Gas, err } + +type Message struct { + from, to []byte + value, gas, price *big.Int + data []byte +} + +func NewMessage(from, to, data []byte, value, gas, price *big.Int) Message { + return Message{from, to, value, gas, price, data} +} + +func (self Message) Hash() []byte { return nil } +func (self Message) From() []byte { return self.from } +func (self Message) To() []byte { return self.to } +func (self Message) GasPrice() *big.Int { return self.price } +func (self Message) Gas() *big.Int { return self.gas } +func (self Message) Value() *big.Int { return self.value } +func (self Message) Nonce() uint64 { return 0 } +func (self Message) Data() []byte { return self.data } diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index da5a41251..42dcc0ae1 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/tests/helper" ) @@ -76,11 +77,18 @@ func RunVmTest(p string, t *testing.T) { tests := make(map[string]VmTest) helper.CreateFileTests(t, p, &tests) + helper.Logger.SetLogLevel(5) for name, test := range tests { + if name != "ABAcalls1" { + continue + } statedb := state.New(helper.NewTrie()) for addr, account := range test.Pre { obj := StateObjectFromAccount(addr, account) statedb.SetStateObject(obj) + for a, v := range account.Storage { + obj.SetState(helper.FromHex(a), ethutil.NewValue(helper.FromHex(v))) + } } // XXX Yeah, yeah... @@ -129,6 +137,16 @@ func RunVmTest(p string, t *testing.T) { for addr, account := range test.Post { obj := statedb.GetStateObject(helper.FromHex(addr)) + if obj == nil { + continue + } + + if len(test.Exec) == 0 { + if obj.Balance().Cmp(ethutil.Big(account.Balance)) != 0 { + t.Errorf("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance())) + } + } + for addr, value := range account.Storage { v := obj.GetState(helper.FromHex(addr)).Bytes() vexp := helper.FromHex(value) @@ -149,6 +167,7 @@ func RunVmTest(p string, t *testing.T) { } } } + logger.Flush() } // I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail. @@ -212,7 +231,12 @@ func TestStateRecursiveCreate(t *testing.T) { RunVmTest(fn, t) } -func TestStateSpecialTest(t *testing.T) { +func TestStateSpecial(t *testing.T) { const fn = "../files/StateTests/stSpecialTest.json" RunVmTest(fn, t) } + +func TestStateRefund(t *testing.T) { + const fn = "../files/StateTests/stRefundTest.json" + RunVmTest(fn, t) +} diff --git a/vm/common.go b/vm/common.go index 3d6d377ca..529bbdeb1 100644 --- a/vm/common.go +++ b/vm/common.go @@ -37,7 +37,7 @@ var ( GasLog = big.NewInt(32) GasSha256 = big.NewInt(50) GasRipemd = big.NewInt(50) - GasEcrecover = big.NewInt(100) + GasEcrecover = big.NewInt(500) Pow256 = ethutil.BigPow(2, 256) diff --git a/vm/vm_debug.go b/vm/vm_debug.go index 9da832a79..d78aff4ce 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "math" "math/big" "github.com/ethereum/go-ethereum/crypto" @@ -112,7 +113,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * return closure.Return(nil), nil } - vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.env.Depth(), closure.Address(), closure.Gas, callData) + vmlogger.Debugf("(%d) (%x) %x gas: %v (d) %x\n", self.env.Depth(), caller.Address()[:4], closure.Address(), closure.Gas, callData) for { prevStep = step @@ -185,11 +186,11 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * // 0 => non 0 mult = ethutil.Big3 } else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 { - statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price) + statedb.Refund(caller.Address(), GasSStoreRefund) mult = ethutil.Big0 } else { - // non 0 => non 0 + // non 0 => non 0 (or 0 => 0) mult = ethutil.Big1 } gas.Set(new(big.Int).Mul(mult, GasSStore)) @@ -660,7 +661,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * cOff = 0 l = 0 } else if cOff+l > size { - l = 0 + l = uint64(math.Min(float64(cOff+l), float64(size))) } codeCopy := code[cOff : cOff+l] @@ -776,10 +777,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * val, loc := stack.Popn() statedb.SetState(closure.Address(), loc.Bytes(), val) - // Debug sessions are allowed to run without message - if closure.message != nil { - closure.message.AddStorageChange(loc.Bytes()) - } + closure.message.AddStorageChange(loc.Bytes()) self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes()) case JUMP: @@ -898,10 +896,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * return closure.Return(ret), nil case SUICIDE: - receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes()) + balance := statedb.GetBalance(closure.Address()) - receiver.AddAmount(statedb.GetBalance(closure.Address())) + self.Printf(" => (%x) %v", receiver.Address()[:4], balance) + + receiver.AddAmount(balance) statedb.Delete(closure.Address()) fallthrough From f7287c626e31e980d5b164935ae913db3855eb81 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 21:58:53 +0100 Subject: [PATCH 5/9] updated tests --- tests/files/StateTests/stRefundTest.json | 271 +++++++++++++++++++++++ tests/files/index.js | 7 +- 2 files changed, 277 insertions(+), 1 deletion(-) diff --git a/tests/files/StateTests/stRefundTest.json b/tests/files/StateTests/stRefundTest.json index c558a2292..08ae1fac8 100644 --- a/tests/files/StateTests/stRefundTest.json +++ b/tests/files/StateTests/stRefundTest.json @@ -1,4 +1,275 @@ { + "refund500" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x600154506002545060ff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655", + "nonce" : "0", + "storage" : { + "0x0a" : "0x8000000000000000000000000000000000000000000000000000000000000000", + "0x0b" : "0x0de0b6b3a7640000" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "592", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9408", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x600154506002545060ff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655", + "nonce" : "0", + "storage" : { + "0x01" : "0x01", + "0x02" : "0x01", + "0x03" : "0x01", + "0x04" : "0x01", + "0x05" : "0x01", + "0x06" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, + "refund50_1" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x60006001556000600255600060035560006004556000600555", + "nonce" : "0", + "storage" : { + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "255", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9745", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x60006001556000600255600060035560006004556000600555", + "nonce" : "0", + "storage" : { + "0x01" : "0x01", + "0x02" : "0x01", + "0x03" : "0x01", + "0x04" : "0x01", + "0x05" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, + "refund50_2" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6001600a556001600b5560006001556000600255600060035560006004556000600555", + "nonce" : "0", + "storage" : { + "0x0a" : "0x01", + "0x0b" : "0x01" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "614", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9386", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x6001600a556001600b5560006001556000600255600060035560006004556000600555", + "nonce" : "0", + "storage" : { + "0x01" : "0x01", + "0x02" : "0x01", + "0x03" : "0x01", + "0x04" : "0x01", + "0x05" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, + "refund600" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "logs" : [ + ], + "out" : "0x", + "post" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x600154506002545061ffff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655", + "nonce" : "0", + "storage" : { + "0x0b" : "0x0de0b6b3a7640000" + } + }, + "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { + "balance" : "492", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9508", + "code" : "0x", + "nonce" : "1", + "storage" : { + } + } + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "code" : "0x600154506002545061ffff60020a600a553031600b55600060015560006002556000600355600060045560006005556000600655", + "nonce" : "0", + "storage" : { + "0x01" : "0x01", + "0x02" : "0x01", + "0x03" : "0x01", + "0x04" : "0x01", + "0x05" : "0x01", + "0x06" : "0x01" + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "0x", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : "", + "gasLimit" : "10000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + }, "refund_NoOOG_1" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/index.js b/tests/files/index.js index 730107a27..34a03d8b2 100644 --- a/tests/files/index.js +++ b/tests/files/index.js @@ -8,12 +8,17 @@ module.exports = { trietestnextprev: require('./TrieTests/trietestnextprev'), txtest: require('./BasicTests/txtest'), StateTests: { + stExample: require('./StateTests/stExample.json'), + stInitCodeTest: require('./StateTests/stInitCodeTest.json'), + stLogTests: require('./StateTests/stLogTests.json'), stPreCompiledContracts: require('./StateTests/stPreCompiledContracts'), stRecursiveCreate: require('./StateTests/stRecursiveCreate'), stSpecial: require('./StateTests/stSpecialTest'), stSystemOperationsTest: require('./StateTests/stSystemOperationsTest'), + stTransactionTest: require('./StateTests/stTransactionTest') }, VMTests: { + vmRandom: require('./VMTests/RandomTests/randomTest'), vmArithmeticTest: require('./VMTests/vmArithmeticTest'), vmBitwiseLogicOperationTest: require('./VMTests/vmBitwiseLogicOperationTest'), vmBlockInfoTest: require('./VMTests/vmBlockInfoTest'), @@ -22,6 +27,6 @@ module.exports = { vmLogTest: require('./VMTests/vmLogTest'), vmPushDupSwapTest: require('./VMTests/vmPushDupSwapTest'), vmSha3Test: require('./VMTests/vmSha3Test'), - vmtests: require('./VMTests/vmtests'), + vmtests: require('./VMTests/vmtests') } }; From 332568379454dce6b1fb3c3e023a53d0c52cded0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 22:38:51 +0100 Subject: [PATCH 6/9] Fixed refund model --- core/state_transition.go | 10 ++++------ state/state.go | 17 ++++++++++------- tests/vm/gh_test.go | 8 ++++---- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 34d8cca74..9e81ddf28 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -213,12 +213,10 @@ func MakeContract(msg Message, state *state.StateDB) *state.StateObject { func (self *StateTransition) RefundGas() { coinbaseSub := new(big.Int).Set(self.gas) uhalf := new(big.Int).Div(self.GasUsed(), ethutil.Big2) - for addr, refs := range self.state.Refunds() { - for _, ref := range refs { - coinbaseSub.Add(self.gas, ref) - refund := ethutil.BigMin(uhalf, ref) - self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice())) - } + for addr, ref := range self.state.Refunds() { + refund := ethutil.BigMin(uhalf, ref) + coinbaseSub.Add(self.gas, refund) + self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice())) } coinbase, sender := self.Coinbase(), self.From() diff --git a/state/state.go b/state/state.go index 682e233c1..a8d611668 100644 --- a/state/state.go +++ b/state/state.go @@ -23,14 +23,14 @@ type StateDB struct { manifest *Manifest - refund map[string][]*big.Int + refund map[string]*big.Int logs Logs } // Create a new state from a given trie func New(trie *trie.Trie) *StateDB { - return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string][]*big.Int)} + return &StateDB{Trie: trie, stateObjects: make(map[string]*StateObject), manifest: NewManifest(), refund: make(map[string]*big.Int)} } func (self *StateDB) EmptyLogs() { @@ -56,7 +56,10 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int { } func (self *StateDB) Refund(addr []byte, gas *big.Int) { - self.refund[string(addr)] = append(self.refund[string(addr)], gas) + if self.refund[string(addr)] == nil { + self.refund[string(addr)] = new(big.Int) + } + self.refund[string(addr)].Add(self.refund[string(addr)], gas) } func (self *StateDB) AddBalance(addr []byte, amount *big.Int) { @@ -207,7 +210,7 @@ func (self *StateDB) Copy() *StateDB { } for addr, refund := range self.refund { - state.refund[addr] = refund + state.refund[addr] = new(big.Int).Set(refund) } logs := make(Logs, len(self.logs)) @@ -269,17 +272,17 @@ func (s *StateDB) Sync() { func (self *StateDB) Empty() { self.stateObjects = make(map[string]*StateObject) - self.refund = make(map[string][]*big.Int) + self.refund = make(map[string]*big.Int) } -func (self *StateDB) Refunds() map[string][]*big.Int { +func (self *StateDB) Refunds() map[string]*big.Int { return self.refund } func (self *StateDB) Update(gasUsed *big.Int) { var deleted bool - self.refund = make(map[string][]*big.Int) + self.refund = make(map[string]*big.Int) for _, stateObject := range self.stateObjects { if stateObject.remove { diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 42dcc0ae1..ca63b90d3 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -77,11 +77,11 @@ func RunVmTest(p string, t *testing.T) { tests := make(map[string]VmTest) helper.CreateFileTests(t, p, &tests) - helper.Logger.SetLogLevel(5) + //helper.Logger.SetLogLevel(5) for name, test := range tests { - if name != "ABAcalls1" { - continue - } + // if name != "refund50_1" { + // continue + // } statedb := state.New(helper.NewTrie()) for addr, account := range test.Pre { obj := StateObjectFromAccount(addr, account) From 4789084998553befa5db1bfe5a14881aa567cb9e Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 23:32:58 +0100 Subject: [PATCH 7/9] updated tests --- tests/vm/gh_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index ca63b90d3..10d63897d 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -77,11 +77,11 @@ func RunVmTest(p string, t *testing.T) { tests := make(map[string]VmTest) helper.CreateFileTests(t, p, &tests) - //helper.Logger.SetLogLevel(5) + helper.Logger.SetLogLevel(5) for name, test := range tests { - // if name != "refund50_1" { - // continue - // } + if name != "CallRecursiveBomb0" { + continue + } statedb := state.New(helper.NewTrie()) for addr, account := range test.Pre { obj := StateObjectFromAccount(addr, account) From 1e985f986569a68601b052c8949fc6f360e139d9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 23:59:40 +0100 Subject: [PATCH 8/9] Fixed casting error * big(bytes) == 0 when len(bytes) > 0 --- vm/vm_debug.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vm/vm_debug.go b/vm/vm_debug.go index d78aff4ce..708aada5b 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -181,11 +181,12 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price * var mult *big.Int y, x := stack.Peekn() - val := closure.GetStorage(x) - if val.BigInt().Cmp(ethutil.Big0) == 0 && len(y.Bytes()) > 0 { + //val := closure.GetStorage(x) + val := statedb.GetState(closure.Address(), x.Bytes()) + if len(val) == 0 && len(y.Bytes()) > 0 { // 0 => non 0 mult = ethutil.Big3 - } else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 { + } else if len(val) > 0 && len(y.Bytes()) == 0 { statedb.Refund(caller.Address(), GasSStoreRefund) mult = ethutil.Big0 From a7f4ade7114ee962110cb7c140e7ce7bd3f6664f Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 23:59:53 +0100 Subject: [PATCH 9/9] Fixed tests --- tests/vm/gh_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 10d63897d..1efda7fe0 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -77,11 +77,7 @@ func RunVmTest(p string, t *testing.T) { tests := make(map[string]VmTest) helper.CreateFileTests(t, p, &tests) - helper.Logger.SetLogLevel(5) for name, test := range tests { - if name != "CallRecursiveBomb0" { - continue - } statedb := state.New(helper.NewTrie()) for addr, account := range test.Pre { obj := StateObjectFromAccount(addr, account)