Commit graph

12685 commits

Author SHA1 Message Date
Daniel Liu
146ea8ba78 accounts: EIP-2718: Typed Transaction Envelope + EIP-2930 (#21502) 2025-01-24 16:18:30 +08:00
Daniel Liu
01d3be7eb8 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
2025-01-24 16:18:30 +08:00
Daniel Liu
2ffdb94855 accounts/keystore: remove uneeded syntax (#21921) 2025-01-24 16:18:30 +08:00
Daniel Liu
4e23f7b607 accounts/scwallet: update documentation (#22242) 2025-01-24 16:18:30 +08:00
Daniel Liu
f8c67edb64 accounts/scwallet: use go-ethereum crypto instead of go-ecdh (#22212)
* accounts/scwallet: use go-ethereum crypto instead of go-ecdh

github.com/wsddn/go-ecdh is a wrapper package for ECDH functionality
with any elliptic curve.

Since 'generic' ECDH is not required in accounts/scwallet (the curve is
always secp256k1), we can just use the standard library functionality
and our own crypto libraries to perform ECDH and save a dependency.

* Update accounts/scwallet/securechannel.go

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

* Use the correct key

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:30 +08:00
Daniel Liu
cebdb44051 accounts/abi/bind: fix erroneous test (#22053)
closes #22049
2025-01-24 16:18:30 +08:00
Daniel Liu
f87376535d cmd/abigen: clarify abigen alias flag usage (#21875)
* doc: clarify abigen alias flag usage

update the `abigen --alias` flag help info, give an example to make it more clear

related issue: https://github.com/ethereum/go-ethereum/issues/21846

* Update cmd/abigen/main.go

Co-authored-by: ligi <ligi@ligi.de>

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: ligi <ligi@ligi.de>
2025-01-24 16:18:30 +08:00
Daniel Liu
54e0d6c093 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.
2025-01-24 16:18:30 +08:00
Daniel Liu
fb85aca8d8 accounts/abi/bind: allow specifying signer on transactOpts (#21356) 2025-01-24 16:18:30 +08:00
Daniel Liu
2ff9f336ed core: improve contextual information on core errors (#21869) 2025-01-24 16:18:30 +08:00
Daniel Liu
05e9dc0def accounts/keystore: add missing function doc for SignText (#21914)
Co-authored-by: Pascal Dierich <pascal@pascaldierich.com>
2025-01-24 16:18:30 +08:00
Daniel Liu
ddea01dc9c accounts: fix Ledger Live account derivation path (clef) (#21757)
* signer/core/api: fix derivation of ledger live accounts

For ledger hardware wallets, change account iteration as follows:

- ledger legacy: m/44'/60'/0'/X; for 0<=X<5
- ledger live: m/44'/60'/0'/0/X; for 0<=X<5

- ledger legacy: m/44'/60'/0'/X; for 0<=X<10
- ledger live: m/44'/60'/X'/0/0; for 0<=X<10

Non-ledger derivation is unchanged and remains as:
- non-ledger: m/44'/60'/0'/0/X; for 0<=X<10

* signer/core/api: derive ten default paths for all hardware wallets, plus ten legacy and ten live paths for ledger wallets

* signer/core/api: as .../0'/0/0 already included by default paths, do not include it again with ledger live paths

* accounts, signer: implement path iterators for hd wallets

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-01-24 16:18:30 +08:00
Daniel Liu
25284155d8 accounts: remove redundant conversions and import names (#21903) 2025-01-24 16:18:30 +08:00
Daniel Liu
7f2ae32933 accounts/abi: template: set events Raw field in Parse methods (#21807) 2025-01-24 16:18:30 +08:00
Daniel Liu
c7efbcd9fd accounts/abi/bind: restore error functionality (#21743) 2025-01-24 16:18:30 +08:00
Daniel Liu
3946405983 accounts/usbwallet: fix ledger version check (#21733)
The version check logic did not take into account the second digit (i.e. the '4' in v1.4.0) - this one line patch corrects this.
2025-01-24 16:18:30 +08:00
Daniel Liu
d02ba1db81 accounts/keystore: fix flaky test (#21703)
* accounts/keystore: add timeout to test to prevent failure on travis

The TestWalletNotifications test sporadically fails on travis.
This is because we shutdown the event collection before all events are received.
Adding a small timeout (10 milliseconds) allows the collector to be scheduled
and to consume all pending events before we shut it down.

* accounts/keystore: added newlines back in

* accounts/keystore: properly fix the walletNotifications test
2025-01-24 16:18:30 +08:00
Daniel Liu
d8c9ad3c9f all: replace RWMutex with Mutex in places where RLock is not used (#21622) 2025-01-24 16:18:30 +08:00
Daniel Liu
5b48621c36 accouts, core: fix some comments (#21617) 2025-01-24 16:18:30 +08:00
Daniel Liu
b0063d39b9 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>
2025-01-24 16:18:30 +08:00
Daniel Liu
22df50c77a 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>
2025-01-24 16:18:29 +08:00
Daniel Liu
7c3c703559 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
2025-01-24 16:18:29 +08:00
Daniel Liu
321bcff620 accounts/usbwallet, signer/core: show accounts from ledger legacy derivation paths (#21517)
* accounts/usbwallet, signer/core: un-hide accounts from ledger legacy derivation paths

* Update accounts/usbwallet/wallet.go

* Update signer/core/api.go

* Update signer/core/api.go
2025-01-24 16:18:29 +08:00
Daniel Liu
c9643e9c90 accounts/abi/bind/backends: clean doc errors (#21514) 2025-01-24 16:18:29 +08:00
Daniel Liu
f4feaebb40 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
2025-01-24 16:18:29 +08:00
Daniel Liu
089242bb39 accounts/abi/bind/backends: Disallow AdjustTime for non-empty blocks (#21334) 2025-01-24 16:18:29 +08:00
Daniel Liu
25d42fef2c accounts/abi: make GetType public again (#21157) 2025-01-24 16:18:29 +08:00
Daniel Liu
9c5dff2554 accounts/keystore: fix typo in error message (#21200) 2025-01-24 16:18:29 +08:00
Daniel Liu
593fe53519 internal/ethapi: return revert reason for eth_call (#21083) 2025-01-24 16:18:29 +08:00
Daniel Liu
ef80645f90 accounts/abi/bind: fix test 2025-01-24 16:18:29 +08:00
Daniel Liu
5e3755c46a accounts/keystore, cmd/faucet: return old account to allow unlock (#21173) 2025-01-24 16:18:29 +08:00
Daniel Liu
d918e53c8a acounts/keystore, cmd/faucet: fix faucet double import (#21172) 2025-01-24 16:18:29 +08:00
Daniel Liu
afc814b00d accounts: fix typos in comments (#21118) 2025-01-24 16:18:29 +08:00
Daniel Liu
e28727e2c9 accounts: add blockByNumberNoLock() to avoid double-lock (#20983)
* abi/bind/backends: testcase for double-lock

* accounts: add blockByNumberNoLock to avoid double-lock

* backend/simulated: use stateroot, not blockhash for retrieveing state

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-01-24 16:18:29 +08:00
Daniel Liu
b9bcf17694 accounts/abi: simplify reflection logic (#21058)
* accounts/abi: simplified reflection logic

* accounts/abi: simplified reflection logic

* accounts/abi: removed unpack

* accounts/abi: removed comments

* accounts/abi: removed uneccessary complications

* accounts/abi: minor changes in error messages

* accounts/abi: removed unnused code

* accounts/abi: fixed indexed argument unpacking

* accounts/abi: removed superfluous test cases

This commit removes two test cases. The first one is trivially invalid as we have the same
test cases as passing in packing_test.go L375. The second one passes now,
because we don't need the mapArgNamesToStructFields in unpack_atomic anymore.
Checking for purely underscored arg names generally should not be something we do
as the abi/contract is generally out of the control of the user.

* accounts/abi: removed comments, debug println

* accounts/abi: added commented out code

* accounts/abi: addressed comments

* accounts/abi: remove unnecessary dst.CanSet check

* accounts/abi: added dst.CanSet checks
2025-01-24 16:18:29 +08:00
Daniel Liu
e836f32ba4 accounts/abi: allow overloaded argument names (#21060)
* accounts/abi: allow overloaded argument names

In solidity it is possible to create the following contract:
```
contract Overloader {
    struct F { uint _f; uint __f; uint f; }
    function f(F memory f) public {}
}
```
This however resulted in a panic in the abi package.

* accounts/abi fixed error handling
2025-01-24 16:18:29 +08:00
Daniel Liu
7e3079cedc accounts/abi: move topics to abi package (#21057)
* accounts/abi/bind: added test cases for waitDeployed

* accounts/abi/bind: added test case for boundContract

* accounts/abi/bind: removed unnecessary resolve methods

* accounts/abi: moved topics from /bind to /abi

* accounts/abi/bind: cleaned up format... functions

* accounts/abi: improved log message

* accounts/abi: added type tests

* accounts/abi/bind: remove superfluous template methods
2025-01-24 16:18:29 +08:00
Daniel Liu
f6b6a24093 account/abi: remove superfluous type checking (#21022)
* accounts/abi: added getType func to Type struct

* accounts/abi: fixed tuple unpack

* accounts/abi: removed type.Type

* accounts/abi: added comment

* accounts/abi: removed unused types

* accounts/abi: removed superfluous declarations

* accounts/abi: typo
2025-01-24 16:18:29 +08:00
Daniel Liu
dabda3335a accounts/abi: removed Kind from Type struct (#21009)
* accounts/abi: removed Kind from Type struct

* accounts/abi: removed unused code
2025-01-24 16:18:29 +08:00
Daniel Liu
bca20a692a accounts/abi: added abi test cases, minor bug fixes (#20903)
* accounts/abi: added documentation

* accounts/abi: reduced usage of arguments.LengthNonIndexed

* accounts/abi: simplified reflection logic

* accounts/abi: moved testjson data into global declaration

* accounts/abi: removed duplicate test cases

* accounts/abi: reworked abi tests

* accounts/abi: added more tests for abi packing

* accounts/abi/bind: refactored base tests

* accounts/abi: run pack tests as subtests

* accounts/abi: removed duplicate tests

* accounts/abi: removed unnused arguments.LengthNonIndexed

Due to refactors to the code, we do not need the arguments.LengthNonIndexed function anymore.
You can still get the length by calling len(arguments.NonIndexed())

* accounts/abi: added type test

* accounts/abi: modified unpack test to pack test

* accounts/abi: length check on arrayTy

* accounts/abi: test invalid abi

* accounts/abi: fixed rebase error

* accounts/abi: fixed rebase errors

* accounts/abi: removed unused definition

* accounts/abi: merged packing/unpacking tests

* accounts/abi: fixed [][][32]bytes encoding

* accounts/abi: added tuple test cases

* accounts/abi: renamed getMockLog -> newMockLog

* accounts/abi: removed duplicate test

* accounts/abi: bools -> booleans
2025-01-24 16:18:29 +08:00
Daniel Liu
0d1cd42dc2 accounts/keystore: fix double import race (#20915)
* accounts/keystore: fix race in Import/ImportECDSA

* accounts/keystore: added import/export tests

* cmd/geth: improved TestAccountImport test

* accounts/keystore: added import/export tests

* accounts/keystore: fixed naming

* accounts/keystore: fixed typo

* accounts/keystore: use mutex instead of rwmutex

* accounts: use errors instead of fmt
2025-01-24 16:18:29 +08:00
Daniel Liu
91f6259135 accounts/abi: remove function Unpack2 (#20830) 2025-01-24 16:18:29 +08:00
Daniel Liu
56f9c17817 accounts/abi: Prevent recalculation of internal fields (#20895)
* accounts/abi: prevent recalculation of ID, Sig and String

* accounts/abi: fixed unpacking of no values

* accounts/abi: multiple fixes to arguments

* accounts/abi: refactored methodName and eventName

This commit moves the complicated logic of how we assign method names
and event names if they already exist into their own functions for
better readability.

* accounts/abi: prevent recalculation of internal

In this commit, I changed the way we calculate the string
representations, sig representations and the id's of methods. Before
that these fields would be recalculated everytime someone called .Sig()
.String() or .ID() on a method or an event.

Additionally this commit fixes issue #20856 as we assign names to inputs
with no name (input with name "" becomes "arg0")

* accounts/abi: added unnamed event params test

* accounts/abi: fixed rebasing errors in method sig

* accounts/abi: fixed rebasing errors in method sig

* accounts/abi: addressed comments

* accounts/abi: added FunctionType enumeration

* accounts/abi/bind: added test for unnamed arguments

* accounts/abi: improved readability in NewMethod, nitpicks

* accounts/abi: method/eventName -> overloadedMethodName
2025-01-24 16:18:29 +08:00
Daniel Liu
fd53a433aa accounts/abi: implement new fallback functions (#20764)
* accounts/abi: implement new fackball functions

In Solidity v0.6.0, the original fallback is separated
into two different sub types: fallback and receive.

This PR addes the support for parsing new format abi
and the relevant abigen functionalities.

* accounts/abi: fix unit tests

* accounts/abi: minor fixes

* accounts/abi, mobile: support jave binding

* accounts/abi: address marius's comment

* accounts/abi: Work around the uin64 conversion issue

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:29 +08:00
Daniel Liu
296c052c02 accounts/abi/bind: fixed erroneous filtering of negative ints (#20865)
* accounts/abi/bind: fixed erroneous packing of negative ints

* accounts/abi/bind: added test cases for negative ints in topics

* accounts/abi/bind: fixed genIntType for go 1.12

* accounts/abi: minor  nitpick
2025-01-24 16:18:29 +08:00
Daniel Liu
f8b85afec5 accounts/abi/bind: Refactored topics (#20851)
* accounts/abi/bind: refactored topics

* accounts/abi/bind: use store function to remove code duplication

* accounts/abi/bind: removed unused type defs

* accounts/abi/bind: error on tuples in topics

* Cosmetic changes to restart travis build

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
2025-01-24 16:18:29 +08:00
Daniel Liu
601d1c80ea accounts/scwallet: fix unnecessary use of fmt.Sprint 2025-01-24 16:18:29 +08:00
Daniel Liu
6259ce565c accounts/abi faster unpacking of int256 (#20850) 2025-01-24 16:18:29 +08:00
Daniel Liu
219b5ef883 accounts: add walletsNoLock to avoid double read lock (#20655) 2025-01-24 16:18:29 +08:00
Daniel Liu
164d929307 accounts/abi/bind/backends: add support for historical state (#20644) 2025-01-24 16:18:29 +08:00