Skip to content

chore(crypto): adopt NewKeccakState wrapper + global hasher pool#76

Open
colinkim wants to merge 3 commits into
devfrom
chore/keccak
Open

chore(crypto): adopt NewKeccakState wrapper + global hasher pool#76
colinkim wants to merge 3 commits into
devfrom
chore/keccak

Conversation

@colinkim

Copy link
Copy Markdown
Contributor

Summary

  • Adopt upstream go-ethereum's keccak-related optimizations in a targeted, low-risk way: the crypto.NewKeccakState() wrapper (from #29362) and the global hasher pool (from #31769).
  • Stay behaviour-preserving — no public API signature, hash output, or thread-safety changes. Only the KeccakState allocation pattern changes.
  • Apply a subset of each upstream PR: the NewKeccakState() wrapper from #29362 and the global hasherPool in crypto/crypto.go from #31769, because their current shape diverges from upstream enough that they cannot be applied directly.

Behaviour and compatibility

  • Hash outputs: unchanged.
  • Public API signatures: unchanged.
  • Thread safety: unchanged. sync.Pool is goroutine-safe; hashers are not shared mid-operation across goroutines.
  • golang.org/x/crypto/sha3 imports removed from files where no other sha3 symbol is used.

Test plan

  • make gstable — build succeeds
  • go vet ./... — no new warnings
  • go test ./crypto/...
  • go test ./core/rawdb/... ./core/types/... ./trie/... ./eth/protocols/snap/...
  • go test -bench=BenchmarkKeccak -benchmem ./crypto/... — confirm allocs/op drops for Keccak256 / Keccak256Hash relative to the pre-PR baseline

References

Manually apply the `crypto.NewKeccakState()`wrapper adoption from
ethereum/go-ethereum#29362 — only that single change, not the full PR.
Manually apply the `crypto.NewKeccakState()` wrapper adoption from
ethereum/go-ethereum#31769 in core/types/hashing.go — only that single-file change, not the full PR.
ethereum/go-ethereum#31769 — only the crypto/crypto.go portion,
 not the full PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant