Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the custom ContractPool with a global sync.Pool, introduces GetContract/ReturnContract, and updates all call sites to use the new pool API.
- Switched to a global
sync.Pooland removedNewContract/ContractPoolstruct. - Updated EVM methods and tests to use
GetContractanddefer ReturnContract. - Simplified return of leftover gas in
createand removed manual cleanup.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/state_test.go | Switched NewContract to GetContract and added defer ReturnContract |
| eth/tracers/logger/logger_test.go | Updated logger tests to use GetContract/ReturnContract |
| eth/tracers/js/tracer_test.go | Replaced NewContract with GetContract and deferred return in JS tracer tests |
| core/vm/instructions_test.go | Updated NewContract to GetContract and added defer ReturnContract |
| core/vm/evm.go | Replaced all NewContract calls with GetContract and deferred ReturnContract |
| core/vm/contract_pool.go | Added new GetContract/ReturnContract implementation with sync.Pool |
| core/vm/contract.go | Removed old NewContract function |
Comments suppressed due to low confidence (1)
core/vm/contract_pool.go:44
- Exported functions should have a GoDoc comment. Add a comment above
ReturnContractexplaining its behavior, e.g.,// ReturnContract returns a Contract to the pool for reuse.
func ReturnContract(contract *Contract) {
buddh0
approved these changes
Jun 10, 2025
zzzckck
approved these changes
Jun 10, 2025
This was referenced Jun 16, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimize Contract Pool Implementation
Changes
sync.PoolContractPoolstruct and making functions package-levelsync.Poolhandle object lifecycleTechnical Details
sync.Poolfor better performancesync.Poolis thread-safe by designGetContractandReturnContractfunctionsBenefits
sync.PoolBenchmarks