Skip to content

Commit b5c8b5c

Browse files
authored
system-tests: plumb workflow attributes through RegisterWithContract (#22108)
* system-tests: plumb workflow attributes through RegisterWithContract The WorkflowRegistryV2 UpsertWorkflow binding accepts an attributes []byte, but the test-helpers path hard-coded it to nil. Thread an attributes parameter through WithAttributes option -> WorkflowRegistrationConfig -> RegisterWithContract -> registerWorkflowV2 -> UpsertWorkflow so tests can register workflows whose spec.Attributes the CRE syncer's IsConfidential check will see. V1 path unchanged. Existing callers pass nil and behave identically. * WithAttributes: defensively clone input slice Prevents caller-mutation-after-pass from inadvertently changing the stored workflow attributes. Raised by Copilot review on #22108. * reorder RegisterWithContract params: attributes before artifactsDirInContainer Groups contract-payload parameters (configURL, secretsURL, attributes) before deployment-specific trailing args (artifactsDirInContainer). Matches usage in confidential-compute engine tests.
1 parent ba066e3 commit b5c8b5c

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

core/scripts/cre/environment/environment/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func deployWorkflow(
475475

476476
fmt.Printf("\n⚙️ Registering workflow '%s' with the workflow registry\n\n", workflowNameFlag)
477477

478-
workflowID, registerErr := creworkflow.RegisterWithContract(ctx, sethClient, common.HexToAddress(workflowRegistryAddress), workflowRegistryVersion, uint64(donIDFlag), workflowNameFlag, "file://"+wasmWorkflowFilePathFlag, configPath, secretsPath, &containerTargetDirFlag)
478+
workflowID, registerErr := creworkflow.RegisterWithContract(ctx, sethClient, common.HexToAddress(workflowRegistryAddress), workflowRegistryVersion, uint64(donIDFlag), workflowNameFlag, "file://"+wasmWorkflowFilePathFlag, configPath, secretsPath, nil, &containerTargetDirFlag)
479479
if registerErr != nil {
480480
return errors.Wrapf(registerErr, "❌ failed to register workflow %s", workflowNameFlag)
481481
}

system-tests/lib/cre/workflow/workflow.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func RegisterWithContract(
5555
version *semver.Version,
5656
donID uint64, workflowName, binaryURL string,
5757
configURL, secretsURL *string,
58+
attributes []byte,
5859
artifactsDirInContainer *string,
5960
) (string, error) {
6061
// Download and decode workflow binary
@@ -92,7 +93,7 @@ func RegisterWithContract(
9293
// Register workflow based on version
9394
switch version.Major() {
9495
case 2:
95-
if err := registerWorkflowV2(sc, workflowRegistryAddr, version, workflowName, workflowID, binaryURLToUse, configURLToUse); err != nil {
96+
if err := registerWorkflowV2(sc, workflowRegistryAddr, version, workflowName, workflowID, binaryURLToUse, configURLToUse, attributes); err != nil {
9697
return "", err
9798
}
9899
default:
@@ -223,6 +224,7 @@ func registerWorkflowV2(
223224
workflowRegistryAddr common.Address,
224225
version *semver.Version,
225226
workflowName, workflowID, binaryURL, configURL string,
227+
attributes []byte,
226228
) error {
227229
registry, err := getRegistryV2Instance(sc, workflowRegistryAddr, version)
228230
if err != nil {
@@ -247,7 +249,7 @@ func registerWorkflowV2(
247249
contracts.DonFamily,
248250
binaryURL,
249251
configURL,
250-
nil,
252+
attributes,
251253
false,
252254
))
253255
if err != nil {

system-tests/tests/test-helpers/t_helpers.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ type WorkflowRegistrationConfig struct {
336336
DonID uint64
337337
ContainerTargetDir string
338338
SethClient *seth.Client
339+
Attributes []byte
339340
}
340341

341342
/*
@@ -644,6 +645,7 @@ func registerWorkflow(ctx context.Context, t *testing.T,
644645
binaryURL,
645646
configURL,
646647
nil, // no secrets yet
648+
wfRegCfg.Attributes,
647649
containerTargetDir,
648650
)
649651
require.NoError(t, registerErr, "failed to register workflow '%s'", wfRegCfg.WorkflowName)
@@ -721,6 +723,7 @@ func CompileAndDeployWorkflow[T WorkflowConfig](t *testing.T,
721723
DonID: testEnv.Dons.MustWorkflowDON().ID,
722724
ContainerTargetDir: creworkflow.DefaultWorkflowTargetDir,
723725
SethClient: testEnv.CreEnvironment.Blockchains[0].(*evm.Blockchain).SethClient,
726+
Attributes: cfg.attributes,
724727
}
725728
require.IsType(t, &evm.Blockchain{}, testEnv.CreEnvironment.Blockchains[0], "expected EVM blockchain type")
726729
workflowID := registerWorkflow(t.Context(), t, workflowRegConfig, testEnv.CreEnvironment.Blockchains[0].(*evm.Blockchain).SethClient, testLogger)
@@ -729,6 +732,7 @@ func CompileAndDeployWorkflow[T WorkflowConfig](t *testing.T,
729732

730733
type compileAndDeployWorkflowCfg struct {
731734
artifactCopyDONTypes []cre.CapabilityFlag
735+
attributes []byte
732736
}
733737

734738
// CompileAndDeployWorkflowOpt customizes workflow compilation/deployment behavior.
@@ -744,6 +748,16 @@ func WithArtifactCopyDONTypes(donTypes ...cre.CapabilityFlag) CompileAndDeployWo
744748
}
745749
}
746750

751+
// WithAttributes sets the workflow attributes byte blob (JSON) written to the
752+
// WorkflowRegistry contract on upsert. The CRE syncer reads this to decide
753+
// routing (e.g. confidential execution via ConfidentialModule). The input is
754+
// cloned so later caller mutations don't affect stored config.
755+
func WithAttributes(attributes []byte) CompileAndDeployWorkflowOpt {
756+
return func(cfg *compileAndDeployWorkflowCfg) {
757+
cfg.attributes = slices.Clone(attributes)
758+
}
759+
}
760+
747761
func selectArtifactTargetDONs(testEnv *ttypes.TestEnvironment, donTypes []cre.CapabilityFlag) []*cre.Don {
748762
if len(donTypes) == 0 {
749763
donTypes = []cre.CapabilityFlag{cre.WorkflowDON}

0 commit comments

Comments
 (0)