Commit Graph

79 Commits

Author SHA1 Message Date
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
Péter Szilágyi
59b8245bbc Merge pull request #3516 from fjl/types-drop-sign-ecdsa
core/types: remove redundant SignECDSA wrappers, rename to SignTx
2017-01-06 15:55:55 +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
Felix Lange
e171bf74f8 core/types: remove redundant SignECDSA wrappers, rename to SignTx 2017-01-05 12:59:17 +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
RJ
2126d81488 accounts/abi: add support for function types (#3405) 2017-01-05 11:46:44 +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
bas-vk
6d15d00ac4 accounts/abi: add support for "anonymous" and "indexed" for events (#3464) 2016-12-22 01:51:20 +01:00
Péter Szilágyi
64bf5bafe9 Merge pull request #3403 from VoR0220/fixedPointsAbi
accounts/abi: prepare ABI to handle fixed point types
2016-12-19 14:22:57 +02:00
Péter Szilágyi
4d05bbf2a4
accounts/abi: clean up PR and add type parsing tests 2016-12-19 14:11:11 +02:00
VoR0220
471990f771
accounts/abi: prepare ABI to handle fixed point types
Signed-off-by: VoR0220 <rj@erisindustries.com>
2016-12-19 14:11:11 +02: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
Péter Szilágyi
5513c49c54
accounts/abi/bind, mobile: review fixes and android tests 2016-11-14 18:00:14 +02:00
Péter Szilágyi
178da7c6a9
mobile: initial wrappers for mobile support 2016-11-14 17:56:58 +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
Felix Lange
b8bd9a71c8 all: update license information 2016-11-09 02:51:34 +01:00
RJ
2ad5dba50a accounts/abi: differentiate between static and dynamic arrays (#3121)
solves #3119

Signed-off-by: VoR0220 <rj@erisindustries.com>
2016-11-03 23:25:19 +01:00
bas-vk
b59c8399fb internal/ethapi: add personal_sign and fix eth_sign to hash message (#2940)
This commit includes several API changes:

- The behavior of eth_sign is changed. It now accepts an arbitrary
  message, prepends the well-known string

        \x19Ethereum Signed Message:\n<length of message>

  hashes the result using keccak256 and calculates the signature of
  the hash. This breaks backwards compatability!
  
- personal_sign(hash, address [, password]) is added. It has the same
  semantics as eth_sign but also accepts a password. The private key
  used to sign the hash is temporarily unlocked in the scope of the
  request.
  
- personal_recover(message, signature) is added and returns the
  address for the account that created a signature.
2016-10-28 21:25:49 +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
06ac31cf1a accounts/abi: fix typo in the comment (dummy commit) 2016-09-26 13:40:28 +03:00
Felix Lange
a59a93f476 core/state: track all accounts in canon state
This change introduces a global, per-state cache that keeps account data
in the canon state. Thanks to @karalabe for lots of fixes.
2016-09-26 10:09:52 +02:00
Felix Lange
c97df052a9 accounts/abi/bind: add utilities for waiting on transactions
The need for these functions comes up in code that actually deploys and
uses contracts. As of this commit, they can be used with both
SimulatedBackend and ethclient.

SimulatedBackend gains some additional methods in the process and is now
safe for concurrent use.
2016-08-22 23:20:13 +02:00
Felix Lange
d62d5fe59a accounts/abi/bind: use ethereum interfaces
In this commit, contract bindings and their backend start using the
Ethereum Go API interfaces offered by ethclient. This makes ethclient a
suitable replacement for the old remote backend and gets us one step
closer to the final stable Go API that is planned for go-ethereum 1.5.

The changes in detail:

* Pending state is optional for read only contract bindings.
  BoundContract attempts to discover the Pending* methods via an
  interface assertion. There are a couple of advantages to this:
  ContractCaller is just two methods and can be implemented on top of
  pretty much anything that provides Ethereum data. Since the backend
  interfaces are now disjoint, ContractBackend can simply be declared as
  a union of the reader and writer side.

* Caching of HasCode is removed. The caching could go wrong in case of
  chain reorganisations and removing it simplifies the code a lot.
  We'll figure out a performant way of providing ErrNoCode before the
  1.5 release.

* BoundContract now ensures that the backend receives a non-nil context
  with every call.
2016-08-22 14:01:28 +02:00
Felix Lange
056f15aa53 accounts/abi/bind/backends: remove nil and remote backends
The remote backend is superseded by ethclient.

The nil backend's stated purpose was to enable testing of
accounts/abi/bind. None of its methods actually worked. A much simpler
way to get a crashing backend is to simply pass nil as the backend. With
a one-line change to the generator (removing two explicit interface
assertions), passing nil actually works.

Removing these backends means that less changes are required later.
2016-08-21 17:06:25 +02:00
Felix Lange
91b7690428 rpc: add new client, use it everywhere
The new client implementation supports concurrent requests,
subscriptions and replaces the various ad hoc RPC clients
throughout go-ethereum.
2016-07-22 23:21:27 +02:00
Péter Szilágyi
3291235711 accounts, core, eth: pass chain config for chain maker to test DAO 2016-07-15 16:52:55 +03:00
zsfelfoldi
00787fe781 core: added CheckNonce() to Message interface 2016-07-11 12:35:23 +02:00
Péter Szilágyi
1e50f5dd28 Merge pull request #2159 from zsfelfoldi/light-backend
eth: separate common and full node-specific API and backend service
2016-06-30 12:57:50 +03:00
zsfelfoldi
3a97280ae8 eth: separate common and full node-specific API and backend service 2016-06-16 17:36:38 +02:00
Péter Szilágyi
0f9539e1e3 accounts/abi: fix uint64 upper range encoding. 2016-06-10 12:32:08 +03:00
Thomas Bocek
89c6c5bb85 accounts/abi: Negative numbers not properly converted in ABI encoding
When converting a negative number e.g., -2, the resulting ABI encoding
should look as follows:
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe.
However, since the check of the type is for an uint instead of an
int, it results in the following ABI encoding:
0101010101010101010101010101010101010101010101010101010101010102. The
Ethereum ABI
(https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) says,
that signed integers are stored in two's complement which should be
of the form ffffff.... and not 01010101..... for e.g. -1. Thus, I
removed the type check in numbers.go as well as the function S256
as I don't think they are correct. Or maybe I'm missing something?
2016-06-06 14:27:15 +02:00
Péter Szilágyi
1580ec1804 accounts/abi/bind, eth: rely on getCode for sanity checks, not estimate and call 2016-05-20 12:29:28 +03:00
Péter Szilágyi
251b3c6406 accounts/abi: fix abi test for go vet... 2016-05-12 16:36:58 +03:00
Péter Szilágyi
cc21706c50 accounts/abi/bind: fix multi-value anonymous unmarshalling 2016-05-12 16:28:18 +03:00
Jeffrey Wilcke
91a7a4a786 accounts/abi: fixed unpacking in to already slice interfaces
Previously it was assumed that wheneven type `[]interface{}` was given
that the interface was empty. The abigen rightfully assumed that
interface slices which already have pre-allocated variable sets to be
assigned.

This PR fixes that by checking that the given `[]interface{}` is larger
than zero and assigns each value using the generic `set` function (this
function has also been moved to abi/reflect.go) and checks whether the
assignment was possible.

The generic assignment function `set` now also deals with pointers
(useful for interface slice mentioned above) by dereferencing the
pointer until it finds a setable type.
2016-05-11 13:36:27 +02:00
Péter Szilágyi
586eddfd09 release, all: integrate the release service into geth 2016-05-02 16:20:21 +03:00
Péter Szilágyi
0f722df2d9 Merge pull request #2435 from obscuren/abi-array-fixes
accounts/abi: refactored ABI package
2016-04-28 15:23:07 +03:00
Jeffrey Wilcke
4880868c88 accounts/abi: fixed string and fixed size bytes packing 2016-04-28 12:41:47 +02:00
Jeffrey Wilcke
c3d5250473 accounts/abi: added unpacking "anything" in to interface{} 2016-04-28 12:41:42 +02:00
Jeffrey Wilcke
e0dc45fce2 accounts/abi: fixed strict go-like unpacking 2016-04-28 12:41:37 +02:00
Péter Szilágyi
cdcbb2f160 accounts/abi/bind, eth: add contract non-existent error 2016-04-27 17:15:23 +03:00
Jeffrey Wilcke
5127ec10cb accouns/abi: refactored ABI package
Refactored the abi package parsing and type handling. Relying mostly on
package reflect as opposed to most of our own type reflection. Our own
type reflection is still used however for cases such as Bytes and
FixedBytes (abi: bytes•).

This also inclused several fixes for slice handling of arbitrary and
fixed size for all supported types.

This also further removes implicit type casting such as assigning,
for example `[2]T{} = []T{1}` will fail, however `[2]T{} == []T{1, 2}`
(notice assigning *slice* to fixed size *array*). Assigning arrays to
slices will always succeed if they are of the same element type.

Incidentally also fixes #2379
2016-04-20 16:43:57 +02:00
Péter Szilágyi
e581f2690a accounts/abi/bind/backends: estimate needed gas, not used 2016-04-15 18:32:21 +03:00
Felix Lange
6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +02:00
Felix Lange
d04a2e7557 all: update license information 2016-04-15 09:48:05 +02:00
Felix Lange
85e6c40c00 accounts, crypto: move keystore to package accounts
The account management API was originally implemented as a thin layer
around crypto.KeyStore, on the grounds that several kinds of key stores
would be implemented later on. It turns out that this won't happen so
KeyStore is a superflous abstraction.

In this commit crypto.KeyStore and everything related to it moves to
package accounts and is unexported.
2016-04-12 15:56:49 +02:00
Péter Szilágyi
fc4fffd5ac accounts/abi/bind: support generating bindings for various arrays 2016-04-05 18:20:50 +03:00
Jeffrey Wilcke
a306e17a26 abi: removed implicit type casting & refactored type parsing 2016-04-04 20:30:59 +02:00