Revert adding gasRemaining and change txn fee calc to use gasPrice and gasUsed (#1573)

Signed-off-by: David Mechler <david.mechler@consensys.net>
pull/1581/head
David Mechler 4 years ago committed by GitHub
parent e5108d1502
commit 39ee371556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  2. 4
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  3. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  4. 10
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  5. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  6. 6
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  7. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/NodeConfiguration.java
  8. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java
  9. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/RevertReasonAcceptanceTest.java
  10. 8
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  11. 6
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  12. 2
      besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
  13. 2
      besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
  14. 2
      besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java
  15. 2
      besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
  16. 2
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  17. 10
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
  18. 8
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolSchedule.java
  19. 8
      consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftProtocolSchedule.java
  20. 2
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java
  21. 18
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java
  22. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/StateBackupService.java
  23. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java
  24. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/logs/LogsSubscriptionServiceTest.java
  25. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_contractAddress.json
  26. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_logs.json
  27. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_nullContractAddress.json
  28. 2
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java
  29. 61
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java
  30. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
  31. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java
  32. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
  33. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  34. 36
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  35. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStoragePrefixedKeyBlockchainStorage.java
  36. 20
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java
  37. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchainTest.java
  38. 8
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionReceiptTest.java
  39. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java
  40. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/ReceiptsMessageTest.java
  41. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java
  42. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/CliqueGenesisFileModule.java
  43. 13
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommandOptionsModule.java
  44. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/GenesisFileModule.java
  45. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/IBFTGenesisFileModule.java
  46. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java

@ -84,7 +84,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final Properties portsProperties = new Properties();
private final Boolean p2pEnabled;
private final NetworkingConfiguration networkingConfiguration;
private final boolean isMetadataEnabled;
private final boolean revertReasonEnabled;
private final String name;
private final MiningParameters miningParameters;
@ -127,7 +127,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
final NetworkingConfiguration networkingConfiguration,
final boolean discoveryEnabled,
final boolean bootnodeEligible,
final boolean isMetadataEnabled,
final boolean revertReasonEnabled,
final boolean secp256k1Native,
final boolean altbn128Native,
final List<String> plugins,
@ -159,7 +159,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.networkingConfiguration = networkingConfiguration;
this.discoveryEnabled = discoveryEnabled;
this.bootnodeEligible = bootnodeEligible;
this.isMetadataEnabled = isMetadataEnabled;
this.revertReasonEnabled = revertReasonEnabled;
this.secp256k1Native = secp256k1Native;
this.altbn128Native = altbn128Native;
this.runCommand = runCommand;
@ -603,8 +603,8 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
}
@Override
public boolean isMetadataEnabled() {
return isMetadataEnabled;
public boolean isRevertReasonEnabled() {
return revertReasonEnabled;
}
@Override

@ -229,8 +229,8 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.addAll(networkConfigParams);
}
if (node.isMetadataEnabled()) {
params.add("--receipt-metadata-enabled");
if (node.isRevertReasonEnabled()) {
params.add("--revert-reason-enabled");
}
params.add("--Xsecp256k1-native-enabled=" + node.isSecp256k1Native());

@ -159,7 +159,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.transactionPoolConfiguration(TransactionPoolConfiguration.builder().build())
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.clock(Clock.systemUTC())
.isMetadataEnabled(node.isMetadataEnabled())
.isRevertReasonEnabled(node.isRevertReasonEnabled())
.storageProvider(storageProvider)
.gasLimitCalculator(GasLimitCalculator.constant())
.build();

@ -43,7 +43,7 @@ public class BesuNodeConfiguration {
private final NetworkingConfiguration networkingConfiguration;
private final boolean discoveryEnabled;
private final boolean bootnodeEligible;
private final boolean metadataEnabled;
private final boolean revertReasonEnabled;
private final boolean secp256k1Native;
private final boolean altbn128Native;
private final List<String> plugins;
@ -68,7 +68,7 @@ public class BesuNodeConfiguration {
final NetworkingConfiguration networkingConfiguration,
final boolean discoveryEnabled,
final boolean bootnodeEligible,
final boolean metadataEnabled,
final boolean revertReasonEnabled,
final boolean secp256k1Native,
final boolean altbn128Native,
final List<String> plugins,
@ -91,7 +91,7 @@ public class BesuNodeConfiguration {
this.networkingConfiguration = networkingConfiguration;
this.discoveryEnabled = discoveryEnabled;
this.bootnodeEligible = bootnodeEligible;
this.metadataEnabled = metadataEnabled;
this.revertReasonEnabled = revertReasonEnabled;
this.secp256k1Native = secp256k1Native;
this.altbn128Native = altbn128Native;
this.plugins = plugins;
@ -166,8 +166,8 @@ public class BesuNodeConfiguration {
return extraCLIOptions;
}
public boolean isMetadataEnabled() {
return metadataEnabled;
public boolean isRevertReasonEnabled() {
return revertReasonEnabled;
}
public boolean isSecp256k1Native() {

@ -54,7 +54,7 @@ public class BesuNodeConfigurationBuilder {
private final NetworkingConfiguration networkingConfiguration = NetworkingConfiguration.create();
private boolean discoveryEnabled = true;
private boolean bootnodeEligible = true;
private boolean metadataEnabled = false;
private boolean revertReasonEnabled = false;
private boolean secp256K1Native = false;
private boolean altbn128Native = false;
private final List<String> plugins = new ArrayList<>();
@ -249,8 +249,8 @@ public class BesuNodeConfigurationBuilder {
return this;
}
public BesuNodeConfigurationBuilder metadataEnabled() {
this.metadataEnabled = true;
public BesuNodeConfigurationBuilder revertReasonEnabled() {
this.revertReasonEnabled = true;
return this;
}
@ -300,7 +300,7 @@ public class BesuNodeConfigurationBuilder {
networkingConfiguration,
discoveryEnabled,
bootnodeEligible,
metadataEnabled,
revertReasonEnabled,
secp256K1Native,
altbn128Native,
plugins,

@ -65,7 +65,7 @@ public class BesuNodeFactory {
config.getNetworkingConfiguration(),
config.isDiscoveryEnabled(),
config.isBootnodeEligible(),
config.isMetadataEnabled(),
config.isRevertReasonEnabled(),
config.isSecp256k1Native(),
config.isAltbn128Native(),
config.getPlugins(),
@ -86,14 +86,14 @@ public class BesuNodeFactory {
.build());
}
public BesuNode createMinerNodeWithMetadataEnabled(final String name) throws IOException {
public BesuNode createMinerNodeWithRevertReasonEnabled(final String name) throws IOException {
return create(
new BesuNodeConfigurationBuilder()
.name(name)
.miningEnabled()
.jsonRpcEnabled()
.webSocketEnabled()
.metadataEnabled()
.revertReasonEnabled()
.build());
}

@ -50,7 +50,7 @@ public interface NodeConfiguration {
List<String> getExtraCLIOptions();
boolean isMetadataEnabled();
boolean isRevertReasonEnabled();
List<String> getStaticNodes();
}

@ -99,7 +99,7 @@ public class PrivacyNode implements AutoCloseable {
besuConfig.getNetworkingConfiguration(),
besuConfig.isDiscoveryEnabled(),
besuConfig.isBootnodeEligible(),
besuConfig.isMetadataEnabled(),
besuConfig.isRevertReasonEnabled(),
besuConfig.isSecp256k1Native(),
besuConfig.isAltbn128Native(),
besuConfig.getPlugins(),

@ -31,7 +31,7 @@ public class RevertReasonAcceptanceTest extends AcceptanceTestBase {
@Before
public void setUp() throws Exception {
minerNode = besu.createMinerNodeWithMetadataEnabled("miner-node-withMetadata");
minerNode = besu.createMinerNodeWithRevertReasonEnabled("miner-node-withRevertReason");
cluster.start(minerNode);
}

@ -878,10 +878,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Boolean isPrivacyMultiTenancyEnabled = false;
@Option(
names = {"--receipt-metadata-enabled", "--revert-reason-enabled"},
names = {"--revert-reason-enabled"},
description =
"Enable passing metadata back through TransactionReceipts (default: ${DEFAULT-VALUE})")
private final Boolean isMetadataEnabled = false;
"Enable passing the revert reason back through TransactionReceipts (default: ${DEFAULT-VALUE})")
private final Boolean isRevertReasonEnabled = false;
@Option(
names = {"--required-blocks", "--required-block"},
@ -1512,7 +1512,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.metricsSystem(metricsSystem.get())
.privacyParameters(privacyParameters())
.clock(Clock.systemUTC())
.isMetadataEnabled(isMetadataEnabled)
.isRevertReasonEnabled(isRevertReasonEnabled)
.storageProvider(keyStorageProvider(keyValueStorageName))
.isPruningEnabled(isPruningEnabled())
.pruningConfiguration(

@ -90,7 +90,7 @@ public abstract class BesuControllerBuilder {
protected Path dataDirectory;
protected Clock clock;
protected NodeKey nodeKey;
protected boolean isMetadataEnabled;
protected boolean isRevertReasonEnabled;
GasLimitCalculator gasLimitCalculator;
private StorageProvider storageProvider;
private boolean isPruningEnabled;
@ -162,8 +162,8 @@ public abstract class BesuControllerBuilder {
return this;
}
public BesuControllerBuilder isMetadataEnabled(final boolean isMetadataEnabled) {
this.isMetadataEnabled = isMetadataEnabled;
public BesuControllerBuilder isRevertReasonEnabled(final boolean isRevertReasonEnabled) {
this.isRevertReasonEnabled = isRevertReasonEnabled;
return this;
}

@ -112,7 +112,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
genesisConfig.getConfigOptions(genesisConfigOverrides),
nodeKey,
privacyParameters,
isMetadataEnabled);
isRevertReasonEnabled);
}
@Override

@ -216,7 +216,7 @@ public class IbftBesuControllerBuilder extends BesuControllerBuilder {
return IbftProtocolSchedule.create(
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isMetadataEnabled);
isRevertReasonEnabled);
}
@Override

@ -77,7 +77,7 @@ public class IbftLegacyBesuControllerBuilder extends BesuControllerBuilder {
return IbftProtocolSchedule.create(
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isMetadataEnabled);
isRevertReasonEnabled);
}
@Override

@ -89,7 +89,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
return MainnetProtocolSchedule.fromConfig(
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isMetadataEnabled);
isRevertReasonEnabled);
}
@Override

@ -181,7 +181,7 @@ public abstract class CommandTestAbstract {
when(mockControllerBuilder.metricsSystem(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.privacyParameters(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.clock(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isMetadataEnabled(false)).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isRevertReasonEnabled(false)).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.storageProvider(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isPruningEnabled(anyBoolean())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.pruningConfiguration(any())).thenReturn(mockControllerBuilder);

@ -44,7 +44,7 @@ public class CliqueProtocolSchedule {
final GenesisConfigOptions config,
final NodeKey nodeKey,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled) {
final boolean isRevertReasonEnabled) {
final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
@ -72,14 +72,16 @@ public class CliqueProtocolSchedule {
builder,
eip1559),
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
config.isQuorum())
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final NodeKey nodeKey, final boolean isMetadataEnabled) {
return create(config, nodeKey, PrivacyParameters.DEFAULT, isMetadataEnabled);
final GenesisConfigOptions config,
final NodeKey nodeKey,
final boolean isRevertReasonEnabled) {
return create(config, nodeKey, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}
private static ProtocolSpecBuilder applyCliqueSpecificModifications(

@ -38,21 +38,21 @@ public class IbftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled) {
final boolean isRevertReasonEnabled) {
return new ProtocolScheduleBuilder(
config,
DEFAULT_CHAIN_ID,
builder -> applyIbftChanges(config.getIbft2ConfigOptions(), builder),
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
config.isQuorum())
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isMetadataEnabled) {
return create(config, PrivacyParameters.DEFAULT, isMetadataEnabled);
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}
public static ProtocolSchedule create(final GenesisConfigOptions config) {

@ -37,7 +37,7 @@ public class IbftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled) {
final boolean isRevertReasonEnabled) {
final IbftConfigOptions ibftConfig = config.getIbftLegacyConfigOptions();
final long blockPeriod = ibftConfig.getBlockPeriodSeconds();
@ -46,14 +46,14 @@ public class IbftProtocolSchedule {
DEFAULT_CHAIN_ID,
builder -> applyIbftChanges(blockPeriod, builder),
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
config.isQuorum())
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isMetadataEnabled) {
return create(config, PrivacyParameters.DEFAULT, isMetadataEnabled);
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}
private static ProtocolSpecBuilder applyIbftChanges(

@ -294,7 +294,7 @@ public class EthGetFilterChangesIntegrationTest {
new BlockBody(transactionList, emptyList()));
final List<TransactionReceipt> transactionReceipts =
transactionList.stream()
.map(transaction -> new TransactionReceipt(1, 1, emptyList(), Optional.empty(), -1L))
.map(transaction -> new TransactionReceipt(1, 1, emptyList(), Optional.empty()))
.collect(toList());
blockchain.appendBlock(block, transactionReceipts);
return block;

@ -29,7 +29,6 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@ -96,16 +95,15 @@ public class EthGetMinerDataByBlockHash implements JsonRpcMethod {
block.getTransactions().stream()
.map(
t -> {
Transaction transaction = t.getTransaction();
Optional<TransactionReceiptWithMetadata> transactionReceiptWithMetadata =
blockchainQueries.transactionReceiptByTransactionHash(transaction.getHash());
Wei refundAmount =
Wei.of(
transactionReceiptWithMetadata
.flatMap(tr -> tr.getReceipt().getGasRemaining())
.orElse(0L))
.multiply(transaction.getGasPrice());
return t.getTransaction().getUpfrontCost().subtract(refundAmount);
blockchainQueries.transactionReceiptByTransactionHash(
t.getTransaction().getHash());
return t.getTransaction()
.getGasPrice()
.multiply(
transactionReceiptWithMetadata
.map(TransactionReceiptWithMetadata::getGasUsed)
.orElse(0L));
})
.reduce(Wei.ZERO, BaseUInt256Value::add);
final Wei uncleInclusionReward =

@ -322,7 +322,7 @@ public class StateBackupService {
bodyWriter.writeBytes(bodyOutput.encoded().toArrayUnsafe());
final BytesValueRLPOutput receiptsOutput = new BytesValueRLPOutput();
receiptsOutput.writeList(receipts.get(), TransactionReceipt::writeToWithMetadata);
receiptsOutput.writeList(receipts.get(), TransactionReceipt::writeToWithRevertReason);
receiptsWriter.writeBytes(receiptsOutput.encoded().toArrayUnsafe());
backupStatus.storedBlock = blockNumber;

@ -47,11 +47,11 @@ import org.junit.Test;
public class EthGetTransactionReceiptTest {
private final TransactionReceipt stateReceipt =
new TransactionReceipt(1, 12, Collections.emptyList(), Optional.empty(), -1L);
new TransactionReceipt(1, 12, Collections.emptyList(), Optional.empty());
private final Hash stateRoot =
Hash.fromHexString("0000000000000000000000000000000000000000000000000000000000000000");
private final TransactionReceipt rootReceipt =
new TransactionReceipt(stateRoot, 12, Collections.emptyList(), Optional.empty(), -1L);
new TransactionReceipt(stateRoot, 12, Collections.emptyList(), Optional.empty());
private final Signature signature = Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 1);
private final Address sender =

@ -377,7 +377,7 @@ public class LogsSubscriptionServiceTest {
final BlockOptions blockOptions = BlockOptions.create();
for (int i = 0; i < txCount; i++) {
final Transaction tx = gen.transaction();
final TransactionReceipt receipt = gen.receipt(logsSupplier.get(), -1L);
final TransactionReceipt receipt = gen.receipt(logsSupplier.get());
receipts.add(receipt);
receipt.getLogs().forEach(logs::add);

@ -22,8 +22,7 @@
"root": "0x6a59608add7cee26032d1c5c3923b91d0b50e6103f61b2137b68229bcdc87395",
"to": null,
"transactionHash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
"transactionIndex": "0x0",
"revertReason" : "0x"
"transactionIndex": "0x0"
}
},
"statusCode": 200

@ -39,8 +39,7 @@
"root": "0xb55d027526b3f56953584db678b5c3d1a418812c0106b0cfbc3c912c7898dfe5",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0x185a9154a0acc4e0ffc84029aee0f3dbf57ff0b84ec7624cb80e7373a03e8aeb",
"transactionIndex": "0x0",
"revertReason" : "0x"
"transactionIndex": "0x0"
}
},
"statusCode": 200

@ -22,8 +22,7 @@
"root": "0x947228066df6272aac99931a1a639621d4ac7dc461ce9fd93dfcaad933e299ee",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0xb1a62356d1433202cdef0ef9030f8abdfbb3aef549fab0867cf0eaee70b09d81",
"transactionIndex": "0x0",
"revertReason" : "0x"
"transactionIndex": "0x0"
}
},
"statusCode": 200

@ -568,6 +568,6 @@ public class BlockTransactionSelectorTest {
private TransactionReceipt createReceipt(
final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) {
return new TransactionReceipt(
worldState.rootHash(), gasUsed, Lists.newArrayList(), Optional.empty(), -1L);
worldState.rootHash(), gasUsed, Lists.newArrayList(), Optional.empty());
}
}

@ -48,7 +48,6 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
private final int status;
private final TransactionReceiptType transactionReceiptType;
private final Optional<Bytes> revertReason;
private final long gasRemaining;
/**
* Creates an instance of a state root-encoded transaction receipt.
@ -57,22 +56,19 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
* @param cumulativeGasUsed the total amount of gas consumed in the block after this transaction
* @param logs the logs generated within the transaction
* @param revertReason the revert reason for a failed transaction (if applicable)
* @param gasRemaining the gas remaining from the processed transaction
*/
public TransactionReceipt(
final Hash stateRoot,
final long cumulativeGasUsed,
final List<Log> logs,
final Optional<Bytes> revertReason,
final long gasRemaining) {
final Optional<Bytes> revertReason) {
this(
stateRoot,
NONEXISTENT,
cumulativeGasUsed,
logs,
LogsBloomFilter.builder().insertLogs(logs).build(),
revertReason,
gasRemaining);
revertReason);
}
private TransactionReceipt(
@ -80,9 +76,8 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
final long cumulativeGasUsed,
final List<Log> logs,
final LogsBloomFilter bloomFilter,
final Optional<Bytes> revertReason,
final long gasRemaining) {
this(stateRoot, NONEXISTENT, cumulativeGasUsed, logs, bloomFilter, revertReason, gasRemaining);
final Optional<Bytes> revertReason) {
this(stateRoot, NONEXISTENT, cumulativeGasUsed, logs, bloomFilter, revertReason);
}
/**
@ -92,22 +87,19 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
* @param cumulativeGasUsed the total amount of gas consumed in the block after this transaction
* @param logs the logs generated within the transaction
* @param revertReason the revert reason for a failed transaction (if applicable)
* @param gasRemaining the remaining gas from the transaction (if applicable)
*/
public TransactionReceipt(
final int status,
final long cumulativeGasUsed,
final List<Log> logs,
final Optional<Bytes> revertReason,
final long gasRemaining) {
final Optional<Bytes> revertReason) {
this(
null,
status,
cumulativeGasUsed,
logs,
LogsBloomFilter.builder().insertLogs(logs).build(),
revertReason,
gasRemaining);
revertReason);
}
private TransactionReceipt(
@ -115,9 +107,8 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
final long cumulativeGasUsed,
final List<Log> logs,
final LogsBloomFilter bloomFilter,
final Optional<Bytes> revertReason,
final long gasRemaining) {
this(null, status, cumulativeGasUsed, logs, bloomFilter, revertReason, gasRemaining);
final Optional<Bytes> revertReason) {
this(null, status, cumulativeGasUsed, logs, bloomFilter, revertReason);
}
private TransactionReceipt(
@ -126,8 +117,7 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
final long cumulativeGasUsed,
final List<Log> logs,
final LogsBloomFilter bloomFilter,
final Optional<Bytes> revertReason,
final long gasRemaining) {
final Optional<Bytes> revertReason) {
this.stateRoot = stateRoot;
this.cumulativeGasUsed = cumulativeGasUsed;
this.status = status;
@ -136,7 +126,6 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
transactionReceiptType =
stateRoot == null ? TransactionReceiptType.STATUS : TransactionReceiptType.ROOT;
this.revertReason = revertReason;
this.gasRemaining = gasRemaining;
}
/**
@ -148,11 +137,11 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
writeTo(out, false);
}
public void writeToWithMetadata(final RLPOutput out) {
public void writeToWithRevertReason(final RLPOutput out) {
writeTo(out, true);
}
private void writeTo(final RLPOutput out, final boolean withMetadata) {
private void writeTo(final RLPOutput out, final boolean withRevertReason) {
out.startList();
// Determine whether it's a state root-encoded transaction receipt
@ -165,11 +154,8 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
out.writeLongScalar(cumulativeGasUsed);
out.writeBytes(bloomFilter);
out.writeList(logs, Log::writeTo);
if (withMetadata) {
out.writeBytes(
revertReason.orElse(
Bytes.EMPTY)); // writing Bytes.EMPTY is the same as calling RLPOutput.writeNull
out.writeLong(gasRemaining);
if (withRevertReason && revertReason.isPresent()) {
out.writeBytes(revertReason.get());
}
out.endList();
}
@ -188,10 +174,11 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
* Creates a transaction receipt for the given RLP
*
* @param input the RLP-encoded transaction receipt
* @param metadataAllowed whether the rlp input is allowed to have a metadata
* @param revertReasonAllowed whether the rlp input is allowed to have a revert reason
* @return the transaction receipt
*/
public static TransactionReceipt readFrom(final RLPInput input, final boolean metadataAllowed) {
public static TransactionReceipt readFrom(
final RLPInput input, final boolean revertReasonAllowed) {
input.enterList();
try {
@ -204,29 +191,23 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
final LogsBloomFilter bloomFilter = LogsBloomFilter.readFrom(input);
final List<Log> logs = input.readList(Log::readFrom);
final Optional<Bytes> revertReason;
long gasRemaining = -1L;
if (input.isEndOfCurrentList()) {
revertReason = Optional.empty();
} else {
if (!metadataAllowed) {
if (!revertReasonAllowed) {
throw new RLPException("Unexpected value at end of TransactionReceipt");
}
revertReason = Optional.of(input.readBytes());
if (!input.isEndOfCurrentList()) {
gasRemaining = input.readLong();
}
}
// Status code-encoded transaction receipts have a single
// byte for success (0x01) or failure (0x80).
if (firstElement.raw().size() == 1) {
final int status = firstElement.readIntScalar();
return new TransactionReceipt(
status, cumulativeGas, logs, bloomFilter, revertReason, gasRemaining);
return new TransactionReceipt(status, cumulativeGas, logs, bloomFilter, revertReason);
} else {
final Hash stateRoot = Hash.wrap(firstElement.readBytes32());
return new TransactionReceipt(
stateRoot, cumulativeGas, logs, bloomFilter, revertReason, gasRemaining);
return new TransactionReceipt(stateRoot, cumulativeGas, logs, bloomFilter, revertReason);
}
} finally {
input.leaveList();
@ -291,10 +272,6 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
return revertReason;
}
public Optional<Long> getGasRemaining() {
return Optional.of(gasRemaining);
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {

@ -25,19 +25,19 @@ public class FixedDifficultyProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled) {
final boolean isRevertReasonEnabled) {
return new ProtocolScheduleBuilder(
config,
builder -> builder.difficultyCalculator(FixedDifficultyCalculators.calculator(config)),
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
config.isQuorum())
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isMetadataEnabled) {
return create(config, PrivacyParameters.DEFAULT, isMetadataEnabled);
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}
public static ProtocolSchedule create(final GenesisConfigOptions config) {

@ -240,20 +240,12 @@ public class ClassicProtocolSpecs {
private static TransactionReceipt byzantiumTransactionReceiptFactory(
final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) {
return new TransactionReceipt(
result.isSuccessful() ? 1 : 0,
gasUsed,
result.getLogs(),
Optional.empty(),
result.getGasRemaining());
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), Optional.empty());
}
private static TransactionReceipt byzantiumTransactionReceiptFactoryWithReasonEnabled(
final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) {
return new TransactionReceipt(
result.isSuccessful() ? 1 : 0,
gasUsed,
result.getLogs(),
result.getRevertReason(),
result.getGasRemaining());
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), result.getRevertReason());
}
}

@ -39,22 +39,23 @@ public class MainnetProtocolSchedule {
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
* @param privacyParameters the parameters set for private transactions
* @param isMetadataEnabled whether storing metadata for failed transactions
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled) {
final boolean isRevertReasonEnabled) {
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
return FixedDifficultyProtocolSchedule.create(config, privacyParameters, isMetadataEnabled);
return FixedDifficultyProtocolSchedule.create(
config, privacyParameters, isRevertReasonEnabled);
}
return new ProtocolScheduleBuilder(
config,
DEFAULT_CHAIN_ID,
Function.identity(),
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
config.isQuorum())
.createProtocolSchedule();
}
@ -64,12 +65,12 @@ public class MainnetProtocolSchedule {
*
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
* @param isMetadataEnabled whether storing metadata for failed transactions
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config, final boolean isMetadataEnabled) {
return fromConfig(config, PrivacyParameters.DEFAULT, isMetadataEnabled);
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return fromConfig(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}
/**

@ -464,28 +464,19 @@ public abstract class MainnetProtocolSpecs {
worldState.rootHash(),
gasUsed,
result.getLogs(),
Optional.empty(), // No revert reason in frontier
result.getGasRemaining());
Optional.empty()); // No revert reason in frontier
}
private static TransactionReceipt byzantiumTransactionReceiptFactory(
final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) {
return new TransactionReceipt(
result.isSuccessful() ? 1 : 0,
gasUsed,
result.getLogs(),
Optional.empty(),
result.getGasRemaining());
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), Optional.empty());
}
private static TransactionReceipt byzantiumTransactionReceiptFactoryWithReasonEnabled(
final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) {
return new TransactionReceipt(
result.isSuccessful() ? 1 : 0,
gasUsed,
result.getLogs(),
result.getRevertReason(),
result.getGasRemaining());
result.isSuccessful() ? 1 : 0, gasUsed, result.getLogs(), result.getRevertReason());
}
private static class DaoBlockProcessor implements BlockProcessor {

@ -36,7 +36,7 @@ public class ProtocolScheduleBuilder {
private final Function<ProtocolSpecBuilder, ProtocolSpecBuilder> protocolSpecAdapter;
private final Optional<BigInteger> defaultChainId;
private final PrivacyParameters privacyParameters;
private final boolean isMetadataEnabled;
private final boolean isRevertReasonEnabled;
private final BadBlockManager badBlockManager = new BadBlockManager();
private final boolean quorumCompatibilityMode;
@ -45,14 +45,14 @@ public class ProtocolScheduleBuilder {
final BigInteger defaultChainId,
final Function<ProtocolSpecBuilder, ProtocolSpecBuilder> protocolSpecAdapter,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
this(
config,
Optional.of(defaultChainId),
protocolSpecAdapter,
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode);
}
@ -60,14 +60,14 @@ public class ProtocolScheduleBuilder {
final GenesisConfigOptions config,
final Function<ProtocolSpecBuilder, ProtocolSpecBuilder> protocolSpecAdapter,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
this(
config,
Optional.empty(),
protocolSpecAdapter,
privacyParameters,
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode);
}
@ -76,13 +76,13 @@ public class ProtocolScheduleBuilder {
final Optional<BigInteger> defaultChainId,
final Function<ProtocolSpecBuilder, ProtocolSpecBuilder> protocolSpecAdapter,
final PrivacyParameters privacyParameters,
final boolean isMetadataEnabled,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
this.config = config;
this.defaultChainId = defaultChainId;
this.protocolSpecAdapter = protocolSpecAdapter;
this.privacyParameters = privacyParameters;
this.isMetadataEnabled = isMetadataEnabled;
this.isRevertReasonEnabled = isRevertReasonEnabled;
this.quorumCompatibilityMode = quorumCompatibilityMode;
}
@ -149,7 +149,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
addProtocolSpec(
protocolSchedule,
@ -158,7 +158,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
addProtocolSpec(
protocolSchedule,
@ -167,7 +167,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
addProtocolSpec(
protocolSchedule,
@ -176,7 +176,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
addProtocolSpec(
protocolSchedule,
@ -185,7 +185,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
if (ExperimentalEIPs.berlinEnabled) {
@ -196,7 +196,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
quorumCompatibilityMode));
}
@ -211,7 +211,7 @@ public class ProtocolScheduleBuilder {
transactionPriceCalculator,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
config,
quorumCompatibilityMode));
}
@ -274,7 +274,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
config.getEcip1017EraRounds(),
quorumCompatibilityMode));
addProtocolSpec(
@ -284,7 +284,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
config.getEcip1017EraRounds(),
quorumCompatibilityMode));
addProtocolSpec(
@ -294,7 +294,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
config.getEcip1017EraRounds(),
quorumCompatibilityMode));
addProtocolSpec(
@ -304,7 +304,7 @@ public class ProtocolScheduleBuilder {
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isMetadataEnabled,
isRevertReasonEnabled,
config.getEcip1017EraRounds(),
quorumCompatibilityMode));

@ -203,7 +203,7 @@ public class KeyValueStoragePrefixedKeyBlockchainStorage implements BlockchainSt
}
private Bytes rlpEncode(final List<TransactionReceipt> receipts) {
return RLP.encode(o -> o.writeList(receipts, TransactionReceipt::writeToWithMetadata));
return RLP.encode(o -> o.writeList(receipts, TransactionReceipt::writeToWithRevertReason));
}
}
}

@ -362,26 +362,22 @@ public class BlockDataGenerator {
return txs;
}
public TransactionReceipt receipt(final long cumulativeGasUsed, final Long gasRemaining) {
public TransactionReceipt receipt(final long cumulativeGasUsed) {
return new TransactionReceipt(
hash(), cumulativeGasUsed, Arrays.asList(log(), log()), Optional.empty(), gasRemaining);
hash(), cumulativeGasUsed, Arrays.asList(log(), log()), Optional.empty());
}
public TransactionReceipt receipt(final Bytes revertReason, final Long gasRemaining) {
public TransactionReceipt receipt(final Bytes revertReason) {
return new TransactionReceipt(
hash(),
positiveLong(),
Arrays.asList(log(), log()),
Optional.of(revertReason),
gasRemaining);
hash(), positiveLong(), Arrays.asList(log(), log()), Optional.of(revertReason));
}
public TransactionReceipt receipt(final Long gasRemaining) {
return receipt(positiveLong(), gasRemaining);
public TransactionReceipt receipt() {
return receipt(positiveLong());
}
public TransactionReceipt receipt(final List<Log> logs, final Long gasRemaining) {
return new TransactionReceipt(hash(), positiveLong(), logs, Optional.empty(), gasRemaining);
public TransactionReceipt receipt(final List<Log> logs) {
return new TransactionReceipt(hash(), positiveLong(), logs, Optional.empty());
}
public UInt256 storageKey() {

@ -241,7 +241,7 @@ public class DefaultBlockchainTest {
.setParentHash(genesisBlock.getHash());
final Block newBlock = gen.block(options);
final List<TransactionReceipt> receipts = gen.receipts(newBlock);
receipts.add(gen.receipt(100L));
receipts.add(gen.receipt());
blockchain.appendBlock(newBlock, receipts);
}

@ -26,18 +26,18 @@ public class TransactionReceiptTest {
@Test
public void toFromRlp() {
final BlockDataGenerator gen = new BlockDataGenerator();
final TransactionReceipt receipt = gen.receipt(100L);
final TransactionReceipt receipt = gen.receipt();
final TransactionReceipt copy =
TransactionReceipt.readFrom(RLP.input(RLP.encode(receipt::writeTo)), false);
TransactionReceipt.readFrom(RLP.input(RLP.encode(receipt::writeToWithRevertReason)), false);
assertThat(copy).isEqualTo(receipt);
}
@Test
public void toFromRlpWithReason() {
final BlockDataGenerator gen = new BlockDataGenerator();
final TransactionReceipt receipt = gen.receipt(Bytes.fromHexString("0x1122334455667788"), 100L);
final TransactionReceipt receipt = gen.receipt(Bytes.fromHexString("0x1122334455667788"));
final TransactionReceipt copy =
TransactionReceipt.readFrom(RLP.input(RLP.encode(receipt::writeToWithMetadata)));
TransactionReceipt.readFrom(RLP.input(RLP.encode(receipt::writeToWithRevertReason)));
assertThat(copy).isEqualTo(receipt);
}
}

@ -210,7 +210,7 @@ public class PrivacyBlockProcessorTest {
final AbstractBlockProcessor.TransactionReceiptFactory mockTransactionReceiptFactory =
mock(AbstractBlockProcessor.TransactionReceiptFactory.class);
when(mockTransactionReceiptFactory.create(any(), any(), anyLong()))
.thenReturn(new TransactionReceipt(0, 0, Collections.emptyList(), Optional.empty(), -1L));
.thenReturn(new TransactionReceipt(0, 0, Collections.emptyList(), Optional.empty()));
when(protocolSpec.getTransactionReceiptFactory()).thenReturn(mockTransactionReceiptFactory);
when(protocolSpec.getBlockReward()).thenReturn(Wei.ZERO);
when(protocolSpec.getMiningBeneficiaryCalculator())

@ -38,7 +38,7 @@ public final class ReceiptsMessageTest {
for (int i = 0; i < dataCount; ++i) {
final List<TransactionReceipt> receiptSet = new ArrayList<>();
for (int j = 0; j < receiptsPerSet; j++) {
receiptSet.add(gen.receipt(-1L));
receiptSet.add(gen.receipt());
}
receipts.add(receiptSet);
}

@ -768,7 +768,7 @@ public class TransactionPoolTest {
new BlockBody(transactionList, emptyList()));
final List<TransactionReceipt> transactionReceipts =
transactionList.stream()
.map(transaction -> new TransactionReceipt(1, 1, emptyList(), Optional.empty(), -1L))
.map(transaction -> new TransactionReceipt(1, 1, emptyList(), Optional.empty()))
.collect(toList());
blockchain.appendBlock(block, transactionReceipts);
return block;

@ -38,9 +38,9 @@ class CliqueGenesisFileModule extends GenesisFileModule {
@Override
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("MetadataEnabled") final boolean metadataEnabled) {
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
// dagger can handle this magic one day
return CliqueProtocolSchedule.create(configOptions, nodeKey, metadataEnabled);
return CliqueProtocolSchedule.create(configOptions, nodeKey, revertReasonEnabled);
}
@Override

@ -34,18 +34,19 @@ import picocli.CommandLine.Option;
@SuppressWarnings("WeakerAccess")
@Module
public class EvmToolCommandOptionsModule {
@Option(
names = {"--receipt-metadata-enabled", "--revert-reason-enabled"},
names = {"--revert-reason-enabled"},
paramLabel = "<Boolean>",
description = "Should metadata be persisted. (default: ${FALLBACK-VALUE})",
description = "Should revert reasons be persisted. (default: ${FALLBACK-VALUE})",
arity = "0..1",
fallbackValue = "true")
final Boolean metadataEnabled = true;
final Boolean revertReasonEnabled = true;
@Provides
@Named("MetadataEnabled")
boolean provideMetadataEnabled() {
return metadataEnabled;
@Named("RevertReasonEnabled")
boolean provideRevertReasonEnabled() {
return revertReasonEnabled;
}
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.

@ -64,7 +64,7 @@ public class GenesisFileModule {
@Provides
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("MetadataEnabled") final boolean metadataEnabled) {
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
throw new RuntimeException("Abstract");
}

@ -32,7 +32,7 @@ class IBFTGenesisFileModule extends GenesisFileModule {
@Override
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("MetadataEnabled") final boolean metadataEnabled) {
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
return IbftProtocolSchedule.create(configOptions);
}

@ -32,7 +32,7 @@ class MainnetGenesisFileModule extends GenesisFileModule {
@Override
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("MetadataEnabled") final boolean metadataEnabled) {
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
return MainnetProtocolSchedule.fromConfig(configOptions);
}

Loading…
Cancel
Save