Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hyperledger/besu into CheckForSnapS…
Browse files Browse the repository at this point in the history
…erver
  • Loading branch information
pinges committed Jun 27, 2024
2 parents 6e98ee9 + 571e030 commit 626af31
Show file tree
Hide file tree
Showing 31 changed files with 764 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class NodeSmartContractPermissioningAcceptanceTest
Expand Down Expand Up @@ -57,6 +58,7 @@ public void setUp() {
}

@Test
@Disabled("test is flaky")
public void permissionedNodeShouldPeerOnlyWithAllowedNodes() {
bootnode.verify(net.awaitPeerCount(3));
allowedNode.verify(net.awaitPeerCount(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class NodeSmartContractPermissioningV2AcceptanceTest
Expand Down Expand Up @@ -51,6 +52,7 @@ public void setUp() {
}

@Test
@Disabled("test is flaky")
public void permissionedNodeShouldPeerOnlyWithAllowedNodes() {
bootnode.verify(net.awaitPeerCount(3));
allowedNode.verify(net.awaitPeerCount(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@Disabled("test is flaky #7191")
public class NodeSmartContractPermissioningV2DNSAcceptanceTest
extends NodeSmartContractPermissioningV2AcceptanceTestBase {

Expand Down Expand Up @@ -57,12 +59,6 @@ public void setUp() {

permissionedNode.execute(allowNode(permissionedNode));
permissionedNode.verify(connectionIsAllowed(permissionedNode));

// Verify initial configuration
bootnode.verify(net.awaitPeerCount(3));
allowedNode.verify(net.awaitPeerCount(3));
forbiddenNode.verify(net.awaitPeerCount(2));
permissionedNode.verify(net.awaitPeerCount(2));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void createConsoleAppender() {
dim("%t"),
colorize("%-5level"),
dim("%c{1}"),
colorize("%msg%n%throwable")))
colorize("%msgc%n%throwable")))
.build();
final ConsoleAppender consoleAppender =
ConsoleAppender.newBuilder().setName("Console").setLayout(patternLayout).build();
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ allprojects {
'-org.hyperledger.besu.tests.acceptance.*,' +
'-org.hyperledger.besu.tests.web3j.generated,' +
// TODO: these are temporary disabled (ethereum and sub modules), it should be removed in a future PR.
'-org.hyperledger.besu.ethereum,' +
'-org.hyperledger.besu.ethereum.*,' +
'-org.hyperledger.besu.ethstats.*,' +
'-org.hyperledger.besu.evmtool',
true)
options.addStringOption('Xmaxerrs','65535')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public void shouldIgnoreSenderBalanceAccountWhenStrictModeDisabled() {
}

@Test
public void shouldNotIgnoreSenderBalanceAccountWhenStrictModeDisabled() {
public void shouldNotIgnoreSenderBalanceAccountWhenStrictModeEnabled() {
final JsonRpcRequestContext request =
ethEstimateGasRequest(legacyTransactionCallParameter(Wei.ZERO, true));
mockTransientProcessorResultGasEstimate(1L, false, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,31 @@
import java.util.List;
import java.util.Optional;

/** Contains the outputs of processing a block. */
public class BlockProcessingOutputs {

private final MutableWorldState worldState;
private final List<TransactionReceipt> receipts;
private final Optional<List<Request>> maybeRequests;

/**
* Creates a new instance.
*
* @param worldState the world state after processing the block
* @param receipts the receipts produced by processing the block
*/
public BlockProcessingOutputs(
final MutableWorldState worldState, final List<TransactionReceipt> receipts) {
this(worldState, receipts, Optional.empty());
}

/**
* Creates a new instance.
*
* @param worldState the world state after processing the block
* @param receipts the receipts produced by processing the block
* @param maybeRequests the requests produced by processing the block
*/
public BlockProcessingOutputs(
final MutableWorldState worldState,
final List<TransactionReceipt> receipts,
Expand All @@ -41,14 +55,29 @@ public BlockProcessingOutputs(
this.maybeRequests = maybeRequests;
}

/**
* Returns the world state after processing the block.
*
* @return the world state after processing the block
*/
public MutableWorldState getWorldState() {
return worldState;
}

/**
* Returns the receipts produced by processing the block.
*
* @return the receipts produced by processing the block
*/
public List<TransactionReceipt> getReceipts() {
return receipts;
}

/**
* Returns the requests produced by processing the block.
*
* @return the requests produced by processing the block
*/
public Optional<List<Request>> getRequests() {
return maybeRequests;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,70 @@
import java.util.List;
import java.util.Optional;

/** Contains the outputs of processing a block. */
public class BlockProcessingResult extends BlockValidationResult {

private final Optional<BlockProcessingOutputs> yield;
private final boolean isPartial;

/** A result indicating that processing failed. */
public static final BlockProcessingResult FAILED = new BlockProcessingResult("processing failed");

/**
* A result indicating that processing was successful but incomplete.
*
* @param yield the outputs of processing a block
*/
public BlockProcessingResult(final Optional<BlockProcessingOutputs> yield) {
this.yield = yield;
this.isPartial = false;
}

/**
* A result indicating that processing was successful but incomplete.
*
* @param yield the outputs of processing a block
* @param isPartial whether the processing was incomplete
*/
public BlockProcessingResult(
final Optional<BlockProcessingOutputs> yield, final boolean isPartial) {
this.yield = yield;
this.isPartial = isPartial;
}

/**
* A result indicating that processing was successful but incomplete.
*
* @param yield the outputs of processing a block
* @param errorMessage the error message if any
*/
public BlockProcessingResult(
final Optional<BlockProcessingOutputs> yield, final String errorMessage) {
super(errorMessage);
this.yield = yield;
this.isPartial = false;
}

/**
* A result indicating that processing was successful but incomplete.
*
* @param yield the outputs of processing a block
* @param cause the cause of the error if any
*/
public BlockProcessingResult(
final Optional<BlockProcessingOutputs> yield, final Throwable cause) {
super(cause.getLocalizedMessage(), cause);
this.yield = yield;
this.isPartial = false;
}

/**
* A result indicating that processing was successful but incomplete.
*
* @param yield the outputs of processing a block
* @param errorMessage the error message if any
* @param isPartial whether the processing was incomplete
*/
public BlockProcessingResult(
final Optional<BlockProcessingOutputs> yield,
final String errorMessage,
Expand All @@ -61,20 +93,40 @@ public BlockProcessingResult(
this.isPartial = isPartial;
}

/**
* A result indicating that processing failed.
*
* @param errorMessage the error message
*/
public BlockProcessingResult(final String errorMessage) {
super(errorMessage);
this.isPartial = false;
this.yield = Optional.empty();
}

/**
* Gets the block processing outputs of the result.
*
* @return the block processing outputs of the result
*/
public Optional<BlockProcessingOutputs> getYield() {
return yield;
}

/**
* Checks if the processing was incomplete.
*
* @return true if the processing was incomplete, false otherwise
*/
public boolean isPartial() {
return isPartial;
}

/**
* Gets the transaction receipts of the result.
*
* @return the transaction receipts of the result
*/
public List<TransactionReceipt> getReceipts() {
if (yield.isEmpty()) {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,78 @@

import java.util.Optional;

/**
* Represents the result of a block validation. This class holds the success status, error message,
* and cause of the validation.
*/
public class BlockValidationResult {

/** The error message of the failed validation, if any. */
public final Optional<String> errorMessage;

/** The cause of the failed validation, if any. */
public final Optional<Throwable> cause;

/**
* The success status of the validation. True if the validation was successful, false otherwise.
*/
public final boolean success;

/** Constructs a new BlockValidationResult indicating a successful validation. */
public BlockValidationResult() {
this.success = true;
this.errorMessage = Optional.empty();
this.cause = Optional.empty();
}

/**
* Constructs a new BlockValidationResult indicating a failed validation with the given error
* message.
*
* @param errorMessage the error message of the failed validation
*/
public BlockValidationResult(final String errorMessage) {
this.success = false;
this.errorMessage = Optional.of(errorMessage);
this.cause = Optional.empty();
}

/**
* Constructs a new BlockValidationResult indicating a failed validation with the given error
* message and cause.
*
* @param errorMessage the error message of the failed validation
* @param cause the cause of the failed validation
*/
public BlockValidationResult(final String errorMessage, final Throwable cause) {
this.success = false;
this.errorMessage = Optional.of(errorMessage);
this.cause = Optional.of(cause);
}

/**
* Checks if the validation was successful.
*
* @return true if the validation was successful, false otherwise
*/
public boolean isSuccessful() {
return this.success;
}

/**
* Checks if the validation failed.
*
* @return true if the validation failed, false otherwise
*/
public boolean isFailed() {
return !isSuccessful();
}

/**
* Gets the cause of the failed validation.
*
* @return the cause of the failed validation
*/
public Optional<Throwable> causedBy() {
return cause;
}
Expand Down
Loading

0 comments on commit 626af31

Please sign in to comment.