Commit Graph

191 Commits

Author SHA1 Message Date
Felix Lange d78ad226c2 ethclient, mobile: add TransactionSender (#15127)
* core/types: make Signer derive address instead of public key

There are two reasons to do this now: The upcoming ethclient signer
doesn't know the public key, just the address. EIP 208 will introduce a
new signer which derives the 'entry point' address for transactions with
zero signature. The entry point has no public key.

Other changes to the interface ease the path make to moving signature
crypto out of core/types later.

* ethclient, mobile: add TransactionSender

The new method can get the right signer without any crypto, and without
knowledge of the signature scheme that was used when the transaction was
included.
2017-10-01 11:03:28 +02:00
Péter Szilágyi 5bbd7fb390
consensus, core, params: rebrand Metro to Byzantium 2017-09-14 10:10:46 +03:00
Mark c1740e4540 core/types, miner: avoid tx sender miscaching (#14773) 2017-09-07 23:22:27 +02:00
Péter Szilágyi f585f9eee8
core, eth: clean up bloom filtering, add some tests 2017-09-06 11:14:19 +03:00
Zsolt Felfoldi 4ea4d2dc34
core, eth: add bloombit indexer, filter based on it 2017-09-06 11:13:13 +03:00
Felix Lange ad16aeb0a2 core/types: encode receipt status in PostState field
This fixes a regression where the new Failed field in ReceiptForStorage
rejected previously stored receipts. Fix it by removing the new field
and store status in the PostState field. This also removes massive RLP
hackery around the status field.
2017-08-24 23:51:50 +02:00
nkbai 68955ed2eb core/types: fix create indicator in Transaction.String (#15025) 2017-08-24 12:48:13 +02:00
Péter Szilágyi 4ee92f2d19
core/types: reject Metro receipts with > 0x01 status bytes 2017-08-23 13:57:15 +03:00
rjl493456442 28aea46ac0
core: implement Metropolis EIP 658, receipt status byte 2017-08-22 18:35:17 +03:00
Péter Szilágyi a56f3dc0d9 core, ethclient: implement Metropolis EIP 98 (#14750)
Implements ethereum/EIPs#98
2017-07-17 10:34:53 +02:00
ligi f25486c3fb core: fix typo in error message (#14763) 2017-07-06 00:19:38 +02:00
bailantaotao bc24b7a912 core/types: use Header.Hash for block hashes (#14587)
Fixes #14586
2017-06-07 12:06:25 +02:00
Felix Lange ef25b826e6 Merge pull request #14502 from karalabe/mobile-import-ecdsa
Enforce 256 bit keys on raw import, support raw mobile imports
2017-05-24 22:30:47 +02:00
Péter Szilágyi aa73420207
accounts/keystore, crypto: enforce 256 bit keys on import 2017-05-23 14:58:03 +03:00
Jeffrey Wilcke a5f6a1cb7c consensus, core, core/vm, parems: review fixes 2017-05-18 09:05:58 +02:00
Jeffrey Wilcke e6aff513db core/types: corrected abstract signing address 2017-05-18 09:05:58 +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
Felix Lange 3d8de95f99 core, core/types: regenerate JSON marshaling, add "hash" to headers (#13868)
* Makefile: fix devtools target

* core: regenerate genesis marshaling with fjl/gencodec@cbfa5be5a8

* core/types: regenerate marshaling methods with fjl/gencodec@cbfa5be5a8

* core/types: add "hash" to JSON headers
2017-04-06 11:38:21 +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
bas-vk baf20010e7 core/types: rename txdata.gasLimit -> txdata.gas in JSON (#13848) 2017-03-29 11:59:13 +02:00
Felix Lange aa9a78e463 core, core/types: use non-pointer receiver for Marshal* methods
Regenerated with fjl/gencodec@1a75a21610
Also add ,omitempty to optional GenesisAccount fields.
2017-03-27 13:29:01 +02:00
Felix Lange 4be37e91b9 core/types: ensure all EIP155 signer fields are set by deriveSigner
Fixes #3819
2017-03-24 22:06:10 +01:00
Felix Lange 37dd9086ec core: refactor genesis handling
This commit solves several issues concerning the genesis block:

* Genesis/ChainConfig loading was handled by cmd/geth code. This left
  library users in the cold. They could specify a JSON-encoded
  string and overwrite the config, but didn't get any of the additional
  checks performed by geth.
* Decoding and writing of genesis JSON was conflated in
  WriteGenesisBlock. This made it a lot harder to embed the genesis
  block into the forthcoming config file loader. This commit changes
  things so there is a single Genesis type that represents genesis
  blocks. All uses of Write*Genesis* are changed to use the new type
  instead.
* If the chain config supplied by the user was incompatible with the
  current chain (i.e. the chain had already advanced beyond a scheduled
  fork), it got overwritten. This is not an issue in practice because
  previous forks have always had the highest total difficulty. It might
  matter in the future though. The new code reverts the local chain to
  the point of the fork when upgrading configuration.

The change to genesis block data removes compression library
dependencies from package core.
2017-03-23 15:58:43 +01:00
Felix Lange 67c47459f2 core/types: handle nil ChainId in NewEIP155Signer
All uses of ChainConfig.ChainId eventually end up in NewEIP155Signer.
This fixes the case where users forget to set the ChainId in their
config.
2017-03-23 15:58:42 +01:00
Felix Lange 8cf08e4b25 core/types: use gencodec for JSON marshaling code 2017-03-07 12:45:12 +01:00
Felix Lange d304da3803 common/hexutil: implement TextMarshaler, TextUnmarshaler
This commit makes the wrapper types more generally applicable.
encoding.TextMarshaler is supported by most codec implementations (e.g.
for yaml).

The tests now ensure that package json actually recognizes the custom
marshaler implementation irrespective of how it is implemented.

The Uint type has new tests, too. These are tricky because uint size
depends on the CPU word size. Turns out that there was one incorrect
case where decoding returned ErrUint64Range instead of ErrUintRange.
2017-03-02 14:05:46 +01:00
Felix Lange 5f7826270c all: unify big.Int zero checks, use common/math in more places (#3716)
* common/math: optimize PaddedBigBytes, use it more

name              old time/op    new time/op    delta
PaddedBigBytes-8    71.1ns ± 5%    46.1ns ± 1%  -35.15%  (p=0.000 n=20+19)

name              old alloc/op   new alloc/op   delta
PaddedBigBytes-8     48.0B ± 0%     32.0B ± 0%  -33.33%  (p=0.000 n=20+20)

* all: unify big.Int zero checks

Various checks were in use. This commit replaces them all with Int.Sign,
which is cheaper and less code.

eg templates:

    func before(x *big.Int) bool { return x.BitLen() == 0 }
    func after(x *big.Int) bool  { return x.Sign() == 0 }

    func before(x *big.Int) bool { return x.BitLen() > 0 }
    func after(x *big.Int) bool  { return x.Sign() != 0 }

    func before(x *big.Int) int { return x.Cmp(common.Big0) }
    func after(x *big.Int) int  { return x.Sign() }

* common/math, crypto/secp256k1: make ReadBits public in package math
2017-02-28 15:09:11 +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
bas-vk c46c41eae3 core/types: add unittest for tx json serialization (#3609) 2017-01-26 21:16:24 +01:00
Felix Lange fc52f2c007 core/types: make Transaction zero value printable (#3595) 2017-01-23 18:51:02 +01:00
bas-vk 0126d01435 types: bugfix invalid V derivation on tx json unmarshal (#3594) 2017-01-20 23:32:16 +01:00
Felix Lange c5df37c111 eth: accept leading zeros for nonce parameter of submitWork (#3558) 2017-01-13 00:37:23 +01:00
Felix Lange f2da6581ba all: fix issues reported by honnef.co/go/simple/cmd/gosimple 2017-01-06 18:18:07 +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
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
Steven Roose 61ccb43487 core/types: Document Transaction.To (#3366) 2016-11-28 21:56:38 +01:00
Felix Lange 24f288770e core/types: use package hexutil for JSON handling 2016-11-28 11:22:52 +01:00
Jeffrey Wilcke a672eae3d1 core, core/types: refactored tx chain id checking (#3257)
* core, core/types: refactored tx chain id checking

Refactored explicit chain id checking in to the Sender deriviation method

* cmd/utils, params: define chain ids
2016-11-14 21:37:13 +01:00
Péter Szilágyi 178da7c6a9
mobile: initial wrappers for mobile support 2016-11-14 17:56:58 +02:00
Jeffrey Wilcke 6c9c1e6712 core, core/types: refactored tx chain id checking
Refactored explicit chain id checking in to the Sender deriviation method
2016-11-14 15:59:31 +01: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
Felix Lange b8bd9a71c8 all: update license information 2016-11-09 02:51:34 +01:00
Felix Lange be3865211c core/types: remove header accessors
These accessors were introduced by light client changes, but
the only method that is actually used is GetNumberU64. This
commit replaces all uses of .GetNumberU64 with .Number.Uint64.
2016-11-09 02:19:07 +01:00
Zsolt Felfoldi 760fd65487 light: light chain, VM env and tx pool 2016-11-09 02:12:53 +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
Bas van Kervel 71e8ae01b8 core/types: renamed receiptRoot to receiptsRoot 2016-10-05 12:24:42 +02:00
Péter Szilágyi b6b5ec8f75 core/types: add core type marshal methods too 2016-09-08 18:16:53 +03:00