From 9e1f1f3dd7943eced26a7dca138b8f2c1f88c5f7 Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 24 Apr 2017 19:53:22 +0300 Subject: modexp tests --- .../stPreCompiledContracts/modexpFiller.json | 221 +++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json (limited to 'src/GeneralStateTestsFiller') diff --git a/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json b/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json new file mode 100644 index 000000000..7db520093 --- /dev/null +++ b/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json @@ -0,0 +1,221 @@ +{ + "modexp" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x20000", + "currentGasLimit" : "10000000000", + "currentNumber" : "1", + "currentTimestamp" : "1000", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "expect" : [ + { + "indexes" : { + "data" : -1, + "gas" : -1, + "value" : -1 + }, + "network" : [ "EIP150", "EIP158"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x00" + } + } + } + }, + { + "indexes" : { + "data" : [0,6,7], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x01" + } + } + } + }, + { + "indexes" : { + "data" : [1,5,8,9,10,12,13,15,18,19,20,21,22,23,24], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x00" + } + } + } + }, + { + "indexes" : { + "data" : [2], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x00", + "0x02" : "0x00" + } + } + } + }, + { + "indexes" : { + "data" : [3,4], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x3b01b01ac41f2d6e917c6d6a221ce793802469026d9ab7578fa2e79e4da6aaab" + } + } + } + }, + { + "indexes" : { + "data" : [11, 14], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x0100000000000000000000000000000000000000000000000000000000000000" + } + } + } + }, + { + "indexes" : { + "data" : [16], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x02000000000000000000000000000000000000000000000000000000000000" + } + } + } + }, + { + "indexes" : { + "data" : [17], + "gas" : -1, + "value" : -1 + }, + "network" : ["Metropolis"], + "result" : { + "1000000000000000000000000000000000000000" : { + "storage" : { + "0x01" : "0x01", + "0x02" : "0x0200000000000000000000000000000000000000000000000000000000000000" + } + } + } + } + ], + "pre" : { + "1000000000000000000000000000000000000000" : { + "balance" : "", + "code" : "{ (CALLDATACOPY 0 0 (CALLDATASIZE)) [[1]] (CALLCODE (GAS) 5 0 0 (CALLDATASIZE) 1000 32) [[2]](MLOAD 1000) }", + "nonce" : "0", + "storage" : { + } + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000000000000000000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : { + "data" : [ + "(BASE**EXPONENT) % MODULUS", + "0 - example: 3**(2**256 - 2**32 - 978) % (2**256 - 2**32 - 977).", + "1 - Would be parsed as a base of 0, exponent of 2**256 - 2**32 - 978 and modulus of 2**256 - 2**32 - 978, and so would return 0. Notice how if the length_of_BASE is 0, then it does not interpret any data as the base, instead immediately interpreting the next 32 bytes as length_of_EXPONENT.", + "2 - Would parse a base length of 0, a modulus length of 32, and an exponent length of 2**256 - 1, where the base is empty, the modulus is 2**256 - 2 and the exponent is (2**256 - 3) * 256**(2**256 - 33) (yes, that's a really big number). It would then immediately fail, as it's not possible to provide enough gas to make that computation.", + "3 - Would parse as a base of 3, an exponent of 65535, and a modulus of 2**255, and it would ignore the remaining 0x07 byte.", + "4 - Would also parse as a base of 3, an exponent of 65535 and a modulus of 2**255, as it attempts to grab 32 bytes for the modulus starting from 0x80, but then there is no further data so it right pads it with 31 zeroes.", + "5 - Missing values", + "6 - Empty value", + "7 - 0**0 % 0x80", + "8 - 0**0 % 0", + "9 - modlength zero", + "10 - 0**03 % 04", + "11 - 02**00 % 04", + "12 - 02**03 % 00", + "13 - **03 % 04", + "14 - 02** % 04", + "15 - 02**03 % ", + "16 - 02**03 % 06", + "17 - 02**03 % 0006", + "18,19,20 - Non-zero length mod, but passed calldata has not enough total length", + "21,21,22,23 - Non-zero length exp & mod, but passed data has only base and part of exp / only base", + "24 - Non-zero length base & exp & mod and no values in input data - interpreted as all zeroes" + ], + "data" : [ + "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", +"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", +"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" , +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff800000000000000000000000000000000000000000000000000000000000000007", +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff80", +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020038000000000000000000000000000000000000000000000000000000000000000", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000080", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000", +"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000101", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000304", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020004", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020300", +"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010304", +"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010204", +"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000203", +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030006", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020306", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002020300", +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030000", +"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020203", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002023003", +"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020230", +"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002" + ], + "gasLimit" : [ + "100000000" + ], + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "1000000000000000000000000000000000000000", + "value" : [ + "0" + ] + } + } +} -- cgit v1.2.3 From da0ac74f3652db88b1f15f68a4647350f3f540c3 Mon Sep 17 00:00:00 2001 From: Dimitry Date: Tue, 25 Apr 2017 14:13:17 +0300 Subject: modexp tests --- .../stPreCompiledContracts/modexpFiller.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/GeneralStateTestsFiller') diff --git a/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json b/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json index 7db520093..4074f49a1 100644 --- a/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json +++ b/src/GeneralStateTestsFiller/stPreCompiledContracts/modexpFiller.json @@ -91,7 +91,7 @@ }, { "indexes" : { - "data" : [11, 14], + "data" : [11, 14, 25, 26], "gas" : -1, "value" : -1 }, @@ -177,7 +177,9 @@ "17 - 02**03 % 0006", "18,19,20 - Non-zero length mod, but passed calldata has not enough total length", "21,21,22,23 - Non-zero length exp & mod, but passed data has only base and part of exp / only base", - "24 - Non-zero length base & exp & mod and no values in input data - interpreted as all zeroes" + "24 - Non-zero length base & exp & mod and no values in input data - interpreted as all zeroes", + "25 - Price calculation when baseLength > modLength", + "26 - bigint_expmod precompiled contract returns 1 for 0 ^ 0 mod 100" ], "data" : [ "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", @@ -204,7 +206,9 @@ "0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002023003", "0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020230", "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202", -"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002" +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002", +"0x000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001001001010010", +"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000064" ], "gasLimit" : [ "100000000" -- cgit v1.2.3