From dc526a9c45b2cacea69cd1b1b34b6c1a78272062 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 15 Oct 2018 15:36:31 +0300 Subject: [PATCH 01/23] Fixed bug in using ethereumj.conf.file param --- .../src/main/java/org/ethereum/config/SystemProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java index 36464648e6..84d7d82eca 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java @@ -198,7 +198,7 @@ public SystemProperties(Config apiConfig, ClassLoader classLoader) { Config testUserConfig = ConfigFactory.parseResources("test-user.conf"); logger.info("Config (" + (testUserConfig.entrySet().size() > 0 ? " yes " : " no ") + "): test properties from resource 'test-user.conf'"); String file = System.getProperty("ethereumj.conf.file"); - Config cmdLineConfigFile = mergeConfigs(res, s -> ConfigFactory.parseFile(new File(s))); + Config cmdLineConfigFile = mergeConfigs(file, s -> ConfigFactory.parseFile(new File(s))); logger.info("Config (" + (cmdLineConfigFile.entrySet().size() > 0 ? " yes " : " no ") + "): user properties from -Dethereumj.conf.file file(s) '" + file + "'"); logger.info("Config (" + (apiConfig.entrySet().size() > 0 ? " yes " : " no ") + "): config passed via constructor"); config = apiConfig From 8ce5dbbbed07c3aab0caed0866c17e5b10f9fedf Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Wed, 19 Dec 2018 18:27:35 +0300 Subject: [PATCH 02/23] Added Constantinople transition test --- .../org/ethereum/jsontestsuite/GitHubJSONTestSuite.java | 8 +++++++- .../org/ethereum/jsontestsuite/GitHubTestNetTest.java | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java index 5741b1c7b2..a31e8cc725 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java @@ -324,7 +324,8 @@ public enum Network { FrontierToHomesteadAt5, HomesteadToDaoAt5, HomesteadToEIP150At5, - EIP158ToByzantiumAt5; + EIP158ToByzantiumAt5, + ByzantiumToConstantinopleAt5; public BlockchainNetConfig getConfig() { switch (this) { @@ -356,6 +357,11 @@ public BlockchainNetConfig getConfig() { add(5, new ByzantiumConfig(new HomesteadConfig())); }}; + case ByzantiumToConstantinopleAt5: return new BaseNetConfig() {{ + add(0, new ByzantiumConfig(new HomesteadConfig())); + add(5, new ConstantinopleConfig(new HomesteadConfig())); + }}; + default: throw new IllegalArgumentException("Unknown network value: " + this.name()); } } diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java index a4010ef7c9..ddbe4bfd95 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTestNetTest.java @@ -26,8 +26,8 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubTestNetTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "12ee51045ace4a3075e39fe58128fdaa74b3fbd0"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/TransitionTests + static String commitSHA = "725dbc73a54649e22a00330bd0f4d6699a5060e5"; + static String treeSHA = "36528084e10bf993fdb20cc304f3421c7324c2a4"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/TransitionTests static BlockchainTestSuite suite; @@ -65,4 +65,9 @@ public void bcHomesteadToEIP150() throws IOException { public void bcEIP158ToByzantium() throws IOException { suite.runAll("bcEIP158ToByzantium", GitHubJSONTestSuite.Network.EIP158ToByzantiumAt5); } + + @Test + public void byzantiumToConstantinople() throws IOException { + suite.runAll("bcByzantiumToConstantinople", GitHubJSONTestSuite.Network.ByzantiumToConstantinopleAt5); + } } From 6c1f26e96db70c85eb38fdab61f0ac9ded53a449 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Sat, 22 Dec 2018 15:30:06 +0300 Subject: [PATCH 03/23] Add Constantinople BasicTest --- .../java/org/ethereum/jsontestsuite/GitHubBasicTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBasicTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBasicTest.java index a747b80f68..eb5a4ccfee 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBasicTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBasicTest.java @@ -38,7 +38,7 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubBasicTest { - String commitSHA = "95a309203890e6244c6d4353ca411671973c13b5"; + String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; @Test public void btCrypto() throws IOException { @@ -55,6 +55,11 @@ public void btDifficultyByzantium() throws IOException, ParseException { runDifficultyTest(new ByzantiumConfig(new DaoHFConfig()), "BasicTests/difficultyByzantium.json", commitSHA); } + @Test + public void btDifficultyConstantinople() throws IOException, ParseException { + runDifficultyTest(new ConstantinopleConfig(new DaoHFConfig()), "BasicTests/difficultyConstantinople.json", commitSHA); + } + @Test @Ignore // due to CPP minimumDifficulty issue public void btDifficultyCustomHomestead() throws IOException, ParseException { From 95f5d31b92bc85140cf18c0f23ecfa6261b60805 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Sat, 22 Dec 2018 15:50:18 +0300 Subject: [PATCH 04/23] Bump commit and tree sha for tests unaffected by Constantinople --- .../org/ethereum/jsontestsuite/GitHubBlockTest.java | 7 ++++--- .../java/org/ethereum/jsontestsuite/GitHubPowTest.java | 2 +- .../java/org/ethereum/jsontestsuite/GitHubVMTest.java | 10 ++-------- .../java/org/ethereum/jsontestsuite/GithubABITest.java | 2 +- .../org/ethereum/jsontestsuite/GithubTrieTest.java | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java index 373b6e3e70..17a2cb33b1 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java @@ -31,14 +31,15 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubBlockTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "3f6a1117be5c0d6f801875118c7c580dc4200712"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/ + static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; + static String treeSHA = "6c32ebcbce50112966427e18788069b9f7cbe285"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/ static GitHubJSONTestSuite.Network[] targetNets = { GitHubJSONTestSuite.Network.Frontier, GitHubJSONTestSuite.Network.Homestead, GitHubJSONTestSuite.Network.EIP150, GitHubJSONTestSuite.Network.EIP158, - GitHubJSONTestSuite.Network.Byzantium + GitHubJSONTestSuite.Network.Byzantium, + GitHubJSONTestSuite.Network.Constantinople }; static BlockchainTestSuite suite; diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubPowTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubPowTest.java index fb4bf5a3c8..cb25b66219 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubPowTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubPowTest.java @@ -36,7 +36,7 @@ public class GitHubPowTest { private static final Logger logger = LoggerFactory.getLogger("TCK-Test"); - public String shacommit = "b09975f0a37afe306f52d5b771f5e3836f53c8bc"; + public String shacommit = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; @Test public void runEthashTest() throws IOException { diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java index 3d56abac7d..089b03a0cc 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java @@ -29,8 +29,8 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubVMTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "7429078cc0ae66034bbede7c9666c234dc76bc67"; // https://github.com/ethereum/tests/tree/develop/VMTests/ + static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; + static String treeSHA = "d909a11b8315a81eaf610f457205025fb1284cc8"; // https://github.com/ethereum/tests/tree/develop/VMTests/ static VMTestSuite suite; @@ -44,12 +44,6 @@ public void recover() { SystemProperties.getDefault().setBlockchainConfig(new MainNetConfig()); } - @Ignore - @Test - public void runSingle() throws ParseException, IOException { - VMTestSuite.runSingle(commitSHA, "vmArithmeticTest/add0.json"); - } - @Test public void vmArithmeticTest() throws ParseException { suite.runAll("vmArithmeticTest"); diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubABITest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubABITest.java index 47fd6ab28d..0bb1343cce 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubABITest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubABITest.java @@ -32,7 +32,7 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GithubABITest { - String commitSHA = "2d28e1f654bb4b6fe6aca2808b4b5c37e3fccdcc"; + String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; @Test public void basicAbiTests() throws IOException { diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubTrieTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubTrieTest.java index 15fb45c1c1..ed4202fdf7 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubTrieTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GithubTrieTest.java @@ -32,7 +32,7 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GithubTrieTest { - String commitSHA = "6581e1fc35b1d0fdec86bd4eea552a7c742d6bca"; + String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; @Test public void hexEncodedSecureTrieTest() throws IOException { From 979cc36e1cbae37ff4888dc4814817c4db19fba1 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Sun, 23 Dec 2018 17:39:41 +0300 Subject: [PATCH 05/23] Transaction test moved to new format --- .../jsontestsuite/GitHubTransactionTest.java | 51 +++++++-------- .../suite/TransactionTestCase.java | 62 ++++++------------- .../suite/TransactionTestSuite.java | 54 ++++++++++++++-- .../suite/runners/TransactionTestRunner.java | 45 ++++++-------- 4 files changed, 112 insertions(+), 100 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTransactionTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTransactionTest.java index 8ae5d8e725..d91bab6c21 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTransactionTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubTransactionTest.java @@ -31,8 +31,8 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubTransactionTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "1405e8a09a6f695e843259b9029b04a3fc4da3fa"; // https://github.com/ethereum/tests/tree/develop/TransactionTests/ + static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; + static String treeSHA = "8c0d8131cb772b572862f0d88e778830bfddb006"; // https://github.com/ethereum/tests/tree/develop/TransactionTests/ static TxTestSuite suite; @@ -47,58 +47,55 @@ public void recover() { SystemProperties.getDefault().setBlockchainConfig(new MainNetConfig()); } - @Ignore @Test - public void runSingleTest() throws IOException, ParseException { - TxTestSuite.runSingle(commitSHA, "ttWrongRLPFrontier/RLPArrayLengthWithFirstZeros.json"); + public void ttAddress() throws IOException, ParseException { + suite.runAll("ttAddress"); } @Test - public void ttConstantinople() throws IOException, ParseException { - suite.runAll("ttConstantinople"); + public void ttData() throws IOException, ParseException { + suite.run("ttData", new HashSet<>(Arrays.asList( + "String10MbData" // too big to run it each time + ))); } @Test - public void ttEip155VitaliksEip158() throws IOException, ParseException { - suite.runAll("ttEip155VitaliksEip158"); + public void ttGasLimit() throws IOException, ParseException { + suite.runAll("ttGasLimit"); } @Test - public void ttEip155VitaliksHomesead() throws IOException, ParseException { - suite.runAll("ttEip155VitaliksHomesead"); + public void ttGasPrice() throws IOException, ParseException { + suite.runAll("ttGasPrice"); } @Test - public void ttEip158() throws IOException, ParseException { - suite.runAll("ttEip158"); + public void ttNonce() throws IOException, ParseException { + suite.runAll("ttNonce"); } @Test - public void ttFrontier() throws IOException, ParseException { - suite.run("ttFrontier", new HashSet<>(Arrays.asList( - "String10MbData" // too big to run it each time - ))); + public void ttRSValue() throws IOException, ParseException { + suite.runAll("ttRSValue"); } @Test - public void ttHomestead() throws IOException, ParseException { - suite.run("ttHomestead", new HashSet<>(Arrays.asList( - "String10MbData" // too big to run it each time - ))); + public void ttVValue() throws IOException, ParseException { + suite.runAll("ttVValue"); } @Test - public void ttVRuleEip158() throws IOException, ParseException { - suite.runAll("ttVRuleEip158"); + public void ttSignature() throws IOException, ParseException { + suite.runAll("ttSignature"); } @Test - public void ttWrongRLPFrontier() throws IOException, ParseException { - suite.runAll("ttWrongRLPFrontier"); + public void ttValue() throws IOException, ParseException { + suite.runAll("ttValue"); } @Test - public void ttWrongRLPHomestead() throws IOException, ParseException { - suite.runAll("ttWrongRLPHomestead"); + public void ttWrongRLP() throws IOException, ParseException { + suite.runAll("ttWrongRLP"); } } diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestCase.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestCase.java index f013a9e415..aa8c4c3f7a 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestCase.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestCase.java @@ -17,47 +17,17 @@ */ package org.ethereum.jsontestsuite.suite; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.ethereum.jsontestsuite.suite.model.TransactionTck; +import org.ethereum.jsontestsuite.GitHubJSONTestSuite; -@JsonIgnoreProperties(ignoreUnknown = true) public class TransactionTestCase { - - private String blocknumber; - private TransactionTck transaction; - private String hash; private String rlp; - private String sender; - private String senderExpect; - + private String expectedHash; + private String expectedRlp; + private GitHubJSONTestSuite.Network network; public TransactionTestCase() { } - public String getBlocknumber() { - return blocknumber; - } - - public void setBlocknumber(String blocknumber) { - this.blocknumber = blocknumber; - } - - public TransactionTck getTransaction() { - return transaction; - } - - public void setTransaction(TransactionTck transaction) { - this.transaction = transaction; - } - - public String getHash() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } - public String getRlp() { return rlp; } @@ -66,19 +36,27 @@ public void setRlp(String rlp) { this.rlp = rlp; } - public String getSender() { - return sender; + public String getExpectedHash() { + return expectedHash; + } + + public void setExpectedHash(String expectedHash) { + this.expectedHash = expectedHash; + } + + public String getExpectedRlp() { + return expectedRlp; } - public void setSender(String sender) { - this.sender = sender; + public void setExpectedRlp(String expectedRlp) { + this.expectedRlp = expectedRlp; } - public String getSenderExpect() { - return senderExpect; + public GitHubJSONTestSuite.Network getNetwork() { + return network; } - public void setSenderExpect(String senderExpect) { - this.senderExpect = senderExpect; + public void setNetwork(GitHubJSONTestSuite.Network network) { + this.network = network; } } diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestSuite.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestSuite.java index 3b7b77dcbd..cad13343aa 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestSuite.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/TransactionTestSuite.java @@ -17,8 +17,8 @@ */ package org.ethereum.jsontestsuite.suite; -import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; +import org.ethereum.jsontestsuite.GitHubJSONTestSuite; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,12 +33,56 @@ public class TransactionTestSuite { Map testCases = new HashMap<>(); public TransactionTestSuite(String json) throws IOException { + Map testCases = new HashMap<>(); - ObjectMapper mapper = new ObjectMapper(); - JavaType type = mapper.getTypeFactory(). - constructMapType(HashMap.class, String.class, TransactionTestCase.class); + Map jsonData = (Map) new ObjectMapper().readValue(json, Object.class); + for (Map.Entry currentCase : jsonData.entrySet()) { + String namePrefix = currentCase.getKey() + "_"; + Map currentCases = new HashMap<>(); + Map networksEtc = (Map) currentCase.getValue(); + String rlp = null; - testCases = new ObjectMapper().readValue(json, type); + for (Map.Entry currentField : networksEtc.entrySet()) { + String currentKey = currentField.getKey(); + GitHubJSONTestSuite.Network maybeNetwork = null; + try { + maybeNetwork = GitHubJSONTestSuite.Network.valueOf(currentKey); + } catch (IllegalArgumentException ex) { + // just not filling maybeNetwork + } + + if (maybeNetwork != null) { + TransactionTestCase txCase = new TransactionTestCase(); + txCase.setNetwork(maybeNetwork); + Map txCaseMap = (Map) currentField.getValue(); + for (String key : txCaseMap.keySet()) { + if (key.equals("hash")) { + txCase.setExpectedHash((String) txCaseMap.get(key)); + } else if (key.equals("sender")) { + txCase.setExpectedRlp((String) txCaseMap.get(key)); + } else { + String error = String.format("Expected transaction is not fully parsed, key \"%s\" missed!", key); + throw new RuntimeException(error); + } + } + currentCases.put(namePrefix + currentKey, txCase); + } else if (currentKey.equals("rlp")) { + rlp = (String) currentField.getValue(); + } else if (currentKey.equals("_info")) { + // legal key, just skip + } else { + String error = String.format("Transaction test case is not fully parsed, key \"%s\" missed!", currentKey); + throw new RuntimeException(error); + } + } + + for (TransactionTestCase testCase : currentCases.values()) { + testCase.setRlp(rlp); + } + testCases.putAll(currentCases); + } + + this.testCases = testCases; } public Map getTestCases() { diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/TransactionTestRunner.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/TransactionTestRunner.java index 612f7ca346..8b32e3dd6e 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/TransactionTestRunner.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/TransactionTestRunner.java @@ -18,15 +18,13 @@ package org.ethereum.jsontestsuite.suite.runners; import org.ethereum.config.BlockchainConfig; -import org.ethereum.config.SystemProperties; import org.ethereum.core.Transaction; import org.ethereum.jsontestsuite.suite.TransactionTestCase; import org.ethereum.jsontestsuite.suite.Utils; -import org.ethereum.jsontestsuite.suite.builder.TransactionBuilder; -import org.ethereum.jsontestsuite.suite.validators.TransactionValidator; +import org.ethereum.util.ByteUtil; +import org.ethereum.util.FastByteComparisons; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.spongycastle.util.encoders.Hex; import java.math.BigInteger; import java.util.ArrayList; @@ -42,7 +40,8 @@ public static List run(TransactionTestCase transactionTestCase2) { protected TransactionTestCase transactionTestCase; protected Transaction transaction = null; - protected Transaction expectedTransaction; + protected byte[] expectedHash; + protected byte[] expectedSender; protected long blockNumber; protected BlockchainConfig blockchainConfig; @@ -51,10 +50,8 @@ public TransactionTestRunner(TransactionTestCase transactionTestCase) { } public List runImpl() { - - blockNumber = transactionTestCase.getBlocknumber() == null ? 0 : Utils.parseLong(transactionTestCase.getBlocknumber()); - logger.info("Block number: {}", blockNumber); - this.blockchainConfig = SystemProperties.getDefault().getBlockchainConfig().getConfigForBlock(blockNumber); + this.blockNumber = 0; + this.blockchainConfig = transactionTestCase.getNetwork().getConfig().getConfigForBlock(blockNumber); try { byte[] rlp = Utils.parseData(transactionTestCase.getRlp()); @@ -69,12 +66,14 @@ public List runImpl() { logger.info("Transaction data skipped because it's too big", transaction); } - expectedTransaction = transactionTestCase.getTransaction() == null ? null : TransactionBuilder.build(transactionTestCase.getTransaction()); - if (expectedTransaction == null || expectedTransaction.getEncoded().length < 10000) { - logger.info("Expected transaction: {}", expectedTransaction); - } else { - logger.info("Expected transaction data skipped because it's too big", transaction); - } + this.expectedHash = (transactionTestCase.getExpectedHash() != null && !transactionTestCase.getExpectedHash().isEmpty()) + ? ByteUtil.hexStringToBytes(transactionTestCase.getExpectedHash()) + : null; + this.expectedSender = (transactionTestCase.getExpectedRlp() != null && !transactionTestCase.getExpectedRlp().isEmpty()) + ? ByteUtil.hexStringToBytes(transactionTestCase.getExpectedRlp()) + : null; + logger.info("Expected transaction: [hash: {}, sender: {}]", + ByteUtil.toHexString(expectedHash), ByteUtil.toHexString(expectedSender)); // Not enough GAS if (transaction != null) { @@ -88,30 +87,24 @@ public List runImpl() { String acceptFail = null; boolean shouldAccept = transaction != null && blockchainConfig.acceptTransactionSignature(transaction); if (!shouldAccept) transaction = null; - if (shouldAccept != (expectedTransaction != null)) { + if (shouldAccept == (expectedSender == null)) { acceptFail = "Transaction shouldn't be accepted"; } String wrongSender = null; String wrongHash = null; - if (transaction != null && expectedTransaction != null) { + if (transaction != null && expectedHash != null) { // Verifying sender - if (!Hex.toHexString(transaction.getSender()).equals(transactionTestCase.getSender())) + if (!FastByteComparisons.equal(transaction.getSender(), expectedSender)) wrongSender = "Sender is incorrect in parsed transaction"; // Verifying hash // NOTE: "hash" is not required field in test case - if (transactionTestCase.getHash() != null && - !Hex.toHexString(transaction.getHash()).equals(transactionTestCase.getHash())) + if (expectedHash != null && + !FastByteComparisons.equal(transaction.getHash(), expectedHash)) wrongHash = "Hash is incorrect in parsed transaction"; } - logger.info("--------- POST Validation---------"); List results = new ArrayList<>(); - - ArrayList outputSummary = - TransactionValidator.valid(transaction, expectedTransaction); - - results.addAll(outputSummary); if (acceptFail != null) results.add(acceptFail); if (wrongSender != null) results.add(wrongSender); if (wrongHash != null) results.add(wrongHash); From 0b4856d6f0297c7789c6b67296ea0371e2dca940 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 00:05:35 +0300 Subject: [PATCH 06/23] Add more modexp tests --- .../ethereum/vm/PrecompiledContractTest.java | 146 +++++++++++++----- 1 file changed, 110 insertions(+), 36 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/vm/PrecompiledContractTest.java b/ethereumj-core/src/test/java/org/ethereum/vm/PrecompiledContractTest.java index 26901b338e..b4b15f0c71 100644 --- a/ethereumj-core/src/test/java/org/ethereum/vm/PrecompiledContractTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/vm/PrecompiledContractTest.java @@ -139,11 +139,11 @@ public void modExpTest() { byte[] data1 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000001" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "03" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); + "0000000000000000000000000000000000000000000000000000000000000020" + + "0000000000000000000000000000000000000000000000000000000000000020" + + "03" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); assertEquals(13056, contract.getGasForData(data1)); @@ -153,10 +153,10 @@ public void modExpTest() { byte[] data2 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000000" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); + "0000000000000000000000000000000000000000000000000000000000000020" + + "0000000000000000000000000000000000000000000000000000000000000020" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); assertEquals(13056, contract.getGasForData(data2)); @@ -166,22 +166,22 @@ public void modExpTest() { byte[] data3 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000000" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); + "0000000000000000000000000000000000000000000000000000000000000020" + + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); // hardly imagine this value could be a real one assertEquals(3_674_950_435_109_146_392L, contract.getGasForData(data3)); byte[] data4 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000001" + - "0000000000000000000000000000000000000000000000000000000000000002" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "03" + - "ffff" + - "8000000000000000000000000000000000000000000000000000000000000000" + - "07"); // "07" should be ignored by data parser + "0000000000000000000000000000000000000000000000000000000000000002" + + "0000000000000000000000000000000000000000000000000000000000000020" + + "03" + + "ffff" + + "8000000000000000000000000000000000000000000000000000000000000000" + + "07"); // "07" should be ignored by data parser assertEquals(768, contract.getGasForData(data4)); @@ -191,12 +191,12 @@ public void modExpTest() { byte[] data5 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000001" + - "0000000000000000000000000000000000000000000000000000000000000002" + - "0000000000000000000000000000000000000000000000000000000000000020" + - "03" + - "ffff" + - "80"); // "80" should be parsed as "8000000000000000000000000000000000000000000000000000000000000000" - // cause call data is infinitely right-padded with zero bytes + "0000000000000000000000000000000000000000000000000000000000000002" + + "0000000000000000000000000000000000000000000000000000000000000020" + + "03" + + "ffff" + + "80"); // "80" should be parsed as "8000000000000000000000000000000000000000000000000000000000000000" + // cause call data is infinitely right-padded with zero bytes assertEquals(768, contract.getGasForData(data5)); @@ -207,22 +207,22 @@ public void modExpTest() { // check overflow handling in gas calculation byte[] data6 = Hex.decode( "0000000000000000000000000000000000000000000000000000000000000020" + - "0000000000000000000000000000000020000000000000000000000000000000" + - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); + "0000000000000000000000000000000020000000000000000000000000000000" + + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); assertEquals(Long.MAX_VALUE, contract.getGasForData(data6)); // check rubbish data byte[] data7 = Hex.decode( "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" + - "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" + + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"); assertEquals(Long.MAX_VALUE, contract.getGasForData(data7)); @@ -236,6 +236,80 @@ public void modExpTest() { assertEquals(0, contract.getGasForData(null)); assertArrayEquals(EMPTY_BYTE_ARRAY, contract.execute(null).getRight()); - } + // nagydani-1-square + byte[] data9 = Hex.decode("000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb502fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b"); + byte[] res9 = contract.execute(data9).getRight(); + assertArrayEquals(Hex.decode("60008f1614cc01dcfb6bfb09c625cf90b47d4468db81b5f8b7a39d42f332eab9b2da8f2d95311648a8f243f4bb13cfb3d8f7f2a3c014122ebb3ed41b02783adc"), res9); + + // nagydani-1-qube + byte[] data10 = Hex.decode("000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb503fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b"); + byte[] res10 = contract.execute(data10).getRight(); + assertArrayEquals(Hex.decode("4834a46ba565db27903b1c720c9d593e84e4cbd6ad2e64b31885d944f68cd801f92225a8961c952ddf2797fa4701b330c85c4b363798100b921a1a22a46a7fec"), res10); + + // nagydani-1-pow0x10001 + byte[] data11 = Hex.decode("000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb5010001fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b"); + byte[] res11 = contract.execute(data11).getRight(); + assertArrayEquals(Hex.decode("c36d804180c35d4426b57b50c5bfcca5c01856d104564cd513b461d3c8b8409128a5573e416d0ebe38f5f736766d9dc27143e4da981dfa4d67f7dc474cbee6d2"), res11); + + // nagydani-2-square + byte[] data12 = Hex.decode("000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf5102e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087"); + byte[] res12 = contract.execute(data12).getRight(); + assertArrayEquals(Hex.decode("981dd99c3b113fae3e3eaa9435c0dc96779a23c12a53d1084b4f67b0b053a27560f627b873e3f16ad78f28c94f14b6392def26e4d8896c5e3c984e50fa0b3aa44f1da78b913187c6128baa9340b1e9c9a0fd02cb78885e72576da4a8f7e5a113e173a7a2889fde9d407bd9f06eb05bc8fc7b4229377a32941a02bf4edcc06d70"), res12); + + // nagydani-2-qube + byte[] data13 = Hex.decode("000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf5103e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087"); + byte[] res13 = contract.execute(data13).getRight(); + assertArrayEquals(Hex.decode("d89ceb68c32da4f6364978d62aaa40d7b09b59ec61eb3c0159c87ec3a91037f7dc6967594e530a69d049b64adfa39c8fa208ea970cfe4b7bcd359d345744405afe1cbf761647e32b3184c7fbe87cee8c6c7ff3b378faba6c68b83b6889cb40f1603ee68c56b4c03d48c595c826c041112dc941878f8c5be828154afd4a16311f"), res13); + + // nagydani-2-pow0x10001 + byte[] data14 = Hex.decode("000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000080cad7d991a00047dd54d3399b6b0b937c718abddef7917c75b6681f40cc15e2be0003657d8d4c34167b2f0bbbca0ccaa407c2a6a07d50f1517a8f22979ce12a81dcaf707cc0cebfc0ce2ee84ee7f77c38b9281b9822a8d3de62784c089c9b18dcb9a2a5eecbede90ea788a862a9ddd9d609c2c52972d63e289e28f6a590ffbf51010001e6d893b80aeed5e6e9ce9afa8a5d5675c93a32ac05554cb20e9951b2c140e3ef4e433068cf0fb73bc9f33af1853f64aa27a0028cbf570d7ac9048eae5dc7b28c87c31e5810f1e7fa2cda6adf9f1076dbc1ec1238560071e7efc4e9565c49be9e7656951985860a558a754594115830bcdb421f741408346dd5997bb01c287087"); + byte[] res14 = contract.execute(data14).getRight(); + assertArrayEquals(Hex.decode("ad85e8ef13fd1dd46eae44af8b91ad1ccae5b7a1c92944f92a19f21b0b658139e0cabe9c1f679507c2de354bf2c91ebd965d1e633978a830d517d2f6f8dd5fd58065d58559de7e2334a878f8ec6992d9b9e77430d4764e863d77c0f87beede8f2f7f2ab2e7222f85cc9d98b8467f4bb72e87ef2882423ebdb6daf02dddac6db2"), res14); + + // nagydani-3-square + byte[] data15 = Hex.decode("000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb02d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d"); + byte[] res15 = contract.execute(data15).getRight(); + assertArrayEquals(Hex.decode("affc7507ea6d84751ec6b3f0d7b99dbcc263f33330e450d1b3ff0bc3d0874320bf4edd57debd587306988157958cb3cfd369cc0c9c198706f635c9e0f15d047df5cb44d03e2727f26b083c4ad8485080e1293f171c1ed52aef5993a5815c35108e848c951cf1e334490b4a539a139e57b68f44fee583306f5b85ffa57206b3ee5660458858534e5386b9584af3c7f67806e84c189d695e5eb96e1272d06ec2df5dc5fabc6e94b793718c60c36be0a4d031fc84cd658aa72294b2e16fc240aef70cb9e591248e38bd49c5a554d1afa01f38dab72733092f7555334bbef6c8c430119840492380aa95fa025dcf699f0a39669d812b0c6946b6091e6e235337b6f8"), res15); + + // nagydani-3-qube + byte[] data16 = Hex.decode("000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb03d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d"); + byte[] res16 = contract.execute(data16).getRight(); + assertArrayEquals(Hex.decode("1b280ecd6a6bf906b806d527c2a831e23b238f89da48449003a88ac3ac7150d6a5e9e6b3be4054c7da11dd1e470ec29a606f5115801b5bf53bc1900271d7c3ff3cd5ed790d1c219a9800437a689f2388ba1a11d68f6a8e5b74e9a3b1fac6ee85fc6afbac599f93c391f5dc82a759e3c6c0ab45ce3f5d25d9b0c1bf94cf701ea6466fc9a478dacc5754e593172b5111eeba88557048bceae401337cd4c1182ad9f700852bc8c99933a193f0b94cf1aedbefc48be3bc93ef5cb276d7c2d5462ac8bb0c8fe8923a1db2afe1c6b90d59c534994a6a633f0ead1d638fdc293486bb634ff2c8ec9e7297c04241a61c37e3ae95b11d53343d4ba2b4cc33d2cfa7eb705e"), res16); + + // nagydani-3-pow0x10001 + byte[] data17 = Hex.decode("000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000100c9130579f243e12451760976261416413742bd7c91d39ae087f46794062b8c239f2a74abf3918605a0e046a7890e049475ba7fbb78f5de6490bd22a710cc04d30088179a919d86c2da62cf37f59d8f258d2310d94c24891be2d7eeafaa32a8cb4b0cfe5f475ed778f45907dc8916a73f03635f233f7a77a00a3ec9ca6761a5bbd558a2318ecd0caa1c5016691523e7e1fa267dd35e70c66e84380bdcf7c0582f540174e572c41f81e93da0b757dff0b0fe23eb03aa19af0bdec3afb474216febaacb8d0381e631802683182b0fe72c28392539850650b70509f54980241dc175191a35d967288b532a7a8223ce2440d010615f70df269501944d4ec16fe4a3cb010001d7a85909174757835187cb52e71934e6c07ef43b4c46fc30bbcd0bc72913068267c54a4aabebb493922492820babdeb7dc9b1558fcf7bd82c37c82d3147e455b623ab0efa752fe0b3a67ca6e4d126639e645a0bf417568adbb2a6a4eef62fa1fa29b2a5a43bebea1f82193a7dd98eb483d09bb595af1fa9c97c7f41f5649d976aee3e5e59e2329b43b13bea228d4a93f16ba139ccb511de521ffe747aa2eca664f7c9e33da59075cc335afcd2bf3ae09765f01ab5a7c3e3938ec168b74724b5074247d200d9970382f683d6059b94dbc336603d1dfee714e4b447ac2fa1d99ecb4961da2854e03795ed758220312d101e1e3d87d5313a6d052aebde75110363d"); + byte[] res17 = contract.execute(data17).getRight(); + assertArrayEquals(Hex.decode("37843d7c67920b5f177372fa56e2a09117df585f81df8b300fba245b1175f488c99476019857198ed459ed8d9799c377330e49f4180c4bf8e8f66240c64f65ede93d601f957b95b83efdee1e1bfde74169ff77002eaf078c71815a9220c80b2e3b3ff22c2f358111d816ebf83c2999026b6de50bfc711ff68705d2f40b753424aefc9f70f08d908b5a20276ad613b4ab4309a3ea72f0c17ea9df6b3367d44fb3acab11c333909e02e81ea2ed404a712d3ea96bba87461720e2d98723e7acd0520ac1a5212dbedcd8dc0c1abf61d4719e319ff4758a774790b8d463cdfe131d1b2dcfee52d002694e98e720cb6ae7ccea353bc503269ba35f0f63bf8d7b672a76"), res17); + + // nagydani-4-square + byte[] data18 = Hex.decode("000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b8102df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f"); + byte[] res18 = contract.execute(data18).getRight(); + assertArrayEquals(Hex.decode("8a5aea5f50dcc03dc7a7a272b5aeebc040554dbc1ffe36753c4fc75f7ed5f6c2cc0de3a922bf96c78bf0643a73025ad21f45a4a5cadd717612c511ab2bff1190fe5f1ae05ba9f8fe3624de1de2a817da6072ddcdb933b50216811dbe6a9ca79d3a3c6b3a476b079fd0d05f04fb154e2dd3e5cb83b148a006f2bcbf0042efb2ae7b916ea81b27aac25c3bf9a8b6d35440062ad8eae34a83f3ffa2cc7b40346b62174a4422584f72f95316f6b2bee9ff232ba9739301c97c99a9ded26c45d72676eb856ad6ecc81d36a6de36d7f9dafafee11baa43a4b0d5e4ecffa7b9b7dcefd58c397dd373e6db4acd2b2c02717712e6289bed7c813b670c4a0c6735aa7f3b0f1ce556eae9fcc94b501b2c8781ba50a8c6220e8246371c3c7359fe4ef9da786ca7d98256754ca4e496be0a9174bedbecb384bdf470779186d6a833f068d2838a88d90ef3ad48ff963b67c39cc5a3ee123baf7bf3125f64e77af7f30e105d72c4b9b5b237ed251e4c122c6d8c1405e736299c3afd6db16a28c6a9cfa68241e53de4cd388271fe534a6a9b0dbea6171d170db1b89858468885d08fecbd54c8e471c3e25d48e97ba450b96d0d87e00ac732aaa0d3ce4309c1064bd8a4c0808a97e0143e43a24cfa847635125cd41c13e0574487963e9d725c01375db99c31da67b4cf65eff555f0c0ac416c727ff8d438ad7c42030551d68c2e7adda0abb1ca7c10"), res18); + + // nagydani-4-qube + byte[] data19 = Hex.decode("000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b8103df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f"); + byte[] res19 = contract.execute(data19).getRight(); + assertArrayEquals(Hex.decode("5a2664252aba2d6e19d9600da582cdd1f09d7a890ac48e6b8da15ae7c6ff1856fc67a841ac2314d283ffa3ca81a0ecf7c27d89ef91a5a893297928f5da0245c99645676b481b7e20a566ee6a4f2481942bee191deec5544600bb2441fd0fb19e2ee7d801ad8911c6b7750affec367a4b29a22942c0f5f4744a4e77a8b654da2a82571037099e9c6d930794efe5cdca73c7b6c0844e386bdca8ea01b3d7807146bb81365e2cdc6475f8c23e0ff84463126189dc9789f72bbce2e3d2d114d728a272f1345122de23df54c922ec7a16e5c2a8f84da8871482bd258c20a7c09bbcd64c7a96a51029bbfe848736a6ba7bf9d931a9b7de0bcaf3635034d4958b20ae9ab3a95a147b0421dd5f7ebff46c971010ebfc4adbbe0ad94d5498c853e7142c450d8c71de4b2f84edbf8acd2e16d00c8115b150b1c30e553dbb82635e781379fe2a56360420ff7e9f70cc64c00aba7e26ed13c7c19622865ae07248daced36416080f35f8cc157a857ed70ea4f347f17d1bee80fa038abd6e39b1ba06b97264388b21364f7c56e192d4b62d9b161405f32ab1e2594e86243e56fcf2cb30d21adef15b9940f91af681da24328c883d892670c6aa47940867a81830a82b82716895db810df1b834640abefb7db2092dd92912cb9a735175bc447be40a503cf22dfe565b4ed7a3293ca0dfd63a507430b323ee248ec82e843b673c97ad730728cebc"), res19); + + // nagydani-4-pow0x10001 + byte[] data20 = Hex.decode("000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000200db34d0e438249c0ed685c949cc28776a05094e1c48691dc3f2dca5fc3356d2a0663bd376e4712839917eb9a19c670407e2c377a2de385a3ff3b52104f7f1f4e0c7bf7717fb913896693dc5edbb65b760ef1b00e42e9d8f9af17352385e1cd742c9b006c0f669995cb0bb21d28c0aced2892267637b6470d8cee0ab27fc5d42658f6e88240c31d6774aa60a7ebd25cd48b56d0da11209f1928e61005c6eb709f3e8e0aaf8d9b10f7d7e296d772264dc76897ccdddadc91efa91c1903b7232a9e4c3b941917b99a3bc0c26497dedc897c25750af60237aa67934a26a2bc491db3dcc677491944bc1f51d3e5d76b8d846a62db03dedd61ff508f91a56d71028125035c3a44cbb041497c83bf3e4ae2a9613a401cc721c547a2afa3b16a2969933d3626ed6d8a7428648f74122fd3f2a02a20758f7f693892c8fd798b39abac01d18506c45e71432639e9f9505719ee822f62ccbf47f6850f096ff77b5afaf4be7d772025791717dbe5abf9b3f40cff7d7aab6f67e38f62faf510747276e20a42127e7500c444f9ed92baf65ade9e836845e39c4316d9dce5f8e2c8083e2c0acbb95296e05e51aab13b6b8f53f06c9c4276e12b0671133218cc3ea907da3bd9a367096d9202128d14846cc2e20d56fc8473ecb07cecbfb8086919f3971926e7045b853d85a69d026195c70f9f7a823536e2a8f4b3e12e94d9b53a934353451094b81010001df3143a0057457d75e8c708b6337a6f5a4fd1a06727acf9fb93e2993c62f3378b37d56c85e7b1e00f0145ebf8e4095bd723166293c60b6ac1252291ef65823c9e040ddad14969b3b340a4ef714db093a587c37766d68b8d6b5016e741587e7e6bf7e763b44f0247e64bae30f994d248bfd20541a333e5b225ef6a61199e301738b1e688f70ec1d7fb892c183c95dc543c3e12adf8a5e8b9ca9d04f9445cced3ab256f29e998e69efaa633a7b60e1db5a867924ccab0a171d9d6e1098dfa15acde9553de599eaa56490c8f411e4985111f3d40bddfc5e301edb01547b01a886550a61158f7e2033c59707789bf7c854181d0c2e2a42a93cf09209747d7082e147eb8544de25c3eb14f2e35559ea0c0f5877f2f3fc92132c0ae9da4e45b2f6c866a224ea6d1f28c05320e287750fbc647368d41116e528014cc1852e5531d53e4af938374daba6cee4baa821ed07117253bb3601ddd00d59a3d7fb2ef1f5a2fbba7c429f0cf9a5b3462410fd833a69118f8be9c559b1000cc608fd877fb43f8e65c2d1302622b944462579056874b387208d90623fcdaf93920ca7a9e4ba64ea208758222ad868501cc2c345e2d3a5ea2a17e5069248138c8a79c0251185d29ee73e5afab5354769142d2bf0cb6712727aa6bf84a6245fcdae66e4938d84d1b9dd09a884818622080ff5f98942fb20acd7e0c916c2d5ea7ce6f7e173315384518f"); + byte[] res20 = contract.execute(data20).getRight(); + assertArrayEquals(Hex.decode("bed8b970c4a34849fc6926b08e40e20b21c15ed68d18f228904878d4370b56322d0da5789da0318768a374758e6375bfe4641fca5285ec7171828922160f48f5ca7efbfee4d5148612c38ad683ae4e3c3a053d2b7c098cf2b34f2cb19146eadd53c86b2d7ccf3d83b2c370bfb840913ee3879b1057a6b4e07e110b6bcd5e958bc71a14798c91d518cc70abee264b0d25a4110962a764b364ac0b0dd1ee8abc8426d775ec0f22b7e47b32576afaf1b5a48f64573ed1c5c29f50ab412188d9685307323d990802b81dacc06c6e05a1e901830ba9fcc67688dc29c5e27bde0a6e845ca925f5454b6fb3747edfaa2a5820838fb759eadf57f7cb5cec57fc213ddd8a4298fa079c3c0f472b07fb15aa6a7f0a3780bd296ff6a62e58ef443870b02260bd4fd2bbc98255674b8e1f1f9f8d33c7170b0ebbea4523b695911abbf26e41885344823bd0587115fdd83b721a4e8457a31c9a84b3d3520a07e0e35df7f48e5a9d534d0ec7feef1ff74de6a11e7f93eab95175b6ce22c68d78a642ad642837897ec11349205d8593ac19300207572c38d29ca5dfa03bc14cdbc32153c80e5cc3e739403d34c75915e49beb43094cc6dcafb3665b305ddec9286934ae66ec6b777ca528728c851318eb0f207b39f1caaf96db6eeead6b55ed08f451939314577d42bcc9f97c0b52d0234f88fd07e4c1d7780fdebc025cfffcb572cb27a8c33963"), res20); + + // nagydani-5-square + byte[] data21 = Hex.decode("000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf02e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad"); + byte[] res21 = contract.execute(data21).getRight(); + assertArrayEquals(Hex.decode("d61fe4e3f32ac260915b5b03b78a86d11bfc41d973fce5b0cc59035cf8289a8a2e3878ea15fa46565b0d806e2f85b53873ea20ed653869b688adf83f3ef444535bf91598ff7e80f334fb782539b92f39f55310cc4b35349ab7b278346eda9bc37c0d8acd3557fae38197f412f8d9e57ce6a76b7205c23564cab06e5615be7c6f05c3d05ec690cba91da5e89d55b152ff8dd2157dc5458190025cf94b1ad98f7cbe64e9482faba95e6b33844afc640892872b44a9932096508f4a782a4805323808f23e54b6ff9b841dbfa87db3505ae4f687972c18ea0f0d0af89d36c1c2a5b14560c153c3fee406f5cf15cfd1c0bb45d767426d465f2f14c158495069d0c5955a00150707862ecaae30624ebacdd8ac33e4e6aab3ff90b6ba445a84689386b9e945d01823a65874444316e83767290fcff630d2477f49d5d8ffdd200e08ee1274270f86ed14c687895f6caf5ce528bd970c20d2408a9ba66216324c6a011ac4999098362dbd98a038129a2d40c8da6ab88318aa3046cb660327cc44236d9e5d2163bd0959062195c51ed93d0088b6f92051fc99050ece2538749165976233697ab4b610385366e5ce0b02ad6b61c168ecfbedcdf74278a38de340fd7a5fead8e588e294795f9b011e2e60377a89e25c90e145397cdeabc60fd32444a6b7642a611a83c464d8b8976666351b4865c37b02e6dc21dbcdf5f930341707b618cc0f03c3122646b3385c9df9f2ec730eec9d49e7dfc9153b6e6289da8c4f0ebea9ccc1b751948e3bb7171c9e4d57423b0eeeb79095c030cb52677b3f7e0b45c30f645391f3f9c957afa549c4e0b2465b03c67993cd200b1af01035962edbc4c9e89b31c82ac121987d6529dafdeef67a132dc04b6dc68e77f22862040b75e2ceb9ff16da0fca534e6db7bd12fa7b7f51b6c08c1e23dfcdb7acbd2da0b51c87ffbced065a612e9b1c8bba9b7e2d8d7a2f04fcc4aaf355b60d764879a76b5e16762d5f2f55d585d0c8e82df6940960cddfb72c91dfa71f6b4e1c6ca25dfc39a878e998a663c04fe29d5e83b9586d047b4d7ff70a9f0d44f127e7d741685ca75f11629128d916a0ffef4be586a30c4b70389cc746e84ebf177c01ee8a4511cfbb9d1ecf7f7b33c7dd8177896e10bbc82f838dcd6db7ac67de62bf46b6a640fb580c5d1d2708f3862e3d2b645d0d18e49ef088053e3a220adc0e033c2afcfe61c90e32151152eb3caaf746c5e377d541cafc6cbb0cc0fa48b5caf1728f2e1957f5addfc234f1a9d89e40d49356c9172d0561a695fce6dab1d412321bbf407f63766ffd7b6b3d79bcfa07991c5a9709849c1008689e3b47c50d613980bec239fb64185249d055b30375ccb4354d71fe4d05648fbf6c80634dfc3575f2f24abb714c1e4c95e8896763bf4316e954c7ad19e5780ab7a040ca6fb9271f90a8b22ae738daf6cb"), res21); + + // nagydani-5-qube + byte[] data22 = Hex.decode("000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf03e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad"); + byte[] res22 = contract.execute(data22).getRight(); + assertArrayEquals(Hex.decode("5f9c70ec884926a89461056ad20ac4c30155e817f807e4d3f5bb743d789c83386762435c3627773fa77da5144451f2a8aad8adba88e0b669f5377c5e9bad70e45c86fe952b613f015a9953b8a5de5eaee4566acf98d41e327d93a35bd5cef4607d025e58951167957df4ff9b1627649d3943805472e5e293d3efb687cfd1e503faafeb2840a3e3b3f85d016051a58e1c9498aab72e63b748d834b31eb05d85dcde65e27834e266b85c75cc4ec0135135e0601cb93eeeb6e0010c8ceb65c4c319623c5e573a2c8c9fbbf7df68a930beb412d3f4dfd146175484f45d7afaa0d2e60684af9b34730f7c8438465ad3e1d0c3237336722f2aa51095bd5759f4b8ab4dda111b684aa3dac62a761722e7ae43495b7709933512c81c4e3c9133a51f7ce9f2b51fcec064f65779666960b4e45df3900f54311f5613e8012dd1b8efd359eda31a778264c72aa8bb419d862734d769076bce2810011989a45374e5c5d8729fec21427f0bf397eacbb4220f603cf463a4b0c94efd858ffd9768cd60d6ce68d755e0fbad007ce5c2223d70c7018345a102e4ab3c60a13a9e7794303156d4c2063e919f2153c13961fb324c80b240742f47773a7a8e25b3e3fb19b00ce839346c6eb3c732fbc6b888df0b1fe0a3d07b053a2e9402c267b2d62f794d8a2840526e3ade15ce2264496ccd7519571dfde47f7a4bb16292241c20b2be59f3f8fb4f6383f232d838c5a22d8c95b6834d9d2ca493f5a505ebe8899503b0e8f9b19e6e2dd81c1628b80016d02097e0134de51054c4e7674824d4d758760fc52377d2cad145e259aa2ffaf54139e1a66b1e0c1c191e32ac59474c6b526f5b3ba07d3e5ec286eddf531fcd5292869be58c9f22ef91026159f7cf9d05ef66b4299f4da48cc1635bf2243051d342d378a22c83390553e873713c0454ce5f3234397111ac3fe3207b86f0ed9fc025c81903e1748103692074f83824fda6341be4f95ff00b0a9a208c267e12fa01825054cc0513629bf3dbb56dc5b90d4316f87654a8be18227978ea0a8a522760cad620d0d14fd38920fb7321314062914275a5f99f677145a6979b156bd82ecd36f23f8e1273cc2759ecc0b2c69d94dad5211d1bed939dd87ed9e07b91d49713a6e16ade0a98aea789f04994e318e4ff2c8a188cd8d43aeb52c6daa3bc29b4af50ea82a247c5cd67b573b34cbadcc0a376d3bbd530d50367b42705d870f2e27a8197ef46070528bfe408360faa2ebb8bf76e9f388572842bcb119f4d84ee34ae31f5cc594f23705a49197b181fb78ed1ec99499c690f843a4d0cf2e226d118e9372271054fbabdcc5c92ae9fefaef0589cd0e722eaf30c1703ec4289c7fd81beaa8a455ccee5298e31e2080c10c366a6fcf56f7d13582ad0bcad037c612b710fc595b70fbefaaca23623b60c6c39b11beb8e5843b6b3dac60f"), res22); + + // nagydani-5-pow0x10001 + byte[] data23 = Hex.decode("000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000400c5a1611f8be90071a43db23cc2fe01871cc4c0e8ab5743f6378e4fef77f7f6db0095c0727e20225beb665645403453e325ad5f9aeb9ba99bf3c148f63f9c07cf4fe8847ad5242d6b7d4499f93bd47056ddab8f7dee878fc2314f344dbee2a7c41a5d3db91eff372c730c2fdd3a141a4b61999e36d549b9870cf2f4e632c4d5df5f024f81c028000073a0ed8847cfb0593d36a47142f578f05ccbe28c0c06aeb1b1da027794c48db880278f79ba78ae64eedfea3c07d10e0562668d839749dc95f40467d15cf65b9cfc52c7c4bcef1cda3596dd52631aac942f146c7cebd46065131699ce8385b0db1874336747ee020a5698a3d1a1082665721e769567f579830f9d259cec1a836845109c21cf6b25da572512bf3c42fd4b96e43895589042ab60dd41f497db96aec102087fe784165bb45f942859268fd2ff6c012d9d00c02ba83eace047cc5f7b2c392c2955c58a49f0338d6fc58749c9db2155522ac17914ec216ad87f12e0ee95574613942fa615898c4d9e8a3be68cd6afa4e7a003dedbdf8edfee31162b174f965b20ae752ad89c967b3068b6f722c16b354456ba8e280f987c08e0a52d40a2e8f3a59b94d590aeef01879eb7a90b3ee7d772c839c85519cbeaddc0c193ec4874a463b53fcaea3271d80ebfb39b33489365fc039ae549a17a9ff898eea2f4cb27b8dbee4c17b998438575b2b8d107e4a0d66ba7fca85b41a58a8d51f191a35c856dfbe8aef2b00048a694bbccff832d23c8ca7a7ff0b6c0b3011d00b97c86c0628444d267c951d9e4fb8f83e154b8f74fb51aa16535e498235c5597dac9606ed0be3173a3836baa4e7d756ffe1e2879b415d3846bccd538c05b847785699aefde3e305decb600cd8fb0e7d8de5efc26971a6ad4e6d7a2d91474f1023a0ac4b78dc937da0ce607a45974d2cac1c33a2631ff7fe6144a3b2e5cf98b531a9627dea92c1dc82204d09db0439b6a11dd64b484e1263aa45fd9539b6020b55e3baece3986a8bffc1003406348f5c61265099ed43a766ee4f93f5f9c5abbc32a0fd3ac2b35b87f9ec26037d88275bd7dd0a54474995ee34ed3727f3f97c48db544b1980193a4b76a8a3ddab3591ce527f16d91882e67f0103b5cda53f7da54d489fc4ac08b6ab358a5a04aa9daa16219d50bd672a7cb804ed769d218807544e5993f1c27427104b349906a0b654df0bf69328afd3013fbe430155339c39f236df5557bf92f1ded7ff609a8502f49064ec3d1dbfb6c15d3a4c11a4f8acd12278cbf68acd5709463d12e3338a6eddb8c112f199645e23154a8e60879d2a654e3ed9296aa28f134168619691cd2c6b9e2eba4438381676173fc63c2588a3c5910dc149cf3760f0aa9fa9c3f5faa9162b0bf1aac9dd32b706a60ef53cbdb394b6b40222b5bc80eea82ba8958386672564cae3794f977871ab62337cf010001e30049201ec12937e7ce79d0f55d9c810e20acf52212aca1d3888949e0e4830aad88d804161230eb89d4d329cc83570fe257217d2119134048dd2ed167646975fc7d77136919a049ea74cf08ddd2b896890bb24a0ba18094a22baa351bf29ad96c66bbb1a598f2ca391749620e62d61c3561a7d3653ccc8892c7b99baaf76bf836e2991cb06d6bc0514568ff0d1ec8bb4b3d6984f5eaefb17d3ea2893722375d3ddb8e389a8eef7d7d198f8e687d6a513983df906099f9a2d23f4f9dec6f8ef2f11fc0a21fac45353b94e00486f5e17d386af42502d09db33cf0cf28310e049c07e88682aeeb00cb833c5174266e62407a57583f1f88b304b7c6e0c84bbe1c0fd423072d37a5bd0aacf764229e5c7cd02473460ba3645cd8e8ae144065bf02d0dd238593d8e230354f67e0b2f23012c23274f80e3ee31e35e2606a4a3f31d94ab755e6d163cff52cbb36b6d0cc67ffc512aeed1dce4d7a0d70ce82f2baba12e8d514dc92a056f994adfb17b5b9712bd5186f27a2fda1f7039c5df2c8587fdc62f5627580c13234b55be4df3056050e2d1ef3218f0dd66cb05265fe1acfb0989d8213f2c19d1735a7cf3fa65d88dad5af52dc2bba22b7abf46c3bc77b5091baab9e8f0ddc4d5e581037de91a9f8dcbc69309be29cc815cf19a20a7585b8b3073edf51fc9baeb3e509b97fa4ecfd621e0fd57bd61cac1b895c03248ff12bdbc57509250df3517e8a3fe1d776836b34ab352b973d932ef708b14f7418f9eceb1d87667e61e3e758649cb083f01b133d37ab2f5afa96d6c84bcacf4efc3851ad308c1e7d9113624fce29fab460ab9d2a48d92cdb281103a5250ad44cb2ff6e67ac670c02fdafb3e0f1353953d6d7d5646ca1568dea55275a050ec501b7c6250444f7219f1ba7521ba3b93d089727ca5f3bbe0d6c1300b423377004954c5628fdb65770b18ced5c9b23a4a5a6d6ef25fe01b4ce278de0bcc4ed86e28a0a68818ffa40970128cf2c38740e80037984428c1bd5113f40ff47512ee6f4e4d8f9b8e8e1b3040d2928d003bd1c1329dc885302fbce9fa81c23b4dc49c7c82d29b52957847898676c89aa5d32b5b0e1c0d5a2b79a19d67562f407f19425687971a957375879d90c5f57c857136c17106c9ab1b99d80e69c8c954ed386493368884b55c939b8d64d26f643e800c56f90c01079d7c534e3b2b7ae352cefd3016da55f6a85eb803b85e2304915fd2001f77c74e28746293c46e4f5f0fd49cf988aafd0026b8e7a3bab2da5cdce1ea26c2e29ec03f4807fac432662b2d6c060be1c7be0e5489de69d0a6e03a4b9117f9244b34a0f1ecba89884f781c6320412413a00c4980287409a2a78c2cd7e65cecebbe4ec1c28cac4dd95f6998e78fc6f1392384331c9436aa10e10e2bf8ad2c4eafbcf276aa7bae64b74428911b3269c749338b0fc5075ad"); + byte[] res23 = contract.execute(data23).getRight(); + assertArrayEquals(Hex.decode("5a0eb2bdf0ac1cae8e586689fa16cd4b07dfdedaec8a110ea1fdb059dd5253231b6132987598dfc6e11f86780428982d50cf68f67ae452622c3b336b537ef3298ca645e8f89ee39a26758206a5a3f6409afc709582f95274b57b71fae5c6b74619ae6f089a5393c5b79235d9caf699d23d88fb873f78379690ad8405e34c19f5257d596580c7a6a7206a3712825afe630c76b31cdb4a23e7f0632e10f14f4e282c81a66451a26f8df2a352b5b9f607a7198449d1b926e27036810368e691a74b91c61afa73d9d3b99453e7c8b50fd4f09c039a2f2feb5c419206694c31b92df1d9586140cb3417b38d0c503c7b508cc2ed12e813a1c795e9829eb39ee78eeaf360a169b491a1d4e419574e712402de9d48d54c1ae5e03739b7156615e8267e1fb0a897f067afd11fb33f6e24182d7aaaaa18fe5bc1982f20d6b871e5a398f0f6f718181d31ec225cfa9a0a70124ed9a70031bdf0c1c7829f708b6e17d50419ef361cf77d99c85f44607186c8d683106b8bd38a49b5d0fb503b397a83388c5678dcfcc737499d84512690701ed621a6f0172aecf037184ddf0f2453e4053024018e5ab2e30d6d5363b56e8b41509317c99042f517247474ab3abc848e00a07f69c254f46f2a05cf6ed84e5cc906a518fdcfdf2c61ce731f24c5264f1a25fc04934dc28aec112134dd523f70115074ca34e3807aa4cb925147f3a0ce152d323bd8c675ace446d0fd1ae30c4b57f0eb2c23884bc18f0964c0114796c5b6d080c3d89175665fbf63a6381a6a9da39ad070b645c8bb1779506da14439a9f5b5d481954764ea114fac688930bc68534d403cff4210673b6a6ff7ae416b7cd41404c3d3f282fcd193b86d0f54d0006c2a503b40d5c3930da980565b8f9630e9493a79d1c03e74e5f93ac8e4dc1a901ec5e3b3e57049124c7b72ea345aa359e782285d9e6a5c144a378111dd02c40855ff9c2be9b48425cb0b2fd62dc8678fd151121cf26a65e917d65d8e0dacfae108eb5508b601fb8ffa370be1f9a8b749a2d12eeab81f41079de87e2d777994fa4d28188c579ad327f9957fb7bdecec5c680844dd43cb57cf87aeb763c003e65011f73f8c63442df39a92b946a6bd968a1c1e4d5fa7d88476a68bd8e20e5b70a99259c7d3f85fb1b65cd2e93972e6264e74ebf289b8b6979b9b68a85cd5b360c1987f87235c3c845d62489e33acf85d53fa3561fe3a3aee18924588d9c6eba4edb7a4d106b31173e42929f6f0c48c80ce6a72d54eca7c0fe870068b7a7c89c63cdda593f5b32d3cb4ea8a32c39f00ab449155757172d66763ed9527019d6de6c9f2416aa6203f4d11c9ebee1e1d3845099e55504446448027212616167eb36035726daa7698b075286f5379cd3e93cb3e0cf4f9cb8d017facbb5550ed32d5ec5400ae57e47e2bf78d1eaeff9480cc765ceff39db500"), res23); + } } From d28ba5cbde26594f6db28308129f8e8c03a699ac Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 00:27:56 +0300 Subject: [PATCH 07/23] Fixed: modexp returns incorrect length with 0 modulus --- .../src/main/java/org/ethereum/vm/PrecompiledContracts.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/PrecompiledContracts.java b/ethereumj-core/src/main/java/org/ethereum/vm/PrecompiledContracts.java index 4feb782cb2..09c8a23f53 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/PrecompiledContracts.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/PrecompiledContracts.java @@ -259,7 +259,7 @@ public Pair execute(byte[] data) { // check if modulus is zero if (isZero(mod)) - return Pair.of(true, EMPTY_BYTE_ARRAY); + return Pair.of(true, new byte[modLen]); // should keep length of the result byte[] res = stripLeadingZeroes(base.modPow(exp, mod).toByteArray()); From 89f858051b25a903653f646b876b1e3d52d3bb09 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 12:10:18 +0300 Subject: [PATCH 08/23] Fixed: Tck tests failed due to contract storage incorrect override --- .../org/ethereum/core/TransactionExecutor.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index a23db7487e..b966e172bd 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -289,19 +289,25 @@ private void create() { m_endGas = m_endGas.subtract(BigInteger.valueOf(basicTxCost)); result.spendGas(basicTxCost); } else { + Repository originalRepo = track; + // removes address in main trackc copy if the same address already exists + // TCK test case only - normally this is near-impossible situation in the real network + if (cacheTrack.hasContractDetails(newContractAddress)) { + originalRepo = track.clone(); + originalRepo.delete(newContractAddress); + } ProgramInvoke programInvoke = programInvokeFactory.createProgramInvoke(tx, currentBlock, - cacheTrack, track, blockStore); + cacheTrack, originalRepo, blockStore); this.vm = new VM(config, vmHook); this.program = new Program(tx.getData(), programInvoke, tx, config, vmHook).withCommonConfig(commonConfig); // reset storage if the contract with the same address already exists // TCK test case only - normally this is near-impossible situation in the real network - // TODO make via Trie.clear() without keyset -// ContractDetails contractDetails = program.getStorage().getContractDetails(newContractAddress); -// for (DataWord key : contractDetails.getStorageKeys()) { -// program.storageSave(key, DataWord.ZERO); -// } + ContractDetails contractDetails = program.getStorage().getContractDetails(newContractAddress); + for (DataWord key : contractDetails.getStorageKeys()) { + program.storageSave(key, DataWord.ZERO); + } } BigInteger endowment = toBI(tx.getValue()); From 6e8c218d09cba09924fcb560e84d26cebef987fe Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 12:11:36 +0300 Subject: [PATCH 09/23] Fixed: coinbase was not touched in Frontier on failed txs --- .../src/main/java/org/ethereum/config/Constants.java | 4 ++++ .../org/ethereum/config/blockchain/FrontierConfig.java | 5 +++++ .../main/java/org/ethereum/core/TransactionExecutor.java | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java index bc477d8510..980ad17b85 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java @@ -108,6 +108,10 @@ public boolean createEmptyContractOnOOG() { */ public boolean hasDelegateCallOpcode() {return false; } + public boolean touchCoinbaseOnTxReject() { + return false; + } + /** * Introduced in the Homestead release */ diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java index 0cd05d8eb9..dadb6b1ff3 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java @@ -45,6 +45,11 @@ public BigInteger getBLOCK_REWARD() { public int getMIN_GAS_LIMIT() { return 5000; } + + @Override + public boolean touchCoinbaseOnTxReject() { + return true; + } }; public FrontierConfig() { diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index b966e172bd..6d9a8f3efe 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -403,7 +403,12 @@ private void rollback() { } public TransactionExecutionSummary finalization() { - if (!readyToExecute) return null; + if (!readyToExecute) { + if (blockchainConfig.getConstants().touchCoinbaseOnTxReject()) { + track.addBalance(coinbase, BigInteger.ZERO); + } + return null; + } TransactionExecutionSummary.Builder summaryBuilder = TransactionExecutionSummary.builderFor(tx) .gasLeftover(m_endGas) From 1209aa8cb552c11626f8893b021090ea48447e7f Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 14:44:29 +0300 Subject: [PATCH 10/23] Finally fix frontier touch for coinbase --- .../java/org/ethereum/core/TransactionExecutor.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index 6d9a8f3efe..81c6c84fed 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -404,9 +404,7 @@ private void rollback() { public TransactionExecutionSummary finalization() { if (!readyToExecute) { - if (blockchainConfig.getConstants().touchCoinbaseOnTxReject()) { - track.addBalance(coinbase, BigInteger.ZERO); - } + touchCoinbaseInFrontier(); return null; } @@ -490,9 +488,17 @@ public TransactionExecutionSummary finalization() { saveProgramTraceFile(config, txHash, trace); listener.onVMTraceCreated(txHash, trace); } + + touchCoinbaseInFrontier(); return summary; } + private void touchCoinbaseInFrontier() { + if (blockchainConfig.getConstants().touchCoinbaseOnTxReject()) { + track.addBalance(coinbase, BigInteger.ZERO); + } + } + public TransactionExecutor setLocalCall(boolean localCall) { this.localCall = localCall; return this; From f51bc29654e2beb0042508a7448f81eb786d903b Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 16:54:53 +0300 Subject: [PATCH 11/23] Fixed: coinbase was not touched with bad txs or was removed later, tests-only solution --- .../java/org/ethereum/config/Constants.java | 4 ---- .../config/blockchain/FrontierConfig.java | 5 ----- .../org/ethereum/core/TransactionExecutor.java | 13 +------------ .../suite/runners/StateTestRunner.java | 17 +++++++++++++++++ 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java index 980ad17b85..bc477d8510 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java @@ -108,10 +108,6 @@ public boolean createEmptyContractOnOOG() { */ public boolean hasDelegateCallOpcode() {return false; } - public boolean touchCoinbaseOnTxReject() { - return false; - } - /** * Introduced in the Homestead release */ diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java index dadb6b1ff3..0cd05d8eb9 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java @@ -45,11 +45,6 @@ public BigInteger getBLOCK_REWARD() { public int getMIN_GAS_LIMIT() { return 5000; } - - @Override - public boolean touchCoinbaseOnTxReject() { - return true; - } }; public FrontierConfig() { diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index 81c6c84fed..b966e172bd 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -403,10 +403,7 @@ private void rollback() { } public TransactionExecutionSummary finalization() { - if (!readyToExecute) { - touchCoinbaseInFrontier(); - return null; - } + if (!readyToExecute) return null; TransactionExecutionSummary.Builder summaryBuilder = TransactionExecutionSummary.builderFor(tx) .gasLeftover(m_endGas) @@ -488,17 +485,9 @@ public TransactionExecutionSummary finalization() { saveProgramTraceFile(config, txHash, trace); listener.onVMTraceCreated(txHash, trace); } - - touchCoinbaseInFrontier(); return summary; } - private void touchCoinbaseInFrontier() { - if (blockchainConfig.getConstants().touchCoinbaseOnTxReject()) { - track.addBalance(coinbase, BigInteger.ZERO); - } - } - public TransactionExecutor setLocalCall(boolean localCall) { this.localCall = localCall; return this; diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/StateTestRunner.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/StateTestRunner.java index f06ad1597f..cdb412f627 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/StateTestRunner.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/runners/StateTestRunner.java @@ -17,6 +17,7 @@ */ package org.ethereum.jsontestsuite.suite.runners; +import org.ethereum.config.BlockchainConfig; import org.ethereum.config.SystemProperties; import org.ethereum.config.net.MainNetConfig; import org.ethereum.core.*; @@ -39,6 +40,7 @@ import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -110,6 +112,21 @@ public List runImpl() { ProgramResult programResult = executeTransaction(transaction); + // Tests only case. When: + // - coinbase suicided or + // - tx is bad so coinbase get no tx fee + // we need to manually touch coinbase + repository.addBalance(block.getCoinbase(), BigInteger.ZERO); + + // But ouch, our just touched coinbase could be subject to removal under EIP-161 + BlockchainConfig config = SystemProperties.getDefault().getBlockchainConfig().getConfigForBlock(block.getNumber()); + if (config.eip161()) { + AccountState state = repository.getAccountState(block.getCoinbase()); + if (state != null && state.isEmpty()) { + repository.delete(block.getCoinbase()); + } + } + repository.commit(); List origLogs = programResult.getLogInfoList(); From eb6e7b119e5a0ebcef8899bbc2b88a89f6eb9f10 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 16:55:40 +0300 Subject: [PATCH 12/23] Fixed all state tests (except ignored) --- .../java/org/ethereum/jsontestsuite/GitHubStateTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java index 6a4f4c7587..a249e30a7d 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java @@ -29,14 +29,15 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubStateTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "d1ece13ebfb2adb27061ae5a6155bd9ed9773d8f"; // https://github.com/ethereum/tests/tree/develop/GeneralStateTests/ + static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; + static String treeSHA = "51fd8f9969ff488917f0832c57ece01f66516db2"; // https://github.com/ethereum/tests/tree/develop/GeneralStateTests/ static GitHubJSONTestSuite.Network[] targetNets = { GitHubJSONTestSuite.Network.Frontier, GitHubJSONTestSuite.Network.Homestead, GitHubJSONTestSuite.Network.EIP150, GitHubJSONTestSuite.Network.EIP158, - GitHubJSONTestSuite.Network.Byzantium + GitHubJSONTestSuite.Network.Byzantium, + GitHubJSONTestSuite.Network.Constantinople }; static GeneralStateTestSuite suite; From 0c6fa8011784715b9f165e446a683601bfc76518 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 18:03:54 +0300 Subject: [PATCH 13/23] Fixed mark in Tck tests only comment --- .../src/main/java/org/ethereum/core/TransactionExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index b966e172bd..e344d14d9b 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -290,7 +290,7 @@ private void create() { result.spendGas(basicTxCost); } else { Repository originalRepo = track; - // removes address in main trackc copy if the same address already exists + // removes address in main track copy if the same address already exists // TCK test case only - normally this is near-impossible situation in the real network if (cacheTrack.hasContractDetails(newContractAddress)) { originalRepo = track.clone(); From 17e2a5450930a6d290e83cefd44fce9fd657c2dc Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 18:06:47 +0300 Subject: [PATCH 14/23] Remove collision storage in Tck tests for vm called create/create2 --- .../java/org/ethereum/vm/program/Program.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java index edcd2b4a01..a0a5363810 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -521,17 +521,31 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd // [5] COOK THE INVOKE AND EXECUTE byte[] nonce = getStorage().getNonce(senderAddress).toByteArray(); InternalTransaction internalTx = addInternalTx(nonce, getGasLimit(), senderAddress, null, endowment, programCode, "create"); + Repository originalRepo = this.invoke.getOrigRepository(); + // removes address in main track copy if the same address already exists + // TCK test case only - normally this is near-impossible situation in the real network + if (!contractAlreadyExists && track.hasContractDetails(newAddress)) { + originalRepo = originalRepo.clone(); + originalRepo.delete(newAddress); + } ProgramInvoke programInvoke = programInvokeFactory.createProgramInvoke( this, DataWord.of(newAddress), getOwnerAddress(), value, gasLimit, - newBalance, null, track, this.invoke.getOrigRepository(), this.invoke.getBlockStore(), false, byTestingSuite()); + newBalance, null, track, originalRepo, this.invoke.getBlockStore(), false, byTestingSuite()); ProgramResult result = ProgramResult.createEmpty(); if (contractAlreadyExists) { result.setException(new BytecodeExecutionException("Trying to create a contract with existing contract address: 0x" + toHexString(newAddress))); } else if (isNotEmpty(programCode)) { + // VM vm = new VM(config, vmHook); Program program = new Program(programCode, programInvoke, internalTx, config, vmHook).withCommonConfig(commonConfig); + // reset storage if the contract with the same address already exists + // TCK test case only - normally this is near-impossible situation in the real network + ContractDetails contractDetails = program.getStorage().getContractDetails(newAddress); + for (DataWord key : contractDetails.getStorageKeys()) { + program.storageSave(key, DataWord.ZERO); + } vm.play(program); result = program.getResult(); } From b115ae136b6ee30aa1e185fe7774f0d013c56dec Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 18:07:34 +0300 Subject: [PATCH 15/23] Fixed all Tck Constantinople state tests --- .../jsontestsuite/GitHubStateTest.java | 54 ++----------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java index a249e30a7d..c11227c4d7 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubStateTest.java @@ -153,7 +153,6 @@ public void stPreCompiledContracts2() throws IOException { } @Test - @Ignore public void stMemoryStressTest() throws IOException { Set excluded = new HashSet<>(); excluded.add("mload32bitBound_return2");// The test extends memory to 4Gb which can't be handled with Java arrays @@ -163,7 +162,6 @@ public void stMemoryStressTest() throws IOException { } @Test - @Ignore public void stMemoryTest() throws IOException { suite.runAll("stMemoryTest"); } @@ -305,65 +303,23 @@ public void stCodeCopyTest() throws IOException { @Test - @Ignore("Fails on pre-configured commit, update after test is merged in develop of Github tests") - public void stExtCodeHashCallCode() throws IOException { - String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44"; - String filePath = "stExtCodeHash/extCodeHashCallCode.json"; - GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople); - GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium); - } - - @Test - @Ignore("Fails on pre-configured commit, update after test is merged in develop of Github tests") - public void stExtCodeHashCall() throws IOException { - String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44"; - String filePath = "stExtCodeHash/extCodeHashCall.json"; - GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople); - GeneralStateTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium); + public void stExtCodeHashTest() throws IOException { + suite.runAll("stExtCodeHash"); } @Test - @Ignore("Update after all tests could pass latest develop") public void stShiftTest() throws IOException { suite.runAll("stShift"); -// TODO: Update all, this one passes with following settings: -// String commit = "ad2184adca367c0b68c65b44519dba16e1d0b9e2"; -// String treeSha = "4dd59a4f448dc06c3641bd5cb9c35cf6a099e438"; -// targetNets += GitHubJSONTestSuite.Network.Constantinople } @Test - @Ignore("Update after all tests could pass latest develop") public void stCreate2Test() throws IOException { - suite.runAll("stCreate2", new HashSet<>(Arrays.asList( - "RevertInCreateInInit", // Tests excluded because they test unreal prestate - "create2collisionStorage" // (nonce, balance 0, code empty, but some storage) - ))); -// TODO: Update all, this one passes with following settings: -// String commitSHA = "95a309203890e6244c6d4353ca411671973c13b5"; -// String treeSHA = "700fdc4aa7d74957a12fbda38785ecc7b846bcc0"; -// targetNets += GitHubJSONTestSuite.Network.Constantinople + suite.runAll("stCreate2"); } @Test - @Ignore("Update after all tests could pass latest develop") - public void stSstoreRefundBug() throws IOException { - final String commit = "9ff64743f0347952903287b9074803607e5855e8"; - - GeneralStateTestSuite.runSingle("stSStoreTest/SstoreCallToSelfSubRefundBelowZero.json", commit, - GitHubJSONTestSuite.Network.Constantinople); - - GeneralStateTestSuite.runSingle("stSStoreTest/sstore_0to0.json", commit, - GitHubJSONTestSuite.Network.Constantinople); - - GeneralStateTestSuite.runSingle("stSStoreTest/sstore_Xto0.json", commit, - GitHubJSONTestSuite.Network.Constantinople); - - GeneralStateTestSuite.runSingle("stSStoreTest/sstore_XtoX.json", commit, - GitHubJSONTestSuite.Network.Constantinople); - - GeneralStateTestSuite.runSingle("stSStoreTest/sstore_XtoY.json", commit, - GitHubJSONTestSuite.Network.Constantinople); + public void stSstoreTest() throws IOException { + suite.runAll("stSStoreTest"); } } From 50db7584f6ad13986cae449f63f0793e12cbdebe Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 18:18:14 +0300 Subject: [PATCH 16/23] Fixed Tck blosk state tests for Constantinople --- .../jsontestsuite/GitHubBlockStateTest.java | 44 +++++-------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockStateTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockStateTest.java index e9d14598c2..3de94cd8e0 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockStateTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockStateTest.java @@ -32,15 +32,16 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class GitHubBlockStateTest { - static String commitSHA = "7f638829311dfc1d341c1db85d8a891f57fa4da7"; - static String treeSHA = "9b96943196bfbb8b49651eab5e479956d7dabcc7"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/GeneralStateTests/ + static String commitSHA = "253e99861fe406c7b1daf3d6a0c40906e8a8fd8f"; + static String treeSHA = "724427f69f5573ed0f504a534b3ecbcd3070fa28"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/GeneralStateTests/ static GitHubJSONTestSuite.Network[] targetNets = { GitHubJSONTestSuite.Network.Frontier, GitHubJSONTestSuite.Network.Homestead, GitHubJSONTestSuite.Network.EIP150, GitHubJSONTestSuite.Network.EIP158, - GitHubJSONTestSuite.Network.Byzantium + GitHubJSONTestSuite.Network.Byzantium, + GitHubJSONTestSuite.Network.Constantinople }; static BlockchainTestSuite suite; @@ -153,7 +154,6 @@ public void bcStPreCompiledContracts2() throws IOException { } @Test - @Ignore public void bcStMemoryStressTest() throws IOException { Set excluded = new HashSet<>(); excluded.add("mload32bitBound_return2");// The test extends memory to 4Gb which can't be handled with Java arrays @@ -302,42 +302,22 @@ public void stCodeCopyTest() throws IOException { } @Test - @Ignore("Broken tests format, delayed until resolved") - public void stExtCodeHashCallCode() throws IOException { - String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44"; - String filePath = "GeneralStateTests/stExtCodeHash/extCodeHashCallCode_d0g0v0.json"; - BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople); - BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium); - } - - @Test - @Ignore("Broken tests format, delayed until resolved") - public void stExtCodeHashCall() throws IOException { - String commit = "10ab37c095bb87d2e781bcf112b6104912fccb44"; - String filePath = "GeneralStateTests/stExtCodeHash/extCodeHashCall_d0g0v0.json"; - BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Constantinople); - BlockchainTestSuite.runSingle(filePath, commit, GitHubJSONTestSuite.Network.Byzantium); + public void stExtCodeHash() throws IOException { + suite.runAll("stExtCodeHash"); } @Test - @Ignore("Update after all tests could pass latest develop") public void stShiftTest() throws IOException { suite.runAll("stShift"); -// TODO: Update all, this one passes with following settings: -// String commitSHA = "560e2cd6cf881821180d46d9cc4c542e19cfea1d"; -// String treeSHA = "8457a6a49f53218575a349abc311c55939797bff"; -// targetNets += GitHubJSONTestSuite.Network.Constantinople } @Test - @Ignore("Update after all tests could pass latest develop") public void stCreate2Test() throws IOException { - suite.runAll("stCreate2", new HashSet<>(Arrays.asList( - "create2collisionStorage_d1g0v0" // Tests excluded because they test unreal prestate - ))); // (nonce, balance 0, code empty, but some storage) -// TODO: Update all, this one passes with following settings: -// String commitSHA = "e2d84e1c00289bc259ad631efb6b42390e6a291a"; -// String treeSHA = "d74573a79cf607744759acde258bf7c3cf849bf1"; -// targetNets += GitHubJSONTestSuite.Network.Constantinople + suite.runAll("stCreate2"); + } + + @Test + public void stSstoreTest() throws IOException { + suite.runAll("stSStoreTest"); } } From 9a1262bdfec87350778d3dcf14a550b3d1d8bfca Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 18:41:11 +0300 Subject: [PATCH 17/23] Fixed rlp test parsing to handle 0x --- .../ethereum/jsontestsuite/suite/RLPTestCase.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/RLPTestCase.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/RLPTestCase.java index ad121df320..738ef03539 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/RLPTestCase.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/RLPTestCase.java @@ -72,7 +72,7 @@ public void doEncode() { } byte[] in = buildRLP(this.in); - String expected = this.out.toLowerCase(); + String expected = parseOut(); String computed = Hex.toHexString(in); this.computed.add(computed); this.expected.add(expected); @@ -80,7 +80,7 @@ public void doEncode() { public void doDecode() { - String out = this.out.toLowerCase(); + String out = parseOut(); try { RLPList list = RLP.decode2(Hex.decode(out)); @@ -92,6 +92,15 @@ public void doDecode() { } } + private String parseOut() { + String out = this.out.toLowerCase(); + if (out.startsWith("0x")) { + return out.substring(2); + } else { + return out; + } + } + public byte[] buildRLP(Object in) { if (in instanceof ArrayList) { List elementList = new Vector<>(); From 64e840c3991c205578a5784ef7f8d326491989c2 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 20:18:50 +0300 Subject: [PATCH 18/23] Rebuilt contract storage clean before create to stop failing when not implemented using ContractDetails --- .../java/org/ethereum/core/TransactionExecutor.java | 4 +--- .../src/main/java/org/ethereum/db/ContractDetails.java | 3 +++ .../src/main/java/org/ethereum/db/RepositoryImpl.java | 5 +++++ .../src/main/java/org/ethereum/vm/program/Program.java | 4 +--- .../jsontestsuite/suite/AbstractContractDetails.java | 10 ++++++++++ .../jsontestsuite/suite/IterableTestRepository.java | 8 ++++++++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index e344d14d9b..1a617cc940 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -305,9 +305,7 @@ private void create() { // reset storage if the contract with the same address already exists // TCK test case only - normally this is near-impossible situation in the real network ContractDetails contractDetails = program.getStorage().getContractDetails(newContractAddress); - for (DataWord key : contractDetails.getStorageKeys()) { - program.storageSave(key, DataWord.ZERO); - } + contractDetails.deleteStorage(); } BigInteger endowment = toBI(tx.getValue()); diff --git a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java index 14b03a3339..aa7748e9b6 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java @@ -55,6 +55,9 @@ public interface ContractDetails { Set getStorageKeys(); + // Removes all storage, key by key, if supported + void deleteStorage(); + Map getStorage(@Nullable Collection keys); Map getStorage(); diff --git a/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java b/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java index 425a1f81a7..8725d964c7 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java @@ -315,6 +315,11 @@ public Set getStorageKeys() { throw new RuntimeException("Not supported"); } + @Override + public void deleteStorage() { + // do nothing as getStorageKeys() is not supported + } + @Override public Map getStorage(@Nullable Collection keys) { throw new RuntimeException("Not supported"); diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java index a0a5363810..a74e6b8a46 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -543,9 +543,7 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd // reset storage if the contract with the same address already exists // TCK test case only - normally this is near-impossible situation in the real network ContractDetails contractDetails = program.getStorage().getContractDetails(newAddress); - for (DataWord key : contractDetails.getStorageKeys()) { - program.storageSave(key, DataWord.ZERO); - } + contractDetails.deleteStorage(); vm.play(program); result = program.getResult(); } diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/AbstractContractDetails.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/AbstractContractDetails.java index 3c4d289d94..4217df78b4 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/AbstractContractDetails.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/AbstractContractDetails.java @@ -19,10 +19,12 @@ import org.ethereum.db.ByteArrayWrapper; import org.ethereum.db.ContractDetails; +import org.ethereum.vm.DataWord; import org.spongycastle.util.encoders.Hex; import java.util.HashMap; import java.util.Map; +import java.util.Set; import static org.ethereum.crypto.HashUtil.sha3; import static org.ethereum.crypto.HashUtil.EMPTY_DATA_HASH; @@ -94,6 +96,14 @@ public boolean isDeleted() { public abstract ContractDetails clone(); + @Override + public void deleteStorage() { + Set keys = getStorageKeys(); + for (DataWord key: keys) { + put(key, DataWord.ZERO); + } + } + @Override public String toString() { String ret = " Code: " + (codes.size() < 2 ? Hex.toHexString(getCode()) : codes.size() + " versions" ) + "\n"; diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/IterableTestRepository.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/IterableTestRepository.java index ab178de013..995ff25934 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/IterableTestRepository.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/suite/IterableTestRepository.java @@ -353,6 +353,14 @@ public Set getStorageKeys() { return getStorage().keySet(); } + @Override + public void deleteStorage() { + Set keys = getStorageKeys(); + for (DataWord key: keys) { + put(key, DataWord.ZERO); + } + } + @Override public Map getStorage(@Nullable Collection keys) { throw new RuntimeException(); From 7f5f5ee7394ecf39e2fe5c8e6a7a31b6ab7b3ee7 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 20:19:24 +0300 Subject: [PATCH 19/23] Bump Tck(Github) tests to the latest commit as of X-Mas 2018 --- ethereumj-core/src/test/resources/github-tests.prop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereumj-core/src/test/resources/github-tests.prop b/ethereumj-core/src/test/resources/github-tests.prop index 384a6008e2..a735f64ed8 100644 --- a/ethereumj-core/src/test/resources/github-tests.prop +++ b/ethereumj-core/src/test/resources/github-tests.prop @@ -2,4 +2,4 @@ # to determinate commit of Ethereum tests repo https://github.com/ethereum/tests # which should be checked out in local repo directory # EthereumJ is tested with files from this commit -GitHubTests.commit=7f638829311dfc1d341c1db85d8a891f57fa4da7 +GitHubTests.commit=253e99861fe406c7b1daf3d6a0c40906e8a8fd8f From f79c2d33df1f33a50770754fde91747f5e961a68 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Mon, 24 Dec 2018 20:25:15 +0300 Subject: [PATCH 20/23] Schedule Constantinople fork on MainNet according to EIP-1013 --- .../src/main/java/org/ethereum/config/net/MainNetConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java index 3eef0f360e..887df9c3ac 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/net/MainNetConfig.java @@ -32,5 +32,6 @@ public MainNetConfig() { add(2_463_000, new Eip150HFConfig(new DaoHFConfig())); add(2_675_000, new Eip160HFConfig(new DaoHFConfig())); add(4_370_000, new ByzantiumConfig(new DaoHFConfig())); + add(7_080_000, new ConstantinopleConfig(new DaoHFConfig())); } } From da8f69a54ec13dba026c03fc1390a45016fcfc77 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Tue, 25 Dec 2018 10:26:27 +0300 Subject: [PATCH 21/23] Removed empty comment --- .../src/main/java/org/ethereum/vm/program/Program.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java index a74e6b8a46..6690f7e399 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -537,7 +537,6 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd if (contractAlreadyExists) { result.setException(new BytecodeExecutionException("Trying to create a contract with existing contract address: 0x" + toHexString(newAddress))); } else if (isNotEmpty(programCode)) { - // VM vm = new VM(config, vmHook); Program program = new Program(programCode, programInvoke, internalTx, config, vmHook).withCommonConfig(commonConfig); // reset storage if the contract with the same address already exists From 913f6fc83d8433c70c7a358e177aa5d766b3b203 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Wed, 26 Dec 2018 11:28:17 +0300 Subject: [PATCH 22/23] Comments associated with account removal before tx execution updated to be clearer --- .../src/main/java/org/ethereum/core/TransactionExecutor.java | 5 +++-- .../src/main/java/org/ethereum/vm/program/Program.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index 1a617cc940..2e6e7db285 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -290,8 +290,9 @@ private void create() { result.spendGas(basicTxCost); } else { Repository originalRepo = track; - // removes address in main track copy if the same address already exists - // TCK test case only - normally this is near-impossible situation in the real network + // Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network + // So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly + // reverted in that case too if (cacheTrack.hasContractDetails(newContractAddress)) { originalRepo = track.clone(); originalRepo.delete(newContractAddress); diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java index 6690f7e399..1ac52a21cc 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -522,8 +522,9 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd byte[] nonce = getStorage().getNonce(senderAddress).toByteArray(); InternalTransaction internalTx = addInternalTx(nonce, getGasLimit(), senderAddress, null, endowment, programCode, "create"); Repository originalRepo = this.invoke.getOrigRepository(); - // removes address in main track copy if the same address already exists - // TCK test case only - normally this is near-impossible situation in the real network + // Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network + // So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly + // reverted in that case too if (!contractAlreadyExists && track.hasContractDetails(newAddress)) { originalRepo = originalRepo.clone(); originalRepo.delete(newAddress); From 444e8dc64d2741c95a915b16b0887cb0287abfc0 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Wed, 26 Dec 2018 11:31:37 +0300 Subject: [PATCH 23/23] Fixed typos in comments --- .../src/main/java/org/ethereum/core/TransactionExecutor.java | 2 +- .../src/main/java/org/ethereum/vm/program/Program.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index 2e6e7db285..d28dcabcab 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -290,7 +290,7 @@ private void create() { result.spendGas(basicTxCost); } else { Repository originalRepo = track; - // Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network + // Some TCK tests have storage only addresses (no code, zero nonce etc) - impossible situation in the real network // So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly // reverted in that case too if (cacheTrack.hasContractDetails(newContractAddress)) { diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java index 1ac52a21cc..659caf9af5 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -522,7 +522,7 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd byte[] nonce = getStorage().getNonce(senderAddress).toByteArray(); InternalTransaction internalTx = addInternalTx(nonce, getGasLimit(), senderAddress, null, endowment, programCode, "create"); Repository originalRepo = this.invoke.getOrigRepository(); - // Some TCK tests have storage only addresses (no code, zero none etc) - impossible situation in the real network + // Some TCK tests have storage only addresses (no code, zero nonce etc) - impossible situation in the real network // So, we should clean up it before reuse, but as tx not always goes successful, state should be correctly // reverted in that case too if (!contractAlreadyExists && track.hasContractDetails(newAddress)) {