diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java index c25e35ab1f..439157a5e0 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java @@ -31,11 +31,11 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; @@ -127,7 +127,7 @@ public class JsonRpcTestMethodsFactory { peerDiscovery, blockchainQueries, synchronizer, - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, filterManager, transactionPool, miningCoordinator, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java index c077f6d54c..33c63f0da5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.core.DefaultSyncStatus; import org.hyperledger.besu.ethereum.core.InMemoryStorageProvider; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; @@ -34,7 +35,6 @@ import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; @@ -95,7 +95,7 @@ public abstract class AbstractEthGraphQLHttpServiceTest { @BeforeClass public static void setupConstants() throws Exception { - PROTOCOL_SCHEDULE = MainnetProtocolSchedule.create(); + PROTOCOL_SCHEDULE = ProtocolScheduleFixture.MAINNET; final URL blocksUrl = BlockTestUtil.getTestBlockchainUrl(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java index bfda5c54fa..6ba804079b 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java @@ -31,11 +31,11 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.EthHashMiningCoordinator; import org.hyperledger.besu.ethereum.core.InMemoryStorageProvider; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.RlpxConfiguration; @@ -200,7 +200,7 @@ public class JsonRpcHttpServiceRpcApisTest { mock(P2PNetwork.class), blockchainQueries, mock(Synchronizer.class), - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, mock(FilterManager.class), mock(TransactionPool.class), mock(EthHashMiningCoordinator.class), @@ -296,7 +296,7 @@ public class JsonRpcHttpServiceRpcApisTest { p2pNetwork, blockchainQueries, mock(Synchronizer.class), - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, mock(FilterManager.class), mock(TransactionPool.class), mock(EthHashMiningCoordinator.class), diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java index 162765d359..3fcc0eaf4a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators; @@ -28,11 +27,6 @@ public class MainnetProtocolSchedule { public static final BigInteger DEFAULT_CHAIN_ID = BigInteger.ONE; - public static ProtocolSchedule create() { - return fromConfig( - GenesisConfigFile.mainnet().getConfigOptions(), PrivacyParameters.DEFAULT, false); - } - /** * Create a Mainnet protocol schedule from a config object * diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java new file mode 100644 index 0000000000..4324caaea9 --- /dev/null +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java @@ -0,0 +1,55 @@ +/* + * Copyright ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.hyperledger.besu.ethereum.core; + +import static org.hyperledger.besu.config.JsonUtil.normalizeKeys; + +import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.config.GenesisConfigOptions; +import org.hyperledger.besu.config.JsonGenesisConfigOptions; +import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ProtocolScheduleFixture { + public static final ProtocolSchedule MAINNET = + MainnetProtocolSchedule.fromConfig( + getMainnetConfigOptions(), PrivacyParameters.DEFAULT, false); + + private static GenesisConfigOptions getMainnetConfigOptions() { + // this method avoids reading all the alloc accounts when all we want is the "config" section + try (final JsonParser jsonParser = + new JsonFactory().createParser(GenesisConfigFile.class.getResource("/mainnet.json"))) { + + while (jsonParser.nextToken() != JsonToken.END_OBJECT) { + if ("config".equals(jsonParser.getCurrentName())) { + jsonParser.nextToken(); + return JsonGenesisConfigOptions.fromJsonObject( + normalizeKeys(new ObjectMapper().readTree(jsonParser))); + } + } + } catch (IOException e) { + throw new RuntimeException("Failed open or parse mainnet genesis json", e); + } + throw new IllegalArgumentException("mainnet json file had no config section"); + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java index 73855fcedd..8fe73db01f 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.InMemoryStorageProvider; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import com.google.common.base.Charsets; @@ -63,7 +63,7 @@ public final class GenesisStateTest { final GenesisState genesisState = GenesisState.fromJson( Resources.toString(GenesisStateTest.class.getResource("genesis1.json"), Charsets.UTF_8), - MainnetProtocolSchedule.create()); + ProtocolScheduleFixture.MAINNET); final BlockHeader header = genesisState.getBlock().getHeader(); assertThat(header.getStateRoot()) .isEqualTo( @@ -91,7 +91,7 @@ public final class GenesisStateTest { final GenesisState genesisState = GenesisState.fromJson( Resources.toString(GenesisStateTest.class.getResource("genesis2.json"), Charsets.UTF_8), - MainnetProtocolSchedule.create()); + ProtocolScheduleFixture.MAINNET); final BlockHeader header = genesisState.getBlock().getHeader(); assertThat(header.getStateRoot()).isEqualTo(Hash.EMPTY_TRIE_HASH); assertThat(header.getTransactionsRoot()).isEqualTo(Hash.EMPTY_TRIE_HASH); @@ -106,7 +106,7 @@ public final class GenesisStateTest { final GenesisState genesisState = GenesisState.fromJson( Resources.toString(GenesisStateTest.class.getResource(sourceFile), Charsets.UTF_8), - MainnetProtocolSchedule.create()); + ProtocolScheduleFixture.MAINNET); final BlockHeader header = genesisState.getBlock().getHeader(); assertThat(header.getHash()).isEqualTo(Hash.fromHexString(blockHash)); @@ -144,7 +144,7 @@ public final class GenesisStateTest { GenesisState.fromJson( Resources.toString( GenesisStateTest.class.getResource("genesisNonce.json"), Charsets.UTF_8), - MainnetProtocolSchedule.create()); + ProtocolScheduleFixture.MAINNET); final BlockHeader header = genesisState.getBlock().getHeader(); assertThat(header.getHash()) .isEqualTo( @@ -158,7 +158,7 @@ public final class GenesisStateTest { GenesisState.fromJson( Resources.toString( GenesisStateTest.class.getResource("genesis-olympic.json"), Charsets.UTF_8), - MainnetProtocolSchedule.create()); + ProtocolScheduleFixture.MAINNET); final BytesValueRLPOutput tmp = new BytesValueRLPOutput(); genesisState.getBlock().writeTo(tmp); assertThat(Hex.toHexString(genesisState.getBlock().getHeader().getHash().toArray())) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java index 423f509589..23b2c64386 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigFile; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import java.nio.charset.StandardCharsets; @@ -26,7 +27,7 @@ public class MainnetProtocolScheduleTest { @Test public void shouldReturnDefaultProtocolSpecsWhenCustomNumbersAreNotUsed() { - final ProtocolSchedule sched = MainnetProtocolSchedule.create(); + final ProtocolSchedule sched = ProtocolScheduleFixture.MAINNET; Assertions.assertThat(sched.getByBlockNumber(1L).getName()).isEqualTo("Frontier"); Assertions.assertThat(sched.getByBlockNumber(1_150_000L).getName()).isEqualTo("Homestead"); Assertions.assertThat(sched.getByBlockNumber(1_920_000L).getName()) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRuleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRuleTest.java index 27bb1d6562..6f380122f1 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRuleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/ProofOfWorkValidationRuleTest.java @@ -21,8 +21,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.Hash; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.mainnet.EpochCalculator; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ValidationTestUtils; @@ -142,7 +142,7 @@ public class ProofOfWorkValidationRuleTest { } private BlockHeaderFunctions mainnetBlockHashFunction() { - final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; return ScheduleBasedBlockHeaderFunctions.create(protocolSchedule); } } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java index ad3f415c28..3d58519a5a 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.Hash; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Wei; @@ -56,7 +57,6 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; @@ -880,7 +880,7 @@ public final class EthProtocolManagerTest { .isEqualTo(Collections.singletonList(EthProtocol.ETH63)); // assert that all messages transmitted contain the expected block & total difficulty. - final ProtocolSchedule protocolSchdeule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchdeule = ProtocolScheduleFixture.MAINNET; for (final NewBlockMessage msg : messageSentCaptor.getAllValues()) { assertThat(msg.block(protocolSchdeule)).isEqualTo(minedBlock); assertThat(msg.totalDifficulty(protocolSchdeule)).isEqualTo(expectedTotalDifficulty); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java index ba30cc55a7..eaa4a945c4 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java @@ -24,12 +24,12 @@ import org.hyperledger.besu.ethereum.chain.ChainHead; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler.TimeoutPolicy; import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; @@ -100,7 +100,7 @@ public class EthProtocolManagerTestUtil { } public static EthProtocolManager create(final EthScheduler ethScheduler) { - final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; final GenesisConfigFile config = GenesisConfigFile.mainnet(); final GenesisState genesisState = GenesisState.fromConfig(config, protocolSchedule); final Blockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/NewBlockMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/NewBlockMessageTest.java index b965396d3e..93e053ff58 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/NewBlockMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/NewBlockMessageTest.java @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; @@ -29,7 +29,7 @@ import org.apache.tuweni.bytes.Bytes; import org.junit.Test; public class NewBlockMessageTest { - private static final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + private static final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; @Test public void roundTripNewBlockMessage() { diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidatorTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidatorTest.java index a02d457223..2ea01b5375 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidatorTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/DaoForkPeerValidatorTest.java @@ -19,11 +19,11 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderValidator; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.concurrent.CompletableFuture; @@ -37,7 +37,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest { @Override AbstractPeerBlockValidator createValidator(final long blockNumber, final long buffer) { return new DaoForkPeerValidator( - MainnetProtocolSchedule.create(), new NoOpMetricsSystem(), blockNumber, buffer); + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), blockNumber, buffer); } @Test @@ -53,7 +53,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest { final PeerValidator validator = new DaoForkPeerValidator( - MainnetProtocolSchedule.create(), new NoOpMetricsSystem(), daoBlockNumber, 0); + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), daoBlockNumber, 0); final RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, daoBlockNumber); @@ -81,7 +81,7 @@ public class DaoForkPeerValidatorTest extends AbstractPeerBlockValidatorTest { final PeerValidator validator = new DaoForkPeerValidator( - MainnetProtocolSchedule.create(), new NoOpMetricsSystem(), daoBlockNumber, 0); + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), daoBlockNumber, 0); final RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, daoBlockNumber); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidatorTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidatorTest.java index af7cacb40d..1054613b9c 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidatorTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/peervalidation/RequiredBlocksPeerValidatorTest.java @@ -22,10 +22,10 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.Hash; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.concurrent.CompletableFuture; @@ -38,7 +38,7 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT @Override AbstractPeerBlockValidator createValidator(final long blockNumber, final long buffer) { return new RequiredBlocksPeerValidator( - MainnetProtocolSchedule.create(), new NoOpMetricsSystem(), blockNumber, Hash.ZERO, buffer); + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), blockNumber, Hash.ZERO, buffer); } @Test @@ -51,7 +51,7 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT final PeerValidator validator = new RequiredBlocksPeerValidator( - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), requiredBlockNumber, requiredBlock.getHash(), @@ -83,7 +83,7 @@ public class RequiredBlocksPeerValidatorTest extends AbstractPeerBlockValidatorT final PeerValidator validator = new RequiredBlocksPeerValidator( - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, new NoOpMetricsSystem(), requiredBlockNumber, Hash.ZERO, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManagerTest.java index 975792108e..a45aaea5dd 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManagerTest.java @@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -31,7 +32,6 @@ import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.state.SyncTarget; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -61,7 +61,7 @@ public class FullSyncTargetManagerTest { final BlockchainSetupUtil localBlockchainSetup = BlockchainSetupUtil.forTesting(); localBlockchain = localBlockchainSetup.getBlockchain(); - final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; final ProtocolContext protocolContext = new ProtocolContext(localBlockchain, localWorldState, null); ethProtocolManager = diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskParameterizedTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskParameterizedTest.java index 7acd6b9b3c..e3101b85e7 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskParameterizedTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskParameterizedTest.java @@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -35,7 +36,6 @@ import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.eth.manager.task.EthTask; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -58,7 +58,7 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class DetermineCommonAncestorTaskParameterizedTest { - private final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + private final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); private final MetricsSystem metricsSystem = new NoOpMetricsSystem(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskTest.java index cb738129fe..6937e71a46 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/DetermineCommonAncestorTaskTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -44,7 +45,6 @@ import org.hyperledger.besu.ethereum.eth.manager.exceptions.EthTaskException; import org.hyperledger.besu.ethereum.eth.manager.task.EthTask; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -62,7 +62,7 @@ import org.junit.Test; public class DetermineCommonAncestorTaskTest { - private final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + private final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); private final MetricsSystem metricsSystem = new NoOpMetricsSystem(); private final int defaultHeaderRequestSize = 10; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java index fd4fd1f294..0bf4f51525 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -46,7 +47,6 @@ import org.hyperledger.besu.ethereum.eth.messages.EthPV63; import org.hyperledger.besu.ethereum.eth.messages.GetNodeDataMessage; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; @@ -907,7 +907,7 @@ public class WorldStateDownloaderTest { mock(Blockchain.class), remoteWorldStateArchive, mock(TransactionPool.class), - MainnetProtocolSchedule.create(), + ProtocolScheduleFixture.MAINNET, .5f); final RespondingEthPeer.Responder emptyResponder = RespondingEthPeer.emptyResponder(); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java index 9465d21cde..da5ea0a6ac 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Address; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; @@ -55,7 +55,7 @@ public class NodeSmartContractPermissioningControllerTest { private NodeSmartContractPermissioningController setupController( final String resourceName, final String contractAddressString) throws IOException { - final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; final String emptyContractFile = Resources.toString(this.getClass().getResource(resourceName), UTF_8); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java index 44ee7e2ce6..131df17920 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java @@ -28,9 +28,9 @@ import org.hyperledger.besu.crypto.SECP256K1.Signature; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Address; +import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -57,7 +57,7 @@ public class TransactionSmartContractPermissioningControllerTest { private TransactionSmartContractPermissioningController setupController( final String resourceName, final String contractAddressString) throws IOException { - final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.create(); + final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; final String emptyContractFile = Resources.toString(this.getClass().getResource(resourceName), UTF_8);