Skip to content

Commit

Permalink
Release 23.10.x (#6155)
Browse files Browse the repository at this point in the history
* Unsigned timestamps and blob gas used (#6046)

* lots of places an unsigned timestamp is a problem
* adds unchecked annotations to OptionalUnsignedLong rpc parameter type

---------

Signed-off-by: Justin Florentine <justin+github@florentine.us>
(cherry picked from commit a90ea05)

* [MINOR] ux improvements (#6049)

* log command line option that is affected

* made plugins summary log part of config overview

* check for null plugin context

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit e8bca61)

* Update changelog release (#6062)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
(cherry picked from commit f810887)

* Dencun corner cases (#6060)

* cherry pick changes from https://github.com/hyperledger/besu/pull/6054/files\#diff-22b78733e37a697fa8d1d8a02d2a87fe5ccea9cf67c34ce5e6311f024c14abd6L643-R738

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* cherry pick changes from https://github.com/hyperledger/besu/pull/6054/files\#diff-61db834b59eae5ce5c438462505de1add8fa244deda830742060d15f668a9806R39-R44

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* formatting

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* update the EIP-6110 acceptance tests

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Co-authored-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit 9d9fe8c)

* add retry logic on sync pipeline for rocksdb issue (#6004)

* add retry logic for sync pipeline with rocksdb issue

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
(cherry picked from commit c839a3b)

* Mining options refactor (#6027)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit 20a82d4)

* Update reference tests to Cancun (#6054)

* Update reference tests to Cancun

Update reference tests to cancun tests.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* update the subrepo

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* update the EIP-6110 acceptance tests

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* update to develop

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

---------

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit 909649f)

* Optimize GetPooledTransactionsFromPeerTask with HashSet (#6071)

Switch from using a List to a HashSet for transaction hashes in GetPooledTransactionsFromPeerTask to improve performance.

Signed-off-by: Suyash Nayan <suyashnyn1@gmail.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit a2dbb82)

* Decouple TrieLogManager and CachedWorldStorageManager (#6072)

Separate out the concepts of world state caching and trie log management.
Remove AbstractTrieLogManager and make TrieLogManager the concrete implementation.

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
(cherry picked from commit 20f518e)

* Implement miner_setMinPriorityFee and miner_getMinPriorityFee (#6080)

* Refactor mining options

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Fix null pointer exception

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* fix another null pointer exception

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* uncomment code

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Move miner options tests

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Unit test fixes

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Removed the commented code

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* WIP

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* WIP

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* New miner option: min-priority-fee

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Remove not relevant for this feature

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Remove not relevant for this feature

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Fix javadoc

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Remove code not belonging to this PR

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* coinbase is an updatable parameter

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Move MiningOptions to upper package

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Fix coinbase for *bft

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Implement methods to get and set min priority fee

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Fix spotless

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Apply suggestions from code review

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java

[skip-ci]

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Add new config option to everything config

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Fix unit test

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

* Accept PR suggestions

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>

---------

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
(cherry picked from commit 3310c41)

* Use Bytes Trie to track warm addresses (#6069)

* Use Bytes Trie to track warm addresses

Move from a java HashSet to a custom Trie based on bytes to store the
warm addresses, creates, and self-destructs.

This avoids needing to calculate java hashes or engage in using custom
Comparators.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* codeql scan

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

---------

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit af011d2)

* Migrate Operand Stack to Growing Stack (#6068)

To improve the performance of CALL operations move the OperandStack and
ReturnStack to growing stacks instead of a fully allocated stack.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit 949c724)

* Remove a BonsaiWorldStateProvider constructor (#6090)

Was only used for supporting test code and can instead reuse static factory from InMemoryKeyValueStorageProvider

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
(cherry picked from commit 9a22703)

* add RpcEndpointService to thread runner (#6091)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit 7ac8af0)

* ETC 'Spiral' network upgrade (#6078)

* Add 23.10.2 section to changelog

Signed-off-by: Diego López León <dieguitoll@gmail.com>

* Set ENR tree for DNS discovery for Mordor network

Signed-off-by: Diego López León <dieguitoll@gmail.com>

* Add ECIP-1109: 'Spiral' network upgrade support

Signed-off-by: Diego López León <dieguitoll@gmail.com>

---------

Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit f58f6cf)

* Trigger contextEnter/Exit for all frames, including root (#6074)

* Trigger contextEnter/Exit for all frames, including root
* Differentiate between context entry and re-entry in `OperationTracer`
* Update evm/src/test/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessorTest.java

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: delehef <github@odena.eu>

---------

Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>
Signed-off-by: delehef <github@odena.eu>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit 0345b24)

* feat: add a way to read memory without altering the word capacity (#6073)

* feat: add a way to read memory without altering the word capacity
* add tests
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>

* Fix read-past-end
* Do not abuse method overload
* Update CHANGELOG.md

Signed-off-by: delehef <github@odena.eu>
Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>

* add tests for MessageFrame.shadowReadMemory

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>

* Straddled reads tests

Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>

---------

Signed-off-by: Franklin Delehelle <franklin.delehelle@odena.eu>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Signed-off-by: delehef <github@odena.eu>
Signed-off-by: delehef <franklin.delehelle@odena.eu>
Co-authored-by: Daniel Lehrner <daniel.lehrner@consensys.net>
(cherry picked from commit edf23cb)

* renamed env field (#6096)

Signed-off-by: Justin Florentine <justin+github@florentine.us>
(cherry picked from commit 67ef9e0)

* [MINOR] Upgrade netty and grpc (#6100)

* Upgrade netty and grpc
* fix verification file
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit accac1c)

* TraceService: return results for transactions in block (#6087)

* TraceService: return results for transactions in block

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
(cherry picked from commit a60b31b)

* RPC Parameters to accept input and data field (#6094)

* Accept input or data as payload for RPC calls

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Add json new rpc valid and invalid request to test the changes

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Change JsonCallParameter signature to avoid duplicating constructor

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Add changelog

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
(cherry picked from commit 6dd558b)

* Fix some typos (#6093)

* Fix some typos
* Update plugin version

Signed-off-by: GoodDaisy <90915921+GoodDaisy@users.noreply.github.com>

---------

Signed-off-by: GoodDaisy <90915921+GoodDaisy@users.noreply.github.com>
(cherry picked from commit e814886)

* Correct reference test blobgas calculation (#6107)

* Correct reference test blobgas calculation

Fix tpyo that resulted in an NPE in t8n blob gas calculations.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* changelog

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

* spotless

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>

---------

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit d0a6a70)

* Restore javadoc and sources jar as trusted artifacts (#6109)

Makes Idea happy again as documented here https://docs.gradle.org/6.8.3/userguide/dependency_verification.html#sec:skipping-javadocs
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
(cherry picked from commit 311570f)

* Add API to set and get the minGasPrice at runtime (#6097)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
(cherry picked from commit de8ca10)

* Don't put NONCE_TOO_LOW transactions into the invalid nonce cache (#6067)

* Don't put NONCE_TOO_LOW transactions into the invalid nonce cache

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Update unit tests

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Use list of errors to ignore

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

---------

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matt Whitehead <matthew1001@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
(cherry picked from commit 84dee29)

* Journaled world state (#6023)

Introduce a new Journaled World State Updater. Within a transaction it
keeps one copy of account and storage state, restoring previous
revisions on reverts and exceptional halts. This updater only supports
post-merge semantics with regard to empty accounts, namely that they do
not exist in world state.

Adds an EvmConfiguration option for stacked vs journaled updater, and
wire it in where needed. The staked updater is default mode, which is
the current behavior prior to this patch.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit 094c841)

* setMinPriorityFee  - Return Invalid Param when invalid and use hexadecimal instead of Long (#6099)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
(cherry picked from commit 7acdd87)

* [MINOR] - Add 23.10.1 correct changelog (#6110)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
(cherry picked from commit 236779d)

* Add transaction selector based on min priority fee parameter (#6083)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
(cherry picked from commit 41b9575)

* Add config option to clique to allow not creating empty blocks (#6082)

Signed-off-by: Jason Frame <jason.frame@consensys.net>
(cherry picked from commit 6a2d41f)

* load all accounts into cache (#6101)

There was a slight problem on the bonsai side because all account reads did not go through a single method. One of the two add the account to the cache but the other did not. This had two consequences:

Less good performance because certain accounts had to be read several times and also all account reads were not marked in the trielog. This will fix both problems.

Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
(cherry picked from commit d049cb3)

* Reference Tests v13 (#6114)

v13 of the official Ethereum Reference Tests.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit cea3d8a)

* clean up the ProcessableBlockHeader (#6117)

* clean up

Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
(cherry picked from commit 646c5a3)

* Log missing chain head as warning, not trace (#6127)

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
(cherry picked from commit 83ae69a)

* Update RPCs for yParity (#6119)

Update the GraphQL and JSON-RPC endpoints to provide `yParity` instead
of `v` for non-legacy transactions.
Update the JSON-RPC tests to use the Hive data. Add tests for Shanghai
and Cancun Blocks.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit 2284242)

* Make tracer in block building block aware (#6135)

Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
(cherry picked from commit f42f8c1)

* Revert "Discard invalid transaction" warning logs (#6137)

* Revert "Log missing chain head as warning, not trace (#6127)"
* leave chain head at warning, just revert the discard warning

Signed-off-by: garyschulte <garyschulte@gmail.com>
(cherry picked from commit 914ab79)

* Reverse sort order (#6106)

* Reverse added order and sequence number

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Remove extraneous 'addedAt' check

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

---------

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
(cherry picked from commit 0203092)

* Force tx replacement price bump to zero when zero base fee market is configured (#6079)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
(cherry picked from commit 636ad8a)

* Time limited block creation (#6044)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
(cherry picked from commit 8319fae)

* Limit memory used in handling invalid blocks (#6138)

Signed-off-by: Jason Frame <jason.frame@consensys.net>
(cherry picked from commit 701cbb0)

* Delete leftPad when capturing the stack before and after a frame execution (#6102)

* Delete leftPad when capturing the stack before and after the execution
* Still use leftPad when displaying the stack in the output (ex. for debug_traceTransaction)
* Fix integration test
* Use StringBuilder to left pad the hex representation of a 32 bytes

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
(cherry picked from commit 9710a9a)

* fix yParity flakey test (#6151)

Fix the flakeiness in EthGetTransactionByHashTest as well as some other
sonar identified cleanup.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
(cherry picked from commit 4b58d07)

* Apply the same reverse sort order as https://github.com/hyperledger/b… (#6146)

* Apply the same reverse sort order as #6106 but to the base fee sorter

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Fix unit tests

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Update eviction unit tests to expect highest-sequence TXs be evicted first

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Update change log

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Spotless fixes

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

---------

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
(cherry picked from commit 8afad41)

---------

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Co-authored-by: matkt <karim.t2am@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Co-authored-by: Suyash Nayan <89125422+7suyash7@users.noreply.github.com>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Co-authored-by: Diego López León <dieguitoll@gmail.com>
Co-authored-by: delehef <franklin.delehelle@odena.eu>
Co-authored-by: daniellehrner <daniel.lehrner@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Co-authored-by: GoodDaisy <90915921+GoodDaisy@users.noreply.github.com>
Co-authored-by: Matt Whitehead <matthew1001@gmail.com>
Co-authored-by: Jason Frame <jason.frame@consensys.net>
Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
Co-authored-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: ahamlat <ameziane.hamlat@consensys.net>
  • Loading branch information
18 people authored Nov 10, 2023
1 parent 287f0c2 commit c29db3f
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 61 deletions.
1 change: 1 addition & 0 deletions ethereum/eth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dependencies {
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation 'io.tmio:tuweni-rlp'
implementation 'org.rocksdb:rocksdbjni'

annotationProcessor "org.immutables:value"
implementation "org.immutables:value-annotations"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.eth.sync;

import org.hyperledger.besu.plugin.services.exception.StorageException;

import java.util.EnumSet;
import java.util.Optional;

import org.rocksdb.RocksDBException;
import org.rocksdb.Status;

public final class StorageExceptionManager {

private static final EnumSet<Status.Code> RETRYABLE_STATUS_CODES =
EnumSet.of(Status.Code.TimedOut, Status.Code.TryAgain, Status.Code.Busy);

private static final long ERROR_THRESHOLD = 1000;

private static long retryableErrorCounter;
/**
* Determines if an operation can be retried based on the error received. This method checks if
* the cause of the StorageException is a RocksDBException. If it is, it retrieves the status code
* of the RocksDBException and checks if it is contained in the list of retryable {@link
* StorageExceptionManager.RETRYABLE_STATUS_CODES} status codes.
*
* @param e the StorageException to check
* @return true if the operation can be retried, false otherwise
*/
public static boolean canRetryOnError(final StorageException e) {
return Optional.of(e.getCause())
.filter(z -> z instanceof RocksDBException)
.map(RocksDBException.class::cast)
.map(RocksDBException::getStatus)
.map(Status::getCode)
.map(RETRYABLE_STATUS_CODES::contains)
.map(
result -> {
retryableErrorCounter++;
return result;
})
.orElse(false);
}

public static long getRetryableErrorCounter() {
return retryableErrorCounter;
}

public static boolean errorCountAtThreshold() {
return retryableErrorCounter % ERROR_THRESHOLD == 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@
*/
package org.hyperledger.besu.ethereum.eth.sync.fastsync.worldstate;

import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.canRetryOnError;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.errorCountAtThreshold;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.getRetryableErrorCounter;

import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldDownloadState;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.services.tasks.Task;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PersistDataStep {

private static final Logger LOG = LoggerFactory.getLogger(PersistDataStep.class);

private final WorldStateStorage worldStateStorage;

public PersistDataStep(final WorldStateStorage worldStateStorage) {
Expand All @@ -33,24 +44,40 @@ public List<Task<NodeDataRequest>> persist(
final List<Task<NodeDataRequest>> tasks,
final BlockHeader blockHeader,
final WorldDownloadState<NodeDataRequest> downloadState) {
final Updater updater = worldStateStorage.updater();
tasks.stream()
.map(
task -> {
enqueueChildren(task, downloadState);
return task;
})
.map(Task::getData)
.filter(request -> request.getData() != null)
.forEach(
request -> {
if (isRootState(blockHeader, request)) {
downloadState.setRootNodeData(request.getData());
} else {
request.persist(updater);
}
});
updater.commit();
try {
final Updater updater = worldStateStorage.updater();
tasks.stream()
.map(
task -> {
enqueueChildren(task, downloadState);
return task;
})
.map(Task::getData)
.filter(request -> request.getData() != null)
.forEach(
request -> {
if (isRootState(blockHeader, request)) {
downloadState.setRootNodeData(request.getData());
} else {
request.persist(updater);
}
});
updater.commit();
} catch (StorageException storageException) {
if (canRetryOnError(storageException)) {
// We reset the task by setting it to null. This way, it is considered as failed by the
// pipeline, and it will attempt to execute it again later.
if (errorCountAtThreshold()) {
LOG.info(
"Encountered {} retryable RocksDB errors, latest error message {}",
getRetryableErrorCounter(),
storageException.getMessage());
}
tasks.forEach(nodeDataRequestTask -> nodeDataRequestTask.getData().setData(null));
} else {
throw storageException;
}
}
return tasks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
*/
package org.hyperledger.besu.ethereum.eth.sync.snapsync;

import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.canRetryOnError;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.errorCountAtThreshold;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.getRetryableErrorCounter;

import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal.TrieNodeHealingRequest;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import org.hyperledger.besu.services.pipeline.Pipe;
import org.hyperledger.besu.services.tasks.Task;
Expand All @@ -27,9 +32,12 @@
import java.util.stream.Stream;

import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoadLocalDataStep {

private static final Logger LOG = LoggerFactory.getLogger(LoadLocalDataStep.class);
private final WorldStateStorage worldStateStorage;
private final SnapWorldDownloadState downloadState;
private final SnapSyncProcessState snapSyncState;
Expand Down Expand Up @@ -58,19 +66,35 @@ public Stream<Task<SnapDataRequest>> loadLocalDataTrieNode(
final Task<SnapDataRequest> task, final Pipe<Task<SnapDataRequest>> completedTasks) {
final TrieNodeHealingRequest request = (TrieNodeHealingRequest) task.getData();
// check if node is already stored in the worldstate
if (snapSyncState.hasPivotBlockHeader()) {
Optional<Bytes> existingData = request.getExistingData(downloadState, worldStateStorage);
if (existingData.isPresent()) {
existingNodeCounter.inc();
request.setData(existingData.get());
request.setRequiresPersisting(false);
final WorldStateStorage.Updater updater = worldStateStorage.updater();
request.persist(
worldStateStorage, updater, downloadState, snapSyncState, snapSyncConfiguration);
updater.commit();
downloadState.enqueueRequests(request.getRootStorageRequests(worldStateStorage));
completedTasks.put(task);
return Stream.empty();
try {
if (snapSyncState.hasPivotBlockHeader()) {
Optional<Bytes> existingData = request.getExistingData(downloadState, worldStateStorage);
if (existingData.isPresent()) {
existingNodeCounter.inc();
request.setData(existingData.get());
request.setRequiresPersisting(false);
final WorldStateStorage.Updater updater = worldStateStorage.updater();
request.persist(
worldStateStorage, updater, downloadState, snapSyncState, snapSyncConfiguration);
updater.commit();
downloadState.enqueueRequests(request.getRootStorageRequests(worldStateStorage));
completedTasks.put(task);
return Stream.empty();
}
}
} catch (StorageException storageException) {
if (canRetryOnError(storageException)) {
// We reset the task by setting it to null. This way, it is considered as failed by the
// pipeline, and it will attempt to execute it again later.
if (errorCountAtThreshold()) {
LOG.info(
"Encountered {} retryable RocksDB errors, latest error message {}",
getRetryableErrorCounter(),
storageException.getMessage());
}
task.getData().clear();
} else {
throw storageException;
}
}
return Stream.of(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@
*/
package org.hyperledger.besu.ethereum.eth.sync.snapsync;

import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.canRetryOnError;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.errorCountAtThreshold;
import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.getRetryableErrorCounter;

import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal.TrieNodeHealingRequest;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.services.tasks.Task;

import java.util.List;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PersistDataStep {
private static final Logger LOG = LoggerFactory.getLogger(PersistDataStep.class);

private final SnapSyncProcessState snapSyncState;
private final WorldStateStorage worldStateStorage;
Expand All @@ -43,41 +52,58 @@ public PersistDataStep(
}

public List<Task<SnapDataRequest>> persist(final List<Task<SnapDataRequest>> tasks) {
final WorldStateStorage.Updater updater = worldStateStorage.updater();
for (Task<SnapDataRequest> task : tasks) {
if (task.getData().isResponseReceived()) {
// enqueue child requests
final Stream<SnapDataRequest> childRequests =
task.getData().getChildRequests(downloadState, worldStateStorage, snapSyncState);
if (!(task.getData() instanceof TrieNodeHealingRequest)) {
enqueueChildren(childRequests);
} else {
if (!task.getData().isExpired(snapSyncState)) {
try {
final WorldStateStorage.Updater updater = worldStateStorage.updater();
for (Task<SnapDataRequest> task : tasks) {
if (task.getData().isResponseReceived()) {
// enqueue child requests
final Stream<SnapDataRequest> childRequests =
task.getData().getChildRequests(downloadState, worldStateStorage, snapSyncState);
if (!(task.getData() instanceof TrieNodeHealingRequest)) {
enqueueChildren(childRequests);
} else {
continue;
if (!task.getData().isExpired(snapSyncState)) {
enqueueChildren(childRequests);
} else {
continue;
}
}
}

// persist nodes
final int persistedNodes =
task.getData()
.persist(
worldStateStorage,
updater,
downloadState,
snapSyncState,
snapSyncConfiguration);
if (persistedNodes > 0) {
if (task.getData() instanceof TrieNodeHealingRequest) {
downloadState.getMetricsManager().notifyTrieNodesHealed(persistedNodes);
} else {
downloadState.getMetricsManager().notifyNodesGenerated(persistedNodes);
// persist nodes
final int persistedNodes =
task.getData()
.persist(
worldStateStorage,
updater,
downloadState,
snapSyncState,
snapSyncConfiguration);
if (persistedNodes > 0) {
if (task.getData() instanceof TrieNodeHealingRequest) {
downloadState.getMetricsManager().notifyTrieNodesHealed(persistedNodes);
} else {
downloadState.getMetricsManager().notifyNodesGenerated(persistedNodes);
}
}
}
}
updater.commit();
} catch (StorageException storageException) {
if (canRetryOnError(storageException)) {
// We reset the task by setting it to null. This way, it is considered as failed by the
// pipeline, and it will attempt to execute it again later. not display all the retryable
// issues
if (errorCountAtThreshold()) {
LOG.info(
"Encountered {} retryable RocksDB errors, latest error message {}",
getRetryableErrorCounter(),
storageException.getMessage());
}
tasks.forEach(task -> task.getData().clear());
} else {
throw storageException;
}
}
updater.commit();
return tasks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ public SnapWorldStateDownloadProcess build() {
"step",
"action");

/*
The logic and intercommunication of different pipelines can be summarized as follows:
1. Account Data Pipeline (fetchAccountDataPipeline): This process starts with downloading the leaves of the account tree in ranges, with multiple ranges being processed simultaneously.
If the downloaded accounts are smart contracts, tasks are created in the storage pipeline to download the storage tree of the smart contract, and in the code download pipeline for the smart contract.
2. Storage Data Pipeline (fetchStorageDataPipeline): Running parallel to the account data pipeline, this pipeline downloads the storage of smart contracts.
If all slots cannot be downloaded at once, tasks are created in the fetchLargeStorageDataPipeline to download the storage by range, allowing parallelization of large account downloads.
3. Code Data Pipeline (fetchCodePipeline): This pipeline, running concurrently with the account and storage data pipelines, is responsible for downloading the code of the smart contracts.
4. Large Storage Data Pipeline (fetchLargeStorageDataPipeline): This pipeline is used when the storage data for a smart contract is too large to be downloaded at once.
It enables the storage data to be downloaded in ranges, similar to the account data.
5. Healing Phase: Initiated after all other pipelines have completed their tasks, this phase ensures the integrity and completeness of the downloaded data.
*/
final Pipeline<Task<SnapDataRequest>> completionPipeline =
PipelineBuilder.<Task<SnapDataRequest>>createPipeline(
"requestDataAvailable", bufferCapacity, outputCounter, true, "node_data_request")
Expand Down
Loading

0 comments on commit c29db3f

Please sign in to comment.