Squash the main verkle PR ahead of rebase
don't call Bytes() in GetTreeKey (#137)
trie: avoid endianness conversion in GetTreeKey (#140)
* trie/utils: add concrete expected value in trie key generation test
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* mod: update to latest go-verkle
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie/utils: avoid endianness conversions
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* apply review changes & update to official go-verkle version
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
upgrade go-verkle to CoW version and get TestProcessVerkle to build (#138)
updating ci to use self-hosted machine (#143)
fix: storage offset in non-header group + reuse of value buffer (#145)
dedup call to ChunkifyCode, same as replay branch (#156)
* dedup call to ChunkifyCode, same as replay branch
* fix some linter issues
fix code offset in tree update (#157)
fix REVERT in state processor test execution (#158)
* fix code offset in tree update
* fix REVERT in test execution
save on key hashing: lump code size update with first code chunk group (#159)
fix code chunk key calculation and storage key calculation (#161)
* fix codeKey calculation
* Remove
* fix storageOffset
* fix the fix to the fix to the offset fix
* Remove copy/pasted, unused code in test
* fix linter
---------
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
fix: infinite loop when calling extcodecopy on empty code (#151)
upgrade to latest go-verkle
fix: only update code in the tree if it's dirty (#174)
fix: read-touch the code size and Keccak of the origin (#175)
List of changes for converting a sepolia database (#182)
* naive conversion rebased on top of beverly hills
* changes for the sepolia shadow fork conversion
* fixes to please the linter
* fixes to please the linter
Unified point cache (#180)
* Unified point cache
* Use cache for Try*Account
* alter Trie interface to use caching for slots (#181)
* alter Trie interface to use caching for slots
* fix: use a lock to protect the point cache (#185)
* use fastest non-master go-verkle version & pull trie/Verkle.go changes to use new api (#184)
* mod: update to fastest go-verkle version today
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie/verkle: use new batch serialization api
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
* fix: TryDelete signature in unit tests
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
trie/utils: fix potential overflow (#191)
* trie/utils: fix potential overflow
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie/utils: receive storage key as a byte slice
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* revert formatter changes
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie/utils: fix mod 256
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
trie/utils: fix incorrect bigint assignment (#193)
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
upgrade precomp link to fix CI
fix: add missing code size&keccak leaves in empty accounts (#192)
fixes to use the latest go-verkle@master (#197)
* fixes to use the latest go-verkle@master
* linter fixes
* linter fixes for tests
* fix: use jsign's go-verkle fix
refactor: remove unused (*StateDB).GetXLittleEndian methods (#204)
fix gas accounting issue in state_processor_test.go (#207)
update go-verkle not to use StatelessNode anymore (#206)
* update go-verkle not to use StatelessNode anymore
* update go-verkle to latest
refactor: move verkle gas accounting to its own block in TransitionDB (#208)
fix a panic in deserializeVerkleProof if GetProofItems returns a nil ProofElements
use the cachingDB instead of a custom VerkleDB (#209)
* use the cachingDB instead of a custom VerkleDB
* fix stack trace in LES
remove holiman from CODEOWNERS as he gets too many emails
read from tree in state object if the snapshot is nil (#205)
add missing error checks for the root node type (#214)
implement OpenStorageTrie for verkle trees (#210)
* implement OpenStorageTrie for verkle trees
* add a few comments for future maintenance
* fix linter issue
fix: copy balance leaf to new buffer in TryGetAccount (#217)
implement some heretofore unimplemented iterator methods (#219)
params: move verkle params to their own file (#228)
fix: proper number of chunk evals (#215)
overlay transition (#244)
* overlay transition
Fix some bugs identified in the code review
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
Include base -> overlay key-values migration logic (#199)
* mod: add go-verkle version with key-value migration new apis
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* core/stateprocessor: use constant for max number of migrated key-values
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* core: add base->overlay key-values migration logic
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* core: fix some compiler errors
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie: consider removing transition trie api in the future
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* mod: use latest go-verkle
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
fix some unit tests errors
get convresion block from file
fix compilation issues
fix initialization issue in migrator
fix: changes needed to run the first 28 blocks
important sutff: fix the banner
fix: use nonce instead of balance in nonce leaf (#202)
fixes for performing the overlay transition (#203)
* fixes for performing the overlay transition
* fixes for the full replay
* fix: deletion-and-recreation of EoA
* fixes to replay 2M+ blocks
* upgrade to go-verkle@master
* fix: proper number of chunk evals
* rewrite conversion loop to fix known issues
changes to make replay work with the overlay method (#216)
* fixes for performing the overlay transition
fixes for the full replay
fix: deletion-and-recreation of EoA
fixes to replay 2M+ blocks
upgrade to go-verkle@master
fix: proper number of chunk evals
rewrite conversion loop to fix known issues
changes to make replay work with the overlay method
fixes to replay 2M+ blocks
update to latest go-verkle@master
* use a PBSS-like scheme for internal nodes (#221)
* use a PBSS-like scheme for internal nodes
* a couple of fixes coming from debugging replay
* fix: use an error to notify the transition tree that a deleted account was found in the overlay tree (#222)
* fixes for pbss replay (#227)
* fixes for pbss replay
* trie/verkle: use capped batch size (#229)
* trie/verkle: use capped batch size
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* trie/verkle: avoid path variable allocation per db.Put
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* don't keep more than 32 state root conversions in RAM (#230)
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
* cleanup some code
* mod: update go-verkle
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* re-enable snapshot (#231)
* re-enable cancun block / snapshot (#226)
* clear storage conversion key upon translating account (#234)
* clear storage conversion key upon translating account
* mod: use latest go-verkle
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
* fix: self-deadlock with translated root map mutex (#236)
* return compressed commitment as root commitment (#237)
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
fix first panic in *TransitionTrie.Copy()
upgrade go-verkle to latest master
mod: update go-verkle (#239)
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
core: print state root every 100 blocks (#240)
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
fix: only Commit the account trie (#242)
fixes to get TestProcessVerkle to work with the overlay branch (#238)
* fixes to get TestProcessVerkle to work with the overlay branch
* fix all panics in verkle state processor test
* fix proof verification
move transition management to cachingDB
* fix: mark the verkle transition as started if it's ended without being started
* fix the verkle state processing test
* fix linter errors
* Add a function to clear verkle params for replay
* fix: handle TransitionTrie in OpenStorageTrie
* fix linter issue
* fix the deleted account error (#247)
* code cleanup (#248)
* fix: don't error on a missing conversion.txt (#249)
* Overlay Tree preimages exporting and usage (#246)
* export overlay preimages tool
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* use preimages flat file in overlay tree migration logic
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* cmd/geth: add --roothash to overlay tree preimage exporting command
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* cleanup
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* review feedback
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
* fix: reduce the PR footprint (#250)
* fix: don't fail when preimages.bin is missing (#251)
* fix: don't fail when preimages.bin is missing
* fix: don't open the preimages file when outside of transition
---------
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
review changes
remove replay-specific code
This updates the reference tests to the latest version and also adds logic
to process EIP-4844 blob transactions into the state transition. We are now
passing most Cancun fork tests.
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Felix Lange <fjl@twurst.com>
Here, the core.Message interface turns into a plain struct and
types.Message gets removed.
This is a breaking change to packages core and core/types. While we do
not promise API stability for package core, we do for core/types. An
exception can be made for types.Message, since it doesn't have any
purpose apart from invoking the state transition in package core.
types.Message was also marked deprecated by the same commit it
got added in, 4dca5d4db7 (November 2016).
The core.Message interface was added in December 2014, in commit
db494170dc, for the purpose of 'testing' state transitions. It's the
same change that made transaction struct fields private. Before that,
the state transition used *types.Transaction directly.
Over time, multiple implementations of the interface accrued across
different packages, since constructing a Message is required whenever
one wants to invoke the state transition. These implementations all
looked very similar, a struct with private fields exposing the fields
as accessor methods.
By changing Message into a struct with public fields we can remove all
these useless interface implementations. It will also hopefully
simplify future changes to the type with less updates to apply across
all of go-ethereum when a field is added to Message.
---------
Co-authored-by: Felix Lange <fjl@twurst.com>
This change implements withdrawals as specified in EIP-4895.
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
Co-authored-by: marioevz <marioevz@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
This is the initial implementation of EIP-1559 in packages core/types and core.
Mining, RPC, etc. will be added in subsequent commits.
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.
There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.
The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID.
This change also adds support for the YoloV3 testnet.
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
Removes the yolov2 definition, adds yolov3, including EIP-2565. This PR also disables some of the erroneously generated blockchain and statetests, and adds the new genesis hash + alloc for yolov3.
This PR disables the CLI switches for yolo, since it's not complete until we merge support for 2930.
A lot of times when we hit 'core' errors, example: invalid tx, the information provided is
insufficient. We miss several pieces of information: what account has nonce too high,
and what transaction in that block was offending?
This PR adds that information, using the new type of wrapped errors.
It also adds a testcase which (partly) verifies the output from the errors.
The first commit changes all usage of direct equality-checks on core errors, into
using errors.Is. The second commit adds contextual information. This wraps most
of the core errors with more information, and also wraps it one more time in
stateprocessor, to further provide tx index and tx hash, if such a tx is encoutered in
a block. The third commit uses the chainmaker to try to generate chains with such
errors in them, thus triggering the errors and checking that the generated string meets
expectations.
* all: core: split vm.Config into BlockConfig and TxConfig
* core: core/vm: reset EVM between tx in block instead of creating new
* core/vm: added docs
* all: seperate consensus error and evm internal error
There are actually two types of error will be returned when
a tranaction/message call is executed: (a) consensus error
(b) evm internal error. The former should be converted to
a consensus issue, e.g. The sender doesn't enough asset to
purchase the gas it specifies. The latter is allowed since
evm itself is a blackbox and internal error is allowed to happen.
This PR emphasizes the difference by introducing a executionResult
structure. The evm error is embedded inside. So if any error
returned, it indicates consensus issue happens.
And also this PR improve the `EstimateGas` API to return the concrete
revert reason if the transaction always fails
* all: polish
* accounts/abi/bind/backends: add tests
* accounts/abi/bind/backends, internal: cleanup error message
* all: address comments
* core: fix lint
* accounts, core, eth, internal: address comments
* accounts, internal: resolve revert reason if possible
* accounts, internal: address comments
This commit is a preparation for the upcoming metropolis hardfork. It
prepares the state, core and vm packages such that integration with
metropolis becomes less of a hassle.
* Difficulty calculation requires header instead of individual
parameters
* statedb.StartRecord renamed to statedb.Prepare and added Finalise
method required by metropolis, which removes unwanted accounts from
the state (i.e. selfdestruct)
* State keeps record of destructed objects (in addition to dirty
objects)
* core/vm pre-compiles may now return errors
* core/vm pre-compiles gas check now take the full byte slice as argument
instead of just the size
* core/vm now keeps several hard-fork instruction tables instead of a
single instruction table and removes the need for hard-fork checks in
the instructions
* core/vm contains a empty restruction function which is added in
preparation of metropolis write-only mode operations
* Adds the bn256 curve
* Adds and sets the metropolis chain config block parameters (2^64-1)
This commit adds pluggable consensus engines to go-ethereum. In short, it
introduces a generic consensus interface, and refactors the entire codebase to
use this interface.
This significantly reduces the dependency closure of ethclient, which no
longer depends on core/vm as of this change.
All uses of vm.Logs are replaced by []*types.Log. NewLog is gone too,
the constructor simply returned a literal.
The run loop, which previously contained custom opcode executes have been
removed and has been simplified to a few checks.
Each operation consists of 4 elements: execution function, gas cost function,
stack validation function and memory size function. The execution function
implements the operation's runtime behaviour, the gas cost function implements
the operation gas costs function and greatly depends on the memory and stack,
the stack validation function validates the stack and makes sure that enough
items can be popped off and pushed on and the memory size function calculates
the memory required for the operation and returns it.
This commit also allows the EVM to go unmetered. This is helpful for offline
operations such as contract calls.
Environment is now a struct (not an interface). This
reduces a lot of tech-debt throughout the codebase where a virtual
machine environment had to be implemented in order to test or run it.
The new environment is suitable to be used en the json tests, core
consensus and light client.
This commit implements EIP158 part 1, 2, 3 & 4
1. If an account is empty it's no longer written to the trie. An empty
account is defined as (balance=0, nonce=0, storage=0, code=0).
2. Delete an empty account if it's touched
3. An empty account is redefined as either non-existent or empty.
4. Zero value calls and zero value suicides no longer consume the 25k
reation costs.
params: moved core/config to params
Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>