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>
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>
Currently, Besu injects a KeyPair from the initial entry, through the hierarchy of classes and into various leaf classes. The leaf classes then execute statically defined cryptographic functions (eg Secp256k1.sign) using the injected key.
Thus the implementation of the cryptographic function is hardcoded by the leaf node, and cannot be injected - and thus its implementation cannot be altered.
This change combines the node's KeyPair with associated cryptographic functions in a single class, which can then be injected. This in turn enables other cryptographic backends to be utilised by Besu.
Signed-off-by: Trent Mohay <trent.mohay@consensys.net>
* 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>
* ### Description
Transaction object needs to be modified in order to add the 2 new fields (`gasPremium` and `feeCap`) 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 `Transaction` object
- Add gasPremium and feeCap fields
- Update readFrom method for RLP decoding
- Update writeTo method for RLP encoding
- Update plugin `Transaction` interface
- Add `getGasPremium` and `getFeeCap` methods
This EIP introduces gasPremium and feeCap fields in the transaction. They need to be included in the signing mechanism.
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* We need a manager class to hold EIP-1559 core logic. This helper class will be then used by glue code. This separation make testing simpler.
Specifically the following methods:
- `long computeBaseFee(final long parentBaseFee, final long parentGasUsed)`
- `boolean isValidBaseFee(final long parentBaseFee, final long baseFee)`
- `long eip1559GasPool(final long blockNumber)`
- `long legacyGasPool(final long blockNumber)`
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* spotlessApply
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>
* update known hash
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* clean up
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* clean up
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Address PR comments
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Address PR comments
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* remove useless constructor
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* add spdx header
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* 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>
* ### Description
Transaction object needs to be modified in order to add the 2 new fields (`gasPremium` and `feeCap`) 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 `Transaction` object
- Add gasPremium and feeCap fields
- Update readFrom method for RLP decoding
- Update writeTo method for RLP encoding
- Update plugin `Transaction` interface
- Add `getGasPremium` and `getFeeCap` methods
This EIP introduces gasPremium and feeCap fields in the transaction. They need to be included in the signing mechanism.
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>
* Remove TODO
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* spotless apply
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Merge step 0 and make EIP-1559 specific fields optional
Add feature flag guard for RLP encoding / decoding of transactions
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* fix error
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* Address PR comments
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* update plugin api known hash
Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
* 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>
The EthQL API spec specifies pulledStates and knownStates in the
`syncing` query. Previously we always returned null. This plumbs through
the needed data so that the synchronization states can report the
fast sync progress via EthQL, as well as the `eth_syncing` JSON-RPC.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Restore test generation of blocks.bin
Restore the ability to generate our blocks.bin as part of the build.
(a) a fixed start time was added
(b) nonces for blocks imported for test are deterministically chosen.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* more readable test files
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Update SLOAD_GAS cost to 200 in Aztlan Gas Calculator
Change SLOAD_GAS cost in Aztlan Gas Calculator from 800 to 200 and
update functions that use SLOAD_GAS.
Signed-off-by: edwardmack <ed@edwardmack.com>
* Update SLOAD_GAS cost to 200 in Aztlan Gas Calculator
Change SLOAD_GAS cost in Aztlan Gas Calculator from 800 to 200 and
update functions that use SLOAD_GAS.
Signed-off-by: edwardmack <ed@edwardmack.com>
Signed-off-by: Edward Mack <ed@edwardmack.com>
* remove overrides
removed overrides of calculateStorageCost and
calculateStorageRefundAmount in AztlanGasCalculator because these were
causing aztlan fork not to sync with kotti testnet.
Signed-off-by: Edward Mack <ed@edwardmack.com>
* merge
Signed-off-by: Edward Mack <ed@edwardmack.com>
* rename the method isPersistingState to isPersistingPrivateState because that is what it is used for
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
* rename the method isPersistingState to isPersistingPrivateState because that is what it is used for
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
* rename the method isPersistingState to isPersistingPrivateState because that is what it is used for
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
- Correct Reporting of reverts in nested call
- correct reporting and handling of value transfer in nested calls
- correct handling of precompiles via DELEGATECALL & CALLCODE
- Addition of precompiled contract gas costs
- Re-work handling of storage writes
- Initial handling of gas refunds
- fix bug in DELEGATECALL tests, we don't need gas in the stack
* this has a cascading effect on balances in diff tests
- rework depth detection in flat trace
- two new tests blocks
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* correct refund addresses
* correct returned memory from static precompiled calls.
* update integration test
* precompiles sometimes get plain old CALLs
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
This PR introduces functionality to conform with ECIP-1061
https://ecips.ethereumclassic.org/ECIPs/ecip-1061
Signed-off-by: edwardmack <ed@edwardmack.com>
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com>
* Handle CREATE and CREATE2 in flat trace
* precompile calls don't generate traces
* Handle REVERT in output and result nodes.
* output doesn't need to be held behind a supplier
* Handle padded output values when end is past memory
* Store memory in vm trace for MLOADs
* CREATE and CREATE2 store memory in vm-trace
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Handle CREATE and CREATE2 in flat trace
Handle create and create2 operations. Some other tests also got adjusted
as the source accounts were running out of test ether. Bumping up the
value in the genesis caused the statediff values to also go up.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Switch the EVM Memory to a copy on write structure, so when the trace
reads the memory they don't have to copy mutable bytes but can instead
simply use the value as immutable.
Also, fix a state diff bug when an account is deleted that was also just
created in the TX don't report it as an all equal diff, as well as new accounts storage diffs.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
When we calculate the cost of a SSTORE in trace we need to consider the
original value as of when the last transaction finished, not when the
whole block started.
To create a test for this the test blockchain also needed to be upgraded
to Istanbul. This resulted in a large number of cost only changes.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>