829 Commits

Author SHA1 Message Date
Felix Lange
8d81eb9999 [release/1.4.18] trie, core/state: improve memory usage and performance (#3135)
* trie: store nodes as pointers

This avoids memory copies when unwrapping node interface values.

name      old time/op  new time/op  delta
Get        388ns ± 8%   215ns ± 2%  -44.56%  (p=0.000 n=15+15)
GetDB      363ns ± 3%   202ns ± 2%  -44.21%  (p=0.000 n=15+15)
UpdateBE  1.57µs ± 2%  1.29µs ± 3%  -17.80%  (p=0.000 n=13+15)
UpdateLE  1.92µs ± 2%  1.61µs ± 2%  -16.25%  (p=0.000 n=14+14)
HashBE    2.16µs ± 6%  2.18µs ± 6%     ~     (p=0.436 n=15+15)
HashLE    7.43µs ± 3%  7.21µs ± 3%   -2.96%  (p=0.000 n=15+13)

* trie: close temporary databases in GetDB benchmark

* trie: don't keep []byte from DB load around

Nodes decoded from a DB load kept hashes and values as sub-slices of
the DB value. This can be a problem because loading from leveldb often
returns []byte with a cap that's larger than necessary, increasing
memory usage.

* trie: unload old cached nodes

* trie, core/state: use cache unloading for account trie

* trie: use explicit private flags (fixes Go 1.5 reflection issue).

* trie: fixup cachegen overflow at request of nick

* core/state: rename journal size constant

(cherry picked from commit 40cdcf1183df235e4b32cfdbf6182a00a0e49f24)
2016-10-14 19:46:36 +03:00
Péter Szilágyi
2425a748ff [release/1.4.18] core: add global (soft) limits on the pending transactions
(cherry picked from commit 182d9cb752ffe08fc5e40718031bc8a497311ff5)
2016-10-14 19:46:33 +03:00
Felix Lange
a79977bc20 [release/1.4.17] core: lower transaction pool max queue limit
(cherry picked from commit 16d8397e30ea0e4d07a07f5c4416b8888daf9796)
2016-10-10 15:53:01 +02:00
Péter Szilágyi
794d2eb582 [release/1.4.17] core: abstract out a sorted transaction hash map
(cherry picked from commit b4a52513915d5a39ac055fc38cafed70098eb698)
2016-10-10 10:50:02 +02:00
Péter Szilágyi
d7721def26 [release/1.4.17] core: add upper bound on the queued transctions
(cherry picked from commit a183ea29f9313cb1d00ed8f73bfbc4ae51e9cb04)
2016-10-10 10:50:02 +02:00
Péter Szilágyi
ddcf02b119 [release/1.4.17] core/types, miner: switch over to the grouped tx sets
(cherry picked from commit affffb39b366321e47784e48c469da9584ceb92c)
2016-10-10 10:49:58 +02:00
Péter Szilágyi
ff697e82dc [release/1.4.17] core, eth, internal, miner: optimize txpool for quick ops
(cherry picked from commit 0ef327bbee79c01a69ba59258acc6ce3a48bc288)
2016-10-10 10:42:07 +02:00
Péter Szilágyi
df64a9f5ef [release/1.4.17] core, eth, miner: only retain 1 tx/nonce, remove bad ones
(cherry picked from commit 795b70423eac7180ab85b735f64aae9d6a10449d)
2016-10-10 10:41:58 +02:00
Felix Lange
18971d9cb4 [release/1.4.16] core/state: optimize GetState
There is no need to use the reflection-based decoder to decode []byte.

(cherry picked from commit 3c836dd71b192de24774b1848173a4eb0ca9a63b)
2016-10-06 16:25:17 +02:00
Felix Lange
74d5251b70 [release/1.4.16] core/state: rename Delete/IsDeleted to Suicide/HasSuicided
The delete/remove naming has caused endless confusion in the past.

(cherry picked from commit 90fce8bfa621f8c3be6663d62740783949111ff1)
2016-10-06 16:25:17 +02:00
Felix Lange
46a527d014 [release/1.4.16] 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!

(cherry picked from commit 1f1ea18b5414bea22332bb4fce53cc95b5c6a07d)
2016-10-06 16:25:17 +02:00
Felix Lange
e97b30169b [release/1.4.16] 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'.

(cherry picked from commit 1b7b2ba2163c7b2b2acc0c4f107951ad873cd8a4)
2016-10-06 16:25:17 +02:00
Péter Szilágyi
945bcb8293 [release/1.4.15] core/state: track dirty state entries for each object
(cherry picked from commit b7159818f9eb102ac842199fd5af0efca7bdd6b0)
2016-10-03 11:24:07 +03:00
Péter Szilágyi
f1949f4d99 [release/1.4.15] cmd, core, internal, light, tests: avoid hashing the code in the VM
(cherry picked from commit cb84e3f02953f2df166ae69369d222dcbbd7d78d)
2016-10-03 11:24:04 +03:00
Péter Szilágyi
f50c2a5c70 [release/1.4.14] core, eth, trie: reuse trie journals in all our code
(cherry picked from commit 710435b51b97b4c688b70bda35ab9d1aa704a988)
2016-09-28 13:32:12 +03:00
Felix Lange
ddadf402fc [release/1.4.14] core, trie: replace state caches with trie journal
(cherry picked from commit cd791bd855b55b95afc8a5c8f56b8bf67863d099)
2016-09-28 13:32:10 +03:00
Felix Lange
dc2b23c869 [release/1.4.13] 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.

(cherry picked from commit a59a93f476434f2805c8fd3e10bf1b2f579b078f)
2016-09-26 10:31:18 +02:00
Gustav Simonsson
42e4e18667 [release 1.4.12] core: short-circuit balance change if zero value
(cherry picked from commit 25ed5feddadea8201974bfacb2a57d060b697acb)
2016-09-26 08:49:59 +03:00
Nick Johnson
e44b2dc881 [release 1.4.12] core/state: Fix memory expansion bug by not copying clean objects
(cherry picked from commit 581b320b9dfb42c0c4842e0bc5aeb507267a8eba)
2016-09-19 04:23:36 +03:00
Bas van Kervel
c4ed34f008 [release/1.4.11] core: ensure the canonical block is written before the canonical hash is set
(cherry picked from commit bb8059f6aa86d1052d7c2dd75a6985982cb278f4)

Conflicts:
	core/blockchain.go
	core/database_util.go
	core/headerchain.go
	eth/filters/filter.go
2016-08-18 15:25:16 +02:00
Felix Lange
d1696dbf07 [release/1.4.11] core/vm: hide ecrecover error message
Fixes #2825

(cherry picked from commit e4736fe46938008b7fa88879f728fa81c6ce09e8)
2016-08-18 15:01:23 +02:00
Péter Szilágyi
1b2941cd56 [release/1.4.10] cmd, core, eth, miner, params, tests: finalize the DAO fork
(cherry picked from commit 2c2e389b778b490fcaf14d9cc45a750647ca5c68)
2016-07-16 14:30:07 +03:00
Péter Szilágyi
b8c0883770 [release/1.4.10] accounts, core, eth: pass chain config for chain maker to test DAO
(cherry picked from commit 3291235711082759cd7b70253c02150a80d57011)
2016-07-16 14:30:05 +03:00
Péter Szilágyi
14bad7e212 [release/1.4.10] core, params, tests: add DAO hard-fork balance moves
(cherry picked from commit 461cdb593b9e5bd9ae9ac35c68809a3a29290dcb)
2016-07-16 14:30:03 +03:00
Péter Szilágyi
8c20fe17bd [release/1.4.10] core, eth: enforce network split post DAO hard-fork
(cherry picked from commit 7f00e8c0331bf13739e749bab88bf9006ca02f96)
2016-07-16 14:30:00 +03:00
Péter Szilágyi
a0cc73a27a [release/1.4.10] cmd, core, miner: add extradata validation to consensus rules
(cherry picked from commit a87089fd2dc08a69a4a4f1ef93db9a2871d819a3)
2016-07-16 14:29:59 +03:00
Péter Szilágyi
5c3051e6fa [release/1.4.10] core: gracefully handle missing homestead block config
(cherry picked from commit 9e56811a3773e225bedf6bf0003327ea1aaae040)
2016-07-16 14:29:54 +03:00
Péter Szilágyi
3dd46bc884 [release/1.4.10] cmd, core, eth, params: implement flags to control dao fork blocks
(cherry picked from commit 6060e098c929792f455d7f580ed91e914d28cf3b)
2016-07-16 14:29:52 +03:00
Péter Szilágyi
da776556d0 [release/1.4.10] core: solve a remote-import/local-mine data race
(cherry picked from commit f5a29eab5ce6ada8fef2378b96384cc81586b6ce)
2016-07-16 14:29:41 +03:00
Péter Szilágyi
adb065a328 [release/1.4.9] Revert "test, cmd/evm, core, core/vm: illegal code hash implementation"
This reverts commit a9c94cbf48fefe39104ee3495df139ff374dd219.
2016-06-29 11:53:41 +03:00
Péter Szilágyi
c793cb3385 [release/1.4.9] Revert "core: add voting and result tracking for the dao soft-fork"
This reverts commit f31a3a251afad1d4c7169bc530fe60471df36122.
2016-06-29 11:53:23 +03:00
Péter Szilágyi
3eef19598e [release/1.4.9] Revert "core: update DAO soft-fork number, clean up the code"
This reverts commit aefffc9ed8ca60ebe58e06066b30f1283493f488.
2016-06-29 11:53:06 +03:00
Péter Szilágyi
f4aebd4c8d [release/1.4.9] Revert "core: update the DAO soft fork proposal to the final block"
This reverts commit b170a80cdcb380765c711017588b2d148eb1601e.
2016-06-29 11:52:05 +03:00
Péter Szilágyi
b170a80cdc [release/1.4.8] core: update the DAO soft fork proposal to the final block
(cherry picked from commit 1e3a7d4fab36df9382d023519ef10e3c34bafa3b)
2016-06-24 16:20:36 +03:00
Péter Szilágyi
aefffc9ed8 [release/1.4.8] core: update DAO soft-fork number, clean up the code
(cherry picked from commit ba784bdf36f2daf7827ec1ec864f3393ba8d86a0)
2016-06-24 13:18:31 +03:00
Péter Szilágyi
f31a3a251a [release/1.4.8] core: add voting and result tracking for the dao soft-fork
(cherry picked from commit c4de28938ff8c688c4444c8b3e8e28a52cbc62ff)
2016-06-24 13:18:28 +03:00
Jeffrey Wilcke
a9c94cbf48 [release/1.4.8] 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.

(cherry picked from commit 7a5b571c671e70e0e4807cf971c15e2d1e09d33d)
2016-06-24 13:18:25 +03:00
Jeffrey Wilcke
f7fdfa4eac [release/1.4.7] 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

(cherry picked from commit bb3651abc865c6f6babec0d357afa85f5a539d83)
2016-06-14 17:12:05 +03:00
Felix Lange
44b912ec64 [release/1.4.6] core: add missing lock in TxPool.{GetTransaction,RemoveTx}
Fixes #2650

(cherry picked from commit fc85dd175ebeef4996e5d370a7a2f085c922196d)
2016-06-06 16:22:00 +03:00
Péter Szilágyi
af53767e16 [release/1.4.6] core, core/state, trie: enterprise hand-tuned multi-level caching
(cherry picked from commit 748d1c171d74fbf6b6051fd629d3c2204dd930e3)
2016-06-06 16:21:39 +03:00
Péter Szilágyi
7632acf6b4 [release/1.4.6] core/state: return the starting nonce for non-existent accs (testnet)
(cherry picked from commit 8ee84584a407464511b453eebaa31854979aa593)
2016-06-06 16:21:37 +03:00
Felix Lange
9ccb70da7b [release/1.4.6] 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.

(cherry picked from commit ca18202eb9a94de1d4b51c1572fa74edfa2773bf)
2016-06-06 16:21:34 +03:00
Fabio Berger
8d2775e3d7 [release/1.4.6] core: Simplify bloom9 tests with available convenience method TestBytes
(cherry picked from commit faf663133b7d784406a6bfc029404b2718abc66d)
2016-06-06 16:21:07 +03:00
Jeffrey Wilcke
aa18aad7ad [release/1.4.4] 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-12 17:31:57 +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