From 213f38aac462ba5cc0f1370f48825d4316946e36 Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Wed, 15 Jan 2025 14:47:45 +0000 Subject: [PATCH 1/5] [CRE-44] Restricted config --- core/capabilities/launcher.go | 7 ++ core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- core/services/workflows/engine.go | 40 ++++++++---- core/services/workflows/engine_test.go | 88 +++++++++++++++++++++++++- deployment/go.mod | 2 +- deployment/go.sum | 4 +- go.mod | 2 +- go.sum | 6 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 4 +- 13 files changed, 139 insertions(+), 28 deletions(-) diff --git a/core/capabilities/launcher.go b/core/capabilities/launcher.go index 51df7eeebfc..719b3e872cc 100644 --- a/core/capabilities/launcher.go +++ b/core/capabilities/launcher.go @@ -81,8 +81,15 @@ func unmarshalCapabilityConfig(data []byte) (capabilities.CapabilityConfiguratio return capabilities.CapabilityConfiguration{}, err } + rc, err := values.FromMapValueProto(cconf.RestrictedConfig) + if err != nil { + return capabilities.CapabilityConfiguration{}, err + } + return capabilities.CapabilityConfiguration{ DefaultConfig: dc, + RestrictedKeys: cconf.RestrictedKeys, + RestrictedConfig: rc, RemoteTriggerConfig: remoteTriggerConfig, RemoteTargetConfig: remoteTargetConfig, }, nil diff --git a/core/scripts/go.mod b/core/scripts/go.mod index e5fa565327a..4517c96a60d 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -34,7 +34,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chainlink-automation v0.8.1 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13 github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919 diff --git a/core/scripts/go.sum b/core/scripts/go.sum index c659d329fbd..789e0013fdc 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1164,8 +1164,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd h1:SX16W7pqXGyn6fHFgtlr/rUdLZzBtQ5O3Gt3a6sFL70= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/core/services/workflows/engine.go b/core/services/workflows/engine.go index f6e73bb8bc5..0dd26938f51 100644 --- a/core/services/workflows/engine.go +++ b/core/services/workflows/engine.go @@ -833,14 +833,34 @@ func (e *Engine) workerForStepRequest(ctx context.Context, msg stepRequest) { l.Debugf("sent step state update for execution %s with status %s", stepState.ExecutionID, stepStatus) } -func merge(baseConfig *values.Map, overrideConfig *values.Map) *values.Map { +func merge(baseConfig *values.Map, capConfig capabilities.CapabilityConfiguration) *values.Map { + restrictedKeys := map[string]bool{} + for _, k := range capConfig.RestrictedKeys { + restrictedKeys[k] = true + } + + // Shallow copy the defaults set in the onchain capability config. m := values.EmptyMap() + if capConfig.DefaultConfig != nil { + for k, v := range capConfig.DefaultConfig.Underlying { + m.Underlying[k] = v + } + } + + // Add in user-provided config, but skipping any restricted keys for k, v := range baseConfig.Underlying { - m.Underlying[k] = v + if !restrictedKeys[k] { + m.Underlying[k] = v + } + } + + if capConfig.RestrictedConfig == nil { + return m } - for k, v := range overrideConfig.Underlying { + // Then overwrite the config with any restricted settings. + for k, v := range capConfig.RestrictedConfig.Underlying { m.Underlying[k] = v } @@ -901,14 +921,12 @@ func (e *Engine) configForStep(ctx context.Context, lggr logger.Logger, step *st return config, nil } - if capConfig.DefaultConfig == nil { - return config, nil - } - - // Merge the configs with registry config overriding the step config. This is because - // some config fields are sensitive and could affect the safe running of the capability, - // so we avoid user provided values by overriding them with config from the capabilities registry. - return merge(config, capConfig.DefaultConfig), nil + // Merge the capability registry config with the config provided by the user. + // We need to obey the following rules: + // - Remove any restricted keys + // - Overlay any restricted config + // - Merge the other keys, with user keys taking precedence + return merge(config, capConfig), nil } // executeStep executes the referenced capability within a step and returns the result. diff --git a/core/services/workflows/engine_test.go b/core/services/workflows/engine_test.go index 839e3680f72..3ffd5372f13 100644 --- a/core/services/workflows/engine_test.go +++ b/core/services/workflows/engine_test.go @@ -1170,7 +1170,7 @@ targets: ` // TestEngine_MergesWorkflowConfigAndCRConfig_CRConfigPrecedence tests that the engine merges the -// workflow config with the CR config, with the CR config taking precedence. +// workflow config with the CR config correctly, with the CR config taking precedence. func TestEngine_MergesWorkflowConfigAndCRConfig_CRConfigPrecedence(t *testing.T) { var ( ctx = testutils.Context(t) @@ -1230,7 +1230,8 @@ func TestEngine_MergesWorkflowConfigAndCRConfig_CRConfigPrecedence(t *testing.T) var cb []byte cb, err = proto.Marshal(&capabilitiespb.CapabilityConfig{ - DefaultConfig: values.ProtoMap(giveRegistryConfig), + RestrictedConfig: values.ProtoMap(giveRegistryConfig), + RestrictedKeys: []string{"maxMemoryMBs", "tickInterval", "timeout"}, }) return registrysyncer.CapabilityConfiguration{ Config: cb, @@ -1671,3 +1672,86 @@ func TestEngine_FetchesSecrets(t *testing.T) { require.NoError(t, err) assert.Equal(t, gotConfig, expm) } + +func TestMerge(t *testing.T) { + tests := []struct { + name string + baseConfig map[string]any + expectedConfig map[string]any + capabilityConfig capabilities.CapabilityConfiguration + }{ + { + name: "no remote config", + baseConfig: map[string]any{ + "foo": "bar", + }, + expectedConfig: map[string]any{ + "foo": "bar", + }, + capabilityConfig: capabilities.CapabilityConfiguration{}, + }, + { + name: "user provides restricted config", + baseConfig: map[string]any{ + "restrictedXXX": "restrictedYYY", + "foo": "bar", + }, + expectedConfig: map[string]any{ + "foo": "bar", + }, + capabilityConfig: capabilities.CapabilityConfiguration{ + RestrictedKeys: []string{"restrictedXXX"}, + }, + }, + { + name: "user provides restricted config; capability contains restricted", + baseConfig: map[string]any{ + "restrictedXXX": "restrictedYYY", + "foo": "bar", + }, + expectedConfig: map[string]any{ + "foo": "bar", + "restrictedXXX": "restrictedXXXSetRemotely", + }, + capabilityConfig: capabilities.CapabilityConfiguration{ + RestrictedKeys: []string{"restrictedXXX"}, + RestrictedConfig: &values.Map{ + Underlying: map[string]values.Value{ + "restrictedXXX": values.NewString("restrictedXXXSetRemotely"), + }, + }, + }, + }, + { + name: "default overridden by what user provides", + baseConfig: map[string]any{ + "restrictedXXX": "restrictedYYY", + "foo": "bar", + "baz": "overridden", + }, + expectedConfig: map[string]any{ + "foo": "bar", + "baz": "overridden", + }, + capabilityConfig: capabilities.CapabilityConfiguration{ + RestrictedKeys: []string{"restrictedXXX"}, + DefaultConfig: &values.Map{ + Underlying: map[string]values.Value{ + "baz": values.NewString("qux"), + }, + }, + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(st *testing.T) { + bc, err := values.NewMap(tc.baseConfig) + require.NoError(t, err) + got := merge(bc, tc.capabilityConfig) + gotMap, err := got.Unwrap() + require.NoError(t, err) + assert.Equal(t, tc.expectedConfig, gotMap) + }) + } +} diff --git a/deployment/go.mod b/deployment/go.mod index 20ec2aa2d51..ea30f792400 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -31,7 +31,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-solana v1.1.1-0.20250110142550-e2a9566d39f3 github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.2-0.20250110073248-456673e8eea2 diff --git a/deployment/go.sum b/deployment/go.sum index f39378c7369..b90c966dda1 100644 --- a/deployment/go.sum +++ b/deployment/go.sum @@ -1390,8 +1390,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd h1:SX16W7pqXGyn6fHFgtlr/rUdLZzBtQ5O3Gt3a6sFL70= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/go.mod b/go.mod index 1cad28ea09d..e4aa2dfdfdf 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.34 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-feeds v0.1.1 diff --git a/go.sum b/go.sum index 10c6bc0e667..b71e4f43dad 100644 --- a/go.sum +++ b/go.sum @@ -1154,8 +1154,10 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1:TeWnxdgSO2cYCKcBMwdkRcs/YdhSvXoWqqw7QWz/KeI= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd h1:SX16W7pqXGyn6fHFgtlr/rUdLZzBtQ5O3Gt3a6sFL70= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d h1:/x7c03GFssDq49Y/GSPM7E8re+iz2K1G9bprz6sbR54= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 65d4bfb05f3..6dfb5c20c5d 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -47,7 +47,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index f5a223dd01c..7de266d76f9 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1414,8 +1414,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd h1:SX16W7pqXGyn6fHFgtlr/rUdLZzBtQ5O3Gt3a6sFL70= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 67acbc538b8..4b73dd06aa6 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -27,7 +27,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.15.0 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 23f6bde3370..1a3fee4e393 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1403,8 +1403,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd h1:SX16W7pqXGyn6fHFgtlr/rUdLZzBtQ5O3Gt3a6sFL70= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115094325-4e61572bb9bd/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= From e2fd1297fd5319d9df393311984129a65820e848 Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Thu, 16 Jan 2025 13:40:55 +0000 Subject: [PATCH 2/5] [CRE-44] Validate values passed into Compute transformer --- core/capabilities/compute/compute.go | 33 ++++- core/capabilities/compute/transformer.go | 21 ++- core/capabilities/compute/transformer_test.go | 126 +++++++++++++++++- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 +- deployment/go.mod | 2 +- deployment/go.sum | 4 +- go.mod | 2 +- go.sum | 6 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 4 +- 13 files changed, 180 insertions(+), 32 deletions(-) diff --git a/core/capabilities/compute/compute.go b/core/capabilities/compute/compute.go index 4508d47534e..04d583460ff 100644 --- a/core/capabilities/compute/compute.go +++ b/core/capabilities/compute/compute.go @@ -360,12 +360,33 @@ func (c *Compute) createFetcher() func(ctx context.Context, req *wasmpb.FetchReq } const ( - defaultNumWorkers = 3 + defaultNumWorkers = 3 + defaultMaxMemoryMBs = 128 + defaultMaxTickInterval = 100 * time.Millisecond + defaultMaxTimeout = 10 * time.Second ) type Config struct { webapi.ServiceConfig - NumWorkers int + NumWorkers int + MaxMemoryMBs uint64 + MaxTimeout time.Duration + MaxTickInterval time.Duration +} + +func (c *Config) ApplyDefaults() { + if c.NumWorkers == 0 { + c.NumWorkers = defaultNumWorkers + } + if c.MaxMemoryMBs == 0 { + c.MaxMemoryMBs = defaultMaxMemoryMBs + } + if c.MaxTimeout == 0 { + c.MaxTimeout = defaultMaxTimeout + } + if c.MaxTickInterval == 0 { + c.MaxTickInterval = defaultMaxTickInterval + } } func NewAction( @@ -376,9 +397,7 @@ func NewAction( idGenerator func() string, opts ...func(*Compute), ) (*Compute, error) { - if config.NumWorkers == 0 { - config.NumWorkers = defaultNumWorkers - } + config.ApplyDefaults() metricsLabeler, err := newComputeMetricsLabeler(metrics.NewLabeler().With("capability", CapabilityIDCompute)) if err != nil { return nil, fmt.Errorf("failed to create compute metrics labeler: %w", err) @@ -393,11 +412,11 @@ func NewAction( metrics: metricsLabeler, registry: registry, modules: newModuleCache(clockwork.NewRealClock(), 1*time.Minute, 10*time.Minute, 3), - transformer: NewTransformer(lggr, labeler), + transformer: NewTransformer(lggr, labeler, config), outgoingConnectorHandler: handler, idGenerator: idGenerator, queue: make(chan request), - numWorkers: defaultNumWorkers, + numWorkers: config.NumWorkers, } ) diff --git a/core/capabilities/compute/transformer.go b/core/capabilities/compute/transformer.go index 3b4ae4cfa69..c018adcb51f 100644 --- a/core/capabilities/compute/transformer.go +++ b/core/capabilities/compute/transformer.go @@ -26,6 +26,7 @@ type ParsedConfig struct { type transformer struct { logger logger.Logger emitter custmsg.MessageEmitter + config Config } func shallowCopy(m *values.Map) *values.Map { @@ -60,11 +61,15 @@ func (t *transformer) Transform(req capabilities.CapabilityRequest, opts ...func return capabilities.CapabilityRequest{}, nil, NewInvalidRequestError(err) } - maxMemoryMBs, err := popOptionalValue[int64](copiedReq.Config, maxMemoryMBsKey) + maxMemoryMBs, err := popOptionalValue[uint64](copiedReq.Config, maxMemoryMBsKey) if err != nil { return capabilities.CapabilityRequest{}, nil, NewInvalidRequestError(err) } + if maxMemoryMBs <= 0 || maxMemoryMBs > t.config.MaxMemoryMBs { + maxMemoryMBs = t.config.MaxMemoryMBs + } + mc := &host.ModuleConfig{ MaxMemoryMBs: maxMemoryMBs, Logger: t.logger, @@ -82,9 +87,16 @@ func (t *transformer) Transform(req capabilities.CapabilityRequest, opts ...func if err != nil { return capabilities.CapabilityRequest{}, nil, NewInvalidRequestError(err) } + if td < 0 || td > t.config.MaxTimeout { + td = t.config.MaxTimeout + } mc.Timeout = &td } + if mc.Timeout == nil { + mc.Timeout = &t.config.MaxTimeout + } + tickInterval, err := popOptionalValue[string](copiedReq.Config, tickIntervalKey) if err != nil { return capabilities.CapabilityRequest{}, nil, NewInvalidRequestError(err) @@ -99,6 +111,10 @@ func (t *transformer) Transform(req capabilities.CapabilityRequest, opts ...func mc.TickInterval = ti } + if mc.TickInterval <= 0 || mc.TickInterval > t.config.MaxTickInterval { + mc.TickInterval = t.config.MaxTickInterval + } + pc := &ParsedConfig{ Binary: binary, Config: config, @@ -112,10 +128,11 @@ func (t *transformer) Transform(req capabilities.CapabilityRequest, opts ...func return copiedReq, pc, nil } -func NewTransformer(lggr logger.Logger, emitter custmsg.MessageEmitter) *transformer { +func NewTransformer(lggr logger.Logger, emitter custmsg.MessageEmitter, config Config) *transformer { return &transformer{ logger: lggr, emitter: emitter, + config: config, } } diff --git a/core/capabilities/compute/transformer_test.go b/core/capabilities/compute/transformer_test.go index ee77e20d6f6..b596b5981eb 100644 --- a/core/capabilities/compute/transformer_test.go +++ b/core/capabilities/compute/transformer_test.go @@ -113,7 +113,12 @@ func Test_transformer(t *testing.T) { }, } - tf := NewTransformer(lgger, emitter) + config := Config{ + MaxMemoryMBs: 2048, + MaxTimeout: 20 * time.Second, + MaxTickInterval: 10 * time.Second, + } + tf := NewTransformer(lgger, emitter, config) _, gotConfig, err := tf.Transform(giveReq) require.NoError(t, err) @@ -130,16 +135,22 @@ func Test_transformer(t *testing.T) { } require.NoError(t, err) + timeout := defaultMaxTimeout wantConfig := &ParsedConfig{ Binary: []byte{0x01, 0x02, 0x03}, Config: []byte{0x04, 0x05, 0x06}, ModuleConfig: &host.ModuleConfig{ - Logger: lgger, - Labeler: emitter, + Logger: lgger, + Labeler: emitter, + TickInterval: defaultMaxTickInterval, + Timeout: &timeout, + MaxMemoryMBs: defaultMaxMemoryMBs, }, } - tf := NewTransformer(lgger, emitter) + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) _, gotConfig, err := tf.Transform(giveReq) require.NoError(t, err) @@ -157,7 +168,9 @@ func Test_transformer(t *testing.T) { } require.NoError(t, err) - tf := NewTransformer(lgger, emitter) + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) _, _, err = tf.Transform(giveReq) require.Error(t, err) @@ -175,10 +188,111 @@ func Test_transformer(t *testing.T) { } require.NoError(t, err) - tf := NewTransformer(lgger, emitter) + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) _, _, err = tf.Transform(giveReq) require.Error(t, err) require.ErrorContains(t, err, "invalid request") }) + + t.Run("invalid tickInterval, applies default", func(t *testing.T) { + giveMap, err := values.NewMap(map[string]any{ + "tickInterval": "-50ms", + "binary": []byte{0x01, 0x02, 0x03}, + "config": []byte{0x04, 0x05, 0x06}, + }) + giveReq := capabilities.CapabilityRequest{ + Config: giveMap, + } + require.NoError(t, err) + + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) + _, pc, err := tf.Transform(giveReq) + + require.NoError(t, err) + assert.Equal(t, defaultMaxTickInterval, pc.ModuleConfig.TickInterval) + }) + + t.Run("invalid timeout, applies default", func(t *testing.T) { + giveMap, err := values.NewMap(map[string]any{ + "timeout": "-50ms", + "binary": []byte{0x01, 0x02, 0x03}, + "config": []byte{0x04, 0x05, 0x06}, + }) + giveReq := capabilities.CapabilityRequest{ + Config: giveMap, + } + require.NoError(t, err) + + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) + _, pc, err := tf.Transform(giveReq) + + require.NoError(t, err) + assert.Equal(t, defaultMaxTimeout, *pc.ModuleConfig.Timeout) + }) + + t.Run("timeout too high, applies default", func(t *testing.T) { + giveMap, err := values.NewMap(map[string]any{ + "timeout": "1h", + "binary": []byte{0x01, 0x02, 0x03}, + "config": []byte{0x04, 0x05, 0x06}, + }) + giveReq := capabilities.CapabilityRequest{ + Config: giveMap, + } + require.NoError(t, err) + + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) + _, pc, err := tf.Transform(giveReq) + + require.NoError(t, err) + assert.Equal(t, defaultMaxTimeout, *pc.ModuleConfig.Timeout) + }) + + t.Run("tickInterval too high, applies default", func(t *testing.T) { + giveMap, err := values.NewMap(map[string]any{ + "tickInterval": "1h", + "binary": []byte{0x01, 0x02, 0x03}, + "config": []byte{0x04, 0x05, 0x06}, + }) + giveReq := capabilities.CapabilityRequest{ + Config: giveMap, + } + require.NoError(t, err) + + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) + _, pc, err := tf.Transform(giveReq) + + require.NoError(t, err) + assert.Equal(t, defaultMaxTickInterval, pc.ModuleConfig.TickInterval) + }) + + t.Run("applies default tick interval if missing", func(t *testing.T) { + giveMap, err := values.NewMap(map[string]any{ + "binary": []byte{0x01, 0x02, 0x03}, + "config": []byte{0x04, 0x05, 0x06}, + }) + giveReq := capabilities.CapabilityRequest{ + Config: giveMap, + } + require.NoError(t, err) + + config := Config{} + config.ApplyDefaults() + tf := NewTransformer(lgger, emitter, config) + _, pc, err := tf.Transform(giveReq) + + require.NoError(t, err) + assert.Equal(t, defaultMaxTickInterval, pc.ModuleConfig.TickInterval) + }) } diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 4517c96a60d..9a23039442c 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -34,7 +34,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chainlink-automation v0.8.1 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13 github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919 diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 789e0013fdc..59337db9e5b 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1164,8 +1164,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/deployment/go.mod b/deployment/go.mod index ea30f792400..dc859505912 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -31,7 +31,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-solana v1.1.1-0.20250110142550-e2a9566d39f3 github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.2-0.20250110073248-456673e8eea2 diff --git a/deployment/go.sum b/deployment/go.sum index b90c966dda1..5e9149b689c 100644 --- a/deployment/go.sum +++ b/deployment/go.sum @@ -1390,8 +1390,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/go.mod b/go.mod index e4aa2dfdfdf..f4408b92cc1 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.34 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-feeds v0.1.1 diff --git a/go.sum b/go.sum index b71e4f43dad..797a702d5d6 100644 --- a/go.sum +++ b/go.sum @@ -1154,10 +1154,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1:TeWnxdgSO2cYCKcBMwdkRcs/YdhSvXoWqqw7QWz/KeI= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d h1:/x7c03GFssDq49Y/GSPM7E8re+iz2K1G9bprz6sbR54= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115142646-10744a99a77d/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 6dfb5c20c5d..904d92f3575 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -47,7 +47,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 7de266d76f9..c9d7242c0c7 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1414,8 +1414,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index 4b73dd06aa6..aa921f162c5 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -27,7 +27,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.15.0 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 + github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 1a3fee4e393..e7aad6bb5a7 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1403,8 +1403,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4 h1:KpfgoW1Zh6SIJd70Vzb2eZ9Xavoz0DyO/9PlwJ+If9U= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115134932-0be579e7dbc4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= +github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= From 888bd144cecd2489a45193e71ce957413687bf1d Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Thu, 16 Jan 2025 17:47:01 +0000 Subject: [PATCH 3/5] [fix] Remove debug logging in safeurl --- core/services/gateway/network/httpclient.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/services/gateway/network/httpclient.go b/core/services/gateway/network/httpclient.go index 21de0b8b9f4..94a0de5d13b 100644 --- a/core/services/gateway/network/httpclient.go +++ b/core/services/gateway/network/httpclient.go @@ -81,7 +81,6 @@ func NewHTTPClient(config HTTPClientConfig, lggr logger.Logger) (HTTPClient, err SetBlockedIPs(config.BlockedIPs...). SetBlockedIPsCIDR(config.BlockedIPsCIDR...). SetCheckRedirect(disableRedirects). - EnableDebugLogging(true). Build() return &httpClient{ From 02e5e0b6aeaae8d186c28514c15e606afee50aa5 Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Fri, 17 Jan 2025 10:32:21 +0000 Subject: [PATCH 4/5] Update common --- core/scripts/go.mod | 2 +- core/scripts/go.sum | 4 ++-- deployment/go.mod | 2 +- deployment/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 ++-- integration-tests/load/go.mod | 2 +- integration-tests/load/go.sum | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 9a23039442c..537f88886f0 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -34,7 +34,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chainlink-automation v0.8.1 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 + github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13 github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919 diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 59337db9e5b..343f83ed7a7 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1164,8 +1164,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 h1:cf7mgbR8OelUnq49x0vYLy1XWddw4t1Q1YsBPxUQY4M= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/deployment/go.mod b/deployment/go.mod index dc859505912..1aa48ebc3d2 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -31,7 +31,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 + github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-solana v1.1.1-0.20250110142550-e2a9566d39f3 github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.2-0.20250110073248-456673e8eea2 diff --git a/deployment/go.sum b/deployment/go.sum index 5e9149b689c..5c543d9719a 100644 --- a/deployment/go.sum +++ b/deployment/go.sum @@ -1390,8 +1390,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 h1:cf7mgbR8OelUnq49x0vYLy1XWddw4t1Q1YsBPxUQY4M= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/go.mod b/go.mod index f4408b92cc1..409e78d385f 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.34 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 + github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 github.com/smartcontractkit/chainlink-feeds v0.1.1 diff --git a/go.sum b/go.sum index 797a702d5d6..537fb07f07f 100644 --- a/go.sum +++ b/go.sum @@ -1154,8 +1154,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1:TeWnxdgSO2cYCKcBMwdkRcs/YdhSvXoWqqw7QWz/KeI= github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 h1:cf7mgbR8OelUnq49x0vYLy1XWddw4t1Q1YsBPxUQY4M= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 904d92f3575..fdbdb08b991 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -47,7 +47,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.36 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 + github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0 github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index c9d7242c0c7..672e7d809e6 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1414,8 +1414,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 h1:cf7mgbR8OelUnq49x0vYLy1XWddw4t1Q1YsBPxUQY4M= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index aa921f162c5..8373b60fca0 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -27,7 +27,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.15.0 - github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 + github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index e7aad6bb5a7..ccc75478250 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1403,8 +1403,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg= github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3 h1:N4XPfzn+qtzblyZDUfHuiVaP9j4TkOHHuFxkavtRHzc= -github.com/smartcontractkit/chainlink-common v0.4.1-0.20250115171417-84cab34cb9e3/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4 h1:cf7mgbR8OelUnq49x0vYLy1XWddw4t1Q1YsBPxUQY4M= +github.com/smartcontractkit/chainlink-common v0.4.2-0.20250117101554-1922eef0bdd4/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250113165937-53c02f2513d4 h1:8qPzgbMGGn6CxQe/cjWvBgNKAxOL+brZZV+xYoY5+GE= From 5a92347225bf4761c65891e00c31dc21f62888a3 Mon Sep 17 00:00:00 2001 From: Cedric Cordenier Date: Fri, 17 Jan 2025 10:35:28 +0000 Subject: [PATCH 5/5] <= 0 --- core/capabilities/compute/transformer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/capabilities/compute/transformer.go b/core/capabilities/compute/transformer.go index c018adcb51f..22a464c9af8 100644 --- a/core/capabilities/compute/transformer.go +++ b/core/capabilities/compute/transformer.go @@ -87,7 +87,7 @@ func (t *transformer) Transform(req capabilities.CapabilityRequest, opts ...func if err != nil { return capabilities.CapabilityRequest{}, nil, NewInvalidRequestError(err) } - if td < 0 || td > t.config.MaxTimeout { + if td <= 0 || td > t.config.MaxTimeout { td = t.config.MaxTimeout } mc.Timeout = &td