Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fixed basefee options #6562

Merged
merged 42 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7df4279
feat: add fixed basefee options
suraneti Feb 13, 2024
1370523
Refactor zero base fee to be extension of fixed base fee
matthew1001 Feb 15, 2024
b12ecfa
feat: use MiningParameters to fixed base fee
suraneti Feb 19, 2024
905ee35
feat: add mining parameters arg on protocol schedule builder
suraneti Feb 20, 2024
656c228
chore: fix lint
suraneti Feb 20, 2024
c53359b
chore: fix lint
suraneti Feb 20, 2024
f620271
chore: apply spotless
suraneti Feb 20, 2024
0fd268d
feat: add miningParameters on gray glacier and prague
suraneti Feb 20, 2024
1d55ea9
feat: add miningParameters on gray glacier and prague
suraneti Feb 20, 2024
2f99168
feat: add miningParameters on paris,shanghai,future,experimental
suraneti Feb 20, 2024
dd3e4a6
chore: fix lint
suraneti Feb 20, 2024
1135316
feat: add mining parameters default
suraneti Feb 20, 2024
0429e1b
chore: fix lint
suraneti Feb 20, 2024
b2e640b
chore: import symbol
suraneti Feb 20, 2024
9967992
feat: add miningParameters arguments
suraneti Feb 20, 2024
8a07483
feat: add miningParameters arguments
suraneti Feb 20, 2024
eaf98a5
feat: add miningParameters arguments
suraneti Feb 20, 2024
e661e24
feat: add miningParameters arguments
suraneti Feb 20, 2024
edf9316
feat: add miningParameters default
suraneti Feb 20, 2024
66295c3
chore: add miningParameters on unit-test
suraneti Feb 20, 2024
13a09bd
chore: fix lint
suraneti Feb 20, 2024
c4fb8f3
chore: add miningParameters on unit-test
suraneti Feb 20, 2024
81a0844
chore: add miningParameters on unit-test
suraneti Feb 20, 2024
be0f0b8
chore: add miningParameters on unit-test
suraneti Feb 20, 2024
bcdb2c6
chore: update unit-test
suraneti Feb 20, 2024
9c3adcb
chore: update unit-test
suraneti Feb 20, 2024
35d3762
chore: update unit-test
suraneti Feb 20, 2024
9c331dc
chore: update unit-test
suraneti Feb 20, 2024
409324a
chore: fix lint
suraneti Feb 20, 2024
6fc67fa
Fix integration tests
matthew1001 Feb 23, 2024
ac43137
feat: refactor interface
suraneti Feb 28, 2024
d2362e7
feat: fix invalid parameters
suraneti Feb 28, 2024
cb68f8d
feat: update tests
suraneti Feb 28, 2024
098c9bb
chore: fix lint
suraneti Feb 28, 2024
e4f9c74
chore: fix lint
suraneti Feb 28, 2024
fa3fa9f
chore: fix lint
suraneti Feb 28, 2024
8888070
Merge branch 'main' into feat/fixed-basefee
suraneti Feb 29, 2024
49e2d11
Merge branch 'main' into feat/fixed-basefee
suraneti Mar 1, 2024
2738cf1
Merge branch 'main' into feature/fixed-basefee
suraneti Mar 4, 2024
56f9fdd
Merge branch 'main' into feature/fixed-basefee
macfarla Mar 14, 2024
cc883cf
Merge branch 'main' into feature/fixed-basefee
suraneti Mar 15, 2024
04bd0f8
Merge branch 'main' into feature/fixed-basefee
macfarla Mar 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ protected ProtocolSchedule createProtocolSchedule() {
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ protected ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
miningParameters,
badBlockManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ protected ProtocolSchedule createProtocolSchedule() {
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ protected MiningCoordinator createTransitionMiningCoordinator(
@Override
protected ProtocolSchedule createProtocolSchedule() {
return MergeProtocolSchedule.create(
configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled, badBlockManager);
configOptionsSupplier.get(),
privacyParameters,
isRevertReasonEnabled,
miningParameters,
badBlockManager);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ protected ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
miningParameters,
badBlockManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.forkid.ForkId;
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
Expand Down Expand Up @@ -188,11 +189,13 @@ private static MilestoneStreamingTransitionProtocolSchedule createSchedule(
MilestoneStreamingProtocolSchedule preMergeProtocolSchedule =
new MilestoneStreamingProtocolSchedule(
(DefaultProtocolSchedule)
MainnetProtocolSchedule.fromConfig(configOptions, new BadBlockManager()));
MainnetProtocolSchedule.fromConfig(
configOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()));
MilestoneStreamingProtocolSchedule postMergeProtocolSchedule =
new MilestoneStreamingProtocolSchedule(
(DefaultProtocolSchedule)
MergeProtocolSchedule.create(configOptions, false, new BadBlockManager()));
MergeProtocolSchedule.create(
configOptions, false, MiningParameters.MINING_DISABLED, new BadBlockManager()));
final MilestoneStreamingTransitionProtocolSchedule schedule =
new MilestoneStreamingTransitionProtocolSchedule(
preMergeProtocolSchedule, postMergeProtocolSchedule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,13 @@ default boolean isConsensusMigration() {
*/
boolean isZeroBaseFee();

/**
* Force a Base Fee as Gas Price network to used with London/EIP-1559.
*
* @return true, if you want the next block to use the base fee as gas price.
macfarla marked this conversation as resolved.
Show resolved Hide resolved
*/
boolean isFixedBaseFee();

/**
* The deposit contract address that should be in the logger field in Receipt of Deposit
* transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
private static final String DISCOVERY_CONFIG_KEY = "discovery";
private static final String CHECKPOINT_CONFIG_KEY = "checkpoint";
private static final String ZERO_BASE_FEE_KEY = "zerobasefee";
private static final String FIXED_BASE_FEE_KEY = "fixedbasefee";
private static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress";

private final ObjectNode configRoot;
Expand Down Expand Up @@ -421,6 +422,11 @@ public boolean isZeroBaseFee() {
return getOptionalBoolean(ZERO_BASE_FEE_KEY).orElse(false);
}

@Override
public boolean isFixedBaseFee() {
return getOptionalBoolean(FIXED_BASE_FEE_KEY).orElse(false);
}

@Override
public Optional<Address> getDepositContractAddress() {
Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY);
Expand Down Expand Up @@ -492,6 +498,10 @@ public Map<String, Object> asMap() {
builder.put("zeroBaseFee", true);
}

if (isFixedBaseFee()) {
builder.put("fixedBaseFee", true);
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
private TransitionsConfigOptions transitions = TransitionsConfigOptions.DEFAULT;
private static final DiscoveryOptions DISCOVERY_OPTIONS = DiscoveryOptions.DEFAULT;
private boolean zeroBaseFee = false;
private boolean fixedBaseFee = false;

@Override
public StubGenesisConfigOptions clone() {
Expand Down Expand Up @@ -424,6 +425,11 @@ public boolean isZeroBaseFee() {
return zeroBaseFee;
}

@Override
public boolean isFixedBaseFee() {
return fixedBaseFee;
}

@Override
public List<Long> getForkBlockNumbers() {
return Collections.emptyList();
Expand Down Expand Up @@ -704,6 +710,17 @@ public StubGenesisConfigOptions zeroBaseFee(final boolean zeroBaseFee) {
return this;
}

/**
* Fixed base fee per gas stub genesis config options.
*
* @param fixedBaseFee the zero base fee override
* @return the stub genesis config options
*/
public StubGenesisConfigOptions fixedBaseFee(final boolean fixedBaseFee) {
this.fixedBaseFee = fixedBaseFee;
return this;
}

/**
* Classic fork block stub genesis config options.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,27 @@ void asMapIncludesZeroBaseFee() {
assertThat(config.asMap()).containsOnlyKeys("zeroBaseFee").containsValue(true);
}

@Test
void isFixedBaseFeeShouldDefaultToFalse() {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions();

assertThat(config.isFixedBaseFee()).isFalse();
}

@Test
void isFixedBaseFeeParsedCorrectly() {
final GenesisConfigOptions config = fromConfigOptions(Map.of("fixedbasefee", true));

assertThat(config.isFixedBaseFee()).isTrue();
}

@Test
void asMapIncludesFixedBaseFee() {
final GenesisConfigOptions config = fromConfigOptions(Map.of("fixedbasefee", true));

assertThat(config.asMap()).containsOnlyKeys("fixedBaseFee").containsValue(true);
}

@Test
void shouldGetDepositContractAddress() {
final GenesisConfigOptions config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class CliqueProtocolSchedule {
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule
*/
Expand All @@ -68,6 +70,7 @@ public static ProtocolSchedule create(
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) {

final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
Expand Down Expand Up @@ -103,6 +106,7 @@ public static ProtocolSchedule create(
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager)
.createProtocolSchedule();
}
Expand All @@ -115,6 +119,7 @@ public static ProtocolSchedule create(
* @param nodeKey the node key
* @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule
*/
Expand All @@ -125,6 +130,7 @@ public static ProtocolSchedule create(
final NodeKey nodeKey,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) {
return create(
config,
Expand All @@ -133,6 +139,7 @@ public static ProtocolSchedule create(
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
Expand Down Expand Up @@ -66,6 +67,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());

final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
Expand All @@ -89,6 +91,7 @@ public void parametersAlignWithMainnetWithAdjustments() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager())
.getByBlockHeader(blockHeader(0));

Expand All @@ -112,6 +115,7 @@ public void zeroEpochLengthThrowsException() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero");
Expand All @@ -131,6 +135,7 @@ public void negativeEpochLengthThrowsException() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero");
Expand All @@ -154,6 +159,7 @@ public void shouldValidateBaseFeeMarketTransition() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());

BlockHeader emptyFrontierParent =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void setup() {
proposerNodeKey,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());

final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void setup() {
proposerNodeKey,
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());
cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS);
blockHeaderBuilder = new BlockHeaderTestFixture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
Expand Down Expand Up @@ -52,6 +53,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule
*/
Expand All @@ -62,6 +64,7 @@ public BftProtocolSchedule createProtocolSchedule(
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();

Expand All @@ -83,6 +86,7 @@ public BftProtocolSchedule createProtocolSchedule(
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager)
.createProtocolSchedule();
return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
Expand Down Expand Up @@ -175,6 +176,7 @@ private BftProtocolSchedule createProtocolSchedule(
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());

return new BftProtocolSchedule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
Expand Down Expand Up @@ -243,6 +244,7 @@ protected BlockHeaderValidator.Builder createBlockHeaderRuleset(
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ private static ControllerAndState createControllerAndFinalState(
forksSchedule,
IBFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading
Loading