| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* params: Updated finalized gascosts for ECMUL/MODEXP
* core,tests: Updates pending new tests
* tests: Updated with new tests
* core: revert state transition bugfix
* tests: Add expected failures due to #15119
|
| |
|
|
|
|
|
|
| |
* core/vm: Make max_codesize only applicable post Spurious Dragon/158/155/161/170
* tests: Remove expected failure
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
core: add status as a consensus field in receipt
|
| | |
|
|/
|
|
|
|
| |
* cmd/evm, core/vm, internal/ethapi: Add 'err' to tracer interface CaptureEnd
* cmd/evm: fix nullpointer when there is no error
|
|
|
| |
Signed-off-by: Ti Zhou <tizhou1986@gmail.com>
|
|\
| |
| | |
core/vm: implement REVERT metropolis opcode
|
| | |
|
| | |
|
|/ |
|
| |
|
| |
|
|
|
|
|
|
| |
* Fix STATICCALL so it is able to call precompiles too
* Fix write detection to use the correct value argument of CALL
* Fix write protection to ignore the value in CALLCODE
|
| |
|
| |
|
| |
|
|
|
|
|
| |
* Update modexp gas calculation to new version
* Fix modexp modulo 0 special case to return zero
|
| |
|
|
|
|
|
|
|
|
| |
* core: Remove unused `state` parameter to `NewEnv`.
`cfg.State` is used instead.
* core/vm/runtime: remove unused import
|
| |
|
| |
|
| |
|
|\
| |
| | |
core/vm: fix overflow in gas calculation formula
|
| | |
|
| | |
|
|/ |
|
|
|
|
|
|
|
|
|
| |
With this commit, core/state's access to the underlying key/value database is
mediated through an interface. Database errors are tracked in StateDB and
returned by CommitTo or the new Error method.
Motivation for this change: We can remove the light client's duplicated copy of
core/state. The light client now supports node iteration, so tracing and storage
enumeration can work with the light client (not implemented in this commit).
|
| |
|
|\
| |
| | |
core/vm: improve opByte
|
| | |
|
| |
| |
| |
| | |
endianness
|
| | |
|
|/ |
|
|
|
|
| |
t push --force
|
| |
|
|
|
|
|
| |
Pre allocate the stack to 1024 optimising stack pushing, reducing calls
to runtime.makeslice and runtime.mallocgc
|
|
|
|
|
| |
Improve the duplication method of the stack to reuse big ints by passing
in an existing integer pool.
|
| |
|
|
|
|
|
| |
Improved push instructions by removing unnecessary big int allocations
and by making it int instead of big.Int
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
* Improved the standard evm tracer output and renamed it to WriteTrace
which now takes an io.Writer to write the logs to.
* Added WriteLogs which writes logs to the given writer in a readable
format.
* evm utility now also prints logs generated during the execution.
|
|
|
|
|
| |
The evm compile command implements a simple assembly language that compiles to
EVM bytecode.
|
|\
| |
| | |
Logger updates
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* common/math: optimize PaddedBigBytes, use it more
name old time/op new time/op delta
PaddedBigBytes-8 71.1ns ± 5% 46.1ns ± 1% -35.15% (p=0.000 n=20+19)
name old alloc/op new alloc/op delta
PaddedBigBytes-8 48.0B ± 0% 32.0B ± 0% -33.33% (p=0.000 n=20+20)
* all: unify big.Int zero checks
Various checks were in use. This commit replaces them all with Int.Sign,
which is cheaper and less code.
eg templates:
func before(x *big.Int) bool { return x.BitLen() == 0 }
func after(x *big.Int) bool { return x.Sign() == 0 }
func before(x *big.Int) bool { return x.BitLen() > 0 }
func after(x *big.Int) bool { return x.Sign() != 0 }
func before(x *big.Int) int { return x.Cmp(common.Big0) }
func after(x *big.Int) int { return x.Sign() }
* common/math, crypto/secp256k1: make ReadBits public in package math
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* common: remove CurrencyToString
Move denomination values to params instead.
* common: delete dead code
* common: move big integer operations to common/math
This commit consolidates all big integer operations into common/math and
adds tests and documentation.
There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.
The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().
BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.
Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.
ParseUint64 is used in places where String2Big was used to decode a
uint64.
The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.
* common: delete unused big integer variables
* accounts/abi: replace uses of BytesToBig with use of encoding/binary
* common: remove BytesToBig
* common: remove Bytes2Big
* common: remove BigTrue
* cmd/utils: add BigFlag and use it for error-checked integer flags
While here, remove environment variable processing for DirectoryFlag
because we don't use it.
* core: add missing error checks in genesis block parser
* common: remove String2Big
* cmd/evm: use utils.BigFlag
* common/math: check for 256 bit overflow in ParseBig
This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.
* cmd/utils: fixup import
|
| |
|
|
|
|
| |
Removed exported statedb object accessors, reducing the chance for nasty
bugs to creep in. It's also ugly and unnecessary to have these methods.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* vendor: add github.com/btcsuite/btcd/btcec
* crypto: add btcec fallback for sign/recover without cgo
This commit adds a non-cgo fallback implementation of secp256k1
operations.
* crypto, core/vm: remove wrappers for sha256, ripemd160
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reworked the EVM gas instructions to use 64bit integers rather than
arbitrary size big ints. All gas operations, be it additions,
multiplications or divisions, are checked and guarded against 64 bit
integer overflows.
In additon, most of the protocol paramaters in the params package have
been converted to uint64 and are now constants rather than variables.
* common/math: added overflow check ops
* core: vmenv, env renamed to evm
* eth, internal/ethapi, les: unmetered eth_call and cancel methods
* core/vm: implemented big.Int pool for evm instructions
* core/vm: unexported intPool methods & verification methods
* core/vm: added memoryGasCost overflow check and test
|
|
|
|
| |
This reverts commit 8b57c494908637a5c0e74f8f7a13b3218e026757.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reworked the EVM gas instructions to use 64bit integers rather than
arbitrary size big ints. All gas operations, be it additions,
multiplications or divisions, are checked and guarded against 64 bit
integer overflows.
In additon, most of the protocol paramaters in the params package have
been converted to uint64 and are now constants rather than variables.
* common/math: added overflow check ops
* core: vmenv, env renamed to evm
* eth, internal/ethapi, les: unmetered eth_call and cancel methods
* core/vm: implemented big.Int pool for evm instructions
* core/vm: unexported intPool methods & verification methods
* core/vm: added memoryGasCost overflow check and test
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
(#3455)
To address increasing complexity in code that handles signatures, this PR
discards all notion of "different" signature types at the library level. Both
the crypto and accounts package is reduced to only be able to produce plain
canonical secp256k1 signatures. This makes the crpyto APIs much cleaner,
simpler and harder to abuse.
|
|
|
|
|
|
|
|
| |
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 field used to be assigned by the filter system and returned through
the RPC API. Now that we have a Go client that uses the underlying type,
the field needs to move. It is now assigned to true when the RemovedLogs
event is generated so the filter system doesn't need to care about the
field at all.
While here, remove the log list from ChainSideEvent. There are no users
of this field right now and any potential users could subscribe to
RemovedLogsEvent instead.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
* common/math, core/vm: implement fast EXP.
Courtesy @chfast & @karalabe
* common/math: fix go vet issues on exp calculation
|
|\
| |
| | |
core/vm: add limit option to LogConfig
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
that specifies the maximum number of elements in the `structLogs`
output. This option is useful for debugging a transaction that
involves a large number of repetition.
For example,
```
debug.traceTransaction(tx, {disableStorage: true, limit: 2})
```
shows at most the first two steps in the `structLogs`.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This implements 1b & 1c of EIP150 by adding a new GasTable which must be
returned from the RuleSet config method. This table is used to determine
the gas prices for the current epoch.
Please note that when the CreateBySuicide gas price is set it is assumed
that we're in the new epoch phase.
In addition this PR will serve as temporary basis while refactorisation
in being done in the EVM64 PR, which will substentially overhaul the gas
price code.
|
| |
| |
| |
| | |
The delete/remove naming has caused endless confusion in the past.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This commit replaces the deep-copy based state revert mechanism with a
linear complexity journal. This commit also hides several internal
StateDB methods to limit the number of ways in which calling code can
use the journal incorrectly.
As usual consultation and bug fixes to the initial implementation were
provided by @karalabe, @obscuren and @Arachnid. Thank you!
|
|/ |
|
|
|
|
|
| |
This change introduces a global, per-state cache that keeps account data
in the canon state. Thanks to @karalabe for lots of fixes.
|
|
|
|
|
|
|
|
| |
In this commit, core/types's types learn how to encode and decode
themselves as JSON. The encoding is very similar to what the RPC API
uses. The RPC API is missing some output fields (e.g. transaction
signature values) which will be added to the API in a later commit. Some
fields that the API generates are ignored by the decoder methods here.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This CL makes several refactors:
- Define a Tracer interface, implementing the `CaptureState` method
- Add the VM environment as the first argument of
`Tracer.CaptureState`
- Rename existing functionality `StructLogger` an make it an
implementation of `Tracer`
- Delete `StructLogCollector` and make `StructLogger` collect the logs
directly
- Change all callers to use the new `StructLogger` where necessary and
extract logs from that.
- Deletes the apparently obsolete and likely nonfunctional 'TraceCall'
from the eth API.
Callers that only wish accumulated logs can use the `StructLogger`
implementation straightforwardly. Callers that wish to efficiently
capture VM traces and operate on them without excessive copying can now
implement the `Tracer` interface to receive VM state at each step and
do with it as they wish.
This CL also removes the accumulation of logs from the vm.Environment;
this was necessary as part of the refactor, but also simplifies it by
removing a responsibility that doesn't directly belong to the
Environment.
|
|
|
|
| |
Fixes #2825
|
|\
| |
| | |
vm: Replace some SstoreClearGas with SstoreResetGas
|
| | |
|
|/ |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Added chain configuration options and write out during genesis database
insertion. If no "config" was found, nothing is written to the database.
Configurations are written on a per genesis base. This means
that any chain (which is identified by it's genesis hash) can have their
own chain settings.
|
|
|
|
|
| |
The EVM is now initialised with an additional configured object that
allows you to turn on debugging options.
|
|
|
|
|
|
|
| |
The EVM was previously initialised and created for every CALL, CALLCODE,
DELEGATECALL and CREATE. This PR changes this behaviour so that the same
EVM can be used through the session and beyond as long as the
Environment sticks around.
|
| |
|
|
|
|
| |
As we aren't really using the standarized SHA-3
|
|
|
|
|
|
| |
* Removed some strange code that didn't apply state reverting properly
* Refactored code setting from vm & state transition to the executioner
* Updated tests
|
|
|
|
|
|
|
|
| |
* change gas cost for contract creating txs
* invalidate signature with s value greater than secp256k1 N / 2
* OOG contract creation if not enough gas to store code
* new difficulty adjustment algorithm
* new DELEGATECALL op code
|
|
|
|
|
|
| |
Implemented `runtime.Call` which uses - unlike Execute - the given state
for the execution and the address of the contract you wish to execute.
Unlike `Execute`, `Call` requires a config.
|
|
|
|
|
|
|
|
| |
integrated feedback
Integrated code review suggestions
Integrated last review comments
|
| |
|
| |
|
|
|
|
|
|
| |
The runtime environment can be used for simple basic execution of
contract code without the requirement of setting up a full stack and
operates fully in memory.
|
|\
| |
| | |
core/vm: JIT segmentation
|
| | |
|
| |
| |
| |
| |
| | |
* multi-push segments
* static jumps segments
|
| |
| |
| |
| |
| |
| | |
Moved the execution of instructions to the instruction it self. This
will allow for specialised instructions (e.g. segments) to be execution
in the same manner as regular instructions.
|
|\ \
| | |
| | | |
eth/63 fast synchronization algorithm
|
| | | |
|
| | | |
|
| |/ |
|
|/
|
|
|
| |
Make sure that we're fetching the hash from the current chain and not
the canonical chain.
|
| |
|
| |
|
|
|
|
|
|
| |
* Renamed ChainManager to BlockChain
* Checkpointing is no longer required and never really properly worked
when the state was corrupted.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Moved `vm.Transfer` to `core` package and changed execution to call
`env.Transfer` instead of `core.Transfer` directly.
* core/vm: byte code VM moved to jump table instead of switch
* Moved `vm.Transfer` to `core` package and changed execution to call
`env.Transfer` instead of `core.Transfer` directly.
* Byte code VM now shares the same code as the JITVM
* Renamed Context to Contract
* Changed initialiser of state transition & unexported methods
* Removed the Execution object and refactor `Call`, `CallCode` &
`Create` in to their own functions instead of being methods.
* Removed the hard dep on the state for the VM. The VM now
depends on a Database interface returned by the environment. In the
process the core now depends less on the statedb by usage of the env
* Moved `Log` from package `core/state` to package `core/vm`.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
opNumber did not create a new big int which could lead to the block's
number being modified.
|
| |
|
|
|
|
|
|
|
| |
Reduced big int allocation by making stack items modifiable. Instead of
adding items such as `common.Big0` to the stack, `new(big.Int)` is
added instead. One must expect that any item that is added to the stack
might change.
|
|
|
|
|
| |
Reduced the amount of state copied that are required by N calls by doing
a balance check prior to any state modifications.
|
|
|
|
| |
* changed stack and removed stack ptr. Let go decide on slice reuse.
|
|
|
|
| |
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
|
|
|
|
|
| |
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Removed VM errors from the consensus errors. They now used for output
only.
|
| |
|
| |
|
| |
|
|
|
|
| |
Removed full tx validation during state transitions
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This also reduces the time required spend in the VM
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
* JUMPDEST analysis is faster because less type conversions are performed.
* The map of JUMPDEST locations is now created lazily at the first JUMP.
* The result of the analysis is kept around for recursive invocations
through CALL/CALLCODE.
Fixes #1147
|
| |
|
|\
| |
| | |
core/vm: Cleanups & SUB output fix. Closes #1096
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
| |
Logs are now recorded per transactions instead of tossing them out after
each transaction. This should also fix an issue with
`eth_getFilterLogs` (#629) Also now implemented are the `transactionHash,
blockHash, transactionIndex, logIndex` on logs. Closes #654.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
* Add params package with exported variables generated from
github.com/ethereum/common/blob/master/params.json
* Use params package variables in applicable places
* Add check for minimum gas limit in validation of block's gas limit
* Remove common/params.json from go-ethereum to avoid
outdated version of it
|
| |
|
| |
|
|
|
|
|
|
| |
* Added new CreateAccount method which properly overwrites previous
accounts (excluding balance)
* Fixed block tests (100% success)
|
| |
|
|
|
|
| |
ebuchman-fix_ecrecover
|
|
|
|
|
|
|
| |
* CALLDATA use getData
* removed old context get range value
* removed casting big => int for some cases
* pc now big int #457
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
* Refund of value
|
| |
|
|
|