- Implemented submitHashrate endpoint.
- Updated eth_hashrateEndpoint so that it returns the cumulative hashrate of all sealers if available. Otherwise it returns the local hashrate
- Added hashrate submission with Stratum1EthProxyProtocol and Stratum1Protocol
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
* 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>
* Use seconds for timeout configuration
* Add units to variable names
* Change timeout to 5 minutes
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>
* Add checks on the replacement of a transaction in the pool:
- reject EIP-1559 for pre-fork blocks
- accept both frontier and EIP-1559 transactions during phase 1
- reject frontier transactions after phase 2 is finalized
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* The transaction gas price is computed when adding a transaction into the local pool using eth_sendRawTransaction JSON RPC endpoint. Transaction price must be computed properly depending on the type of the transaction.
For instance `shouldReplace` method of PendingTransactions must be updated to deal with EIP-1559 transactions.
- Updated `PendingTransactions` to add access to the chain header in order to retrieve the last base fee value.
- Updated `TransactionReplacementByPriceRule` to compute the transaction price depending on the type of the transaction (frontier or eip-1559).
- Added unit tests to cover all possible replacement scenarios.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
Retesteth requires even length quantities (in contravariance to the Eth
JSON-RPC standards). For storage range at provide even length
quantities.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Fix cases where the gas estimate is too low and causes the transaction to fail
Implementation of a strategy that will estimate the number of gas needed by a transaction
1 - Estimate the number of gas used by a transaction
2 - Estimate the number of gas necessary to add for each sub call present in a transaction (65/64^depth)
3 - Add the minimum gas required for operations that need it (SSTORE)
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
* Update transaction pool error handling.
Transactions added locally into the pool via `eth_sendRawTransaction` can now generate 2 new JSON RPC errors:
- `ETH_SEND_TX_ALREADY_KNOWN`: occurs when adding a transaction already present in the pool.
- code: -32000
- message: `Known Transaction`
- `ETH_SEND_TX_REPLACEMENT_UNDERPRICED`: occurs when adding a transaction already present in the pool.
- code: -32000
- message: `Replacement transaction underpriced`
### Changes summary
- Created `TransactionAddedStatus` enum.
- `ALREADY_KNOWN`
- `REJECTED_UNDERPRICED_REPLACEMENT`
- `ADDED`
- Created 2 new errors in `JsonRpcError`.
- Updated JsonRpcErrorConverter to handle newly created errors.
- Updated `addLocalTransaction` method of `PendingTransactions` to return `TransactionAddedStatus` instead of boolean.
- Updated unit tests accordingly.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* When in retesteth return the coinbase in the eth_getBlockByHash, as
required by the retesteth tool.
* use genesis extraData when mining
* storage keys should be 0x00 instead of 0x when zero.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Compute transaction gas budget allocation according to EIP-1559 rules.
- Added `TransactionGasBudgetCalculator` with `hasBudget` method.
- Updated `AbstractBlockProcessor` to compute the gas budget using `TransactionGasBudgetCalculator`.
- Added unit tests in `TransactionGasBudgetCalculatorTest`.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Fixed unit test.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
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>
* 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>
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>
Update BesuController to use the NodeKey, rather than working with KeyPair - which in turn allows the crypto operations to be injected.
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>
When we deny a connection based on HTTP hostname log to trace the
rejected value.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Co-authored-by: Usman Saleem <usman@usmans.info>
* 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>
* ### Description
BlockHeader object needs to be modified in order to add the new field (baseFee) as specified in the EIP.
We should take care about the RLP encoding/decoding of this structure since it has to include or not the new fields depending on whether we are pre fork or post fork.
- Update `core.BlockHeader.java`
- Add `baseFee`
- Update `readFrom` method for RLP decoding
- Update `writeTo` method for RLP encoding
- Update `plugin.data.BlockHeader.java`
- Add `getBaseFee` method
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* TODO Add CLI command line flag `--Xeip1559-enabled`.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* TODO Add CLI command line flag `--Xeip1559-enabled`.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Added unstable annotation for getBaseFee. Moved from long to `Optional<Long>`
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Spotless apply
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Fixed error
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* fix plugin API hash
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* RLP encoding / decoding operations are guarded with the feature flag.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* spotless apply
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>