Skip to content

Commit f4c8b36

Browse files
daniellehrnerahamlatmacfarlafab-10mirgee
authored
Merge latest main into bal-devnet-3 (#10207)
* Add SHL, SHR and SAR shift operations for EVM v2 (#10154) * Add SHL, SHR and SAR implementations and benchmarks for EVM v2 Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Upgrade RocksDB version from 9.7.3 to 10.6.2 (#9767) * Upgrade RocksDB version from 9.7.3 to 10.6.2 * Fix JNI SIGSEGV crashes Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> * Add missing verification metadata (#10198) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Stream debug_traceBlock* responses directly to avoid OOM on large blocks (#9848) * stream block traces on op code level Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * correctly parse default setting for memory tracing Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * fix initcode capture for failed create op codes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * created separate streaming debug tracer, for batch request fall back to accumulation in memory, adddress pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * execute tests from genesis and verify full trace Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * addressed pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * optimize trace streaming and struct log handling Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * spotless Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Fix remaining issues and add unit tests Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * added back pressure when writing to the socket and reduced the buffer size to work better with netty's default buffer size Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * improve error handling by deferring to send the header only when data is available, allows to send the proper error codes during setup Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * compactHex candidate comparison Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * wire in more performant hex writer Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * introduce separate timeout for streaming calls, defaults to 10 minutes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Fix streamin/accumulating output parity, added missing refund field, corrected error format, reason encoding, returnValue prefix, and precompile gasCost, with equivalence tests between both Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * revert accidental removal of 0x prefix Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * pad memory bytes to 32 bytes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Ameziane H. <ameziane.hamlat@consensys.net> * Optimize performance and reduce memory when creating Quantity from scalar (#10134) * Optimize performance and reduce memory when creating Quantity from scalar Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Benchmark other implementations Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * snap sync - apply BALs before flat db heal (#10151) Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> * Remove dryRunDetector workaround methods from unit tests (#10201) * Remove dryRunDetector workaround methods from unit tests The dryRunDetector methods were added as a workaround for a Gradle issue that prevented @ParameterizedTest classes from being selected when running with --dry-run. Since the issue is fixed and --dry-run is no longer used, these methods are no longer needed. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove dryRunDetector workaround from acceptance tests too The Gradle issue is confirmed fixed, so the workaround is no longer needed anywhere, including acceptance tests. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * preserve state gas reservoir for the top level frame in case of OOG (#10205) Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> Co-authored-by: ahamlat <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Miroslav Kovář <miroslavkovar@protonmail.com>
1 parent 69b4bda commit f4c8b36

File tree

105 files changed

+654
-832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+654
-832
lines changed

acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import org.awaitility.Awaitility;
6363
import org.junit.jupiter.api.AfterEach;
6464
import org.junit.jupiter.api.BeforeEach;
65-
import org.junit.jupiter.api.Test;
6665
import org.junit.jupiter.api.TestInfo;
6766
import org.junit.jupiter.api.extension.ExtendWith;
6867
import org.slf4j.Logger;
@@ -210,11 +209,4 @@ protected void waitForFile(final Path path) {
210209
}
211210
});
212211
}
213-
214-
@Test
215-
public void dryRunDetector() {
216-
assertThat(true)
217-
.withFailMessage("This test is here so gradle --dry-run executes this class")
218-
.isTrue();
219-
}
220212
}

acceptance-tests/tests/src/acceptanceTest/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import okhttp3.Request;
4141
import okhttp3.RequestBody;
4242
import okhttp3.Response;
43-
import org.junit.jupiter.api.Test;
4443
import org.junit.jupiter.params.ParameterizedTest;
4544
import org.junit.jupiter.params.provider.Arguments;
4645
import org.junit.jupiter.params.provider.MethodSource;
@@ -148,11 +147,4 @@ public static Stream<Arguments> testCasesFromPath(final String testCasesPath)
148147

149148
return Arrays.stream(testCasesList).sorted().map(File::toURI).map(Arguments::of);
150149
}
151-
152-
@Test
153-
void dryRunDetector() {
154-
assertThat(true)
155-
.withFailMessage("This test is here so gradle --dry-run executes this class")
156-
.isTrue();
157-
}
158150
}

app/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949

5050
import com.google.common.collect.Streams;
5151
import org.apache.tuweni.bytes.Bytes;
52-
import org.junit.jupiter.api.Test;
5352
import org.junit.jupiter.api.extension.ExtendWith;
5453
import org.junit.jupiter.params.ParameterizedTest;
5554
import org.junit.jupiter.params.provider.MethodSource;
@@ -207,11 +206,4 @@ public Stream<Long> streamMilestoneBlocks() {
207206
MilestoneStreamingProtocolSchedule::streamMilestoneBlocks);
208207
}
209208
}
210-
211-
@Test
212-
void dryRunDetector() {
213-
assertThat(true)
214-
.withFailMessage("This test is here so gradle --dry-run executes this class")
215-
.isTrue();
216-
}
217209
}

app/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import dagger.Component;
6565
import dagger.Module;
6666
import dagger.Provides;
67-
import org.junit.jupiter.api.Test;
6867
import org.junit.jupiter.api.io.TempDir;
6968
import org.junit.jupiter.params.ParameterizedTest;
7069
import org.junit.jupiter.params.provider.Arguments;
@@ -348,13 +347,6 @@ public void importChain_specialFields(final String consensusEngine) throws IOExc
348347
.hasMessage(
349348
"Some fields (coinbase, extraData) are no longer supported for block import since PoW consensus has been removed");
350349
}
351-
352-
@Test
353-
void dryRunDetector() {
354-
assertThat(true)
355-
.withFailMessage("This test is here so gradle --dry-run executes this class")
356-
.isTrue();
357-
}
358350
}
359351

360352
protected Block getBlockAt(final Blockchain blockchain, final long blockNumber) {

app/src/test/java/org/hyperledger/besu/cli/NetworkDeprecationMessageTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.hyperledger.besu.config.NetworkDefinition;
2121

22-
import org.junit.jupiter.api.Test;
2322
import org.junit.jupiter.params.ParameterizedTest;
2423
import org.junit.jupiter.params.provider.EnumSource;
2524

@@ -42,11 +41,4 @@ void shouldThrowErrorForNonDeprecatedNetworks(final NetworkDefinition network) {
4241
assertThatThrownBy(() -> NetworkDeprecationMessage.generate(network))
4342
.isInstanceOf(AssertionError.class);
4443
}
45-
46-
@Test
47-
void dryRunDetector() {
48-
assertThat(true)
49-
.withFailMessage("This test is here so gradle --dry-run executes this class")
50-
.isTrue();
51-
}
5244
}

consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/VoteValidationRuleTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import java.util.stream.Stream;
2424

25-
import org.junit.jupiter.api.Test;
2625
import org.junit.jupiter.api.extension.ExtensionContext;
2726
import org.junit.jupiter.params.ParameterizedTest;
2827
import org.junit.jupiter.params.provider.Arguments;
@@ -53,11 +52,4 @@ public void test(final long input, final boolean expectedResult) {
5352

5453
assertThat(uut.validate(header, null)).isEqualTo(expectedResult);
5554
}
56-
57-
@Test
58-
void dryRunDetector() {
59-
assertThat(true)
60-
.withFailMessage("This test is here so gradle --dry-run executes this class")
61-
.isTrue();
62-
}
6355
}

ethereum/api/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ dependencies {
3434
api 'org.slf4j:slf4j-api'
3535
api 'org.apache.logging.log4j:log4j-api'
3636

37+
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess'
38+
3739
compileOnly 'org.jspecify:jspecify'
3840

3941
implementation project(':config')
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* Copyright contributors to 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+
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
16+
17+
import java.util.Objects;
18+
import java.util.concurrent.TimeUnit;
19+
20+
import org.apache.tuweni.units.bigints.UInt256;
21+
import org.apache.tuweni.units.bigints.UInt256Value;
22+
import org.openjdk.jmh.annotations.Benchmark;
23+
import org.openjdk.jmh.annotations.BenchmarkMode;
24+
import org.openjdk.jmh.annotations.Measurement;
25+
import org.openjdk.jmh.annotations.Mode;
26+
import org.openjdk.jmh.annotations.OutputTimeUnit;
27+
import org.openjdk.jmh.annotations.Param;
28+
import org.openjdk.jmh.annotations.Scope;
29+
import org.openjdk.jmh.annotations.State;
30+
import org.openjdk.jmh.annotations.Warmup;
31+
import org.openjdk.jmh.infra.Blackhole;
32+
33+
@State(Scope.Thread)
34+
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
35+
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
36+
@OutputTimeUnit(value = TimeUnit.NANOSECONDS)
37+
@BenchmarkMode(Mode.AverageTime)
38+
public class QuantityLongToHexBenchmark {
39+
private static final String HEX_PREFIX = "0x";
40+
public static final String HEX_ZERO = "0x0";
41+
private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray();
42+
43+
@Param({"0", "255", "65535", "1000000", "9007199254740991", "9223372036854775807"})
44+
public long value;
45+
46+
@Benchmark
47+
public void current(final Blackhole blackhole) {
48+
blackhole.consume(uint256ToHex(UInt256.fromHexString(Long.toHexString(value))));
49+
}
50+
51+
@Benchmark
52+
public void simpleHexString(final Blackhole blackhole) {
53+
blackhole.consume(simpleHexString(value));
54+
}
55+
56+
@Benchmark
57+
public void directCharArray(final Blackhole blackhole) {
58+
blackhole.consume(directCharArray(value));
59+
}
60+
61+
@Benchmark
62+
public void unrolled(final Blackhole blackhole) {
63+
blackhole.consume(unrolled(value));
64+
}
65+
66+
private static String simpleHexString(final long value) {
67+
return HEX_PREFIX + Long.toHexString(value);
68+
}
69+
70+
private static String unrolled(final long value) {
71+
if (value == 0L) {
72+
return HEX_ZERO;
73+
}
74+
final int leadingZeroNibbles = Long.numberOfLeadingZeros(value) >>> 2;
75+
final char[] buf = new char[18];
76+
buf[2] = HEX_DIGITS[(int) ((value >>> 60) & 0xF)];
77+
buf[3] = HEX_DIGITS[(int) ((value >>> 56) & 0xF)];
78+
buf[4] = HEX_DIGITS[(int) ((value >>> 52) & 0xF)];
79+
buf[5] = HEX_DIGITS[(int) ((value >>> 48) & 0xF)];
80+
buf[6] = HEX_DIGITS[(int) ((value >>> 44) & 0xF)];
81+
buf[7] = HEX_DIGITS[(int) ((value >>> 40) & 0xF)];
82+
buf[8] = HEX_DIGITS[(int) ((value >>> 36) & 0xF)];
83+
buf[9] = HEX_DIGITS[(int) ((value >>> 32) & 0xF)];
84+
buf[10] = HEX_DIGITS[(int) ((value >>> 28) & 0xF)];
85+
buf[11] = HEX_DIGITS[(int) ((value >>> 24) & 0xF)];
86+
buf[12] = HEX_DIGITS[(int) ((value >>> 20) & 0xF)];
87+
buf[13] = HEX_DIGITS[(int) ((value >>> 16) & 0xF)];
88+
buf[14] = HEX_DIGITS[(int) ((value >>> 12) & 0xF)];
89+
buf[15] = HEX_DIGITS[(int) ((value >>> 8) & 0xF)];
90+
buf[16] = HEX_DIGITS[(int) ((value >>> 4) & 0xF)];
91+
buf[17] = HEX_DIGITS[(int) (value & 0xF)];
92+
buf[leadingZeroNibbles] = '0';
93+
buf[leadingZeroNibbles + 1] = 'x';
94+
return new String(buf, leadingZeroNibbles, 18 - leadingZeroNibbles);
95+
}
96+
97+
private static String directCharArray(final long value) {
98+
if (value == 0L) {
99+
return HEX_ZERO;
100+
}
101+
int nibbles = 16;
102+
while (nibbles > 1 && ((value >>> ((nibbles - 1) * 4)) & 0xFL) == 0L) {
103+
nibbles--;
104+
}
105+
final char[] buf = new char[2 + nibbles];
106+
buf[0] = '0';
107+
buf[1] = 'x';
108+
for (int i = 0; i < nibbles; i++) {
109+
buf[2 + i] = HEX_DIGITS[(int) ((value >>> ((nibbles - 1 - i) * 4)) & 0xFL)];
110+
}
111+
return new String(buf);
112+
}
113+
114+
private static String uint256ToHex(final UInt256Value<?> value) {
115+
return value == null ? null : formatMinimalValue(value.toMinimalBytes().toShortHexString());
116+
}
117+
118+
private static String formatMinimalValue(final String hexValue) {
119+
final String prefixedHexString = prefixHexNotation(hexValue);
120+
return Objects.equals(prefixedHexString, HEX_PREFIX) ? HEX_ZERO : prefixedHexString;
121+
}
122+
123+
private static String prefixHexNotation(final String hexValue) {
124+
return hexValue.startsWith(HEX_PREFIX) ? hexValue : HEX_PREFIX + hexValue;
125+
}
126+
}

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/Quantity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,29 @@ public static String create(final UInt64Value<?> value) {
4444
}
4545

4646
public static String create(final int value) {
47-
return uint256ToHex(UInt256.valueOf(value));
47+
return HEX_PREFIX + Integer.toHexString(value);
4848
}
4949

5050
public static String create(final long value) {
51-
return uint256ToHex(UInt256.fromHexString(Long.toHexString(value)));
51+
return HEX_PREFIX + Long.toHexString(value);
52+
}
53+
54+
public static String create(final byte value) {
55+
return HEX_PREFIX + Integer.toHexString(value);
5256
}
5357

5458
public static String create(final Bytes value) {
55-
return create(value.toArrayUnsafe());
59+
return uint256ToHex(UInt256.fromBytes(Bytes32.leftPad(value)));
5660
}
5761

5862
public static String create(final byte[] value) {
59-
return uint256ToHex(UInt256.fromBytes(Bytes32.leftPad(Bytes.wrap(value))));
63+
return create(Bytes.wrap(value));
6064
}
6165

6266
public static String create(final BigInteger value) {
6367
return uint256ToHex(UInt256.valueOf(value));
6468
}
6569

66-
public static String create(final byte value) {
67-
return formatMinimalValue(Integer.toHexString(value));
68-
}
69-
7070
/**
7171
* Fixed-length bytes sequences and should be returned as hex strings zero-padded to the expected
7272
* length.

ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/EthGraphQLHttpBySpecTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.hyperledger.besu.ethereum.api.graphql;
1616

1717
import static com.google.common.base.Preconditions.checkState;
18-
import static org.assertj.core.api.Assertions.assertThat;
1918

2019
import java.io.IOException;
2120
import java.net.URISyntaxException;
@@ -32,7 +31,6 @@
3231
import okhttp3.RequestBody;
3332
import okhttp3.Response;
3433
import org.assertj.core.api.Assertions;
35-
import org.junit.jupiter.api.Test;
3634
import org.junit.jupiter.params.ParameterizedTest;
3735
import org.junit.jupiter.params.provider.Arguments;
3836
import org.junit.jupiter.params.provider.MethodSource;
@@ -86,11 +84,4 @@ private void graphQLCall(final String name) throws IOException {
8684
Assertions.assertThat(resp.code()).isEqualTo(expectedStatusCode);
8785
}
8886
}
89-
90-
@Test
91-
void dryRunDetector() {
92-
assertThat(true)
93-
.withFailMessage("This test is here so gradle --dry-run executes this class")
94-
.isTrue();
95-
}
9687
}

0 commit comments

Comments
 (0)