Commit Graph

258 Commits

Author SHA1 Message Date
Péter Szilágyi
e14f8a408c
Merge pull request #19328 from karalabe/preload
core: prefetch next block state concurrently
2019-04-02 17:03:12 +03:00
Runchao Han
c4109d790f core: fix typo in insertChain method doc (#19371) 2019-04-02 13:01:02 +03:00
Péter Szilágyi
ed34a5e08a
cmd, core, eth: support disabling the concurrent state prefetcher 2019-04-01 11:52:11 +03:00
Péter Szilágyi
bb9631c399
core: prefetch next block state concurrently 2019-04-01 11:06:15 +03:00
Brent
7fb89697fd core/types: add block location fields to receipt (#17662)
Solves #15210 without changing consensus, in a backwards compatible way,
by adding tx inclusion information to the Receipt struct.
2019-03-27 13:39:25 +01:00
Péter Szilágyi
a732c93309
core: 3rd try on splitting the trie metrics correctly 2019-03-27 13:02:04 +02:00
Martin Holst Swende
59e1953246 core, ethdb, trie: mode dirty data to clean cache on flush (#19307)
This PR is a more advanced form of the dirty-to-clean cacher (#18995),
where we reuse previous database write batches as datasets to uncache,
saving a dirty-trie-iteration and a dirty-trie-rlp-reencoding per block.
2019-03-26 15:48:31 +01:00
Péter Szilágyi
435020f9b3
core: split trie op metrics from the correct chain metrics 2019-03-25 16:27:46 +02:00
Péter Szilágyi
86989e3fcd
core: split out detailed trie access metrics from insertion time (#19316)
* core: split out detailed trie access metrics from insertion time

* cmd, core, metrics: support expensive optional metrics
2019-03-25 10:01:18 +02:00
Péter Szilágyi
91eec1251c
cmd, core, eth, trie: get rid of trie cache generations (#19262)
* cmd, core, eth, trie: get rid of trie cache generations

* core, trie: get rid of remainder of cache gen boilerplate
2019-03-14 15:25:12 +02:00
Péter Szilágyi
4f457859a2
core: use headers only where blocks are unnecessary 2019-03-13 12:32:47 +02:00
Péter Szilágyi
054412e335
all: clean up and proerly abstract database access 2019-03-06 13:35:03 +02:00
Felföldi Zsolt
c2003ed63b les, les/flowcontrol: improved request serving and flow control (#18230)
This change

- implements concurrent LES request serving even for a single peer.
- replaces the request cost estimation method with a cost table based on
  benchmarks which gives much more consistent results. Until now the
  allowed number of light peers was just a guess which probably contributed
  a lot to the fluctuating quality of available service. Everything related
  to request cost is implemented in a single object, the 'cost tracker'. It
  uses a fixed cost table with a global 'correction factor'. Benchmark code
  is included and can be run at any time to adapt costs to low-level
  implementation changes.
- reimplements flowcontrol.ClientManager in a cleaner and more efficient
  way, with added capabilities: There is now control over bandwidth, which
  allows using the flow control parameters for client prioritization.
  Target utilization over 100 percent is now supported to model concurrent
  request processing. Total serving bandwidth is reduced during block
  processing to prevent database contention.
- implements an RPC API for the LES servers allowing server operators to
  assign priority bandwidth to certain clients and change prioritized
  status even while the client is connected. The new API is meant for
  cases where server operators charge for LES using an off-protocol mechanism.
- adds a unit test for the new client manager.
- adds an end-to-end test using the network simulator that tests bandwidth
  control functions through the new API.
2019-02-26 12:32:48 +01:00
gary rong
7fd0ccaa68 core: remove unnecessary fields in logs, receipts and tx lookups (#17106)
* core: remove unnecessary fields in log

* core: bump blockchain database version

* core, les: remove unnecessary fields in txlookup

* eth: print db version explicitly

* core/rawdb: drop txlookup entry struct wrapper
2019-02-21 15:14:35 +02:00
Martin Holst Swende
8577b5b020 core: more tests for sidechain import, fixes #19105 (#19113)
* blockchain: more tests for sidechain import, fixes #19105

* core/blockchain: rework import of pruned canon blocks and canon-prepended sidechains

* core/blockchain: minor clarity change

* core/blockchain: remove unused method
2019-02-21 12:36:49 +02:00
Matthew Halpern
bf42535d31 core: remove redundant parentheses (#19106) 2019-02-19 13:25:42 +02:00
Péter Szilágyi
940e317094
core: fix pruner panic when importing low-diff-large-sidechain 2019-02-08 11:56:25 +02:00
Péter Szilágyi
d6225ab846
cmd/utils, eth: relinquish GC cache to read cache in archive mode 2019-02-07 14:36:25 +02:00
Martin Holst Swende
ec3432bccb
core: fix error in block iterator (#18986) 2019-02-04 13:30:19 +01:00
silence
66f0c464cc core: only cache non-nil receipts from the database (#18447)
receipts may be null for very short time in some condition. For this case, we should not add the null value into cache. Because you will not get the right result if you keep requesting that receipt.
2019-01-17 17:49:12 +02:00
Péter Szilágyi
f25f776c9f
core, light: get rid of the dual mutexes, hard to reason with 2019-01-11 15:27:47 +02:00
gary rong
d5cad488be core, eth: fix database version (#18429)
* core, eth: fix database version

* eth: polish error message
2019-01-11 13:49:12 +02:00
Paweł Bylica
de39513ced core, internal, eth, miner, les: Take VM config from BlockChain (#17955)
Until this commit, when sending an RPC request that called `NewEVM`, a blank `vm.Config`
would be taken so as to set some options, based on the default configuration. If some extra
configuration switches were passed to the blockchain, those would be ignored.

This PR adds a function to get the config from the blockchain, and this is what is now used
for RPC calls.

Some subsequent changes need to be made, see https://github.com/ethereum/go-ethereum/pull/17955#pullrequestreview-182237244
for the details of the discussion.
2018-12-06 14:34:49 +01:00
Martin Holst Swende
bfed28a421 core: more detailed metrics for block processing (#18119) 2018-11-28 10:29:05 +02:00
mr_franklin
2a113f6d72 core: return error if repair block failed (#18126)
* core: return error if repair block failed

* make error a bit shorter
2018-11-23 11:16:14 +02:00
Péter Szilágyi
3ba0418a9a
Merge pull request #17973 from holiman/splitter2
core: better side-chain importing
2018-11-22 15:01:10 +02:00
Martin Holst Swende
e0d091e090 core: better printout of receipts in bad block reports (#18156)
* core/blockchain: better printout of receipts in bad block reports

* fix splleing
2018-11-22 11:00:16 +02:00
Péter Szilágyi
333b5fb123
core: polish side chain importer a bit 2018-11-21 13:19:56 +02:00
Martin Holst Swende
493903eede
core: better side-chain importing 2018-11-20 12:28:43 +02:00
Péter Szilágyi
accc0fab4f
core, eth/downloader: fix ancestor lookup for fast sync 2018-11-16 13:21:20 +02:00
Péter Szilágyi
434dd5bc00
cmd, core, eth, light, trie: add trie read caching layer 2018-11-15 12:22:13 +02:00
gary rong
1212c7b844 core: fix default trie cache limit (#17860) 2018-11-12 18:06:34 +02:00
Corey Lin
1ff152f3a4 rawdb: remove unused parameter for WritePreimages func (#18059)
* rawdb: remove unused parameter for WritePreimages func and modify a
spelling mistake

* rawdb: update the doc for function WritePreimages
2018-11-09 12:51:07 +02:00
Ryan Schneider
b69942befe core, internal/ethapi: add and use LRU cache for receipts (#17610) 2018-09-29 22:53:31 +02:00
gary rong
ba0a8b7887 core, eth: fix dependency cycle (#17720) 2018-09-20 20:02:15 +03:00
gary rong
d6254f827b all: protect self-mined block during reorg (#17656) 2018-09-20 15:09:30 +03:00
Péter Szilágyi
0f2ba07c41
common, core, light: add block age into info logs 2018-09-20 12:56:35 +03:00
Wenbiao Zheng
6a33954731 core, eth, trie: use common/prque (#17508) 2018-09-03 17:33:21 +02:00
gary rong
a1783d1697 miner: move agent logic to worker (#17351)
* miner: move agent logic to worker

* miner: polish

* core: persist block before reorg
2018-08-14 18:34:33 +03:00
Ha ĐANG
2cffd4ff3c core: fix some small typos on comment code (#17278) 2018-07-30 14:10:48 +03:00
Raghav Sood
11a402f747 core: report progress on log chain exports (#17066)
* core/blockchain: export progress

* core: polish up chain export progress report a bit
2018-07-26 14:26:24 +03:00
gary rong
a4a2343cdc ethdb, core: implement delete for db batch (#17101) 2018-07-02 11:16:30 +03:00
Péter Szilágyi
d926bf2c7e trie: cache collapsed tries node, not rlp blobs (#16876)
The current trie memory database/cache that we do pruning on stores
trie nodes as binary rlp encoded blobs, and also stores the node
relationships/references for GC purposes. However, most of the trie
nodes (everything apart from a value node) is in essence just a
collection of references.

This PR switches out the RLP encoded trie blobs with the
collapsed-but-not-serialized trie nodes. This permits most of the
references to be recovered from within the node data structure,
avoiding the need to track them a second time (expensive memory wise).
2018-06-21 11:28:05 +02:00
Felföldi Zsolt
049f5b3572 core, eth, les: more efficient hash-based header chain retrieval (#16946) 2018-06-12 16:52:54 +03:00
Martin Holst Swende
eac16f9824 core: improve getBadBlocks to return full block rlp (#16902)
* core: improve getBadBlocks to return full block rlp

* core, eth, ethapi: changes to getBadBlocks formatting

* ethapi: address review concerns
2018-06-11 11:03:40 +03:00
Péter Szilágyi
2ab24a2a8f
core: concurrent background transaction sender ecrecover 2018-06-05 11:03:55 +03:00
Péter Szilágyi
143c4341d8
core, eth, trie: streaming GC for the trie cache (#16810)
* core, eth, trie: streaming GC for the trie cache

* trie: track memcache statistics
2018-06-04 10:47:43 +03:00
Péter Szilágyi
6cf0ab38bd
core/rawdb: separate raw database access to own package (#16666) 2018-05-07 14:35:06 +03:00
Kyuntae Ethan Kim
63687f04e4 core: check transaction/receipt count match when reconstructing blocks (#16272) 2018-03-07 12:05:14 +02:00
Martin Holst Swende
f83237573f core: make current*Block atomic, and accessor functions mutex-free (#16171)
* core: make current*Block atomic, and accessor functions mutex-free

* core: fix review concerns

* core: fix error in atomic assignment

* core/light: implement atomic getter/setter for headerchain
2018-02-26 11:53:10 +02:00
Péter Szilágyi
89f914c030
core: flush out trie cache more meaningfully on stop (#16143)
* core: flush out trie cache more meaningfully on stop

* core: upgrade legacy tests to chain maker
2018-02-23 14:02:33 +02:00
Anton Evangelatov
ae9f97221a metrics: pull library and introduce ResettingTimer and InfluxDB reporter (#15910)
* go-metrics: fork library and introduce ResettingTimer and InfluxDB reporter.

* vendor: change nonsense/go-metrics to ethersphere/go-metrics

* go-metrics: add tests. move ResettingTimer logic from reporter to type.

* all, metrics: pull in metrics package in go-ethereum

* metrics/test: make sure metrics are enabled for tests

* metrics: apply gosimple rules

* metrics/exp, internal/debug: init expvar endpoint when starting pprof server

* internal/debug: tiny comment formatting fix
2018-02-23 11:56:08 +02:00
Felix Lange
b007412db1 core: soften up state memory force-commit log messages (#16080)
Talk about "state" instead of "trie timing", "trie memory" and remove
the overzealous warning when the limit is just reached. Since the time
limit is always reached on slow machines, move the message to info level
so users don't freak out about internal details.
2018-02-13 15:12:55 +02:00
Péter Szilágyi
69c1f2c2a7
core: force import known but rolled back blocks 2018-02-12 11:54:14 +02:00
Péter Szilágyi
55599ee95d core, trie: intermediate mempool between trie and database (#15857)
This commit reduces database I/O by not writing every state trie to disk.
2018-02-05 17:40:32 +01:00
Péter Szilágyi
fdb34b7a7c
Merge pull request #15996 from karalabe/drop-redundant-methods
core, eth, les, light: get rid of redundant methods
2018-01-31 12:46:38 +02:00
Martin Holst Swende
017b9f7eac core, ethdb: reuse database batches (#15989)
* leveldb: Update leveldb to 211f780 (poolfix)

* core, ethdb: reuse database batches
2018-01-30 19:03:31 +02:00
Péter Szilágyi
566d5c0777
core, eth, les, light: get rid of redundant methods 2018-01-30 18:42:00 +02:00
Péter Szilágyi
84be009154
core: sorted reorg insertion order for proper head header updating 2018-01-22 14:11:07 +02:00
Péter Szilágyi
6f69cdd109
all: switch gas limits from big.Int to uint64 2018-01-03 14:45:35 +02:00
ferhat elmas
5866626b08 core, p2p/discv5: use time.NewTicker instead of time.Tick (#15747) 2018-01-02 12:50:46 +01:00
Péter Szilágyi
54ce3887d8
core: split same-td blocks on block height 2017-11-13 17:07:05 +02:00
Péter Szilágyi
629b5837e9 core: revert invalid block dedup code (#15235) 2017-10-03 18:59:53 +02:00
Péter Szilágyi
10b3f97c9d core: only fire one chain head per batch (#15123)
* core: only fire one chain head per batch

* miner: announce chan events synchronously
2017-09-11 13:13:05 +03:00
Felix Lange
10181b57a9 core, eth/downloader: commit block data using batches (#15115)
* ethdb: add Putter interface and Has method

* ethdb: improve docs and add IdealBatchSize

* ethdb: remove memory batch lock

Batches are not safe for concurrent use.

* core: use ethdb.Putter for Write* functions

This covers the easy cases.

* core/state: simplify StateSync

* trie: optimize local node check

* ethdb: add ValueSize to Batch

* core: optimize HasHeader check

This avoids one random database read get the block number. For many uses
of HasHeader, the expectation is that it's actually there. Using Has
avoids a load + decode of the value.

* core: write fast sync block data in batches

Collect writes into batches up to the ideal size instead of issuing many
small, concurrent writes.

* eth/downloader: commit larger state batches

Collect nodes into a batch up to the ideal size instead of committing
whenever a node is received.

* core: optimize HasBlock check

This avoids a random database read to get the number.

* core: use numberCache in HasHeader

numberCache has higher capacity, increasing the odds of finding the
header without a database lookup.

* core: write imported block data using a batch

Restore batch writes of state and add blocks, tx entries, receipts to
the same batch. The change also simplifies the miner.

This commit also removes posting of logs when a forked block is imported.

* core: fix DB write error handling

* ethdb: use RLock for Has

* core: fix HasBlock comment
2017-09-09 19:03:07 +03:00
Zsolt Felfoldi
4ea4d2dc34
core, eth: add bloombit indexer, filter based on it 2017-09-06 11:13:13 +03:00
Péter Szilágyi
da7d57e07c
core: make txpool operate on immutable state 2017-09-05 13:34:41 +03:00
Miya Chen
bf1e263128 core, light: send chain events using event.Feed (#14865) 2017-08-18 12:58:36 +02:00
Mark
4f9789b28d core: avoid write existing block again (#14849) 2017-07-31 11:59:07 +02:00
Péter Szilágyi
0ff35e170d core: remove redundant storage of transactions and receipts (#14801)
* core: remove redundant storage of transactions and receipts

* core, eth, internal: new transaction schema usage polishes

* eth: implement upgrade mechanism for db deduplication

* core, eth: drop old sequential key db upgrader

* eth: close last iterator on successful db upgrage

* core: prefix the lookup entries to make their purpose clearer
2017-07-14 19:39:53 +03:00
Martin Holst Swende
8bbd598ef4 core: fix an off-by-one when the block import counts blocks 2017-06-29 14:19:10 +02:00
Felix Lange
9e5f03b6c4 core/state: access trie through Database interface, track errors (#14589)
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).
2017-06-27 15:57:06 +02:00
Péter Szilágyi
c98bce709c
core: fix minor accidental typos and comment errors 2017-05-25 17:22:45 +03:00
changhong
17f0b11942
core: typos and comments improve
1. fix typos
2. methods recevier of struct should be same
3. comments improve

(cherry picked from commit 1ba979539582a00b7fd1a7c8a37a6852e59eac0d)
2017-05-25 17:14:33 +03:00
Péter Szilágyi
60293820b7
core: fix processing regression during receipt import 2017-05-08 12:09:35 +03:00
Felix Lange
7b2fc0643f core, light: delete SplitStatTy, ChainSplitEvent (unused) 2017-04-21 18:56:00 +02:00
Péter Szilágyi
a7b9e484d0 consensus, core, ethstats: use engine specific block beneficiary (#14318)
* consensus, core, ethstats: use engine specific block beneficiary

* core, eth, les, miner: use explicit beneficiary during mining
2017-04-12 16:38:31 +03:00
Justin
542e42b21e core: fix comment typo 2017-04-10 16:01:31 +03:00
Péter Szilágyi
158d603528
consensus, core: drop all the legacy custom core error types 2017-04-06 17:34:19 +03:00
Péter Szilágyi
09777952ee core, consensus: pluggable consensus engines (#3817)
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.
2017-04-05 00:16:29 +02:00
Felföldi Zsolt
525116dbff les: implement request distributor, fix blocking issues (#3660)
* les: implement request distributor, fix blocking issues
* core: moved header validation before chain mutex lock
2017-03-22 20:44:22 +01:00
Péter Szilágyi
9b84caf3a5 core, eth, les: support resuming fast sync on heavy rollback (#3743) 2017-03-22 01:37:24 +01:00
Péter Szilágyi
567d41d936 all: swap out the C++ ethash to the pure Go one (mining todo) 2017-03-09 15:50:14 +01:00
Péter Szilágyi
07c216d603 Merge pull request #3739 from karalabe/logger-updates-4
all: update light logs (and a few others) to the new model
2017-03-03 18:53:30 +02:00
Péter Szilágyi
e7030c4bf5
all: update light logs (and a few others) to the new model 2017-03-03 11:41:52 +02:00
Péter Szilágyi
a38e1a9c00
core: reorg logs crashed, add a check for corner cases 2017-03-03 09:54:13 +02:00
Péter Szilágyi
e02883c0a2
core, log: track field length and pad to align 2017-02-28 15:36:51 +02:00
Péter Szilágyi
e588e0ca2b
all: next batch of log polishes to contextual versions 2017-02-28 15:03:20 +02:00
Péter Szilágyi
d4fd06c3dc
all: blidly swap out glog to our log15, logs need rework 2017-02-23 12:16:44 +02:00
Jeffrey Wilcke
024d41d0c2 core, core/state, core/vm: remove exported account getters (#3618)
Removed exported statedb object accessors, reducing the chance for nasty
bugs to creep in. It's also ugly and unnecessary to have these methods.
2017-02-22 23:29:59 +01:00
Martin Holst Swende
b19e5885fe core/blockchain: Change iterator in procFutureBlocks to use lru.Peek instead of Get (#3655) 2017-02-18 09:27:21 +01:00
Martin Holst Swende
72dcd3c58b core, eth, internal: Added debug_getBadBlocks() method (#3654)
* core,eth,internal: Added `debug_getBadBlocks()` method

When bad blocks are discovered, these are stored within geth.
An RPC-endpoint makes them availablewithin the `debug`
namespace. This feature makes it easier to discover network forks.

```

* core, api: go format + docs

* core/blockchain: Documentation, fix minor nitpick

* core: fix failing blockchain test
2017-02-13 21:44:06 +01:00
Vivek Anand
82aa5b1de6 core: fix a small typo in blockchain.go (#3611) 2017-01-26 16:54:49 +02:00
Martin Holst Swende
6fb76443b3 core/blockchain: Made logging of reorgs more structured (#3573)
* core: Made logging of reorgs more structured, also always log if reorg is > 63 blocks long

* core/blockchain: go fmt

* core/blockchain: Minor fixes to the reorg reporting
2017-01-17 14:10:26 +02:00
Nick Johnson
17d92233d9 cmd/geth, core: add support for recording SHA3 preimages (#3543) 2017-01-17 12:19:50 +01:00
Felix Lange
21f1370d2a core: improve import log alignment 2017-01-10 23:14:08 +01:00
Felix Lange
b9b3efb09f all: fix ineffectual assignments and remove uses of crypto.Sha3
go get github.com/gordonklaus/ineffassign
ineffassign .
2017-01-09 16:24:42 +01:00
Felix Lange
13e3b2f433 logger, pow/dagger, pow/ezp: delete dead code 2017-01-06 18:18:07 +01:00
Felix Lange
f2da6581ba all: fix issues reported by honnef.co/go/simple/cmd/gosimple 2017-01-06 18:18:07 +01:00
Felix Lange
35a7dcb162 all: gofmt -w -s 2017-01-06 15:52:03 +01:00
Felix Lange
7731061903 core/vm: move Log to core/types
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.
2017-01-06 14:15:22 +01:00
Péter Szilágyi
a59fcc33e6
core: import future blocks one-by-one, enfore chain ancestry 2016-12-13 16:19:45 +02:00
Felix Lange
f52a1ae849 core, core/vm, eth/filters: move Removed field into vm.Log
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.
2016-12-05 10:57:11 +01:00
Jeffrey Wilcke
801a13f791 core: fixed unwinding bad hash (#3347)
Fixed unwinding of bad hashes when already on the canon chain
2016-11-28 10:37:42 +01:00
Jeffrey Wilcke
c04c8f10f0 core: improved bad block error reporting (#3320) 2016-11-23 13:32:25 +01:00
Jeffrey Wilcke
4dca5d4db7 core/types, params: EIP#155 2016-11-13 14:55:30 +01:00
Jeffrey Wilcke
445feaeef5 core, core/state, trie: EIP158, reprice & skip empty account write
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>
2016-11-13 10:44:04 +01:00
Zsolt Felfoldi
760fd65487 light: light chain, VM env and tx pool 2016-11-09 02:12:53 +01:00
Péter Szilágyi
1291778032
cmd/geth, code, eth/downloader: tune import logs and mem stats 2016-10-21 12:23:39 +03:00
Jeffrey Wilcke
5b262ff5ab Merge pull request #3156 from holiman/metrics-blocks
core: Add block processing time metric collection
2016-10-18 13:26:31 +02:00
Péter Szilágyi
64500ab0fa
common, core, eth/downloader: adjust import log formatting 2016-10-18 13:16:36 +03:00
Martin Holst Swende
00b853418e core: Add block processing time metric collection 2016-10-18 09:29:50 +02:00
Felix Lange
40cdcf1183 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
2016-10-14 19:04:33 +03:00
Jeffrey Wilcke
ca419f3cd8 core: fixed import reporter 2016-10-11 00:16:08 +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
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
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
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
Péter Szilágyi
f5a29eab5c core: solve a remote-import/local-mine data race 2016-07-08 16:59:19 +03:00
zsfelfoldi
f9917c8c7b core: improved chainDb using sequential keys 2016-06-07 16:38:56 +02: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
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
Felix Lange
6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +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
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
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
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
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
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
Jeffrey Wilcke
987c1a595a eth/filters: pending logs
Pending logs are now filterable through the Go API. Filter API changed
such that each filter type has it's own bucket and adding filter
explicitly requires you specify the bucket to put it in.
2016-02-13 13:14:02 +01:00
Péter Szilágyi
9e011ff1cd core, eth/downloader: ensure state presence in ancestor lookup 2016-01-04 16:27:23 +02:00
Péter Szilágyi
1cecda8333 core: write individual transactions and receipts too on fast sync 2015-12-04 15:30:59 +02:00
Jeffrey Wilcke
9901a40f04 core: added a new RemovedLogEvent
When a chain reorganisation occurs we collect the logs that were deleted
during the chain reorganisation. The removed logs are posted to the
event mux indicating that those were deleted during the reorg.
2015-12-01 12:12:30 +01:00
Péter Szilágyi
1e806c4c77 cmd, common, core, eth, node, rpc, tests, whisper, xeth: use protocol stacks 2015-11-27 11:06:12 +02:00
Péter Szilágyi
e86e0ecdc8 core, eth, miner, xeth: clean up tx/receipt db accessors 2015-11-19 16:03:32 +02:00
Jeffrey Wilcke
a1d9ef48c5 core, eth, rpc: split out block validator and state processor
This removes the burden on a single object to take care of all
validation and state processing. Now instead the validation is done by
the `core.BlockValidator` (`types.Validator`) that takes care of both
header and uncle validation through the `ValidateBlock` method and state
validation through the `ValidateState` method. The state processing is
done by a new object `core.StateProcessor` (`types.Processor`) and
accepts a new state as input and uses that to process the given block's
transactions (and uncles for rewords) to calculate the state root for
the next block (P_n + 1).
2015-11-18 14:24:42 +01:00
Péter Szilágyi
667987e7d0 core: only reset head header/fastblock if stale 2015-10-28 17:40:24 +02:00
Péter Szilágyi
5b0ee8ec30 core, eth, trie: fix data races and merge/review issues 2015-10-21 16:49:55 +03:00
Péter Szilágyi
a9d8dfc8e7 core, eth: roll back uncertain headers in failed fast syncs 2015-10-19 10:03:10 +03:00
Péter Szilágyi
b97e34a8e4 eth/downloader: concurrent receipt and state processing 2015-10-19 10:03:10 +03:00
Péter Szilágyi
ab27bee25a core, eth, trie: direct state trie synchronization 2015-10-19 10:03:09 +03:00
Péter Szilágyi
832b37c822 core, eth: receipt chain reconstruction 2015-10-19 10:03:09 +03:00