Merge branch 'main' into zkbesu

# Conflicts:
#	.github/workflows/checks.yml
#	.github/workflows/codeql.yml
#	.github/workflows/release.yml
#	.github/workflows/sonarcloud.yml
#	build.gradle
#	gradle.properties
This commit is contained in:
Fabio Di Fabio
2023-12-21 10:32:57 +01:00
199 changed files with 3468 additions and 1762 deletions

View File

@@ -9,6 +9,10 @@
### Additions and Improvements
- Add error messages on authentication failures with username and password [#6212](https://github.com/hyperledger/besu/pull/6212)
- New `Sequenced` transaction pool. The pool is an evolution of the `legacy` pool and is likely to be more suitable to enterprise or permissioned chains than the `layered` transaction pool. Select to use this pool with `--tx-pool=sequenced`. Supports the same options as the `legacy` pool [#6211](https://github.com/hyperledger/besu/issues/6211)
- Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267)
- Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297)
- Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275)
### Bug fixes

View File

@@ -11,7 +11,6 @@ dependencies {
implementation 'com.google.auto.service:auto-service'
implementation 'info.picocli:picocli'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

View File

@@ -29,13 +29,13 @@ import java.util.Optional;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.ThrowableAssert;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class BesuPluginContextImplTest {
@BeforeClass
@BeforeAll
public static void createFakePluginDir() throws IOException {
if (System.getProperty("besu.plugins.dir") == null) {
final Path pluginDir = Files.createTempDirectory("besuTest");
@@ -44,7 +44,7 @@ public class BesuPluginContextImplTest {
}
}
@After
@AfterEach
public void clearTestPluginState() {
System.clearProperty("testPicoCLIPlugin.testOption");
}

View File

@@ -43,15 +43,8 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
public class AbstractPreexistingNodeTest extends AcceptanceTestBase {
protected final String testName;
protected final String dataPath;
protected Path hostDataPath;
public AbstractPreexistingNodeTest(final String testName, final String dataPath) {
this.testName = testName;
this.dataPath = dataPath;
}
protected static void extract(final Path path, final String destDirectory) throws IOException {
try (final TarArchiveInputStream fin =
new TarArchiveInputStream(

View File

@@ -21,7 +21,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class LoggingTest extends AcceptanceTestBase {

View File

@@ -29,7 +29,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.nio.file.Files;
@@ -37,64 +36,42 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@RunWith(Parameterized.class)
public class BackupRoundTripAcceptanceTest extends AbstractPreexistingNodeTest {
private final Path backupPath;
private final Path restorePath;
private final Path rebackupPath;
private Path backupPath;
private Path restorePath;
private Path rebackupPath;
@SuppressWarnings({"unused", "FieldCanBeLocal"})
private final List<AccountData> testAccounts;
public static Stream<Arguments> getParameters() {
// First 10 blocks of ropsten
return Stream.of(
Arguments.of(
"After versioning was enabled and using multiple RocksDB columns",
"version1",
0xA,
singletonList(
new AccountData(
"0xd1aeb42885a43b72b518182ef893125814811048",
BigInteger.valueOf(0xA),
Wei.fromHexString("0x2B5E3AF16B1880000")))));
}
@SuppressWarnings({"unused", "FieldCanBeLocal"})
private final long expectedChainHeight;
public BackupRoundTripAcceptanceTest(
final String testName,
final String dataPath,
final long expectedChainHeight,
final List<AccountData> testAccounts)
throws IOException {
super(testName, dataPath);
this.expectedChainHeight = expectedChainHeight;
this.testAccounts = testAccounts;
public void setUp(final String testName, final String dataPath) throws Exception {
backupPath = Files.createTempDirectory("backup");
backupPath.toFile().deleteOnExit();
restorePath = Files.createTempDirectory("restore");
restorePath.toFile().deleteOnExit();
rebackupPath = Files.createTempDirectory("rebackup");
rebackupPath.toFile().deleteOnExit();
}
@Parameters(name = "{0}")
public static Object[][] getParameters() {
return new Object[][] {
// First 10 blocks of ropsten
new Object[] {
"After versioning was enabled and using multiple RocksDB columns",
"version1",
0xA,
singletonList(
new AccountData(
"0xd1aeb42885a43b72b518182ef893125814811048",
BigInteger.valueOf(0xA),
Wei.fromHexString("0x2B5E3AF16B1880000")))
}
};
}
@Before
public void setUp() throws Exception {
final URL rootURL = DatabaseMigrationAcceptanceTest.class.getResource(dataPath);
hostDataPath = copyDataDir(rootURL);
final Path databaseArchive =
@@ -105,8 +82,16 @@ public class BackupRoundTripAcceptanceTest extends AbstractPreexistingNodeTest {
extract(databaseArchive, hostDataPath.toAbsolutePath().toString());
}
@Test
public void backupRoundtripAndBack() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void backupRoundtripAndBack(
final String testName,
final String dataPath,
final long expectedChainHeight,
final List<AccountData> testAccounts)
throws Exception {
setUp(testName, dataPath);
// backup from existing files
final BesuNode backupNode =

View File

@@ -17,15 +17,15 @@ package org.hyperledger.besu.tests.acceptance.bootstrap;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ClusterAcceptanceTest extends AcceptanceTestBase {
private Node minerNode;
private Node fullNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("node1");
fullNode = besu.createArchiveNode("node2");

View File

@@ -20,8 +20,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase {
@@ -29,7 +29,7 @@ public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase {
private Node noDiscoveryNode;
private Cluster noDiscoveryCluster;
@Before
@BeforeEach
public void setUp() throws Exception {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();

View File

@@ -23,15 +23,15 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ClusterThreadNodeRunnerAcceptanceTest extends AcceptanceTestBase {
private Node fullNode;
private Cluster noDiscoveryCluster;
@Before
@BeforeEach
public void setUp() throws Exception {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();

View File

@@ -20,14 +20,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class P2pDisabledAcceptanceTest extends AcceptanceTestBase {
private Node node;
private Cluster p2pDisabledCluster;
@Before
@BeforeEach
public void setUp() throws Exception {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();

View File

@@ -20,15 +20,15 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class StaticNodesAcceptanceTest extends AcceptanceTestBase {
private Node otherNode;
private Node node;
@Before
@BeforeEach
public void setUp() throws Exception {
otherNode = besu.createNodeWithNoDiscovery("other-node");
cluster.start(otherNode);

View File

@@ -29,9 +29,9 @@ import org.apache.tuweni.bytes.Bytes32;
import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class BootNodesGenesisSetupTest extends AcceptanceTestBase {
private static final String CURVE_NAME = "secp256k1";
@@ -42,13 +42,13 @@ public class BootNodesGenesisSetupTest extends AcceptanceTestBase {
private Node nodeA;
private Node nodeB;
@BeforeClass
@BeforeAll
public static void environment() {
final X9ECParameters params = SECNamedCurves.getByName(CURVE_NAME);
curve = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
}
@Before
@BeforeEach
public void setUp() throws Exception {
int nodeAP2pBindingPort;
int nodeBP2pBindingPort;

View File

@@ -32,8 +32,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurati
import java.util.List;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class SECP256R1AcceptanceTest extends AcceptanceTestBase {
private Node minerNode;
@@ -49,7 +49,7 @@ public class SECP256R1AcceptanceTest extends AcceptanceTestBase {
private static final SECP256R1 SECP256R1_SIGNATURE_ALGORITHM = new SECP256R1();
@Before
@BeforeEach
public void setUp() throws Exception {
KeyPair minerNodeKeyPair = createKeyPair(MINER_NODE_PRIVATE_KEY);
KeyPair otherNodeKeyPair = createKeyPair(OTHER_NODE_PRIVATE_KEY);

View File

@@ -28,49 +28,31 @@ import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@RunWith(Parameterized.class)
public class DatabaseMigrationAcceptanceTest
extends org.hyperledger.besu.tests.acceptance.AbstractPreexistingNodeTest {
private final long expectedChainHeight;
private BesuNode node;
private final List<AccountData> testAccounts;
public DatabaseMigrationAcceptanceTest(
final String testName,
final String dataPath,
final long expectedChainHeight,
final List<AccountData> testAccounts) {
super(testName, dataPath);
this.expectedChainHeight = expectedChainHeight;
this.testAccounts = testAccounts;
public static Stream<Arguments> getParameters() {
// First 10 blocks of ropsten
return Stream.of(
Arguments.of(
"After versioning was enabled and using multiple RocksDB columns",
"version1",
0xA,
singletonList(
new AccountData(
"0xd1aeb42885a43b72b518182ef893125814811048",
BigInteger.valueOf(0xA),
Wei.fromHexString("0x2B5E3AF16B1880000")))));
}
@Parameters(name = "{0}")
public static Object[][] getParameters() {
return new Object[][] {
// First 10 blocks of ropsten
new Object[] {
"After versioning was enabled and using multiple RocksDB columns",
"version1",
0xA,
singletonList(
new AccountData(
"0xd1aeb42885a43b72b518182ef893125814811048",
BigInteger.valueOf(0xA),
Wei.fromHexString("0x2B5E3AF16B1880000")))
}
};
}
@Before
public void setUp() throws Exception {
public void setUp(final String testName, final String dataPath) throws Exception {
final URL rootURL = DatabaseMigrationAcceptanceTest.class.getResource(dataPath);
hostDataPath = copyDataDir(rootURL);
final Path databaseArchive =
@@ -83,13 +65,27 @@ public class DatabaseMigrationAcceptanceTest
cluster.start(node);
}
@Test
public void shouldReturnCorrectBlockHeight() {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void shouldReturnCorrectBlockHeight(
final String testName,
final String dataPath,
final long expectedChainHeight,
final List<AccountData> testAccounts)
throws Exception {
setUp(testName, dataPath);
blockchain.currentHeight(expectedChainHeight).verify(node);
}
@Test
public void shouldReturnCorrectAccountBalance() {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void shouldReturnCorrectAccountBalance(
final String testName,
final String dataPath,
final long expectedChainHeight,
final List<AccountData> testAccounts)
throws Exception {
setUp(testName, dataPath);
testAccounts.forEach(
accountData ->
accounts

View File

@@ -30,7 +30,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -40,10 +40,12 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
abstract class AbstractJsonRpcTest {
private static final MediaType MEDIA_TYPE_JSON =
protected static final MediaType MEDIA_TYPE_JSON =
MediaType.parse("application/json; charset=utf-8");
static class JsonRpcTestsContext {
@@ -69,16 +71,14 @@ abstract class AbstractJsonRpcTest {
}
private final JsonRpcTestsContext testsContext;
private final URI testCaseFileURI;
public AbstractJsonRpcTest(
final String ignored, final JsonRpcTestsContext testsContext, final URI testCaseFileURI) {
this.testCaseFileURI = testCaseFileURI;
public AbstractJsonRpcTest(final JsonRpcTestsContext testsContext) {
this.testsContext = testsContext;
}
@Test
public void test() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("testCases")
public void test(final URI testCaseFileURI) throws IOException {
final JsonRpcTestCase testCase =
testsContext.mapper.readValue(testCaseFileURI.toURL(), JsonRpcTestCase.class);
@@ -118,7 +118,7 @@ abstract class AbstractJsonRpcTest {
final JsonRpcTestCase testCase,
final URL url) {}
private String getRpcUrl(final String rpcMethod) {
protected String getRpcUrl(final String rpcMethod) {
if (rpcMethod.contains("eth_") || rpcMethod.contains("engine_")) {
return testsContext.besuNode.engineRpcUrl().get();
}
@@ -126,14 +126,12 @@ abstract class AbstractJsonRpcTest {
return testsContext.besuNode.jsonRpcBaseUrl().get();
}
public static Iterable<Object[]> testCases(final String testCasesPath) throws URISyntaxException {
public static Stream<Arguments> testCasesFromPath(final String testCasesPath)
throws URISyntaxException {
final File[] testCasesList =
new File(AbstractJsonRpcTest.class.getResource(testCasesPath).toURI()).listFiles();
return Arrays.stream(testCasesList)
.sorted()
.map(file -> new Object[] {file.getName(), file.toURI()})
.collect(Collectors.toList());
return Arrays.stream(testCasesList).sorted().map(File::toURI).map(Arguments::of);
}
}

View File

@@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class DebugReplayBlockAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/debug/replayBlock/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/debug/replayBlock/test-cases/";
private static AbstractJsonRpcTest.JsonRpcTestsContext testsContext;
public DebugReplayBlockAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public DebugReplayBlockAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class DebugSetHeadAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/debug/setHead/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/debug/setHead/test-cases/";
private static JsonRpcTestsContext testsContext;
public DebugSetHeadAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public DebugSetHeadAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -28,8 +28,8 @@ import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class EthEstimateGasAcceptanceTest extends AcceptanceTestBase {
@@ -38,7 +38,7 @@ public class EthEstimateGasAcceptanceTest extends AcceptanceTestBase {
List<SimpleEntry<Integer, Long>> testCase = new ArrayList<>();
@Before
@BeforeEach
public void setUp() throws Exception {
node =
besu.createMinerNode(

View File

@@ -15,15 +15,13 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class EthGetBlockByNumberAndHashShanghaiAcceptanceTest extends AbstractJsonRpcTest {
private static final String TEST_RESOURCES_DIR = "/jsonrpc/eth/getBlockBy/";
private static final String GENESIS_FILE = TEST_RESOURCES_DIR + "genesis.json";
@@ -31,22 +29,20 @@ public class EthGetBlockByNumberAndHashShanghaiAcceptanceTest extends AbstractJs
private static AbstractJsonRpcTest.JsonRpcTestsContext testsContext;
public EthGetBlockByNumberAndHashShanghaiAcceptanceTest(
final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public EthGetBlockByNumberAndHashShanghaiAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -19,39 +19,35 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.tests.acceptance.dsl.rpc.JsonRpcTestCase;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import okhttp3.Call;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineCancunBlockBuildingAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/cancun/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/cancun/test-cases/block-production";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineCancunBlockBuildingAcceptanceTest(
final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineCancunBlockBuildingAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@Override
@@ -90,7 +86,7 @@ public class ExecutionEngineCancunBlockBuildingAcceptanceTest extends AbstractJs
}
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineEip6110AcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineEip6110AcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineParisAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/paris/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/paris/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineParisAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineParisAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -15,36 +15,32 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineShanghaiAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/shanghai/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/shanghai/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineShanghaiAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineShanghaiAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws Exception {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

View File

@@ -29,8 +29,8 @@ import java.nio.file.Path;
import java.util.Collections;
import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.NetVersion;
@@ -41,7 +41,7 @@ public class Web3JSupportAcceptanceTest extends AcceptanceTestBase {
private Node node;
private Path socketPath;
@Before
@BeforeEach
public void setUp() throws Exception {
socketPath = Files.createTempFile("besu-test-", ".ipc");
node =

View File

@@ -99,10 +99,8 @@ dependencies {
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.testcontainers:testcontainers'
testImplementation 'tech.pegasys.discovery:discovery'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
annotationProcessor 'com.google.dagger:dagger-compiler'
}

View File

@@ -78,6 +78,7 @@ import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask
import org.hyperledger.besu.cli.subcommands.PasswordSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand;
import org.hyperledger.besu.cli.subcommands.RetestethSubCommand;
import org.hyperledger.besu.cli.subcommands.TxParseSubCommand;
import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand;
import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand;
import org.hyperledger.besu.cli.subcommands.operator.OperatorSubCommand;
@@ -145,7 +146,7 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
@@ -1494,6 +1495,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
jsonBlockImporterFactory,
rlpBlockExporterFactory,
commandLine.getOut()));
commandLine.addSubcommand(
TxParseSubCommand.COMMAND_NAME, new TxParseSubCommand(commandLine.getOut()));
commandLine.addSubcommand(
PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut()));
commandLine.addSubcommand(
@@ -2121,8 +2124,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
instantiateSignatureAlgorithmFactory();
logger.info(generateConfigurationOverview());
logger.info("Connecting to {} static nodes.", staticNodes.size());
logger.trace("Static Nodes = {}", staticNodes);
logger.info("Security Module: {}", securityModuleName);
}
@@ -3120,9 +3121,14 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
if (listBootNodes != null) {
if (!p2PDiscoveryOptionGroup.peerDiscoveryEnabled) {
logger.warn("Discovery disabled: bootnodes will be ignored.");
} else {
logger.info("Configured {} bootnodes.", listBootNodes.size());
logger.debug("Bootnodes = {}", listBootNodes);
}
DiscoveryConfiguration.assertValidBootnodes(listBootNodes);
builder.setBootNodes(listBootNodes);
} else {
logger.info("0 Bootnodes configured");
}
return builder.build();
}
@@ -3225,7 +3231,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
staticNodesPath = dataDir().resolve(staticNodesFilename);
}
logger.debug("Static Nodes file: {}", staticNodesPath);
return StaticNodesParser.fromPath(staticNodesPath, getEnodeDnsConfiguration());
final Set<EnodeURL> staticNodes =
StaticNodesParser.fromPath(staticNodesPath, getEnodeDnsConfiguration());
logger.info("Connecting to {} static nodes.", staticNodes.size());
logger.debug("Static Nodes = {}", staticNodes);
return staticNodes;
}
private List<EnodeURL> buildEnodes(
@@ -3237,7 +3247,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
/**
* Besu CLI Paramaters exception handler used by VertX. Visible for testing.
* Besu CLI Parameters exception handler used by VertX. Visible for testing.
*
* @return instance of BesuParameterExceptionHandler
*/
@@ -3517,6 +3527,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
builder.setHasCustomGenesis(genesisFile != null);
if (genesisFile != null) {
builder.setCustomGenesis(genesisFile.getAbsolutePath());
}
builder.setNetworkId(ethNetworkConfig.getNetworkId());
builder

View File

@@ -42,6 +42,7 @@ public class ConfigurationOverviewBuilder {
private String network;
private BigInteger networkId;
private boolean hasCustomGenesis;
private String customGenesisFileName;
private String dataStorage;
private String syncMode;
private Integer rpcPort;
@@ -98,6 +99,17 @@ public class ConfigurationOverviewBuilder {
return this;
}
/**
* Sets location of custom genesis file specified.
*
* @param customGenesisFileName the filename of the custom genesis file, only set if specified
* @return the builder
*/
public ConfigurationOverviewBuilder setCustomGenesis(final String customGenesisFileName) {
this.customGenesisFileName = customGenesisFileName;
return this;
}
/**
* Sets data storage.
*
@@ -269,7 +281,9 @@ public class ConfigurationOverviewBuilder {
}
if (hasCustomGenesis) {
lines.add("Network: Custom genesis file specified");
lines.add("Network: Custom genesis file");
lines.add(
customGenesisFileName == null ? "Custom genesis file is null" : customGenesisFileName);
}
if (networkId != null) {

View File

@@ -19,6 +19,7 @@ import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_INTEGER_FO
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_LONG_FORMAT_HELP;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LAYERED;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LEGACY;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.SEQUENCED;
import org.hyperledger.besu.cli.converter.DurationMillisConverter;
import org.hyperledger.besu.cli.converter.FractionConverter;
@@ -171,10 +172,10 @@ public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfigu
@CommandLine.ArgGroup(
validate = false,
heading = "@|bold Tx Pool Legacy Implementation Options|@%n")
private final Legacy legacyOptions = new Legacy();
heading = "@|bold Tx Pool Sequenced Implementation Options|@%n")
private final Sequenced sequencedOptions = new Sequenced();
static class Legacy {
static class Sequenced {
private static final String TX_POOL_RETENTION_HOURS = "--tx-pool-retention-hours";
private static final String TX_POOL_LIMIT_BY_ACCOUNT_PERCENTAGE =
"--tx-pool-limit-by-account-percentage";
@@ -272,10 +273,10 @@ public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfigu
config.getPendingTransactionsLayerMaxCapacityBytes();
options.layeredOptions.txPoolMaxPrioritized = config.getMaxPrioritizedTransactions();
options.layeredOptions.txPoolMaxFutureBySender = config.getMaxFutureBySender();
options.legacyOptions.txPoolLimitByAccountPercentage =
options.sequencedOptions.txPoolLimitByAccountPercentage =
config.getTxPoolLimitByAccountPercentage();
options.legacyOptions.txPoolMaxSize = config.getTxPoolMaxSize();
options.legacyOptions.pendingTxRetentionPeriod = config.getPendingTxRetentionPeriod();
options.sequencedOptions.txPoolMaxSize = config.getTxPoolMaxSize();
options.sequencedOptions.pendingTxRetentionPeriod = config.getPendingTxRetentionPeriod();
options.unstableOptions.txMessageKeepAliveSeconds =
config.getUnstable().getTxMessageKeepAliveSeconds();
options.unstableOptions.eth65TrxAnnouncedBufferingPeriod =
@@ -295,14 +296,14 @@ public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfigu
final CommandLine commandLine, final GenesisConfigOptions genesisConfigOptions) {
CommandLineUtils.failIfOptionDoesntMeetRequirement(
commandLine,
"Could not use legacy transaction pool options with layered implementation",
"Could not use legacy or sequenced transaction pool options with layered implementation",
!txPoolImplementation.equals(LAYERED),
CommandLineUtils.getCLIOptionNames(Legacy.class));
CommandLineUtils.getCLIOptionNames(Sequenced.class));
CommandLineUtils.failIfOptionDoesntMeetRequirement(
commandLine,
"Could not use layered transaction pool options with legacy implementation",
!txPoolImplementation.equals(LEGACY),
"Could not use layered transaction pool options with legacy or sequenced implementation",
!txPoolImplementation.equals(LEGACY) && !txPoolImplementation.equals(SEQUENCED),
CommandLineUtils.getCLIOptionNames(Layered.class));
CommandLineUtils.failIfOptionDoesntMeetRequirement(
@@ -327,9 +328,9 @@ public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfigu
.pendingTransactionsLayerMaxCapacityBytes(layeredOptions.txPoolLayerMaxCapacity)
.maxPrioritizedTransactions(layeredOptions.txPoolMaxPrioritized)
.maxFutureBySender(layeredOptions.txPoolMaxFutureBySender)
.txPoolLimitByAccountPercentage(legacyOptions.txPoolLimitByAccountPercentage)
.txPoolMaxSize(legacyOptions.txPoolMaxSize)
.pendingTxRetentionPeriod(legacyOptions.pendingTxRetentionPeriod)
.txPoolLimitByAccountPercentage(sequencedOptions.txPoolLimitByAccountPercentage)
.txPoolMaxSize(sequencedOptions.txPoolMaxSize)
.pendingTxRetentionPeriod(sequencedOptions.pendingTxRetentionPeriod)
.unstable(
ImmutableTransactionPoolConfiguration.Unstable.builder()
.txMessageKeepAliveSeconds(unstableOptions.txMessageKeepAliveSeconds)

View File

@@ -0,0 +1,129 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* 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.cli.subcommands;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.cli.subcommands.TxParseSubCommand.COMMAND_NAME;
import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.core.encoding.EncodingContext;
import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes;
import picocli.CommandLine;
/**
* txparse sub command implementing txparse spec from
* https://github.com/holiman/txparse/tree/main/cmd/txparse
*/
@CommandLine.Command(
name = COMMAND_NAME,
description = "Parse input transactions and return the sender, or an error.",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class)
public class TxParseSubCommand implements Runnable {
/** The constant COMMAND_NAME. */
public static final String COMMAND_NAME = "txparse";
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = "--corpus-file",
arity = "1..1",
description = "file to read transaction data lines from, otherwise defaults to stdin")
private String corpusFile = null;
static final BigInteger halfCurveOrder =
SignatureAlgorithmFactory.getInstance().getHalfCurveOrder();
static final BigInteger chainId = new BigInteger("1", 10);
private final PrintWriter out;
/**
* Instantiates a new TxParse sub command.
*
* @param out the PrintWriter where validation results will be reported.
*/
public TxParseSubCommand(final PrintWriter out) {
this.out = out;
}
@SuppressWarnings("StreamResourceLeak")
Stream<String> fileStreamReader(final String filePath) {
try {
return Files.lines(Paths.get(filePath))
// skip comments
.filter(line -> !line.startsWith("#"))
// strip out non-alphanumeric characters
.map(line -> line.replaceAll("[^a-zA-Z0-9]", ""));
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public void run() {
Stream<String> txStream;
if (corpusFile != null) {
txStream = fileStreamReader(corpusFile);
} else {
txStream = new BufferedReader(new InputStreamReader(System.in, UTF_8)).lines();
}
txStream.forEach(
line -> {
try {
Bytes bytes = Bytes.fromHexStringLenient(line);
dump(bytes);
} catch (Exception ex) {
err(ex.getMessage());
}
});
}
void dump(final Bytes tx) {
try {
var transaction = TransactionDecoder.decodeOpaqueBytes(tx, EncodingContext.BLOCK_BODY);
// https://github.com/hyperledger/besu/blob/5fe49c60b30fe2954c7967e8475c3b3e9afecf35/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java#L252
if (transaction.getChainId().isPresent() && !transaction.getChainId().get().equals(chainId)) {
throw new Exception("wrong chain id");
}
// https://github.com/hyperledger/besu/blob/5fe49c60b30fe2954c7967e8475c3b3e9afecf35/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java#L270
if (transaction.getS().compareTo(halfCurveOrder) > 0) {
throw new Exception("signature s out of range");
}
out.println(transaction.getSender());
} catch (Exception ex) {
err(ex.getMessage());
}
}
void err(final String message) {
out.println("err: " + message);
}
}

View File

@@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.api.query.StateBackupService;
import org.hyperledger.besu.ethereum.api.query.StateBackupService.BackupStatus;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -82,7 +82,7 @@ public class BackupState implements Runnable {
final BesuController besuController = createBesuController();
final MutableBlockchain blockchain = besuController.getProtocolContext().getBlockchain();
final WorldStateStorage worldStateStorage =
((DefaultWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
.getWorldStateStorage();
final EthScheduler scheduler = new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem());
try {

View File

@@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.Node;
import org.hyperledger.besu.ethereum.trie.PersistVisitor;
import org.hyperledger.besu.ethereum.trie.RestoreVisitor;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.util.io.RollingFileReader;
@@ -250,7 +250,7 @@ public class RestoreState implements Runnable {
updater.commit();
}
final WorldStateStorage worldStateStorage =
((DefaultWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
.getWorldStateStorage();
updater = worldStateStorage.updater();
}

View File

@@ -17,10 +17,10 @@
package org.hyperledger.besu.components;
import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoaderModule;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoaderModule;
import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.services.BesuPluginContextImpl;

View File

@@ -31,10 +31,6 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage;
import org.hyperledger.besu.ethereum.chain.ChainDataPruner;
@@ -84,12 +80,16 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.pruner.MarkSweepPruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.MarkSweepPruner;
import org.hyperledger.besu.ethereum.worldstate.Pruner;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@@ -657,7 +657,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
Optional.of(
new Pruner(
new MarkSweepPruner(
((DefaultWorldStateArchive) worldStateArchive).getWorldStateStorage(),
((ForestWorldStateArchive) worldStateArchive).getWorldStateStorage(),
blockchain,
storageProvider.getStorageBySegmentIdentifier(
KeyValueSegmentIdentifier.PRUNING_STATE),
@@ -1093,7 +1093,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
case FOREST -> {
final WorldStatePreimageStorage preimageStorage =
storageProvider.createWorldStatePreimageStorage();
yield new DefaultWorldStateArchive(worldStateStorage, preimageStorage, evmConfiguration);
yield new ForestWorldStateArchive(worldStateStorage, preimageStorage, evmConfiguration);
}
};
}

View File

@@ -56,8 +56,8 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;

View File

@@ -52,9 +52,9 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.Pruner;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

View File

@@ -147,8 +147,9 @@ public class ForkIdsNetworkConfigTest {
new ForkId(Bytes.ofUnsignedInt(0x9007bfccL), 11700000L),
new ForkId(Bytes.ofUnsignedInt(0xdb63a1caL), 13189133),
new ForkId(Bytes.ofUnsignedInt(0x0f6bf187L), 14525000L),
new ForkId(Bytes.ofUnsignedInt(0x7fd1bb25L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x7fd1bb25L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x7fd1bb25L), 19250000L),
new ForkId(Bytes.ofUnsignedInt(0xbe46d57cL), 0L),
new ForkId(Bytes.ofUnsignedInt(0xbe46d57cL), 0L))
});
}

View File

@@ -46,29 +46,30 @@ import org.hyperledger.besu.testutil.TestClock;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.junit.jupiter.MockitoExtension;
/** Tests for {@link BlockExporter}. */
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public final class RlpBlockExporterTest {
@ClassRule public static final TemporaryFolder folder = new TemporaryFolder();
@TempDir public static Path folder;
private static Blockchain blockchain;
private static long chainHead;
private static ProtocolSchedule protocolSchedule;
@BeforeClass
@BeforeAll
public static void setupBlockchain() throws IOException {
final BesuController controller = createController();
final Path blocks = folder.newFile("1000.blocks").toPath();
final BesuController controller =
createController(Files.createTempDirectory(folder, "rlpBlockExporterTestData"));
final Path blocks = Files.createTempFile(folder, "1000", "blocks");
BlockTestUtil.write1000Blocks(blocks);
blockchain = importBlocks(controller, blocks);
chainHead = blockchain.getChainHeadBlockNumber();
@@ -83,8 +84,7 @@ public final class RlpBlockExporterTest {
return controller.getProtocolContext().getBlockchain();
}
private static BesuController createController() throws IOException {
final Path dataDir = folder.newFolder().toPath();
private static BesuController createController(final @TempDir Path dataDir) throws IOException {
return new BesuController.Builder()
.fromGenesisConfig(GenesisConfigFile.mainnet(), SyncMode.FAST)
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())
@@ -105,13 +105,13 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_noBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_noBounds(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
exporter.exportBlocks(outputPath, Optional.empty(), Optional.empty());
exporter.exportBlocks(outputPath.toFile(), Optional.empty(), Optional.empty());
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = 0;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@@ -125,15 +125,15 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withLowerBound() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withLowerBound(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = 990;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.empty());
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.empty());
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@@ -147,15 +147,15 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withUpperBound() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withUpperBound(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long upperBound = 10;
exporter.exportBlocks(outputPath, Optional.empty(), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.empty(), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = 0;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@@ -169,16 +169,17 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withUpperAndLowerBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withUpperAndLowerBounds(final @TempDir Path outputDir)
throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = 5;
final long upperBound = 10;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@@ -192,16 +193,17 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withRangeBeyondChainHead() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withRangeBeyondChainHead(final @TempDir Path outputDir)
throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = chainHead - 10;
final long upperBound = chainHead + 10;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@@ -215,8 +217,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_negativeStartNumber() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_negativeStartNumber(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.of(-1L), Optional.empty()))
@@ -225,8 +226,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_negativeEndNumber() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_negativeEndNumber(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.empty(), Optional.of(-1L)))
@@ -235,8 +235,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_outOfOrderBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_outOfOrderBounds(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.of(10L), Optional.of(2L)))

View File

@@ -48,29 +48,28 @@ import java.math.BigInteger;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public abstract class JsonBlockImporterTest {
@Rule public final TemporaryFolder folder = new TemporaryFolder();
@TempDir public Path dataDir;
protected final String consensusEngine;
protected final GenesisConfigFile genesisConfigFile;
protected final boolean isEthash;
protected String consensusEngine;
protected GenesisConfigFile genesisConfigFile;
protected boolean isEthash;
protected JsonBlockImporterTest(final String consensusEngine) throws IOException {
protected void setup(final String consensusEngine) throws IOException {
this.consensusEngine = consensusEngine;
final String genesisData = getFileContents("genesis.json");
this.genesisConfigFile = GenesisConfigFile.fromConfig(genesisData);
@@ -78,8 +77,10 @@ public abstract class JsonBlockImporterTest {
}
public static class SingletonTests extends JsonBlockImporterTest {
public SingletonTests() throws IOException {
super("unsupported");
@BeforeEach
public void setup() throws IOException {
super.setup("unsupported");
}
@Test
@@ -97,21 +98,23 @@ public abstract class JsonBlockImporterTest {
}
}
@RunWith(Parameterized.class)
public static class ParameterizedTests extends JsonBlockImporterTest {
public ParameterizedTests(final String consensusEngine) throws IOException {
super(consensusEngine);
@Override
public void setup(final String consensusEngine) throws IOException {
super.setup(consensusEngine);
}
@Parameters(name = "Name: {0}")
public static Collection<Object[]> getParameters() {
final Object[][] params = {{"ethash"}, {"clique"}};
return Arrays.asList(params);
public static Stream<Arguments> getParameters() {
return Stream.of(Arguments.of("ethash"), Arguments.of("clique"));
}
@Test
public void importChain_validJson_withBlockNumbers() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_withBlockNumbers(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -201,8 +204,12 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(1L);
}
@Test
public void importChain_validJson_noBlockIdentifiers() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_noBlockIdentifiers(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -292,8 +299,12 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(1L);
}
@Test
public void importChain_validJson_withParentHashes() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_withParentHashes(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -343,8 +354,11 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(2L);
}
@Test
public void importChain_invalidParent() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_invalidParent(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -355,8 +369,11 @@ public abstract class JsonBlockImporterTest {
.hasMessageStartingWith("Unable to locate block parent at 2456");
}
@Test
public void importChain_invalidTransaction() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_invalidTransaction(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -368,8 +385,11 @@ public abstract class JsonBlockImporterTest {
"Unable to create block. 1 transaction(s) were found to be invalid.");
}
@Test
public void importChain_specialFields() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_specialFields(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@@ -414,7 +434,6 @@ public abstract class JsonBlockImporterTest {
protected BesuController createController(final GenesisConfigFile genesisConfigFile)
throws IOException {
final Path dataDir = folder.newFolder().toPath();
return new BesuController.Builder()
.fromGenesisConfig(genesisConfigFile, SyncMode.FAST)
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())

View File

@@ -83,8 +83,8 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
import org.hyperledger.besu.metrics.StandardMetricCategory;
@@ -127,19 +127,18 @@ import org.apache.commons.text.StringEscapeUtils;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlParseResult;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuCommandTest extends CommandTestAbstract {
private static final String ENCLAVE_URI = "http://1.2.3.4:5555";
@@ -198,7 +197,7 @@ public class BesuCommandTest extends CommandTestAbstract {
DEFAULT_API_CONFIGURATION = ImmutableApiConfiguration.builder().build();
}
@Before
@BeforeEach
public void setup() {
try {
// optimistically tear down a potential previous loaded trusted setup
@@ -210,7 +209,7 @@ public class BesuCommandTest extends CommandTestAbstract {
MergeConfigOptions.setMergeEnabled(false);
}
@After
@AfterEach
public void tearDown() {
MergeConfigOptions.setMergeEnabled(false);
@@ -366,10 +365,10 @@ public class BesuCommandTest extends CommandTestAbstract {
}
@Test
public void overrideDefaultValuesIfKeyIsPresentInConfigFile() throws IOException {
public void overrideDefaultValuesIfKeyIsPresentInConfigFile(final @TempDir File dataFolder)
throws IOException {
final URL configFile = this.getClass().getResource("/complete_config.toml");
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
final File dataFolder = temp.newFolder();
final String updatedConfig =
Resources.toString(configFile, UTF_8)
.replace("/opt/besu/genesis.json", escapeTomlString(genesisFile.toString()))
@@ -3745,7 +3744,7 @@ public class BesuCommandTest extends CommandTestAbstract {
});
}
@Ignore
@Disabled
public void pruningIsEnabledIfSyncModeIsFast() {
parseCommand("--sync-mode", "FAST");
@@ -3756,7 +3755,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Ignore
@Disabled
public void pruningIsDisabledIfSyncModeIsFull() {
parseCommand("--sync-mode", "FULL");
@@ -3778,7 +3777,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Ignore
@Disabled
public void pruningDisabledExplicitly() {
parseCommand("--pruning-enabled=false", "--sync-mode=FAST");
@@ -4373,14 +4372,11 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
}
@Rule public TemporaryFolder testFolder = new TemporaryFolder();
@Test
public void errorIsRaisedIfStaticNodesAreNotAllowed() throws IOException {
final File staticNodesFile = testFolder.newFile("static-nodes.json");
staticNodesFile.deleteOnExit();
final File permissioningConfig = testFolder.newFile("permissioning");
permissioningConfig.deleteOnExit();
public void errorIsRaisedIfStaticNodesAreNotAllowed(final @TempDir Path testFolder)
throws IOException {
final Path staticNodesFile = testFolder.resolve("static-nodes.json");
final Path permissioningConfig = testFolder.resolve("permissioning.json");
final EnodeURL staticNodeURI =
EnodeURLImpl.builder()
@@ -4399,17 +4395,16 @@ public class BesuCommandTest extends CommandTestAbstract {
.listeningPort(30304)
.build();
Files.write(staticNodesFile, ("[\"" + staticNodeURI.toString() + "\"]").getBytes(UTF_8));
Files.write(
staticNodesFile.toPath(), ("[\"" + staticNodeURI.toString() + "\"]").getBytes(UTF_8));
Files.write(
permissioningConfig.toPath(),
permissioningConfig,
("nodes-allowlist=[\"" + allowedNode.toString() + "\"]").getBytes(UTF_8));
parseCommand(
"--data-path=" + testFolder.getRoot().getPath(),
"--data-path=" + testFolder,
"--bootnodes",
"--permissions-nodes-config-file-enabled=true",
"--permissions-nodes-config-file=" + permissioningConfig.getPath());
"--permissions-nodes-config-file=" + permissioningConfig);
assertThat(commandErrorOutput.toString(UTF_8))
.contains(staticNodeURI.toString(), "not in nodes-allowlist");
}
@@ -4985,12 +4980,10 @@ public class BesuCommandTest extends CommandTestAbstract {
"File containing password to unlock keystore is required when PKI Block Creation is enabled");
}
@Rule public TemporaryFolder pkiTempFolder = new TemporaryFolder();
@Test
public void pkiBlockCreationFullConfig() throws Exception {
public void pkiBlockCreationFullConfig(final @TempDir Path pkiTempFolder) throws Exception {
// Create temp file with password
final File pwdFile = pkiTempFolder.newFile("pwd");
final File pwdFile = pkiTempFolder.resolve("pwd").toFile();
FileUtils.writeStringToFile(pwdFile, "foo", UTF_8);
parseCommand(

View File

@@ -35,18 +35,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CommandLineUtilsTest {
@SuppressWarnings("PrivateStaticFinalLoggers") // @Mocks are inited by JUnit
@Mock

View File

@@ -112,22 +112,20 @@ import io.vertx.core.json.JsonObject;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public abstract class CommandTestAbstract {
private static final Logger TEST_LOGGER = LoggerFactory.getLogger(CommandTestAbstract.class);
protected static final JsonObject VALID_GENESIS_QBFT_POST_LONDON =
@@ -156,17 +154,30 @@ public abstract class CommandTestAbstract {
protected static final RpcEndpointServiceImpl rpcEndpointServiceImpl =
new RpcEndpointServiceImpl();
@Mock protected RunnerBuilder mockRunnerBuilder;
@Mock(lenient = true)
protected RunnerBuilder mockRunnerBuilder;
@Mock protected Runner mockRunner;
@Mock protected BesuController.Builder mockControllerBuilderFactory;
@Mock(lenient = true)
protected BesuController.Builder mockControllerBuilderFactory;
@Mock(lenient = true)
protected BesuControllerBuilder mockControllerBuilder;
@Mock(lenient = true)
protected EthProtocolManager mockEthProtocolManager;
@Mock protected BesuControllerBuilder mockControllerBuilder;
@Mock protected EthProtocolManager mockEthProtocolManager;
@Mock protected ProtocolSchedule mockProtocolSchedule;
@Mock protected ProtocolContext mockProtocolContext;
@Mock(lenient = true)
protected ProtocolContext mockProtocolContext;
@Mock protected BlockBroadcaster mockBlockBroadcaster;
@Mock protected BesuController mockController;
@Mock(lenient = true)
protected BesuController mockController;
@Mock protected RlpBlockExporter rlpBlockExporter;
@Mock protected JsonBlockImporter jsonBlockImporter;
@Mock protected RlpBlockImporter rlpBlockImporter;
@@ -188,7 +199,8 @@ public abstract class CommandTestAbstract {
@Mock
protected Logger mockLogger;
@Mock protected BesuComponent mockBesuComponent;
@Mock(lenient = true)
protected BesuComponent mockBesuComponent;
@Mock protected PkiBlockCreationConfigurationProvider mockPkiBlockCreationConfigProvider;
@Mock protected PkiBlockCreationConfiguration mockPkiBlockCreationConfiguration;
@@ -218,9 +230,7 @@ public abstract class CommandTestAbstract {
@Captor protected ArgumentCaptor<EthstatsOptions> ethstatsOptionsArgumentCaptor;
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@Before
@BeforeEach
public void initMocks() throws Exception {
// doReturn used because of generic BesuController
doReturn(mockControllerBuilder)
@@ -353,7 +363,7 @@ public abstract class CommandTestAbstract {
when(mockBesuComponent.getBesuCommandLogger()).thenReturn(mockLogger);
}
@Before
@BeforeEach
public void setUpStreams() {
// reset the global opentelemetry singleton
GlobalOpenTelemetry.resetForTest();
@@ -364,7 +374,7 @@ public abstract class CommandTestAbstract {
}
// Display outputs for debug purpose
@After
@AfterEach
public void displayOutput() throws IOException {
TEST_LOGGER.info("Standard output {}", commandOutput.toString(UTF_8));
TEST_LOGGER.info("Standard error {}", commandErrorOutput.toString(UTF_8));

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.cli;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LAYERED;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LEGACY;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.SEQUENCED;
import static org.mockito.Mockito.mock;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
@@ -57,8 +58,9 @@ class ConfigurationOverviewBuilderTest {
assertThat(networkSet).contains("Network: foobar");
builder.setHasCustomGenesis(true);
builder.setCustomGenesis("file.name");
final String genesisSet = builder.build();
assertThat(genesisSet).contains("Network: Custom genesis file specified");
assertThat(genesisSet).contains("Network: Custom genesis file");
assertThat(genesisSet).doesNotContain("Network: foobar");
}
@@ -180,6 +182,13 @@ class ConfigurationOverviewBuilderTest {
assertThat(legacyTxPoolSelected).contains("Using LEGACY transaction pool implementation");
}
@Test
void setTxPoolImplementationSequenced() {
builder.setTxPoolImplementation(SEQUENCED);
final String sequencedTxPoolSelected = builder.build();
assertThat(sequencedTxPoolSelected).contains("Using SEQUENCED transaction pool implementation");
}
@Test
void setWorldStateUpdateModeDefault() {
builder.setWorldStateUpdateMode(EvmConfiguration.DEFAULT.worldUpdaterMode());

View File

@@ -21,13 +21,13 @@ import org.hyperledger.besu.cli.util.EnvironmentVariableDefaultProvider;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.Model.PositionalParamSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class EnvironmentVariableDefaultProviderTest {
private final Map<String, String> environment = new HashMap<>();

View File

@@ -19,12 +19,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.BesuInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PasswordSubCommandTest extends CommandTestAbstract {
@Test

View File

@@ -35,14 +35,14 @@ import org.apache.tuweni.bytes.Bytes32;
import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PublicKeySubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_PUBLIC_KEY_USAGE =
@@ -126,13 +126,13 @@ public class PublicKeySubCommandTest extends CommandTestAbstract {
private static final String ALGORITHM = SignatureAlgorithm.ALGORITHM;
private static ECDomainParameters curve;
@BeforeClass
@BeforeAll
public static void setUp() {
final X9ECParameters params = SECNamedCurves.getByName(CURVE_NAME);
curve = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
}
@Before
@BeforeEach
public void before() {
SignatureAlgorithmFactory.resetInstance();
}

View File

@@ -26,31 +26,29 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.ParameterException;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TomlConfigFileDefaultProviderTest {
@Mock CommandLine mockCommandLine;
@Mock CommandSpec mockCommandSpec;
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@Test
public void defaultValueForMatchingKey() throws IOException {
public void defaultValueForMatchingKey(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
validOptionsMap.put("--a-short-option", null);
@@ -58,7 +56,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--a-longer-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
try (final BufferedWriter fileWriter =
Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8)) {
@@ -106,7 +104,7 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void defaultValueForOptionMustMatchType() throws IOException {
public void defaultValueForOptionMustMatchType(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
validOptionsMap.put("--a-boolean-option", null);
@@ -124,7 +122,7 @@ public class TomlConfigFileDefaultProviderTest {
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
try (final BufferedWriter fileWriter =
Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8)) {
@@ -238,9 +236,9 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void invalidConfigMustThrow() throws IOException {
public void invalidConfigMustThrow(final @TempDir Path temp) throws IOException {
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = Files.createTempFile("invalid", "toml").toFile();
final TomlConfigFileDefaultProvider providerUnderTest =
new TomlConfigFileDefaultProvider(mockCommandLine, tempConfigFile);
@@ -254,9 +252,9 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void invalidConfigContentMustThrow() throws IOException {
public void invalidConfigContentMustThrow(final @TempDir Path temp) throws IOException {
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("an-invalid-syntax=======....");
@@ -276,13 +274,13 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void unknownOptionMustThrow() throws IOException {
public void unknownOptionMustThrow(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("invalid_option=true");
@@ -300,7 +298,7 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void tomlTableHeadingsMustBeIgnored() throws IOException {
public void tomlTableHeadingsMustBeIgnored(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
@@ -310,7 +308,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--onemore-valid-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("a-valid-option=123");
@@ -343,7 +341,8 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void tomlTableHeadingsMustNotSkipValidationOfUnknownOptions() throws IOException {
public void tomlTableHeadingsMustNotSkipValidationOfUnknownOptions(final @TempDir Path temp)
throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
@@ -351,7 +350,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--a-valid-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("[ignoreme]");

View File

@@ -25,12 +25,12 @@ import java.nio.file.Files;
import java.nio.file.Path;
import com.google.common.io.Resources;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ValidateConfigSubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_PUBLIC_KEY_USAGE =

View File

@@ -23,11 +23,11 @@ import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfigura
import java.math.BigInteger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class EthNetworkConfigTest {
@Test

View File

@@ -20,11 +20,11 @@ import static org.assertj.core.api.Assertions.catchThrowable;
import org.hyperledger.besu.cli.converter.exception.FractionConversionException;
import org.hyperledger.besu.util.number.Fraction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class FractionConverterTest {
private final FractionConverter fractionConverter = new FractionConverter();

View File

@@ -20,20 +20,20 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MetricCategoryConverterTest {
private MetricCategoryConverter metricCategoryConverter;
@Mock MetricCategory metricCategory;
@Before
@BeforeEach
public void setUp() {
metricCategoryConverter = new MetricCategoryConverter();
}

View File

@@ -20,11 +20,11 @@ import static org.assertj.core.api.Assertions.catchThrowable;
import org.hyperledger.besu.cli.converter.exception.PercentageConversionException;
import org.hyperledger.besu.util.number.Percentage;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PercentageConverterTest {
private final PercentageConverter percentageConverter = new PercentageConverter();

View File

@@ -17,14 +17,14 @@ package org.hyperledger.besu.cli.custom;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.ParameterException;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
@ExtendWith(MockitoExtension.class)
public class RpcAuthFileValidatorTest {
private static final String CORRECT_TOML = "/rpcauth/auth_correct.toml";

View File

@@ -52,13 +52,13 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.json.JsonObject;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class OperatorSubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_OPERATOR_USAGE =
@@ -80,7 +80,7 @@ public class OperatorSubCommandTest extends CommandTestAbstract {
private Path tmpOutputDirectoryPath;
@Before
@BeforeEach
public void init() throws IOException {
SignatureAlgorithmFactory.resetInstance();
tmpOutputDirectoryPath = createTempDirectory(format("output-%d", currentTimeMillis()));

View File

@@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public abstract class AbstractCLIOptionsTest<D, T extends CLIOptions<D>>
extends CommandTestAbstract {

View File

@@ -21,11 +21,11 @@ import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class EthProtocolOptionsTest
extends AbstractCLIOptionsTest<EthProtocolConfiguration, EthProtocolOptions> {

View File

@@ -17,10 +17,10 @@ package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MetricsCLIOptionsTest
extends AbstractCLIOptionsTest<MetricsConfiguration.Builder, MetricsCLIOptions> {

View File

@@ -35,12 +35,12 @@ import java.nio.file.Path;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters, MiningOptions> {
@Test

View File

@@ -23,11 +23,11 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class NetworkingOptionsTest
extends AbstractCLIOptionsTest<NetworkingConfiguration, NetworkingOptions> {

View File

@@ -21,11 +21,11 @@ import java.math.BigInteger;
import com.google.common.collect.Range;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class OptionParserTest {
@Test

View File

@@ -23,10 +23,10 @@ import java.util.Arrays;
import java.util.List;
import com.google.common.collect.Range;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SynchronizerOptionsTest
extends AbstractCLIOptionsTest<SynchronizerConfiguration.Builder, SynchronizerOptions> {

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LAYERED;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LEGACY;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.SEQUENCED;
import org.hyperledger.besu.cli.converter.DurationMillisConverter;
import org.hyperledger.besu.datatypes.Address;
@@ -27,11 +28,11 @@ import org.hyperledger.besu.util.number.Percentage;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TransactionPoolOptionsTest
extends AbstractCLIOptionsTest<TransactionPoolConfiguration, TransactionPoolOptions> {
@@ -63,7 +64,7 @@ public class TransactionPoolOptionsTest
}
@Test
public void pendingTransactionRetentionPeriod() {
public void pendingTransactionRetentionPeriodLegacy() {
final int pendingTxRetentionHours = 999;
internalTestSuccess(
config ->
@@ -73,6 +74,17 @@ public class TransactionPoolOptionsTest
"--tx-pool=legacy");
}
@Test
public void pendingTransactionRetentionPeriodSequenced() {
final int pendingTxRetentionHours = 999;
internalTestSuccess(
config ->
assertThat(config.getPendingTxRetentionPeriod()).isEqualTo(pendingTxRetentionHours),
"--tx-pool-retention-hours",
String.valueOf(pendingTxRetentionHours),
"--tx-pool=sequenced");
}
@Test
public void disableLocalsDefault() {
internalTestSuccess(config -> assertThat(config.getNoLocalPriority()).isFalse());
@@ -193,17 +205,24 @@ public class TransactionPoolOptionsTest
"--tx-pool=legacy");
}
@Test
public void selectSequencedImplementationByArg() {
internalTestSuccess(
config -> assertThat(config.getTxPoolImplementation()).isEqualTo(SEQUENCED),
"--tx-pool=sequenced");
}
@Test
public void failIfLegacyOptionsWhenLayeredSelectedByDefault() {
internalTestFailure(
"Could not use legacy transaction pool options with layered implementation",
"Could not use legacy or sequenced transaction pool options with layered implementation",
"--tx-pool-max-size=1000");
}
@Test
public void failIfLegacyOptionsWhenLayeredSelectedByArg() {
internalTestFailure(
"Could not use legacy transaction pool options with layered implementation",
"Could not use legacy or sequenced transaction pool options with layered implementation",
"--tx-pool=layered",
"--tx-pool-max-size=1000");
}
@@ -211,11 +230,19 @@ public class TransactionPoolOptionsTest
@Test
public void failIfLayeredOptionsWhenLegacySelectedByArg() {
internalTestFailure(
"Could not use layered transaction pool options with legacy implementation",
"Could not use layered transaction pool options with legacy or sequenced implementation",
"--tx-pool=legacy",
"--tx-pool-max-prioritized=1000");
}
@Test
public void failIfLayeredOptionsWhenSequencedSelectedByArg() {
internalTestFailure(
"Could not use layered transaction pool options with legacy or sequenced implementation",
"--tx-pool=sequenced",
"--tx-pool-max-prioritized=1000");
}
@Test
public void byDefaultNoPrioritySenders() {
internalTestSuccess(config -> assertThat(config.getPrioritySenders()).isEmpty());

View File

@@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class DataStorageOptionsTest
extends AbstractCLIOptionsTest<DataStorageConfiguration, DataStorageOptions> {

View File

@@ -21,8 +21,8 @@ import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import java.util.Arrays;
import org.apache.logging.log4j.Level;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.ParameterException;
@@ -31,7 +31,7 @@ public class LoggingLevelOptionTest {
private LoggingLevelOption levelOption;
@Before
@BeforeEach
public void setUp() {
levelOption = new LoggingLevelOption();
}

View File

@@ -24,11 +24,12 @@ import org.hyperledger.besu.cli.CommandTestAbstract;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import picocli.CommandLine.Model.CommandSpec;
public class RLPSubCommandTest extends CommandTestAbstract {
@@ -158,31 +159,10 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithInputFilePathMustReadFromThisFile() throws Exception {
final File tempJsonFile = temp.newFile("test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
fileWriter.write(
"[\"be068f726a13c8d46c44be6ce9d275600e1735a4\", \"5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193\"]");
fileWriter.flush();
parseCommand(
RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
final String expectedRlpString =
"0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d"
+ "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0";
assertThat(commandOutput.toString(UTF_8)).contains(expectedRlpString);
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
}
@Test
public void canEncodeToQbftExtraData() throws IOException {
final File tempJsonFile = temp.newFile("test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
public void encodeWithInputFilePathMustReadFromThisFile(final @TempDir Path dir)
throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "input", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write(
"[\"be068f726a13c8d46c44be6ce9d275600e1735a4\", \"5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193\"]");
@@ -193,7 +173,31 @@ public class RLPSubCommandTest extends CommandTestAbstract {
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.getPath(),
tempJsonFile.toFile().getAbsolutePath());
final String expectedRlpString =
"0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d"
+ "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0";
assertThat(commandOutput.toString(UTF_8)).contains(expectedRlpString);
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
}
@Test
public void canEncodeToQbftExtraData(final @TempDir Path dir) throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "qbft", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write(
"[\"be068f726a13c8d46c44be6ce9d275600e1735a4\", \"5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193\"]");
fileWriter.flush();
parseCommand(
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.toFile().getAbsolutePath(),
"--type",
RLP_QBFT_TYPE);
@@ -206,17 +210,19 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithInvalidInputMustRaiseAnError() throws Exception {
final File tempJsonFile = temp.newFile("invalid_test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
public void encodeWithInvalidInputMustRaiseAnError(final @TempDir Path dir) throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "invalid", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write("{\"property\":0}");
fileWriter.flush();
parseCommand(
RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -226,11 +232,13 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithEmptyInputMustRaiseAnError() throws Exception {
final File tempJsonFile = temp.newFile("empty.json");
parseCommand(RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
public void encodeWithEmptyInputMustRaiseAnError(final @TempDir Path dir) throws Exception {
final Path emptyFile = Files.createTempFile(dir, "empty", "json");
parseCommand(
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
emptyFile.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -251,7 +259,7 @@ public class RLPSubCommandTest extends CommandTestAbstract {
.startsWith("An error occurred while trying to read the JSON data.");
}
@After
@AfterEach
public void restoreStdin() {
System.setIn(System.in);
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* 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.cli.subcommands;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
public class TxParseSubCommandTest {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(baos, UTF_8), true);
TxParseSubCommand txParseSubCommand = new TxParseSubCommand(writer);
@Test
public void smokeTest() {
txParseSubCommand.dump(
Bytes.fromHexString(
"0x02f875018363bc5a8477359400850c570bd200825208943893d427c770de9b92065da03a8c825f13498da28702fbf8ccf8530480c080a0dd49141ecf93eeeaed5f3499a6103d6a9778e24a37b1f5c6a336c60c8a078c15a0511b51a3050771f66c1b779210a46a51be521a2446a3f87fc656dcfd1782aa5e"));
String output = baos.toString(UTF_8);
assertThat(output).isEqualTo("0xeb2629a2734e272bcc07bda959863f316f4bd4cf\n");
}
@Test
public void assertInvalidRlp() {
txParseSubCommand.dump(
Bytes.fromHexString(
"0x03f90124f9011e010516058261a89403040500000000000000000000000000000000006383000000f8b6f859940000000000000000000000000000000074657374f842a00100000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940000000000000000000000000000000074657374f842a00100000000000000000000000000000000000000000000000000000000000000a002000000000000000000000000000000000000000000000000000000000000000fc080a082f96cae43a3f2554cad899a6e9168a3cd613454f82e93488f9b4c1a998cc814a06b7519cd0e3159d6ce9bf811ff3ca4e9c5d7ac63fc52142370a0725e4c5273b2c0c0c0"));
String output = baos.toString(UTF_8);
assertThat(output).startsWith("err: ");
assertThat(output).contains("arbitrary precision scalar");
}
@Test
public void assertValidRlp() {
txParseSubCommand.dump(
Bytes.fromHexString(
"0x03f9013f010516058261a89403040500000000000000000000000000000000006383000000f8b6f859940000000000000000000000000000000074657374f842a00100000000000000000000000000000000000000000000000000000000000000a00200000000000000000000000000000000000000000000000000000000000000f859940000000000000000000000000000000074657374f842a00100000000000000000000000000000000000000000000000000000000000000a002000000000000000000000000000000000000000000000000000000000000000fe1a0010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c44401401a0d98465c5489a09933e6428657f1fc4461d49febd8556c1c7e7053ed0be49cc4fa02c0d67e40aed75f87ea640cc47064d79f4383e24dec283ac6eb81e19da46cc26"));
String output = baos.toString(UTF_8);
assertThat(output).isEqualTo("0x730aa72228b55236de378f5267dfc77723b1380c\n");
}
@Test
public void assertInvalidChainId() {
txParseSubCommand.dump(
Bytes.fromHexString(
"0xf901fc303083303030803030b901ae30303030303030303030433030303030303030303030303030303030303030303030303030303030203030413030303030303030303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038390030000000002800380000413159000021000000002b0000000000003800000000003800000000000000000000002b633279315a00633200303041374222610063416200325832325a002543323861795930314130383058435931317a633043304239623900310031254363384361000023433158253041380037000027285839005a007937000000623700002761002b5a003937622e000000006300007863410000002a2e320000000000005a0000000000000037242778002039006120412e6362002138300000002a313030303030303030303030373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030a03030303030303030303030303030303030303030303030303030303030303030a03030303030303030303030303030303030303030303030303030303030303030"));
String output = baos.toString(UTF_8);
assertThat(output).isEqualTo("err: wrong chain id\n");
}
}

View File

@@ -36,17 +36,16 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BlocksSubCommandTest extends CommandTestAbstract {
@Rule public final TemporaryFolder folder = new TemporaryFolder();
@TempDir public Path folder;
private static final String EXPECTED_BLOCK_USAGE =
"Usage: besu blocks [-hV] [COMMAND]"
@@ -187,10 +186,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void callingBlockImportSubCommandWithPathMustImportBlocksWithThisPath() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
public void callingBlockImportSubCommandWithPathMustImportBlocksWithThisPath(
final @TempDir File fileToImport) throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME, BLOCK_IMPORT_SUBCOMMAND_NAME, "--from", fileToImport.getPath());
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
"--from",
fileToImport.getAbsolutePath().toString());
verify(rlpBlockImporter)
.importBlockchain(pathArgumentCaptor.capture(), any(), anyBoolean(), anyLong(), anyLong());
@@ -202,8 +204,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_rlpFormat() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
public void blocksImport_rlpFormat(final @TempDir File fileToImport) throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
@@ -222,10 +223,11 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_rlpFormatMultiple() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
final File file2ToImport = temp.newFile("blocks2.file");
final File file3ToImport = temp.newFile("blocks3.file");
public void blocksImport_rlpFormatMultiple(
final @TempDir File fileToImport,
final @TempDir File file2ToImport,
final @TempDir File file3ToImport)
throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
@@ -247,10 +249,10 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_jsonFormat() throws Exception {
public void blocksImport_jsonFormat(final @TempDir Path dir) throws Exception {
final String fileContent = "test";
final File fileToImport = temp.newFile("blocks.file");
final Writer fileWriter = Files.newBufferedWriter(fileToImport.toPath(), UTF_8);
final Path fileToImport = Files.createTempFile(dir, "tmp", "json");
final Writer fileWriter = Files.newBufferedWriter(fileToImport, UTF_8);
fileWriter.write(fileContent);
fileWriter.close();
@@ -260,7 +262,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
"--format",
"JSON",
"--from",
fileToImport.getPath());
fileToImport.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
@@ -274,9 +276,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
public void blocksExport_missingFileParam() throws IOException {
createDbDirectory(true);
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME);
"--data-path=" + folder.getRoot(), BLOCK_SUBCOMMAND_NAME, BLOCK_EXPORT_SUBCOMMAND_NAME);
final String expectedErrorOutputStart = "Missing required option: '--to=<FILE>'";
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).startsWith(expectedErrorOutputStart);
@@ -285,17 +285,17 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksExport_noDbDirectory() throws IOException {
final File outputFile = folder.newFile("blocks.bin");
public void blocksExport_noDbDirectory(final @TempDir Path noDbDir) throws IOException {
final File outputFile = noDbDir.resolve("blocks.bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + noDbDir,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
outputFile.getAbsolutePath());
final String expectedErrorOutputStart =
"Chain is empty. Unable to export blocks from specified data directory: "
+ folder.getRoot().getAbsolutePath()
+ noDbDir
+ File.separator
+ BesuController.DATABASE_PATH;
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@@ -307,16 +307,16 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_emptyDbDirectory() throws IOException {
createDbDirectory(false);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createFile(folder.resolve("empty")).toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
final String expectedErrorOutputStart =
"Chain is empty. Unable to export blocks from specified data directory: "
+ folder.getRoot().getAbsolutePath()
+ folder
+ File.separator
+ BesuController.DATABASE_PATH;
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@@ -328,13 +328,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_noStartOrEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
outputFile.getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
@@ -344,9 +344,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withStartAndNoEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createFile(folder.resolve("blocks.bin")).toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@@ -361,9 +361,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withEndAndNoStart() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@@ -378,13 +378,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withStartAndEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath(),
outputFile.getAbsolutePath(),
"--start-block=1",
"--end-block=10");
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@@ -396,13 +396,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withOutOfOrderStartAndEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath(),
outputFile.getAbsolutePath(),
"--start-block=10",
"--end-block=1");
assertThat(commandErrorOutput.toString(UTF_8))
@@ -415,9 +415,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withEmptyRange() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@@ -434,9 +434,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withInvalidStart() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder.getRoot(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@@ -452,9 +452,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withInvalidEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder.getRoot(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@@ -482,17 +482,18 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
private void createDbDirectory(final boolean createDataFiles) throws IOException {
final File dbDir = folder.newFolder(BesuController.DATABASE_PATH);
final Path dbDir = Files.createDirectory(folder.resolve(BesuController.DATABASE_PATH));
if (createDataFiles) {
final Path dataFilePath = Paths.get(dbDir.getAbsolutePath(), "0000001.sst");
final boolean success = new File(dataFilePath.toString()).createNewFile();
final Path dataFilePath = Paths.get(dbDir.toFile().getAbsolutePath(), "0000001.sst");
final boolean success = new File(dataFilePath.toFile().getAbsolutePath()).createNewFile();
assertThat(success).isTrue();
}
}
@Test
public void blocksImportWithNoSyncModeDoesNotRaiseNPE() throws IOException {
final File fileToImport = temp.newFile("blocks.file");
public void blocksImportWithNoSyncModeDoesNotRaiseNPE(final @TempDir File fileToImport)
throws IOException {
parseCommand(
BLOCK_SUBCOMMAND_NAME, BLOCK_IMPORT_SUBCOMMAND_NAME, "--from", fileToImport.getPath());

View File

@@ -36,11 +36,11 @@ import org.hyperledger.besu.services.kvstore.SegmentedKeyValueStorageAdapter;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.Silent.class)
@ExtendWith(MockitoExtension.class)
public class StorageSubCommandTest extends CommandTestAbstract {
@Test

View File

@@ -22,18 +22,18 @@ import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuCommandCustomFactoryTest {
@Mock private PluginVersionsProvider pluginVersionsProvider;
@Before
@BeforeEach
public void initMocks() {
when(pluginVersionsProvider.getPluginVersions()).thenReturn(Arrays.asList("v1", "v2"));
}

View File

@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -28,18 +29,19 @@ import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.IDefaultValueProvider;
import picocli.CommandLine.IExecutionStrategy;
@@ -49,11 +51,11 @@ import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.ParseResult;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ConfigOptionSearchAndRunHandlerTest {
private static final String CONFIG_FILE_OPTION_NAME = "--config-file";
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@TempDir public Path temp;
private LoggingLevelOption levelOption;
private final IExecutionStrategy resultHandler = new RunLast();
@@ -68,16 +70,18 @@ public class ConfigOptionSearchAndRunHandlerTest {
@Mock IGetter mockConfigOptionGetter;
@Mock BesuParameterExceptionHandler mockParameterExceptionHandler;
@Before
@BeforeEach
public void initMocks() {
when(mockCommandSpec.commandLine()).thenReturn(mockCommandLine);
when(mockParseResult.commandSpec()).thenReturn(mockCommandSpec);
lenient().when(mockCommandSpec.commandLine()).thenReturn(mockCommandLine);
lenient().when(mockParseResult.commandSpec()).thenReturn(mockCommandSpec);
final List<String> originalArgs = new ArrayList<>();
originalArgs.add(CONFIG_FILE_OPTION_NAME);
when(mockParseResult.originalArgs()).thenReturn(originalArgs);
when(mockParseResult.matchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(mockConfigOptionSpec);
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);
when(mockConfigOptionSpec.getter()).thenReturn(mockConfigOptionGetter);
lenient().when(mockParseResult.originalArgs()).thenReturn(originalArgs);
lenient()
.when(mockParseResult.matchedOption(CONFIG_FILE_OPTION_NAME))
.thenReturn(mockConfigOptionSpec);
lenient().when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);
lenient().when(mockConfigOptionSpec.getter()).thenReturn(mockConfigOptionGetter);
levelOption = new LoggingLevelOption();
levelOption.setLogLevel("INFO");
configParsingHandler =
@@ -87,7 +91,7 @@ public class ConfigOptionSearchAndRunHandlerTest {
@Test
public void handleWithCommandLineOption() throws Exception {
when(mockConfigOptionGetter.get()).thenReturn(temp.newFile());
when(mockConfigOptionGetter.get()).thenReturn(Files.createTempFile("tmp", "txt").toFile());
final List<Object> result = configParsingHandler.handle(mockParseResult);
verify(mockCommandLine).setDefaultValueProvider(any(IDefaultValueProvider.class));
verify(mockCommandLine).setExecutionStrategy(eq(resultHandler));
@@ -105,7 +109,9 @@ public class ConfigOptionSearchAndRunHandlerTest {
new ConfigOptionSearchAndRunHandler(
resultHandler,
mockParameterExceptionHandler,
singletonMap("BESU_CONFIG_FILE", temp.newFile().getAbsolutePath()));
singletonMap(
"BESU_CONFIG_FILE",
Files.createFile(temp.resolve("tmp")).toFile().getAbsolutePath()));
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(false);
@@ -160,7 +166,7 @@ public class ConfigOptionSearchAndRunHandlerTest {
new ConfigOptionSearchAndRunHandler(
resultHandler,
mockParameterExceptionHandler,
singletonMap("BESU_CONFIG_FILE", temp.newFile().getAbsolutePath()));
singletonMap("BESU_CONFIG_FILE", temp.resolve("tmp").toFile().getAbsolutePath()));
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);

View File

@@ -23,12 +23,12 @@ import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class VersionProviderTest {
@Mock private PluginVersionsProvider pluginVersionsProvider;

View File

@@ -30,9 +30,6 @@ import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@@ -45,10 +42,13 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.services;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -76,15 +77,15 @@ import java.util.stream.Stream;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@SuppressWarnings("unchecked")
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuEventsImplTest {
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
@@ -113,7 +114,7 @@ public class BesuEventsImplTest {
private MutableBlockchain blockchain;
private final BlockDataGenerator gen = new BlockDataGenerator();
@Before
@BeforeEach
public void setUp() {
blockchain =
DefaultBlockchain.createMutable(
@@ -128,18 +129,22 @@ public class BesuEventsImplTest {
when(mockEthContext.getEthMessages()).thenReturn(mockEthMessages);
when(mockEthContext.getEthPeers()).thenReturn(mockEthPeers);
when(mockEthContext.getScheduler()).thenReturn(mockEthScheduler);
when(mockEthPeers.streamAvailablePeers()).thenAnswer(z -> Stream.empty());
lenient().when(mockEthPeers.streamAvailablePeers()).thenAnswer(z -> Stream.empty());
when(mockProtocolContext.getBlockchain()).thenReturn(blockchain);
when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
when(mockProtocolSchedule.getByBlockHeader(any())).thenReturn(mockProtocolSpec);
when(mockProtocolSpec.getTransactionValidatorFactory())
lenient().when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
lenient().when(mockProtocolSchedule.getByBlockHeader(any())).thenReturn(mockProtocolSpec);
lenient()
.when(mockProtocolSpec.getTransactionValidatorFactory())
.thenReturn(mockTransactionValidatorFactory);
when(mockProtocolSpec.getFeeMarket()).thenReturn(FeeMarket.london(0L));
when(mockTransactionValidatorFactory.get().validate(any(), any(Optional.class), any()))
lenient().when(mockProtocolSpec.getFeeMarket()).thenReturn(FeeMarket.london(0L));
lenient()
.when(mockTransactionValidatorFactory.get().validate(any(), any(Optional.class), any()))
.thenReturn(ValidationResult.valid());
when(mockTransactionValidatorFactory.get().validateForSender(any(), any(), any()))
lenient()
.when(mockTransactionValidatorFactory.get().validateForSender(any(), any(), any()))
.thenReturn(ValidationResult.valid());
when(mockWorldStateArchive.getMutable(any(), anyBoolean()))
lenient()
.when(mockWorldStateArchive.getMutable(any(), anyBoolean()))
.thenReturn(Optional.of(mockWorldState));
blockBroadcaster = new BlockBroadcaster(mockEthContext);

View File

@@ -17,16 +17,16 @@ package org.hyperledger.besu.services;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.UnmatchedArgumentException;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PicoCLIOptionsImplTest {
@Command
@@ -46,7 +46,7 @@ public class PicoCLIOptionsImplTest {
private CommandLine commandLine;
private PicoCLIOptionsImpl serviceImpl;
@Before
@BeforeEach
public void setUp() {
command = new SimpleCommand();
mixin = new MixinOptions();

View File

@@ -232,7 +232,6 @@ public class LocalPermissioningConfigurationValidatorTest {
true,
toml.toAbsolutePath().toString()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"Invalid IP address (or DNS query resolved an invalid IP). --Xdns-enabled is true but --Xdns-update-enabled flag is false.");
.hasMessageContaining("Invalid IP address");
}
}

View File

@@ -185,7 +185,7 @@ tx-pool-save-file="txpool.dump"
tx-pool-layer-max-capacity=12345678
tx-pool-max-prioritized=9876
tx-pool-max-future-by-sender=321
## Legacy
## Legacy/Sequenced
tx-pool-retention-hours=999
tx-pool-max-size=1234
tx-pool-limit-by-account-percentage=0.017

View File

@@ -14,6 +14,7 @@
*/
import com.github.jk1.license.filter.LicenseBundleNormalizer
import groovy.transform.CompileStatic
import groovy.transform.Memoized
import net.ltgt.gradle.errorprone.CheckSeverity
@@ -22,13 +23,13 @@ import java.text.SimpleDateFormat
import java.util.regex.Pattern
plugins {
id 'com.diffplug.spotless' version '6.12.0'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'com.github.hierynomus.license' version '0.16.1-fix'
id 'com.jfrog.artifactory' version '4.28.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'me.champeau.jmh' version '0.7.0' apply false
id 'net.ltgt.errorprone' version '2.0.2'
id 'com.diffplug.spotless' version '6.23.3'
id 'com.github.ben-manes.versions' version '0.50.0'
id 'com.github.jk1.dependency-license-report' version '2.5'
id 'com.jfrog.artifactory' version '5.1.11'
id 'io.spring.dependency-management' version '1.1.4'
id 'me.champeau.jmh' version '0.7.2' apply false
id 'net.ltgt.errorprone' version '3.0.1'
id 'maven-publish'
}
@@ -74,13 +75,35 @@ def _strListCmdArg(name) {
return _strListCmdArg(name, null)
}
licenseReport {
// This is for the allowed-licenses-file in checkLicense Task
// Accepts File, URL or String path to local or remote file
allowedLicensesFile = new File("$rootDir/gradle/allowed-licenses.json")
excludes = [
// only used for static analysis, not actually shipped
'com.google.errorprone:javac',
'org.checkerframework:dataflow-shaded',
'org.checkerframework:dataflow-errorprone',
// exclude Kotlin multiplatform dependencies container, they have the same license of what they contain
'com.squareup.okio:okio',
'org.jetbrains.kotlinx:kotlinx-coroutines-core'
]
// If set to true, then all boms will be excluded from the report
excludeBoms = true
filters = [
new LicenseBundleNormalizer(bundlePath: "$rootDir/gradle/license-normalizer-bundle.json")
]
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
apply from: "${rootDir}/gradle/versions.gradle"
apply from: "${rootDir}/gradle/check-licenses.gradle"
version = rootProject.version
@@ -164,7 +187,7 @@ allprojects {
}
groovyGradle {
target '*.gradle'
greclipse('4.21.0').configFile(rootProject.file('gradle/formatter.properties'))
greclipse('4.21').configFile(rootProject.file('gradle/formatter.properties'))
endWithNewline()
}
// Below this line are currently only license header tasks
@@ -310,7 +333,6 @@ allprojects {
options.addStringOption('Xwerror', '-html5')
options.encoding = 'UTF-8'
}
}
task deploy() {}
@@ -602,10 +624,10 @@ task autocomplete(type: JavaExec) {
}
}
installDist { dependsOn checkLicenses, untunedStartScripts, evmToolStartScripts }
installDist { dependsOn checkLicense, untunedStartScripts, evmToolStartScripts }
distTar {
dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts
dependsOn checkLicense, autocomplete, untunedStartScripts, evmToolStartScripts
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.tar.gz')
}
@@ -615,7 +637,7 @@ distTar {
}
distZip {
dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts
dependsOn checkLicense, autocomplete, untunedStartScripts, evmToolStartScripts
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.zip')
}
@@ -913,7 +935,6 @@ task checkSpdxHeader(type: CheckSpdxHeader) {
"(.*${sep}build${sep}.*)",
"(.*${sep}src${sep}[^${sep}]+${sep}generated${sep}.*)"
].join("|")
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {

View File

@@ -13,10 +13,12 @@
"thanosBlock": 11700000,
"magnetoBlock": 13189133,
"mystiqueBlock": 14525000,
"spiralBlock": 19250000,
"ethash": {
},
"discovery" : {
"dns": "enrtree://AJE62Q4DUX4QMMXEHCSSCSC65TDHZYSMONSD64P3WULVLSF6MRQ3K@all.classic.blockd.info",
"bootnodes" : [
"enode://8e73168affd8d445edda09c561d607081ca5d7963317caae2702f701eb6546b06948b7f8687a795de576f6a5f33c44828e25a90aa63de18db380a11e660dd06f@159.203.37.80:30303",
"enode://2b1ef75e8b7119b6e0294f2e51ead2cf1a5400472452c199e9587727ada99e7e2b1199e36adcad6cbae65dce2410559546e4d83d8c93d45a559e723e56444c03@67.207.93.100:30303",

View File

@@ -60,6 +60,4 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

View File

@@ -59,8 +59,6 @@ dependencies {
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testSupportImplementation project( path: ':crypto:services', configuration: 'testSupportArtifacts')
testSupportImplementation project( path: ':ethereum:core', configuration: 'testSupportArtifacts')
testSupportImplementation 'org.mockito:mockito-core'

View File

@@ -104,7 +104,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolMetrics;
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -241,7 +241,7 @@ public class TestContextBuilder {
}
final MutableBlockchain blockChain;
final DefaultWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
final ForestWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
if (genesisFile.isPresent()) {
try {

View File

@@ -42,6 +42,4 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

View File

@@ -32,11 +32,8 @@ dependencies {
api project(':crypto:algorithms')
api project(':plugin-api')
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
artifacts { testSupportArtifacts testSupportJar }

View File

@@ -20,26 +20,22 @@ import org.hyperledger.besu.crypto.KeyPairUtil;
import org.hyperledger.besu.crypto.SECPPublicKey;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.security.spec.ECPoint;
import org.apache.tuweni.bytes.Bytes;
import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
public class KeyPairSecurityModuleTest {
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@TempDir public Path keyFile;
@Test
public void validatePublicKeyFromECPointCanBeConstructed() throws IOException {
final File keyDirectory = temp.newFolder();
final File keyFile = new File(keyDirectory, "key");
final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile);
final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile.resolve("key"));
final KeyPairSecurityModule keyPairSecurityModule = new KeyPairSecurityModule(keyPair);
final ECPoint ecPoint = keyPairSecurityModule.getPublicKey().getW();

View File

@@ -21,12 +21,12 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class NodeKeyTest {
@Before
@BeforeEach
public void resetInstance() {
SignatureAlgorithmFactory.resetInstance();
}

View File

@@ -39,8 +39,6 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
configurations { testArtifacts }

View File

@@ -38,8 +38,6 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
epJavac 'com.google.errorprone:error_prone_check_api'
}

View File

@@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;

View File

@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Optional;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@@ -46,6 +47,10 @@ import org.slf4j.LoggerFactory;
public class WebSocketMessageHandler {
private static final ObjectMapper jsonObjectMapper =
new ObjectMapper()
.registerModule(new Jdk8Module()); // Handle JDK8 Optionals (de)serialization
private static final Logger LOG = LoggerFactory.getLogger(WebSocketMessageHandler.class);
private static final ObjectWriter JSON_OBJECT_WRITER =
new ObjectMapper()
@@ -161,6 +166,7 @@ public class WebSocketMessageHandler {
}
private void replyToClient(final ServerWebSocket websocket, final Object result) {
traceResponse(result);
try {
// underlying output stream lifecycle is managed by the json object writer
JSON_OBJECT_WRITER.writeValue(new JsonResponseStreamer(websocket), result);
@@ -172,4 +178,12 @@ public class WebSocketMessageHandler {
private JsonRpcResponse errorResponse(final Object id, final RpcErrorType error) {
return new JsonRpcErrorResponse(id, error);
}
private void traceResponse(final Object response) {
try {
LOG.trace(jsonObjectMapper.writeValueAsString(response));
} catch (JsonProcessingException e) {
LOG.error("Error tracing JSON-RPC response", e);
}
}
}

View File

@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.pruner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
@@ -26,11 +26,15 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner.PruningPhase;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.Pruner.PruningPhase;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -57,9 +61,10 @@ public class PrunerIntegrationTest {
private final NoOpMetricsSystem metricsSystem = new NoOpMetricsSystem();
private final Map<Bytes, Optional<byte[]>> hashValueStore = new HashMap<>();
private final InMemoryKeyValueStorage stateStorage = new TestInMemoryStorage(hashValueStore);
private final WorldStateStorage worldStateStorage = new WorldStateKeyValueStorage(stateStorage);
private final WorldStateStorage worldStateStorage =
new ForestWorldStateKeyValueStorage(stateStorage);
private final WorldStateArchive worldStateArchive =
new DefaultWorldStateArchive(
new ForestWorldStateArchive(
worldStateStorage,
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()),
EvmConfiguration.DEFAULT);

View File

@@ -32,9 +32,9 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.log.LogsBloomFilter;
@@ -134,12 +134,12 @@ public final class GenesisState {
}
private static Hash calculateGenesisStateHash(final List<GenesisAccount> genesisAccounts) {
final WorldStateKeyValueStorage stateStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final ForestWorldStateKeyValueStorage stateStorage =
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final WorldStatePreimageKeyValueStorage preimageStorage =
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage());
final MutableWorldState worldState =
new DefaultMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
new ForestMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
writeAccountsTo(worldState, genesisAccounts, null);
return worldState.rootHash();
}

View File

@@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver;
import org.hyperledger.besu.ethereum.privacy.PrivateWorldStateReader;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@@ -340,7 +340,7 @@ public class PrivacyParameters {
final WorldStatePreimageStorage privatePreimageStorage =
storageProvider.createWorldStatePreimageStorage();
final WorldStateArchive privateWorldStateArchive =
new DefaultWorldStateArchive(
new ForestWorldStateArchive(
privateWorldStateStorage, privatePreimageStorage, EvmConfiguration.DEFAULT);
final PrivateStateStorage privateStateStorage = storageProvider.createPrivateStateStorage();

View File

@@ -21,8 +21,6 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.BlockProcessingOutputs;
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit;
@@ -33,6 +31,8 @@ import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.evm.tracing.OperationTracer;

View File

@@ -505,9 +505,15 @@ public class MainnetTransactionProcessor {
gasUsedByTransaction, refundedGas, validationResult, initialFrame.getRevertReason());
}
} catch (final MerkleTrieException re) {
operationTracer.traceEndTransaction(
worldState.updater(), transaction, false, Bytes.EMPTY, List.of(), 0, 0L);
// need to throw to trigger the heal
throw re;
} catch (final RuntimeException re) {
operationTracer.traceEndTransaction(
worldState.updater(), transaction, false, Bytes.EMPTY, List.of(), 0, 0L);
LOG.error("Critical Exception Processing Transaction", re);
return TransactionProcessingResult.invalid(
ValidationResult.invalid(

View File

@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.privacy;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
@@ -26,12 +26,12 @@ import java.util.Optional;
// This class uses a public WorldUpdater and a private WorldUpdater to provide a
// MutableWorldStateUpdater that can read and write from the private world state and can read from
// the public world state, but cannot write to it.
public class DefaultMutablePrivateWorldStateUpdater implements WorldUpdater {
public class PrivateMutableWorldStateUpdater implements WorldUpdater {
protected final WorldUpdater publicWorldUpdater;
protected final WorldUpdater privateWorldUpdater;
public DefaultMutablePrivateWorldStateUpdater(
public PrivateMutableWorldStateUpdater(
final WorldUpdater publicWorldUpdater, final WorldUpdater privateWorldUpdater) {
this.publicWorldUpdater = publicWorldUpdater;
this.privateWorldUpdater = privateWorldUpdater;

View File

@@ -24,7 +24,6 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidatorFactory;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateUpdater;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.code.CodeV0;
@@ -109,7 +108,7 @@ public class PrivateTransactionProcessor {
sender.getNonce());
final WorldUpdater mutablePrivateWorldStateUpdater =
new DefaultMutablePrivateWorldStateUpdater(publicWorldState, privateWorldState);
new PrivateMutableWorldStateUpdater(publicWorldState, privateWorldState);
final MessageFrame.Builder commonMessageFrameBuilder =
MessageFrame.builder()
.maxStackSize(maxStackSize)

View File

@@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
@@ -48,7 +48,7 @@ public class PrivacyKeyValueStorageProvider implements PrivacyStorageProvider {
@Override
public WorldStateStorage createWorldStateStorage() {
return new WorldStateKeyValueStorage(privateWorldStateKeyValueStorage);
return new ForestWorldStateKeyValueStorage(privateWorldStateKeyValueStorage);
}
@Override

View File

@@ -14,12 +14,13 @@
*/
package org.hyperledger.besu.ethereum.storage.keyvalue;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage;
import org.hyperledger.besu.ethereum.chain.VariablesStorage;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@@ -78,7 +79,7 @@ public class KeyValueStorageProvider implements StorageProvider {
if (dataStorageFormat.equals(DataStorageFormat.BONSAI)) {
return new BonsaiWorldStateKeyValueStorage(this, metricsSystem);
} else {
return new WorldStateKeyValueStorage(
return new ForestWorldStateKeyValueStorage(
getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.WORLD_STATE));
}
}

View File

@@ -14,18 +14,18 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldView;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldView;
import org.hyperledger.besu.evm.ModificationNotAllowedException;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.account.MutableAccount;

View File

@@ -14,7 +14,7 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;

View File

@@ -14,19 +14,12 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import static org.hyperledger.besu.ethereum.bonsai.cache.CachedWorldStorageManager.RETAINED_LAYERS;
import static org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedWorldStorageManager.RETAINED_LAYERS;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
@@ -34,6 +27,13 @@ import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;

Some files were not shown because too many files have changed in this diff Show More