Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b5d368d
Add TeeEnabled to template generator, and add a new requirements call…
nolag Apr 8, 2026
660e58a
Add region
nolag Apr 22, 2026
4294618
Requirements selecting runner
nolag Apr 22, 2026
0a4ed20
Merge branch 'main' into rtinianov_teeWorkflows
nolag Apr 23, 2026
a869861
update proto and fix requirement not met test
nolag Apr 24, 2026
16dba12
Update proto, allow individual triggers to choose where to run
nolag Apr 27, 2026
cf01251
Add max time for requirements selection
nolag Apr 27, 2026
b8745af
Use subscription for the trigger requirement
nolag Apr 27, 2026
2b8b244
Main module satisfies requirements
nolag Apr 28, 2026
58ec02d
remove unused hook from module, the selecting one is now responsible …
nolag Apr 29, 2026
937bc20
Hook to ask implementation to determine if it supports regions
nolag Apr 30, 2026
e578b91
Update protos to use full TEE requirement and not use bytes for the e…
nolag Apr 30, 2026
98d72c5
Send full requirements to modules that accept them
nolag Apr 30, 2026
8e8598d
Regions with any is allowed too, and let the TEE say everything it is…
nolag May 1, 2026
f0dfd6b
Update protos for unknown TEE Type
nolag May 4, 2026
b213255
Merge branch 'main' into rtinianov_teeWorkflows
nolag May 12, 2026
3860740
Fix misc tests that were fixed on a different branch, update to use p…
nolag May 20, 2026
179ae0e
Merge branch 'main' into rtinianov_teeWorkflows
nolag May 20, 2026
e612a5e
Remove file left from prior genreation and update to use the one from…
nolag May 20, 2026
7236bc1
Merge branch 'main' into rtinianov_teeWorkflows
nolag May 20, 2026
d826341
AI feedback addressed
nolag May 20, 2026
50c6721
Pin artifacts test build
nolag May 21, 2026
6762215
Merge branch 'main' into rtinianov_teeWorkflows
nolag May 21, 2026
ead638e
Merge branch 'main' into rtinianov_teeWorkflows
nolag May 29, 2026
0e49c59
Undo whitespaces changes to unrealated files
nolag Jun 1, 2026
8a3236b
Merge branch 'main' into rtinianov_teeWorkflows
nolag Jun 1, 2026
fad5acc
Cleaner go version pinning
nolag Jun 1, 2026
9f4470d
Undo whitespaces changes to unrealated files
nolag Jun 1, 2026
b4959b4
Use slices.Contains in template_generator
nolag Jun 1, 2026
0577b0d
Undo whitespaces changes to unrealated files
nolag Jun 1, 2026
a8c273f
Revert whitespace changes for real...
nolag Jun 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ packages:
github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/host:
interfaces:
ModuleV1: {}
ModuleV2: {}
github.com/smartcontractkit/chainlink-common/pkg/workflows/host:
interfaces:
Module: {}
ExecutionHelper:
config:
inpackage: true
filename: "mock_{{.InterfaceName | snakecase}}_test.go"
mockname: "Mock{{.InterfaceName}}"
dir: "{{.InterfaceDir}}"
mockname: "Mock{{.InterfaceName}}"
github.com/smartcontractkit/chainlink-common/pkg/custmsg:
interfaces:
MessageEmitter:
Expand All @@ -64,4 +63,4 @@ packages:
dir: "{{.InterfaceDir}}/limits"
outpkg: limits
interfaces:
Getter:
Getter:
11 changes: 9 additions & 2 deletions pkg/capabilities/v2/protoc/pkg/template_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ func (t *TemplateGenerator) runTemplate(name, tmplText string, args any, partial

if md == nil {
return false, nil
} else {
return md.MapToUntypedApi, nil
}

return md.MapToUntypedApi, nil
},
"addImport": func(importPath protogen.GoImportPath, ignore string) string {
importName := importPath.String()
Expand Down Expand Up @@ -259,6 +259,13 @@ func (t *TemplateGenerator) runTemplate(name, tmplText string, args any, partial
return line
}
},
"TeeEnabled": func(s *protogen.Service) (bool, error) {
md, err := getCapabilityMetadata(s)
if err != nil {
return false, err
}
return slices.Contains(md.AdditionalEnvironments, generator.AdditionalEnvironments_ADDITIONAL_ENVIRONMENTS_TEE), nil
},
}).Funcs(t.ExtraFns)

// Register partials
Expand Down
8 changes: 4 additions & 4 deletions pkg/workflows/artifacts/artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ func (s *ArtifactsTestSuite) TestArtifacts() {

s.lggr.Info("WorkflowCompiledBinary Size", "size", len(b64EncodedBinaryData))

// Compare the keccak256 hash of the binary data with the keccak256 hash of the
// base64 encoded binary from CRE-CLI
// Compare the keccak256 hash of the binary data against a value produced by
// the pinned Go toolchain (see GetBuildCmd in utils.go). Because Compile sets
// GOTOOLCHAIN from the nearest go.mod, this hash is stable across machines.
expKeccak256Hash, err := hex.DecodeString("a057a58ff8212122016515b2922b7c3893525f7f5afe95c8442e0cd629d68420")
s.NoError(err, "failed to decode expected keccak256 hash")
keccak256FromSha3Lib := sha3.NewLegacyKeccak256()
Expand All @@ -58,8 +59,7 @@ func (s *ArtifactsTestSuite) TestArtifacts() {
s.NoError(err, "failed to prepare artifacts")

base64EncodedBinaryData := artifacts.GetBinaryData()
// Compare if the compiled WASM binary is the same as the CRE-CLI output
s.Len(base64EncodedBinaryData, 636684, "binary data size should be same as CRE-CLI output")
s.Len(base64EncodedBinaryData, 636684, "binary data size should match the pinned toolchain output")
s.Equal("m1upG3s6AJQvOA8AAK295+EaARsHAADf/YcBgFURwPQAANDq5wFQVVVVVVVVVVVV3ZMQEI7ZtgMAAKqq",
string(base64EncodedBinaryData[0:80]))
s.Equal("gUEoFNoVRfyHGTsZmdg7wCJbGVibOhmYmsDAytgg92FTTmiddpI/x8SYzdANBkPGhtLoj/Hn7jvK26YE",
Expand Down
59 changes: 58 additions & 1 deletion pkg/workflows/artifacts/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package artifacts

import (
"bufio"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -78,10 +79,66 @@ func GetBuildCmd(inputFile string, outputFile string, rootFolder string) *exec.C
"-buildvcs=false",
inputFile,
)
buildCmd.Env = append(os.Environ(), "GOOS=wasip1", "GOARCH=wasm", "CGO_ENABLED=0")
env := append(os.Environ(), "GOOS=wasip1", "GOARCH=wasm", "CGO_ENABLED=0")
// Pin GOTOOLCHAIN so the compiled WASM is reproducible. Prefer the
// configured GOTOOLCHAIN; when it's unset, fall back to the version
// declared in the module's go.mod (the local Go version wouldn't pin).
if toolchain := goToolchain(rootFolder); toolchain != "" {
env = append(env, "GOTOOLCHAIN="+toolchain)
}
buildCmd.Env = env
}

buildCmd.Dir = rootFolder

return buildCmd
}

// goToolchain returns a GOTOOLCHAIN value (e.g. "go1.26.2") to pin the build
// to. It prefers the configured `go env GOTOOLCHAIN`; when that is unset (e.g.
// "auto") it falls back to the go version declared in the module's go.mod. The
// local Go version is not used as a fallback because it would not pin a
// reproducible toolchain. Returns "" when nothing can be determined.
func goToolchain(dir string) string {
if v := goEnv(dir, "GOTOOLCHAIN"); v != "" && v != "auto" {
return v
}
return goToolchainFromMod(dir)
}

// goEnv runs `go env <name>` in dir and returns the trimmed value, or "" on error.
func goEnv(dir, name string) string {
cmd := exec.Command("go", "env", name)
cmd.Dir = dir
out, err := cmd.Output()
if err != nil {
return ""
}
return strings.TrimSpace(string(out))
}

// goToolchainFromMod returns a GOTOOLCHAIN value derived from the go directive
// in the module's go.mod, located via `go env GOMOD`. Returns "" when no go.mod
// or go version can be determined.
func goToolchainFromMod(dir string) string {
goModPath := goEnv(dir, "GOMOD")
// `go env GOMOD` returns "" outside a module and os.DevNull when modules
// are disabled (GO111MODULE=off); neither is a real go.mod file.
if goModPath == "" || goModPath == os.DevNull {
return ""
}
f, err := os.Open(goModPath)
if err != nil {
return ""
}
defer f.Close()

scanner := bufio.NewScanner(f)
for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if len(fields) == 2 && fields[0] == "go" {
return "go" + fields[1]
}
}
return ""
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

207 changes: 207 additions & 0 deletions pkg/workflows/host/mocks/module.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading