Skip to content

Commit 66f82dc

Browse files
authored
Merge branch 'main' into no-persist
2 parents b4f37f1 + b1ac5ac commit 66f82dc

File tree

13 files changed

+494
-18
lines changed

13 files changed

+494
-18
lines changed

acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,30 @@ public BesuNode createIbft2Node(final String name, final String genesisFile) thr
461461
.build());
462462
}
463463

464-
public BesuNode createIbft2Node(final String name) throws IOException {
465-
return create(
464+
public BesuNode createIbft2Node(final String name, final boolean fixedPort) throws IOException {
465+
JsonRpcConfiguration rpcConfig = node.createJsonRpcWithIbft2EnabledConfig(false);
466+
rpcConfig.addRpcApi("ADMIN,TXPOOL");
467+
if (fixedPort) {
468+
rpcConfig.setPort(
469+
Math.abs(name.hashCode() % 60000)
470+
+ 1024); // Generate a consistent port for p2p based on node name
471+
}
472+
BesuNodeConfigurationBuilder builder =
466473
new BesuNodeConfigurationBuilder()
467474
.name(name)
468475
.miningEnabled()
469-
.jsonRpcConfiguration(node.createJsonRpcWithIbft2EnabledConfig(false))
476+
.jsonRpcConfiguration(rpcConfig)
470477
.webSocketConfiguration(node.createWebSocketEnabledConfig())
471478
.devMode(false)
472-
.genesisConfigProvider(GenesisConfigurationFactory::createIbft2GenesisConfig)
473-
.build());
479+
.genesisConfigProvider(GenesisConfigurationFactory::createIbft2GenesisConfig);
480+
if (fixedPort) {
481+
builder.p2pPort(
482+
Math.abs(name.hashCode() % 60000)
483+
+ 1024
484+
+ 500); // Generate a consistent port for p2p based on node name (+ 500 to avoid
485+
// clashing with RPC port or other nodes with a similar name)
486+
}
487+
return create(builder.build());
474488
}
475489

476490
public BesuNode createQbftNodeWithTLS(final String name, final String type) throws IOException {
@@ -498,16 +512,31 @@ public BesuNode createQbftNodeWithTLSPKCS11(final String name) throws IOExceptio
498512
return createQbftNodeWithTLS(name, KeyStoreWrapper.KEYSTORE_TYPE_PKCS11);
499513
}
500514

501-
public BesuNode createQbftNode(final String name) throws IOException {
502-
return create(
515+
public BesuNode createQbftNode(final String name, final boolean fixedPort) throws IOException {
516+
JsonRpcConfiguration rpcConfig = node.createJsonRpcWithQbftEnabledConfig(false);
517+
rpcConfig.addRpcApi("ADMIN,TXPOOL");
518+
if (fixedPort) {
519+
rpcConfig.setPort(
520+
Math.abs(name.hashCode() % 60000)
521+
+ 1024); // Generate a consistent port for p2p based on node name
522+
}
523+
524+
BesuNodeConfigurationBuilder builder =
503525
new BesuNodeConfigurationBuilder()
504526
.name(name)
505527
.miningEnabled()
506-
.jsonRpcConfiguration(node.createJsonRpcWithQbftEnabledConfig(false))
528+
.jsonRpcConfiguration(rpcConfig)
507529
.webSocketConfiguration(node.createWebSocketEnabledConfig())
508530
.devMode(false)
509-
.genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig)
510-
.build());
531+
.genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig);
532+
if (fixedPort) {
533+
builder.p2pPort(
534+
Math.abs(name.hashCode() % 60000)
535+
+ 1024
536+
+ 500); // Generate a consistent port for p2p based on node name (+ 500 to avoid
537+
// clashing with RPC port or other nodes with a similar name)
538+
}
539+
return create(builder.build());
511540
}
512541

513542
public BesuNode createCustomGenesisNode(

acceptance-tests/tests/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ solidity {
2424
resolvePackages = false
2525
// TODO: remove the forced version, when DEV network is upgraded to support latest forks
2626
version '0.8.19'
27+
evmVersion 'london'
2728
}
2829

2930
dependencies {
@@ -79,6 +80,7 @@ dependencies {
7980
testImplementation 'org.web3j:besu'
8081
testImplementation 'org.web3j:core'
8182
testImplementation 'org.wiremock:wiremock'
83+
testImplementation project(path: ':acceptance-tests:tests:shanghai')
8284

8385
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
8486
}
@@ -153,6 +155,7 @@ task acceptanceTestMainnet(type: Test) {
153155
task acceptanceTestNotPrivacy(type: Test) {
154156
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
155157
exclude '**/privacy/**'
158+
exclude '**/bftsoak/**'
156159

157160
useJUnitPlatform {}
158161

@@ -205,6 +208,35 @@ task acceptanceTestCliqueBft(type: Test) {
205208
doFirst { mkdir "${buildDir}/jvmErrorLogs" }
206209
}
207210

211+
task acceptanceTestBftSoak(type: Test) {
212+
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
213+
include '**/bftsoak/**'
214+
215+
useJUnitPlatform {}
216+
217+
dependsOn(rootProject.installDist)
218+
setSystemProperties(test.getSystemProperties())
219+
systemProperty 'acctests.runBesuAsProcess', 'true'
220+
// Set to any time > 60 minutes to run the soak test for longer
221+
// systemProperty 'acctests.soakTimeMins', '120'
222+
systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security"
223+
mustRunAfter rootProject.subprojects*.test
224+
description = 'Runs BFT soak test.'
225+
group = 'verification'
226+
227+
jvmArgs "-XX:ErrorFile=${buildDir}/jvmErrorLogs/java_err_pid%p.log"
228+
229+
testLogging {
230+
exceptionFormat = 'full'
231+
showStackTraces = true
232+
showStandardStreams = true
233+
showExceptions = true
234+
showCauses = true
235+
}
236+
237+
doFirst { mkdir "${buildDir}/jvmErrorLogs" }
238+
}
239+
208240
task acceptanceTestPrivacy(type: Test) {
209241
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
210242
include '**/privacy/**'

acceptance-tests/tests/contracts/CrossContractReader.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "./EventEmitter.sol";
1919
// compile with:
2020
// solc CrossContractReader.sol --bin --abi --optimize --overwrite -o .
2121
// then create web3j wrappers with:
22-
// web3j solidity generate -b ./generated/CrossContractReader.bin -a ./generated/CrossContractReader.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
22+
// web3j generate solidity -b ./generated/CrossContractReader.bin -a ./generated/CrossContractReader.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
2323
contract CrossContractReader {
2424
uint counter;
2525

acceptance-tests/tests/contracts/EventEmitter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pragma solidity >=0.7.0 <0.9.0;
1717
// compile with:
1818
// solc EventEmitter.sol --bin --abi --optimize --overwrite -o .
1919
// then create web3j wrappers with:
20-
// web3j solidity generate -b ./generated/EventEmitter.bin -a ./generated/EventEmitter.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
20+
// web3j generate solidity -b ./generated/EventEmitter.bin -a ./generated/EventEmitter.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
2121
contract EventEmitter {
2222
address owner;
2323
event stored(address _to, uint _amount);

acceptance-tests/tests/contracts/RemoteSimpleStorage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "./SimpleStorage.sol";
1919
// compile with:
2020
// solc RemoteSimpleStorage.sol --bin --abi --optimize --overwrite -o .
2121
// then create web3j wrappers with:
22-
// web3j solidity generate -b ./generated/RemoteSimpleStorage.bin -a ./generated/RemoteSimpleStorage.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
22+
// web3j generate solidity -b ./generated/RemoteSimpleStorage.bin -a ./generated/RemoteSimpleStorage.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
2323
contract RemoteSimpleStorage {
2424
SimpleStorage public simpleStorage;
2525

acceptance-tests/tests/contracts/RevertReason.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pragma solidity >=0.7.0 <0.9.0;
1717
// compile with:
1818
// solc RevertReason.sol --bin --abi --optimize --overwrite -o .
1919
// then create web3j wrappers with:
20-
// web3j solidity generate -b ./generated/RevertReason.bin -a ./generated/RevertReason.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
20+
// web3j generate solidity -b ./generated/RevertReason.bin -a ./generated/RevertReason.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
2121
contract RevertReason {
2222

2323
function revertWithRevertReason() public pure returns (bool) {

acceptance-tests/tests/contracts/SimpleStorage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pragma solidity >=0.7.0 <0.8.20;
1717
// compile with:
1818
// solc SimpleStorage.sol --bin --abi --optimize --overwrite -o .
1919
// then create web3j wrappers with:
20-
// web3j solidity generate -b ./generated/SimpleStorage.bin -a ./generated/SimpleStorage.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
20+
// web3j generate solidity -b ./generated/SimpleStorage.bin -a ./generated/SimpleStorage.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
2121
contract SimpleStorage {
2222
uint data;
2323

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
plugins {
3+
id 'org.web3j' version '4.11.3'
4+
id 'org.web3j.solidity' version '0.4.1'
5+
}
6+
7+
jar { enabled = true }
8+
9+
web3j {
10+
generatedPackageName = 'org.hyperledger.besu.tests.web3j.generated'
11+
}
12+
13+
sourceSets.main.solidity.srcDirs = [
14+
"$projectDir/shanghaicontracts"
15+
]
16+
17+
solidity {
18+
resolvePackages = false
19+
version '0.8.25'
20+
evmVersion 'shanghai'
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright contributors to Hyperledger Besu.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*
13+
* SPDX-License-Identifier: Apache-2.0
14+
*/
15+
pragma solidity >=0.8.20;
16+
17+
// compile with:
18+
// solc SimpleStorageShanghai.sol --bin --abi --optimize --overwrite -o .
19+
// then create web3j wrappers with:
20+
// web3j generate solidity -b ./SimpleStorageShanghai.bin -a ./SimpleStorageShanghai.abi -o ../../../../../ -p org.hyperledger.besu.tests.web3j.generated
21+
contract SimpleStorageShanghai {
22+
uint data;
23+
24+
function set(uint value) public {
25+
data = value;
26+
}
27+
28+
function get() public view returns (uint) {
29+
return data;
30+
}
31+
}

acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ public static Stream<Arguments> getFactories() {
3838
@FunctionalInterface
3939
public interface NodeCreator {
4040

41-
BesuNode create(BesuNodeFactory factory, String name) throws Exception;
41+
BesuNode create(BesuNodeFactory factory, String name, boolean fixedPort) throws Exception;
42+
}
43+
44+
@FunctionalInterface
45+
public interface FixedPortNodeCreator {
46+
47+
BesuNode createFixedPort(BesuNodeFactory factory, String name, boolean fixedPort)
48+
throws Exception;
4249
}
4350

4451
@FunctionalInterface
@@ -57,7 +64,11 @@ public BftAcceptanceTestParameterization(
5764
}
5865

5966
public BesuNode createNode(BesuNodeFactory factory, String name) throws Exception {
60-
return creatorFn.create(factory, name);
67+
return creatorFn.create(factory, name, false);
68+
}
69+
70+
public BesuNode createNodeFixedPort(BesuNodeFactory factory, String name) throws Exception {
71+
return creatorFn.create(factory, name, true);
6172
}
6273

6374
public BesuNode createNodeWithValidators(

0 commit comments

Comments
 (0)