Skip to content

Commit

Permalink
Update Tuweni to 2.4.1 (hyperledger#5513)
Browse files Browse the repository at this point in the history
* update to 2.4.1

* update use of DNS daemon with Vertx

* fix issue with Bytes.repeat

* update antlr version

* fix dns tests

Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>

---------

Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
atoulme and macfarla authored Jun 9, 2023
1 parent 39577fd commit b964181
Show file tree
Hide file tree
Showing 41 changed files with 388 additions and 96 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and in case a rollback is needed, before installing a previous version, the migr
- Tidy DEBUG logs by moving engine API full logging to TRACE [#5529](https://github.com/hyperledger/besu/pull/5529)
- remove PoW validation if merge is enabled as it is not needed anymore [#5538](https://github.com/hyperledger/besu/pull/5538)
- Use BlobDB for blockchain storage to reduce initial sync time and write amplification [#5475](https://github.com/hyperledger/besu/pull/5475)
- Update to Tuweni 2.4.1. [#5513](https://github.com/hyperledger/besu/pull/5513)

### Bug Fixes
- check to ensure storage and transactions are not closed prior to reading/writing [#5527](https://github.com/hyperledger/besu/pull/5527)
Expand Down
6 changes: 3 additions & 3 deletions acceptance-tests/dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ dependencies {
implementation 'io.vertx:vertx-core'
implementation 'junit:junit'
implementation 'io.opentelemetry:opentelemetry-api'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-io'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-io'
implementation 'io.tmio:tuweni-units'
implementation 'org.assertj:assertj-core'
implementation 'org.awaitility:awaitility'
implementation 'org.java-websocket:Java-WebSocket'
Expand Down
2 changes: 1 addition & 1 deletion acceptance-tests/tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies {
testImplementation 'junit:junit'
testImplementation 'org.apache.commons:commons-compress'
testImplementation 'org.apache.logging.log4j:log4j-core'
testImplementation 'org.apache.tuweni:tuweni-crypto'
testImplementation 'io.tmio:tuweni-crypto'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
12 changes: 6 additions & 6 deletions besu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ dependencies {
implementation 'io.vertx:vertx-web'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.logging.log4j:log4j-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-config'
implementation 'org.apache.tuweni:tuweni-toml'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-config'
implementation 'io.tmio:tuweni-toml'
implementation 'io.tmio:tuweni-units'
implementation 'org.springframework.security:spring-security-crypto'
implementation 'org.xerial.snappy:snappy-java'
implementation 'tech.pegasys:jc-kzg-4844'
Expand All @@ -92,8 +92,8 @@ dependencies {
testImplementation 'io.opentelemetry:opentelemetry-api'
testImplementation 'junit:junit'
testImplementation 'org.apache.commons:commons-text'
testImplementation 'org.apache.tuweni:tuweni-bytes'
testImplementation 'org.apache.tuweni:tuweni-units'
testImplementation 'io.tmio:tuweni-bytes'
testImplementation 'io.tmio:tuweni-units'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
4 changes: 2 additions & 2 deletions config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'info.picocli:picocli'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

testImplementation project(':testutil')

Expand Down
4 changes: 2 additions & 2 deletions consensus/clique/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

testImplementation project(path: ':consensus:common', configuration: 'testArtifacts')
testImplementation project(path: ':crypto:services', configuration: 'testSupportArtifacts')
Expand Down
2 changes: 1 addition & 1 deletion consensus/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'io.tmio:tuweni-bytes'

testImplementation project(':config')
testImplementation project(':crypto:algorithms')
Expand Down
4 changes: 2 additions & 2 deletions consensus/ibft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts')
integrationTestImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
Expand Down
4 changes: 2 additions & 2 deletions consensus/merge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

testImplementation project(path: ':consensus:common', configuration: 'testArtifacts')
testImplementation project(':crypto:algorithms')
Expand Down
4 changes: 2 additions & 2 deletions consensus/qbft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation 'org.web3j:abi'

integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts')
Expand Down
4 changes: 2 additions & 2 deletions crypto/algorithms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ dependencies {
api 'org.slf4j:slf4j-api'

implementation 'net.java.dev.jna:jna'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation 'org.hyperledger.besu:secp256k1'
implementation 'org.hyperledger.besu:secp256r1'
implementation 'org.hyperledger.besu:blake2bf'
Expand Down
4 changes: 2 additions & 2 deletions datatypes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ dependencies {
implementation project(':crypto:algorithms')
implementation project(':ethereum:rlp')
implementation 'com.google.guava:guava'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
Expand Down
2 changes: 1 addition & 1 deletion enclave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'io.vertx:vertx-web'
implementation 'org.apache.tuweni:tuweni-net'
implementation 'io.tmio:tuweni-net'

runtimeOnly('org.bouncycastle:bcpkix-jdk15on')

Expand Down
8 changes: 4 additions & 4 deletions ethereum/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ dependencies {
implementation 'io.vertx:vertx-web'
implementation 'io.vertx:vertx-codegen'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-net'
implementation 'org.apache.tuweni:tuweni-toml'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-net'
implementation 'io.tmio:tuweni-toml'
implementation 'io.tmio:tuweni-units'
implementation 'org.antlr:antlr4-runtime'
implementation 'org.bouncycastle:bcprov-jdk15on'
implementation 'org.springframework.security:spring-security-crypto'
Expand Down
4 changes: 2 additions & 2 deletions ethereum/blockcreation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dependencies {

implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'

testImplementation project(path: ':config', configuration: 'testSupportArtifacts')
testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts')
Expand Down
14 changes: 7 additions & 7 deletions ethereum/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ dependencies {

implementation 'net.java.dev.jna:jna'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-concurrent'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-rlp'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-concurrent'
implementation 'io.tmio:tuweni-units'
implementation 'io.tmio:tuweni-rlp'
implementation 'org.hyperledger.besu:bls12-381'
implementation 'org.immutables:value-annotations'

Expand All @@ -77,9 +77,9 @@ dependencies {

testImplementation 'junit:junit'
testImplementation 'org.apache.logging.log4j:log4j-core'
testImplementation 'org.apache.tuweni:tuweni-bytes'
testImplementation 'org.apache.tuweni:tuweni-io'
testImplementation 'org.apache.tuweni:tuweni-units'
testImplementation 'io.tmio:tuweni-bytes'
testImplementation 'io.tmio:tuweni-io'
testImplementation 'io.tmio:tuweni-units'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class TransactionTestFixture {
private static final Hash DEFAULT_VERSIONED_HASH =
Hash.wrap(
Bytes32.wrap(
Bytes.concatenate(Bytes.fromHexString("0x01"), Bytes.repeat((byte) 42, 31))));
Bytes.concatenate(
Bytes.fromHexString("0x01"), Bytes.fromHexString("2a".repeat(31)))));

private TransactionType transactionType = TransactionType.FRONTIER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class WithdrawalEncoderTest {
"0xd8808094000000000000000000000000000000000000000080";
public static final String WITHDRAWAL_MAX_VALUE =
"0xf088ffffffffffffffff88ffffffffffffffff94ffffffffffffffffffffffffffffffffffffffff88ffffffffffffffff";
public static final Address MAX_ADDRESS =
Address.fromHexString(Bytes.repeat((byte) 0xff, 20).toHexString());
public static final Address MAX_ADDRESS = Address.fromHexString("ff".repeat(20));

@Test
void shouldEncodeWithdrawalForZeroCase() {
Expand Down
6 changes: 3 additions & 3 deletions ethereum/eth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-rlp'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation 'io.tmio:tuweni-rlp'

annotationProcessor "org.immutables:value"
implementation "org.immutables:value-annotations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected TransactionTestFixture prepareTransaction(
.nonce(nonce)
.type(type);
if (payloadSize > 0) {
var payloadBytes = Bytes.repeat((byte) 1, payloadSize);
var payloadBytes = Bytes.fromHexString("01".repeat(payloadSize));
tx.payload(payloadBytes);
}
if (type.supports1559FeeMarket()) {
Expand Down
2 changes: 1 addition & 1 deletion ethereum/ethstats/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'com.squareup.okhttp3:okhttp'
implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'io.tmio:tuweni-bytes'

implementation project(':consensus:clique')
implementation project(':config')
Expand Down
2 changes: 1 addition & 1 deletion ethereum/mock-p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
implementation project(':util')

implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'io.tmio:tuweni-bytes'

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
Expand Down
14 changes: 7 additions & 7 deletions ethereum/p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ dependencies {
implementation 'io.prometheus:simpleclient'
implementation 'io.vertx:vertx-core'

implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-crypto'
implementation('org.apache.tuweni:tuweni-devp2p') {
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-crypto'
implementation('io.tmio:tuweni-devp2p') {
exclude group:'ch.qos.logback', module:'logback-classic'
}
implementation('org.apache.tuweni:tuweni-dns-discovery'){
implementation('io.tmio:tuweni-dns-discovery'){
exclude group:'ch.qos.logback', module:'logback-classic'
}
implementation 'org.apache.tuweni:tuweni-io'
implementation 'org.apache.tuweni:tuweni-rlp'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-io'
implementation 'io.tmio:tuweni-rlp'
implementation 'io.tmio:tuweni-units'
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
implementation 'org.xerial.snappy:snappy-java'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public class DefaultP2PNetwork implements P2PNetwork {
private final AtomicBoolean stopped = new AtomicBoolean(false);
private final CountDownLatch shutdownLatch = new CountDownLatch(2);
private final Duration shutdownTimeout = Duration.ofSeconds(15);
private final Vertx vertx;
private DNSDaemon dnsDaemon;

/**
Expand All @@ -163,6 +164,7 @@ public class DefaultP2PNetwork implements P2PNetwork {
* @param maintainedPeers A collection of peers for which we are expected to maintain connections
* @param reputationManager An object that inspect disconnections for misbehaving peers that can
* then be blacklisted.
* @param vertx the Vert.x instance managing network resources
*/
DefaultP2PNetwork(
final MutableLocalNode localNode,
Expand All @@ -173,7 +175,8 @@ public class DefaultP2PNetwork implements P2PNetwork {
final PeerPermissions peerPermissions,
final NatService natService,
final MaintainedPeers maintainedPeers,
final PeerDenylistManager reputationManager) {
final PeerDenylistManager reputationManager,
final Vertx vertx) {
this.localNode = localNode;
this.peerDiscoveryAgent = peerDiscoveryAgent;
this.rlpxAgent = rlpxAgent;
Expand All @@ -183,6 +186,7 @@ public class DefaultP2PNetwork implements P2PNetwork {

this.nodeId = nodeKey.getPublicKey().getEncodedBytes();
this.peerPermissions = peerPermissions;
this.vertx = vertx;

// set the requirement here that the number of peers be greater than the lower bound
final int peerLowerBound = rlpxAgent.getPeerLowerBound();
Expand Down Expand Up @@ -229,7 +233,8 @@ public void start() {
createDaemonListener(),
0L,
600000L,
config.getDnsDiscoveryServerOverride().orElse(null));
config.getDnsDiscoveryServerOverride().orElse(null),
vertx);
dnsDaemon.start();
});

Expand Down Expand Up @@ -535,7 +540,8 @@ private P2PNetwork doBuild() {
peerPermissions,
natService,
maintainedPeers,
reputationManager);
reputationManager,
vertx);
}

private void validate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.vertx.core.Vertx;
import io.vertx.core.dns.DnsClient;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.crypto.SECP256K1;
import org.assertj.core.api.Assertions;
Expand Down Expand Up @@ -348,8 +350,12 @@ public void shouldStartDnsDiscoveryWhenDnsURLIsConfigured() {
final NetworkingConfiguration dnsConfig =
when(spy(config).getDiscovery()).thenReturn(disco).getMock();

Vertx vertx = mock(Vertx.class);
when(vertx.createDnsClient(any())).thenReturn(mock(DnsClient.class));

// spy on DefaultP2PNetwork
final DefaultP2PNetwork testClass = (DefaultP2PNetwork) builder().config(dnsConfig).build();
final DefaultP2PNetwork testClass =
(DefaultP2PNetwork) builder().vertx(vertx).config(dnsConfig).build();

testClass.start();
assertThat(testClass.getDnsDaemon()).isPresent();
Expand All @@ -366,7 +372,11 @@ public void shouldUseDnsServerOverrideIfPresent() {
doReturn(disco).when(dnsConfig).getDiscovery();
doReturn(Optional.of("localhost")).when(dnsConfig).getDnsDiscoveryServerOverride();

final DefaultP2PNetwork testClass = (DefaultP2PNetwork) builder().config(dnsConfig).build();
Vertx vertx = mock(Vertx.class);
when(vertx.createDnsClient(any())).thenReturn(mock(DnsClient.class));

final DefaultP2PNetwork testClass =
(DefaultP2PNetwork) builder().config(dnsConfig).vertx(vertx).build();
testClass.start();

// ensure we used the dns server override config when building DNSDaemon:
Expand Down
6 changes: 3 additions & 3 deletions ethereum/permissioning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ dependencies {

implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-toml'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-toml'
implementation 'io.tmio:tuweni-units'
implementation 'org.web3j:abi'

testImplementation project(':config')
Expand Down
Loading

0 comments on commit b964181

Please sign in to comment.