[CLD-1777]: feat(operations-gen): add evm support#910
Conversation
|
There was a problem hiding this comment.
file mainly copied from https://github.com/smartcontractkit/chainlink-ccip/blob/main/chains/evm/cmd/operations-gen/main.go and adapted to the new design and added tests.
I will update the ported code in chainlink-ccip to point to this one when this PR is merged.
There was a problem hiding this comment.
Pull request overview
Adds EVM support to the tools/operations-gen CLI so it can generate type-safe Go operation wrappers from Solidity ABIs/bytecode, using an EVM-specific handler and template.
Changes:
- Registers the
evmchain-family handler and introduces EVM extraction/generation logic. - Adds an EVM operations template plus supporting utilities (type mapping, ABI parsing, overload handling).
- Adds documentation and unit tests for key EVM helpers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tools/operations-gen/README.md | Documents the CLI, config schema, and input/output layouts for EVM generation. |
| tools/operations-gen/main.go | Enables EVM by registering evmHandler in chainFamilies. |
| tools/operations-gen/evm.go | Implements EVM handler: config decoding, ABI/bytecode reading, ABI parsing, template data preparation, and codegen helpers. |
| tools/operations-gen/evm_test.go | Adds unit tests for EVM naming/type mapping utilities and overload handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3df479d to
0d43e7b
Compare
jkongie
left a comment
There was a problem hiding this comment.
We should add more documentation to this
| input: | ||
| base_path: "." # Directory containing abi/ and bytecode/ subdirectories | ||
|
|
||
| output: | ||
| base_path: "." # Directory where generated operations/ folders are written |
There was a problem hiding this comment.
Can we always assume that the contracts will be in a single base path?
There was a problem hiding this comment.
hmmm, hard to say, but users can move them into a single base path if it is not? Or do you think is it worth supporting multiple base path? I was also thinking to avoid many breaking user facing changes with the existing cli too.
There was a problem hiding this comment.
I'm not concerned about breaking changes so much. We are providing this as a feature for the teams that want to use it. CCIP can choose to switch to it or continue to use their own.
I would like to make sure this is flexible though. I could see a case where users do not put all their abis and byte code in a single path. Maybe I'm over thinking this though
There was a problem hiding this comment.
Cool, not a big lift, i can do that for the extra flexibility
@jkongie do you think the current readme is lacking any other information? I also plan to add something to the https://docs.cld.cldev.sh/ too. |
0d43e7b to
8a090ef
Compare
340cea6 to
4924b93
Compare
| desc: Generate mocks for interfaces | ||
| cmds: | ||
| - mockery | ||
|
|
There was a problem hiding this comment.
removed per discussion as taskfile is more of a repo wide command
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
taskfiles/generate/Taskfile.yml:12
generate:operationswas removed, buttools/operations-gen/README.mdstill documentstask generate:operations .... This will break the documented workflow; either re-add anoperationstask here (wrappinggo run ./tools/operations-gen -config ...) or update the README to match the new invocation.
tasks:
mocks:
desc: Generate mocks for interfaces
cmds:
- mockery
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4924b93 to
e63b65b
Compare
e63b65b to
e6bcc9a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
taskfiles/generate/Taskfile.yml:12
- This change removes the
generate:operationstask entirely. If contributors rely ontask generate:operations CONFIG=...(especially since the task handled resolving relative CONFIG paths from the repo root), this is a workflow regression and it’s not mentioned in the PR description. Consider keeping the task (or replacing it with an equivalent) so there remains a documented, one-command way to run operations-gen from the repo root.
tasks:
mocks:
desc: Generate mocks for interfaces
cmds:
- mockery
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e6bcc9a to
e94ae22
Compare
tools/operations-gen/README.md
Outdated
| version: "1.6.0" | ||
| package_name: fee_quoter # Optional: override default package name | ||
| abi_file: "fee_quoter.json" # Optional: override default ABI filename | ||
| no_deployment: false # Optional: skip bytecode and Deploy operation |
There was a problem hiding this comment.
I don't love the name of this field.
- skipping both bytecode and deploy under no_deployment could be considered magic. Should this perhaps be split into two configurations
- I think using a word like
omit_is better thanno_
There was a problem hiding this comment.
but if no_deployment is false, in order to generate the Deploy code eg
var Deploy = contract.NewDeploy(contract.DeployParams[ConstructorArgs]{
Name: "link-token:deploy",
Version: Version,
Description: "Deploys the LinkToken contract",
ContractMetadata: &bind.MetaData{
ABI: LinkTokenABI,
Bin: LinkTokenBin,
},
BytecodeByTypeAndVersion: map[string]contract.Bytecode{
cldf_deployment.NewTypeAndVersion(ContractType, *Version).String(): {
EVM: common.FromHex(LinkTokenBin),
},
},
Validate: func(ConstructorArgs) error { return nil },
})If requires the Bin LinkTokenBin ,and LinkTokenBin is only used for this purpose, so if no_deployment is true, we dont need the LinkTokenBin, thats why they are coupled. So i was thinking to keep it as single flag instead?
I will rename it to omit_deploy
e94ae22 to
3e98b36
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e98b36 to
8b7d364
Compare
8b7d364 to
1c9fe4c
Compare
| functions: | ||
| - name: transfer | ||
| access: owner | ||
| access: public |
There was a problem hiding this comment.
Seems like deploy link token ABI doesnt support owner method , so changing this to public
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (2)
tools/operations-gen/templates/evm/operations.tmpl:96
- ConstructorArgs fields are generated without JSON tags, while other generated argument structs now include tags derived from ABI parameter names. Since DeployInput.Args is unmarshaled from JSON, this makes constructor args inconsistent and can break CLI usage (e.g., ABI params like "_to" would require JSON key "To" instead of "_to"). Consider adding
json:"{{.JSONTag}}"tags (conditionally) to ConstructorArgs fields, similar to ArgStructs/StructDefs, so JSON keys can match ABI parameter names.
type ConstructorArgs struct {
{{- range .Constructor.Parameters}}
{{.GoName}} {{.GoType}}
{{- end}}
}
taskfiles/generate/Taskfile.yml:12
- This change removes the
generate:operationsTaskfile task entirely. Since the PR is adding/enabling operations-gen EVM support, dropping the task may be an unintended breaking change for developer workflows unless there’s a replacement entry point documented elsewhere. If the removal is intentional, consider adding an alternative task or updating docs to point to the preferred invocation.
tasks:
mocks:
desc: Generate mocks for interfaces
cmds:
- mockery
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1c9fe4c to
c142d01
Compare
| type {{.Name}} struct { | ||
| {{- range .Fields}} | ||
| {{.GoName}} {{.GoType}} | ||
| {{.GoName}} {{.GoType}} `json:"{{.JSONTag}}"` |
There was a problem hiding this comment.
abi field name can be _to which is not exported in go, so we want to differentiate between go and json field name.
c142d01 to
7ec42ee
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (2)
taskfiles/generate/Taskfile.yml:12
- This change removes the
generate:operationstask entirely. If this Taskfile target is part of the expected developer workflow/CI docs, consider keeping it (or replacing it with an equivalent) so generation can still be invoked consistently viatask.
tasks:
mocks:
desc: Generate mocks for interfaces
cmds:
- mockery
tools/operations-gen/main.go:47
- The config schema version is documented as required, but the CLI never validates
config.Version(or thatcontractsis non-empty). This can lead to silent no-op runs or unhelpful errors as the schema evolves. Consider validatingversionagainst supported values and failing fast whencontractsis missing/empty.
var config core.Config
if err = yaml.Unmarshal(configData, &config); err != nil {
fmt.Fprintf(os.Stderr, "Error parsing config: %v\n", err)
os.Exit(1)
}
chainFamily := config.ChainFamily
if chainFamily == "" {
chainFamily = "evm"
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add evm support for the operations-gen cli, basically ported the code from https://github.com/smartcontractkit/chainlink-ccip/blob/main/chains/evm/cmd/operations-gen/main.go and adapted it to the new design JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1777
7ec42ee to
663feeb
Compare
|


Add evm support for the operations-gen cli, ported the code from https://github.com/smartcontractkit/chainlink-ccip/blob/main/chains/evm/cmd/operations-gen/main.go, improved and adapted it to the new design
I have follow up PR adding some golden tests - #920
JIRA: https://smartcontract-it.atlassian.net/browse/CLD-1777