Refactor crypto, datatypes, and plugin-api to reduce plugin APIs in the EVM.
Split crypto into crypto services and crypto algorithms
Reverse the dependency between datatyps and plugin-api.
Remove plugin Hash and Address types (use datatypes)
Move PublicKey and Quantity into datatypes.
Lots of changes to imports and build files, and some fromPlugin calls removed.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@shemnon.com>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
Changes and config to support using GraalVM AOT to compile and
execute evmTool as an alternate configuration.
While not as long-term performant the startup time
makes filling reference tests with Besu reasonable.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Fix a formatting error in standard trace that produced non-parsable
JSON. Add unit tests to cover those cases.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Adding the t8n and b11r tool allows Hyperledger besu to produce reference
tests from the https://github.com/ethereum/execution-spec-tests repository.
* Add t8n tool, or transition tool. Calculates the state changes from a set
of transactions against a given parent context
* Add b11r tool, or block-builder tool. Given block parts it can generate a
RLP block.
* Change some tracing CLI flags to work better with retesteth
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Speedup initcode validation by
- optimizing the jumpdest loop
- not caching initcode in the code cache
(but keep codecache for normal contracts).
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Add the BLS curve precompiles into the registry for cancun. All of the
curve precompiles have been here since berlin, so this is just wiring
them in.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Add enforcement of the rule that EOF cannot create prior versions or
legacy EVM code contracts in create opcodes and create transactions.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
- Added missing javadocs so that javadoc doclint passes against JDK 17 (invoke by Besu gradle build).
- Exclude following packages from javadoc lint:
org.hyperledger.besu.privacy.contracts.generated
org.hyperledger.besu.tests.acceptance.*
- Temporarily exclude ethereum and evm submodule for doc lint checks.
- Run the javadoc task using GitHub actions (use Java 17) to report any javadoc errors during the PR builds
- Updating plugin-api build.gradle with new hash as javadoc comments caused it to change
Signed-off-by: Usman Saleem <usman@usmans.info>
Optimize the EOF Functions implementation by not splitting code sections
into separate Bytes object. Instead the EOF evaluation occurs on a
single container space. When a function is called the PC (relative to
container start, not section start) is moved.
EOF lacks PC introspection and absolute jumps, so where "PC=0" starts is
not observable to the code. "PC=0" is still respected in the traces.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Fix a variety of issues found during the fuzzing sprint.
* Validate type length matches code length
* Remove JUMPF from shanghai
* check retf output size
* handle zero length types and code better
* Fix table error on RETURNDATACOPY
* RJUMPV byte should be unsigned
* RJUMPV stack validation fix and more tests
* dead code detection via counting considered bytes
* EVMTool EOF Fuzzing support- remove all alphanumerics (punctuation) and comment lines from code in CLI
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Add two new development networks and forks, `FutureEips` for EIPs not yet
scheduled for a fork and `ExperimentalEips` for EIPs and other work not yet
accepted to a public network. Two new fork-named networks are added
like the `dev` network to facilitate easy local development.
These replace the deprecated `Shandong` network and fork.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Optimize Sstore operation, get current value and original value only once.
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Fix javadoc.
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* refactoring (add a supplier implementation to better support all the forks)
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* delete unnecessary parameters, add final for some fields and modify CHANGELOG.md
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* add a missing parameter in Javadoc
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Add failing test for deploying invalid contract
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Validate contractCode from frame
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Only receive frame output data in ContractValidationRule#validate
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Implement CALLF, RETF, and JUMPF operations. This introduces the
notion of "code sections" into the code. For legacy code section zero
consists of all of the code and is the only code section. Also
implements EIP specified code validation to ensure validated EOF code
won't use CALLF or JUMPF to a non-existent section.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Remove opSize field from Operation
With the introduction of RJUMPV, operations don't have fixed size anymore. This field isn't used anyware in the code so it's safe to delete it
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add comments
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add some EIP-3670 and EIP-3540 tests
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Replace jumpdest bitmap with BitSet
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Implement EIP-4200: EOF - Static relative jumps
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Increate the speed of ModExp gas calculations by using primitive types.
Use a native lib for modexp precompile.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Native modexp
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add Shandong gas calculator to support EIP-3860
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* add unit tests for Shandong gas calculator
Signed-off-by: lukelee-sl <luke.lee@swirldslabs.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: Diego López León <dieguitoll@gmail.com>
Signed-off-by: lukelee-sl <luke.lee@swirldslabs.com>
Co-authored-by: lukelee-sl <luke.lee@swirldslabs.com>
Implement "Small" EOF - EIP-3540 (container) and EIP-3670 (validation).
Make code an interface so EOF specific features are compartmentalized,
including an 'invalid' code type representing a code block that didn't
pass validation, CodeV1 for EOF1, and CodeV0 which represents pre-EOF
code. EVMs track a maximum supported EOF version (where 0 is pre-eof)and
code is generated from a CodeFactory taking in context (is it a CREATE
operation and max code size) for the validation.
Includes spec versions for "Shanghai" and transient testnet "Shandong".
"Small" EOF is only activated in Shandong.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Add Shandong network and fork
Add the transient Shandong fork and network definitions. For Shanghai
fork testing. Besu doesn't sync, but it does connect.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Parallelize some steps in BonsaiPersistedWorldState.calculateRootHash method
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Add synchronized on storage flat database remove and update method
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Add synchronized on storage flat database remove and update method
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Fix this error org.rocksdb.RocksDBException: unknown WriteBatch tag
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* create a specific calculateRootHash for BonsaiInMemoryWorldState class
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* create a specific calculateRootHash for BonsaiInMemoryWorldState class
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Fix nullPointerException on Collections.synchronizedSet
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Use parallelStreams instead of CompletableFuture API
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* Modify CHANGELOG.md
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
* spotless and synchronizedSet initializaton
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
* implementation of Bonsai snapshots based BonsaiWorldStateArchive
includes: try-with-resources and AutoCloseable WorldState in order to release snapshots when we are done with them
Signed-off-by: garyschulte <garyschulte@gmail.com>
The EVM refactor introduced a couple of EVM trace changes that are
outside the EIP-3115 standards.
* pc, gasRemaining, and memory were all post-execution values
* some places null should be "0x0" or "0x"
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Due to subtle differences between Bytes32 and UInt256 the changes failed
burn-in testing and are being reverted.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
The current internal storage APIs implement UInt256 rather than Bytes32,
which is an accident of prior EVM design. This migrates all internal
handling of storage addresses and values to Bytes32.
The main performance gain is reduced GC pressure, in that UInt256
stores the data as an array of ints, whereas Bytes32 keeps a sliced or
wrapped array of bytes. Since database APIs are all byte array based
this should remove unneeded conversions when going to/from the DB.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
* Adjust tracing calls
Restore two tracing behaviors in the EVM introduced by the unrolled loop
* change gas only on successful operations
* send post execution call after gas and PC changes.
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>