Commit Graph

298 Commits

Author SHA1 Message Date
JoeGruffins
eb69f490ed
abi/base: return error for pending call error (#24649)
If a pending contract call errors, return that error right away rather
than ignoring it to allow an error somewhere else. This is helpful for
callers to know if perhaps a call failed because of the context deadline
being expired. This change mirrors the behavior of non-pending contract
calls.
2022-04-12 11:36:29 +03:00
Eng Zer Jun
8d066f1f42
all: use T.TempDir to create temporary test directories (#24633)
This commit replaces ioutil.TempDir with t.TempDir in tests. The
directory created by t.TempDir is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using ioutil.TempDir
had to be removed manually by calling os.RemoveAll, which is omitted in
some tests. The error handling boilerplate e.g.

	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}

is also tedious, but t.TempDir handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-08 15:44:55 +02:00
Tangui Clairet
bf5cacfb8f
accounts/abi: handle tuple arrays in ParseSelector (#24587)
Closes #24571
2022-04-08 15:38:23 +02:00
Daniel Perez
37f9d25ba0
signer/fourbyte: add support for nested types in selectors (#24407)
This replaces the simple selector parser in signer/fourbyte with one that
can actually handle most types. The new parser is added in accounts/abi
to also make it useable elsewhere.
2022-03-04 13:39:09 +01:00
komika
afe344bcf3
accounts/abi/bind: improve WaitMined error handling (#24321)
This change makes it so WaitMined no longer logs an error when the receipt
is unavailable. It also changes the simulated backend to return NotFound for
unavailable receipts, just like ethclient does.
2022-02-01 16:42:51 +01:00
zhiqiangxu
f39f068161
accounts/abi: simplify Arguments.Unpack (#24277)
Since len(nonIndexedArgs) is definitely 0 in this context, the code can be simplified.
2022-01-24 17:19:43 +01:00
Pantelis Peslis
f80ce141a1
accounts/abi/bind/backends: return errors instead of panic (#24242) 2022-01-18 11:17:37 +02:00
fomotrader
99be62a9b1
accounts/abi: avoid unnecessary alloc (#24128) 2021-12-20 10:25:46 +01:00
Andrei Maiboroda
3e47e38a4e
core/vm: Make INVALID a defined opcode (#24017)
* core/vm: Define 0xfe opcode as INVALID

* core/vm: Remove opInvalid as opUndefined handles it

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
2021-12-17 13:44:05 +01:00
divergencetech
b45931cc4a
accounts/abi/bind: correctly handle structs used only as constructor params (#23940)
The `structs` map is populated by iterating over all methods except the constructor, which results in a nil-pointer dereference.

I've first reproduced the problem with a new test and then implemented the fix.

Co-authored-by: Arran Schlosberg <me@arranschlosberg.com>
2021-12-02 13:53:10 +01:00
Joshua Colvin
abc74a5ffe
accounts/abi/bind/backends: fix race condition in simulated backend (#23898)
Now that `SimulatedBackend.SuggestGasPrice` inspects member values, a lock needs to be added to prevent a race condition.
2021-11-12 15:50:08 +01:00
Marius van der Wijden
c2e64db3b1
accounts/abi/bind/backends: make suggestGasPrice compatible with non-1559 chains (#23840) 2021-11-01 10:01:22 +01:00
Sparty
57c252ef4e
accounts/abi/bin/backends: return basefee in suggestGasPrice (#23838)
Co-authored-by: mrx <mrx@mrx.com>
2021-11-01 07:49:45 +01:00
KibGzr
b6fb18479c
accounts/abi/bind: fix error handling in baseFee query (#23781)
This fixes a panic that occurs when HeaderByNumber() returns an error.
2021-10-21 11:40:35 +02:00
Marius van der Wijden
08e782c61f
accounts/abi: add basic support for error types (#23161)
This is the initial step for support of Solidity errors in contract bindings.
As of this change, errors can be decoded, but are not supported in
bindings yet.

Closes #23157
2021-10-14 13:33:28 +02:00
Marius van der Wijden
79b727bc8a
accounts/abi/bind: refactor transact method (#23719)
This fixes a bug where gas-related fields of the TransactOpts passed
to transaction methods would be modified, skipping gas estimation for
subsequent transactions.

Co-authored-by: Yondon Fu <yondon.fu@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-10-13 22:59:11 +02:00
Iskander (Alex) Sharipov
778ff94794
all: fix some go-critic linter warnings (#23709)
This doesn't fix all go-critic warnings, just the most serious ones.

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-10-13 17:31:02 +02:00
Yihau Chen
92c5d104d0
accounts/abi/bind: check event signature before parsing (#23230)
* accounts/abi/bind: check event signature before parsing

* remove redundant break line
2021-09-28 12:56:03 +02:00
gary rong
57a3fab8a7
accounts/abi: fix resolving single struct argument (#23573) 2021-09-22 10:18:18 +02:00
Marius van der Wijden
d02c605367
core: only check sendernoeoa in non fake mode (#23424) 2021-08-23 12:49:39 +03:00
lightclient
a879c42bd3
internal/ethapi, accounts/abi/bind: cap highest gas limit by account balance for 1559 fee parameters (#23309)
* internal/ethapi/api: cap highest gas limit by account balance for 1559 fee parameters

* accounts/abi/bind: port gas limit cap for 1559 parameters to simulated backend

* accounts/abi/bind: add test for 1559 gas estimates for the simulated backend

* internal/ethapi/api: fix comment

* accounts/abi/bind/backends, internal/ethapi: unify naming style

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2021-08-10 16:56:34 +03:00
Marius van der Wijden
3aea432b35
accounts/abi/bind: set Context in TransactOpts (#23188) 2021-07-27 16:24:27 +02:00
Marius van der Wijden
b20bc5c0ca
accounts/abi/bind: parse ABI only once, create metadata struct (#22583) 2021-07-27 16:22:21 +02:00
Pierre R
61f4b5aa89
accounts/abi/bind: fix gas price suggestion with pre EIP-1559 clients (#23102)
This fixes transaction sending in the case where an app using go-ethereum v1.10.4
is talking to a pre-EIP-1559 RPC node. In this case, the eth_maxPriorityFeePerGas
endpoint is not available and we can only rely on eth_gasPrice.
2021-06-29 10:57:29 +02:00
Guillaume Ballet
ddf10250c7
accounts/abi/bind: replace context.TODO with context.Background (#23088) 2021-06-22 12:06:34 +03:00
Nicolas Feignon
c63c2d855e accounts/abi/bind: call ensureContext on every context 2021-06-17 14:04:24 +02:00
Péter Szilágyi
7a7abe3de8
accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#23038)
* accounts/abi/bind: fix bounded contracts and sim backend for 1559

* accounts/abi/bind, ethclient: don't rely on chain config for gas prices

* all: enable London for all internal tests

* les: get receipt type info in les tests

* les: fix weird test

Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-06-15 13:56:14 +03:00
Oliver Tale-Yazdi
1d57f22d58
accounts/abi/bind/backends: add simulated reorgs (#22624)
* accounts/abi/bind/backends: add blockByHashNoLock

Signed-off-by: Oliver Tale-Yazdi <oliver@perun.network>

* accounts/abi/bind/backends: add 'parent' arg to rollback

Signed-off-by: Oliver Tale-Yazdi <oliver@perun.network>

* accounts/abi/bind/backends: add simulated forks

Signed-off-by: Oliver Tale-Yazdi <oliver@perun.network>

* accounts/abi/bind/backends: minor nitpicks

* accounts/abi/bind/backends: don't add defensive panics

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2021-06-14 08:55:44 +03:00
Péter Szilágyi
c503f98f6d
all: rename internal 1559 gas fields, add support for graphql (#23010)
* all: rename internal 1559 gas fields, add support for graphql

* cmd/evm/testdata, core: use public 1559 gas names on API surfaces
2021-06-08 12:05:41 +02:00
Martin Holst Swende
94451c2788
all: implement EIP-1559 (#22837)
This is the initial implementation of EIP-1559 in packages core/types and core.
Mining, RPC, etc. will be added in subsequent commits.

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-05-17 15:13:22 +02:00
Martin Redmond
38ea7f2cf4
accounts/abi/bind: add NoSend transact option (#22446)
This adds a new option to avoid sending the transaction which is
created by calling a bound contract method.
2021-03-19 11:56:10 +01:00
lightclient
bbfb1e4008
all: add support for EIP-2718, EIP-2930 transactions (#21502)
This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.

There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.

The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID. 

This change also adds support for the YoloV3 testnet.

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
2021-02-25 15:26:57 +01:00
Péter Szilágyi
2d1a0e9b03
accounts/abi/bind: fix up Go mod files for Go 1.16 2021-02-23 18:12:25 +02:00
Marius van der Wijden
cb3c7e4319
accounts/abi/bind: fixed unpacking error (#22230)
There was a dormant error with structured inputs that failed unpacking.
This commit fixes the error by switching casting to the better abi.ConvertType function.
It also adds a test for calling a view function that returns a struct
2021-02-10 13:12:13 +01:00
Péter Szilágyi
42f9f1f073
core/state: convert prefetcher to concurrent per-trie loader 2021-01-21 01:47:14 +02:00
yumiel yoomee1313
0a3993c558
accounts/abi/bind: fix erroneous test (#22053)
closes #22049
2020-12-30 13:10:11 +01:00
Connor Stein
38c1d592b7
abi/bind: fix error-handling in generated wrappers for functions returning structs (#22005)
Fixes the template used when generating code, which in some scenarios would lead to panic instead of returning an error.
2020-12-12 10:16:34 +01:00
Marius van der Wijden
ed0670cb17
accounts/abi/bind: allow specifying signer on transactOpts (#21356)
This commit enables users to specify which signer they want to use while creating their transactOpts.
Previously all contract interactions used the homestead signer. Now a user can specify whether they
want to sign with homestead or EIP155 and specify the chainID which adds another layer of security.

Closes #16484
2020-12-08 14:44:56 +01:00
Martin Holst Swende
7770e41cb5
core: improve contextual information on core errors (#21869)
A lot of times when we hit 'core' errors, example: invalid tx, the information provided is
insufficient. We miss several pieces of information: what account has nonce too high,
and what transaction in that block was offending?

This PR adds that information, using the new type of wrapped errors.
It also adds a testcase which (partly) verifies the output from the errors.

The first commit changes all usage of direct equality-checks on core errors, into
using errors.Is. The second commit adds contextual information. This wraps most
of the core errors with more information, and also wraps it one more time in
stateprocessor, to further provide tx index and tx hash, if such a tx is encoutered in
a block. The third commit uses the chainmaker to try to generate chains with such
errors in them, thus triggering the errors and checking that the generated string meets
expectations.
2020-12-04 12:22:19 +01:00
Alex Prut
810f9e057d
all: remove redundant conversions and import names (#21903) 2020-11-25 21:00:23 +01:00
Nicolas Feignon
cf856ea1ad
accounts/abi: template: set events Raw field in Parse methods (#21807) 2020-11-13 13:43:15 +01:00
Marius van der Wijden
2045a2bba3
core, all: split vm.Context into BlockContext and TxContext (#21672)
* all: core: split vm.Config into BlockConfig and TxConfig

* core: core/vm: reset EVM between tx in block instead of creating new

* core/vm: added docs
2020-11-13 13:42:19 +01:00
Marius van der Wijden
296a27d106
accounts/abi/bind: restore error functionality (#21743)
* accounts/abi/bind: restore error functionality

* Update accounts/abi/bind/base.go

Co-authored-by: Guillaume Ballet <gballet@gmail.com>

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2020-10-27 17:22:44 +01:00
Marius van der Wijden
420b78659b
accounts/abi: ABI explicit difference between Unpack and UnpackIntoInterface (#21091)
* accounts/abi: refactored abi.Unpack

* accounts/abi/bind: fixed error

* accounts/abi/bind: modified template

* accounts/abi/bind: added ToStruct for conversion

* accounts/abi: reenabled tests

* accounts/abi: fixed tests

* accounts/abi: fixed tests for packing/unpacking

* accounts/abi: fixed tests

* accounts/abi: added more logic to ToStruct

* accounts/abi/bind: fixed template

* accounts/abi/bind: fixed ToStruct conversion

* accounts/abi/: removed unused code

* accounts/abi: updated template

* accounts/abi: refactored unused code

* contracts/checkpointoracle: updated contracts to sol ^0.6.0

* accounts/abi: refactored reflection logic

* accounts/abi: less code duplication in Unpack*

* accounts/abi: fixed rebasing bug

* fix a few typos in comments

* rebase on master

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2020-09-28 14:10:26 +02:00
Osoro Bironga
9a39c6bcb1
accounts/abi: improve documentation and names (#21540)
* accounts: abi/bid/backends; cleaned doc errors, camelCase refactors and anonymous variable assignments

* acounts/abi/bind: doc errors, anonymous parameter assignments

* accounts/abi: doc edits, camelCase refactors

* accounts/abi/bind: review fix

* reverted name changes

* name revert

Co-authored-by: Osoro Bironga <osoro@doctaroo.com>
2020-09-20 10:43:57 +02:00
Marius van der Wijden
89884dc353
tests/fuzzers/abi: add fuzzer for fuzzing package accounts/abi (#21217)
* tests/fuzzers/abi: added abi fuzzer

* accounts/abi: fixed issues found by fuzzing

* tests/fuzzers/abi: update fuzzers, added repro test

* tests/fuzzers/abi: renamed abi_fuzzer to abifuzzer

* tests/fuzzers/abi: updated abi fuzzer

* tests/fuzzers/abi: updated abi fuzzer

* accounts/abi: minor style fix

* go.mod: added go-fuzz dependency

* tests/fuzzers/abi: updated abi fuzzer

* tests/fuzzers/abi: make linter happy

* tests/fuzzers/abi: make linter happy

* tests/fuzzers/abi: comment out false positives
2020-09-16 13:15:22 +02:00
Marius van der Wijden
d81c9d9b76
accounts/abi/bind/backends: reverted some stylistic changes (#21535) 2020-09-09 13:21:20 +00:00
Osoro Bironga
c5d28f0b27
accounts: abi/bid/backends; cleaned doc errors, camelCase refactors and anonymous variable assignments (#21514)
Co-authored-by: Osoro Bironga <osoro@doctaroo.com>
2020-09-07 13:07:15 +02:00
Fuyang Deng
12d8570322
accounts/abi: fix a bug in getTypeSize method (#21501)
* accounts/abi: fix a bug in getTypeSize method

e.g. for "Tuple[2]" type, the element of the array is a tuple type and the size of the tuple may not be 32.

* accounts/abi: add unit test of getTypeSize method
2020-09-01 07:29:54 +00:00
Marius van der Wijden
92b12ee6c6
accounts/abi/bind/backends: Disallow AdjustTime for non-empty blocks (#21334)
* accounts/abi/bind/backends: Disallow timeshift for non-empty blocks

* accounts/abi/bind/backends: added tests for adjust time

* accounts/abi/bind/simulated: added comments, fixed test for AdjustTime

* accounts/abi/bind/backends: updated comment
2020-08-26 09:37:00 +02:00