Feature/arrow glacier (#2978)

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/2979/head
garyschulte 3 years ago committed by GitHub
parent 65cb5f6a9c
commit 93b556aa9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      CHANGELOG.md
  2. 7
      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. 1
      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. 5
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  13. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
  14. 14
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/ForkIdTestUtil.java
  15. 60
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EIP2124Test.java
  16. 3
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  17. 3
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java

@ -19,6 +19,30 @@
### Early Access Features
- Enable plugins to expose custom JSON-RPC / WebSocket methods [#1317](https://github.com/hyperledger/besu/issues/1317)
## 21.10.0-RC5
### Additions and Improvements
### Bug Fixes
- add support for ArrowGlacier hardfork [#2943](https://github.com/hyperledger/besu/issues/2943)
### Early Access Features
### Download Link
## 21.10.0-RC4
### Additions and Improvements
### Bug Fixes
- Fixes the exit condition for loading a BonsaiPersistedWorldState for a sibling block of the last one persisted [#2967](https://github.com/hyperledger/besu/pull/2967)
- Fixes bonsai getMutable regression affecting fast-sync [#2934](https://github.com/hyperledger/besu/pull/2934)
### Early Access Features
### Download Link
https://hyperledger.jfrog.io/native/besu-binaries/besu/21.10.0-RC4/besu-21.10.0-RC4.zip \
SHA256: b16e15764b8bc06c5c3f9f19bc8b99fa48e7894aa5a6ccdad65da49bbf564793
## 21.10.0-RC3
### Bug Fixes

@ -108,9 +108,10 @@ public class ForkIdsTest {
new ForkId(Bytes.ofUnsignedInt(0x668db0afL), 9069000L),
new ForkId(Bytes.ofUnsignedInt(0x879d6e30L), 9200000L),
new ForkId(Bytes.ofUnsignedInt(0xe029e991L), 12244000L),
new ForkId(Bytes.ofUnsignedInt(0xeb440f6L), 12965000),
new ForkId(Bytes.ofUnsignedInt(0xb715077dL), 0L),
new ForkId(Bytes.ofUnsignedInt(0xb715077dL), 0L))
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 Object[] {
NetworkName.MORDOR,

@ -73,6 +73,8 @@ public interface GenesisConfigOptions {
OptionalLong getLondonBlockNumber();
OptionalLong getArrowGlacierBlockNumber();
OptionalLong getBaseFeePerGas();
Optional<UInt256> getTerminalTotalDifficulty();

@ -256,6 +256,11 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
return getOptionalLong("londonblock");
}
@Override
public OptionalLong getArrowGlacierBlockNumber() {
return getOptionalLong("arrowglacierblock");
}
@Override
public OptionalLong getBaseFeePerGas() {
return Optional.ofNullable(configOverrides.get("baseFeePerGas"))
@ -395,6 +400,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getMuirGlacierBlockNumber().ifPresent(l -> builder.put("muirGlacierBlock", l));
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
// classic fork blocks
getClassicForkBlock().ifPresent(l -> builder.put("classicForkBlock", l));
@ -499,6 +505,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getMuirGlacierBlockNumber(),
getBerlinBlockNumber(),
getLondonBlockNumber(),
getArrowGlacierBlockNumber(),
getEcip1015BlockNumber(),
getDieHardBlockNumber(),
getGothamBlockNumber(),

@ -38,6 +38,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong muirGlacierBlockNumber = OptionalLong.empty();
private OptionalLong berlinBlockNumber = OptionalLong.empty();
private OptionalLong londonBlockNumber = OptionalLong.empty();
private OptionalLong arrowGlacierBlockNumber = OptionalLong.empty();
private Optional<UInt256> terminalTotalDifficulty = Optional.empty();
private OptionalLong baseFeePerGas = OptionalLong.empty();
@ -181,6 +182,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return londonBlockNumber;
}
@Override
public OptionalLong getArrowGlacierBlockNumber() {
return arrowGlacierBlockNumber;
}
@Override
public OptionalLong getBaseFeePerGas() {
return baseFeePerGas;
@ -291,6 +297,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
getMuirGlacierBlockNumber().ifPresent(l -> builder.put("muirGlacierBlock", l));
getBerlinBlockNumber().ifPresent(l -> builder.put("berlinBlock", l));
getLondonBlockNumber().ifPresent(l -> builder.put("londonBlock", l));
getArrowGlacierBlockNumber().ifPresent(l -> builder.put("arrowGlacierBlock", l));
// classic fork blocks
getClassicForkBlock().ifPresent(l -> builder.put("classicForkBlock", l));
getEcip1015BlockNumber().ifPresent(l -> builder.put("ecip1015Block", l));
@ -411,6 +418,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
return this;
}
public StubGenesisConfigOptions arrowGlacierBlock(final long blockNumber) {
arrowGlacierBlockNumber = OptionalLong.of(blockNumber);
return this;
}
public StubGenesisConfigOptions terminalTotalDifficulty(
final UInt256 updatedTerminalTotalDifficulty) {
terminalTotalDifficulty = Optional.of(updatedTerminalTotalDifficulty);

@ -11,6 +11,7 @@
"muirGlacierBlock": 9200000,
"berlinBlock": 12244000,
"londonBlock": 12965000,
"arrowGlacierBlock": 13773000,
"ethash": {
}
},

@ -185,6 +185,12 @@ public class GenesisConfigOptionsTest {
assertThat(config.getLondonBlockNumber()).hasValue(1000);
}
@Test
public void shouldGetArrowGlacierBlockNumber() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("arrowGlacierBlock", 1000));
assertThat(config.getArrowGlacierBlockNumber()).hasValue(1000);
}
@Test
// TODO ECIP-1049 change for the actual fork name when known
public void shouldGetECIP1049BlockNumber() {
@ -206,6 +212,7 @@ public class GenesisConfigOptionsTest {
assertThat(config.getMuirGlacierBlockNumber()).isEmpty();
assertThat(config.getBerlinBlockNumber()).isEmpty();
assertThat(config.getLondonBlockNumber()).isEmpty();
assertThat(config.getArrowGlacierBlockNumber()).isEmpty();
assertThat(config.getEcip1049BlockNumber()).isEmpty();
}

@ -11,6 +11,7 @@
"muirGlacierBlock": 9,
"berlinBlock": 10,
"londonBlock": 11,
"arrowGlacierBlock": 12,
"ecip1015Block": 102,
"dieHardBlock": 103,
"gothamBlock": 104,

@ -40,6 +40,7 @@ public abstract class MainnetDifficultyCalculators {
private static final long CONSTANTINOPLE_FAKE_BLOCK_OFFSET = 4_999_999L;
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 MainnetDifficultyCalculators() {}
@ -88,6 +89,11 @@ public abstract class MainnetDifficultyCalculators {
(time, parent, protocolContext) ->
calculateThawedDifficulty(time, parent, LONDON_FAKE_BLOCK_OFFSET);
// As per https://eips.ethereum.org/EIPS/eip-4345
static DifficultyCalculator ARROW_GLACIER =
(time, parent, protocolContext) ->
calculateThawedDifficulty(time, parent, ARROW_GLACIER_FAKE_BLOCK_OFFSET);
private static BigInteger calculateThawedDifficulty(
final long time, final BlockHeader parent, final long fakeBlockOffset) {
final BigInteger parentDifficulty = difficulty(parent.getDifficulty());

@ -150,6 +150,18 @@ public class MainnetProtocolSpecFactory {
evmConfiguration);
}
public ProtocolSpecBuilder arrowGlacierDefinition(
final GenesisConfigOptions genesisConfigOptions) {
return MainnetProtocolSpecs.arrowGlacierDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
genesisConfigOptions,
quorumCompatibilityMode,
evmConfiguration);
}
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
// Classic Protocol Specs

@ -569,6 +569,26 @@ public abstract class MainnetProtocolSpecs {
.name(LONDON_FORK_NAME);
}
static ProtocolSpecBuilder arrowGlacierDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return londonDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
genesisConfigOptions,
quorumCompatibilityMode,
evmConfiguration)
.difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER)
.name("ArrowGlacier");
}
private static TransactionReceipt frontierTransactionReceiptFactory(
// ignored because it's always FRONTIER
final TransactionType __,

@ -232,6 +232,9 @@ public class ProtocolScheduleBuilder {
create(config.getMuirGlacierBlockNumber(), specFactory.muirGlacierDefinition()),
create(config.getBerlinBlockNumber(), specFactory.berlinDefinition()),
create(config.getLondonBlockNumber(), specFactory.londonDefinition(config)),
create(
config.getArrowGlacierBlockNumber(),
specFactory.arrowGlacierDefinition(config)),
// Classic Milestones
create(config.getEcip1015BlockNumber(), specFactory.tangerineWhistleDefinition()),
create(config.getDieHardBlockNumber(), specFactory.dieHardDefinition()),
@ -319,6 +322,8 @@ public class ProtocolScheduleBuilder {
validateForkOrder("MuirGlacier", config.getMuirGlacierBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Berlin", config.getBerlinBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("London", config.getLondonBlockNumber(), lastForkBlock);
lastForkBlock =
validateForkOrder("ArrowGlacier", config.getArrowGlacierBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}

@ -47,7 +47,9 @@ public class MainnetProtocolScheduleTest {
Assertions.assertThat(sched.getByBlockNumber(9_200_000L).getName()).isEqualTo("MuirGlacier");
Assertions.assertThat(sched.getByBlockNumber(12_244_000L).getName()).isEqualTo("Berlin");
Assertions.assertThat(sched.getByBlockNumber(12_965_000L).getName()).isEqualTo("London");
Assertions.assertThat(sched.getByBlockNumber(Long.MAX_VALUE).getName()).isEqualTo("London");
Assertions.assertThat(sched.getByBlockNumber(13_773_000L).getName()).isEqualTo("ArrowGlacier");
Assertions.assertThat(sched.getByBlockNumber(Long.MAX_VALUE).getName())
.isEqualTo("ArrowGlacier");
}
@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);
9069000L, 9200000L, 12244000L, 12965000L, 13773000L);
public static final List<Long> ROPSTEN =
Arrays.asList(0L, 0L, 10L, 1700000L, 4230000L, 4939394L, 6485846L, 7117117L);
public static final List<Long> RINKEBY =
@ -76,15 +76,19 @@ public class ForkIdTestUtil {
public static class ForkIds {
public static final List<ForkId> MAINNET =
Arrays.asList(
new ForkId(Bytes.fromHexString("0xfc64ec04"), 1150000L), // Unsynced
new ForkId(
Bytes.fromHexString("0xfc64ec04"), 1150000L), // Unsynced / last Frontier block
new ForkId(Bytes.fromHexString("0x97c2c34c"), 1920000L), // First Homestead block
new ForkId(Bytes.fromHexString("0x91d1f948"), 2463000L), // First DAO block
new ForkId(Bytes.fromHexString("0x7a64da13"), 2675000L), // First Tangerine block
new ForkId(Bytes.fromHexString("0x3edd5b10"), 4370000L), // First Spurious block
new ForkId(Bytes.fromHexString("0xa00bc324"), 7280000L), // First Byzantium block
new ForkId(Bytes.fromHexString("0x668db0af"), 9069000L),
new ForkId(Bytes.fromHexString("0x879d6e30"), 9200000L),
new ForkId(Bytes.fromHexString("0xe029e991"), 0L));
new ForkId(Bytes.fromHexString("0x668db0af"), 9069000L), // First Petersburg block
new ForkId(Bytes.fromHexString("0x879d6e30"), 9200000L), // First Istanbul block
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
public static final List<ForkId> ROPSTEN =
Arrays.asList(
new ForkId(Bytes.fromHexString("0x30c7ddbc"), 10L),

@ -153,7 +153,7 @@ public class EIP2124Test {
empty()
},
{
"Mainnet // First Istanbul and first Muir Glacier block",
"Mainnet // First Istanbul block",
Network.MAINNET,
9069000L,
ForkIdTestUtil.wantForkId("0x879d6e30", 9200000L),
@ -161,7 +161,7 @@ public class EIP2124Test {
empty()
},
{
"Mainnet // Last Istanbul and first Muir Glacier block",
"Mainnet // Last Istanbul block",
Network.MAINNET,
9199999L,
ForkIdTestUtil.wantForkId("0x879d6e30", 9200000L),
@ -172,15 +172,63 @@ public class EIP2124Test {
"Mainnet // First Muir Glacier block",
Network.MAINNET,
9200000L,
ForkIdTestUtil.wantForkId("0xe029e991", 0L),
ForkIdTestUtil.wantForkId("0xe029e991", 12244000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Future Muir Glacier block",
"Mainnet // Last Muir Glacier block",
Network.MAINNET,
10000000L,
ForkIdTestUtil.wantForkId("0xe029e991", 0L),
12243999L,
ForkIdTestUtil.wantForkId("0xe029e991", 12244000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // First Berlin block",
Network.MAINNET,
12244000L,
ForkIdTestUtil.wantForkId("0x0eb440f6", 12965000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Last Berlin block",
Network.MAINNET,
12964999L,
ForkIdTestUtil.wantForkId("0x0eb440f6", 12965000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // First London block",
Network.MAINNET,
12965000L,
ForkIdTestUtil.wantForkId("0xb715077d", 13773000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Last London block",
Network.MAINNET,
13772999L,
ForkIdTestUtil.wantForkId("0xb715077d", 13773000L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // First Arrow Glacier block",
Network.MAINNET,
13773000L,
ForkIdTestUtil.wantForkId("0x20c327fc", 0L),
Optional.of(ForkIds.MAINNET),
empty()
},
{
"Mainnet // Future Arrow Glacier block",
Network.MAINNET,
20000000L,
ForkIdTestUtil.wantForkId("0x20c327fc", 0L),
Optional.of(ForkIds.MAINNET),
empty()
},

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

@ -122,6 +122,8 @@ public class TestSetChainParams implements JsonRpcMethod {
maybeMoveToNumber(params, "istanbulForkBlock", config, "istanbulBlock");
maybeMoveToNumber(params, "muirGlacierForkBlock", config, "muirGlacierBlock");
maybeMoveToNumber(params, "berlinForkBlock", config, "berlinBlock");
maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock");
maybeMoveToNumber(params, "muirGlacierForkBlock", config, "muirGlacierBlock");
maybeMoveToNumber(params, "chainID", config, "chainId", 1);
maybeMove(genesis, "author", chainParamsJson, "coinbase");
@ -133,7 +135,6 @@ public class TestSetChainParams implements JsonRpcMethod {
maybeMove(genesis, "timestamp", chainParamsJson, "timestamp");
maybeMove(chainParamsJson, "accounts", chainParamsJson, "alloc");
maybeMove(genesis, "baseFeePerGas", chainParamsJson, "baseFeePerGas");
maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock");
// strip out precompiles with zero balance
final JsonObject alloc = chainParamsJson.getJsonObject("alloc");

Loading…
Cancel
Save