Skip to content

Commit 0ce7971

Browse files
committed
Merge branch 'main' of github.com:hyperledger/besu into implement-tracing-by-opcode
2 parents abda04c + 80dc502 commit 0ce7971

File tree

47 files changed

+721
-488
lines changed

Some content is hidden

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

47 files changed

+721
-488
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@
1515
- Fast Sync
1616

1717
### Additions and Improvements
18+
- Update to vertx 4.5.22 [#9375](https://github.com/hyperledger/besu/pull/9375)
19+
20+
### Bug fixes
21+
22+
## 25.11.0
23+
24+
### Breaking Changes
25+
26+
### Upcoming Breaking Changes
27+
- Deprecated CLI options
28+
- `--Xbonsai-parallel-tx-processing-enabled` is deprecated since 25.7.0. Use `--bonsai-parallel-tx-processing-enabled` instead.
29+
- `--Xsnapsync-server-enabled` is deprecated since 25.7.0. Use `--snapsync-server-enabled` instead.
30+
- `--Xsnapsync-synchronizer-pre-merge-headers-only-enabled` is deprecated since 25.7.0. Use `--snapsync-synchronizer-pre-checkpoint-headers-only-enabled` instead.
31+
- `--Xhistory-expiry-prune` is deprecated since 25.7.0. Use `--history-expiry-prune` instead.
32+
- Sunsetting features - for more context on the reasoning behind the deprecation of these features, including alternative options, read [this blog post](https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu)
33+
- Proof of Work consensus (PoW)
34+
- Fast Sync
35+
36+
### Additions and Improvements
37+
- Add Osaka, BPO1 and BPO2 fork times for mainnet [#9380](https://github.com/hyperledger/besu/pull/9380)
1838
- Add blockTimestamp to receipt logs for `eth_getBlockReceipts` and `eth_getTransactionReceipt` results [#9294](https://github.com/hyperledger/besu/pull/9294)
1939
- Upgrade to execution-spec-tests v5.3.0 [#9301](https://github.com/hyperledger/besu/pull/9301)
2040
- Update to netty 4.2.7.Final [#9330](https://github.com/hyperledger/besu/pull/9330)

acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import org.hyperledger.besu.plugin.BesuPlugin;
1818
import org.hyperledger.besu.plugin.ServiceManager;
19+
import org.hyperledger.besu.plugin.data.AddedBlockContext;
1920
import org.hyperledger.besu.plugin.data.BlockHeader;
2021
import org.hyperledger.besu.plugin.data.PropagatedBlockContext;
2122
import org.hyperledger.besu.plugin.services.BesuEvents;
@@ -37,8 +38,10 @@ public class TestBesuEventsPlugin implements BesuPlugin {
3738

3839
private ServiceManager context;
3940

40-
private Optional<Long> subscriptionId;
41-
private final AtomicInteger blockCounter = new AtomicInteger();
41+
private Optional<Long> propagationSubscriptionId;
42+
private Optional<Long> addedSubscriptionId;
43+
private final AtomicInteger propagatedBlockCounter = new AtomicInteger();
44+
private final AtomicInteger addedBlockCounter = new AtomicInteger();
4245
private File callbackDir;
4346

4447
@Override
@@ -50,26 +53,37 @@ public void register(final ServiceManager context) {
5053

5154
@Override
5255
public void start() {
53-
subscriptionId =
56+
propagationSubscriptionId =
5457
context
5558
.getService(BesuEvents.class)
5659
.map(events -> events.addBlockPropagatedListener(this::onBlockAnnounce));
57-
LOG.info("Listening with ID#" + subscriptionId);
60+
LOG.info("Listening with propagation ID#" + propagationSubscriptionId);
61+
addedSubscriptionId =
62+
context
63+
.getService(BesuEvents.class)
64+
.map(events -> events.addBlockAddedListener(this::onBlockAdded));
65+
LOG.info("Listening with added ID#" + addedSubscriptionId);
5866
}
5967

6068
@Override
6169
public void stop() {
62-
subscriptionId.ifPresent(
70+
propagationSubscriptionId.ifPresent(
6371
id ->
6472
context
6573
.getService(BesuEvents.class)
6674
.ifPresent(besuEvents -> besuEvents.removeBlockPropagatedListener(id)));
67-
LOG.info("No longer listening with ID#" + subscriptionId);
75+
LOG.info("No longer listening propagation with ID#" + propagationSubscriptionId);
76+
addedSubscriptionId.ifPresent(
77+
id ->
78+
context
79+
.getService(BesuEvents.class)
80+
.ifPresent(besuEvents -> besuEvents.removeBlockAddedListener(id)));
81+
LOG.info("No longer listening added with ID#" + addedSubscriptionId);
6882
}
6983

7084
private void onBlockAnnounce(final PropagatedBlockContext propagatedBlockContext) {
7185
final BlockHeader header = propagatedBlockContext.getBlockHeader();
72-
final int blockCount = blockCounter.incrementAndGet();
86+
final int blockCount = propagatedBlockCounter.incrementAndGet();
7387
LOG.info("I got a new block! (I've seen {}) - {}", blockCount, header);
7488
try {
7589
final File callbackFile = new File(callbackDir, "newBlock." + blockCount);
@@ -83,4 +97,27 @@ private void onBlockAnnounce(final PropagatedBlockContext propagatedBlockContext
8397
throw new RuntimeException(ioe);
8498
}
8599
}
100+
101+
private void onBlockAdded(final AddedBlockContext addedBlockContext) {
102+
final BlockHeader header = addedBlockContext.getBlockHeader();
103+
final int blockCount = addedBlockCounter.incrementAndGet();
104+
LOG.info(
105+
"New block added! (I've seen {}) - {}, eventType {}",
106+
blockCount,
107+
header,
108+
addedBlockContext.getEventType());
109+
try {
110+
final File callbackFile = new File(callbackDir, "addedBlock." + blockCount);
111+
if (!callbackFile.getParentFile().exists()) {
112+
callbackFile.getParentFile().mkdirs();
113+
callbackFile.getParentFile().deleteOnExit();
114+
}
115+
Files.write(
116+
callbackFile.toPath(),
117+
Collections.singletonList(addedBlockContext.getEventType().name()));
118+
callbackFile.deleteOnExit();
119+
} catch (final IOException ioe) {
120+
throw new RuntimeException(ioe);
121+
}
122+
}
86123
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.tests.acceptance.plugins;
16+
17+
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
18+
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
19+
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory;
20+
21+
import java.util.Collections;
22+
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
25+
26+
public class BesuEventsPluginTest extends AcceptanceTestBase {
27+
private BesuNode pluginNode;
28+
private BesuNode minerNode;
29+
30+
@BeforeEach
31+
public void setUp() throws Exception {
32+
minerNode =
33+
besu.createQbftNode(
34+
"minerNode",
35+
b ->
36+
b.genesisConfigProvider(
37+
GenesisConfigurationFactory::createQbftLondonGenesisConfig));
38+
pluginNode =
39+
besu.createQbftPluginsNode(
40+
"node1", Collections.singletonList("testPlugins"), Collections.emptyList());
41+
cluster.start(pluginNode, minerNode);
42+
}
43+
44+
@Test
45+
public void blockIsAdded() {
46+
waitForFile(pluginNode.homeDirectory().resolve("plugins/addedBlock.2"));
47+
}
48+
}

app/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,29 +1349,22 @@ protected List<PeerValidator> createPeerValidators(
13491349
if (daoBlock.isPresent()) {
13501350
// Setup dao validator
13511351
validators.add(
1352-
new DaoForkPeerValidator(
1353-
protocolSchedule, peerTaskExecutor, syncConfig, metricsSystem, daoBlock.getAsLong()));
1352+
new DaoForkPeerValidator(protocolSchedule, peerTaskExecutor, daoBlock.getAsLong()));
13541353
}
13551354

13561355
final OptionalLong classicBlock = genesisConfigOptions.getClassicForkBlock();
13571356
// setup classic validator
13581357
if (classicBlock.isPresent()) {
13591358
validators.add(
13601359
new ClassicForkPeerValidator(
1361-
protocolSchedule,
1362-
peerTaskExecutor,
1363-
syncConfig,
1364-
metricsSystem,
1365-
classicBlock.getAsLong()));
1360+
protocolSchedule, peerTaskExecutor, classicBlock.getAsLong()));
13661361
}
13671362

13681363
for (final Map.Entry<Long, Hash> requiredBlock : requiredBlocks.entrySet()) {
13691364
validators.add(
13701365
new RequiredBlocksPeerValidator(
13711366
protocolSchedule,
13721367
peerTaskExecutor,
1373-
syncConfig,
1374-
metricsSystem,
13751368
requiredBlock.getKey(),
13761369
requiredBlock.getValue()));
13771370
}

app/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ protected List<PeerValidator> createPeerValidators(
249249
new RequiredBlocksPeerValidator(
250250
protocolSchedule,
251251
peerTaskExecutor,
252-
syncConfig,
253-
metricsSystem,
254252
powTerminalBlockNumber.getAsLong(),
255253
powTerminalBlockHash.get(),
256254
0));

app/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
3030
import org.hyperledger.besu.evm.log.LogTopic;
3131
import org.hyperledger.besu.plugin.data.AddedBlockContext;
32+
import org.hyperledger.besu.plugin.data.AddedBlockContext.EventType;
3233
import org.hyperledger.besu.plugin.data.BlockHeader;
3334
import org.hyperledger.besu.plugin.data.PropagatedBlockContext;
3435
import org.hyperledger.besu.plugin.services.BesuEvents;
@@ -88,6 +89,7 @@ public long addBlockAddedListener(final BlockAddedListener listener) {
8889
event ->
8990
listener.onBlockAdded(
9091
blockAddedContext(
92+
event.getEventType(),
9193
event::getHeader,
9294
() -> event.getBlock().getBody(),
9395
event::getTransactionReceipts)));
@@ -104,6 +106,7 @@ public long addBlockReorgListener(final BlockReorgListener listener) {
104106
(blockWithReceipts, chain) ->
105107
listener.onBlockReorg(
106108
blockAddedContext(
109+
EventType.CHAIN_REORG,
107110
blockWithReceipts::getHeader,
108111
blockWithReceipts.getBlock()::getBody,
109112
blockWithReceipts::getReceipts)));
@@ -210,6 +213,7 @@ public UInt256 getTotalDifficulty() {
210213
}
211214

212215
private static AddedBlockContext blockAddedContext(
216+
final EventType eventType,
213217
final Supplier<BlockHeader> blockHeaderSupplier,
214218
final Supplier<BlockBody> blockBodySupplier,
215219
final Supplier<List<TransactionReceipt>> transactionReceiptsSupplier) {
@@ -228,6 +232,11 @@ public BlockBody getBlockBody() {
228232
public List<TransactionReceipt> getTransactionReceipts() {
229233
return transactionReceiptsSupplier.get();
230234
}
235+
236+
@Override
237+
public EventType getEventType() {
238+
return eventType;
239+
}
231240
};
232241
}
233242
}

app/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hyperledger.besu.datatypes.BlobGas;
2020
import org.hyperledger.besu.datatypes.HardforkId;
2121
import org.hyperledger.besu.datatypes.Hash;
22+
import org.hyperledger.besu.datatypes.Transaction;
2223
import org.hyperledger.besu.datatypes.Wei;
2324
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
2425
import org.hyperledger.besu.ethereum.core.Block;
@@ -136,6 +137,11 @@ public Wei getBlobGasPrice(final BlockHeader blockHeader) {
136137
.orElse(BlobGas.ZERO));
137138
}
138139

140+
@Override
141+
public Optional<Transaction> getTransactionByHash(final Hash transactionHash) {
142+
return blockchain.getTransactionByHash(transactionHash).map(Transaction.class::cast);
143+
}
144+
139145
@Override
140146
public Optional<List<TransactionReceipt>> getReceiptsByBlockHash(final Hash blockHash) {
141147
return blockchain

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ public static Collection<Object[]> parameters() {
115115
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 1681338455L),
116116
new ForkId(Bytes.ofUnsignedInt(0xdce96c2dL), 1710338135L),
117117
new ForkId(Bytes.ofUnsignedInt(0x9f3d2254L), 1746612311L),
118-
new ForkId(Bytes.ofUnsignedInt(0xc376cf8bL), 0L),
119-
new ForkId(Bytes.ofUnsignedInt(0xc376cf8bL), 0L))
118+
new ForkId(Bytes.ofUnsignedInt(0xc376cf8bL), 1764798551),
119+
new ForkId(Bytes.ofUnsignedInt(0x5167e2a6L), 1765290071),
120+
new ForkId(Bytes.ofUnsignedInt(0xcba2a1c0L), 1767747671),
121+
new ForkId(Bytes.ofUnsignedInt(0x07c9462eL), 0),
122+
new ForkId(Bytes.ofUnsignedInt(0x07c9462eL), 0))
120123
},
121124
new Object[] {
122125
NetworkName.MORDOR,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.hyperledger.besu.nat.NatMethod;
2323

24-
import org.junit.jupiter.api.Disabled;
2524
import org.junit.jupiter.api.Test;
2625
import org.mockito.Mockito;
2726

@@ -81,7 +80,6 @@ public void natMethodFallbackEnabledPropertyIsCorrectlyUpdatedWithDocker() {
8180
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
8281
}
8382

84-
@Disabled("flaky test see https://github.com/hyperledger/besu/issues/8775")
8583
@Test
8684
public void natMethodFallbackEnabledPropertyIsCorrectlyUpdatedWithUpnp() {
8785

app/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public void addedBlockEventFiresAfterSubscribe() {
284284
assertThat(result.get()).isNotNull();
285285
assertThat(result.get().getBlockHeader()).isEqualTo(block.getHeader());
286286
assertThat(result.get().getTransactionReceipts()).isEqualTo(transactionReceipts);
287+
assertThat(result.get().getEventType()).isEqualTo(AddedBlockContext.EventType.HEAD_ADVANCED);
287288
}
288289

289290
@Test

0 commit comments

Comments
 (0)