* avoid the edge case of long minimum value which gives a negative value when passed into abs()
* changed some Longs to long where they were statically intialized
* replace Lists.emptyList() with Collections.emptyList()
* removed unnecessary eq() invocation and resulting code smell
Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
Call the shutdown task async to allow the BftProcessor CountDownLatch to complete.
Start the next coordinator only once the previous shutdown is complete.
Fixes https://github.com/hyperledger/besu/issues/3003
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Merge: extend block creation and mining to support The Merge
Code originally written by garyschulte on the merge branch.
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
* Bump SLF4J version
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Replace log4j2 API with SLF4j API
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Replace usage of LogManager#getFormatterLogger
This is for keeping compatibility with SLF4J. If neccesary, a specific formatter can be created for the RlpBlockImporter class
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Unset the default logging value for the retesteth
This is because it's not possible to resolve the root logger level into a Log4J2 field
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Prevent creation of Logger context outside SLF4J
org.hyperledger.besu.cli.BesuCommand#setAllLevels was taken from
https://github.com/apache/logging-log4j2/blob/rel%2F2.17.1/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L309
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add FATAL level deprecation message
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* [Sonar] Fix java:S2139
Exceptions should be either logged or rethrown but not both
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* [Sonar] Fix java:S3457
Printf-style format strings should be used correctly
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add changelog
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* lots of errorprone fixes
* some license updates
* some mockito updates
* upgrade the rocksdb version
* Prometheus left at 0.9.0 as 0.10.0+ introduces OpenMetrics
related changes that break unit tests.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Unsubscribe the active delegate mining coordinator from BlockAddedEvents
The MigratingMiningCoordinator acts as the observer on its behalf
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Create MigratingMiningCoordinator, a schedulable mining coordinator that will switch between mining coordinators based on the consensus schedule.
https://github.com/hyperledger/besu/issues/2999
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
* Rename BftForksSchedule to ForkSchedule
* Make ForksSchedule generic beyond BftConfigOptions to allow it to work for MiningCoordinator
* Extract BftForksScheduleFactory from ForksSchedule
* Move ForksSchedule to common package
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
When producing the next block, the previousBlockHeader.number + 1 needs to be used to query the transition forkSchedule.
This is because the list of validators associated with each forkSchedule may be a different set to the current block.
This commit changes the implementation for getValidatorsAfterBlock to support this and points getValidatorsAtHead at this implementation.
Note getValidatorsForBlock's forkSchedule query is unchanged since we have already mined the block at the point this is called (e.g. for RPCs qbft_getValidatorsBy...).
For TransactionValidatorProvider, we need to use the next block's contract address but still use the previous block's validators in the contract call itself.
Querying validators using afterBlock vs forBlock may yield different (blockNumber -> validatorAddresses) combinations when transitioning into CONTRACT mode.
There we also split TransactionValidatorProvider validatorCache into two caches.
Add special case to ForkingValidatorProvider (BlockValidatorProvider.hasValidatorOverridesForBlockNumber) to support transitioning to blockheader mode with some validator overrides. This might be needed if the current validator set loses quorum and we
are no longer able to vote new ones in.
New integration test cases for validatorselectionmode transitions:
- contract -> contract
- contract1 -> blockheader -> contract2
- contract1 -> blockheader with overridden validators -> contract2
Fixes https://github.com/hyperledger/besu/issues/2901
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
During the transition from contract mode to block header mode, when creating the extra data for a new block, we need to look ahead to the next block's voteProvider to obtain the nonEmpty one associated with the BlockValidatorProvider.
This only applies to ForkingValidatorProvider which is currently only used for QBFT. However, we don't want QBFT to know it's using a ForkingValidatorProvider. Therefore we need to implement getVoteProviderAfterBlock on the ValidatorProvider interface even though it's implementation is equivalent to getVoteProvider.
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
* Create new datatypes module
Create a new `datatypes` module to hold datatypes that are broadly used.
This will aid modularization by making sure the base types in the module
minimize the amount of unrelated support classes needed.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Add Address, Hash, and Wei to datatypes
Move the Address, Hash, and Wei to datatypes in as they are needed for
EVM modularization.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Create extradata with round information only when using contract to obtain validators and vote
* Qbft header validation rule for extradata when validators are obtained from contract
Signed-off-by: Usman Saleem <usman@usmans.info>
The Hash of a qbft payload is calculated by hashing the RLP'd bytes of the message-id, followed by the payload's encoded bytes.
RLP(msgCode, RLP(payload.encodedBytes()))
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>
We were creating new in-memory storage segments each time we were
supposed to be retrieving it which prevented me from being able to test
what keys ended up being stored in that segment.
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
This is the first step in supporting switchable consensus mechanisms.
Specifically this allows additional protocol specs to be inserted to the protocol schedule at milestones other than that explicitly specified in the genesis config.
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>