Commit graph

119 commits

Author SHA1 Message Date
Daniel Liu
b4cbf663a7
accounts/keystore: fix panic in decryptPreSaleKey #33602 (#1951)
Validate ciphertext length in decryptPreSaleKey, preventing runtime
panics on invalid input.

Co-authored-by: DeFi Junkie <deffie.jnkiee@gmail.com>
2026-01-19 12:15:03 +05:30
wit liu
ea3a55aef4
all: fix invalid directive syntax for golangci-lint nolint (#1799) 2025-12-08 13:02:54 +05:30
Daniel Liu
ec08863ba0
all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
wit liu
ea179d287c
accounts/keystore: clear decrypted key after use#33090 (#1790) 2025-11-24 10:55:09 +05:30
wit liu
7c5d2a45da
accounts/keystore: use ticker to avoid timer allocations #32732 (#1592) 2025-10-08 12:50:48 +08:00
wit liu
09b6622165
accounts/keystore: use runtime.AddCleanup #32610 (#1580)
Co-authored-by: cui <cuiweixie@gmail.com>
2025-10-08 12:29:03 +08:00
Daniel Liu
9b189e1ea3
accounts/abi, accounts/keystore: use reflect.TypeFor #32323 (#1428)
Co-authored-by: cui <cuiweixie@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-06 17:01:22 +08:00
Daniel Liu
61fcd420b3
accounts/keystore: update links to documenation #32194 (#1425) 2025-09-03 15:50:18 +08:00
Daniel Liu
05a9e91898
cmd/abigen, accounts/abi/bind: implement abigen version 2 #31379 (#1416)
This PR implements a new version of the abigen utility (v2) which exists
along with the pre-existing v1 version.

Abigen is a utility command provided by go-ethereum that, given a
solidity contract ABI definition, will generate Go code to transact/call
the contract methods, converting the method parameters/results and
structures defined in the contract into corresponding Go types. This is
useful for preventing the need to write custom boilerplate code for
contract interactions.

Methods in the generated bindings perform encoding between Go types and
Solidity ABI-encoded packed bytecode, as well as some action (e.g.
`eth_call` or creating and submitting a transaction). This limits the
flexibility of how the generated bindings can be used, and prevents
easily adding new functionality, as it will make the generated bindings
larger for each feature added.

Abigen v2 was conceived of by the observation that the only
functionality that generated Go bindings ought to perform is conversion
between Go types and ABI-encoded packed data. Go-ethereum already
provides various APIs which in conjunction with conversion methods
generated in v2 bindings can cover all functionality currently provided
by v1, and facilitate all other previously-desired use-cases.

To generate contract bindings using abigen v2, invoke the `abigen`
command with the `--v2` flag. The functionality of all other flags is
preserved between the v2 and v1 versions.

The execution of `abigen --v2` generates Go code containing methods
which convert between Go types and corresponding ABI-encoded data
expected by the contract. For each input-accepting contract method and
the constructor, a "packing" method is generated in the binding which
converts from Go types to the corresponding packed solidity expected by
the contract. If a method returns output, an "unpacking" method is
generated to convert this output from ABI-encoded data to the
corresponding Go types.

For contracts which emit events, an unpacking method is defined for each
event to unpack the corresponding raw log to the Go type that it
represents.

Likewise, where custom errors are defined by contracts, an unpack method
is generated to unpack raw error data into a Go type.

For a smooth user-experience, abigen v2 comes with a number of utility
functions to be used in conjunction with the generated bindings for
performing common contract interaction use-cases. These include:

* filtering for historical logs of a given topic
* watching the chain for emission of logs with a given topic
* contract deployment methods
* Call/Transact methods

https://geth.ethereum.org will be updated to include a new tutorial page
for abigen v2 with full code examples. The page currently exists in a
PR: https://github.com/ethereum/go-ethereum/pull/31390 .

There are also extensive examples of interactions with contract bindings
in [test
cases](cc855c7ede/accounts/abi/bind/v2/lib_test.go)
provided with this PR.

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-09-03 15:47:12 +08:00
Daniel Liu
0cbaccd106 accounts/keystore: simplify tests using t.TempDir() (#30150) 2025-01-24 16:54:12 +08:00
Daniel Liu
62895df693 accounts/keystore: use t.TempDir in test (#30052) 2025-01-24 16:54:12 +08:00
Daniel Liu
643c715b43 accounts: fix TestUpdateKeyfileContents (#29867)
Create the directory before NewKeyStore. This ensures the watcher successfully starts on
the first attempt, and waitWatcherStart functions as intended.
2025-01-24 16:54:12 +08:00
Daniel Liu
ef71887d7a accounts, cmd/geth, core: close opened files (#29598)
* fix: open file used up but not closed

* feat: more same case

* feat: accept conversation
2025-01-24 16:54:12 +08:00
Daniel Liu
733a5fc193 accounts: fix mismatched names in comments (#29348) 2025-01-24 16:54:12 +08:00
Daniel Liu
dfc0f112b8 accounts/keystore: use min/max/clear from go1.21 (#29307) 2025-01-24 16:54:12 +08:00
Daniel Liu
888963c6ff accounts: remove deprecated function NewPlaintextKeyStore (#29171) 2025-01-24 16:54:12 +08:00
Daniel Liu
0e7679dc6a accounts,signer: fix typos in comments (#28730) 2025-01-24 16:54:12 +08:00
Daniel Liu
4a54407eb9 accounts: run tests in parallel (#28544) 2025-01-24 16:54:12 +08:00
Daniel Liu
f804203609 accounts/keystore: speed up tests (#28461) 2025-01-24 16:54:12 +08:00
Daniel Liu
ccda15ef5d accounts, cmd: fix typos (#28526) 2025-01-24 16:54:12 +08:00
Daniel Liu
5081ad72f5 accounts: move fuzzers into native packages (#28467) 2025-01-24 16:54:12 +08:00
Daniel Liu
3e880ef27d cmd/clef: suppress fsnotify error if keydir not exists (#28160)
As the keydir will be automatically created after an account is created, no error message if the watcher is failed.
2025-01-24 16:54:12 +08:00
Daniel Liu
3bce105c95 accounts: use atomic type (#27857) 2025-01-24 16:54:12 +08:00
Daniel Liu
f365434a0c accounts/keystore: use slices package for sorting (#27485)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-01-24 16:54:12 +08:00
Daniel Liu
a57f3583fc accounts/keystore: handle error for invalid key in DecryptKey (#27432)
Co-authored-by: KAI <kaili@coinsummer.io>
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-01-24 16:54:12 +08:00
Daniel Liu
d4bf06d689 accounts: replace noarg fmt.Errorf with errors.New (#27331)
* accounts: replace noarg fmt.Errorf with errors.New

Signed-off-by: jsvisa <delweng@gmail.com>

* accounts: go autoimport

Signed-off-by: jsvisa <delweng@gmail.com>

---------

Signed-off-by: jsvisa <delweng@gmail.com>
2025-01-24 16:54:12 +08:00
Daniel Liu
3d90cf7de2 accounts/keystore: remove deprecated uses of math.rand (#26710) 2025-01-24 16:54:11 +08:00
Daniel Liu
4e951ed8fe all: use github.com/deckarep/golang-set/v2 (generic set) (#26159) 2025-01-24 16:54:11 +08:00
Daniel Liu
4081ed926a accounts/keystore: replace inotify with fsnotify (#26176) 2025-01-24 16:54:11 +08:00
Daniel Liu
a79d2a2ed3 accounts/keystore: faster tests (#25827)
This PR removes some optimistic tests -- a'la "do something,
wait a while, and hope it has trickled through and continue" -- and
instead uses some introspection to ensure that prerequisites are met.
2025-01-24 16:54:11 +08:00
Daniel Liu
c046f36afd accounts: fix some typos (#25551) 2025-01-24 16:54:11 +08:00
Daniel Liu
78a35f1dc3 accounts: lint whitespace (#25312) 2025-01-24 16:54:11 +08:00
Daniel Liu
9dda5b9819 accounts: more linters (#24783) 2025-01-24 16:54:11 +08:00
Daniel Liu
5b10b2441c all: use T.TempDir to create temporary test directories (#24633) 2025-01-24 16:54:08 +08:00
Daniel Liu
bcae4205e4 accounts/keystore: fix flaky tests (#23599)
* ethclient/gethclient: fix flaky test (due to map key ordering)

* accounts/keystore: fix test failing due to rand collision due to low time resolution on windows
2025-01-24 16:18:30 +08:00
Daniel Liu
83b7c0eacb accounts/keystore: add go:build lines (#23468) 2025-01-24 16:18:30 +08:00
Daniel Liu
c75ba99267 accounts/keystore: use github.com/google/uuid (#22217)
This replaces the github.com/pborman/uuid dependency with
github.com/google/uuid because the former is only a wrapper for
the latter (since v1.0.0).

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-01-24 16:18:30 +08:00
Daniel Liu
146ea8ba78 accounts: EIP-2718: Typed Transaction Envelope + EIP-2930 (#21502) 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
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
25284155d8 accounts: remove redundant conversions and import names (#21903) 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
9c5dff2554 accounts/keystore: fix typo in error message (#21200) 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
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
833c851361 accounts/keystore: fix staticcheck warnings (#20373)
* accounts/keystore: fix staticcheck warnings

* review feedback
2025-01-24 16:18:29 +08:00
Daniel Liu
e90df44b43 accounts: replace passPHRASE with passWORD in any user interactions (#19932) 2025-01-24 16:18:29 +08:00
Daniel Liu
07ebb5ef12 accounts/keystore: fix #19707, avoid keyword as variable name (#19731) 2025-01-24 16:18:29 +08:00