Skip to content

[CLD-1777]: feat(operations-gen): add evm support#910

Merged
graham-chainlink merged 1 commit intomainfrom
ggoh/cld-1777/evm-support-operations-gen
Apr 13, 2026
Merged

[CLD-1777]: feat(operations-gen): add evm support#910
graham-chainlink merged 1 commit intomainfrom
ggoh/cld-1777/evm-support-operations-gen

Conversation

@graham-chainlink
Copy link
Copy Markdown
Collaborator

@graham-chainlink graham-chainlink commented Apr 3, 2026

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

⚠️ No Changeset found

Latest commit: 663feeb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Collaborator Author

@graham-chainlink graham-chainlink Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@graham-chainlink graham-chainlink changed the title feat(operations-gen): add evm support [CLD-1777]: feat(operations-gen): add evm support Apr 3, 2026
@graham-chainlink graham-chainlink marked this pull request as ready for review April 3, 2026 02:28
@graham-chainlink graham-chainlink requested a review from a team as a code owner April 3, 2026 02:28
Copilot AI review requested due to automatic review settings April 3, 2026 02:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 evm chain-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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 3df479d to 0d43e7b Compare April 3, 2026 02:49
Copy link
Copy Markdown
Collaborator

@jkongie jkongie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add more documentation to this

Comment on lines +29 to +33
input:
base_path: "." # Directory containing abi/ and bytecode/ subdirectories

output:
base_path: "." # Directory where generated operations/ folders are written
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we always assume that the contracts will be in a single base path?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

@graham-chainlink graham-chainlink Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, not a big lift, i can do that for the extra flexibility

@graham-chainlink
Copy link
Copy Markdown
Collaborator Author

graham-chainlink commented Apr 7, 2026

We should add more documentation to this

@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.

Copilot AI review requested due to automatic review settings April 7, 2026 07:30
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 0d43e7b to 8a090ef Compare April 7, 2026 07:30
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch 2 times, most recently from 340cea6 to 4924b93 Compare April 7, 2026 07:32
desc: Generate mocks for interfaces
cmds:
- mockery

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed per discussion as taskfile is more of a repo wide command

@graham-chainlink graham-chainlink requested a review from jkongie April 7, 2026 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:operations was removed, but tools/operations-gen/README.md still documents task generate:operations .... This will break the documented workflow; either re-add an operations task here (wrapping go 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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 4924b93 to e63b65b Compare April 7, 2026 11:40
Copilot AI review requested due to automatic review settings April 8, 2026 14:43
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from e63b65b to e6bcc9a Compare April 8, 2026 14:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:operations task entirely. If contributors rely on task 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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from e6bcc9a to e94ae22 Compare April 8, 2026 15:02
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the name of this field.

  1. skipping both bytecode and deploy under no_deployment could be considered magic. Should this perhaps be split into two configurations
  2. I think using a word like omit_ is better than no_

Copy link
Copy Markdown
Collaborator Author

@graham-chainlink graham-chainlink Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI review requested due to automatic review settings April 13, 2026 03:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 3e98b36 to 8b7d364 Compare April 13, 2026 03:48
Copilot AI review requested due to automatic review settings April 13, 2026 04:18
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 8b7d364 to 1c9fe4c Compare April 13, 2026 04:18
functions:
- name: transfer
access: owner
access: public
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like deploy link token ABI doesnt support owner method , so changing this to public

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:operations Taskfile 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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 1c9fe4c to c142d01 Compare April 13, 2026 04:32
type {{.Name}} struct {
{{- range .Fields}}
{{.GoName}} {{.GoType}}
{{.GoName}} {{.GoType}} `json:"{{.JSONTag}}"`
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abi field name can be _to which is not exported in go, so we want to differentiate between go and json field name.

Copilot AI review requested due to automatic review settings April 13, 2026 05:02
@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from c142d01 to 7ec42ee Compare April 13, 2026 05:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:operations task 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 via task.
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 that contracts is non-empty). This can lead to silent no-op runs or unhelpful errors as the schema evolves. Consider validating version against supported values and failing fast when contracts is 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.

@graham-chainlink graham-chainlink force-pushed the ggoh/cld-1777/evm-support-operations-gen branch from 7ec42ee to 663feeb Compare April 13, 2026 05:18
@cl-sonarqube-production
Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@graham-chainlink graham-chainlink added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit 4e3e764 Apr 13, 2026
23 of 24 checks passed
@graham-chainlink graham-chainlink deleted the ggoh/cld-1777/evm-support-operations-gen branch April 13, 2026 08:02
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.

3 participants