* Fix EIP-1559 block mining.
- Updated `AbstractBlockCreator` to set base fee to initial value if block is the fork block number.
- Updated `BlockHeaderBuilder` to populate base fee field.
- Updated `EthHash` to include base fee in hash computation if present in header.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Set the gas block limit as a factor of the target gas usage instead of hard coded value.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
When updating an account we often calculate the address hash multiple
times. We also will always calculate it at least once when tracking an
accout update. Hence, just calculate it in the constructor and re-use
it.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Some of our loggers were not private, static, and final. In a few
cases these were non-static fields in classes that were repeatedly
instantiated in core transaction logic.
This is enforced via a new ErrorProne check, so the PR includes fixes
for all of the places this was a problem, not just the performance
impacting code.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Handle legacy gas pool and EIP-1559 gas pool when mining blocks.
- Added `EIP1559` manager class in `ProtocolSpec` (defaulted to `Optional.empty()`).
- Updated `MainnetProtocolSpecs` EIP-1559 definition to set the `EIP1559` manager class.
- Updated `BlockTransactionSelector`
- Added `eip1559CumulativeGasUsed` field in `TransactionSelectionResults`.
- Updated `updateTransactionResultTracking` method to compute cumulative gas used according to `EIP-1559` rules.
- Updated `transactionTooLargeForBlock` method to compute gas remaining according to `EIP-1559` rules.
- Updated `blockOccupancyAboveThreshold` method to compute minimum block occupancy ratio according to `EIP-1559` rules.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Update BlockTransactionSelector transaction gas price computation.
BlockTransactionSelector should compare transaction gas price to the min transaction gas price parameter according to EIP-1559 rules.
- Added `TransactionPriceCalculator` to `ProtocolSpec` (defaulted to `TransactionPriceCalculator.frontier()`.
- Created `minTransactionPriceInNextBlock` method in `BaseFee`.
- Removed useless constructor in `BaseFee`.
- Updated EIP-1559 protocol spec definition to set the correct transaction price calculator.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
@pinges correctly pointed out that, even though we have access to all the logs in the BlockAddedEvent, we still use BlockchainQueries to add the new logs from the event. Now we do the sane thing.
Unfortunately, it doesn't seem as easy with private logs so we still have to use privacyQueries as far as I can tell.
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Enable native encryption by default, but retain the feature flags. The problem with acceptance tests is that the new native libraries added some startup overhead, which when translated to starting up 12 nodes on the same vm resulted in longer time getting to a testable state. Start up timeout was increased to 60 seconds.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Via JNA use native scep256k1 and altbn128 libraries.
This is gated by two feature flags and is disabled by default.
* `--Xsecp256k1-native-enabled` enables native secp256k1 across all of besu
* `--Xaltbn128-native-enabled` enables native altbn128 in the precompiled contracts
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Manage EIP-1559 transactions forging in local transaction pool.
- Updated `TransactionPool`
- Added `TransactionPriceCalculator` field for frontier transactions.
- Added `TransactionPriceCalculator` field for EIP-1559 transactions.
- Added `EIP1559` field.
- Added `minTransactionGasPrice` to compute transaction gas price according to EIP-1559 rules.
- Created `BaseFee` domain object.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
## PR description
- Created `TransactionPriceCalculator` to compute the transaction gas price.
- Created `CoinbaseFeePriceCalculator` to compute the coinbase reward.
- Updated `MainnetTransactionProcessor` to apply new consensus rules:
- Updated transaction gas price for EIP-1559 transactions.
- Updated coinbase reward for EIP-1559 transactions.
- Updated `MainnetProtocolSpecs` to build the correct TransactionProcessor for EIP-1559 definition.
## Fixed Issue(s)
- #601
- #605
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Move baseFee from SealableBlockHeader to ProcessableBlockHeader
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Move baseFee from SealableBlockHeader to ProcessableBlockHeader
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Write null gas price in the RLP structure if this an EIP-1559 transaction. (#738)
Write null gas price in the RLP structure if this an EIP-1559 transaction.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
Make sure we remove pending transaction tracker when a peer disconnects
with a unit tests to test that disconnect callbacks are indeed called when a peer disconnects, for transaction and pending transaction tracking
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Added changelog entries for PR:
- https://github.com/hyperledger/besu/pull/430
- https://github.com/hyperledger/besu/pull/440
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* For post EIP-1559 blocks we must disable GasLimitRangeAndDeltaValidationRule.
We must also update ProofOfWorkValidationRule to include base fee field in the hash computation.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Rename logger
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Rename logger
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Fix base fee computation and add tests.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Address PR comments
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Fix support of peers <eth/65
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Fix unit test
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* Update ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PeerPendingTransactionTracker.java
Co-Authored-By: Danno Ferrin <danno.ferrin@shemnon.com>
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
* make protocol version part of the function
Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com>
Pull two methods out of ProtocolSpec into the only class that uses them.
This is in preparation for future refactoring of the ProtocolSpec.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Add support for `berlinBlock` in genesis configs.
Until the final contents of Berlin are finalized this will be guarded by
a feature flag `--Xberlin-enabled`. Once Berlin is finalized and before
it is deployed on test nets the flag will be removed.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
This change allows the newly defined "SecurityModule" to work against a generic API, while the NodeKey interface adapts these generic types to the types already used throughout Besu (i.e. those defined in Secp256k1).
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>
Speed up build time by removing some of the most time consuming tests
* CALLBlake2f_MaxRounds - runs Blake2f 4 billion rounds, something no
one ever does and there is never enough gas to do. We have a unit test
for this already.
* The "do this 50k times" tests. Each has a smaller "5k times" or less
variant. This drifts into performance testing instead of conformance
testing
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Added changelog entries for PR:
- https://github.com/hyperledger/besu/pull/430
- https://github.com/hyperledger/besu/pull/440
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Implement gas limit and gas price block header validation rules as per specified in EIP-1559
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* We should enforce the per transaction gas limit, as specified by the EIP, to 8,000,000 gas.
Add a `TransactionInvalidReason`
Update the `validate` method in `MainnetTransactionValidator` to enforce this check.
Update the validation process in `MainnetBlockBodyValidator` to enforce this check for all transactions within a block.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* fix unit test
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Removed blockNumber from TransactionValidator.validate
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>