chore: split root and ops gen contract package#966
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR separates the EVM “contract operations” helper code into two distinct packages: a restored runtime package under chain/evm/operations/contract (to preserve downstream compatibility during migration) and a generator-owned package under tools/operations-gen/contract. It also fixes EVM read-operation codegen for Solidity methods with multiple named return values by reusing abigen’s generated return structs instead of re-declaring duplicates.
Changes:
- Moved generator-consumed contract helpers to
tools/operations-gen/contractand updated codegen templates + golden files to import that package. - Fixed read op codegen for multi-return named outputs by referencing
gobindings.<MethodName>rather than generating a new<MethodName>Resulttype. - Simplified generated deploy/write operations by removing default no-op
Validatefunctions; expanded/updated module dependencies fortools/operations-gen.
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/operations-gen/testdata/evm/rbac_timelock.golden.go | Updates generated output to import tools/operations-gen/contract and removes no-op Validate. |
| tools/operations-gen/testdata/evm/many_chain_multi_sig.golden.go | Updates generated output to import tools/operations-gen/contract and removes no-op Validate. |
| tools/operations-gen/testdata/evm/link_token.golden.go | Updates generated output to import tools/operations-gen/contract and removes no-op Validate. |
| tools/operations-gen/internal/families/evm/contract.go | Skips generating local multi-return structs when all return params are named. |
| tools/operations-gen/internal/families/evm/codegen.go | Uses gobindings.<MethodName> as return type for multi-return named outputs. |
| tools/operations-gen/internal/families/evm/abi.go | Tracks AllReturnParamsNamed during ABI parsing. |
| tools/operations-gen/go.sum | Records expanded dependency graph for the tools module. |
| tools/operations-gen/go.mod | Updates Go/tool deps and adds required module dependencies for new contract helpers. |
| tools/operations-gen/generate/templates/evm/operations.tmpl | Switches generated imports to tools/operations-gen/contract and removes no-op Validate. |
| tools/operations-gen/contract/write.go | Adds generator-owned write helpers (incl. retries, role/owner gating, batch builder). |
| tools/operations-gen/contract/write_test.go | Adds unit tests for generator-owned write helpers. |
| tools/operations-gen/contract/read.go | Adds generator-owned read operation wrapper. |
| tools/operations-gen/contract/read_test.go | Adds unit tests for generator-owned read wrapper. |
| tools/operations-gen/contract/mocks/mock_access_control_contract.go | Adds mock for AccessControlContract (for generator-owned helpers). |
| tools/operations-gen/contract/function.go | Defines generator-owned FunctionInput. |
| tools/operations-gen/contract/function_test.go | Provides test contract + rpc error helpers for generator-owned contract tests. |
| tools/operations-gen/contract/deployment_test.go | Adds unit tests for generator-owned deploy helpers. |
| tools/operations-gen/contract/deploy.go | Adds generator-owned deploy helpers and supporting utilities. |
| chain/evm/operations/contract/write.go | Restores/adjusts runtime write op API to bind contracts by address (NewContract) and adds chain/address validation. |
| chain/evm/operations/contract/write_test.go | Updates tests for runtime write op API and removes HasRole/RetryContractCall tests. |
| chain/evm/operations/contract/read.go | Restores/adjusts runtime read op API to bind contracts by address (NewContract) and adds chain/address validation. |
| chain/evm/operations/contract/read_test.go | Updates tests for runtime read op API and adds selector/address validation cases. |
| chain/evm/operations/contract/function.go | Expands runtime FunctionInput to include contract address + chain selector. |
| chain/evm/operations/contract/function_test.go | Updates test contract constructor signature to match NewContract pattern. |
| chain/evm/operations/contract/deployment_test.go | Updates runtime deploy tests to include chain selector input validation. |
| chain/evm/operations/contract/deploy.go | Adds chain selector into runtime deploy input/output and validates selector match. |
| .mockery.yml | Redirects mock output dir for AccessControlContract mocks (but package target needs updating). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|


Summary
chain/evm/operations/contractpackage to pre ops-gen rework state (2194dcd): this is meant to be temporary to avoid break changes while downstream user migrate to the new tool (e.g. https://github.com/smartcontractkit/chainlink-ccip/blob/96113614447dbaebf9a08f98811caf7f5fcb7120/chains/evm/deployment/v2_0_0/operations/committee_verifier/committee_verifier.go). The updated package has been moved into a separateoperations2package.Validatefunction which was unused.