Commit Graph

108 Commits

Author SHA1 Message Date
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 f89dd62776
internal, log: support debug log prints, displaying log origins 2017-02-23 12:16:47 +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 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
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
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 205ea95802
accounts, cmd, internal, node: implement HD wallet self-derivation 2017-02-13 14:00:09 +02:00
Péter Szilágyi c5215fdd48
accounts, cmd, internal, mobile, node: canonical account URLs 2017-02-13 14:00:08 +02: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 833e4d1319
accounts, cmd, eth, internal, mobile, node: split account backends 2017-02-13 14:00:02 +02:00
Diego Siqueira 6ea8eba8ce accounts/abi, internal/jsre/deps: gofmt -w -s (#3636)
Signed-off-by: DiSiqueira <dieg0@live.com>
2017-02-03 13:32:04 +01: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 1886d03faa console, internal/web3ext: remove bzz and ens extensions (#3602)
web3.js includes bzz methods and throws an error when the extension
module is reregistered. The ENS RPC API is deprecated and not exposed by
anything.
2017-01-25 16:29:40 +01:00
Péter Szilágyi 682875adff accounts/abi/bind, internal/ethapi: binary search gas estimation (#3587)
Gas estimation currently mostly works, but can underestimate for more funky
refunds. This is because various ops (e.g. CALL) need more gas to run than they
actually consume (e.g. 2300 stipend that is refunded if not used). With more
intricate contract interplays, it becomes almost impossible to return a proper
value to the user.

This commit swaps out the simplistic gas estimation to a binary search approach,
honing in on the correct gas use. This does mean that gas estimation needs to
rerun the transaction log(max-price) times to measure whether it fails or not,
but it's a price paid by the transaction issuer, and it should be worth it to
support proper estimates.
2017-01-20 23:39:16 +01:00
Péter Szilágyi 946db8ba65 internal/guide: initial test suite to ensure guide snippets run ok (#3582) 2017-01-20 11:50:21 +01:00
Péter Szilágyi d63752ef4d Merge pull request #3579 from bas-vk/natspec
cmd,eth,les,internal: remove natspec support
2017-01-17 14:38:57 +02:00
Nick Johnson 17d92233d9 cmd/geth, core: add support for recording SHA3 preimages (#3543) 2017-01-17 12:19:50 +01:00
Bas van Kervel 54a65e6d87
cmd,eth,les,internal: remove natspec support 2017-01-17 12:13:50 +01:00
Péter Szilágyi 93077c98e4 internal: update web3.js to 0.18.1, embed deps with go-bindata (#3545) 2017-01-12 21:28:35 +01:00
Felix Lange 8820d97039 internal/ethapi: fix duration parameter of personal_unlockAccount (#3542) 2017-01-11 13:20:24 +01:00
Péter Szilágyi 18c77744ff
all: fix spelling errors 2017-01-06 19:44:35 +02:00
Péter Szilágyi 8f9daaa3ba Merge pull request #3518 from fjl/ethclient-dependency-cleanup
core/types: dependency cleanup
2017-01-06 15:42:03 +02: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 b37d175e59
accounts, internal, mobile: polish accounts API, extend Android tests 2017-01-05 12:58:03 +02: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 08eea0f0e4 accounts, core, crypto, internal: use normalised V during signature handling (#3455)
To address increasing complexity in code that handles signatures, this PR
discards all notion of "different" signature types at the library level. Both
the crypto and accounts package is reduced to only be able to produce plain
canonical secp256k1 signatures. This makes the crpyto APIs much cleaner,
simpler and harder to abuse.
2017-01-05 11:35:23 +01:00
Felix Lange 12c964b2b7 internal/ethapi: fix hex handling for eth_call input and eth_sendRawTransaction 2016-12-20 14:46:22 +01:00
Felix Lange cf71f5cd60 rpc: remove HexNumber, replace all uses with hexutil types
This change couldn't be automated because HexNumber was used for numbers
of all sizes.
2016-12-20 14:41:58 +01:00
Felix Lange adab2e16bd rpc: remove HexBytes, replace all uses with hexutil.Bytes 2016-12-20 14:35:26 +01:00
Felix Lange 2be3c4b0e3 internal/jsre: fix built-in inspect function
inspect was broken by ffaf58f0a9 (May 2016!).
Looks like nobody uses this function.
2016-12-20 14:35:14 +01:00
Felix Lange 3e4a04f34d internal/ethapi: fix hex handling for eth_sign, personal_{sign,recover} 2016-12-16 11:32:51 +01: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
Jeffrey Wilcke 3fc7c97827 core, core/vm: implemented a generic environment (#3348)
Environment is now a struct (not an interface). This
reduces a lot of tech-debt throughout the codebase where a virtual
machine environment had to be implemented in order to test or run it.

The new environment is suitable to be used en the json tests, core
consensus and light client.
2016-12-06 02:16:03 +01:00
Viktor Trón e949a2ed2f cmd/bzzd: swarm daemon fixes (#3359)
* cmd/bzzd: add missing p2p/discovery flags
* cmd/bzzd: fix two bugs crashing bzzd if bootnodes flag given
* cmd/bzzd: make no swap default, renamed flag bzznoswap->bzzswap
* internal/web3ext: correct methods for bzz IPC module
* cmd/bzzd: ethapi param not mandatory. Warning if no blockchain
* cmd/bzzd: correct default IPC modules in help string
* cmd/utils: fix help description for networkId - add Ropsten
* cmd/bzz, swarm/api, swarm/network: add swarm networkId flag
* cmd/bzzd: change nosync flag to sync and BootTFlag
2016-11-28 13:29:33 +01:00
Felix Lange 20899c05a4 internal/build: use 'git tag --points-at' to get the current tag
This should restore support for building with git 1.x.
2016-11-27 18:42:48 +01:00
Jeffrey Wilcke 6cc87a31c6 cmd/utils, internal/web3ext: removed httpGet 2016-11-25 12:31:06 +01:00
Felix Lange 01d5fc670b internal/web3ext: remove registrar-related extensions
(cherry picked from commit d54ad55c6079ae6eab93d7f34ce5c4ec829f8e5b)
2016-11-25 12:15:12 +01:00
Felix Lange e1e2df656a internal/build: add support for git tag in local Environment
I didn't add this initially because the command I tried was too slow.
The 'git for-each-ref ...' invocation takes 40ms on my machine. That
ought to be acceptable.
2016-11-23 10:40:22 +01:00
Péter Szilágyi b7dfd333c5
.travis, build: Build step to push .aar to Maven Central 2016-11-14 17:56:58 +02:00
Zsolt Felfoldi b10bcd924b core/types: turn off nonce checking for Call messages 2016-11-14 14:16:06 +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
Felix Lange b8bd9a71c8 all: update license information 2016-11-09 02:51:34 +01:00
Zsolt Felfoldi 9f8d192991 les: light client protocol and API 2016-11-09 02:12:53 +01:00
Felix Lange 8b1df1a259 build: fix remote path for archive uploads (#3243)
archiveUpload did not handle absolute paths correctly. Fix it by using
the basename and ensure that uploads can be tested using -n.
2016-11-08 23:46:46 +01:00
Péter Szilágyi 9bc97a5785 build: NSIS based Windows installer (#3240)
This commit adds support for creating Windows installers to ci.go
2016-11-08 22:55:39 +01:00
Péter Szilágyi df30ef5177
internal/build: call correct signer method 2016-11-08 10:59:19 +02:00
Felix Lange ed2bc7fbe9 build, internal/build: misc improvements (#3229)
* travis.yml: don't create darwin/386 builds

* build: remove godep remains

* internal/build: improve archives

- enable compression for zip files
- don't write half-complete archives

* build: add -unstable to archive names
2016-11-03 14:44:16 +02:00
Péter Szilágyi 3b62c145f8
travis, build: implement uploading archives to azure 2016-11-03 10:32:53 +02:00
Kenji Siu d85d3c74db internal/debug, internal/ethapi, rpc, swarm/storage: Ran "go fmt" 2016-11-01 18:40:36 +08:00