* 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>
Overview of changes:
* Remove vestigial log tracing. We will never use it in production and
standard json tracing gets us what we need
* Reduce use of lambdas and optionals. Reads great, translates into a 10%
perf hit in a tight loop.
* Unroll operation loop in some cases. Those are (a) ops that haven't
changed in any way since Frontier (b) ops not overridden in downstream
uses and (c) operations that translate into short static executions.
This has the longest tendrils as it is enabled by operations exposing
static methods to do their work.
* Refactoring of the operationTracer. The single, lambda consuming
traceExecution method was a barrier to performance. It has been replaced
with tracePreExecution and tracePostExecution. Look at
DebugOperationTracer to see how traces that need to operate on both
sides of the operation can be handled with this API.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Add java module info to the manifests of the following libraries used by the Besu EVM
./crypto - org.hyperledger.besu.internal.Crypto
./ethereum/rlp - org.hyperledger.besu.internal.Rlp
./util - org.hyperledger.besu.internal.Util
./datatypes - org.hyperledger.besu.Datatypes
./evm - org.hyperledger.besu.Evm
./plugin-api - org.hyperledger.besu.PluginApi
Signed-off-by: Mustafa Uzun <mustafa.uzun@limechain.tech>
Change the "minimum" gas in the TangerineWhistleGasCalculator to use an
unsigned comparison, to ensure a larger signed value is not selected.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
The four instances of gas in the CALL operations are all implemented
identically. Refactor the method into the abstract parent.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
10.4 revision of reference tests has notable changes
* Nonce can be up to 2^64-1, with some opcode and validity interactions specced in eip-2681
* Wei fields can be up to 2^256, tests check for rollover
* VM Tests were removed
* Legacy Tests were removed
* Reference tests make it clear that transactions with a maxPriorityFee of zero are valid. Perhaps useless, but still valid.
* Adding validation hooks in the out-of-chain test execution. These validations are caught in full-chain execution, just not in conveniently places for integration testing.
* This does not transaction tests support for the "merge" fork, as the release notes marked it as an "upcoming" feature.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Co-authored-by: Diego López León <dieguitoll@gmail.com>
Co-authored-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Rename SHA3 -> Keccak256
Ethereum doesn't do "official" sha3, we do keccak256, so rename as needed to reflect that reality.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Remove the Gas object from the EVM and replace it with the primitive
long. This will have positive impact on short lived object garbage
collection stats, which at very high load causes significant performance
issues.
This also codifies EIP-4803 in the Besu EVM, limiting gas to a signed
64-bit long internally.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Change the unit test execution to use the Junit5 JUnitPlatform. This
allows for a mix of junit 4 and junit 5 tests and for a gradual
migration to junit 5 instead of a big bang. One class depended on
junit 4 exceptions and was updated. Two tests depending on
native libraries fail gracefully on mac (and only mac).
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Allow precompiled contracts to return richer information instead of
results/fail. System/precompile contracts can now revert, fail, refund
gas, etc. instead of just succeed or fail.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
For each contract validation error return a relevant error instead of
the incorrect "INSUFFICIENT_GAS" error.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Migrate the jump dest analysis cache into a more generic code cache that
lives inside the EVM.
This is in preparation for Ethereum Object Formats where a string of
code may be treated differently depending on what EVM version is
executing the code. Newer versions will also have difference analyses to
run that will need different backing data structures.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* Bump SLF4J version
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Replace log4j2 API with SLF4j API
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Replace usage of LogManager#getFormatterLogger
This is for keeping compatibility with SLF4J. If neccesary, a specific formatter can be created for the RlpBlockImporter class
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Unset the default logging value for the retesteth
This is because it's not possible to resolve the root logger level into a Log4J2 field
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Prevent creation of Logger context outside SLF4J
org.hyperledger.besu.cli.BesuCommand#setAllLevels was taken from
https://github.com/apache/logging-log4j2/blob/rel%2F2.17.1/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L309
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add FATAL level deprecation message
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* [Sonar] Fix java:S2139
Exceptions should be either logged or rethrown but not both
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* [Sonar] Fix java:S3457
Printf-style format strings should be used correctly
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* Add changelog
Signed-off-by: Diego López León <dieguitoll@gmail.com>
* lots of errorprone fixes
* some license updates
* some mockito updates
* upgrade the rocksdb version
* Prometheus left at 0.9.0 as 0.10.0+ introduces OpenMetrics
related changes that break unit tests.
Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
* CLI option name change
Signed-off-by: Frank Li <b439988l@gmail.com>
* refactor privacyparameters.java and add deprecation warning
Signed-off-by: Frank Li <b439988l@gmail.com>
* more refactoring
Signed-off-by: Frank Li <b439988l@gmail.com>
* add to everything.toml
Signed-off-by: Frank Li <b439988l@gmail.com>
* bugs
Signed-off-by: Frank Li <b439988l@gmail.com>
* more missing variable names
Signed-off-by: Frank Li <b439988l@gmail.com>
* more classes
Signed-off-by: Frank Li <b439988l@gmail.com>
* more classes
Signed-off-by: Frank Li <b439988l@gmail.com>
* fix compile error
Signed-off-by: Frank Li <b439988l@gmail.com>
* add new test to invalidate passing both commands
Signed-off-by: Frank Li <b439988l@gmail.com>
* more refactoring + more tests
Signed-off-by: Frank Li <b439988l@gmail.com>
* new batch
Signed-off-by: Frank Li <b439988l@gmail.com>
* final batch?
Signed-off-by: Frank Li <b439988l@gmail.com>
* failing unit test
Signed-off-by: Frank Li <b439988l@gmail.com>
* revert incorrect refactoring back to onchain
Signed-off-by: Frank Li <b439988l@gmail.com>
* fix unit test
Signed-off-by: Frank Li <b439988l@gmail.com>
* comment
Signed-off-by: Frank Li <b439988l@gmail.com>
* comment
Signed-off-by: Frank Li <b439988l@gmail.com>
* support both privx methods
Signed-off-by: Frank Li <b439988l@gmail.com>
* add to changelog
Signed-off-by: Frank Li <b439988l@gmail.com>
* address comment
Signed-off-by: Frank Li <b439988l@gmail.com>
* add plugin privacy
Signed-off-by: Frank Li <b439988l@gmail.com>