Commit Graph

374 Commits

Author SHA1 Message Date
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
Peter Fox 159d813f35 Transaction signer mismatch fix (#463)
Always use the EIP155 signer for verifying new transactions being added
to the transaction pool and only skip protected public transactions from replay attacks until
we reach EIP155 activation.
2018-08-08 21:30:53 -04:00
amalraj.manigmail.com 95a1b03c3e merge 1.8.12 with upstream/master to apply the fixes/changes added newly 2018-08-06 19:03:51 +08:00
amalraj.manigmail.com e6773756fb merge 1.8.12 with upstream/master to apply the fixes/changes added newly 2018-08-06 19:03:51 +08:00
gary rong 941018b570 miner: seperate state, receipts for different mining work (#17323) 2018-08-06 12:55:44 +03:00
gary rong 51db5975cc consensus/ethash: move remote agent logic to ethash internal (#15853)
* consensus/ethash: start remote ggoroutine to handle remote mining

* consensus/ethash: expose remote miner api

* consensus/ethash: expose submitHashrate api

* miner, ethash: push empty block to sealer without waiting execution

* consensus, internal: add getHashrate API for ethash

* consensus: add three method for consensus interface

* miner: expose consensus engine running status to miner

* eth, miner: specify etherbase when miner created

* miner: commit new work when consensus engine is started

* consensus, miner: fix some logics

* all: delete useless interfaces

* consensus: polish a bit
2018-08-03 11:33:37 +03:00
Peter Fox 228a7d93d6 Istanbul events not firing & logs not showing on some nodes (#460)
* keep merging of public and private receipts inline with other processing flows
* added private state prepare in commitTransaction for missed private events
2018-08-01 10:06:47 -04:00
ledgerwatch 2fbc454355 miner: fix state locking while writing to chain (issue #16933) (#17173) 2018-07-31 10:22:33 +03:00
amalraj.manigmail.com f97be18238 miner: restore Handle ChainHeadEvent change specific to quorum from previous quorum version 2018-07-26 18:50:10 +08:00
amalraj.manigmail.com c3c479d2aa Merge remote-tracking branch 'remotes/geth/release/1.8' into merge-193
# Conflicts:
#	.github/CODEOWNERS
#	.travis.yml
#	README.md
#	VERSION
#	accounts/abi/argument.go
#	accounts/abi/bind/backends/simulated.go
#	accounts/abi/bind/bind_test.go
#	accounts/abi/event_test.go
#	accounts/abi/numbers.go
#	accounts/abi/numbers_test.go
#	accounts/abi/reflect.go
#	accounts/accounts.go
#	accounts/keystore/keystore.go
#	accounts/keystore/keystore_wallet.go
#	accounts/usbwallet/internal/trezor/trezor.go
#	accounts/usbwallet/ledger.go
#	accounts/usbwallet/wallet.go
#	appveyor.yml
#	build/ci.go
#	build/goimports.sh
#	cmd/ethkey/generate.go
#	cmd/ethkey/inspect.go
#	cmd/ethkey/main.go
#	cmd/ethkey/message.go
#	cmd/ethkey/utils.go
#	cmd/faucet/faucet.go
#	cmd/geth/chaincmd.go
#	cmd/geth/config.go
#	cmd/geth/main.go
#	cmd/geth/misccmd.go
#	cmd/geth/usage.go
#	cmd/p2psim/main.go
#	cmd/puppeth/genesis.go
#	cmd/puppeth/module_dashboard.go
#	cmd/puppeth/wizard_faucet.go
#	cmd/puppeth/wizard_genesis.go
#	cmd/puppeth/wizard_netstats.go
#	cmd/puppeth/wizard_node.go
#	cmd/puppeth/wizard_wallet.go
#	cmd/swarm/config.go
#	cmd/swarm/config_test.go
#	cmd/swarm/db.go
#	cmd/swarm/hash.go
#	cmd/swarm/main.go
#	cmd/swarm/manifest.go
#	cmd/swarm/run_test.go
#	cmd/swarm/upload.go
#	cmd/swarm/upload_test.go
#	cmd/utils/flags.go
#	cmd/wnode/main.go
#	common/bytes.go
#	common/compiler/solidity.go
#	common/hexutil/hexutil.go
#	common/math/big.go
#	common/math/integer.go
#	common/mclock/mclock.go
#	common/types.go
#	common/types_template.go
#	consensus/clique/clique.go
#	consensus/consensus.go
#	consensus/ethash/algorithm.go
#	consensus/ethash/consensus.go
#	consensus/ethash/ethash.go
#	containers/vagrant/Vagrantfile
#	contracts/ens/ens_test.go
#	core/asm/compiler.go
#	core/asm/lexer.go
#	core/block_validator.go
#	core/blockchain.go
#	core/blockchain_test.go
#	core/chain_makers.go
#	core/database_util.go
#	core/database_util_test.go
#	core/events.go
#	core/genesis.go
#	core/genesis_alloc.go
#	core/genesis_test.go
#	core/headerchain.go
#	core/rawdb/accessors_chain.go
#	core/rawdb/accessors_indexes.go
#	core/rawdb/accessors_metadata.go
#	core/rawdb/schema.go
#	core/state/state_test.go
#	core/state/statedb.go
#	core/state/sync.go
#	core/state_processor.go
#	core/state_transition.go
#	core/tx_journal.go
#	core/tx_list.go
#	core/tx_pool.go
#	core/tx_pool_test.go
#	core/types.go
#	core/types/block.go
#	core/types/block_test.go
#	core/types/gen_receipt_json.go
#	core/types/log.go
#	core/types/receipt.go
#	core/types/transaction.go
#	core/types/transaction_signing.go
#	core/types/transaction_signing_test.go
#	core/types/transaction_test.go
#	core/vm/errors.go
#	core/vm/evm.go
#	core/vm/gas.go
#	core/vm/gas_table.go
#	core/vm/instructions.go
#	core/vm/instructions_test.go
#	core/vm/interface.go
#	core/vm/interpreter.go
#	core/vm/intpool.go
#	core/vm/jump_table.go
#	core/vm/logger.go
#	core/vm/logger_test.go
#	core/vm/memory_table.go
#	core/vm/opcodes.go
#	core/vm/runtime/env.go
#	core/vm/runtime/runtime.go
#	crypto/crypto.go
#	crypto/crypto_test.go
#	eth/api.go
#	eth/api_backend.go
#	eth/api_tracer.go
#	eth/backend.go
#	eth/config.go
#	eth/downloader/downloader.go
#	eth/downloader/queue.go
#	eth/downloader/statesync.go
#	eth/filters/filter.go
#	eth/filters/filter_system.go
#	eth/filters/filter_system_test.go
#	eth/gen_config.go
#	eth/handler.go
#	eth/handler_test.go
#	eth/helper_test.go
#	eth/protocol.go
#	eth/sync.go
#	eth/tracers/internal/tracers/4byte_tracer.js
#	eth/tracers/internal/tracers/assets.go
#	eth/tracers/tracer_test.go
#	eth/tracers/tracers_test.go
#	ethclient/ethclient.go
#	ethdb/database.go
#	ethdb/interface.go
#	ethdb/memory_database.go
#	ethstats/ethstats.go
#	event/feed.go
#	internal/ethapi/api.go
#	internal/ethapi/backend.go
#	internal/guide/guide_test.go
#	internal/web3ext/web3ext.go
#	les/api_backend.go
#	les/backend.go
#	les/fetcher.go
#	les/handler.go
#	les/helper_test.go
#	les/odr_requests.go
#	les/odr_test.go
#	les/retrieve.go
#	les/server.go
#	les/serverpool.go
#	light/lightchain.go
#	light/odr_test.go
#	light/postprocess.go
#	light/txpool.go
#	log/README.md
#	log/doc.go
#	log/format.go
#	log/handler.go
#	log/logger.go
#	log/root.go
#	metrics/exp/exp.go
#	metrics/influxdb/influxdb.go
#	metrics/metrics.go
#	metrics/resetting_timer.go
#	metrics/resetting_timer_test.go
#	metrics/timer_test.go
#	miner/worker.go
#	mobile/accounts.go
#	mobile/ethereum.go
#	mobile/geth.go
#	node/config.go
#	node/doc.go
#	p2p/discover/database.go
#	p2p/discover/database_test.go
#	p2p/discover/table.go
#	p2p/discover/table_test.go
#	p2p/discover/udp.go
#	p2p/discover/udp_test.go
#	p2p/discv5/udp.go
#	p2p/enr/enr.go
#	p2p/enr/enr_test.go
#	p2p/enr/entries.go
#	p2p/protocols/protocol.go
#	p2p/protocols/protocol_test.go
#	p2p/rlpx_test.go
#	p2p/server.go
#	p2p/simulations/adapters/docker.go
#	p2p/simulations/adapters/exec.go
#	p2p/simulations/adapters/inproc.go
#	p2p/simulations/adapters/types.go
#	p2p/simulations/http.go
#	p2p/simulations/http_test.go
#	p2p/simulations/mocker.go
#	p2p/simulations/network.go
#	p2p/simulations/network_test.go
#	p2p/testing/protocolsession.go
#	params/bootnodes.go
#	params/config.go
#	params/denomination.go
#	params/gas_table.go
#	params/protocol_params.go
#	params/version.go
#	rpc/http.go
#	rpc/json.go
#	rpc/utils.go
#	signer/core/api.go
#	swarm/api/api.go
#	swarm/api/api_test.go
#	swarm/api/client/client.go
#	swarm/api/client/client_test.go
#	swarm/api/config.go
#	swarm/api/config_test.go
#	swarm/api/filesystem.go
#	swarm/api/filesystem_test.go
#	swarm/api/http/error.go
#	swarm/api/http/error_templates.go
#	swarm/api/http/error_test.go
#	swarm/api/http/roundtripper.go
#	swarm/api/http/server.go
#	swarm/api/http/server_test.go
#	swarm/api/http/templates.go
#	swarm/api/manifest.go
#	swarm/api/manifest_test.go
#	swarm/api/storage.go
#	swarm/api/storage_test.go
#	swarm/api/uri.go
#	swarm/api/uri_test.go
#	swarm/fuse/fuse_dir.go
#	swarm/fuse/fuse_file.go
#	swarm/fuse/swarmfs.go
#	swarm/fuse/swarmfs_test.go
#	swarm/fuse/swarmfs_unix.go
#	swarm/fuse/swarmfs_util.go
#	swarm/metrics/flags.go
#	swarm/network/depo.go
#	swarm/network/forwarding.go
#	swarm/network/hive.go
#	swarm/network/kademlia/address.go
#	swarm/network/kademlia/kaddb.go
#	swarm/network/kademlia/kademlia.go
#	swarm/network/kademlia/kademlia_test.go
#	swarm/network/messages.go
#	swarm/network/protocol.go
#	swarm/network/syncdb.go
#	swarm/network/syncdb_test.go
#	swarm/network/syncer.go
#	swarm/services/swap/swap.go
#	swarm/services/swap/swap/swap.go
#	swarm/storage/chunker.go
#	swarm/storage/chunker_test.go
#	swarm/storage/common_test.go
#	swarm/storage/database.go
#	swarm/storage/dbstore.go
#	swarm/storage/dbstore_test.go
#	swarm/storage/dpa.go
#	swarm/storage/dpa_test.go
#	swarm/storage/localstore.go
#	swarm/storage/memstore.go
#	swarm/storage/netstore.go
#	swarm/storage/pyramid.go
#	swarm/storage/swarmhasher.go
#	swarm/storage/types.go
#	swarm/swarm.go
#	swarm/swarm_test.go
#	swarm/testutil/http.go
#	tests/block_test_util.go
#	tests/difficulty_test.go
#	tests/init.go
#	tests/state_test_util.go
#	tests/transaction_test.go
#	tests/util.go
#	tests/vm_test_util.go
#	trie/database.go
#	trie/encoding.go
#	trie/hasher.go
#	trie/iterator.go
#	trie/proof.go
#	trie/proof_test.go
#	trie/secure_trie.go
#	trie/sync.go
#	trie/sync_test.go
#	trie/trie.go
#	vendor/github.com/docker/docker/pkg/reexec/command_linux.go
#	vendor/github.com/docker/docker/pkg/reexec/command_unix.go
#	vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go
#	vendor/github.com/docker/docker/pkg/reexec/command_windows.go
#	vendor/github.com/docker/docker/pkg/reexec/reexec.go
#	vendor/github.com/eapache/channels/.gitignore
#	vendor/github.com/eapache/queue/.gitignore
#	vendor/github.com/naoina/toml/encode.go
#	vendor/github.com/naoina/toml/parse.go
#	vendor/github.com/naoina/toml/parse.peg
#	vendor/github.com/naoina/toml/parse.peg.go
#	vendor/github.com/rcrowley/go-metrics/.gitignore
#	vendor/github.com/rcrowley/go-metrics/.travis.yml
#	vendor/github.com/rcrowley/go-metrics/README.md
#	vendor/github.com/rcrowley/go-metrics/counter.go
#	vendor/github.com/rcrowley/go-metrics/debug.go
#	vendor/github.com/rcrowley/go-metrics/ewma.go
#	vendor/github.com/rcrowley/go-metrics/exp/exp.go
#	vendor/github.com/rcrowley/go-metrics/gauge.go
#	vendor/github.com/rcrowley/go-metrics/gauge_float64.go
#	vendor/github.com/rcrowley/go-metrics/graphite.go
#	vendor/github.com/rcrowley/go-metrics/healthcheck.go
#	vendor/github.com/rcrowley/go-metrics/histogram.go
#	vendor/github.com/rcrowley/go-metrics/json.go
#	vendor/github.com/rcrowley/go-metrics/log.go
#	vendor/github.com/rcrowley/go-metrics/meter.go
#	vendor/github.com/rcrowley/go-metrics/metrics.go
#	vendor/github.com/rcrowley/go-metrics/opentsdb.go
#	vendor/github.com/rcrowley/go-metrics/registry.go
#	vendor/github.com/rcrowley/go-metrics/runtime.go
#	vendor/github.com/rcrowley/go-metrics/sample.go
#	vendor/github.com/rcrowley/go-metrics/syslog.go
#	vendor/github.com/rcrowley/go-metrics/timer.go
#	vendor/github.com/rcrowley/go-metrics/writer.go
#	vendor/github.com/syndtr/goleveldb/leveldb/db.go
#	vendor/golang.org/x/sys/unix/mksysnum_linux.pl
#	vendor/golang.org/x/sys/unix/types_linux.go
#	vendor/vendor.json
#	whisper/shhclient/client.go
#	whisper/whisperv5/api.go
#	whisper/whisperv5/peer_test.go
#	whisper/whisperv5/whisper.go
#	whisper/whisperv6/api.go
#	whisper/whisperv6/peer_test.go
#	whisper/whisperv6/whisper.go
2018-07-24 16:11:05 +08:00
Ralph Caraveo III 5d30be412b all: switch out defunct set library to different one (#16873)
* keystore, ethash, eth, miner, rpc, whisperv6: tech debt with now defunct set.

* whisperv5: swap out gopkg.in/fatih/set.v0 with supported set
2018-07-16 10:54:19 +03:00
Qvintvs 39ca953828 fix istanbul consensus 2018-06-29 14:16:27 +08:00
Qvintvs 30a2c8c7ef fix raft block creating issue;
issue was that miner was subscribing to chainheadevent
2018-06-26 12:29:45 +08:00
kiel barry cbfb40b0aa params: fix golint warnings (#16853)
params: fix golint warnings
2018-06-05 12:31:34 +02:00
Mark 0029a869f0 miner: not call commitNewWork if it's a side block (#16751) 2018-06-05 12:10:09 +02:00
Qvintvs 622e98ad51 debug merge attempt 2018-05-31 14:21:16 +08:00
Qvintvs 4b44bea1d7 Merge attempt 2018-05-31 14:16:44 +08:00
Péter Szilágyi 49719e21bc
core, eth: minor txpool event cleanups 2018-05-18 12:08:24 +03:00
rjl493456442 a2e43d28d0
all: collate new transaction events together 2018-05-18 11:46:44 +03:00
Ryan Schneider 2a1fc3d155 miner: remove contention on currentMu for pending data retrievals (#16497) 2018-04-16 10:56:20 +03:00
stompesi fe6cf00f48 miner: remove duplicated code (#15968) 2018-03-16 14:13:52 +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
mark.lin 9ac24f9aaa consensus, core, eth, miner, params: update istanbul engine 2018-01-31 10:27:08 +08:00
Jim McDonald 18a7d31338 miner: avoid unnecessary work (#15883) 2018-01-15 12:57:06 +02:00
Péter Szilágyi 6f69cdd109
all: switch gas limits from big.Int to uint64 2018-01-03 14:45:35 +02:00
Ricardo Domingos 9ff9d04a69 all: fix code comment typos (#15547)
* console: fix typo in comment

* contracts/release: fix typo in comment

* core: fix typo in comment

* eth: fix typo in comment

* miner: fix typo in comment
2017-11-24 11:20:01 +02:00
mark.lin 6f835c377e miner: enable private transaction 2017-11-16 09:17:12 -05:00
Patrick Mylund Nielsen 3d91976f08
Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
Péter Szilágyi 6d6a5a9337 cmd, consensus, core, miner: instatx clique for --dev (#15323)
* cmd, consensus, core, miner: instatx clique for --dev

* cmd, consensus, clique: support configurable --dev block times

* cmd, core: allow --dev to use persistent storage too
2017-10-24 13:40:42 +03:00
terasum e9382c6e9f miner: fix typo 2017-10-12 10:19:23 +08:00
Mark cb5235eb07 miner: make starting of CPU agent more reliable (#15148) 2017-09-19 13:28:15 +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
Mark c1740e4540 core/types, miner: avoid tx sender miscaching (#14773) 2017-09-07 23:22:27 +02: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
Egon Elbre faafeef79e miner: fix megacheck warnings 2017-08-07 13:41:22 +03: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
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
Jeffrey Wilcke 10a57fc3d4 consensus, core/*, params: metropolis preparation refactor
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)
2017-05-18 09:05:58 +02:00
Péter Szilágyi a2f23ca9b1 cmd, core, eth, miner: remove txpool gas price limits (#14442) 2017-05-16 21:07:27 +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
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 d83a9a8f44
miner: don't verify our own blocks, trust the engine 2017-04-06 12:22:14 +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
Péter Szilágyi b7d93500f1 all: finish integrating Go ethash, delete C++ vendor 2017-03-09 15:50:14 +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
Felix Lange 5c8fe28b72 common: move big integer math to common/math (#3699)
* 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
2017-02-26 22:21:51 +01: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 c12f4df910 params: core, core/vm, miner: 64bit gas instructions
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
2017-02-13 21:44:25 +01:00
Jeffrey Wilcke 57f4e90257 Revert "params: core, core/vm, miner: 64bit gas instructions (#3514)"
This reverts commit 8b57c49490.
2017-02-13 15:15:12 +01:00
Péter Szilágyi fad5eb0a87
accounts, cmd, eth, internal, miner, node: wallets and HD APIs 2017-02-13 14:00:07 +02:00
Péter Szilágyi 7734ead520 Merge pull request #3605 from fjl/event-feed
event: add new Subscription type and related utilities
2017-02-03 13:56:00 +02:00
Jeffrey Wilcke 8b57c49490 params: core, core/vm, miner: 64bit gas instructions (#3514)
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
2017-02-02 15:25:42 +01:00
Felix Lange 9b62facdd4 event: deprecate TypeMux and related types
The Subscription type is gone, all uses are replaced by
*TypeMuxSubscription. This change is prep-work for the
introduction of the new Subscription type in a later commit.

   gorename -from '"github.com/ethereum/go-ethereum/event"::Event' -to TypeMuxEvent
   gorename -from '"github.com/ethereum/go-ethereum/event"::muxsub' -to TypeMuxSubscription
   gofmt -w -r 'Subscription -> *TypeMuxSubscription' ./event/*.go
   find . -name '*.go' -and -not -regex '\./vendor/.*' \| xargs gofmt -w -r 'event.Subscription -> *event.TypeMuxSubscription'
2017-01-25 16:25:57 +01:00
Felix Lange c5df37c111 eth: accept leading zeros for nonce parameter of submitWork (#3558) 2017-01-13 00:37:23 +01:00
Péter Szilágyi 18c77744ff
all: fix spelling errors 2017-01-06 19:44:35 +02: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
Jeffrey Wilcke bbc4ea4ae8 core/vm: improved EVM run loop & instruction calling (#3378)
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.
2017-01-05 11:52:10 +01:00
Péter Szilágyi 0ee796632a eth, miner: verify PoW in the remote agent to notify submitter (#3438) 2016-12-20 02:14:36 +01:00
Péter Szilágyi 07311f3157
miner: rename pending to unconformed, add bounds and ops tests 2016-12-13 15:10:52 +02:00
Péter Szilágyi 17637ed1bb
miner: clean up unconfirmed mined block tracking 2016-12-13 14:31:32 +02:00
Péter Szilágyi dadd689359
miner: fix data race on setting etherbase/extradata 2016-12-13 14:04:05 +02:00
Péter Szilágyi b750cab56a
miner: fix a race between remote agent start/loop 2016-12-13 14:03:57 +02:00
bas-vk 4e36b1e3da core: bugfix state change race condition in txpool (#3412)
The transaction pool keeps track of the current nonce in its local pendingState. When a
new block comes in the pendingState is reset. During the reset it fetches multiple times
the current state through the use of the currentState callback. When a second block comes
in during the reset its possible that the state changes during the reset. If that block
holds transactions that are currently in the pool the local pendingState that is used to
determine nonces can get out of sync.
2016-12-10 23:54:58 +01:00
Martin Holst Swende 9f8bc00cf5 eth, miner: removed unnecessary state.Copy()
* miner: removed unnecessary state.Copy()

* eth: made use of new miner method without state copying

* miner: More documentation about new method
2016-11-30 11:48:48 +02:00
bas-vk b5be6b72cb eth/filter: add support for pending logs (#3219) 2016-11-28 14:59:06 +01:00
Péter Szilágyi 94c0519be2
miner: remove dead code, add gas price getter 2016-11-24 15:24:49 +02: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
Bas van Kervel f7cb85824c quorum integration 2016-10-30 09:20:48 +01:00
Nick Johnson c9471e7782 miner: copy pending state before handing it to callers (#3162)
The pending state was not copied while not mining, leading to a data race.
2016-10-18 22:34:37 +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
Péter Szilágyi 710435b51b core, eth, trie: reuse trie journals in all our code 2016-09-28 11:27:31 +03:00
Bas van Kervel e3fe634f99 miner: set tx index logs 2016-09-12 11:33:25 +02:00
Péter Szilágyi 2c6be49d20 Merge pull request #2949 from elliots/fix/#2948
miner: Prevent attempts to close nil quit channel in agent (fixes #2948)
2016-09-02 14:45:15 +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
☃ Elliot Shepherd ac0f8b81ae miner: Move CpuAgent channel creation from Start() to initialization (fixes #2948)
Also remove the now un-needed mutex locking in Start() and Stop()
2016-08-26 00:12:17 +10: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
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 461cdb593b core, params, tests: add DAO hard-fork balance moves 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 1e24c2e4f4 cmd/geth, miner, params: special extradata for DAO fork start 2016-07-15 16:52:55 +03:00
zsfelfoldi f9917c8c7b core: improved chainDb using sequential keys 2016-06-07 16:38:56 +02:00
Jeffrey Wilcke a824c3f02f miner: fixed pending state by not shutting down update loop 2016-05-10 13:35:01 +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
Felix Lange 6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +02:00
Felix Lange 46e8940b19 accounts: streamline API
- Manager.Accounts no longer returns an error.
- Manager methods take Account instead of common.Address.
- All uses of Account with unkeyed fields are converted.
2016-04-12 15:58:01 +02:00
Péter Szilágyi e9254bb0f9 core, miner: remove Frontier canary 2016-04-04 13:18:34 +03:00
Jeffrey Wilcke bbeaab7e64 cmd/utils, miner: A/B testing JIT VM. Disabled for miners
This PR introduces a 10% probability that you'll run the client with the
JIT enabled testing the new client and helps us potentially catch
errors when reported.

This feature is **disabled** for miners (disabling the JIT completely).
The JIT can however be force for miners if they enable both --jitvm and
--forcejit.
2016-04-01 13:44:58 +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 75c86f8646 Merge pull request #2141 from obscuren/evm-init
core, core/vm, tests: changed the initialisation behaviour of the EVM
2016-03-23 23:20:51 +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 0228fb57cd eth, miner: fetch pending block/state in on go (data race) 2016-03-16 11:23:26 +02:00