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 3627662f82.

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>

Co-authored-by: mark-terry <36909937+mark-terry@users.noreply.github.com>
pull/2309/head
Sally MacFarlane 4 years ago committed by GitHub
parent da9d63d391
commit cd88151d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      build.gradle
  2. 16
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  3. 42
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java

@ -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 {

@ -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));

@ -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<TransactionSimulatorResult> result =
transactionSimulator.process(callParameter, 1L);
assertThat(result.get().isSuccessful()).isTrue();
verifyTransactionWasProcessed(expectedTransaction);
}
@Test
public void shouldIncreaseBalanceAccountWhenExceedingBalanceAllowed() {
final CallParameter callParameter = legacyTransactionCallParameter();

Loading…
Cancel
Save