diff --git a/rskj-core/src/test/java/co/rsk/rpc/modules/trace/TraceTransformerTest.java b/rskj-core/src/test/java/co/rsk/rpc/modules/trace/TraceTransformerTest.java index c17c96533bb..da578fc7499 100644 --- a/rskj-core/src/test/java/co/rsk/rpc/modules/trace/TraceTransformerTest.java +++ b/rskj-core/src/test/java/co/rsk/rpc/modules/trace/TraceTransformerTest.java @@ -43,7 +43,7 @@ void getActionFromInvokeData() { gas, callValue, data, - null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, 0, null, false, false); TraceAction action = TraceTransformer.toAction(TraceType.CALL, invoke, CallType.CALL, null, null, null); @@ -76,7 +76,7 @@ void getActionFromInvokeDataWithCreationData() { gas, callValue, null, - null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, 0, null, false, false); TraceAction action = TraceTransformer.toAction(TraceType.CREATE, invoke, CallType.NONE, data, null, null); @@ -110,7 +110,7 @@ void getActionFromInvokeDataWithCreationDataUsingCreationMethod() { gas, callValue, null, - null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, 0, null, false, false); TraceAction action = TraceTransformer.toAction(TraceType.CREATE, invoke, CallType.NONE, data, "create2", null); diff --git a/rskj-core/src/test/java/org/ethereum/jsontestsuite/Env.java b/rskj-core/src/test/java/org/ethereum/jsontestsuite/Env.java index 4aef0fd6eaf..a854065f015 100644 --- a/rskj-core/src/test/java/org/ethereum/jsontestsuite/Env.java +++ b/rskj-core/src/test/java/org/ethereum/jsontestsuite/Env.java @@ -33,17 +33,20 @@ public class Env { private final byte[] currentCoinbase; private final byte[] currentDifficulty; private final byte[] currentGasLimit; + private final byte[] currentMinimumGasPrice; private final byte[] currentNumber; private final byte[] currentTimestamp; private final byte[] previousHash; public Env(byte[] currentCoinbase, byte[] currentDifficulty, byte[] - currentGasLimit, byte[] currentNumber, byte[] - currentTimestamp, byte[] previousHash) { + currentGasLimit, byte[] currentMinimumGasPrice, + byte[] currentNumber, byte[] currentTimestamp, + byte[] previousHash) { this.currentCoinbase = currentCoinbase; this.currentDifficulty = currentDifficulty; this.currentGasLimit = currentGasLimit; + this.currentMinimumGasPrice = currentMinimumGasPrice; this.currentNumber = currentNumber; this.currentTimestamp = currentTimestamp; this.previousHash = previousHash; @@ -54,6 +57,7 @@ public Env(byte[] currentCoinbase, byte[] currentDifficulty, byte[] "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "256", "currentGasLimit" : "1000000", + "currentMinimumGasPrice" : "777", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -65,12 +69,14 @@ public Env(JsonNode env) { String timestamp = env.get("currentTimestamp").asText(); String number = env.get("currentNumber").asText(); String gasLimit = org.ethereum.json.Utils.parseUnidentifiedBase(env.get("currentGasLimit").asText()); + String minimumGasPrice = org.ethereum.json.Utils.parseUnidentifiedBase(env.get("minimumGasPrice").asText()); JsonNode previousHash = env.get("previousHash"); String prevHash = previousHash == null ? "" : previousHash.asText(); this.currentCoinbase = Hex.decode(coinbase); this.currentDifficulty = BigIntegers.asUnsignedByteArray(TestingCase.toBigInt(difficulty) ); - this.currentGasLimit = BigIntegers.asUnsignedByteArray(TestingCase.toBigInt(gasLimit)); + this.currentGasLimit = BigIntegers.asUnsignedByteArray(TestingCase.toBigInt(gasLimit)); + this.currentMinimumGasPrice = BigIntegers.asUnsignedByteArray(TestingCase.toBigInt(minimumGasPrice)); this.currentNumber = TestingCase.toBigInt(number).toByteArray(); this.currentTimestamp = TestingCase.toBigInt(timestamp).toByteArray(); this.previousHash = Hex.decode(prevHash); @@ -89,6 +95,10 @@ public byte[] getCurrentGasLimit() { return currentGasLimit; } + public byte[] getCurrentMinimumGasPrice() { + return currentMinimumGasPrice; + } + public byte[] getCurrentNumber() { return currentNumber; } @@ -107,6 +117,7 @@ public String toString() { "currentCoinbase=" + ByteUtil.toHexString(currentCoinbase) + ", currentDifficulty=" + ByteUtil.toHexString(currentDifficulty) + ", currentGasLimit=" + ByteUtil.toHexString(currentGasLimit) + + ", currentMinimumGasPrice=" + ByteUtil.toHexString(currentMinimumGasPrice) + ", currentNumber=" + ByteUtil.toHexString(currentNumber) + ", currentTimestamp=" + ByteUtil.toHexString(currentTimestamp) + ", previousHash=" + ByteUtil.toHexString(previousHash) + diff --git a/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestProgramInvokeFactory.java b/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestProgramInvokeFactory.java index e19db998bad..3af60cfbe7c 100644 --- a/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestProgramInvokeFactory.java +++ b/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestProgramInvokeFactory.java @@ -47,7 +47,7 @@ public TestProgramInvokeFactory(Env env) { @Override public ProgramInvoke createProgramInvoke(Transaction tx, int txindex, Block block, Repository repository, BlockStore blockStore, SignatureCache signatureCache) { - return generalInvoke(tx, txindex, repository, blockStore, signatureCache); + return generalInvoke(tx, txindex, block, repository, blockStore, signatureCache); } @Override @@ -59,7 +59,7 @@ public ProgramInvoke createProgramInvoke(Program program, DataWord toAddress, Da return null; } - private ProgramInvoke generalInvoke(Transaction tx, int txindex, Repository repository, BlockStore blockStore, SignatureCache signatureCache) { + private ProgramInvoke generalInvoke(Transaction tx, int txindex, Block block, Repository repository, BlockStore blockStore, SignatureCache signatureCache) { /*** ADDRESS op ***/ // YP: Get address of currently executing account. @@ -77,7 +77,7 @@ private ProgramInvoke generalInvoke(Transaction tx, int txindex, Repository repo Coin balance = repository.getBalance(addr); /*** GASPRICE op ***/ - Coin gasPrice = tx.getGasPrice(); + Coin txGasPrice = tx.getGasPrice(); /*** GAS op ***/ byte[] gas = tx.getGasLimit(); @@ -109,9 +109,12 @@ private ProgramInvoke generalInvoke(Transaction tx, int txindex, Repository repo /*** GASLIMIT op ***/ byte[] gaslimit = env.getCurrentGasLimit(); + /*** BASEFEE op ***/ + Coin minimumGasPrice = block.getMinimumGasPrice(); + return new ProgramInvokeImpl(addr.getBytes(), origin.getBytes(), caller.getBytes(), balance.getBytes(), - gasPrice.getBytes(), gas, callValue.getBytes(), data, lastHash, coinbase, - timestamp, number, txindex, difficulty, gaslimit, repository, blockStore); + txGasPrice.getBytes(), gas, callValue.getBytes(), data, lastHash, coinbase, + timestamp, number, txindex, difficulty, gaslimit, minimumGasPrice.getBytes(), repository, blockStore); } } diff --git a/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestRunner.java b/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestRunner.java index 5d4a7ea3e26..2f01f686168 100644 --- a/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestRunner.java +++ b/rskj-core/src/test/java/org/ethereum/jsontestsuite/TestRunner.java @@ -252,7 +252,7 @@ public List runTestCase(TestingCase testCase) { byte[] origin = exec.getOrigin(); byte[] caller = exec.getCaller(); byte[] balance = ByteUtil.bigIntegerToBytes(repository.getBalance(new RskAddress(exec.getAddress())).asBigInteger()); - byte[] gasPrice = exec.getGasPrice(); + byte[] txGasPrice = exec.getGasPrice(); byte[] gas = exec.getGas(); byte[] callValue = exec.getValue(); byte[] msgData = exec.getData(); @@ -262,6 +262,7 @@ public List runTestCase(TestingCase testCase) { long number = ByteUtil.byteArrayToLong(env.getCurrentNumber()); byte[] difficulty = env.getCurrentDifficulty(); byte[] gaslimit = env.getCurrentGasLimit(); + byte[] minimumGasPrice = env.getCurrentMinimumGasPrice(); // Origin and caller need to exist in order to be able to execute RskAddress originAddress = new RskAddress(origin); @@ -274,8 +275,8 @@ public List runTestCase(TestingCase testCase) { } ProgramInvoke programInvoke = new ProgramInvokeImpl(address, origin, caller, balance, - gasPrice, gas, callValue, msgData, lastHash, coinbase, - timestamp, number, 0, difficulty, gaslimit, repository, new BlockStoreDummy(), true); + txGasPrice, gas, callValue, msgData, lastHash, coinbase, + timestamp, number, 0, difficulty, gaslimit, minimumGasPrice, repository, new BlockStoreDummy(), true); /* 3. Create Program - exec.code */ /* 4. run VM */ diff --git a/rskj-core/src/test/java/org/ethereum/jsontestsuite/builder/EnvBuilder.java b/rskj-core/src/test/java/org/ethereum/jsontestsuite/builder/EnvBuilder.java index 2914d33af47..afc5b811ee5 100644 --- a/rskj-core/src/test/java/org/ethereum/jsontestsuite/builder/EnvBuilder.java +++ b/rskj-core/src/test/java/org/ethereum/jsontestsuite/builder/EnvBuilder.java @@ -30,11 +30,12 @@ public static Env build(EnvTck envTck){ byte[] coinbase = parseData(envTck.getCurrentCoinbase()); byte[] difficulty = parseVarData(envTck.getCurrentDifficulty()); byte[] gasLimit = parseVarData(envTck.getCurrentGasLimit()); + byte[] minimumGasPrice = parseVarData(envTck.getCurrentMinimumGasPrice()); byte[] number = parseNumericData(envTck.getCurrentNumber()); byte[] timestamp = parseNumericData(envTck.getCurrentTimestamp()); byte[] hash = parseData(envTck.getPreviousHash()); - return new Env(coinbase, difficulty, gasLimit, number, timestamp, hash); + return new Env(coinbase, difficulty, gasLimit, minimumGasPrice, number, timestamp, hash); } } diff --git a/rskj-core/src/test/java/org/ethereum/jsontestsuite/model/EnvTck.java b/rskj-core/src/test/java/org/ethereum/jsontestsuite/model/EnvTck.java index 24721a127f3..36a26784788 100644 --- a/rskj-core/src/test/java/org/ethereum/jsontestsuite/model/EnvTck.java +++ b/rskj-core/src/test/java/org/ethereum/jsontestsuite/model/EnvTck.java @@ -24,6 +24,7 @@ public class EnvTck { String currentCoinbase; String currentDifficulty; String currentGasLimit; + String currentMinimumGasPrice; String currentNumber; String currentTimestamp; String previousHash; @@ -55,6 +56,14 @@ public void setCurrentGasLimit(String currentGasLimit) { this.currentGasLimit = currentGasLimit; } + public String getCurrentMinimumGasPrice() { + return currentMinimumGasPrice; + } + + public void setCurrentMinimumGasPrice(String currentMinimumGasPrice) { + this.currentMinimumGasPrice = currentMinimumGasPrice; + } + public String getCurrentNumber() { return currentNumber; } diff --git a/rskj-core/src/test/java/org/ethereum/vm/program/ProgramInvokeImplTest.java b/rskj-core/src/test/java/org/ethereum/vm/program/ProgramInvokeImplTest.java index 43e68746e57..27127f5cede 100644 --- a/rskj-core/src/test/java/org/ethereum/vm/program/ProgramInvokeImplTest.java +++ b/rskj-core/src/test/java/org/ethereum/vm/program/ProgramInvokeImplTest.java @@ -32,6 +32,7 @@ void testEquals_OK() { int transactionIndex1 = 3; byte[] difficulty1 = new byte[]{11}; byte[] gasLimit1 = new byte[]{12}; + byte[] minimumGasPrice1 = new byte[]{13}; Repository repository1 = RepositoryBuilder.build(Collections.emptyMap()); BlockStore blockStore1 = new BlockStoreDummy(); boolean byTestingSuite1 = true; @@ -51,13 +52,14 @@ void testEquals_OK() { int transactionIndex2 = 2; byte[] difficulty2 = new byte[]{2}; byte[] gasLimit2 = new byte[]{1}; + byte[] minimumGasPrice2 = new byte[]{14}; Repository repository2 = null; BlockStore blockStore2 = null; boolean byTestingSuite2 = false; // An object must be equal to itself - ProgramInvokeImpl programInvokeA = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, repository1, blockStore1, byTestingSuite1); + ProgramInvokeImpl programInvokeA = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, minimumGasPrice1, repository1, blockStore1, byTestingSuite1); assertEquals(programInvokeA, programInvokeA); @@ -67,15 +69,15 @@ void testEquals_OK() { // Same property values make objects to be equal - ProgramInvokeImpl programInvokeB = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, repository1, blockStore1, byTestingSuite1); + ProgramInvokeImpl programInvokeB = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, minimumGasPrice1, repository1, blockStore1, byTestingSuite1); assertEquals(programInvokeA, programInvokeB); // Different combinations of property values make objects to be different - ProgramInvokeImpl programInvokeC = new ProgramInvokeImpl(address2, origin2, caller2, balance2, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number2, transactionIndex2, difficulty2, gasLimit2, repository2, blockStore2, byTestingSuite2); - ProgramInvokeImpl programInvokeD = new ProgramInvokeImpl(address2, origin2, caller2, balance1, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number1, transactionIndex2, difficulty2, gasLimit2, repository2, blockStore2, byTestingSuite2); - ProgramInvokeImpl programInvokeE = new ProgramInvokeImpl(address2, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, repository1, blockStore1, byTestingSuite1); + ProgramInvokeImpl programInvokeC = new ProgramInvokeImpl(address2, origin2, caller2, balance2, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number2, transactionIndex2, difficulty2, gasLimit2, minimumGasPrice2, repository2, blockStore2, byTestingSuite2); + ProgramInvokeImpl programInvokeD = new ProgramInvokeImpl(address2, origin2, caller2, balance1, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number1, transactionIndex2, difficulty2, gasLimit2, minimumGasPrice2, repository2, blockStore2, byTestingSuite2); + ProgramInvokeImpl programInvokeE = new ProgramInvokeImpl(address2, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, minimumGasPrice1, repository1, blockStore1, byTestingSuite1); assertNotEquals(programInvokeA, programInvokeC); assertNotEquals(programInvokeA, programInvokeD); @@ -103,6 +105,7 @@ void testHashcode_OK() { int transactionIndex1 = 3; byte[] difficulty1 = new byte[]{11}; byte[] gasLimit1 = new byte[]{12}; + byte[] minimumGasPrice1 = new byte[]{13}; Repository repository1 = RepositoryBuilder.build(Collections.emptyMap()); BlockStore blockStore1 = new BlockStoreDummy(); boolean byTestingSuite1 = true; @@ -122,20 +125,21 @@ void testHashcode_OK() { int transactionIndex2 = 2; byte[] difficulty2 = new byte[]{2}; byte[] gasLimit2 = new byte[]{1}; + byte[] minimumGasPrice2 = new byte[]{14}; Repository repository2 = null; BlockStore blockStore2 = null; boolean byTestingSuite2 = false; // Same properties included in the hashcode makes hashcode to be equal - ProgramInvokeImpl programInvokeA = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, repository1, blockStore1, byTestingSuite1); - ProgramInvokeImpl programInvokeB = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, repository1, blockStore1, byTestingSuite1); + ProgramInvokeImpl programInvokeA = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, minimumGasPrice1, repository1, blockStore1, byTestingSuite1); + ProgramInvokeImpl programInvokeB = new ProgramInvokeImpl(address1, origin1, caller1, balance1, gasPrice1, gas1, callValue1, msgData1, lastHash1, coinbase1, timestamp1, number1, transactionIndex1, difficulty1, gasLimit1, minimumGasPrice1, repository1, blockStore1, byTestingSuite1); assertEquals(programInvokeA.hashCode(), programInvokeB.hashCode()); // Different combinations of property values makes hashcode to be different - ProgramInvokeImpl programInvokeC = new ProgramInvokeImpl(address2, origin2, caller2, balance2, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number2, transactionIndex2, difficulty2, gasLimit2, repository2, blockStore2, byTestingSuite2); + ProgramInvokeImpl programInvokeC = new ProgramInvokeImpl(address2, origin2, caller2, balance2, gasPrice2, gas2, callValue2, msgData2, lastHash2, coinbase2, timestamp2, number2, transactionIndex2, difficulty2, gasLimit2, minimumGasPrice2, repository2, blockStore2, byTestingSuite2); assertNotEquals(programInvokeA.hashCode(), programInvokeC.hashCode()); diff --git a/rskj-core/src/test/java/org/ethereum/vm/program/invoke/ProgramInvokeMockImpl.java b/rskj-core/src/test/java/org/ethereum/vm/program/invoke/ProgramInvokeMockImpl.java index 9235bfc42b4..f9377f33a65 100644 --- a/rskj-core/src/test/java/org/ethereum/vm/program/invoke/ProgramInvokeMockImpl.java +++ b/rskj-core/src/test/java/org/ethereum/vm/program/invoke/ProgramInvokeMockImpl.java @@ -143,6 +143,13 @@ public long getGas() { return gasLimit; } + /* BASEFEE op */ + @Override + public DataWord getMinimumGasPrice() { + byte[] minimumGasPrice = Hex.decode("03104e60a000"); + return DataWord.valueOf(minimumGasPrice); + } + public void setGas(long gasLimit) { this.gasLimit = gasLimit; }