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 8afa81a4..e912f073 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -89,6 +89,16 @@ public class TransactionExecutor { return; } + //Insert gas cost protection + BigInteger gasLimit = new BigInteger(1, tx.getGasLimit()); + if (gasLimit.compareTo(BigInteger.ZERO) == 0) { + logger.debug("No gas limit set on transaction: hash={}", + Hex.toHexString(tx.getHash())); + + receipt.setCumulativeGas(0); + this.receipt = receipt; + return; + } // FIND OUT THE TRANSACTION TYPE final byte[] receiverAddress; diff --git a/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java b/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java index 07e08a8d..adc61ef8 100644 --- a/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java @@ -110,12 +110,10 @@ public class GitHubStateTest { GitHubJSONTestSuite.runGitHubJsonStateTest(json, excluded); } - @Test // todo: fix: excluded test public void stTransactionTest() throws ParseException { Set excluded = new HashSet<>(); - excluded.add("EmptyTransaction"); //todo: it goes OOG, because no gasLimit is given. So it does not change the state.