Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-towns-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#updated observation cache TTL and bridge cache-fallback test coverage
3 changes: 3 additions & 0 deletions .github/workflows/cre-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

- name: Resolve Spot Setting
id: spot
uses: $/.github/actions/setup-runner-spot

Check failure on line 79 in .github/workflows/cre-system-tests.yaml

View workflow job for this annotation

GitHub Actions / Validate Github Action Workflows

[actionlint] reported by reviewdog 🐶 specifying action "$/.github/actions/setup-runner-spot" in invalid format because ref is missing. available formats are "{owner}/{repo}@{ref}" or "{owner}/{repo}/{path}@{ref}" [action] Raw Output: e:.github/workflows/cre-system-tests.yaml:79:15: specifying action "$/.github/actions/setup-runner-spot" in invalid format because ref is missing. available formats are "{owner}/{repo}@{ref}" or "{owner}/{repo}/{path}@{ref}" [action]

# TODO(DX-5101): replace this inline grep/jq matrix step with `ci matrix system --suite cre-smoke`
- name: Define test matrix
Expand Down Expand Up @@ -126,6 +126,9 @@
"Test_CRE_V2_ShardManualAssignment": [
{"topology":"workflow-gateway-sharded-manual","configs":"configs/workflow-gateway-sharded-manual.toml"}
],
"Test_CRE_V2_ShardedCapabilitiesManualEVMLogTrigger": [
{"topology":"workflow-sharded-capabilities","configs":"configs/workflow-sharded-capabilities-don.toml"}
],
"Test_CRE_V2_ShardRingOCROverrides": [
{"topology":"workflow-gateway-sharded-ringocr-overrides","configs":"configs/workflow-gateway-sharded-ringocr-overrides.toml"}
],
Expand Down
48 changes: 38 additions & 10 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,25 @@ func (s *SolKeys) SetFrom(f *SolKeys) error {
if f == nil || len(f.Keys) == 0 {
return nil
}
s.Keys = make([]*SolKey, len(f.Keys))
copy(s.Keys, f.Keys)
// Replacing would discard the keys contributed by earlier -s files;
// validateMerge has already rejected any duplicated across them.
s.Keys = append(s.Keys, f.Keys...)
return nil
}

func (s *SolKeys) validateMerge(f *SolKeys) (err error) {
have := make(map[string]struct{})
if s != nil && f != nil {
for _, solKey := range s.Keys {
if solKey.ID == nil {
continue
}
have[*solKey.ID] = struct{}{}
}
for _, solKey := range f.Keys {
if solKey.ID == nil {
continue // a missing ID is a validation error, not a merge conflict
}
if _, ok := have[*solKey.ID]; ok {
err = errors.Join(err, configutils.ErrOverride{Name: "SolKeys: " + *solKey.ID})
}
Expand Down Expand Up @@ -240,7 +247,7 @@ func (e *SolKey) validateMerge(f *SolKey) (err error) {
}

func (e *SolKey) ValidateConfig() (err error) {
if (e.JSON != nil) != (e.Password != nil) && (e.Password != nil) != (e.ID != nil) {
if (e.JSON != nil) != (e.Password != nil) || (e.Password != nil) != (e.ID != nil) {
err = errors.Join(err, configutils.ErrInvalid{Name: "SolKey", Value: e.JSON, Msg: "all fields must be nil or non-nil"})
}
// require valid id
Expand Down Expand Up @@ -271,18 +278,25 @@ func (a *AptosKeys) SetFrom(f *AptosKeys) error {
if f == nil || len(f.Keys) == 0 {
return nil
}
a.Keys = make([]*AptosKey, len(f.Keys))
copy(a.Keys, f.Keys)
// Replacing would discard the keys contributed by earlier -s files;
// validateMerge has already rejected any duplicated across them.
a.Keys = append(a.Keys, f.Keys...)
return nil
}

func (a *AptosKeys) validateMerge(f *AptosKeys) (err error) {
have := make(map[uint64]struct{})
if a != nil && f != nil {
for _, aptosKey := range a.Keys {
if aptosKey.ID == nil {
continue
}
have[*aptosKey.ID] = struct{}{}
}
for _, aptosKey := range f.Keys {
if aptosKey.ID == nil {
continue // a missing ID is a validation error, not a merge conflict
}
if _, ok := have[*aptosKey.ID]; ok {
err = errors.Join(err, configutils.ErrOverride{Name: fmt.Sprintf("AptosKeys: %d", *aptosKey.ID)})
}
Expand Down Expand Up @@ -360,18 +374,25 @@ func (s *StellarKeys) SetFrom(f *StellarKeys) error {
if f == nil || len(f.Keys) == 0 {
return nil
}
s.Keys = make([]*StellarKey, len(f.Keys))
copy(s.Keys, f.Keys)
// Replacing would discard the keys contributed by earlier -s files;
// validateMerge has already rejected any duplicated across them.
s.Keys = append(s.Keys, f.Keys...)
return nil
}

func (s *StellarKeys) validateMerge(f *StellarKeys) (err error) {
have := make(map[string]struct{})
if s != nil && f != nil {
for _, stellarKey := range s.Keys {
if stellarKey.ID == nil {
continue
}
have[*stellarKey.ID] = struct{}{}
}
for _, stellarKey := range f.Keys {
if stellarKey.ID == nil {
continue // a missing ID is a validation error, not a merge conflict
}
if _, ok := have[*stellarKey.ID]; ok {
err = errors.Join(err, configutils.ErrOverride{Name: "StellarKeys: " + *stellarKey.ID})
}
Expand Down Expand Up @@ -443,18 +464,25 @@ func (e *EthKeys) SetFrom(f *EthKeys) error {
if f == nil || len(f.Keys) == 0 {
return nil
}
e.Keys = make([]*EthKey, len(f.Keys))
copy(e.Keys, f.Keys)
// Replacing would discard the keys contributed by earlier -s files;
// validateMerge has already rejected any duplicated across them.
e.Keys = append(e.Keys, f.Keys...)
return nil
}

func (e *EthKeys) validateMerge(f *EthKeys) (err error) {
have := make(map[int]struct{})
if e != nil && f != nil {
for _, ethKey := range e.Keys {
if ethKey.ID == nil {
continue
}
have[*ethKey.ID] = struct{}{}
}
for _, ethKey := range f.Keys {
if ethKey.ID == nil {
continue // a missing ID is a validation error, not a merge conflict
}
if _, ok := have[*ethKey.ID]; ok {
err = errors.Join(err, configutils.ErrOverride{Name: fmt.Sprintf("EthKeys: %d", *ethKey.ID)})
}
Expand Down Expand Up @@ -612,7 +640,7 @@ func (e *EthKey) validateMerge(f *EthKey) (err error) {
}

func (e *EthKey) ValidateConfig() (err error) {
if (e.JSON != nil) != (e.Password != nil) && (e.Password != nil) != (e.ID != nil) {
if (e.JSON != nil) != (e.Password != nil) || (e.Password != nil) != (e.ID != nil) {
err = errors.Join(err, configutils.ErrInvalid{Name: "EthKey", Value: e.JSON, Msg: "all fields must be nil or non-nil"})
}
// require valid id
Expand Down
159 changes: 159 additions & 0 deletions core/config/toml/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,165 @@ func TestEthKeys_SetFrom(t *testing.T) {
assert.Equal(t, ethKeysWrapper2, *ethKeysWrapper1)
}

func TestEthKeys_SetFrom_multipleSecretsFiles(t *testing.T) {
t.Parallel()
// Secrets files are applied in order and must union: a key from an earlier
// -s file has to survive a later file that only carries other chains' keys.
base := &EthKeys{Keys: []*EthKey{
{JSON: new(models.Secret("key1")), Password: new(models.Secret("pass1")), ID: new(1)},
}}
disjoint := &EthKeys{Keys: []*EthKey{
{JSON: new(models.Secret("key56")), Password: new(models.Secret("pass56")), ID: new(56)},
}}

require.NoError(t, base.SetFrom(disjoint))

ids := make([]int, 0, len(base.Keys))
for _, k := range base.Keys {
ids = append(ids, *k.ID)
}
assert.Equal(t, []int{1, 56}, ids, "keys from earlier secrets files must not be discarded")

// Union must not weaken the no-overrides guarantee the -s flag documents.
dupe := &EthKeys{Keys: []*EthKey{
{JSON: new(models.Secret("other")), Password: new(models.Secret("otherpass")), ID: new(1)},
}}
require.Error(t, base.SetFrom(dupe))
assert.Len(t, base.Keys, 2)
}

func TestEthKeys_validateMerge_nilID(t *testing.T) {
t.Parallel()
// A secrets file may omit ID, and merging must survive it: a missing field
// is a validation error, not a crash.
base := &EthKeys{}
noID := &EthKeys{Keys: []*EthKey{
{JSON: new(models.Secret("key1")), Password: new(models.Secret("pass1"))},
}}
require.NotPanics(t, func() {
require.NoError(t, base.SetFrom(noID))
})
}

func TestSolKeys_SetFrom_multipleSecretsFiles(t *testing.T) {
t.Parallel()
base := &SolKeys{Keys: []*SolKey{
{JSON: new(models.Secret("key1")), Password: new(models.Secret("pass1")), ID: new("devnet")},
}}
disjoint := &SolKeys{Keys: []*SolKey{
{JSON: new(models.Secret("key2")), Password: new(models.Secret("pass2")), ID: new("mainnet")},
}}

require.NoError(t, base.SetFrom(disjoint))

ids := make([]string, 0, len(base.Keys))
for _, k := range base.Keys {
ids = append(ids, *k.ID)
}
assert.Equal(t, []string{"devnet", "mainnet"}, ids, "keys from earlier secrets files must not be discarded")

dupe := &SolKeys{Keys: []*SolKey{
{JSON: new(models.Secret("other")), Password: new(models.Secret("otherpass")), ID: new("devnet")},
}}
require.Error(t, base.SetFrom(dupe))
assert.Len(t, base.Keys, 2)

require.NotPanics(t, func() {
noID := &SolKeys{Keys: []*SolKey{{JSON: new(models.Secret("k"))}}}
require.NoError(t, (&SolKeys{}).SetFrom(noID))
})
}

func TestAptosKeys_SetFrom_multipleSecretsFiles(t *testing.T) {
t.Parallel()
base := &AptosKeys{Keys: []*AptosKey{
{JSON: new(models.Secret("key1")), Password: new(models.Secret("pass1")), ID: new(uint64(1))},
}}
disjoint := &AptosKeys{Keys: []*AptosKey{
{JSON: new(models.Secret("key2")), Password: new(models.Secret("pass2")), ID: new(uint64(2))},
}}

require.NoError(t, base.SetFrom(disjoint))

ids := make([]uint64, 0, len(base.Keys))
for _, k := range base.Keys {
ids = append(ids, *k.ID)
}
assert.Equal(t, []uint64{1, 2}, ids, "keys from earlier secrets files must not be discarded")

dupe := &AptosKeys{Keys: []*AptosKey{
{JSON: new(models.Secret("other")), Password: new(models.Secret("otherpass")), ID: new(uint64(1))},
}}
require.Error(t, base.SetFrom(dupe))
assert.Len(t, base.Keys, 2)

require.NotPanics(t, func() {
noID := &AptosKeys{Keys: []*AptosKey{{JSON: new(models.Secret("k"))}}}
require.NoError(t, (&AptosKeys{}).SetFrom(noID))
})
}

func TestStellarKeys_SetFrom_multipleSecretsFiles(t *testing.T) {
t.Parallel()
base := &StellarKeys{Keys: []*StellarKey{
{JSON: new(commonconfig.SecretString("key1")), Password: new(commonconfig.SecretString("pass1")), ID: new("testnet")},
}}
disjoint := &StellarKeys{Keys: []*StellarKey{
{JSON: new(commonconfig.SecretString("key2")), Password: new(commonconfig.SecretString("pass2")), ID: new("pubnet")},
}}

require.NoError(t, base.SetFrom(disjoint))

ids := make([]string, 0, len(base.Keys))
for _, k := range base.Keys {
ids = append(ids, *k.ID)
}
assert.Equal(t, []string{"testnet", "pubnet"}, ids, "keys from earlier secrets files must not be discarded")

dupe := &StellarKeys{Keys: []*StellarKey{
{JSON: new(commonconfig.SecretString("other")), Password: new(commonconfig.SecretString("otherpass")), ID: new("testnet")},
}}
require.Error(t, base.SetFrom(dupe))
assert.Len(t, base.Keys, 2)

require.NotPanics(t, func() {
noID := &StellarKeys{Keys: []*StellarKey{{JSON: new(commonconfig.SecretString("k"))}}}
require.NoError(t, (&StellarKeys{}).SetFrom(noID))
})
}

// A key with only some of JSON/Password/ID set must be rejected, not silently
// accepted. All four key types share the "all fields must be nil or non-nil"
// rule.
func TestKeys_ValidateConfig_partialFields(t *testing.T) {
t.Parallel()
secret := new(models.Secret("s"))
stellarSecret := new(commonconfig.SecretString("s"))

for _, tt := range []struct {
name string
cfg interface{ ValidateConfig() error }
}{
{"EthKey missing ID", &EthKey{JSON: secret, Password: secret}},
{"EthKey missing Password", &EthKey{JSON: secret, ID: new(1)}},
{"SolKey missing ID", &SolKey{JSON: secret, Password: secret}},
{"SolKey missing Password", &SolKey{JSON: secret, ID: new("devnet")}},
{"AptosKey missing ID", &AptosKey{JSON: secret, Password: secret}},
{"StellarKey missing ID", &StellarKey{JSON: stellarSecret, Password: stellarSecret}},
} {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
require.Error(t, tt.cfg.ValidateConfig())
})
}

// All-nil remains valid: an absent key section is not an error.
require.NoError(t, (&EthKey{}).ValidateConfig())
require.NoError(t, (&SolKey{}).ValidateConfig())
require.NoError(t, (&AptosKey{}).ValidateConfig())
require.NoError(t, (&StellarKey{}).ValidateConfig())
}

func TestBridgeStatusReporter_ValidateConfig(t *testing.T) {
testCases := []struct {
name string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Sharded capability routing via DON families.
#
# The same capability (evm-2337 write target) is hosted on multiple capability DON shards.
# Each workflow shard is routed to exactly one capability shard by sharing a per-shard DON
# family, while a common family ("zone-a") keeps every workflow shard connected to the
# gateway and to shared (non-sharded) capability DONs.
# The same capability (evm-1337) is hosted on multiple capability DON shards. Each workflow
# shard is routed to exactly one capability shard by sharing a per-shard DON family, while a
# common family ("zone-a") keeps every workflow shard connected to the gateway and to shared
# (non-sharded) capability DONs.
#
# The workflow shards deliberately host no EVM capability of their own: if they did, the
# launcher would serve evm-1337 locally and family routing would never be exercised.
#
# Family layout (see don_families):
# workflow-shard-0 : don_families=["zone-a", "zone-a_shard-0"]
Expand All @@ -14,7 +17,7 @@
# bootstrap-gateway: don_families=["zone-a"]
#
# The launcher's family-overlap filter therefore routes workflow-shard-0 -> cap-shard-0 and
# workflow-shard-1 -> cap-shard-1 for evm-2337, while both shards reach shared-cap via "zone-a".
# workflow-shard-1 -> cap-shard-1 for evm-1337, while both shards reach shared-cap via "zone-a".
# Gateway pairing uses the primary (first) don_families entry ("zone-a") only.

[chip_router]
Expand Down Expand Up @@ -58,7 +61,7 @@
supported_evm_chains = [1337, 2337]

env_vars = { CL_EVM_CMD = "", OTEL_SERVICE_NAME = "chainlink-node", CL_CRE_SETTINGS = '{"global":{"PerOrg":{"BaseTriggerRetransmitEnabled":"true"}}}' }
capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time", "evm-1337"]
capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time"]
registry_based_launch_allowlist = ["cron-trigger@1.0.0", "dontime@1.0.0"]

[nodesets.db]
Expand Down Expand Up @@ -113,7 +116,7 @@
supported_evm_chains = [1337, 2337]

env_vars = { CL_EVM_CMD = "", OTEL_SERVICE_NAME = "chainlink-node", CL_CRE_SETTINGS = '{"global":{"PerOrg":{"BaseTriggerRetransmitEnabled":"true"}}}' }
capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time", "evm-1337"]
capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time"]
registry_based_launch_allowlist = ["cron-trigger@1.0.0", "dontime@1.0.0"]

[nodesets.db]
Expand All @@ -140,7 +143,7 @@
supported_evm_chains = [1337, 2337]

env_vars = { CL_EVM_CMD = "", OTEL_SERVICE_NAME = "chainlink-node", CL_CRE_SETTINGS = '{"global":{"PerOrg":{"BaseTriggerRetransmitEnabled":"true"}}}' }
capabilities = ["evm-2337"]
capabilities = ["evm-1337"]

[nodesets.db]
image = "postgres:15.0"
Expand All @@ -166,7 +169,7 @@
supported_evm_chains = [1337, 2337]

env_vars = { CL_EVM_CMD = "", OTEL_SERVICE_NAME = "chainlink-node", CL_CRE_SETTINGS = '{"global":{"PerOrg":{"BaseTriggerRetransmitEnabled":"true"}}}' }
capabilities = ["evm-2337"]
capabilities = ["evm-1337"]

[nodesets.db]
image = "postgres:15.0"
Expand Down
2 changes: 1 addition & 1 deletion core/services/pipeline/bridgeconn/bridge_conn_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (

// observationTTL bounds how long a cached observation may be served before it is
// treated as stale. Hardcoded for now; may become configurable later.
const observationTTL = 60 * time.Second
const observationTTL = 90 * time.Second

// cacheEntry pairs a cached observation with the time it was stored, so
// GetObservation can reject entries older than observationTTL.
Expand Down
Loading
Loading