Skip to content

Commit 9fab511

Browse files
[CAPPL-400] Fix/truncate workflow names #2 (#15896)
* fix(workflows/syncer): truncate workflow name * chore: changeset patch * (refactor): Move truncated hashed workflow name into engine. Ensure UTF8 encoding by hex encoding * (refactor): injectable name transform * Bump common to commit 42c3764c171e870bfd91443c6ae82a6e76bc6f1f * Use HashTruncateName in workflow registry syncer handler * Remove comment line * go mod tidy * Changes from review --------- Co-authored-by: Michael Street <[email protected]>
1 parent 796357b commit 9fab511

File tree

13 files changed

+55
-41
lines changed

13 files changed

+55
-41
lines changed

.changeset/wild-planes-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink": patch
3+
---
4+
5+
Truncates workflow name before starting engine

core/scripts/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ require (
3333
github.com/prometheus/client_golang v1.20.5
3434
github.com/shopspring/decimal v1.4.0
3535
github.com/smartcontractkit/chainlink-automation v0.8.1
36-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e
36+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e
3737
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3
3838
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13
3939
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919

core/scripts/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1
11641164
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY=
11651165
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg=
11661166
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
1167-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e h1:8BStiP1F4W8AvjBRga0TYtjvAtkwN8oHYnHJztAlSF4=
1168-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
1167+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e h1:l1npEX9O1Y1R4ss6yNPlggxFOdhPWmvD3tIMZkOzuDU=
1168+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
11691169
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0=
11701170
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk=
11711171
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3 h1:aeiBdBHGY8QNftps+VqrIk6OnfeeOD5z4jrAabW4ZSc=

core/services/workflows/engine.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,22 +1191,23 @@ func (e *Engine) Name() string {
11911191
}
11921192

11931193
type Config struct {
1194-
Workflow sdk.WorkflowSpec
1195-
WorkflowID string
1196-
WorkflowOwner string
1197-
WorkflowName string
1198-
Lggr logger.Logger
1199-
Registry core.CapabilitiesRegistry
1200-
MaxWorkerLimit int
1201-
QueueSize int
1202-
NewWorkerTimeout time.Duration
1203-
MaxExecutionDuration time.Duration
1204-
Store store.Store
1205-
Config []byte
1206-
Binary []byte
1207-
SecretsFetcher secretsFetcher
1208-
HeartbeatCadence time.Duration
1209-
StepTimeout time.Duration
1194+
Workflow sdk.WorkflowSpec
1195+
WorkflowID string
1196+
WorkflowOwner string
1197+
WorkflowName string // Full human-readable workflow name. Intended for metrics and logging.
1198+
WorkflowNameTransform string // The Workflow Name in an on-chain format, which has requirements of being hex encoded and max 10 bytes
1199+
Lggr logger.Logger
1200+
Registry core.CapabilitiesRegistry
1201+
MaxWorkerLimit int
1202+
QueueSize int
1203+
NewWorkerTimeout time.Duration
1204+
MaxExecutionDuration time.Duration
1205+
Store store.Store
1206+
Config []byte
1207+
Binary []byte
1208+
SecretsFetcher secretsFetcher
1209+
HeartbeatCadence time.Duration
1210+
StepTimeout time.Duration
12101211

12111212
// For testing purposes only
12121213
maxRetries int
@@ -1300,6 +1301,10 @@ func NewEngine(ctx context.Context, cfg Config) (engine *Engine, err error) {
13001301
workflow.hexName = hex.EncodeToString([]byte(cfg.WorkflowName))
13011302
workflow.name = cfg.WorkflowName
13021303

1304+
if len(cfg.WorkflowNameTransform) > 0 {
1305+
workflow.hexName = cfg.WorkflowNameTransform
1306+
}
1307+
13031308
engine = &Engine{
13041309
cma: cma,
13051310
logger: cfg.Lggr.Named("WorkflowEngine").With("workflowID", cfg.WorkflowID),

core/services/workflows/syncer/handler.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,20 @@ func (h *eventHandler) engineFactoryFn(ctx context.Context, id string, owner str
533533
}
534534

535535
cfg := workflows.Config{
536-
Lggr: h.lggr,
537-
Workflow: *sdkSpec,
538-
WorkflowID: id,
539-
WorkflowOwner: owner, // this gets hex encoded in the engine.
540-
WorkflowName: name,
541-
Registry: h.capRegistry,
542-
Store: h.workflowStore,
543-
Config: config,
544-
Binary: binary,
545-
SecretsFetcher: h,
536+
Lggr: h.lggr,
537+
Workflow: *sdkSpec,
538+
WorkflowID: id,
539+
WorkflowOwner: owner, // this gets hex encoded in the engine.
540+
WorkflowName: name,
541+
// Internal workflow names must not exceed 10 bytes for workflow engine and on-chain use.
542+
// A name is used internally that is first hashed to avoid collisions,
543+
// hex encoded to ensure UTF8 encoding, then truncated to 10 bytes.
544+
WorkflowNameTransform: pkgworkflows.HashTruncateName(name),
545+
Registry: h.capRegistry,
546+
Store: h.workflowStore,
547+
Config: config,
548+
Binary: binary,
549+
SecretsFetcher: h,
546550
}
547551
return workflows.NewEngine(ctx, cfg)
548552
}

deployment/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/smartcontractkit/chain-selectors v1.0.36
3232
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103
3333
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b
34-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e
34+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e
3535
github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0
3636
github.com/smartcontractkit/chainlink-solana v1.1.1-0.20250110142550-e2a9566d39f3
3737
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.2-0.20250110073248-456673e8eea2

deployment/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,8 +1390,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1
13901390
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY=
13911391
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b h1:UBXi9Yj8YSMHDDaxQLu273x1fWjyEL9xP58nuJsqZfg=
13921392
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250103152858-8973fd0c912b/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
1393-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e h1:8BStiP1F4W8AvjBRga0TYtjvAtkwN8oHYnHJztAlSF4=
1394-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
1393+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e h1:l1npEX9O1Y1R4ss6yNPlggxFOdhPWmvD3tIMZkOzuDU=
1394+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
13951395
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0=
13961396
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk=
13971397
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3 h1:aeiBdBHGY8QNftps+VqrIk6OnfeeOD5z4jrAabW4ZSc=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ require (
8080
github.com/smartcontractkit/chain-selectors v1.0.34
8181
github.com/smartcontractkit/chainlink-automation v0.8.1
8282
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103
83-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e
83+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e
8484
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e
8585
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3
8686
github.com/smartcontractkit/chainlink-feeds v0.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB
11541154
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
11551155
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103 h1:TeWnxdgSO2cYCKcBMwdkRcs/YdhSvXoWqqw7QWz/KeI=
11561156
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103/go.mod h1:ncjd6mPZSRlelEqH/2KeLE1pU3UlqzBSn8RYkEoECzY=
1157-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e h1:8BStiP1F4W8AvjBRga0TYtjvAtkwN8oHYnHJztAlSF4=
1158-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
1157+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e h1:l1npEX9O1Y1R4ss6yNPlggxFOdhPWmvD3tIMZkOzuDU=
1158+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e/go.mod h1:yti7e1+G9hhkYhj+L5sVUULn9Bn3bBL5/AxaNqdJ5YQ=
11591159
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e h1:PRoeby6ZlTuTkv2f+7tVU4+zboTfRzI+beECynF4JQ0=
11601160
github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241202195413-82468150ac1e/go.mod h1:mUh5/woemsVaHgTorA080hrYmO3syBCmPdnWc/5dOqk=
11611161
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241216163550-fa030d178ba3 h1:aeiBdBHGY8QNftps+VqrIk6OnfeeOD5z4jrAabW4ZSc=

integration-tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require (
4747
github.com/smartcontractkit/chain-selectors v1.0.36
4848
github.com/smartcontractkit/chainlink-automation v0.8.1
4949
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250110181647-9dba278f2103
50-
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250108194320-2ebd63bbb16e
50+
github.com/smartcontractkit/chainlink-common v0.4.1-0.20250113183410-42c3764c171e
5151
github.com/smartcontractkit/chainlink-protos/job-distributor v0.6.0
5252
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2
5353
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.19

0 commit comments

Comments
 (0)