diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa4a66d3b9..d2f79959af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java index aba0dd6841a..0c985311593 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java @@ -120,8 +120,9 @@ public static Collection 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, @@ -130,8 +131,9 @@ public static Collection 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, @@ -148,8 +150,9 @@ public static Collection 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)) }); } diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java index 59ff28b8627..005879b5511 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java @@ -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 https://ecips.ethereumclassic.org/ECIPs/ecip-1104 + */ + OptionalLong getMystiqueBlockNumber(); + /** * Block number to activate ECIP-1049 on Classic networks. Changes the hashing algorithm to * keccak-256. diff --git a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java index fa0e3939d5a..fb7f8651d39 100644 --- a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java @@ -332,6 +332,11 @@ public OptionalLong getMagnetoBlockNumber() { return getOptionalLong("magnetoblock"); } + @Override + public OptionalLong getMystiqueBlockNumber() { + return getOptionalLong("mystiqueblock"); + } + @Override public OptionalLong getEcip1049BlockNumber() { return getOptionalLong("ecip1049block"); @@ -421,6 +426,7 @@ public Map 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)); @@ -523,6 +529,7 @@ public List getForks() { getPhoenixBlockNumber(), getThanosBlockNumber(), getMagnetoBlockNumber(), + getMystiqueBlockNumber(), getEcip1049BlockNumber()); // when adding forks add an entry to ${REPO_ROOT}/config/src/test/resources/all_forks.json diff --git a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java index 39797401e87..7d7ebb52d31 100644 --- a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java @@ -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 chainId = Optional.empty(); private OptionalInt contractSizeLimit = OptionalInt.empty(); @@ -253,6 +254,11 @@ public OptionalLong getMagnetoBlockNumber() { return magnetoBlockNumber; } + @Override + public OptionalLong getMystiqueBlockNumber() { + return mystiqueBlockNumber; + } + @Override public OptionalLong getEcip1049BlockNumber() { return ecip1049BlockNumber; @@ -315,6 +321,7 @@ public Map 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)); @@ -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; diff --git a/config/src/main/resources/classic.json b/config/src/main/resources/classic.json index 1063ef04d0a..b0e767561f6 100644 --- a/config/src/main/resources/classic.json +++ b/config/src/main/resources/classic.json @@ -12,6 +12,7 @@ "phoenixBlock": 10500839, "thanosBlock": 11700000, "magnetoBlock": 13189133, + "mystiqueBlock": 14525000, "ethash": { } diff --git a/config/src/main/resources/kotti.json b/config/src/main/resources/kotti.json index 2f1725b12a6..5fc589d4ac0 100644 --- a/config/src/main/resources/kotti.json +++ b/config/src/main/resources/kotti.json @@ -6,6 +6,7 @@ "aghartaBlock": 1705549, "phoenixBlock": 2200013, "magnetoBlock": 4368634, + "mystiqueBlock": 5578000, "clique":{ "blockperiodseconds":15, "epochlength":30000 diff --git a/config/src/main/resources/mordor.json b/config/src/main/resources/mordor.json index 15311cc5f69..69826dc5373 100644 --- a/config/src/main/resources/mordor.json +++ b/config/src/main/resources/mordor.json @@ -7,6 +7,7 @@ "ecip1017EraRounds": 2000000, "thanosBlock": 2520000, "magnetoBlock": 3985893, + "mystiqueBlock": 5520000, "ethash": {} }, "nonce": "0x0000000000000000", diff --git a/config/src/test/resources/all_forks.json b/config/src/test/resources/all_forks.json index 27ae1390263..3931ae0accb 100644 --- a/config/src/test/resources/all_forks.json +++ b/config/src/test/resources/all_forks.json @@ -20,6 +20,8 @@ "aghartaBlock": 107, "phoenixBlock": 108, "thanosBlock": 109, + "magnetoBlock": 110, + "mystiqueBlock": 111, "ecip1049Block": 199 } } \ No newline at end of file diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfoTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfoTest.java index bd93c3d9259..e9ad7c78a74 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfoTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfoTest.java @@ -370,7 +370,8 @@ public void returnsClassicForkBlocks() { .phoenix(8) .thanos(9) .magneto(10) - .ecip1049(11); + .ecip1049(11) + .mystique(12); final AdminNodeInfo methodClassic = new AdminNodeInfo( @@ -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); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java index 2c9cba6925a..8ab18a7a24e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java @@ -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; @@ -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; @@ -356,4 +359,34 @@ public static ProtocolSpecBuilder magnetoDefinition( : MainnetProtocolSpecs::berlinTransactionReceiptFactory) .name("Magneto"); } + + public static ProtocolSpecBuilder mystiqueDefinition( + final Optional 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"); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java index 0a82811fa3d..709a5a52402 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java @@ -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, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java index 173789046b8..469426c0a04 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java @@ -247,6 +247,7 @@ private TreeMap 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) @@ -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); } } diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/config/DiscoveryConfiguration.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/config/DiscoveryConfiguration.java index 4e7763c6f8f..1b1cb151ecd 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/config/DiscoveryConfiguration.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/config/DiscoveryConfiguration.java @@ -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", diff --git a/gradle.properties b/gradle.properties index e45b3b23409..5d305c7bfe7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \