Commit Graph

903 Commits

Author SHA1 Message Date
Felix Lange
16d8397e30 core: lower transaction pool max queue limit 2016-10-10 15:32:06 +02:00
Felix Lange
e66b158f0b core: print import stats more often
If geth is busy importing 2048 heavy blocks it can take a while before
it prints anything. This change ensures that a message gets printed
every 8s.
2016-10-07 21:03:38 +02:00
Felix Lange
c88e435724 Merge pull request #3088 from bas-vk/rpc-block-output
core/types: renamed receiptRoot to receiptsRoot
2016-10-06 18:32:27 +02:00
Felix Lange
eeb2a1a6e3 Merge pull request #3094 from fjl/tests-update
tests: update test files from github.com/ethereum/tests @ 45bc1d21d3c1
2016-10-06 16:19:53 +02:00
Felix Lange
1b7b2ba216 tests: update test files from github.com/ethereum/tests @ 45bc1d21d3c1
Two new tests are skipped because they're buggy. Making some newer
random state tests work required implementing the 'compressed return
value encoding'.
2016-10-06 15:36:21 +02:00
Felix Lange
3c836dd71b core/state: optimize GetState
There is no need to use the reflection-based decoder to decode []byte.
2016-10-06 15:32:17 +02:00
Felix Lange
90fce8bfa6 core/state: rename Delete/IsDeleted to Suicide/HasSuicided
The delete/remove naming has caused endless confusion in the past.
2016-10-06 15:32:17 +02:00
Felix Lange
1f1ea18b54 core/state: implement reverts by journaling all changes
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!
2016-10-06 15:32:16 +02:00
Bas van Kervel
71e8ae01b8 core/types: renamed receiptRoot to receiptsRoot 2016-10-05 12:24:42 +02:00
Péter Szilágyi
b7159818f9 core/state: track dirty state entries for each object 2016-10-03 10:48:01 +03:00
Péter Szilágyi
cb84e3f029 cmd, core, internal, light, tests: avoid hashing the code in the VM 2016-10-01 16:01:58 +03:00
Yoichi Hirai
bb6115b737 vm, ethapi: add limit option to traceTransaction
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`.
2016-09-30 17:36:00 +02:00
Péter Szilágyi
710435b51b core, eth, trie: reuse trie journals in all our code 2016-09-28 11:27:31 +03:00
Felix Lange
cd791bd855 core, trie: replace state caches with trie journal 2016-09-28 11:27:28 +03:00
Felix Lange
a59a93f476 core/state: track all accounts in canon state
This change introduces a global, per-state cache that keeps account data
in the canon state. Thanks to @karalabe for lots of fixes.
2016-09-26 10:09:52 +02:00
Gustav Simonsson
25ed5fedda core/state: short-circuit balance change if zero value 2016-09-26 01:26:54 -04:00
Gustav Simonsson
b6b17e5648 core/state, light: remove unused StateObject.initCode 2016-09-19 02:16:58 -04:00
Péter Szilágyi
88b012ad3b Merge pull request #3006 from Arachnid/patch
core/state: Fix memory expansion bug by not copying clean objects
2016-09-19 04:20:14 +03:00
Nick Johnson
581b320b9d core/state: Fix memory expansion bug by not copying clean objects 2016-09-19 08:57:08 +08:00
Péter Szilágyi
b6b5ec8f75 core/types: add core type marshal methods too 2016-09-08 18:16:53 +03:00
Péter Szilágyi
b4a5251391 core: abstract out a sorted transaction hash map 2016-09-02 14:15:40 +03:00
Péter Szilágyi
a183ea29f9 core: add upper bound on the queued transctions 2016-09-02 14:15:40 +03:00
Péter Szilágyi
affffb39b3 core/types, miner: switch over to the grouped tx sets 2016-09-02 14:12:03 +03:00
Péter Szilágyi
0ef327bbee core, eth, internal, miner: optimize txpool for quick ops 2016-09-02 14:12:03 +03:00
Péter Szilágyi
795b70423e core, eth, miner: only retain 1 tx/nonce, remove bad ones 2016-09-02 14:12:03 +03:00
Felix Lange
704fde01e8 core/types, core/vm: improve docs, add JSON marshaling methods
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.
2016-08-04 03:55:33 +02:00
Nick Johnson
2f99720901 core/vm, eth: Add support for javascript trace functions 2016-08-23 15:06:39 +01:00
Nick Johnson
781915f183 core/vm: Refactor tracing to make Tracer the main interface
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.
2016-08-22 09:26:15 +01:00
Felix Lange
475521dd74 Merge pull request #2909 from fjl/account-manager-cleanup
all: clean up tech debt left behind by the API split
2016-08-17 20:59:59 +02:00
Felix Lange
3c09c5f12d core, miner: move Backend to miner
This ensures that package core doesn't depend on package accounts and
resolves an age-old TODO.
2016-08-17 17:39:04 +02:00
Felix Lange
84d11c19fd eth: remove dapp database remains 2016-08-17 17:39:03 +02:00
Bas van Kervel
47ff813012 rpc: refactor subscriptions and filters 2016-08-17 12:59:58 +02:00
Bas van Kervel
bb8059f6aa core: ensure the canonical block is written before the canonical hash is set 2016-08-16 15:21:22 +02:00
Felix Lange
e4736fe469 core/vm: hide ecrecover error message
Fixes #2825
2016-08-05 23:12:52 +02:00
Péter Szilágyi
2c2e389b77 cmd, core, eth, miner, params, tests: finalize the DAO fork 2016-07-15 16:52:55 +03:00
Péter Szilágyi
3291235711 accounts, core, eth: pass chain config for chain maker to test DAO 2016-07-15 16:52:55 +03:00
Péter Szilágyi
461cdb593b core, params, tests: add DAO hard-fork balance moves 2016-07-15 16:52:55 +03:00
Péter Szilágyi
7f00e8c033 core, eth: enforce network split post DAO hard-fork 2016-07-15 16:52:55 +03:00
Péter Szilágyi
a87089fd2d cmd, core, miner: add extradata validation to consensus rules 2016-07-15 16:52:55 +03:00
Péter Szilágyi
9e56811a37 core: gracefully handle missing homestead block config 2016-07-15 16:52:55 +03:00
Péter Szilágyi
6060e098c9 cmd, core, eth, params: implement flags to control dao fork blocks 2016-07-15 16:52:55 +03:00
Péter Szilágyi
1a652afe16 Merge pull request #2724 from pirapira/fix_reset_fees
vm: Replace some SstoreClearGas with SstoreResetGas
2016-07-15 16:24:16 +03:00
Péter Szilágyi
f970610c04 Merge pull request #2799 from zsfelfoldi/api-nonce-fix2
core: added CheckNonce() to Message interface
2016-07-12 16:07:15 +03:00
zsfelfoldi
00787fe781 core: added CheckNonce() to Message interface 2016-07-11 12:35:23 +02:00
Péter Szilágyi
f5a29eab5c core: solve a remote-import/local-mine data race 2016-07-08 16:59:19 +03:00
Péter Szilágyi
1e50f5dd28 Merge pull request #2159 from zsfelfoldi/light-backend
eth: separate common and full node-specific API and backend service
2016-06-30 12:57:50 +03:00
Péter Szilágyi
6362a9d610 Revert "test, cmd/evm, core, core/vm: illegal code hash implementation"
This reverts commit 7a5b571c67.
2016-06-29 11:44:51 +03:00
Péter Szilágyi
d55fc35df1 Revert "core: add voting and result tracking for the dao soft-fork"
This reverts commit c4de28938f.
2016-06-29 11:44:40 +03:00
Péter Szilágyi
67e9d33486 Revert "core: update DAO soft-fork number, clean up the code"
This reverts commit ba784bdf36.
2016-06-29 11:44:29 +03:00
Péter Szilágyi
219859f8bb Revert "core: update the DAO soft fork proposal to the final block"
This reverts commit 1e3a7d4fab.
2016-06-29 11:44:03 +03:00
Péter Szilágyi
1e3a7d4fab core: update the DAO soft fork proposal to the final block 2016-06-24 15:24:09 +03:00
Péter Szilágyi
ba784bdf36 core: update DAO soft-fork number, clean up the code 2016-06-23 17:16:43 +03:00
Péter Szilágyi
c4de28938f core: add voting and result tracking for the dao soft-fork 2016-06-23 16:43:35 +03:00
Jeffrey Wilcke
7a5b571c67 test, cmd/evm, core, core/vm: illegal code hash implementation
This implements a generic approach to enabling soft forks by allowing
anyone to put in hashes of contracts that should not be interacted from.
This will help "The DAO" in their endevour to stop any whithdrawals from
any DAO contract by convincing the mining community to accept their code
hash.
2016-06-22 11:38:25 +03:00
Yoichi Hirai
86bc7795a3 vm: Replace some SstoreClearGas with SstoreResetGas 2016-06-21 21:15:26 +02:00
Fabio Berger
a3efdb13f2 README, core, rpc: fix various typos 2016-06-21 17:38:35 +01:00
zsfelfoldi
3a97280ae8 eth: separate common and full node-specific API and backend service 2016-06-16 17:36:38 +02:00
Péter Szilágyi
22ef7370e7 Merge pull request #2686 from obscuren/issue-2542
core/state, eth: Updated suicides objects when tracing transactions
2016-06-14 16:54:46 +03:00
Jeffrey Wilcke
bb3651abc8 core/state, eth: Updated suicides objects when tracing transactions
Consensus rules dictate that objects can only be removed during the
finalisation of the transaction (i.e. after all calls have finished).
Thus calling a suicided contract twice from the same transaction:
A->B(S)->ret(A)->B(S) results in 2 suicides. Calling the suicided
object twice from two transactions: A->B(S), A->B, results in only one
suicide and a call to an empty object.

Our current debug tracing functionality replays all transaction that
were executed prior to the targetted transaction in order to provide
the user with an accurate trace.

As a side effect to calling StateDB.IntermediateRoot it also deletes any
suicides objects. Our tracing code never calls this function because it
isn't interested in the intermediate root. Becasue of this it caused a
bug in the tracing code where transactions that were send to priviously
deleted objects resulted in two suicides rather than one suicide and a
call to an empty object.

Fixes #2542
2016-06-13 11:57:42 +02:00
zsfelfoldi
f9917c8c7b core: improved chainDb using sequential keys 2016-06-07 16:38:56 +02:00
zsfelfoldi
5a458da42a core: chain read/write speed benchmarks 2016-06-06 14:38:28 +02:00
Felix Lange
fc85dd175e core: add missing lock in TxPool.{GetTransaction,RemoveTx}
Fixes #2650
2016-06-03 12:43:33 +02:00
Jeffrey Wilcke
5c39a1bb26 Merge pull request #2585 from karalabe/trie-dirty-tracking
core, core/state, trie: enterprise hand-tuned multi-level caching
2016-05-30 23:07:51 +02:00
Péter Szilágyi
8ee84584a4 core/state: return the starting nonce for non-existent accs (testnet) 2016-05-27 10:42:11 +03:00
Péter Szilágyi
748d1c171d core, core/state, trie: enterprise hand-tuned multi-level caching 2016-05-26 16:33:09 +03:00
Felix Lange
ca18202eb9 eth: enable bad block reports
We used to have reporting of bad blocks, but it was disabled
before the Frontier release. We need it back because users
are usually unable to provide the full RLP data of a bad
block when it occurs.

A shortcoming of this particular implementation is that the
origin peer is not tracked for blocks received during eth/63
sync. No origin peer info is still better than no report at
all though.
2016-05-25 02:02:51 +02:00
Fabio Berger
faf663133b core: Simplify bloom9 tests with available convenience method TestBytes 2016-05-22 16:42:46 -07:00
Jeffrey Wilcke
fe532a98f9 core: fixed pointer assignment
This fixes an issue where it's theoretical possible to cause a consensus
failure when hitting the lower end of the difficulty, though pratically
impossible it's worth a fix.
2016-05-13 12:12:46 +02:00
Felix Lange
56ed6152a1 core, eth, miner: improve shutdown synchronisation
Shutting down geth prints hundreds of annoying error messages in some
cases. The errors appear because the Stop method of eth.ProtocolManager,
miner.Miner and core.TxPool is asynchronous. Left over peer sessions
generate events which are processed after Stop even though the database
has already been closed.

The fix is to make Stop synchronous using sync.WaitGroup.

For eth.ProtocolManager, in order to make use of WaitGroup safe, we need
a way to stop new peer sessions from being added while waiting on the
WaitGroup. The eth protocol Run function now selects on a signaling
channel and adds to the WaitGroup only if ProtocolManager is not
shutting down.

For miner.worker and core.TxPool the number of goroutines is static,
WaitGroup can be used in the usual way without additional
synchronisation.
2016-05-09 13:03:08 +02:00
Nicholas Johnson
c74a575725 core: Provide a public accessor for ChainConfig
This is necessary for external users of the go-ethereum code who want to, for instance, build a custom node that plays back transactions, as core.ApplyTransaction requires a ChainConfig as a parameter.
2016-04-29 12:42:03 +01:00
Jeffrey Wilcke
c1a4dcfc87 core, eth: added json tag field for proper unmarshalling
According to our own instructions the genesis config attribute should be
"config". The genesis definition in the go code, however, has a field
called `ChainConfig`. This field now has a `json:"config"` struct tag so
that the json is properly unmarshalled.

This fixes #2482
2016-04-25 12:48:31 +02:00
Felix Lange
6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +02:00
Felix Lange
68c755a238 core/state: fix TestDump
Lazy "I'll just put return here instead of fixing the test" found by go vet.
2016-04-15 11:16:56 +02:00
Felix Lange
24cdac41f3 core, core/types, eth: add and use Block.Body
This fixes a few uses of unkeyed Body literals which go vet was
complaining about.
2016-04-15 10:57:37 +02:00
Felix Lange
d04a2e7557 all: update license information 2016-04-15 09:48:05 +02:00
Péter Szilágyi
e9254bb0f9 core, miner: remove Frontier canary 2016-04-04 13:18:34 +03:00
Jeffrey Wilcke
1f3596c25a core: transition db now also returns the required gas amount
Exposes some core methods to transition and compute new state
information and adds an additional return value to the transition db
method to fetch required gas for that particular message (excluding gas
refunds from any SSTORE[X] = 0 and SUICIDE.

Fixes #2395
2016-04-01 01:01:10 +02:00
Jeffrey Wilcke
9055c16efa accounts/a/b/backends, core: chain maker homestead block set to 0
The chain maker and the simulated backend now run with a homestead phase
beginning at block 0 (i.e. there's no frontier).

This commit also fixes up #2388
2016-04-01 01:01:10 +02:00
Jeffrey Wilcke
f0cbebb19f core: added basic chain configuration
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.
2016-04-01 01:01:10 +02:00
Jeffrey Wilcke
0cfa21fc7f core, eth, cmd: temporary work around for enabling the jit
This commit serves as a temporary workaround for enabling the jit until
the block customisation PR is merged in.
2016-03-23 23:02:44 +01:00
Jeffrey Wilcke
14013372ae core: Added EVM configuration options
The EVM is now initialised with an additional configured object that
allows you to turn on debugging options.
2016-03-23 23:02:42 +01:00
Jeffrey Wilcke
342ae7ce7d core, core/vm, tests: changed the initialisation behaviour of the EVM
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.
2016-03-23 00:04:00 +01:00
Péter Szilágyi
2855a93ede Merge pull request #2341 from leijurv/patch-2
core: fixed various typos
2016-03-16 11:22:33 +02:00
Leif Jurvetson
434e4b31d8 core, eth: replace reorganiz with reorganis 2016-03-15 12:03:17 -07:00
Leif Jurvetson
b7bb2d8589 core: various typos 2016-03-15 11:08:18 -07:00
Leif Jurvetson
c7727191ae core: fixed various typos 2016-03-15 09:12:03 -07:00
Jeffrey Wilcke
8a3ce5450a Merge pull request #2311 from obscuren/future-proc-fix
core: added future proc mutex lock
2016-03-11 18:26:57 +01:00
Jeffrey Wilcke
558d18d2b0 core: added future proc mutex lock
Added a future lock which prevents the anything being added or removed
from or to the set when looping over the set of blocks. This fixes a nil
pointer in the range loop when trying to retrieve a block from the set
which was previously available but removed due to regular chain
processing.

Fixes #2305
2016-03-11 09:52:36 +01:00
Péter Szilágyi
daad2b2559 core: cache fresh headers and tds to avoid db trashing 2016-03-10 21:40:34 +02:00
zsfelfoldi
73d21ea6af core: create a header chain structure shared by core.BlockChain and light.LightChain 2016-03-10 14:57:32 +01:00
Jeffrey Wilcke
bff9ceb6b8 Merge pull request #2301 from obscuren/uncle-fix
core: announce ChainSideEvent during reorg
2016-03-10 14:21:41 +01:00
Péter Szilágyi
e90958cd29 cmd, eth, ethdb, node: prioritise chaindata for resources, bump cache 2016-03-09 10:33:39 +02:00
Jeffrey Wilcke
ba3fb9e6f4 core: announce ChainSideEvent during reorg
Previously all blocks that were already in our chain were never re
announced as potential uncle block (e.g. ChainSideEvent). This is
problematic during mining where you want to gather as much possible
uncles as possible increasing the profit. This is now addressed in this
PR where during reorganisations of chains the old chain is regarded as
uncles.

Fixed #2298
2016-03-08 16:12:48 +01:00
Péter Szilágyi
5adc461d58 Merge pull request #2267 from karalabe/pending-state-events
core, miner: add PendingStateEvent to track non-log updates.
2016-03-02 11:24:27 +02:00
Péter Szilágyi
f30b809f00 Merge pull request #2215 from bas-vk/estimategas
core: improved check for contract creation
2016-03-01 10:59:12 +02:00
Péter Szilágyi
b534106cc8 core, miner: add PendingStateEvent to track non-log updates 2016-02-29 11:24:58 +02:00
Jeffrey Wilcke
483feb0d3f Merge pull request #2242 from jimenezrick/upstream-crypto
Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
2016-02-24 12:57:57 +01:00
Péter Szilágyi
3dca9cc550 Merge pull request #2095 from karalabe/trie-node-iterator
core/state, trie: add node iterator, test state/trie sync consistency
2016-02-23 10:26:25 +02:00
Ricardo Catalinas Jiménez
436fc8d76a all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()
As we aren't really using the standarized SHA-3
2016-02-21 22:34:34 +00:00
Jeffrey Wilcke
5b283663b4 core: Added new TD strategy which mitigate the risk for selfish mining
Assuming the following scenario where a miner has 15% of all hashing
power and the ability to exert a moderate control over the network to
the point where if the attacker sees a message A, it can't stop A from
propagating, but what it **can** do is send a message B and ensure that
most nodes see B before A. The attacker can then selfish mine and
augment selfish mining strategy by giving his own blocks an advantage.

This change makes the time at which a block is received less relevant
and so the level of control an attacker has over the network no longer
makes a difference.

This change changes the current td algorithm `B_td > C_td` to the new
algorithm `B_td > C_td || B_td == C_td && rnd < 0.5`.
2016-02-18 10:12:13 +01:00