From cd88151d2cf9047ca3408734108c63a5c0fc1713 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 20 May 2021 12:04:55 +1000 Subject: [PATCH] GoQuorum ATs: run the estimate gas test (#2294) * run the estimate gas test * Revert "Modify Gas estimation logic for GoQuorum mode (#2282)" This reverts commit 3627662f82889c9c0c1a2adcb6030a9d574842cf. Signed-off-by: Sally MacFarlane Co-authored-by: mark-terry <36909937+mark-terry@users.noreply.github.com> --- build.gradle | 4 +- .../transaction/TransactionSimulator.java | 16 +------ .../transaction/TransactionSimulatorTest.java | 42 ------------------- 3 files changed, 3 insertions(+), 59 deletions(-) diff --git a/build.gradle b/build.gradle index eec772e1a8..9afdd77989 100644 --- a/build.gradle +++ b/build.gradle @@ -663,11 +663,11 @@ task acceptanceTestsQuorum { * Not available features in Besu: privacy-enhancements-disabled, extension * Not available RPC methods in Besu: async, storage-root, get-quorum-payload, personal-api-signed * - * Ignored for now (privacy-polishing): graphql, eth-api-signed, (estimategas && public) + * Ignored for now (privacy-polishing): graphql, eth-api-signed * * LOGGING_LEVEL_COM_QUORUM_GAUGE=DEBUG -- enables HTTP JSON-RPC logging */ - def tags = "(basic && !(estimategas && public) && !eth-api-signed && !privacy-enhancements-disabled && !graphql && !async && !extension && !storage-root && !get-quorum-payload && !personal-api-signed) || networks/typical-besu::ibft2" + def tags = "(basic && !eth-api-signed && !privacy-enhancements-disabled && !graphql && !async && !extension && !storage-root && !get-quorum-payload && !personal-api-signed) || networks/typical-besu::ibft2" doLast { exec { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java index e0041017b8..f571294c82 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.transaction; import static org.hyperledger.besu.ethereum.goquorum.GoQuorumPrivateStateUtil.getPrivateWorldStateAtBlock; -import org.hyperledger.besu.config.GoQuorumOptions; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; @@ -72,11 +71,6 @@ public class TransactionSimulator { private static final Address DEFAULT_FROM = Address.fromHexString("0x0000000000000000000000000000000000000000"); - // Hex-encoded 64 byte array of "17" values - private static final Bytes MAX_PRIVATE_INTRINSIC_DATA_HEX = - Bytes.fromHexString( - "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"); - private final Blockchain blockchain; private final WorldStateArchive worldStateArchive; private final ProtocolSchedule protocolSchedule; @@ -163,15 +157,7 @@ public class TransactionSimulator { callParams.getGasLimit() >= 0 ? callParams.getGasLimit() : header.getGasLimit(); final Wei gasPrice = callParams.getGasPrice() != null ? callParams.getGasPrice() : Wei.ZERO; final Wei value = callParams.getValue() != null ? callParams.getValue() : Wei.ZERO; - - // If GoQuorum privacy enabled, and value = zero, do simulation with max non-zero bytes. - // It is possible to have a data field that has a lower intrinsic value than the PTM hash - // so this checks the tx as if we were to place a PTM hash (with all non-zero values). - // This means a potential over-estimate of gas, rather than the exact cost to run right now. - final Bytes payload = - GoQuorumOptions.goQuorumCompatibilityMode && value.isZero() - ? MAX_PRIVATE_INTRINSIC_DATA_HEX - : (callParams.getPayload() != null ? callParams.getPayload() : Bytes.EMPTY); + final Bytes payload = callParams.getPayload() != null ? callParams.getPayload() : Bytes.EMPTY; if (transactionValidationParams.isAllowExceedingBalance()) { updater.getOrCreate(senderAddress).getMutable().setBalance(Wei.of(UInt256.MAX_VALUE)); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java index 7210e3bf4d..700d279678 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.GoQuorumOptions; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; @@ -54,7 +53,6 @@ import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -77,11 +75,6 @@ public class TransactionSimulatorTest { private static final Hash DEFAULT_BLOCK_HEADER_HASH = Hash.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001"); - // Hex-encoded 64 byte array of "17" values - private static final Bytes MAX_PRIVATE_INTRINSIC_DATA_HEX = - Bytes.fromHexString( - "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"); - private TransactionSimulator transactionSimulator; @Mock private Blockchain blockchain; @@ -98,12 +91,6 @@ public class TransactionSimulatorTest { new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule); } - @After - public void tearDown() { - GoQuorumOptions.goQuorumCompatibilityMode = - GoQuorumOptions.GOQUORUM_COMPATIBILITY_MODE_DEFAULT_VALUE; - } - @Test public void shouldReturnEmptyWhenBlockDoesNotExist() { when(blockchain.getBlockHeader(eq(1L))).thenReturn(Optional.empty()); @@ -141,35 +128,6 @@ public class TransactionSimulatorTest { verifyTransactionWasProcessed(expectedTransaction); } - @Test - public void shouldReturnSuccessfulResultWhenProcessingPotentiallyPrivateTxIsSuccessful() { - final CallParameter callParameter = legacyTransactionCallParameter(); - - GoQuorumOptions.goQuorumCompatibilityMode = true; - - mockBlockchainForBlockHeader(Hash.ZERO, 1L); - mockWorldStateForAccount(Hash.ZERO, callParameter.getFrom(), 1L); - - final Transaction expectedTransaction = - Transaction.builder() - .nonce(1L) - .gasPrice(callParameter.getGasPrice()) - .gasLimit(callParameter.getGasLimit()) - .to(callParameter.getTo()) - .sender(callParameter.getFrom()) - .value(callParameter.getValue()) - .payload(MAX_PRIVATE_INTRINSIC_DATA_HEX) - .signature(FAKE_SIGNATURE) - .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); - - final Optional result = - transactionSimulator.process(callParameter, 1L); - - assertThat(result.get().isSuccessful()).isTrue(); - verifyTransactionWasProcessed(expectedTransaction); - } - @Test public void shouldIncreaseBalanceAccountWhenExceedingBalanceAllowed() { final CallParameter callParameter = legacyTransactionCallParameter();