diff --git a/.changeset/four-knives-stare.md b/.changeset/four-knives-stare.md new file mode 100644 index 00000000000..edac39bc894 --- /dev/null +++ b/.changeset/four-knives-stare.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#internal [Keystone] Merge version field with ID diff --git a/.changeset/happy-oranges-heal.md b/.changeset/happy-oranges-heal.md new file mode 100644 index 00000000000..9041c861a79 --- /dev/null +++ b/.changeset/happy-oranges-heal.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#internal Add workflow validation diff --git a/core/capabilities/registry.go b/core/capabilities/registry.go index 042e5dfca90..84174e0232f 100644 --- a/core/capabilities/registry.go +++ b/core/capabilities/registry.go @@ -145,7 +145,7 @@ func (r *Registry) Add(ctx context.Context, c capabilities.BaseCapability) error } r.m[id] = c - r.lggr.Infow("capability added", "id", id, "type", info.CapabilityType, "description", info.Description, "version", info.Version) + r.lggr.Infow("capability added", "id", id, "type", info.CapabilityType, "description", info.Description, "version", info.Version()) return nil } diff --git a/core/capabilities/registry_test.go b/core/capabilities/registry_test.go index 3bed31a957a..5208781700a 100644 --- a/core/capabilities/registry_test.go +++ b/core/capabilities/registry_test.go @@ -2,6 +2,7 @@ package capabilities_test import ( "context" + "fmt" "testing" "github.com/google/uuid" @@ -36,12 +37,11 @@ func TestRegistry(t *testing.T) { r := coreCapabilities.NewRegistry(logger.TestLogger(t)) - id := "capability-1" + id := "capability-1@1.0.0" ci, err := capabilities.NewCapabilityInfo( id, capabilities.CapabilityTypeAction, "capability-1-description", - "v1.0.0", ) require.NoError(t, err) @@ -64,12 +64,11 @@ func TestRegistry_NoDuplicateIDs(t *testing.T) { ctx := testutils.Context(t) r := coreCapabilities.NewRegistry(logger.TestLogger(t)) - id := "capability-1" + id := "capability-1@1.0.0" ci, err := capabilities.NewCapabilityInfo( id, capabilities.CapabilityTypeAction, "capability-1-description", - "v1.0.0", ) require.NoError(t, err) @@ -81,13 +80,12 @@ func TestRegistry_NoDuplicateIDs(t *testing.T) { id, capabilities.CapabilityTypeConsensus, "capability-2-description", - "v1.0.0", ) require.NoError(t, err) c2 := &mockCapability{CapabilityInfo: ci} err = r.Add(ctx, c2) - assert.ErrorContains(t, err, "capability with id: capability-1 already exists") + assert.ErrorContains(t, err, "capability with id: capability-1@1.0.0 already exists") } func TestRegistry_ChecksExecutionAPIByType(t *testing.T) { @@ -100,12 +98,11 @@ func TestRegistry_ChecksExecutionAPIByType(t *testing.T) { { name: "action", newCapability: func(ctx context.Context, reg *coreCapabilities.Registry) (string, error) { - id := uuid.New().String() + id := fmt.Sprintf("%s@%s", uuid.New().String(), "1.0.0") ci, err := capabilities.NewCapabilityInfo( id, capabilities.CapabilityTypeAction, "capability-1-description", - "v1.0.0", ) require.NoError(t, err) @@ -120,12 +117,11 @@ func TestRegistry_ChecksExecutionAPIByType(t *testing.T) { { name: "target", newCapability: func(ctx context.Context, reg *coreCapabilities.Registry) (string, error) { - id := uuid.New().String() + id := fmt.Sprintf("%s@%s", uuid.New().String(), "1.0.0") ci, err := capabilities.NewCapabilityInfo( id, capabilities.CapabilityTypeTarget, "capability-1-description", - "v1.0.0", ) require.NoError(t, err) @@ -153,12 +149,11 @@ func TestRegistry_ChecksExecutionAPIByType(t *testing.T) { { name: "consensus", newCapability: func(ctx context.Context, reg *coreCapabilities.Registry) (string, error) { - id := uuid.New().String() + id := fmt.Sprintf("%s@%s", uuid.New().String(), "1.0.0") ci, err := capabilities.NewCapabilityInfo( id, capabilities.CapabilityTypeConsensus, "capability-1-description", - "v1.0.0", ) require.NoError(t, err) diff --git a/core/capabilities/remote/target/client_test.go b/core/capabilities/remote/target/client_test.go index 5bfbb0c7a0c..f5c6c19ef93 100644 --- a/core/capabilities/remote/target/client_test.go +++ b/core/capabilities/remote/target/client_test.go @@ -138,10 +138,9 @@ func testClient(ctx context.Context, t *testing.T, numWorkflowPeers int, workflo } capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1.0.0", CapabilityType: commoncap.CapabilityTypeTarget, Description: "Remote Target", - Version: "0.0.1", DON: &capDonInfo, } @@ -257,7 +256,7 @@ func (t *clientTestServer) Receive(msg *remotetypes.MessageBody) { for receiver := range t.messageIDToSenders[messageID] { var responseMsg = &remotetypes.MessageBody{ - CapabilityId: "cap_id", + CapabilityId: "cap_id@1.0.0", CapabilityDonId: "capability-don", CallerDonId: t.workflowDonInfo.ID, Method: remotetypes.MethodExecute, diff --git a/core/capabilities/remote/target/endtoend_test.go b/core/capabilities/remote/target/endtoend_test.go index 998c9532871..24776960562 100644 --- a/core/capabilities/remote/target/endtoend_test.go +++ b/core/capabilities/remote/target/endtoend_test.go @@ -200,10 +200,9 @@ func testRemoteTarget(ctx context.Context, t *testing.T, underlying commoncap.Ta } capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1.0.0", CapabilityType: commoncap.CapabilityTypeTarget, Description: "Remote Target", - Version: "0.0.1", DON: &capDonInfo, } diff --git a/core/capabilities/remote/target/request/client_request_test.go b/core/capabilities/remote/target/request/client_request_test.go index 930ba595625..e4b0d9da88e 100644 --- a/core/capabilities/remote/target/request/client_request_test.go +++ b/core/capabilities/remote/target/request/client_request_test.go @@ -35,10 +35,9 @@ func Test_ClientRequest_MessageValidation(t *testing.T) { } capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1.0.0", CapabilityType: commoncap.CapabilityTypeTarget, Description: "Remote Target", - Version: "0.0.1", DON: &capDonInfo, } diff --git a/core/capabilities/remote/target/server_test.go b/core/capabilities/remote/target/server_test.go index ed80e760951..fd7cbe0dfd1 100644 --- a/core/capabilities/remote/target/server_test.go +++ b/core/capabilities/remote/target/server_test.go @@ -117,10 +117,9 @@ func testRemoteTargetServer(ctx context.Context, t *testing.T, } capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1.0.0", CapabilityType: commoncap.CapabilityTypeTarget, Description: "Remote Target", - Version: "0.0.1", DON: &capDonInfo, } diff --git a/core/capabilities/remote/trigger_publisher_test.go b/core/capabilities/remote/trigger_publisher_test.go index 71a5174c07f..15bdd39b55f 100644 --- a/core/capabilities/remote/trigger_publisher_test.go +++ b/core/capabilities/remote/trigger_publisher_test.go @@ -20,10 +20,9 @@ func TestTriggerPublisher_Register(t *testing.T) { lggr := logger.TestLogger(t) ctx := testutils.Context(t) capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1", CapabilityType: commoncap.CapabilityTypeTrigger, Description: "Remote Trigger", - Version: "0.0.1", } p1 := p2ptypes.PeerID{} require.NoError(t, p1.UnmarshalText([]byte(peerID1))) diff --git a/core/capabilities/remote/trigger_subscriber_test.go b/core/capabilities/remote/trigger_subscriber_test.go index 1ad360418fb..e50f570bb7b 100644 --- a/core/capabilities/remote/trigger_subscriber_test.go +++ b/core/capabilities/remote/trigger_subscriber_test.go @@ -29,10 +29,9 @@ func TestTriggerSubscriber_RegisterAndReceive(t *testing.T) { lggr := logger.TestLogger(t) ctx := testutils.Context(t) capInfo := commoncap.CapabilityInfo{ - ID: "cap_id", + ID: "cap_id@1", CapabilityType: commoncap.CapabilityTypeTrigger, Description: "Remote Trigger", - Version: "0.0.1", } p1 := p2ptypes.PeerID{} require.NoError(t, p1.UnmarshalText([]byte(peerID1))) diff --git a/core/capabilities/syncer.go b/core/capabilities/syncer.go index 1c3bbab8fe8..e80ea9a13ff 100644 --- a/core/capabilities/syncer.go +++ b/core/capabilities/syncer.go @@ -76,12 +76,11 @@ func (s *registrySyncer) Start(ctx context.Context) error { // that reads the configuration from chain (KS-117). func (s *registrySyncer) launch(ctx context.Context) { defer s.wg.Done() - capId := "streams-trigger" + capId := "streams-trigger@0.0.1" triggerInfo, err := capabilities.NewRemoteCapabilityInfo( capId, capabilities.CapabilityTypeTrigger, "Remote Trigger", - "v0.0.1", &s.networkSetup.TriggerCapabilityDonInfo, ) if err != nil { diff --git a/core/capabilities/targets/write_target.go b/core/capabilities/targets/write_target.go index 97b88330ba3..913551d20b0 100644 --- a/core/capabilities/targets/write_target.go +++ b/core/capabilities/targets/write_target.go @@ -31,12 +31,11 @@ type WriteTarget struct { lggr logger.Logger } -func NewWriteTarget(lggr logger.Logger, name string, cr commontypes.ContractReader, cw commontypes.ChainWriter, forwarderAddress string) *WriteTarget { +func NewWriteTarget(lggr logger.Logger, id string, cr commontypes.ContractReader, cw commontypes.ChainWriter, forwarderAddress string) *WriteTarget { info := capabilities.MustNewCapabilityInfo( - name, + id, capabilities.CapabilityTypeTarget, "Write target.", - "v1.0.0", ) logger := lggr.Named("WriteTarget") diff --git a/core/capabilities/targets/write_target_test.go b/core/capabilities/targets/write_target_test.go index 5d77535bdcb..9f243389f27 100644 --- a/core/capabilities/targets/write_target_test.go +++ b/core/capabilities/targets/write_target_test.go @@ -31,7 +31,7 @@ func TestWriteTarget(t *testing.T) { forwarderA := testutils.NewAddress() forwarderAddr := forwarderA.Hex() - writeTarget := targets.NewWriteTarget(lggr, "Test", cr, cw, forwarderAddr) + writeTarget := targets.NewWriteTarget(lggr, "test-write-target@1.0.0", cr, cw, forwarderAddr) require.NotNil(t, writeTarget) config, err := values.NewMap(map[string]any{ diff --git a/core/capabilities/transmission/local_target_capability_test.go b/core/capabilities/transmission/local_target_capability_test.go index 19d51b492ff..6b4d040f0fa 100644 --- a/core/capabilities/transmission/local_target_capability_test.go +++ b/core/capabilities/transmission/local_target_capability_test.go @@ -33,10 +33,9 @@ func TestScheduledExecutionStrategy_LocalDON(t *testing.T) { // schedule. mt := newMockCapability( capabilities.MustNewCapabilityInfo( - "write_polygon-testnet-mumbai", + "write_polygon-testnet-mumbai@1.0.0", capabilities.CapabilityTypeTarget, "a write capability targeting polygon mumbai testnet", - "v1.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { gotTime = time.Now() diff --git a/core/scripts/go.mod b/core/scripts/go.mod index e2dcfcdba9b..171751a3f0c 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -24,7 +24,7 @@ require ( github.com/prometheus/client_golang v1.17.0 github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/chainlink-automation v1.0.3 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 76215a34c15..469e468bd6e 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1212,8 +1212,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs= github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 h1:53zVcdDxrHG3oewhP7AWOiLtwTozcQ0/wzFTsaTBS5M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 h1:hs8dNt80KM3iBPBJ4fo6Kp3gsHhdJUe8RVr/JpGBaQM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240606130021-a4b7359e1580 h1:nsnLzpBTDAQWkfsOz/qd8BTlb1hUpaow1KmA1tPwTf4= diff --git a/core/services/feeds/service_test.go b/core/services/feeds/service_test.go index d1133662a76..7e4097a1d13 100644 --- a/core/services/feeds/service_test.go +++ b/core/services/feeds/service_test.go @@ -657,23 +657,27 @@ func Test_Service_ProposeJob(t *testing.T) { wfName = "myworkflow" // len 10 specYaml = ` triggers: - - id: "a-trigger" + - id: "a-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" ref: "an-action" + config: {} inputs: trigger_output: $(trigger.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" ref: "a-consensus" + config: {} inputs: trigger_output: $(trigger.outputs) an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) diff --git a/core/services/relay/evm/write_target.go b/core/services/relay/evm/write_target.go index 172e4c1423c..c3df064bb4e 100644 --- a/core/services/relay/evm/write_target.go +++ b/core/services/relay/evm/write_target.go @@ -17,10 +17,10 @@ import ( func NewWriteTarget(ctx context.Context, relayer *Relayer, chain legacyevm.Chain, lggr logger.Logger) (*targets.WriteTarget, error) { // generate ID based on chain selector - name := fmt.Sprintf("write_%v", chain.ID()) + id := fmt.Sprintf("write_%v@0.0.1", chain.ID()) chainName, err := chainselectors.NameFromChainId(chain.ID().Uint64()) if err == nil { - name = fmt.Sprintf("write_%v", chainName) + id = fmt.Sprintf("write_%v@0.0.1", chainName) } // EVM-specific init @@ -74,5 +74,5 @@ func NewWriteTarget(ctx context.Context, relayer *Relayer, chain legacyevm.Chain return nil, err } - return targets.NewWriteTarget(lggr, name, cr, cw, config.ForwarderAddress().String()), nil + return targets.NewWriteTarget(lggr, id, cr, cw, config.ForwarderAddress().String()), nil } diff --git a/core/services/workflows/delegate_test.go b/core/services/workflows/delegate_test.go index f7e106796e6..dde01e50665 100644 --- a/core/services/workflows/delegate_test.go +++ b/core/services/workflows/delegate_test.go @@ -6,69 +6,174 @@ import ( "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/services/workflows" + "github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs" ) func TestDelegate_JobSpecValidator(t *testing.T) { t.Parallel() - + validName := "ten bytes!" var tt = []struct { - name string - toml string - valid bool + name string + workflowTomlFn func() string + valid bool }{ { - "valid spec", - ` -type = "workflow" -schemaVersion = 1 -workflowId = "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" -workflowOwner = "00000000000000000000000000000000000000aa" -workflowName = "ten bytes!" -`, - true, + "not a hex owner", + func() string { + workflowId := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + workflowOwner := "00000000000000000000000000000000000000aZ" + return testspecs.GenerateWorkflowSpec(workflowId, workflowOwner, "1234567890", "").Toml() + }, + false, }, { - "parse error", - ` -invalid syntax{{{{ -`, + "missing workflow field", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + return testspecs.GenerateWorkflowSpec(id, owner, validName, "").Toml() + }, false, }, + { - "invalid job type", - ` -type = "work flows" -schemaVersion = 1 -`, + "null workflow", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + return testspecs.GenerateWorkflowSpec(id, owner, validName, "{}").Toml() + }, false, }, + { - "invalid name length", - ` -type = "workflow" -schemaVersion = 1 -workflowId = "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" -workflowOwner = "00000000000000000000000000000000000000aa" -workflowName = "not ten bytes" -`, + "missing name", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + wf := ` +triggers: [] +consensus: [] +targets: [] +` + return testspecs.GenerateWorkflowSpec(id, owner, "", wf).Toml() + }, false, }, + { - "not a hex owner", - ` -type = "workflow" + "minimal passing workflow", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + wf := ` +triggers: [] +consensus: [] +targets: [] +` + return testspecs.GenerateWorkflowSpec(id, owner, validName, wf).Toml() + }, + true, + }, + + { + "name too long", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + wf := ` +triggers: [] +consensus: [] +targets: [] +` + return testspecs.GenerateWorkflowSpec(id, owner, validName+"1", wf).Toml() + }, + false, + }, + + // Taken from jobs controller test, as we want to fail early without a db / slow test dependency + { + "valid full spec", + func() string { + id := "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" + owner := "00000000000000000000000000000000000000aa" + workflow := ` +triggers: + - id: "mercury-trigger@1.0.0" + config: + feedIds: + - "0x1111111111111111111100000000000000000000000000000000000000000000" + - "0x2222222222222222222200000000000000000000000000000000000000000000" + - "0x3333333333333333333300000000000000000000000000000000000000000000" + +consensus: + - id: "offchain_reporting@2.0.0" + ref: "evm_median" + inputs: + observations: + - "$(trigger.outputs)" + config: + aggregation_method: "data_feeds_2_0" + aggregation_config: + "0x1111111111111111111100000000000000000000000000000000000000000000": + deviation: "0.001" + heartbeat: 3600 + "0x2222222222222222222200000000000000000000000000000000000000000000": + deviation: "0.001" + heartbeat: 3600 + "0x3333333333333333333300000000000000000000000000000000000000000000": + deviation: "0.001" + heartbeat: 3600 + encoder: "EVM" + encoder_config: + abi: "mercury_reports bytes[]" + +targets: + - id: "write_polygon-testnet-mumbai@3.0.0" + inputs: + report: "$(evm_median.outputs.report)" + config: + address: "0x3F3554832c636721F1fD1822Ccca0354576741Ef" + params: ["$(report)"] + abi: "receive(report bytes)" + - id: "write_ethereum-testnet-sepolia@4.0.0" + inputs: + report: "$(evm_median.outputs.report)" + config: + address: "0x54e220867af6683aE6DcBF535B4f952cB5116510" + params: ["$(report)"] + abi: "receive(report bytes)" +` + return testspecs.GenerateWorkflowSpec(id, owner, validName, workflow).Toml() + }, + true, + }, + + { + "parse error", + func() string { + return ` +invalid syntax{{{{ +` + }, + false, + }, + + { + "invalid job type", + func() string { + return ` +type = "work flows" schemaVersion = 1 -workflowId = "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef" -workflowOwner = "00000000000000000000000000000000000000aZ" -workflowName = "0123456789" -`, +` + }, false, }, } for _, tc := range tt { tc := tc t.Run(tc.name, func(t *testing.T) { - _, err := workflows.ValidatedWorkflowSpec(tc.toml) + _, err := workflows.ValidatedWorkflowSpec(tc.workflowTomlFn()) if tc.valid { require.NoError(t, err) } else { diff --git a/core/services/workflows/engine_test.go b/core/services/workflows/engine_test.go index a25568953a8..7f76db137e9 100644 --- a/core/services/workflows/engine_test.go +++ b/core/services/workflows/engine_test.go @@ -24,7 +24,7 @@ import ( const hardcodedWorkflow = ` triggers: - - id: "mercury-trigger" + - id: "mercury-trigger@1.0.0" config: feedIds: - "0x1111111111111111111100000000000000000000000000000000000000000000" @@ -32,7 +32,7 @@ triggers: - "0x3333333333333333333300000000000000000000000000000000000000000000" consensus: - - id: "offchain_reporting" + - id: "offchain_reporting@1.0.0" ref: "evm_median" inputs: observations: @@ -54,14 +54,14 @@ consensus: abi: "mercury_reports bytes[]" targets: - - id: "write_polygon-testnet-mumbai" + - id: "write_polygon-testnet-mumbai@1.0.0" inputs: report: "$(evm_median.outputs.report)" config: address: "0x3F3554832c636721F1fD1822Ccca0354576741Ef" params: ["$(report)"] abi: "receive(report bytes)" - - id: "write_ethereum-testnet-sepolia" + - id: "write_ethereum-testnet-sepolia@1.0.0" inputs: report: "$(evm_median.outputs.report)" config: @@ -210,10 +210,9 @@ func TestEngineWithHardcodedWorkflow(t *testing.T) { target2 := newMockCapability( capabilities.MustNewCapabilityInfo( - "write_ethereum-testnet-sepolia", + "write_ethereum-testnet-sepolia@1.0.0", capabilities.CapabilityTypeTarget, "a write capability targeting ethereum sepolia testnet", - "v1.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { m := req.Inputs.Underlying["report"].(*values.Map) @@ -250,7 +249,7 @@ func TestEngineWithHardcodedWorkflow(t *testing.T) { const ( simpleWorkflow = ` triggers: - - id: "mercury-trigger" + - id: "mercury-trigger@1.0.0" config: feedlist: - "0x1111111111111111111100000000000000000000000000000000000000000000" # ETHUSD @@ -258,7 +257,7 @@ triggers: - "0x3333333333333333333300000000000000000000000000000000000000000000" # BTCUSD consensus: - - id: "offchain_reporting" + - id: "offchain_reporting@1.0.0" ref: "evm_median" inputs: observations: @@ -280,7 +279,7 @@ consensus: abi: "mercury_reports bytes[]" targets: - - id: "write_polygon-testnet-mumbai" + - id: "write_polygon-testnet-mumbai@1.0.0" inputs: report: "$(evm_median.outputs.report)" config: @@ -293,10 +292,9 @@ targets: func mockTrigger(t *testing.T) (capabilities.TriggerCapability, capabilities.CapabilityResponse) { mt := &mockTriggerCapability{ CapabilityInfo: capabilities.MustNewCapabilityInfo( - "mercury-trigger", + "mercury-trigger@1.0.0", capabilities.CapabilityTypeTrigger, "issues a trigger when a mercury report is received.", - "v1.0.0", ), ch: make(chan capabilities.CapabilityResponse, 10), } @@ -316,10 +314,9 @@ func mockTrigger(t *testing.T) (capabilities.TriggerCapability, capabilities.Cap func mockNoopTrigger(t *testing.T) capabilities.TriggerCapability { mt := &mockTriggerCapability{ CapabilityInfo: capabilities.MustNewCapabilityInfo( - "mercury-trigger", + "mercury-trigger@1.0.0", capabilities.CapabilityTypeTrigger, "issues a trigger when a mercury report is received.", - "v1.0.0", ), ch: make(chan capabilities.CapabilityResponse, 10), } @@ -329,10 +326,9 @@ func mockNoopTrigger(t *testing.T) capabilities.TriggerCapability { func mockFailingConsensus() *mockCapability { return newMockCapability( capabilities.MustNewCapabilityInfo( - "offchain_reporting", + "offchain_reporting@1.0.0", capabilities.CapabilityTypeConsensus, "an ocr3 consensus capability", - "v3.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { return capabilities.CapabilityResponse{}, errors.New("fatal consensus error") @@ -343,10 +339,9 @@ func mockFailingConsensus() *mockCapability { func mockConsensus() *mockCapability { return newMockCapability( capabilities.MustNewCapabilityInfo( - "offchain_reporting", + "offchain_reporting@1.0.0", capabilities.CapabilityTypeConsensus, "an ocr3 consensus capability", - "v3.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { obs := req.Inputs.Underlying["observations"] @@ -369,10 +364,9 @@ func mockConsensus() *mockCapability { func mockTarget() *mockCapability { return newMockCapability( capabilities.MustNewCapabilityInfo( - "write_polygon-testnet-mumbai", + "write_polygon-testnet-mumbai@1.0.0", capabilities.CapabilityTypeTarget, "a write capability targeting polygon mumbai testnet", - "v1.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { m := req.Inputs.Underlying["report"].(*values.Map) @@ -412,7 +406,7 @@ func TestEngine_ErrorsTheWorkflowIfAStepErrors(t *testing.T) { const ( multiStepWorkflow = ` triggers: - - id: "mercury-trigger" + - id: "mercury-trigger@1.0.0" config: feedlist: - "0x1111111111111111111100000000000000000000000000000000000000000000" # ETHUSD @@ -420,14 +414,15 @@ triggers: - "0x3333333333333333333300000000000000000000000000000000000000000000" # BTCUSD actions: - - id: "read_chain_action" + - id: "read_chain_action@1.0.0" ref: "read_chain_action" + config: {} inputs: action: - "$(trigger.outputs)" consensus: - - id: "offchain_reporting" + - id: "offchain_reporting@1.0.0" ref: "evm_median" inputs: observations: @@ -450,7 +445,7 @@ consensus: abi: "mercury_reports bytes[]" targets: - - id: "write_polygon-testnet-mumbai" + - id: "write_polygon-testnet-mumbai@1.0.0" inputs: report: "$(evm_median.outputs.report)" config: @@ -464,10 +459,9 @@ func mockAction() (*mockCapability, values.Value) { outputs := values.NewString("output") return newMockCapability( capabilities.MustNewCapabilityInfo( - "read_chain_action", + "read_chain_action@1.0.0", capabilities.CapabilityTypeAction, "a read chain action", - "v1.0.0", ), func(req capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { return capabilities.CapabilityResponse{ diff --git a/core/services/workflows/models_test.go b/core/services/workflows/models_test.go index cf68b0e7117..4b4747c486f 100644 --- a/core/services/workflows/models_test.go +++ b/core/services/workflows/models_test.go @@ -21,23 +21,27 @@ func TestParse_Graph(t *testing.T) { name: "basic example", yaml: ` triggers: - - id: "a-trigger" + - id: "a-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: trigger_output: $(trigger.outputs) an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -60,28 +64,33 @@ targets: name: "circular relationship", yaml: ` triggers: - - id: "a-trigger" + - id: "a-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) output: $(a-second-action.outputs) - - id: "a-second-action" + - id: "a-second-action@1.0.0" + config: {} ref: "a-second-action" inputs: output: $(an-action.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: trigger_output: $(trigger.outputs) an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -92,32 +101,38 @@ targets: name: "indirect circular relationship", yaml: ` triggers: - - id: "a-trigger" + - id: "a-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) action_output: $(a-third-action.outputs) - - id: "a-second-action" + - id: "a-second-action@1.0.0" + config: {} ref: "a-second-action" inputs: output: $(an-action.outputs) - - id: "a-third-action" + - id: "a-third-action@1.0.0" + config: {} ref: "a-third-action" inputs: output: $(a-second-action.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: trigger_output: $(trigger.outputs) an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -128,23 +143,27 @@ targets: name: "relationship doesn't exist", yaml: ` triggers: - - id: "a-trigger" + - id: "a-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) action_output: $(missing-action.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -155,23 +174,28 @@ targets: name: "two trigger nodes", yaml: ` triggers: - - id: "a-trigger" - - id: "a-second-trigger" + - id: "a-trigger@1.0.0" + config: {} + - id: "a-second-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: an-action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -193,21 +217,26 @@ targets: name: "non-trigger step with no dependent refs", yaml: ` triggers: - - id: "a-trigger" - - id: "a-second-trigger" + - id: "a-trigger@1.0.0" + config: {} + - id: "a-second-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: hello: "world" consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: trigger_output: $(trigger.outputs) action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) @@ -218,21 +247,26 @@ targets: name: "duplicate edge declarations", yaml: ` triggers: - - id: "a-trigger" - - id: "a-second-trigger" + - id: "a-trigger@1.0.0" + config: {} + - id: "a-second-trigger@1.0.0" + config: {} actions: - - id: "an-action" + - id: "an-action@1.0.0" + config: {} ref: "an-action" inputs: trigger_output: $(trigger.outputs) consensus: - - id: "a-consensus" + - id: "a-consensus@1.0.0" + config: {} ref: "a-consensus" inputs: trigger_output: $(trigger.outputs) action_output: $(an-action.outputs) targets: - - id: "a-target" + - id: "a-target@1.0.0" + config: {} ref: "a-target" inputs: consensus_output: $(a-consensus.outputs) diff --git a/core/web/jobs_controller_test.go b/core/web/jobs_controller_test.go index 0eadcab108c..88ebdce2934 100644 --- a/core/web/jobs_controller_test.go +++ b/core/web/jobs_controller_test.go @@ -397,7 +397,7 @@ func TestJobController_Create_HappyPath(t *testing.T) { name := "myworkflow" // 10 bytes workflow := ` triggers: - - id: "mercury-trigger" + - id: "mercury-trigger@1.0.0" config: feedIds: - "0x1111111111111111111100000000000000000000000000000000000000000000" @@ -405,7 +405,7 @@ triggers: - "0x3333333333333333333300000000000000000000000000000000000000000000" consensus: - - id: "offchain_reporting" + - id: "offchain_reporting@2.0.0" ref: "evm_median" inputs: observations: @@ -427,14 +427,14 @@ consensus: abi: "mercury_reports bytes[]" targets: - - id: "write_polygon-testnet-mumbai" + - id: "write_polygon-testnet-mumbai@3.0.0" inputs: report: "$(evm_median.outputs.report)" config: address: "0x3F3554832c636721F1fD1822Ccca0354576741Ef" params: ["$(report)"] abi: "receive(report bytes)" - - id: "write_ethereum-testnet-sepolia" + - id: "write_ethereum-testnet-sepolia@4.0.0" inputs: report: "$(evm_median.outputs.report)" config: diff --git a/go.mod b/go.mod index 6844bbcd7bf..bd2fa774446 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,7 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/smartcontractkit/chain-selectors v1.0.10 github.com/smartcontractkit/chainlink-automation v1.0.3 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240606130021-a4b7359e1580 github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917 @@ -348,4 +348,5 @@ replace ( // until merged upstream: https://github.com/mwitkow/grpc-proxy/pull/69 github.com/mwitkow/grpc-proxy => github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f + ) diff --git a/go.sum b/go.sum index 1afcb4f9b89..9570c21e7a5 100644 --- a/go.sum +++ b/go.sum @@ -1171,8 +1171,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs= github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 h1:53zVcdDxrHG3oewhP7AWOiLtwTozcQ0/wzFTsaTBS5M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 h1:hs8dNt80KM3iBPBJ4fo6Kp3gsHhdJUe8RVr/JpGBaQM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240606130021-a4b7359e1580 h1:nsnLzpBTDAQWkfsOz/qd8BTlb1hUpaow1KmA1tPwTf4= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index dd0e0ed3c44..9630350ccf9 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -27,7 +27,7 @@ require ( github.com/shopspring/decimal v1.3.1 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.3 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 github.com/smartcontractkit/chainlink-testing-framework v1.30.1 github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868 github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000 @@ -50,6 +50,7 @@ require ( exclude github.com/hashicorp/consul v1.2.1 replace ( + // Pin K8s versions as their updates are highly disruptive and go mod keeps wanting to update them k8s.io/api => k8s.io/api v0.25.11 k8s.io/client-go => k8s.io/client-go v0.25.11 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 75d96085bdb..7131bdf29d2 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1512,8 +1512,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs= github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 h1:53zVcdDxrHG3oewhP7AWOiLtwTozcQ0/wzFTsaTBS5M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 h1:hs8dNt80KM3iBPBJ4fo6Kp3gsHhdJUe8RVr/JpGBaQM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240606130021-a4b7359e1580 h1:nsnLzpBTDAQWkfsOz/qd8BTlb1hUpaow1KmA1tPwTf4= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 63c6c3e69cc..4a36f95c84d 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -16,7 +16,7 @@ require ( github.com/rs/zerolog v1.30.0 github.com/slack-go/slack v0.12.2 github.com/smartcontractkit/chainlink-automation v1.0.3 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 github.com/smartcontractkit/chainlink-testing-framework v1.30.1 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index fd58729101b..16ecb5c6fb0 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1502,8 +1502,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs= github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0 h1:53zVcdDxrHG3oewhP7AWOiLtwTozcQ0/wzFTsaTBS5M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606094423-573049c41fa0/go.mod h1:DUZccDEW98n+J1mhdWGO7wr/Njad9p9Fzks839JN7Rs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79 h1:hs8dNt80KM3iBPBJ4fo6Kp3gsHhdJUe8RVr/JpGBaQM= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240606173949-4d52ba4e3c79/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240606130021-a4b7359e1580 h1:nsnLzpBTDAQWkfsOz/qd8BTlb1hUpaow1KmA1tPwTf4=