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 d39bf0050f..04190bbcbf 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 @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.graphql; +import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; + import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; @@ -145,8 +147,7 @@ public abstract class AbstractEthGraphQLHttpServiceTest { true, Instant.ofEpochSecond(Integer.MAX_VALUE)))); - final WorldStateArchive stateArchive = - InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive(); + final WorldStateArchive stateArchive = createInMemoryWorldStateArchive(); GENESIS_CONFIG.writeStateTo(stateArchive.getMutable()); final MutableBlockchain blockchain = diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java index 80232a7e7d..5e88eca5ff 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpBySpecTest.java @@ -27,6 +27,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Stream; @@ -51,7 +52,7 @@ public abstract class AbstractJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpS private static final ObjectMapper objectMapper = new ObjectMapper(); private final URL specURL; - AbstractJsonRpcHttpBySpecTest(final String specName, final URL specURL) { + protected AbstractJsonRpcHttpBySpecTest(final String specName, final URL specURL) { this.specURL = specURL; } @@ -68,7 +69,8 @@ public abstract class AbstractJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpS * @return Parameters for this test which will contain the name of the test and the url of the * spec file to run. */ - static Object[][] findSpecFiles(final String... subDirectoryPaths) { + public static Object[][] findSpecFiles( + final String[] subDirectoryPaths, final String... exceptions) { final List specFiles = new ArrayList<>(); for (final String path : subDirectoryPaths) { final URL url = AbstractJsonRpcHttpBySpecTest.class.getResource(path); @@ -83,6 +85,7 @@ public abstract class AbstractJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpS s.map(Path::toFile) .filter(f -> f.getPath().endsWith(".json")) .filter(f -> !f.getPath().contains("genesis")) + .filter(f -> Arrays.stream(exceptions).noneMatch(f.getPath()::contains)) .map(AbstractJsonRpcHttpBySpecTest::fileToParams) .forEach(specFiles::add); } catch (final IOException e) { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java index 7809140565..236e68c273 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java @@ -43,6 +43,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -83,22 +84,28 @@ public abstract class AbstractJsonRpcHttpServiceTest { protected final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); protected FilterManager filterManager; - private void setupBlockchain() { - blockchainSetupUtil = getBlockchainSetupUtil(); + protected void setupBlockchain() { + blockchainSetupUtil = getBlockchainSetupUtil(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); } - protected BlockchainSetupUtil getBlockchainSetupUtil() { - return BlockchainSetupUtil.forTesting(); + protected void setupBonsaiBlockchain() { + blockchainSetupUtil = getBlockchainSetupUtil(DataStorageFormat.BONSAI); + blockchainSetupUtil.importAllBlocks(); + } + + protected BlockchainSetupUtil getBlockchainSetupUtil(final DataStorageFormat storageFormat) { + return BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); } protected BlockchainSetupUtil createBlockchainSetupUtil( - final String genesisPath, final String blocksPath) { + final String genesisPath, final String blocksPath, final DataStorageFormat storageFormat) { final URL genesisURL = AbstractJsonRpcHttpServiceTest.class.getResource(genesisPath); final URL blocksURL = AbstractJsonRpcHttpServiceTest.class.getResource(blocksPath); checkArgument(genesisURL != null, "Unable to locate genesis file: " + genesisPath); checkArgument(blocksURL != null, "Unable to locate blocks file: " + blocksPath); - return BlockchainSetupUtil.createForEthashChain(new ChainResources(genesisURL, blocksURL)); + return BlockchainSetupUtil.createForEthashChain( + new ChainResources(genesisURL, blocksURL), storageFormat); } @Before @@ -106,8 +113,9 @@ public abstract class AbstractJsonRpcHttpServiceTest { setupBlockchain(); } - protected BlockchainSetupUtil startServiceWithEmptyChain() throws Exception { - final BlockchainSetupUtil emptySetupUtil = getBlockchainSetupUtil(); + protected BlockchainSetupUtil startServiceWithEmptyChain(final DataStorageFormat storageFormat) + throws Exception { + final BlockchainSetupUtil emptySetupUtil = getBlockchainSetupUtil(storageFormat); startService(emptySetupUtil); return emptySetupUtil; } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/DebugJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/DebugJsonRpcHttpBySpecTest.java new file mode 100644 index 0000000000..ba55e7cf11 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/DebugJsonRpcHttpBySpecTest.java @@ -0,0 +1,45 @@ +/* + * 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.api.jsonrpc.bonsai; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; + +import java.net.URL; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class DebugJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { + + public DebugJsonRpcHttpBySpecTest(final String specName, final URL specURL) { + super(specName, specURL); + } + + @Override + public void setup() throws Exception { + setupBonsaiBlockchain(); + startService(); + } + + @Parameters(name = "{index}: {0}") + public static Object[][] specs() { + return findSpecFiles( + new String[] {"debug"}, + "storageRange", + "accountRange"); // storageRange and accountRange are not working with bonsai trie + } +} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthByzantiumJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthByzantiumJsonRpcHttpBySpecTest.java new file mode 100644 index 0000000000..d012c1eb40 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthByzantiumJsonRpcHttpBySpecTest.java @@ -0,0 +1,50 @@ +/* + * 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.api.jsonrpc.bonsai; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; +import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; + +import java.net.URL; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class EthByzantiumJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { + + public EthByzantiumJsonRpcHttpBySpecTest(final String specName, final URL specURL) { + super(specName, specURL); + } + + @Override + public void setup() throws Exception { + setupBonsaiBlockchain(); + startService(); + } + + @Override + protected BlockchainSetupUtil getBlockchainSetupUtil(final DataStorageFormat dataStorageFormat) { + return createBlockchainSetupUtil( + "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin", dataStorageFormat); + } + + @Parameters(name = "{index}: {0}") + public static Object[][] specs() { + return AbstractJsonRpcHttpBySpecTest.findSpecFiles(new String[] {"eth_latest"}); + } +} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthJsonRpcHttpBySpecTest.java new file mode 100644 index 0000000000..96aa9b3ada --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/EthJsonRpcHttpBySpecTest.java @@ -0,0 +1,43 @@ +/* + * 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.api.jsonrpc.bonsai; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; + +import java.net.URL; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class EthJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { + + public EthJsonRpcHttpBySpecTest(final String specName, final URL specURL) { + super(specName, specURL); + } + + @Override + public void setup() throws Exception { + setupBonsaiBlockchain(); + startService(); + } + + @Parameters(name = "{index}: {0}") + public static Object[][] specs() { + return findSpecFiles( + new String[] {"eth"}, "getProof"); // getProof is not working with bonsai trie + } +} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/TraceJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/TraceJsonRpcHttpBySpecTest.java new file mode 100644 index 0000000000..81d8eb71f1 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/bonsai/TraceJsonRpcHttpBySpecTest.java @@ -0,0 +1,59 @@ +/* + * 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.api.jsonrpc.bonsai; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; +import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; + +import java.net.URL; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class TraceJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { + + public TraceJsonRpcHttpBySpecTest(final String specName, final URL specURL) { + super(specName, specURL); + } + + @Override + public void setup() throws Exception { + setupBonsaiBlockchain(); + startService(); + } + + @Override + protected BlockchainSetupUtil getBlockchainSetupUtil(final DataStorageFormat storageFormat) { + return createBlockchainSetupUtil( + "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin", storageFormat); + } + + @Parameters(name = "{index}: {0}") + public static Object[][] specs() { + return AbstractJsonRpcHttpBySpecTest.findSpecFiles( + new String[] { + "trace/specs/trace-block", + "trace/specs/trace-transaction", + "trace/specs/replay-trace-transaction/flat", + "trace/specs/replay-trace-transaction/vm-trace", + "trace/specs/replay-trace-transaction/statediff", + "trace/specs/replay-trace-transaction/all", + "trace/specs/replay-trace-transaction/halt-cases" + }); + } +} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/DebugJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/DebugJsonRpcHttpBySpecTest.java similarity index 84% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/DebugJsonRpcHttpBySpecTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/DebugJsonRpcHttpBySpecTest.java index 23d11ba76f..b9ab7d398a 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/DebugJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/DebugJsonRpcHttpBySpecTest.java @@ -12,7 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc; +package org.hyperledger.besu.ethereum.api.jsonrpc.forest; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; import java.net.URL; @@ -29,12 +31,12 @@ public class DebugJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { @Override public void setup() throws Exception { - super.setup(); + setupBlockchain(); startService(); } @Parameters(name = "{index}: {0}") public static Object[][] specs() { - return findSpecFiles("debug"); + return findSpecFiles(new String[] {"debug"}); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthByzantiumJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthByzantiumJsonRpcHttpBySpecTest.java similarity index 75% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthByzantiumJsonRpcHttpBySpecTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthByzantiumJsonRpcHttpBySpecTest.java index 38f42fee88..3d0a85ce6e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthByzantiumJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthByzantiumJsonRpcHttpBySpecTest.java @@ -12,9 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc; +package org.hyperledger.besu.ethereum.api.jsonrpc.forest; +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import java.net.URL; @@ -31,18 +33,18 @@ public class EthByzantiumJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpec @Override public void setup() throws Exception { - super.setup(); + setupBlockchain(); startService(); } @Override - protected BlockchainSetupUtil getBlockchainSetupUtil() { + protected BlockchainSetupUtil getBlockchainSetupUtil(final DataStorageFormat storageFormat) { return createBlockchainSetupUtil( - "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin"); + "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin", storageFormat); } @Parameters(name = "{index}: {0}") public static Object[][] specs() { - return AbstractJsonRpcHttpBySpecTest.findSpecFiles("eth_latest"); + return AbstractJsonRpcHttpBySpecTest.findSpecFiles(new String[] {"eth_latest"}); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthJsonRpcHttpBySpecTest.java similarity index 84% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthJsonRpcHttpBySpecTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthJsonRpcHttpBySpecTest.java index 6529795165..faf6ed93ac 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/EthJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/EthJsonRpcHttpBySpecTest.java @@ -12,7 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc; +package org.hyperledger.besu.ethereum.api.jsonrpc.forest; + +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; import java.net.URL; @@ -29,12 +31,12 @@ public class EthJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { @Override public void setup() throws Exception { - super.setup(); + setupBlockchain(); startService(); } @Parameters(name = "{index}: {0}") public static Object[][] specs() { - return findSpecFiles("eth"); + return findSpecFiles(new String[] {"eth"}); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/TraceJsonRpcHttpBySpecTest.java similarity index 64% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/TraceJsonRpcHttpBySpecTest.java index 9b72430513..2d7b637914 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/TraceJsonRpcHttpBySpecTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/forest/TraceJsonRpcHttpBySpecTest.java @@ -12,9 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.api.jsonrpc; +package org.hyperledger.besu.ethereum.api.jsonrpc.forest; +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpBySpecTest; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import java.net.URL; @@ -31,25 +33,27 @@ public class TraceJsonRpcHttpBySpecTest extends AbstractJsonRpcHttpBySpecTest { @Override public void setup() throws Exception { - super.setup(); + setupBlockchain(); startService(); } @Override - protected BlockchainSetupUtil getBlockchainSetupUtil() { + protected BlockchainSetupUtil getBlockchainSetupUtil(final DataStorageFormat storageFormat) { return createBlockchainSetupUtil( - "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin"); + "trace/chain-data/genesis.json", "trace/chain-data/blocks.bin", storageFormat); } @Parameters(name = "{index}: {0}") public static Object[][] specs() { return AbstractJsonRpcHttpBySpecTest.findSpecFiles( - "trace/specs/trace-block", - "trace/specs/trace-transaction", - "trace/specs/replay-trace-transaction/flat", - "trace/specs/replay-trace-transaction/vm-trace", - "trace/specs/replay-trace-transaction/statediff", - "trace/specs/replay-trace-transaction/all", - "trace/specs/replay-trace-transaction/halt-cases"); + new String[] { + "trace/specs/trace-block", + "trace/specs/trace-transaction", + "trace/specs/replay-trace-transaction/flat", + "trace/specs/replay-trace-transaction/vm-trace", + "trace/specs/replay-trace-transaction/statediff", + "trace/specs/replay-trace-transaction/all", + "trace/specs/replay-trace-transaction/halt-cases" + }); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/EthJsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/EthJsonRpcHttpServiceTest.java index 70fb8d2b99..eb5e12b699 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/EthJsonRpcHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/EthJsonRpcHttpServiceTest.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import java.io.IOException; @@ -56,7 +57,7 @@ public class EthJsonRpcHttpServiceTest extends AbstractJsonRpcHttpServiceTest { @Test public void getFilterChanges_oneBlock() throws Exception { - BlockchainSetupUtil blockchainSetupUtil = startServiceWithEmptyChain(); + BlockchainSetupUtil blockchainSetupUtil = startServiceWithEmptyChain(DataStorageFormat.FOREST); final String expectedRespBody = String.format( "{%n \"jsonrpc\" : \"2.0\",%n \"id\" : 2,%n \"result\" : [ \"0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9\" ]%n}"); diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java index fecd1d3252..c732feff1e 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java @@ -15,11 +15,11 @@ package org.hyperledger.besu.ethereum.vm; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; import org.hyperledger.besu.ethereum.core.AccountStorageEntry; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.Hash; -import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.WorldUpdater; @@ -37,8 +37,7 @@ public class EntriesFromIntegrationTest { @Test @SuppressWarnings("MathAbsoluteRandom") public void shouldCollectStateEntries() { - final MutableWorldState worldState = - InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive().getMutable(); + final MutableWorldState worldState = createInMemoryWorldStateArchive().getMutable(); final WorldUpdater updater = worldState.updater(); MutableAccount account = updater.getOrCreate(Address.fromHexString("0x56")).getMutable(); final Map expectedValues = new TreeMap<>(); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java index 0c50d80d1f..998a923e8e 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.core; import static com.google.common.base.Preconditions.checkArgument; import static java.util.stream.Collectors.toUnmodifiableList; import static java.util.stream.Collectors.toUnmodifiableSet; +import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SecureRandomProvider; @@ -193,14 +194,12 @@ public class BlockDataGenerator { } public List blockSequence(final int count) { - final WorldStateArchive worldState = - InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive(); + final WorldStateArchive worldState = createInMemoryWorldStateArchive(); return blockSequence(count, worldState, Collections.emptyList(), Collections.emptyList()); } public List blockSequence(final Block previousBlock, final int count) { - final WorldStateArchive worldState = - InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive(); + final WorldStateArchive worldState = createInMemoryWorldStateArchive(); final Hash parentHash = previousBlock.getHeader().getHash(); final long blockNumber = previousBlock.getHeader().getNumber() + 1; return blockSequence( diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index 784cd18a61..8154f8386f 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.core; import static org.assertj.core.util.Preconditions.checkArgument; +import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; import static org.mockito.Mockito.mock; @@ -32,6 +33,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.util.RawBlockIterator; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.testutil.BlockTestUtil; @@ -104,25 +106,27 @@ public class BlockchainSetupUtil { return blocks.size(); } - public static BlockchainSetupUtil forTesting() { - return createForEthashChain(BlockTestUtil.getTestChainResources()); + public static BlockchainSetupUtil forTesting(final DataStorageFormat storageFormat) { + return createForEthashChain(BlockTestUtil.getTestChainResources(), storageFormat); } public static BlockchainSetupUtil forMainnet() { - return createForEthashChain(BlockTestUtil.getMainnetResources()); + return createForEthashChain(BlockTestUtil.getMainnetResources(), DataStorageFormat.FOREST); } public static BlockchainSetupUtil forOutdatedFork() { - return createForEthashChain(BlockTestUtil.getOutdatedForkResources()); + return createForEthashChain(BlockTestUtil.getOutdatedForkResources(), DataStorageFormat.FOREST); } public static BlockchainSetupUtil forUpgradedFork() { - return createForEthashChain(BlockTestUtil.getUpgradedForkResources()); + return createForEthashChain(BlockTestUtil.getUpgradedForkResources(), DataStorageFormat.FOREST); } - public static BlockchainSetupUtil createForEthashChain(final ChainResources chainResources) { + public static BlockchainSetupUtil createForEthashChain( + final ChainResources chainResources, final DataStorageFormat storageFormat) { return create( chainResources, + storageFormat, BlockchainSetupUtil::mainnetProtocolScheduleProvider, BlockchainSetupUtil::mainnetProtocolContextProvider, new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem())); @@ -140,6 +144,7 @@ public class BlockchainSetupUtil { private static BlockchainSetupUtil create( final ChainResources chainResources, + final DataStorageFormat storageFormat, final ProtocolScheduleProvider protocolScheduleProvider, final ProtocolContextProvider protocolContextProvider, final EthScheduler scheduler) { @@ -153,7 +158,10 @@ public class BlockchainSetupUtil { final GenesisState genesisState = GenesisState.fromJson(genesisJson, protocolSchedule); final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); - final WorldStateArchive worldArchive = createInMemoryWorldStateArchive(); + final WorldStateArchive worldArchive = + storageFormat == DataStorageFormat.BONSAI + ? createBonsaiInMemoryWorldStateArchive(blockchain) + : createInMemoryWorldStateArchive(); final TransactionPool transactionPool = mock(TransactionPool.class); genesisState.writeStateTo(worldArchive.getMutable()); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java index adb19841ae..8ce4a09e3c 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java @@ -61,7 +61,7 @@ public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider { new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage())); } - public static BonsaiWorldStateArchive createInMemoryWorldStateArchive( + public static BonsaiWorldStateArchive createBonsaiInMemoryWorldStateArchive( final Blockchain blockchain) { return new BonsaiWorldStateArchive(new InMemoryKeyValueStorageProvider(), blockchain); } 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 0f6d355674..997b272230 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 @@ -63,6 +63,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -105,7 +106,8 @@ public final class EthProtocolManagerTest { @BeforeClass public static void setup() { gen = new BlockDataGenerator(0); - final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); blockchain = blockchainSetupUtil.getBlockchain(); transactionPool = blockchainSetupUtil.getTransactionPool(); 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 6c7d9dae08..5a2cbc7a1a 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 @@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; 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; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.testutil.TestClock; @@ -135,7 +136,7 @@ public class EthProtocolManagerTestUtil { return create( blockchain, ethScheduler, - BlockchainSetupUtil.forTesting().getWorldArchive(), + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST).getWorldArchive(), mock(TransactionPool.class), EthProtocolConfiguration.defaultConfig(), peers, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java index 333ae2c7c3..90e8bc39ef 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java @@ -38,6 +38,7 @@ 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.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.testutil.TestClock; @@ -70,7 +71,8 @@ public abstract class AbstractMessageTaskTest { @BeforeClass public static void setup() { - final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); blockchain = blockchainSetupUtil.getBlockchain(); protocolSchedule = blockchainSetupUtil.getProtocolSchedule(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManagerTest.java index a41f62d61b..4cade930e0 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManagerTest.java @@ -51,6 +51,7 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.testutil.TestClock; @@ -88,12 +89,12 @@ public class BlockPropagationManagerTest { @BeforeClass public static void setupSuite() { - fullBlockchain = BlockchainSetupUtil.forTesting().importAllBlocks(); + fullBlockchain = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST).importAllBlocks(); } @Before public void setup() { - blockchainUtil = BlockchainSetupUtil.forTesting(); + blockchainUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchain = blockchainUtil.getBlockchain(); protocolSchedule = blockchainUtil.getProtocolSchedule(); final ProtocolContext tempProtocolContext = blockchainUtil.getProtocolContext(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java index b1723f23a9..afdaa39e05 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.assertj.core.api.Assertions; @@ -35,7 +36,8 @@ import org.junit.Test; public class ChainHeadTrackerTest { - private final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + private final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); private final MutableBlockchain blockchain = blockchainSetupUtil.getBlockchain(); private final EthProtocolManager ethProtocolManager = EthProtocolManagerTestUtil.create(blockchain); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcherTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcherTest.java index 6e194775f8..a14660e39e 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcherTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/CheckpointHeaderFetcherTest.java @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -59,7 +60,8 @@ public class CheckpointHeaderFetcherTest { @BeforeClass public static void setUpClass() { - final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); blockchain = blockchainSetupUtil.getBlockchain(); transactionPool = blockchainSetupUtil.getTransactionPool(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStepTest.java index 069d460fbe..c5d04eb482 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/DownloadHeadersStepTest.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.ArrayList; @@ -53,7 +54,7 @@ public class DownloadHeadersStepTest { @BeforeClass public static void setUpClass() { - final BlockchainSetupUtil setupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil setupUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); setupUtil.importFirstBlocks(20); protocolSchedule = setupUtil.getProtocolSchedule(); protocolContext = setupUtil.getProtocolContext(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java index 66718745f2..b5657ab4f9 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java @@ -30,6 +30,7 @@ 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.eth.transactions.TransactionPool; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.List; @@ -49,7 +50,7 @@ public class DownloadReceiptsStepTest { @BeforeClass public static void setUpClass() { - final BlockchainSetupUtil setupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil setupUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); setupUtil.importFirstBlocks(20); protocolContext = setupUtil.getProtocolContext(); blockchain = setupUtil.getBlockchain(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActionsTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActionsTest.java index 00985afeef..09e05926d6 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActionsTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncActionsTest.java @@ -37,6 +37,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.ArrayList; @@ -50,7 +51,8 @@ import org.junit.Test; public class FastSyncActionsTest { - private final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + private final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); private final SynchronizerConfiguration.Builder syncConfigBuilder = new SynchronizerConfiguration.Builder().syncMode(SyncMode.FAST).fastSyncPivotDistance(1000); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloaderTest.java index 12650cdc1d..af4fee5878 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloaderTest.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.eth.sync.ChainDownloader; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.concurrent.CompletableFuture; @@ -61,9 +62,10 @@ public class FastSyncChainDownloaderTest { @Before public void setup() { when(validationPolicy.getValidationModeForNextBlock()).thenReturn(LIGHT_SKIP_DETACHED); - final BlockchainSetupUtil localBlockchainSetup = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil localBlockchainSetup = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); localBlockchain = localBlockchainSetup.getBlockchain(); - otherBlockchainSetup = BlockchainSetupUtil.forTesting(); + otherBlockchainSetup = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); otherBlockchain = otherBlockchainSetup.getBlockchain(); protocolSchedule = localBlockchainSetup.getProtocolSchedule(); @@ -143,7 +145,8 @@ public class FastSyncChainDownloaderTest { @Test public void recoversFromSyncTargetDisconnect() { - final BlockchainSetupUtil shorterChainUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil shorterChainUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); final MutableBlockchain shorterChain = shorterChainUtil.getBlockchain(); otherBlockchainSetup.importFirstBlocks(30); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmerTest.java index 68753a3a2e..4aaf2c2eb9 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockConfirmerTest.java @@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder; import org.hyperledger.besu.ethereum.eth.sync.fastsync.PivotBlockConfirmer.ContestedPivotBlockException; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -59,7 +60,8 @@ public class PivotBlockConfirmerTest { @Before public void setUp() { - final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); blockchain = blockchainSetupUtil.getBlockchain(); transactionPool = blockchainSetupUtil.getTransactionPool(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java index caa50338a1..26ca0424a9 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java @@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder; import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.util.ExceptionUtils; @@ -62,7 +63,8 @@ public class PivotBlockRetrieverTest { @Before public void setUp() { - final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil blockchainSetupUtil = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); blockchainSetupUtil.importAllBlocks(); blockchain = blockchainSetupUtil.getBlockchain(); protocolSchedule = blockchainSetupUtil.getProtocolSchedule(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncChainDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncChainDownloaderTest.java index c26cd43ee8..8c10a00a2f 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncChainDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncChainDownloaderTest.java @@ -42,6 +42,7 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -74,9 +75,9 @@ public class FullSyncChainDownloaderTest { @Before public void setupTest() { gen = new BlockDataGenerator(); - localBlockchainSetup = BlockchainSetupUtil.forTesting(); + localBlockchainSetup = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); localBlockchain = localBlockchainSetup.getBlockchain(); - otherBlockchainSetup = BlockchainSetupUtil.forTesting(); + otherBlockchainSetup = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); otherBlockchain = otherBlockchainSetup.getBlockchain(); protocolSchedule = localBlockchainSetup.getProtocolSchedule(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java index 05511a4ef4..4a9963bb83 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncDownloaderTest.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.TrailingPeerRequirements; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -50,7 +51,7 @@ public class FullSyncDownloaderTest { @Before public void setupTest() { - localBlockchainSetup = BlockchainSetupUtil.forTesting(); + localBlockchainSetup = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); localBlockchain = localBlockchainSetup.getBlockchain(); protocolSchedule = localBlockchainSetup.getProtocolSchedule(); 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 e268705fa8..1ede9e2be5 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 @@ -34,6 +34,7 @@ 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.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -55,11 +56,13 @@ public class FullSyncTargetManagerTest { @Before public void setup() { - final BlockchainSetupUtil otherBlockchainSetup = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil otherBlockchainSetup = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); final Blockchain otherBlockchain = otherBlockchainSetup.getBlockchain(); responder = RespondingEthPeer.blockchainResponder(otherBlockchain); - final BlockchainSetupUtil localBlockchainSetup = BlockchainSetupUtil.forTesting(); + final BlockchainSetupUtil localBlockchainSetup = + BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); localBlockchain = localBlockchainSetup.getBlockchain(); final ProtocolSchedule protocolSchedule = ProtocolScheduleFixture.MAINNET; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTaskTest.java index 1a3f2178e2..91ddea2141 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTaskTest.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil; import org.hyperledger.besu.ethereum.eth.sync.tasks.exceptions.InvalidBlockException; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -53,7 +54,7 @@ public class PersistBlockTaskTest { @Before public void setup() { - blockchainUtil = BlockchainSetupUtil.forTesting(); + blockchainUtil = BlockchainSetupUtil.forTesting(DataStorageFormat.FOREST); protocolSchedule = blockchainUtil.getProtocolSchedule(); protocolContext = blockchainUtil.getProtocolContext(); blockchain = blockchainUtil.getBlockchain(); diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java index a4da8c5a8c..14bf5607af 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java @@ -15,6 +15,8 @@ */ package org.hyperledger.besu.ethereum.referencetests; +import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; + import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Address; @@ -62,8 +64,7 @@ public class BlockchainReferenceTestCaseSpec { private static WorldStateArchive buildWorldStateArchive( final Map accounts) { - final WorldStateArchive worldStateArchive = - InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive(); + final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); final MutableWorldState worldState = worldStateArchive.getMutable(); final WorldUpdater updater = worldState.updater();