diff --git a/rskj-core/src/main/java/org/ethereum/vm/program/Program.java b/rskj-core/src/main/java/org/ethereum/vm/program/Program.java index 87443ab6b8..7b417cf52f 100644 --- a/rskj-core/src/main/java/org/ethereum/vm/program/Program.java +++ b/rskj-core/src/main/java/org/ethereum/vm/program/Program.java @@ -72,10 +72,8 @@ import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Map; import java.util.Optional; import java.util.Set; diff --git a/rskj-core/src/test/java/co/rsk/vm/opcode/TransientStorageDslTest.java b/rskj-core/src/test/java/co/rsk/vm/opcode/TransientStorageDslTest.java index 6a6e1a30f9..bf4719b854 100644 --- a/rskj-core/src/test/java/co/rsk/vm/opcode/TransientStorageDslTest.java +++ b/rskj-core/src/test/java/co/rsk/vm/opcode/TransientStorageDslTest.java @@ -146,6 +146,18 @@ void testTransientStorageTestsEip1153BasicScenarios() throws FileNotFoundExcepti Assertions.assertEquals(4, TransactionReceiptUtil.getEventCount(txReceipt, "OK", null)); } + @Test + void testTransientStorageTestsCreateContextsOnlyConstructorCode() throws FileNotFoundException, DslProcessorException { + DslParser parser = DslParser.fromResource("dsl/transaction_storage_rskip446/tload_tstore_create_context_only_constructor_code.txt"); + World world = new World(); + WorldDslProcessor processor = new WorldDslProcessor(world); + processor.processCommands(parser); + + String mainContractTransientStorageCreationTxName = "txTestTransientStorageContract"; + TransactionReceipt txReceipt = assertTransactionReceiptWithStatus(world, mainContractTransientStorageCreationTxName, "b01", true); + Assertions.assertEquals(2, TransactionReceiptUtil.getEventCount(txReceipt, "OK", null)); + } + private static TransactionReceipt assertTransactionReceiptWithStatus(World world, String txName, String blockName, boolean withSuccess) { Transaction txCreation = world.getTransactionByName(txName); assertNotNull(txCreation); diff --git a/rskj-core/src/test/resources/dsl/transaction_storage_rskip446/tload_tstore_create_context_only_constructor_code.txt b/rskj-core/src/test/resources/dsl/transaction_storage_rskip446/tload_tstore_create_context_only_constructor_code.txt new file mode 100644 index 0000000000..991b31f15f --- /dev/null +++ b/rskj-core/src/test/resources/dsl/transaction_storage_rskip446/tload_tstore_create_context_only_constructor_code.txt @@ -0,0 +1,62 @@ +comment + +// CONTRACT CODE +pragma solidity ^0.8.24; + +contract TestsTransientStorageCreateContextsOnlyConstructorCode { + + constructor() { + bytes32 valueLoadedInitially; + bytes32 valueLoadedAfterStore; + assembly{ + valueLoadedInitially := tload(0) + tstore(0,0x0000000000000000000000000000000100000000000000000000000000000001) + valueLoadedAfterStore := tload(0) + } + if(valueLoadedInitially == 0x00){ + emit OK(); + } else { + emit ERROR(valueLoadedInitially); + } + + if(valueLoadedAfterStore == 0x0000000000000000000000000000000100000000000000000000000000000001){ + emit OK(); + } else { + emit ERROR(valueLoadedAfterStore); + } + } + + event OK(); + event ERROR(bytes32); +} + +// CONTRACT BYTECODE + +TestsTransientStorageCreateContextsOnlyConstructorCode: 608060405234801561000f575f80fd5b505f805f5c91507001000000000000000000000000000000015f5d5f5c90505f801b8203610068577fd48fe2800bace8f5ca2450feacbd6efc681b1cd0115019bb49fa529b6171bf6760405160405180910390a16100a0565b7f2fe0d3bd8bbb632441eefda46ec52f1ddda3a9e827d14c40f422037320f28bd9826040516100979190610142565b60405180910390a15b7001000000000000000000000000000000015f1b81036100eb577fd48fe2800bace8f5ca2450feacbd6efc681b1cd0115019bb49fa529b6171bf6760405160405180910390a1610123565b7f2fe0d3bd8bbb632441eefda46ec52f1ddda3a9e827d14c40f422037320f28bd98160405161011a9190610142565b60405180910390a15b505061015b565b5f819050919050565b61013c8161012a565b82525050565b5f6020820190506101555f830184610133565b92915050565b603e806101675f395ff3fe60806040525f80fdfea2646970667358221220c3c06d3ce43439437bdc0d04739df150a62dcb18dc5af99be6058c5c452435d964736f6c634300081a0033 + +end + + +# Create and fund new account +account_new acc1 10000000 + +# Create transaction to deploy TestTransientStorage contract +transaction_build txTestTransientStorageContract + sender acc1 + receiverAddress 00 + value 0 + data 608060405234801561000f575f80fd5b505f805f5c91507001000000000000000000000000000000015f5d5f5c90505f801b8203610068577fd48fe2800bace8f5ca2450feacbd6efc681b1cd0115019bb49fa529b6171bf6760405160405180910390a16100a0565b7f2fe0d3bd8bbb632441eefda46ec52f1ddda3a9e827d14c40f422037320f28bd9826040516100979190610142565b60405180910390a15b7001000000000000000000000000000000015f1b81036100eb577fd48fe2800bace8f5ca2450feacbd6efc681b1cd0115019bb49fa529b6171bf6760405160405180910390a1610123565b7f2fe0d3bd8bbb632441eefda46ec52f1ddda3a9e827d14c40f422037320f28bd98160405161011a9190610142565b60405180910390a15b505061015b565b5f819050919050565b61013c8161012a565b82525050565b5f6020820190506101555f830184610133565b92915050565b603e806101675f395ff3fe60806040525f80fdfea2646970667358221220c3c06d3ce43439437bdc0d04739df150a62dcb18dc5af99be6058c5c452435d964736f6c634300081a0033 + gas 1000000 + build + +# Create block to hold txTestTransientStorageContract transaction +block_build b01 + parent g00 + transactions txTestTransientStorageContract + build + +# Connect block +block_connect b01 + +# Check b01 is best block +assert_best b01 \ No newline at end of file