Gray glacier hard fork (#3962)

* preparation for the gray glacier hard fork

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
pull/3967/head
Daniel Lehrner 2 years ago committed by GitHub
parent e1d0a3d601
commit 4996a8731a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java
  3. 2
      config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java
  4. 7
      config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java
  5. 12
      config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java
  6. 1
      config/src/main/resources/mainnet.json
  7. 7
      config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java
  8. 3
      config/src/test/resources/all_forks.json
  9. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetDifficultyCalculators.java
  10. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
  11. 20
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  12. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  13. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
  14. 5
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdTestUtil.java
  15. 14
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java
  16. 1
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  17. 1
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java

@ -6,6 +6,7 @@
- \[EXPERIMENTAL\] Add checkpoint sync `--sync-mode="X_CHECKPOINT"` [#3849](https://github.com/hyperledger/besu/pull/3849)
- Support `finalized` and `safe` as tags for the block parameter in RPC APIs [#3950](https://github.com/hyperledger/besu/pull/3950)
- Added verification of payload attributes in ForkchoiceUpdated [#3837](https://github.com/hyperledger/besu/pull/3837)
- Add support for Gray Glacier hardfork [#3961](https://github.com/hyperledger/besu/issues/3961)
### Bug Fixes
- alias engine-rpc-port parameter with the former rpc param name [#3958](https://github.com/hyperledger/besu/pull/3958)

@ -110,8 +110,9 @@ public class ForkIdsTest {
new ForkId(Bytes.ofUnsignedInt(0xe029e991L), 12244000L),
new ForkId(Bytes.ofUnsignedInt(0xeb440f6L), 12965000L),
new ForkId(Bytes.ofUnsignedInt(0xb715077dL), 13773000L),
new ForkId(Bytes.ofUnsignedInt(0x20c327fc), 0L),
new ForkId(Bytes.ofUnsignedInt(0x20c327fc), 0L))
new ForkId(Bytes.ofUnsignedInt(0x20c327fcL), 15050000L),
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 0L))
},
new Object[] {
NetworkName.MORDOR,

@ -86,6 +86,8 @@ public interface GenesisConfigOptions {
OptionalLong getArrowGlacierBlockNumber();
OptionalLong getGrayGlacierBlockNumber();
OptionalLong getParisBlockNumber();
Optional<Wei> getBaseFeePerGas();

@ -275,6 +275,11 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
return getOptionalLong("arrowglacierblock");
}
@Override
public OptionalLong getGrayGlacierBlockNumber() {
return getOptionalLong("grayglacierblock");
}
@Override
public OptionalLong getParisBlockNumber() {
var parisBlock = getOptionalLong("parisblock");
@ -441,6 +446,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
getGrayGlacierBlockNumber().ifPresent(l -> builder.put("grayGlacierBlock", l));
getParisBlockNumber().ifPresent(l -> builder.put("parisBlock", l));
getTerminalBlockNumber().ifPresent(l -> builder.put("terminalBlockNumber", l));
getTerminalBlockHash().ifPresent(h -> builder.put("terminalBlockHash", h.toHexString()));
@ -559,6 +565,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getBerlinBlockNumber(),
getLondonBlockNumber(),
getArrowGlacierBlockNumber(),
getGrayGlacierBlockNumber(),
getParisBlockNumber(),
getTerminalBlockNumber(),
getEcip1015BlockNumber(),

@ -42,6 +42,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong berlinBlockNumber = OptionalLong.empty();
private OptionalLong londonBlockNumber = OptionalLong.empty();
private OptionalLong arrowGlacierBlockNumber = OptionalLong.empty();
private OptionalLong grayGlacierBlockNumber = OptionalLong.empty();
private OptionalLong parisBlockNumber = OptionalLong.empty();
private OptionalLong terminalBlockNumber = OptionalLong.empty();
private Optional<Hash> terminalBlockHash = Optional.empty();
@ -205,6 +206,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return arrowGlacierBlockNumber;
}
@Override
public OptionalLong getGrayGlacierBlockNumber() {
return grayGlacierBlockNumber;
}
@Override
public OptionalLong getParisBlockNumber() {
return parisBlockNumber;
@ -336,6 +342,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
getGrayGlacierBlockNumber().ifPresent(l -> builder.put("grayGlacierBlock", l));
getParisBlockNumber().ifPresent(l -> builder.put("parisBlock", l));
getTerminalBlockNumber().ifPresent(l -> builder.put("terminalBlockNumber", l));
getTerminalBlockHash().ifPresent(h -> builder.put("terminalBlockHash", h));
@ -465,6 +472,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return this;
}
public StubGenesisConfigOptions grayGlacierBlock(final long blockNumber) {
grayGlacierBlockNumber = OptionalLong.of(blockNumber);
return this;
}
public StubGenesisConfigOptions parisBlock(final long blockNumber) {
parisBlockNumber = OptionalLong.of(blockNumber);
return this;

@ -12,6 +12,7 @@
"berlinBlock": 12244000,
"londonBlock": 12965000,
"arrowGlacierBlock": 13773000,
"grayGlacierBlock": 15050000,
"ethash": {
},
"discovery": {

@ -191,6 +191,12 @@ public class GenesisConfigOptionsTest {
assertThat(config.getArrowGlacierBlockNumber()).hasValue(1000);
}
@Test
public void shouldGetGrayGlacierBlockNumber() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("grayGlacierBlock", 4242));
assertThat(config.getGrayGlacierBlockNumber()).hasValue(4242);
}
@Test
// TODO ECIP-1049 change for the actual fork name when known
public void shouldGetECIP1049BlockNumber() {
@ -213,6 +219,7 @@ public class GenesisConfigOptionsTest {
assertThat(config.getBerlinBlockNumber()).isEmpty();
assertThat(config.getLondonBlockNumber()).isEmpty();
assertThat(config.getArrowGlacierBlockNumber()).isEmpty();
assertThat(config.getGrayGlacierBlockNumber()).isEmpty();
assertThat(config.getEcip1049BlockNumber()).isEmpty();
}

@ -12,7 +12,8 @@
"berlinBlock": 10,
"londonBlock": 11,
"arrowGlacierBlock": 12,
"parisBlock": 13,
"grayGlacierBlock": 13,
"parisBlock": 14,
"ecip1015Block": 102,
"dieHardBlock": 103,
"gothamBlock": 104,

@ -41,6 +41,7 @@ public abstract class MainnetDifficultyCalculators {
private static final long MUIR_GLACIER_FAKE_BLOCK_OFFSET = 8_999_999L;
private static final long LONDON_FAKE_BLOCK_OFFSET = 9_699_999L;
private static final long ARROW_GLACIER_FAKE_BLOCK_OFFSET = 10_699_999L;
private static final long GRAY_GLACIER_FAKE_BLOCK_OFFSET = 11_399_999L;
private MainnetDifficultyCalculators() {}
@ -94,6 +95,11 @@ public abstract class MainnetDifficultyCalculators {
(time, parent, protocolContext) ->
calculateThawedDifficulty(time, parent, ARROW_GLACIER_FAKE_BLOCK_OFFSET);
// As per https://eips.ethereum.org/EIPS/eip-5133
static DifficultyCalculator GRAY_GLACIER =
(time, parent, protocolContext) ->
calculateThawedDifficulty(time, parent, GRAY_GLACIER_FAKE_BLOCK_OFFSET);
private static BigInteger calculateThawedDifficulty(
final long time, final BlockHeader parent, final long fakeBlockOffset) {
final BigInteger parentDifficulty = difficulty(parent.getDifficulty());

@ -162,6 +162,18 @@ public class MainnetProtocolSpecFactory {
evmConfiguration);
}
public ProtocolSpecBuilder grayGlacierDefinition(
final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.grayGlacierDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
genesisConfigOptions,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.parisDefinition(
chainId,

@ -589,6 +589,26 @@ public abstract class MainnetProtocolSpecs {
.name("ArrowGlacier");
}
static ProtocolSpecBuilder grayGlacierDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return arrowGlacierDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
genesisConfigOptions,
quorumCompatibilityMode,
evmConfiguration)
.difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER)
.name("GrayGlacier");
}
static ProtocolSpecBuilder parisDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,

@ -231,6 +231,8 @@ public class ProtocolScheduleBuilder {
create(
config.getArrowGlacierBlockNumber(),
specFactory.arrowGlacierDefinition(config)),
create(
config.getGrayGlacierBlockNumber(), specFactory.grayGlacierDefinition(config)),
create(config.getParisBlockNumber(), specFactory.parisDefinition(config)),
// Classic Milestones
create(config.getEcip1015BlockNumber(), specFactory.tangerineWhistleDefinition()),
@ -322,6 +324,8 @@ public class ProtocolScheduleBuilder {
lastForkBlock = validateForkOrder("London", config.getLondonBlockNumber(), lastForkBlock);
lastForkBlock =
validateForkOrder("ArrowGlacier", config.getArrowGlacierBlockNumber(), lastForkBlock);
lastForkBlock =
validateForkOrder("GrayGlacier", config.getGrayGlacierBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}

@ -48,8 +48,9 @@ public class MainnetProtocolScheduleTest {
Assertions.assertThat(sched.getByBlockNumber(12_244_000L).getName()).isEqualTo("Berlin");
Assertions.assertThat(sched.getByBlockNumber(12_965_000L).getName()).isEqualTo("London");
Assertions.assertThat(sched.getByBlockNumber(13_773_000L).getName()).isEqualTo("ArrowGlacier");
Assertions.assertThat(sched.getByBlockNumber(15_050_000L).getName()).isEqualTo("GrayGlacier");
Assertions.assertThat(sched.getByBlockNumber(Long.MAX_VALUE).getName())
.isEqualTo("ArrowGlacier");
.isEqualTo("GrayGlacier");
}
@Test

@ -64,7 +64,7 @@ public class ForkIdTestUtil {
public static final List<Long> MAINNET =
Arrays.asList(
1920000L, 1150000L, 2463000L, 2675000L, 2675000L, 4370000L, 7280000L, 7280000L,
9069000L, 9200000L, 12244000L, 12965000L, 13773000L);
9069000L, 9200000L, 12244000L, 12965000L, 13773000L, 15050000L);
public static final List<Long> ROPSTEN =
Arrays.asList(0L, 0L, 10L, 1700000L, 4230000L, 4939394L, 6485846L, 7117117L);
public static final List<Long> RINKEBY =
@ -88,7 +88,8 @@ public class ForkIdTestUtil {
new ForkId(Bytes.fromHexString("0xe029e991"), 12244000L), // First Muir Glacier block
new ForkId(Bytes.fromHexString("0x0eb440f6"), 12965000L), // First Berlin block
new ForkId(Bytes.fromHexString("0xb715077d"), 13773000L), // First London block
new ForkId(Bytes.fromHexString("0x20c327fc"), 0L)); // First Arrow Glacier block
new ForkId(Bytes.fromHexString("0x20c327fc"), 15050000L), // First Arrow Glacier block
new ForkId(Bytes.fromHexString("0xf0afd0e3"), 0L)); // First Gray Glacier block
public static final List<ForkId> ROPSTEN =
Arrays.asList(
new ForkId(Bytes.fromHexString("0x30c7ddbc"), 10L),

@ -220,15 +220,23 @@ public class EIP2124Test {
"Mainnet // First Arrow Glacier block",
Network.MAINNET,
13773000L,
ForkIdTestUtil.wantForkId("0x20c327fc", 0L),
ForkIdTestUtil.wantForkId("0x20c327fc", 15050000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Future Arrow Glacier block",
"Mainnet // First Gray Glacier block",
Network.MAINNET,
15050000L,
ForkIdTestUtil.wantForkId("0xf0afd0e3", 0L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Future Gray Glacier block",
Network.MAINNET,
20000000L,
ForkIdTestUtil.wantForkId("0x20c327fc", 0L),
ForkIdTestUtil.wantForkId("0xf0afd0e3", 0L),
Optional.of(ForkIds.MAINNET),
empty()
},

@ -67,6 +67,7 @@ public class ReferenceTestProtocolSchedules {
builder.put("London", createSchedule(new StubGenesisConfigOptions().londonBlock(0)));
builder.put(
"ArrowGlacier", createSchedule(new StubGenesisConfigOptions().arrowGlacierBlock(0)));
builder.put("GrayGlacier", createSchedule(new StubGenesisConfigOptions().grayGlacierBlock(0)));
return new ReferenceTestProtocolSchedules(builder.build());
}

@ -124,6 +124,7 @@ public class TestSetChainParams implements JsonRpcMethod {
maybeMoveToNumber(params, "berlinForkBlock", config, "berlinBlock");
maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock");
maybeMoveToNumber(params, "arrowGlacierForkBlock", config, "arrowGlacierBlock");
maybeMoveToNumber(params, "grayGlacierForkBlock", config, "grayGlacierBlock");
maybeMoveToNumber(params, "chainID", config, "chainId", 1);
maybeMove(genesis, "author", chainParamsJson, "coinbase");

Loading…
Cancel
Save