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>
Create readOnlyValidatorProvider in QbftBesuControllerBuilder and pass into QbftJsonRpcMethods constructor (better than using protocolContext as is only used once when creating the RPCs
This requires storing transactionValidatorProvider in a field and relying on its earlier creation during createConsensusContext()
Fixes#2795
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>
This is a re-implementation of the initial POC done in https://github.com/PegaSysEng/pantheon/pull/1909/ by Danno Ferrin <danno.ferrin@gmail.com>
* Only enable plugin rpc api when enabled on --rpc-http-api or --rpc-ws-apis
* Only allow new rpc endpoints to be defined
Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>
Broad reaching optimizations to speed up EVM calculations
* Generally speaking, use int and long where it is more appropriate than UInt256 (memory indexes mostly)
* Move the internal stack to Bytes from UInt256
* Re-work the flow of many operations to account for the above
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Move EVM to a standalone module
Move the EVM classes to a standalone module. This is mostly moves but
some API re-resign to peel out some features not essential to the EVM,
such as privacy support and ties to the data storage subsystem.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* 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>
* Add unstable CLI option for max ommers depth
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Move to a builder pattern for mining parameters
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Upgrade to Apache Tuweni 2.0
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Remove intermediate repository
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Remove all occurrences of toBytes
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Migrate to tuweni-bytes
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* add changelog
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* correct reference tests
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Initial API changes
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* more changes
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Change APIs for VM ops
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Use constant UInt256.ONE
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Optimize a bit address <> word transformation
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* spotless
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>