Skip to content

Commit

Permalink
Remove Berlin Feature Flag (hyperledger#1898)
Browse files Browse the repository at this point in the history
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
(cherry picked from commit f2669df)
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
  • Loading branch information
RatanRSur authored and shemnon committed Feb 11, 2021
1 parent 6695d7c commit cc9af94
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 69 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- [Fast sync when running Besu on cloud providers](KNOWN_ISSUES.md#fast-sync-when-running-besu-on-cloud-providers)
- [Privacy users with private transactions created using v1.3.4 or earlier](KNOWN_ISSUES.md#privacy-users-with-private-transactions-created-using-v134-or-earlier)

## 21.1.0-RC2
### Additions and Improvements
* Support for the Berlin Network Upgrade, although the block number must be set manually with `--override-genesis-config=berlinBlock=<blocknumber>`. This is because the block numbers haven't been determined yet. The next release will include the number in the genesis file so it will support Berlin with no intervention. [\#1898](https://github.com/hyperledger/besu/pull/1898)

## 21.1.0-RC1

### 21.1.0 Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,16 @@ public OptionalLong getMuirGlacierBlockNumber() {

@Override
public OptionalLong getBerlinBlockNumber() {
if (ExperimentalEIPs.berlinEnabled) {
final OptionalLong berlinBlock = getOptionalLong("berlinblock");
final OptionalLong yolov3Block = getOptionalLong("yolov3block");
if (yolov3Block.isPresent()) {
if (berlinBlock.isPresent()) {
throw new RuntimeException(
"Genesis files cannot specify both berlinblock and yoloV2Block.");
}
return yolov3Block;
final OptionalLong berlinBlock = getOptionalLong("berlinblock");
final OptionalLong yolov3Block = getOptionalLong("yolov3block");
if (yolov3Block.isPresent()) {
if (berlinBlock.isPresent()) {
throw new RuntimeException(
"Genesis files cannot specify both berlinblock and yoloV2Block.");
}
return berlinBlock;
return yolov3Block;
}
return OptionalLong.empty();
return berlinBlock;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public OptionalLong getMuirGlacierBlockNumber() {

@Override
public OptionalLong getBerlinBlockNumber() {
return ExperimentalEIPs.berlinEnabled ? berlinBlockNumber : OptionalLong.empty();
return berlinBlockNumber;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public class ExperimentalEIPs {
arity = "1")
public static boolean eip1559Enabled = EIP1559_ENABLED_DEFAULT_VALUE;

// To make it easier for tests to reset the value to default
public static final boolean BERLIN_ENABLED_DEFAULT_VALUE = false;

@Option(
hidden = true,
names = {"--Xberlin-enabled"},
description = "Enable non-finalized Berlin features (default: ${DEFAULT-VALUE})",
arity = "1")
public static boolean berlinEnabled = BERLIN_ENABLED_DEFAULT_VALUE;

public static void eip1559MustBeEnabled() {
if (!eip1559Enabled) {
throw new RuntimeException("EIP-1559 feature flag must be enabled --Xeip1559-enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,14 @@ public void shouldGetMuirGlacierBlockNumber() {

@Test
public void shouldGetBerlinBlockNumber() {
try {
ExperimentalEIPs.berlinEnabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("berlinBlock", 1000));
assertThat(config.getBerlinBlockNumber()).hasValue(1000);
} finally {
ExperimentalEIPs.berlinEnabled = ExperimentalEIPs.BERLIN_ENABLED_DEFAULT_VALUE;
}
final GenesisConfigOptions config = fromConfigOptions(singletonMap("berlinBlock", 1000));
assertThat(config.getBerlinBlockNumber()).hasValue(1000);
}

@Test
public void shouldGetYoloV2BlockNumber() {
try {
ExperimentalEIPs.berlinEnabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("yoloV3Block", 1000));
assertThat(config.getBerlinBlockNumber()).hasValue(1000);
} finally {
ExperimentalEIPs.berlinEnabled = ExperimentalEIPs.BERLIN_ENABLED_DEFAULT_VALUE;
}
public void shouldGetYoloV3BlockNumber() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("yoloV3Block", 1000));
assertThat(config.getBerlinBlockNumber()).hasValue(1000);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ static ProtocolSpecBuilder berlinDefinition(
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
if (!ExperimentalEIPs.berlinEnabled) {
throw new RuntimeException("Berlin feature flag must be enabled --Xberlin-enabled");
}
return muirGlacierDefinition(
chainId,
contractSizeLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,15 @@ public ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
quorumCompatibilityMode));

if (ExperimentalEIPs.berlinEnabled) {
addProtocolSpec(
protocolSchedule,
config.getBerlinBlockNumber(),
MainnetProtocolSpecs.berlinDefinition(
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isRevertReasonEnabled,
quorumCompatibilityMode));
}
addProtocolSpec(
protocolSchedule,
config.getBerlinBlockNumber(),
MainnetProtocolSpecs.berlinDefinition(
chainId,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isRevertReasonEnabled,
quorumCompatibilityMode));

if (ExperimentalEIPs.eip1559Enabled) {
final Optional<TransactionPriceCalculator> transactionPriceCalculator =
Expand Down Expand Up @@ -366,9 +364,7 @@ private void validateEthereumForkOrdering() {
lastForkBlock = validateForkOrder("Istanbul", config.getIstanbulBlockNumber(), lastForkBlock);
lastForkBlock =
validateForkOrder("MuirGlacier", config.getMuirGlacierBlockNumber(), lastForkBlock);
if (ExperimentalEIPs.berlinEnabled) {
lastForkBlock = validateForkOrder("Berlin", config.getBerlinBlockNumber(), lastForkBlock);
}
lastForkBlock = validateForkOrder("Berlin", config.getBerlinBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
Expand Down Expand Up @@ -79,10 +78,7 @@ public class BlockchainReferenceTestTools {
// Don't do time consuming tests
params.ignore("CALLBlake2f_MaxRounds.*");

// Berlin isn't finalized
if (!ExperimentalEIPs.berlinEnabled) {
params.ignore(".*[_-]Berlin");
}
params.ignore(".*[_-]Berlin");
}

public static Collection<Object[]> generateTestParametersForConfig(final String[] filePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.core.Account;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Hash;
Expand Down Expand Up @@ -103,10 +102,7 @@ private static MainnetTransactionProcessor transactionProcessor(final String nam
// Don't do time consuming tests
params.ignore("CALLBlake2f_MaxRounds.*");

// Berlin isn't finalized
if (!ExperimentalEIPs.berlinEnabled) {
params.ignore(".*[_-]Berlin");
}
params.ignore(".*[_-]Berlin");
}

public static Collection<Object[]> generateTestParametersForConfig(final String[] filePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
Expand Down Expand Up @@ -62,10 +61,8 @@ public static ReferenceTestProtocolSchedules create() {
builder.put("Petersburg", createSchedule(new StubGenesisConfigOptions().petersburgBlock(0)));
builder.put("Istanbul", createSchedule(new StubGenesisConfigOptions().istanbulBlock(0)));
builder.put("MuirGlacier", createSchedule(new StubGenesisConfigOptions().muirGlacierBlock(0)));
if (ExperimentalEIPs.berlinEnabled) {
builder.put("Berlin", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
builder.put("YOLOv3", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
}
builder.put("Berlin", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
builder.put("YOLOv3", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
return new ReferenceTestProtocolSchedules(builder.build());
}

Expand Down

0 comments on commit cc9af94

Please sign in to comment.