Skip to content

Commit

Permalink
Merge branch 'main' into qbft-snap
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Whitehead <[email protected]>
  • Loading branch information
matthew1001 authored Jun 27, 2024
2 parents 3bf0c8b + d7f8510 commit 6ba69e1
Show file tree
Hide file tree
Showing 54 changed files with 1,183 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Update Docker base image to Ubuntu 24.04 [#7251](https://github.com/hyperledger/besu/pull/7251)
- Add LUKSO as predefined network name [#7223](https://github.com/hyperledger/besu/pull/7223)
- Refactored how code, initcode, and max stack size are configured in forks. [#7245](https://github.com/hyperledger/besu/pull/7245)
- Nodes in a permissioned chain maintain (and retry) connections to bootnodes [#7257](https://github.com/hyperledger/besu/pull/7257)
- `--Xsnapsync-bft-enabled` option enables experimental support for snap sync with IBFT/QBFT permissioned Bonsai-DB chains [#7140](https://github.com/hyperledger/besu/pull/7140)

### Bug fixes
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 NodeSmartContractPermissioningAcceptanceTest
Expand All @@ -37,17 +38,17 @@ public void setUp() {
permissionedCluster.start(bootnode, forbiddenNode, allowedNode, permissionedNode);

// updating permissioning smart contract with allowed nodes

permissionedNode.verify(nodeIsForbidden(bootnode));
permissionedNode.execute(allowNode(bootnode));
permissionedNode.verify(nodeIsAllowed(bootnode));
permissionedNode.verify(admin.hasPeer(bootnode));

permissionedNode.execute(allowNode(allowedNode));
permissionedNode.verify(nodeIsAllowed(allowedNode));

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

permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));

allowedNode.verify(eth.syncingStatus(false));
Expand All @@ -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 All @@ -60,7 +62,7 @@ public void permissionedNodeShouldPeerOnlyWithAllowedNodes() {

@Test
public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() {
permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.hasPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));
permissionedNode.verify(net.awaitPeerCount(2));

Expand All @@ -72,7 +74,7 @@ public void permissionedNodeShouldDisconnectFromNodeNotPermittedAnymore() {

@Test
public void permissionedNodeShouldConnectToNewlyPermittedNode() {
permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.hasPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));
permissionedNode.verify(net.awaitPeerCount(2));

Expand All @@ -87,7 +89,7 @@ public void permissionedNodeShouldConnectToNewlyPermittedNode() {

@Test
public void permissioningUpdatesPropagateThroughNetwork() {
permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.hasPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));
permissionedNode.verify(net.awaitPeerCount(2));

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
15 changes: 14 additions & 1 deletion besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,20 @@ public Runner build() {
LOG.debug("added ethash observer: {}", stratumServer.get());
}

sanitizePeers(network, staticNodes)
final Stream<EnodeURL> maintainedPeers;
if (besuController.getGenesisConfigOptions().isPoa()) {
// In a permissioned chain Besu should maintain connections to both static nodes and
// bootnodes, which includes retries periodically
maintainedPeers =
sanitizePeers(
network,
Stream.concat(staticNodes.stream(), bootnodes.stream()).collect(Collectors.toList()));
LOG.debug("Added bootnodes to the maintained peer list");
} else {
// In a public chain only maintain connections to static nodes
maintainedPeers = sanitizePeers(network, staticNodes);
}
maintainedPeers
.map(DefaultPeer::fromEnodeURL)
.forEach(peerNetwork::addMaintainedConnectionPeer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,7 @@ private void configureNativeLibs() {
}

if (genesisConfigOptionsSupplier.get().getCancunTime().isPresent()
|| genesisConfigOptionsSupplier.get().getCancunEOFTime().isPresent()
|| genesisConfigOptionsSupplier.get().getPragueTime().isPresent()
|| genesisConfigOptionsSupplier.get().getPragueEOFTime().isPresent()) {
if (kzgTrustedSetupFile != null) {
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 @@ -242,6 +242,13 @@ default boolean isConsensusMigration() {
*/
OptionalLong getCancunTime();

/**
* Gets cancun EOF time.
*
* @return the cancun EOF time
*/
OptionalLong getCancunEOFTime();

/**
* Gets prague time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ public OptionalLong getShanghaiTime() {
return getOptionalLong("shanghaitime");
}

@Override
public OptionalLong getCancunEOFTime() {
return getOptionalLong("cancuneoftime");
}

@Override
public OptionalLong getCancunTime() {
return getOptionalLong("cancuntime");
Expand Down Expand Up @@ -461,6 +466,7 @@ public Map<String, Object> asMap() {
getMergeNetSplitBlockNumber().ifPresent(l -> builder.put("mergeNetSplitBlock", l));
getShanghaiTime().ifPresent(l -> builder.put("shanghaiTime", l));
getCancunTime().ifPresent(l -> builder.put("cancunTime", l));
getCancunEOFTime().ifPresent(l -> builder.put("cancunEOFTime", l));
getPragueTime().ifPresent(l -> builder.put("pragueTime", l));
getPragueEOFTime().ifPresent(l -> builder.put("pragueEOFTime", l));
getTerminalBlockNumber().ifPresent(l -> builder.put("terminalBlockNumber", l));
Expand Down Expand Up @@ -610,6 +616,7 @@ public List<Long> getForkBlockTimestamps() {
Stream.of(
getShanghaiTime(),
getCancunTime(),
getCancunEOFTime(),
getPragueTime(),
getPragueEOFTime(),
getFutureEipsTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
private OptionalLong mergeNetSplitBlockNumber = OptionalLong.empty();
private OptionalLong shanghaiTime = OptionalLong.empty();
private OptionalLong cancunTime = OptionalLong.empty();
private OptionalLong cancunEOFTime = OptionalLong.empty();
private OptionalLong pragueTime = OptionalLong.empty();
private OptionalLong pragueEOFTime = OptionalLong.empty();
private OptionalLong futureEipsTime = OptionalLong.empty();
Expand Down Expand Up @@ -82,7 +83,9 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
private boolean fixedBaseFee = false;

/** Default constructor. */
public StubGenesisConfigOptions() {}
public StubGenesisConfigOptions() {
// Explicit default constructor because of JavaDoc linting
}

@Override
public StubGenesisConfigOptions clone() {
Expand Down Expand Up @@ -238,6 +241,11 @@ public OptionalLong getCancunTime() {
return cancunTime;
}

@Override
public OptionalLong getCancunEOFTime() {
return cancunEOFTime;
}

@Override
public OptionalLong getPragueTime() {
return pragueTime;
Expand Down Expand Up @@ -630,6 +638,17 @@ public StubGenesisConfigOptions cancunTime(final long timestamp) {
return this;
}

/**
* Cancun EOF time.
*
* @param timestamp the timestamp
* @return the stub genesis config options
*/
public StubGenesisConfigOptions cancunEOFTime(final long timestamp) {
cancunEOFTime = OptionalLong.of(timestamp);
return this;
}

/**
* Prague time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ void shouldGetCancunTime() {
assertThat(config.getCancunTime()).hasValue(1670470142);
}

@Test
void shouldGetCancunEOFTime() {
final GenesisConfigOptions config =
fromConfigOptions(singletonMap("cancunEOFTime", 1670470142));
assertThat(config.getCancunEOFTime()).hasValue(1670470142);
}

@Test
void shouldGetPragueTime() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("pragueTime", 1670470143));
Expand Down Expand Up @@ -238,6 +245,7 @@ void shouldNotReturnEmptyOptionalWhenBlockNumberNotSpecified() {
assertThat(config.getMergeNetSplitBlockNumber()).isEmpty();
assertThat(config.getShanghaiTime()).isEmpty();
assertThat(config.getCancunTime()).isEmpty();
assertThat(config.getCancunEOFTime()).isEmpty();
assertThat(config.getPragueTime()).isEmpty();
assertThat(config.getPragueEOFTime()).isEmpty();
assertThat(config.getFutureEipsTime()).isEmpty();
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
Loading

0 comments on commit 6ba69e1

Please sign in to comment.