From e4a57da528709ac2636cd9ce387e613e4d4f49a0 Mon Sep 17 00:00:00 2001 From: george-dorin <120329946+george-dorin@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:08:07 +0000 Subject: [PATCH 1/2] Lower MaxResultsPerQuery to 250 so getWorkflowListByDON fits under RPC gas caps (#24229) Lower workflow registry query page size to avoid RPC gas cap (cherry picked from commit 31bc3d9878fe482f05c60f85dccede9f392e04d2) --- .../v2/contract_workflow_source_test.go | 72 ++++++++++++++++++- .../workflows/syncer/v2/workflow_registry.go | 6 +- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/core/services/workflows/syncer/v2/contract_workflow_source_test.go b/core/services/workflows/syncer/v2/contract_workflow_source_test.go index f0d1ebbde5d..196e9c5f528 100644 --- a/core/services/workflows/syncer/v2/contract_workflow_source_test.go +++ b/core/services/workflows/syncer/v2/contract_workflow_source_test.go @@ -3,6 +3,8 @@ package v2 import ( "context" "errors" + "fmt" + "math/big" "reflect" "testing" @@ -37,6 +39,9 @@ var ( type mockWorkflowContractReader struct { commontypes.ContractReader workflowList []workflow_registry_wrapper_v2.WorkflowRegistryWorkflowMetadataView + // onGet, when set, returns the workflow list for a specific query (e.g. one page). + onGet func(params GetWorkflowListByDONParams) []workflow_registry_wrapper_v2.WorkflowRegistryWorkflowMetadataView + calls []GetWorkflowListByDONParams head *commontypes.Head getLatestErr error bindErr error @@ -47,17 +52,30 @@ func (m *mockWorkflowContractReader) GetLatestValueWithHeadData( _ context.Context, _ string, _ primitives.ConfidenceLevel, - _ any, + params any, result any, ) (*commontypes.Head, error) { if m.getLatestErr != nil { return nil, m.getLatestErr } + list := m.workflowList + if p, ok := params.(GetWorkflowListByDONParams); ok { + // The caller mutates Start between pages, so snapshot it for assertions. + m.calls = append(m.calls, GetWorkflowListByDONParams{ + DonFamily: p.DonFamily, + Start: new(big.Int).Set(p.Start), + Limit: new(big.Int).Set(p.Limit), + }) + if m.onGet != nil { + list = m.onGet(p) + } + } + resultVal := reflect.ValueOf(result).Elem() listField := resultVal.FieldByName("List") if listField.IsValid() && listField.CanSet() { - listField.Set(reflect.ValueOf(m.workflowList)) + listField.Set(reflect.ValueOf(list)) } return m.head, nil @@ -134,6 +152,56 @@ func TestContractWorkflowSource_ListWorkflowMetadata_Success(t *testing.T) { assert.Equal(t, "workflow-2", wfs[1].WorkflowName) } +func TestContractWorkflowSource_ListWorkflowMetadata_PaginatesAcrossPages(t *testing.T) { + t.Parallel() + lggr := logger.TestLogger(t) + ctx := t.Context() + + // One full page plus a short page so the loop is exercised end to end. + total := int(MaxResultsPerQuery) + 3 + all := make([]workflow_registry_wrapper_v2.WorkflowRegistryWorkflowMetadataView, 0, total) + for i := range total { + all = append(all, createTestWorkflowMetadata(fmt.Sprintf("workflow-%d", i), "family-a")) + } + + mockReader := &mockWorkflowContractReader{ + onGet: func(params GetWorkflowListByDONParams) []workflow_registry_wrapper_v2.WorkflowRegistryWorkflowMetadataView { + start := int(params.Start.Int64()) + if start >= len(all) { + return nil + } + end := min(start+int(params.Limit.Int64()), len(all)) + return all[start:end] + }, + head: &commontypes.Head{Height: "100"}, + } + + source := NewContractWorkflowSource( + lggr, + func(_ context.Context, _ []byte) (commontypes.ContractReader, error) { + return mockReader, nil + }, + testOwnerAddress, + "test-chain-selector", + ) + source.contractReader = mockReader + + don := capabilities.DON{ + ID: 1, + Families: []string{"family-a"}, + } + + wfs, _, err := source.ListWorkflowMetadata(ctx, don) + require.NoError(t, err) + assert.Len(t, wfs, total) + + require.Len(t, mockReader.calls, 2) + assert.Equal(t, int64(0), mockReader.calls[0].Start.Int64()) + assert.Equal(t, MaxResultsPerQuery, mockReader.calls[0].Limit.Int64()) + assert.Equal(t, MaxResultsPerQuery, mockReader.calls[1].Start.Int64()) + assert.Equal(t, MaxResultsPerQuery, mockReader.calls[1].Limit.Int64()) +} + func TestContractWorkflowSource_ListWorkflowMetadata_MultipleDONFamilies(t *testing.T) { t.Parallel() lggr := logger.TestLogger(t) diff --git a/core/services/workflows/syncer/v2/workflow_registry.go b/core/services/workflows/syncer/v2/workflow_registry.go index 70929e42260..a8e39a1ab2e 100644 --- a/core/services/workflows/syncer/v2/workflow_registry.go +++ b/core/services/workflows/syncer/v2/workflow_registry.go @@ -53,8 +53,10 @@ var ( defaultTickIntervalForAllowlistedRequests = 5 * time.Second // MaxResultsPerQuery defines the maximum number of results that can be queried in a single request. - // The default value of 1,000 was chosen based on expected system performance and typical use cases. - MaxResultsPerQuery = int64(1_000) + // getWorkflowListByDON costs roughly 50k gas per returned workflow, so the page size must keep a + // single eth_call well under the RPC node's gas cap (commonly 16,777,216). At 1,000 the call needs + // >30M gas once ~600 workflows are indexed and is rejected outright; 250 keeps a page around 12.5M. + MaxResultsPerQuery = int64(250) ) // WorkflowRegistrySyncer is the public interface of the package. From b236223d1120a8042a138f8939c63b6873e9d5fd Mon Sep 17 00:00:00 2001 From: Patrick Huie Date: Wed, 18 Nov 2026 17:45:46 -0500 Subject: [PATCH 2/2] Add patch changeset for workflow registry page size hotfix --- .changeset/lower-workflow-registry-page-size.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lower-workflow-registry-page-size.md diff --git a/.changeset/lower-workflow-registry-page-size.md b/.changeset/lower-workflow-registry-page-size.md new file mode 100644 index 00000000000..b88480888ff --- /dev/null +++ b/.changeset/lower-workflow-registry-page-size.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#bugfix Lower the Workflow Registry syncer page size from 1000 to 250 so a single `getWorkflowListByDON` eth_call stays under the common 16,777,216 gas cap and registry reconciliation no longer fails once a DON family indexes enough workflows.