Before this pull request Besu was using the latest known fork id to create status message for Ethereum P2P protocol handshake.
This latest known fork id was created based on a list of forks retrieved from the Genesis.
For private networks it is possible that all fork blocks number are set to 0.
The algorithm to compute the valid fork hashes excludes 0 values.
As a result, the list was empty and the `getLatestForkId` was returning `null`. This is an issue when you support capabilities >= to Eth/64 sub protocol because other peers expect the fork id value in the `RLP` encoded message.
Moreover, the algorithm to compute the fork id should be aware of the chain head number and update `CRC` value only for fork blocks below the current head.
This pull request fixes this issue by fetching the chain head number and update accordingly the `CRC` value.
Unit tests have been extended to cover an exhaustive list of possible combinations on named networks (`goerli`, `rinkeby`, `ropsten` and `mainnet`).
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Add onchain privacy group multi-tenancy support to priv_getPrivateTx and priv_getPrivRcpt
Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
ProtocolContext uses a generic for the consensus state, which has a very
large footprint across the code to accomplish what it intends to
accomplish. For every call there are about 61 other lines per call that
need to be updated, over 1300 lines total.
Instead replace it with java.lang.Class#cast, which provides runtime
security, and use generics to provide the compile time sugar that
allows for chained methods of the appropriate type. Then remove its
(quite large) footprint from the rest of the code.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
The NAT manager's `MANUAL` method has been removed. This mode does not seem really useful because it does the same thing as a NONE mode.
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
* reduce number of validators, remove unnecessary checks for number of peers (this is already done in cluster.start) and reduce number of blocks we wait for
Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
* check status of cluster not a single node
Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
Performance measurements have indicated that the list of Bytes32 for
memory is not performant enough. Moving to a byte array reduces wrapper
object thrashing as well as simplifying cross-word boundary logic (there
are no boundaries).
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Add an option to run besu after blocks import. This is aimed to cut the
startup penalty in half for hive testing, combining the block import
with the node execution.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* feat: FastSync now stops on failure instead of falling back to FullSync
* feat: exiting on FastSync failed
* feat: FastSync continues on FullSync when no errors happened
Signed-off-by: Alexandre PARIS-VERGNE <alexpv14@gmail.com>
We consider the named network condition to be satisfied when --network
is explicitly used OR when it isn't supplied but neither are
--genesis-file nor --privacy-enabled
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Extend the `blocks import` subcommand to accept multiple files in the
command line and import them in the same batch.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Improved JUMP and JUMPSUB destination check. Avoid having to browse the code if the destination == code size
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
* Handle nested TOML array to resolve TOML array decoding bug in certain plugin configs.
* Fix for picocli unable to determine if plugin options are multivalue.
Signed-off-by: Steven J Schroeder <steven.schroeder@consensys.net>
We are seeing the gradle daemon die when running the acceptance tests
```
The message received from the daemon indicates that the daemon has
disappeared.
```
Starting from Java 10, UseContainerSupport is turned on by default,
except in the case whereXmx is specified. I'll be honest in that I
don't know why the Xmx of 1gb was specified in the first place, so this
change is bad on the Chesterton's Fence front but if it has anything to
do with limiting the memory usage on containers, removing it would
probably be better.
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
* update getForks to ignore classicforkblock param
Signed-off-by: Edward Mack <ed@edwardmack.com>
* update gotham block fork number
Signed-off-by: Edward Mack <ed@edwardmack.com>
* add to entry to CHANGELOG.md
Signed-off-by: Edward Mack <ed@edwardmack.com>
* Use non-blocking randomness for acceptance tests
This addresses entropy draining during unit tests.
* wait 30 seconds instead of 2 when killing AT processes
* mark NodeSmartContractPermissioningIbftStallAcceptanceTest as @Ignore since it has become reliably and specifically flakey.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
The EthGetWork.shouldReturnSuccessResponseWhenMining was exhibiting intermittent failures, as a mining node would occasionally report "No mining work available yet" - rather than the inputs required to be solved for the current block.
From investigation, it was found that Besu's EthHash miner has a small time window after completing a block, in which the target for the next block has not yet been computed (eg while collating transactions) - during this interval, Besu will validly report "No mining work available yet".
To overcome this, the acceptance test has been updated to poll Besu for upto 5 seconds, waiting for a valid work target to be provided - rather than executing a single-attempt (which may fall within the window specified above).
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>
DevP2P packets expiration fields should be in seconds past the epoch,
not milliseconds past the epoch.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
We cleared the mark storage upon starting the pruner in order to prevent the first sweep from being smaller than it needs to be.
```
// Optimization for the case where the previous cycle was interrupted (like the node was shut
// down). If the previous cycle was interrupted, there will be marks in the mark storage from
// last time, causing the first sweep to be smaller than it needs to be.
clearMarks();
```
Unfortunately, it's currently called in prepare, which is synchronous with the main thread. This means that we can delay startup by on the order of 10 minutes if the storage was especially full.
This commit makes the pruner `start` asynchronous.
This was reverted once before due to test intermittency and this commit is the second attempt :P
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Rollback a Eth64 change intended to improve compatibility in consortium network. It resulted in many nodes not connecting on named networks such as goerli and mordor.
* Revert "Handle backward compatibility for EIP-2124 fork id management (#981)"
This reverts commit 1d8218ae
* Revert "[EIP-2124] Backward compatible fork id management implementation (#979)"
This reverts commit cb2c67d7
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Use seconds for timeout configuration
* Add units to variable names
* Change timeout to 5 minutes
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Changelog for PR #969.
Signed-off-by: Mark Terry <mark.terry@consensys.net>
* Tweak.
Signed-off-by: Mark Terry <mark.terry@consensys.net>
Co-authored-by: MadelineMurray <43356962+MadelineMurray@users.noreply.github.com>
We cleared the mark storage upon starting the pruner in order to prevent the first sweep from being smaller than it needs to be.
// Optimization for the case where the previous cycle was interrupted (like the node was shut
// down). If the previous cycle was interrupted, there will be marks in the mark storage from
// last time, causing the first sweep to be smaller than it needs to be.
clearMarks();
Unfortunately, it's currently called in prepare, which is synchronous with the main thread. This means that we can delay startup by on the order of 10 minutes if the storage was especially full.
This commit makes the pruner `start` asynchronous.
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Slight rework on some PendingTransaction synchronization
* sync on `prioritizedTransactions` instead of `pendingTransactions`
* `pendingTransactions` is already a `ConcurrentHashMap`, which
syncs on itself internally
* not all accesses to `pendingTransactions` were synced
* `prioritizedTransactions` is not exposed directly or indirectly,
making it a better lock
* Improve synchronization in TransactionsForSenderInfo
* `gaps` was returned without requiring synchronization
* `transacitonInfos` was not thread safe.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Add timeout handler in JsonRpcHttpService.
- Created `TimeoutOptions` class with fields:
- *timeout*: the timeout in milliseconds.
- *errorCode*: the http status code.
- Created `EthRpcTimeoutHandler`.
- Contains `handler` static method to create `Vertx Handler`. The process of the handler created is the following
- retrieve the body as string.
- parse it as a `JsonObject`.
- cache the resulting `JsonObject` in the `RoutingContext`.
- retrieve the RPC method name.
- set a timer based on the configuration if the method name matches one entry in the configuration map.
- call the next handler.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
SPDX checks shouldn't be done against jmh generated files. Make it
generic so that the gradle/intellij favoured location of generated files
will never be a problem. These are also covered by `.gitignore` already.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Don't respond to neighbors and ping packets that have an expiration
prior to the system's current time.
Addresses two tests in #975
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Update implementation of the EIP-2315
- Execution of BEGINSUB causes exception and terminates execution.
- JUMPSUB sets the pc to location + 1 .
- In the edge case when BEGINSUB is the last instruction in code and this subroutine is jumped-to, the implementations should execute STOP .
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
* Handle zeros fork blocks when computing fork id.
- Updated `ForkIdManager`:
- Created `ForkIDChecker` interface with `boolean check(ForkId forkId)` method.
- Added a check in the constructor to use the proper `ForkIDChecker` based on the following conditions:
- Accept all peers if the list of forks contains only `zeros`.
- Use `EIP-2124` rules otherwise.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Handle backward compatibility
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>