Skip to content

Commit

Permalink
Feature/1559 cleanup remove experimentaleip (hyperledger#2586)
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
garyschulte authored Aug 6, 2021
1 parent 47a3941 commit b9e1ce0
Show file tree
Hide file tree
Showing 37 changed files with 103 additions and 180 deletions.
7 changes: 0 additions & 7 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.GoQuorumOptions;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.controller.BesuControllerBuilder;
import org.hyperledger.besu.controller.TargetingGasLimitCalculator;
Expand Down Expand Up @@ -1181,7 +1180,6 @@ public void parse(
.setCaseInsensitiveEnumValuesAllowed(true);

handleStableOptions();
enableExperimentalEIPs();
addSubCommands(resultHandler, in);
registerConverters();
handleUnstableOptions();
Expand Down Expand Up @@ -1228,11 +1226,6 @@ void setBesuConfiguration(final BesuConfiguration pluginCommonConfiguration) {
this.pluginCommonConfiguration = pluginCommonConfiguration;
}

private void enableExperimentalEIPs() {
// Usage of static command line flags is strictly reserved for experimental EIPs
commandLine.addMixin("experimentalEIPs", ExperimentalEIPs.class);
}

private void addSubCommands(
final AbstractParseResultHandler<List<Object>> resultHandler, final InputStream in) {
commandLine.addSubcommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.hyperledger.besu.BesuInfo;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethService;
Expand All @@ -32,7 +31,6 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;

@Command(
Expand All @@ -53,8 +51,6 @@ public class RetestethSubCommand implements Runnable {
*/
public static final int RETESTETH_PORT = 47710;

@Mixin private final ExperimentalEIPs experimentalEIPs = new ExperimentalEIPs();

@Option(
names = {"--data-path"},
paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.base.Preconditions.checkNotNull;

import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
Expand All @@ -33,7 +32,6 @@
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
Expand Down Expand Up @@ -299,14 +297,6 @@ public BesuController build() {
final SyncState syncState = new SyncState(blockchain, ethPeers);
final boolean fastSyncEnabled = SyncMode.FAST.equals(syncConfig.getSyncMode());

final Optional<EIP1559> eip1559;
final GenesisConfigOptions genesisConfigOptions =
genesisConfig.getConfigOptions(genesisConfigOverrides);
if (genesisConfigOptions.getEIP1559BlockNumber().isPresent()) {
eip1559 = Optional.of(new EIP1559(genesisConfigOptions.getEIP1559BlockNumber().getAsLong()));
} else {
eip1559 = Optional.empty();
}
final TransactionPool transactionPool =
TransactionPoolFactory.createTransactionPool(
protocolSchedule,
Expand All @@ -316,8 +306,7 @@ public BesuController build() {
metricsSystem,
syncState,
miningParameters.getMinTransactionGasPrice(),
transactionPoolConfiguration,
eip1559);
transactionPoolConfiguration);

final EthProtocolManager ethProtocolManager =
createEthProtocolManager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
Expand Down Expand Up @@ -129,6 +130,8 @@ public void setUp() {
when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
when(mockProtocolSchedule.getByBlockNumber(anyLong())).thenReturn(mockProtocolSpec);
when(mockProtocolSpec.getTransactionValidator()).thenReturn(mockTransactionValidator);
when(mockProtocolSpec.getEip1559()).thenReturn(Optional.of(new EIP1559(0L)));
when(mockProtocolSpec.getFeeMarket()).thenReturn(Optional.of(FeeMarket.london()));
when(mockTransactionValidator.validate(any(), any(Optional.class), any()))
.thenReturn(ValidationResult.valid());
when(mockTransactionValidator.validateForSender(any(), any(), any()))
Expand All @@ -150,8 +153,7 @@ public void setUp() {
new NoOpMetricsSystem(),
syncState,
Wei.ZERO,
txPoolConfig,
Optional.of(new EIP1559(0)));
txPoolConfig);

serviceImpl = new BesuEventsImpl(blockchain, blockBroadcaster, transactionPool, syncState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.config.JsonUtil.normalizeKeys;

import org.hyperledger.besu.config.experimental.ExperimentalEIPs;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -129,11 +127,6 @@ public Optional<Long> getBaseFeePerGas() {
.map(baseFeeStr -> parseLong("baseFeePerGas", baseFeeStr));
}

public Optional<Long> getGenesisBaseFeePerGas() {
return Optional.of(getBaseFeePerGas().orElse(ExperimentalEIPs.initialBasefee))
.filter(z -> 0L == getConfigOptions().getEIP1559BlockNumber().orElse(-1L));
}

public String getMixHash() {
return JsonUtil.getString(configRoot, "mixhash", "");
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hyperledger.besu.config.GenesisConfigFile.fromConfig;

import org.hyperledger.besu.config.experimental.ExperimentalEIPs;

import java.io.IOException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -150,24 +148,18 @@ public void shouldGetBaseFeeAtGenesis() {
GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0},\"baseFeePerGas\":\"0xa\"}");
assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isPresent();
assertThat(withBaseFeeAtGenesis.getBaseFeePerGas().get()).isEqualTo(10L);
assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas()).isPresent();
assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas().get()).isEqualTo(10L);
}

@Test
public void shouldGetDefaultBaseFeeAtGenesis() {
GenesisConfigFile withBaseFeeAtGenesis =
GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0}}");
assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isNotPresent();
assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas()).isPresent();
assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas().get())
.isEqualTo(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE);
}

@Test
public void shouldNotGetBaseFeeAtGenesis() {
assertThat(EMPTY_CONFIG.getBaseFeePerGas()).isNotPresent();
assertThat(EMPTY_CONFIG.getGenesisBaseFeePerGas()).isNotPresent();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public void setUp() {
peerPendingTransactionTracker,
Wei.ZERO,
metricsSystem,
Optional.empty(),
TransactionPoolConfiguration.DEFAULT);
final BlockchainQueries blockchainQueries =
new BlockchainQueries(blockchain, protocolContext.getWorldStateArchive());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
Expand All @@ -39,6 +38,7 @@
import org.hyperledger.besu.ethereum.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -145,7 +145,7 @@ public void correctlyHandlesForkBlock() {
(FeeHistory.FeeHistoryResult)
((JsonRpcSuccessResponse) feeHistoryRequest(1, "latest")).getResult();
assertThat(Long.decode(result.getBaseFeePerGas().get(1)))
.isEqualTo(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE);
.isEqualTo(FeeMarket.london().getInitialBasefee());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class EthGetTransactionReceiptTest {
null,
TransactionPriceCalculator.frontier(),
Optional.empty(),
Optional.empty(),
null,
Optional.of(PoWHasher.ETHASH_LIGHT));
private final ProtocolSpec statusTransactionTypeSpec =
Expand All @@ -133,6 +134,7 @@ public class EthGetTransactionReceiptTest {
null,
TransactionPriceCalculator.frontier(),
Optional.empty(),
Optional.empty(),
null,
Optional.of(PoWHasher.ETHASH_LIGHT));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ private ProcessableBlockHeader createPendingBlockHeader(final long timestamp) {
difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext);

Long baseFee = null;
if (protocolSpec.isEip1559()) {
if (protocolSpec.hasFeeMarket()) {
// TODO roll eip1559 into feeMarket
final EIP1559 eip1559 = protocolSpec.getEip1559().orElseThrow();
if (eip1559.isForkBlock(newBlockNumber)) {
gasLimit = gasLimit * eip1559.getFeeMarket().getSlackCoefficient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static BlockHeader buildHeader(
.mixHash(parseMixHash(genesis))
.nonce(parseNonce(genesis))
.blockHeaderFunctions(ScheduleBasedBlockHeaderFunctions.create(protocolSchedule))
.baseFee(genesis.getGenesisBaseFeePerGas().orElse(null))
.baseFee(genesis.getBaseFeePerGas().orElse(null))
.buildBlockHeader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public long getEffectivePriorityFeePerGas(final Optional<Long> maybeBaseFee) {
.map(
maybeNegativeEffectivePriorityFeePerGas ->
Math.max(0, maybeNegativeEffectivePriorityFeePerGas))
.orElseGet(() -> getGasPrice().get().getValue().longValue());
.orElseGet(() -> getGasPrice().map(Wei::getValue).map(Number::longValue).orElse(0L));
}
/**
* Returns the transaction gas limit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public BaseFee(final FeeMarket feeMarket, final long value) {

public static Wei minTransactionPriceInNextBlock(
final Transaction transaction,
final FeeMarket feeMarket,
final TransactionPriceCalculator calculator,
final Supplier<Optional<Long>> baseFeeSupplier) {
final Optional<Long> baseFee = baseFeeSupplier.get();
Optional<Long> minBaseFeeInNextBlock = Optional.empty();
if (baseFee.isPresent()) {
minBaseFeeInNextBlock =
Optional.of(new BaseFee(FeeMarket.london(), baseFee.get()).getMinNextValue());
minBaseFeeInNextBlock = Optional.of(new BaseFee(feeMarket, baseFee.get()).getMinNextValue());
}
return calculator.price(transaction, minBaseFeeInNextBlock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public class EIP1559 {

private final long initialForkBlknum;

private final FeeMarket feeMarket = FeeMarket.london();
private final FeeMarket feeMarket;

public EIP1559(final long forkBlockNumber) {
initialForkBlknum = forkBlockNumber;
this.initialForkBlknum = forkBlockNumber;
this.feeMarket = FeeMarket.london();
}

public long computeBaseFee(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
*/
package org.hyperledger.besu.ethereum.core.fees;

public class LondonFeeMarketException extends Exception {
public class FeeMarketException extends Exception {

public static LondonFeeMarketException MissingBaseFeeFromBlockHeader() {
return new LondonFeeMarketException("Invalid block header: basefee should be specified");
public static FeeMarketException MissingBaseFeeFromBlockHeader() {
return new FeeMarketException("Invalid block header: basefee should be specified");
}

public static LondonFeeMarketException BaseFeePresentBeforeForkBlock() {
return new LondonFeeMarketException(
"Invalid block header: basefee should not be present before London fork block");
public static FeeMarketException BaseFeePresentBeforeForkBlock() {
return new FeeMarketException(
"Invalid block header: basefee should not be present before fee market fork block");
}

private LondonFeeMarketException(final String reason) {
private FeeMarketException(final String reason) {
super(reason);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public interface TransactionPriceCalculator {
Wei price(Transaction transaction, Optional<Long> baseFee);

static TransactionPriceCalculator frontier() {
return (transaction, baseFee) -> transaction.getGasPrice().get();
return (transaction, baseFee) -> transaction.getGasPrice().orElse(Wei.ZERO);
}

static TransactionPriceCalculator eip1559() {
return (transaction, maybeBaseFee) -> {
final Wei baseFee = Wei.of(maybeBaseFee.orElseThrow());
if (!transaction.getType().supports1559FeeMarket()) {
return transaction.getGasPrice().get();
return transaction.getGasPrice().orElse(Wei.ZERO);
}
final Wei maxPriorityFeePerGas = transaction.getMaxPriorityFeePerGas().orElseThrow();
final Wei maxFeePerGas = transaction.getMaxFeePerGas().orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockValidatorBuilder;
import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule;
import org.hyperledger.besu.ethereum.mainnet.contractvalidation.PrefixCodeRule;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
Expand Down Expand Up @@ -517,6 +518,7 @@ static ProtocolSpecBuilder londonDefinition(
MainnetEvmRegistries.london(gasCalculator, chainId.orElse(BigInteger.ZERO)))
.transactionPriceCalculator(transactionPriceCalculator.orElseThrow())
.eip1559(Optional.of(eip1559))
.feeMarket(Optional.of(FeeMarket.london()))
.difficultyCalculator(MainnetDifficultyCalculators.LONDON)
.blockHeaderValidatorBuilder(MainnetBlockHeaderValidator.createEip1559Validator(eip1559))
.ommerHeaderValidatorBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface ProtocolSchedule {

ProtocolSpec getByBlockNumber(long number);

public Stream<Long> streamMilestoneBlocks();
Stream<Long> streamMilestoneBlocks();

Optional<BigInteger> getChainId();

Expand Down
Loading

0 comments on commit b9e1ce0

Please sign in to comment.