Skip to content

Commit

Permalink
Include ETC Mystique specification in 21.10.8 (#3283)
Browse files Browse the repository at this point in the history
* ETC Mystique hard fork (#3256)

* Add missing Magneto ETC hard fork entry in test
* Prepare version for release

Signed-off-by: Diego López León <[email protected]>
  • Loading branch information
diega authored Jan 17, 2022
1 parent 400df67 commit aa877ae
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 21.10.8

### Additions and Improvements
- Ethereum Classic Mystique Hard Fork [#3256](https://github.com/hyperledger/besu/pull/3256)

## 21.10.7

### Bug Fixes
Expand Down
15 changes: 9 additions & 6 deletions besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0x604f6ee1L), 999983L),
new ForkId(Bytes.ofUnsignedInt(0xf42f5539L), 2520000L),
new ForkId(Bytes.ofUnsignedInt(0x66b5c286L), 3985893),
new ForkId(Bytes.ofUnsignedInt(0x92b323e0L), 0),
new ForkId(Bytes.ofUnsignedInt(0x92b323e0L), 0))
new ForkId(Bytes.ofUnsignedInt(0x92b323e0L), 5520000L),
new ForkId(Bytes.ofUnsignedInt(0x8c9b1797L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x8c9b1797L), 0L))
},
new Object[] {
NetworkName.KOTTI,
Expand All @@ -130,8 +131,9 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0xa3270822L), 1705549L),
new ForkId(Bytes.ofUnsignedInt(0x8f3698e0L), 2200013L),
new ForkId(Bytes.ofUnsignedInt(0x6f402821L), 4368634),
new ForkId(Bytes.ofUnsignedInt(0xf03e54e7L), 0),
new ForkId(Bytes.ofUnsignedInt(0xf03e54e7L), 0))
new ForkId(Bytes.ofUnsignedInt(0xf03e54e7L), 5578000L),
new ForkId(Bytes.ofUnsignedInt(0xc5459816L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xc5459816L), 0L))
},
new Object[] {
NetworkName.CLASSIC,
Expand All @@ -148,8 +150,9 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0x7ba22882L), 10500839L),
new ForkId(Bytes.ofUnsignedInt(0x9007bfccL), 11700000L),
new ForkId(Bytes.ofUnsignedInt(0xdb63a1caL), 13189133),
new ForkId(Bytes.ofUnsignedInt(0x0f6bf187L), 0),
new ForkId(Bytes.ofUnsignedInt(0x0f6bf187L), 0))
new ForkId(Bytes.ofUnsignedInt(0x0f6bf187L), 14525000L),
new ForkId(Bytes.ofUnsignedInt(0x7fd1bb25L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x7fd1bb25L), 0L))
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ public interface GenesisConfigOptions {
*/
OptionalLong getMagnetoBlockNumber();

/**
* Block number to activate Mystique on Classic networks.
*
* @return block number of Mystique fork on Classic networks
* @see <a
* href="https://ecips.ethereumclassic.org/ECIPs/ecip-1104">https://ecips.ethereumclassic.org/ECIPs/ecip-1104</a>
*/
OptionalLong getMystiqueBlockNumber();

/**
* Block number to activate ECIP-1049 on Classic networks. Changes the hashing algorithm to
* keccak-256.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public OptionalLong getMagnetoBlockNumber() {
return getOptionalLong("magnetoblock");
}

@Override
public OptionalLong getMystiqueBlockNumber() {
return getOptionalLong("mystiqueblock");
}

@Override
public OptionalLong getEcip1049BlockNumber() {
return getOptionalLong("ecip1049block");
Expand Down Expand Up @@ -421,6 +426,7 @@ public Map<String, Object> asMap() {
getPhoenixBlockNumber().ifPresent(l -> builder.put("phoenixBlock", l));
getThanosBlockNumber().ifPresent(l -> builder.put("thanosBlock", l));
getMagnetoBlockNumber().ifPresent(l -> builder.put("magnetoBlock", l));
getMystiqueBlockNumber().ifPresent(l -> builder.put("mystiqueBlock", l));
getEcip1049BlockNumber().ifPresent(l -> builder.put("ecip1049Block", l));

getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
Expand Down Expand Up @@ -523,6 +529,7 @@ public List<Long> getForks() {
getPhoenixBlockNumber(),
getThanosBlockNumber(),
getMagnetoBlockNumber(),
getMystiqueBlockNumber(),
getEcip1049BlockNumber());
// when adding forks add an entry to ${REPO_ROOT}/config/src/test/resources/all_forks.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
private OptionalLong phoenixBlockNumber = OptionalLong.empty();
private OptionalLong thanosBlockNumber = OptionalLong.empty();
private OptionalLong magnetoBlockNumber = OptionalLong.empty();
private OptionalLong mystiqueBlockNumber = OptionalLong.empty();
private OptionalLong ecip1049BlockNumber = OptionalLong.empty();
private Optional<BigInteger> chainId = Optional.empty();
private OptionalInt contractSizeLimit = OptionalInt.empty();
Expand Down Expand Up @@ -253,6 +254,11 @@ public OptionalLong getMagnetoBlockNumber() {
return magnetoBlockNumber;
}

@Override
public OptionalLong getMystiqueBlockNumber() {
return mystiqueBlockNumber;
}

@Override
public OptionalLong getEcip1049BlockNumber() {
return ecip1049BlockNumber;
Expand Down Expand Up @@ -315,6 +321,7 @@ public Map<String, Object> asMap() {
getPhoenixBlockNumber().ifPresent(l -> builder.put("phoenixBlock", l));
getThanosBlockNumber().ifPresent(l -> builder.put("thanosBlock", l));
getMagnetoBlockNumber().ifPresent(l -> builder.put("magnetoBlock", l));
getMystiqueBlockNumber().ifPresent(l -> builder.put("mystiqueBlock", l));
getEcip1049BlockNumber().ifPresent(l -> builder.put("ecip1049Block", l));

getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
Expand Down Expand Up @@ -490,6 +497,11 @@ public StubGenesisConfigOptions magneto(final long blockNumber) {
return this;
}

public StubGenesisConfigOptions mystique(final long blockNumber) {
mystiqueBlockNumber = OptionalLong.of(blockNumber);
return this;
}

public StubGenesisConfigOptions ecip1049(final long blockNumber) {
ecip1049BlockNumber = OptionalLong.of(blockNumber);
return this;
Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"phoenixBlock": 10500839,
"thanosBlock": 11700000,
"magnetoBlock": 13189133,
"mystiqueBlock": 14525000,
"ethash": {

}
Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/kotti.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"aghartaBlock": 1705549,
"phoenixBlock": 2200013,
"magnetoBlock": 4368634,
"mystiqueBlock": 5578000,
"clique":{
"blockperiodseconds":15,
"epochlength":30000
Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/mordor.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ecip1017EraRounds": 2000000,
"thanosBlock": 2520000,
"magnetoBlock": 3985893,
"mystiqueBlock": 5520000,
"ethash": {}
},
"nonce": "0x0000000000000000",
Expand Down
2 changes: 2 additions & 0 deletions config/src/test/resources/all_forks.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"aghartaBlock": 107,
"phoenixBlock": 108,
"thanosBlock": 109,
"magnetoBlock": 110,
"mystiqueBlock": 111,
"ecip1049Block": 199
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ public void returnsClassicForkBlocks() {
.phoenix(8)
.thanos(9)
.magneto(10)
.ecip1049(11);
.ecip1049(11)
.mystique(12);

final AdminNodeInfo methodClassic =
new AdminNodeInfo(
Expand All @@ -397,6 +398,7 @@ public void returnsClassicForkBlocks() {
"thanosBlock", 9L,
"magnetoBlock", 10L));
expectedConfig.put("ecip1049Block", 11L);
expectedConfig.put("mystiqueBlock", 12L);

final JsonRpcResponse response = methodClassic.response(request);
assertThat(response).isInstanceOf(JsonRpcSuccessResponse.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.evm.MainnetEVMs;
import org.hyperledger.besu.evm.contractvalidation.MaxCodeSizeRule;
import org.hyperledger.besu.evm.contractvalidation.PrefixCodeRule;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator;
import org.hyperledger.besu.evm.gascalculator.DieHardGasCalculator;
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
Expand All @@ -39,6 +41,7 @@

import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
Expand Down Expand Up @@ -356,4 +359,34 @@ public static ProtocolSpecBuilder magnetoDefinition(
: MainnetProtocolSpecs::berlinTransactionReceiptFactory)
.name("Magneto");
}

public static ProtocolSpecBuilder mystiqueDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit =
configContractSizeLimit.orElse(MainnetProtocolSpecs.SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
return magnetoDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(LondonGasCalculator::new)
.contractCreationProcessorBuilder(
(gasCalculator, evm) ->
new ContractCreationProcessor(
gasCalculator,
evm,
true,
List.of(MaxCodeSizeRule.of(contractSizeLimit), PrefixCodeRule.of()),
1))
.name("Mystique");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ public ProtocolSpecBuilder magnetoDefinition() {
evmConfiguration);
}

public ProtocolSpecBuilder mystiqueDefinition() {
return ClassicProtocolSpecs.mystiqueDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode,
evmConfiguration);
}

public ProtocolSpecBuilder ecip1049Definition() {
return ClassicProtocolSpecs.ecip1049Definition(
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private TreeMap<Long, BuilderMapEntry> buildMilestoneMap(
create(config.getPhoenixBlockNumber(), specFactory.phoenixDefinition()),
create(config.getThanosBlockNumber(), specFactory.thanosDefinition()),
create(config.getMagnetoBlockNumber(), specFactory.magnetoDefinition()),
create(config.getMystiqueBlockNumber(), specFactory.mystiqueDefinition()),
create(config.getEcip1049BlockNumber(), specFactory.ecip1049Definition()))
.stream()
.filter(Optional::isPresent)
Expand Down Expand Up @@ -343,6 +344,7 @@ private void validateClassicForkOrdering() {
lastForkBlock = validateForkOrder("Phoenix", config.getPhoenixBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Thanos", config.getThanosBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Magneto", config.getMagnetoBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Mystique", config.getMystiqueBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public class DiscoveryConfiguration {
Stream.of(
// ETC Cooperative
"enode://8e73168affd8d445edda09c561d607081ca5d7963317caae2702f701eb6546b06948b7f8687a795de576f6a5f33c44828e25a90aa63de18db380a11e660dd06f@159.203.37.80:30303",
"enode://1d9aef3350a712ca90cabdf7b94a6f29e7df390c083d39d739c58cdba8708c4fbeb7784e2c8ae7a9086141e31c7df193c5a247d40264d040e6ac02d316c2fcfb@67.207.93.100:30303",
"enode://506e4f07e736a6415aac813d5f2365f6359a9877844b02799819d185571908188c8ddd855897c814583f5f36f30e5cb76472e13108e6ecb0fc1901d71f0df8e2@128.199.160.131:30303",
"enode://2b1ef75e8b7119b6e0294f2e51ead2cf1a5400472452c199e9587727ada99e7e2b1199e36adcad6cbae65dce2410559546e4d83d8c93d45a559e723e56444c03@67.207.93.100:30303",
"enode://40b37d729fdc2c29620bbecc61264f450c3e849b5e60d1a362e6af04d84ae36e15120573498bcf56f97aeec18e530113a4d0b55b18e6a6523de8cf5a45e1db23@128.199.160.131:30303",
"enode://84e70a981a436efd7d6ae80b5d7ecb82636de77029635a2fb25ccf5d02106172d1cafdd7d8171a136d3fd545e5df94f4d63299eda7f8aec79967aa568ddaa71e@165.22.202.207:30303",
"enode://6ec7ac618a7147d8b0e41bc1e63080abfd56a48f50f06095c112e30f72cd5eee262b06aa168cb46ab470d56885f842a1ae44a3714bfb029ced83dab461852062@164.90.218.200:30303",
"enode://feba6c4bd757efce4fec0fa5775780d2c209e86231553a72738c2c4e95d0cfd7ac2189f6d30d3c059dd25d93ea060ca28f9936b564f7d04c4270bb60e8e1487b@178.128.171.230:30303",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=21.10.8-SNAPSHOT
version=21.10.8

# Workaround for Java 16 and spotless bug 834 https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
Expand Down

0 comments on commit aa877ae

Please sign in to comment.