Add support for baikal testnet and london network upgrade (#2237)

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>

Co-authored-by: garyschulte <garyschulte@gmail.com>
pull/2243/head
matkt 4 years ago committed by GitHub
parent 4a3e2751c3
commit 9b542bc7ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 13
      besu/src/main/java/org/hyperledger/besu/cli/config/EthNetworkConfig.java
  3. 2
      besu/src/main/java/org/hyperledger/besu/cli/config/NetworkName.java
  4. 4
      config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java
  5. 39
      config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java
  6. 30
      config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java
  7. 25
      config/src/main/resources/baikal.json
  8. 33
      config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java
  9. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/CoinbaseFeePriceCalculator.java
  10. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/TransactionPriceCalculator.java
  11. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java
  12. 22
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
  13. 67
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  14. 29
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  15. 57
      ethereum/evmtool/src/test/benchmarks/bench-yolov3.sh
  16. 7
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/config/DiscoveryConfiguration.java
  17. 3
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  18. 2
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java

@ -4,6 +4,10 @@
### Additions and Improvements
* Added support for the upcoming BAIKAL ephemeral testnet and removed the configuration for the deprecated YOLOv3 ephemeral testnet. [\#2237](https://github.com/hyperledger/besu/pull/2237)
* Added support for the London Network Upgrade, although the block number must be set manually with `--override-genesis-config=londonBlock=<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 London with no intervention. [\#2237](https://github.com/hyperledger/besu/pull/2237)
### Bug Fixes
- Added ACCESS_LIST transactions to the list of transactions using legacy gas pricing for 1559 [\#2239](https://github.com/hyperledger/besu/pull/2239)

@ -27,7 +27,6 @@ import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.RI
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.RINKEBY_DISCOVERY_URL;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.ROPSTEN_BOOTSTRAP_NODES;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.ROPSTEN_DISCOVERY_URL;
import static org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration.YOLO_V3_BOOTSTRAP_NODES;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
@ -47,23 +46,23 @@ public class EthNetworkConfig {
public static final BigInteger ROPSTEN_NETWORK_ID = BigInteger.valueOf(3);
public static final BigInteger RINKEBY_NETWORK_ID = BigInteger.valueOf(4);
public static final BigInteger GOERLI_NETWORK_ID = BigInteger.valueOf(5);
public static final BigInteger BAIKAL_NETWORK_ID = BigInteger.valueOf(1642);
public static final BigInteger DEV_NETWORK_ID = BigInteger.valueOf(2018);
public static final BigInteger ECIP1049_DEV_NETWORK_ID = BigInteger.valueOf(2021);
public static final BigInteger CLASSIC_NETWORK_ID = BigInteger.valueOf(1);
public static final BigInteger KOTTI_NETWORK_ID = BigInteger.valueOf(6);
public static final BigInteger MORDOR_NETWORK_ID = BigInteger.valueOf(7);
private static final BigInteger YOLO_V3_NETWORK_ID = BigInteger.valueOf(34180983699157880L);
private static final BigInteger ASTOR_NETWORK_ID = BigInteger.valueOf(212);
private static final String MAINNET_GENESIS = "/mainnet.json";
private static final String ROPSTEN_GENESIS = "/ropsten.json";
private static final String RINKEBY_GENESIS = "/rinkeby.json";
private static final String GOERLI_GENESIS = "/goerli.json";
private static final String BAIKAL_GENESIS = "/baikal.json";
private static final String DEV_GENESIS = "/dev.json";
private static final String DEV_ECIP1049_GENESIS = "/ecip1049_dev.json";
private static final String CLASSIC_GENESIS = "/classic.json";
private static final String KOTTI_GENESIS = "/kotti.json";
private static final String MORDOR_GENESIS = "/mordor.json";
private static final String YOLO_GENESIS = "/yolo.json";
private static final String ASTOR_GENESIS = "/astor.json";
private final String genesisConfig;
@ -154,6 +153,9 @@ public class EthNetworkConfig {
GOERLI_NETWORK_ID,
GOERLI_BOOTSTRAP_NODES,
GOERLI_DISCOVERY_URL);
case BAIKAL:
return new EthNetworkConfig(
jsonConfig(BAIKAL_GENESIS), BAIKAL_NETWORK_ID, new ArrayList<>(), null);
case DEV:
return new EthNetworkConfig(
jsonConfig(DEV_GENESIS), DEV_NETWORK_ID, new ArrayList<>(), null);
@ -169,9 +171,6 @@ public class EthNetworkConfig {
case MORDOR:
return new EthNetworkConfig(
jsonConfig(MORDOR_GENESIS), MORDOR_NETWORK_ID, MORDOR_BOOTSTRAP_NODES, null);
case YOLO_V3:
return new EthNetworkConfig(
jsonConfig(YOLO_GENESIS), YOLO_V3_NETWORK_ID, YOLO_V3_BOOTSTRAP_NODES, null);
case ASTOR:
return new EthNetworkConfig(
jsonConfig(ASTOR_GENESIS), ASTOR_NETWORK_ID, ASTOR_BOOTSTRAP_NODES, null);
@ -214,8 +213,6 @@ public class EthNetworkConfig {
return jsonConfig(KOTTI_GENESIS);
case MORDOR:
return jsonConfig(MORDOR_GENESIS);
case YOLO_V3:
return jsonConfig(YOLO_GENESIS);
default:
throw new IllegalArgumentException("Unknown network:" + network);
}

@ -19,11 +19,11 @@ public enum NetworkName {
RINKEBY,
ROPSTEN,
GOERLI,
BAIKAL,
DEV,
CLASSIC,
KOTTI,
MORDOR,
YOLO_V3,
ECIP1049_DEV,
ASTOR
}

@ -69,7 +69,11 @@ public interface GenesisConfigOptions {
OptionalLong getBerlinBlockNumber();
OptionalLong getLondonBlockNumber();
// TODO EIP-1559 change for the actual fork name when known
OptionalLong getAleutBlockNumber();
OptionalLong getEIP1559BlockNumber();
default Optional<Long> getGenesisBaseFee() {

@ -242,22 +242,39 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
@Override
public OptionalLong getBerlinBlockNumber() {
final OptionalLong berlinBlock = getOptionalLong("berlinblock");
final OptionalLong yolov3Block = getOptionalLong("yolov3block");
if (yolov3Block.isPresent()) {
if (berlinBlock.isPresent()) {
return getOptionalLong("berlinblock");
}
@Override
public OptionalLong getLondonBlockNumber() {
if (!ExperimentalEIPs.eip1559Enabled) {
return OptionalLong.empty();
}
final OptionalLong londonBlock = getOptionalLong("londonblock");
final OptionalLong baikalblock = getOptionalLong("baikalblock");
if (baikalblock.isPresent()) {
if (londonBlock.isPresent()) {
throw new RuntimeException(
"Genesis files cannot specify both berlinblock and yoloV2Block.");
"Genesis files cannot specify both londonblock and baikalblock.");
}
return yolov3Block;
return baikalblock;
}
return berlinBlock;
return londonBlock;
}
@Override
public OptionalLong getAleutBlockNumber() {
return ExperimentalEIPs.eip1559Enabled ? getOptionalLong("aleutblock") : OptionalLong.empty();
}
@Override
// TODO EIP-1559 change for the actual fork name when known
public OptionalLong getEIP1559BlockNumber() {
return ExperimentalEIPs.eip1559Enabled ? getOptionalLong("aleutblock") : OptionalLong.empty();
if (getAleutBlockNumber().isPresent()) {
return getAleutBlockNumber();
} else {
return getLondonBlockNumber();
}
}
@Override
@ -380,6 +397,8 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getIstanbulBlockNumber().ifPresent(l -> builder.put("istanbulBlock", l));
getMuirGlacierBlockNumber().ifPresent(l -> builder.put("muirGlacierBlock", l));
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getAleutBlockNumber().ifPresent(l -> builder.put("aleutBlock", l));
// classic fork blocks
getClassicForkBlock().ifPresent(l -> builder.put("classicForkBlock", l));
@ -393,7 +412,6 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getThanosBlockNumber().ifPresent(l -> builder.put("thanosBlock", l));
getEcip1049BlockNumber().ifPresent(l -> builder.put("ecip1049Block", l));
getEIP1559BlockNumber().ifPresent(l -> builder.put("aleutblock", l));
getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
getEvmStackSize().ifPresent(l -> builder.put("evmstacksize", l));
getEcip1017EraRounds().ifPresent(l -> builder.put("ecip1017EraRounds", l));
@ -480,7 +498,8 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getIstanbulBlockNumber(),
getMuirGlacierBlockNumber(),
getBerlinBlockNumber(),
getEIP1559BlockNumber(),
getLondonBlockNumber(),
getAleutBlockNumber(),
getEcip1015BlockNumber(),
getDieHardBlockNumber(),
getGothamBlockNumber(),

@ -38,8 +38,10 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong istanbulBlockNumber = OptionalLong.empty();
private OptionalLong muirGlacierBlockNumber = OptionalLong.empty();
private OptionalLong berlinBlockNumber = OptionalLong.empty();
private OptionalLong londonBlockNumber = OptionalLong.empty();
// TODO EIP-1559 change for the actual fork name when known
private final OptionalLong eip1559BlockNumber = OptionalLong.empty();
private final OptionalLong aleutBlockNumber = OptionalLong.empty();
private OptionalLong classicForkBlock = OptionalLong.empty();
private OptionalLong ecip1015BlockNumber = OptionalLong.empty();
private OptionalLong diehardBlockNumber = OptionalLong.empty();
@ -166,10 +168,24 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return berlinBlockNumber;
}
@Override
public OptionalLong getLondonBlockNumber() {
return ExperimentalEIPs.eip1559Enabled ? londonBlockNumber : OptionalLong.empty();
}
@Override
// TODO EIP-1559 change for the actual fork name when known
public OptionalLong getAleutBlockNumber() {
return ExperimentalEIPs.eip1559Enabled ? aleutBlockNumber : OptionalLong.empty();
}
@Override
public OptionalLong getEIP1559BlockNumber() {
return ExperimentalEIPs.eip1559Enabled ? eip1559BlockNumber : OptionalLong.empty();
if (getAleutBlockNumber().isPresent()) {
return getAleutBlockNumber();
} else {
return getLondonBlockNumber();
}
}
@Override
@ -266,9 +282,8 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
getIstanbulBlockNumber().ifPresent(l -> builder.put("istanbulBlock", l));
getMuirGlacierBlockNumber().ifPresent(l -> builder.put("muirGlacierBlock", l));
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
// TODO EIP-1559 change for the actual fork name when known
getEIP1559BlockNumber().ifPresent(l -> builder.put("aleutblock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getAleutBlockNumber().ifPresent(l -> builder.put("aleutBlock", l));
// classic fork blocks
getClassicForkBlock().ifPresent(l -> builder.put("classicForkBlock", l));
getEcip1015BlockNumber().ifPresent(l -> builder.put("ecip1015Block", l));
@ -383,6 +398,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return this;
}
public StubGenesisConfigOptions londonBlock(final long blockNumber) {
londonBlockNumber = OptionalLong.of(blockNumber);
return this;
}
public StubGenesisConfigOptions classicForkBlock(final long blockNumber) {
classicForkBlock = OptionalLong.of(blockNumber);
return this;

@ -1,24 +1,23 @@
{
"config": {
"chainId": 34180983699157880,
"chainId": 1642,
"homesteadBlock": 0,
"daoForkBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"yoloV3Block": 0,
"berlinBlock": 0,
"londonBlock": 500,
"clique": {
"period": 30,
"epoch": 30000
"blockperiodseconds": 30,
"epochlength": 30000
}
},
"nonce": "0x0",
"timestamp": "0x6027dd2e",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000001041afbcb359d5a8dc58c15b2ff51354ff8a217d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x6092ca7f",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000005211cea3870c7ba7c6c44b185e62eecdb864cd8c560228ce57d31efbf64c200b2c200aacec78cf17a7148e784fe95a7a750335f8b9572ee28d72e7650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
@ -795,9 +794,6 @@
"0e89e2aedb1cfcdb9424d41a1f218f4132738172": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"1041afbcb359d5a8dc58c15b2ff51354ff8a217d": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"60adc0f89a41af237ce73554ede170d733ec14e0": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
@ -815,12 +811,9 @@
},
"b02a2eda1b317fbd16760128836b0ac59b560e9d": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
},
"df0a88b2b68c673713a8ec826003676f272e3573": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}

@ -181,18 +181,39 @@ public class GenesisConfigOptionsTest {
}
@Test
public void shouldGetYoloV3BlockNumber() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("yoloV3Block", 1000));
assertThat(config.getBerlinBlockNumber()).hasValue(1000);
public void shouldGetLondonBlockNumber() {
try {
ExperimentalEIPs.eip1559Enabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("londonblock", 1000));
assertThat(config.getEIP1559BlockNumber()).hasValue(1000);
assertThat(config.getLondonBlockNumber()).hasValue(1000);
assertThat(config.getGenesisBaseFee()).isEmpty();
} finally {
ExperimentalEIPs.eip1559Enabled = ExperimentalEIPs.EIP1559_ENABLED_DEFAULT_VALUE;
}
}
@Test
public void shouldGetBaikalBlockNumber() {
try {
ExperimentalEIPs.eip1559Enabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("baikalblock", 1000));
assertThat(config.getEIP1559BlockNumber()).hasValue(1000);
assertThat(config.getLondonBlockNumber()).hasValue(1000);
assertThat(config.getGenesisBaseFee()).isEmpty();
} finally {
ExperimentalEIPs.eip1559Enabled = ExperimentalEIPs.EIP1559_ENABLED_DEFAULT_VALUE;
}
}
@Test
// TODO EIP-1559 change for the actual fork name when known
public void shouldGetEIP1559BlockNumber() {
public void shouldGetAleutBlockNumber() {
try {
ExperimentalEIPs.eip1559Enabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("aleutblock", 1000));
assertThat(config.getEIP1559BlockNumber()).hasValue(1000);
assertThat(config.getAleutBlockNumber()).hasValue(1000);
assertThat(config.getGenesisBaseFee()).isEmpty();
} finally {
ExperimentalEIPs.eip1559Enabled = ExperimentalEIPs.EIP1559_ENABLED_DEFAULT_VALUE;
@ -204,7 +225,7 @@ public class GenesisConfigOptionsTest {
public void shouldGetEIP1559BaseFeeAtGenesis() {
try {
ExperimentalEIPs.eip1559Enabled = true;
final GenesisConfigOptions config = fromConfigOptions(singletonMap("aleutblock", 0));
final GenesisConfigOptions config = fromConfigOptions(singletonMap("londonblock", 0));
assertThat(config.getEIP1559BlockNumber()).hasValue(0);
assertThat(config.getGenesisBaseFee())
.hasValue(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE);
@ -233,6 +254,8 @@ public class GenesisConfigOptionsTest {
assertThat(config.getIstanbulBlockNumber()).isEmpty();
assertThat(config.getMuirGlacierBlockNumber()).isEmpty();
assertThat(config.getBerlinBlockNumber()).isEmpty();
assertThat(config.getLondonBlockNumber()).isEmpty();
assertThat(config.getAleutBlockNumber()).isEmpty();
assertThat(config.getEcip1049BlockNumber()).isEmpty();
}

@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.core.fees;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.core.Gas;
import org.hyperledger.besu.ethereum.core.Wei;
@ -30,7 +29,6 @@ public interface CoinbaseFeePriceCalculator {
static CoinbaseFeePriceCalculator eip1559() {
return (coinbaseFee, transactionGasPrice, baseFee) -> {
ExperimentalEIPs.eip1559MustBeEnabled();
return coinbaseFee.priceFor(transactionGasPrice.subtract(Wei.of(baseFee.orElseThrow())));
};
}

@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.core.fees;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Wei;
@ -31,7 +30,6 @@ public interface TransactionPriceCalculator {
static TransactionPriceCalculator eip1559() {
return (transaction, maybeBaseFee) -> {
ExperimentalEIPs.eip1559MustBeEnabled();
final Wei baseFee = Wei.of(maybeBaseFee.orElseThrow());
if (!transaction.getType().supports1559FeeMarket()) {
return transaction.getGasPrice();

@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.AncestryValidationRule;
@ -119,7 +118,6 @@ public final class MainnetBlockHeaderValidator {
}
static BlockHeaderValidator.Builder createEip1559Validator(final EIP1559 eip1559) {
ExperimentalEIPs.eip1559MustBeEnabled();
return new BlockHeaderValidator.Builder()
.addRule(CalculatedDifficultyValidationRule::new)
.addRule(new AncestryValidationRule())
@ -134,7 +132,6 @@ public final class MainnetBlockHeaderValidator {
}
static BlockHeaderValidator.Builder createEip1559OmmerValidator(final EIP1559 eip1559) {
ExperimentalEIPs.eip1559MustBeEnabled();
return new BlockHeaderValidator.Builder()
.addRule(CalculatedDifficultyValidationRule::new)
.addRule(new AncestryValidationRule())

@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions;
import java.math.BigInteger;
import java.util.Optional;
import java.util.OptionalInt;
@ -103,6 +105,26 @@ public class MainnetProtocolSpecFactory {
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
}
public ProtocolSpecBuilder aleutDefinition(final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.aleutDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
genesisConfigOptions,
quorumCompatibilityMode);
}
public ProtocolSpecBuilder londonDefinition(final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.londonDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
genesisConfigOptions,
quorumCompatibilityMode);
}
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
// Classic Protocol Specs

@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.PowAlgorithm;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Account;
@ -456,17 +455,75 @@ public abstract class MainnetProtocolSpecs {
.name("Berlin");
}
static ProtocolSpecBuilder aleutDefinition(
final Optional<BigInteger> chainId,
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode) {
final Optional<TransactionPriceCalculator> transactionPriceCalculator =
Optional.of(TransactionPriceCalculator.eip1559());
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
final EIP1559 eip1559 =
new EIP1559(genesisConfigOptions.getEIP1559BlockNumber().orElse(Long.MAX_VALUE));
return berlinDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
.transactionValidatorBuilder(
gasCalculator ->
new MainnetTransactionValidator(
gasCalculator,
transactionPriceCalculator,
true,
chainId,
Set.of(
TransactionType.FRONTIER,
TransactionType.ACCESS_LIST,
TransactionType.EIP1559),
quorumCompatibilityMode))
.transactionProcessorBuilder(
(gasCalculator,
transactionValidator,
contractCreationProcessor,
messageCallProcessor) ->
new MainnetTransactionProcessor(
gasCalculator,
transactionValidator,
contractCreationProcessor,
messageCallProcessor,
true,
stackSizeLimit,
Account.DEFAULT_VERSION,
transactionPriceCalculator.orElseThrow(),
CoinbaseFeePriceCalculator.eip1559()))
.evmBuilder(
gasCalculator ->
MainnetEvmRegistries.london(gasCalculator, chainId.orElse(BigInteger.ZERO)))
.name("Aleut")
.transactionPriceCalculator(transactionPriceCalculator.orElseThrow())
.eip1559(Optional.of(eip1559))
.gasBudgetCalculator(TransactionGasBudgetCalculator.eip1559(eip1559))
.blockHeaderValidatorBuilder(MainnetBlockHeaderValidator.createEip1559Validator(eip1559))
.ommerHeaderValidatorBuilder(
MainnetBlockHeaderValidator.createEip1559OmmerValidator(eip1559));
}
static ProtocolSpecBuilder londonDefinition(
final Optional<BigInteger> chainId,
final Optional<TransactionPriceCalculator> transactionPriceCalculator,
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode) {
ExperimentalEIPs.eip1559MustBeEnabled();
final Optional<TransactionPriceCalculator> transactionPriceCalculator =
Optional.of(TransactionPriceCalculator.eip1559());
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
final EIP1559 eip1559 = new EIP1559(genesisConfigOptions.getEIP1559BlockNumber().orElse(0));
final EIP1559 eip1559 =
new EIP1559(genesisConfigOptions.getEIP1559BlockNumber().orElse(Long.MAX_VALUE));
return berlinDefinition(
chainId,
contractSizeLimit,
@ -484,7 +541,7 @@ public abstract class MainnetProtocolSpecs {
TransactionType.FRONTIER,
TransactionType.ACCESS_LIST,
TransactionType.EIP1559),
genesisConfigOptions.isQuorum()))
quorumCompatibilityMode))
.transactionProcessorBuilder(
(gasCalculator,
transactionValidator,

@ -15,10 +15,8 @@
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import java.math.BigInteger;
@ -143,7 +141,7 @@ public class ProtocolScheduleBuilder {
validateForkOrdering();
final TreeMap<Long, BuilderMapEntry> builders = buildMilestoneMap(specFactory, chainId);
final TreeMap<Long, BuilderMapEntry> builders = buildMilestoneMap(specFactory);
// At this stage, all milestones are flagged with correct modifier, but ProtocolSpecs must be
// inserted _AT_ the modifier block entry.
@ -206,7 +204,7 @@ public class ProtocolScheduleBuilder {
}
private TreeMap<Long, BuilderMapEntry> buildMilestoneMap(
final MainnetProtocolSpecFactory specFactory, final Optional<BigInteger> chainId) {
final MainnetProtocolSpecFactory specFactory) {
final TreeMap<Long, BuilderMapEntry> builders =
Lists.newArrayList(
create(OptionalLong.of(0), specFactory.frontierDefinition()),
@ -223,6 +221,8 @@ public class ProtocolScheduleBuilder {
create(config.getIstanbulBlockNumber(), specFactory.istanbulDefinition()),
create(config.getMuirGlacierBlockNumber(), specFactory.muirGlacierDefinition()),
create(config.getBerlinBlockNumber(), specFactory.berlinDefinition()),
create(config.getAleutBlockNumber(), specFactory.aleutDefinition(config)),
create(config.getLondonBlockNumber(), specFactory.londonDefinition(config)),
// Classic Milestones
create(config.getEcip1015BlockNumber(), specFactory.tangerineWhistleDefinition()),
create(config.getDieHardBlockNumber(), specFactory.dieHardDefinition()),
@ -245,26 +245,6 @@ public class ProtocolScheduleBuilder {
(existing, replacement) -> replacement,
TreeMap::new));
if (ExperimentalEIPs.eip1559Enabled) {
final Optional<TransactionPriceCalculator> transactionPriceCalculator =
Optional.of(TransactionPriceCalculator.eip1559());
// if we do not have a 1559 block number, assume we are running pre-London config:
final long eip1559Block = config.getEIP1559BlockNumber().orElse(Long.MAX_VALUE);
builders.put(
eip1559Block,
new BuilderMapEntry(
eip1559Block,
MainnetProtocolSpecs.londonDefinition(
chainId,
transactionPriceCalculator,
config.getContractSizeLimit(),
config.getEvmStackSize(),
isRevertReasonEnabled,
config,
quorumCompatibilityMode),
protocolSpecAdapters.getModifierForBlock(eip1559Block)));
}
return builders;
}
@ -328,6 +308,7 @@ public class ProtocolScheduleBuilder {
lastForkBlock =
validateForkOrder("MuirGlacier", config.getMuirGlacierBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Berlin", config.getBerlinBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("London", config.getLondonBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}

@ -1,57 +0,0 @@
# Case 1 - https://gist.github.com/holiman/174548cad102096858583c6fbbb0649a#case-1
#
# This checks EXT(codehash,codesize,balance) of precompiles, which should be
# 100, and later checks the same operations twice against some non-precompiles.
# Those are cheaper second time they are accessed. Lastly, it checks the BALANCE
# of origin and this.
../../../build/install/evmtool/bin/evm \
--Xberlin-enabled=true \
--code=0x60013f5060023b506003315060f13f5060f23b5060f3315060f23f5060f33b5060f1315032315030315000 \
--sender=0x0000000000000000000000000000000000000000 \
--receiver=0x000000000000000000000000636F6E7472616374 \
--chain=YOLO_V3 \
--gas=9223372036854775807 \
--repeat=10
echo 'expect gasUser="0x21cd" (8653 dec)'
# Case 2 - https://gist.github.com/holiman/174548cad102096858583c6fbbb0649a#case-2
#
# This checks extcodecopy( 0xff,0,0,0,0) twice, (should be expensive first
# time), and then does extcodecopy( this,0,0,0,0)
../../../build/install/evmtool/bin/evm \
--Xberlin-enabled=true \
--code=0x60006000600060ff3c60006000600060ff3c600060006000303c00 \
--sender=0x0000000000000000000000000000000000000000 \
--receiver=0x000000000000000000000000636F6E7472616374 \
--chain=YOLO_V3 \
--gas=9223372036854775807 \
--repeat=10
echo 'expect gasUser="0xb13" (2835 dec)'
# Case 3 - https://gist.github.com/holiman/174548cad102096858583c6fbbb0649a#case-3
#
# This checks sload( 0x1) followed by sstore(loc: 0x01, val:0x11), then 'naked'
# sstore:sstore(loc: 0x02, val:0x11) twice, and sload(0x2), sload(0x1).
../../../build/install/evmtool/bin/evm \
--Xberlin-enabled=true \
--code=0x60015450601160015560116002556011600255600254600154 \
--sender=0x0000000000000000000000000000000000000000 \
--receiver=0x000000000000000000000000636F6E7472616374 \
--chain=YOLO_V3 \
--gas=9223372036854775807 \
--repeat=10
echo 'expect gasUser="0xadf1" (44529 dec)'
# Case 4 - https://gist.github.com/holiman/174548cad102096858583c6fbbb0649a#case-4
#
# This calls the identity-precompile (cheap), then calls an account (expensive)
# and staticcalls the same account (cheap)
../../../build/install/evmtool/bin/evm \
--Xberlin-enabled=true \
--code=0x60008080808060046000f15060008080808060ff6000f15060008080808060ff6000fa50 \
--sender=0x0000000000000000000000000000000000000000 \
--receiver=0x000000000000000000000000636F6E7472616374 \
--chain=YOLO_V3 \
--gas=9223372036854775807 \
--repeat=10
echo 'expect gasUser="0xb35" (2869 dec)'

@ -197,13 +197,6 @@ public class DiscoveryConfiguration {
.map(EnodeURL::fromString)
.collect(toList()));
public static final List<EnodeURL> YOLO_V3_BOOTSTRAP_NODES =
Collections.unmodifiableList(
Stream.of(
"enode://9e1096aa59862a6f164994cb5cb16f5124d6c992cdbf4535ff7dea43ea1512afe5448dca9df1b7ab0726129603f1a3336b631e4d7a1a44c94daddd03241587f9@3.9.20.133:30303")
.map(EnodeURL::fromString)
.collect(toList()));
public static final List<EnodeURL> ASTOR_BOOTSTRAP_NODES =
Collections.unmodifiableList(
Stream.of(

@ -63,7 +63,8 @@ public class ReferenceTestProtocolSchedules {
builder.put("Istanbul", createSchedule(new StubGenesisConfigOptions().istanbulBlock(0)));
builder.put("MuirGlacier", createSchedule(new StubGenesisConfigOptions().muirGlacierBlock(0)));
builder.put("Berlin", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
builder.put("YOLOv3", createSchedule(new StubGenesisConfigOptions().berlinBlock(0)));
builder.put("London", createSchedule(new StubGenesisConfigOptions().londonBlock(0)));
builder.put("Baikal", createSchedule(new StubGenesisConfigOptions().londonBlock(0)));
return new ReferenceTestProtocolSchedules(builder.build());
}

@ -137,6 +137,8 @@ public class TestSetChainParams implements JsonRpcMethod {
if (ExperimentalEIPs.eip1559Enabled) {
// TODO EIP-1559 change for the actual fork name when known
maybeMoveToNumber(params, "londonForkBlock", config, "aleutBlock");
maybeMoveToNumber(params, "londonForkBlock", config, "baikalBlock");
maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock");
ExperimentalEIPs.initialBasefee =
Optional.ofNullable(
chainParamsJson

Loading…
Cancel
Save