Skip to content

fix(codegen): point //go:linkname at abigen for go-ethereum v1.16+#16

Merged
piotr-roslaniec merged 3 commits into
mainfrom
fix/go-ethereum-1.17-linkname
May 23, 2026
Merged

fix(codegen): point //go:linkname at abigen for go-ethereum v1.16+#16
piotr-roslaniec merged 3 commits into
mainfrom
fix/go-ethereum-1.17-linkname

Conversation

@mswilkison
Copy link
Copy Markdown
Contributor

Summary

go-ethereum v1.16 moved the binding-generation helpers from
`github.com/ethereum/go-ethereum/accounts/abi/bind` to
`github.com/ethereum/go-ethereum/accounts/abi/abigen` and renamed two of them:

Old (v1.15 and earlier, in `bind`) New (v1.16+, in `abigen`)
`bindStructTypeGo` `bindStructType`
`bindTopicTypeGo` `bindTopicType`
`structured` `structured` (unchanged)

`tools/generators/ethereum/contract_parsing.go` reaches into those symbols via `//go:linkname` (signatures use `map[string]struct{}` rather than the package-private `map[string]*tmplStruct`; this works because Go's linker doesn't type-check linkname targets and both value types are pointer-sized in memory).

Pointing the directives at the post-rename names in the post-move package lets the codegen tool link cleanly against go-ethereum v1.16, v1.17, and later. This is needed for tlabs-xyz/keep-core-security#13 (a security PR bumping go-ethereum 1.13.15 → 1.17.3 to clear 5 High CVEs); the Docker build's `make generate` step fails to link without this fix.

Changes

  • `tools/generators/ethereum/contract_parsing.go`: linkname targets updated from `...bind.bindStructTypeGo` etc. → `...abigen.bindStructType` etc. Comments updated. Replaced the unused `bind` blank-import with an `abigen` blank-import so the link target package is brought in.
  • `go.mod`/`go.sum`: bump `github.com/ethereum/go-ethereum` to v1.17.3 so the codegen tool compiles against the post-move package layout.

Verification

  • `go build ./tools/generators/ethereum/...` is clean on this branch.
  • A follow-up keep-core branch (tlabs-xyz/keep-core-security#13) consuming this tag passes its Docker build's `make generate` step locally.

Caveats

  • `//go:linkname` is fragile by design — Go authors don't guarantee the stability of unexported symbols. A longer-term fix would be to either:

    1. switch to the public `abigen.Bind(...)` entrypoint and post-process its output, or
    2. inline the (small) helper bodies into this package and drop the linkname directives entirely.

    This PR keeps the existing approach because the same compatibility hazard already lived in v1.7.0; the rename is the minimum-diff fix needed to unblock the go-ethereum v1.17.3 security bump downstream. A follow-up to remove the linkname approach is worthwhile.

Test plan

  • CI green on this branch (if any)
  • tlabs-xyz/keep-core-security#13 build verification once a new tag is cut
  • After merge, re-tag `v1.7.1-tlabs.1` from `main`

🤖 Generated with Claude Code

mswilkison and others added 3 commits May 22, 2026 21:18
go-ethereum v1.16 moved the contract-binding codegen helpers from
github.com/ethereum/go-ethereum/accounts/abi/bind to
github.com/ethereum/go-ethereum/accounts/abi/abigen, and renamed
bindStructTypeGo -> bindStructType and bindTopicTypeGo -> bindTopicType
(dropping the "Go" suffix). The "structured" helper kept its name.

contract_parsing.go reached into those symbols via //go:linkname and
broke with the keep-core security fork's go-ethereum bump to v1.17.3
(failing the Docker build at `make generate` with undefined references
during cgo link).

Update the linkname targets to point at the new abigen package; bump
the local go.mod's go-ethereum to v1.17.3 so the codegen tool can
actually link against the new symbol layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The go-ethereum v1.17.3 dependency on this branch raises the required
Go version (go.mod 'go 1.24.0'), so the workflows' hardcoded Go 1.22
plus GOTOOLCHAIN=local fails with:

    go: go.mod requires go >= 1.24.0 (running go 1.22.12; GOTOOLCHAIN=local)

Switch to go-version-file: go.mod so the workflows track the module's
declared Go version automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants