go-ethereum/accounts
Vadim Tertilov 289826fefb
Some checks are pending
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
cmd/abigen/v2: add package-level errors (#34076)
# Summary

Replaces the inline `errors.New("event signature mismatch")` in
generated `UnpackXxxEvent` methods with per-event package-level sentinel
errors (e.g. `ErrTransferSignatureMismatch`,
`ErrApprovalSignatureMismatch`), allowing callers to reliably
distinguish a topic mismatch from a genuine decoding failure via
`errors.Is`.

Each event gets its own sentinel, generated via the abigen template:

```go
var ErrTransferSignatureMismatch = errors.New("event signature mismatch")
```

This scoping is intentional — it allows callers to be precise about
*which* event was mismatched, which is useful when routing logs across
multiple unpackers.

# Motivation
Previously, all errors returned from `UnpackXxxEvent` were
indistinguishable without string matching. This is especially
problematic when processing logs sourced from `eth_getBlockReceipts`,
where a caller receives the full set of logs for a block across all
contracts and event types. In that context, a signature mismatch is
expected and should be skipped, while any other error (malformed data,
topic parsing failure) indicates something is genuinely wrong and should
halt execution:

```go
for _, log := range blockLogs {
    event, err := contract.UnpackTransferEvent(log)
    if errors.Is(err, gen.ErrTransferSignatureMismatch) {
        continue // not our event, expected
    }
    if err != nil {
        return fmt.Errorf("unexpected decode failure: %w", err) // alert
    }
    // process event
}
```

**Changes:**
- `abigen` template: generates a `ErrXxxSignatureMismatch` sentinel per
event and returns it on topic mismatch instead of an inline error
- Existing generated bindings & testdata: regenerated to reflect the
update

Implements #34075
2026-04-13 14:42:34 +02:00
..
abi cmd/abigen/v2: add package-level errors (#34076) 2026-04-13 14:42:34 +02:00
external all: implement eip-7702 set code tx (#30078) 2024-12-16 11:29:37 +01:00
keystore accounts/keystore: fix flaky TestUpdatedKeyfileContents (#34084) 2026-04-13 14:10:56 +02:00
scwallet accounts/scwallet: fix panic in decryptAPDU (#33606) 2026-01-20 12:04:23 +01:00
usbwallet accounts/usbwallet: add support for Ledger Nano Gen5 (#33297) 2026-02-03 13:11:47 +01:00
accounts.go crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
accounts_test.go accounts: run tests in parallel (#28544) 2023-12-04 14:55:06 +01:00
errors.go accounts: fix typo in comments (#24805) 2022-05-03 08:49:41 +02:00
hd.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
hd_test.go accounts: run tests in parallel (#28544) 2023-12-04 14:55:06 +01:00
manager.go accounts: fix data race when closing manager (#31982) 2025-06-17 14:44:51 +02:00
sort.go accounts, console: frendly card errors, support pin unblock 2019-04-08 13:19:37 +02:00
url.go build: upgrade to go 1.19 (#25726) 2022-09-10 13:25:40 +02:00
url_test.go accounts: run tests in parallel (#28544) 2023-12-04 14:55:06 +01:00