From 66dbd0bfa6d500db46ca9b5579f03e101d094e71 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Wed, 4 Oct 2023 16:22:33 -0500 Subject: [PATCH 01/11] Remove legacy secrets support --- .../functions/external_adapter_client.go | 34 ++++++++++++++----- core/services/functions/listener.go | 4 +-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/core/services/functions/external_adapter_client.go b/core/services/functions/external_adapter_client.go index fc12406e442..815a6ebf2a6 100644 --- a/core/services/functions/external_adapter_client.go +++ b/core/services/functions/external_adapter_client.go @@ -62,14 +62,23 @@ type bridgeAccessor struct { var _ BridgeAccessor = (*bridgeAccessor)(nil) type requestPayload struct { - Endpoint string `json:"endpoint"` - RequestId string `json:"requestId"` - JobName string `json:"jobName"` - SubscriptionOwner string `json:"subscriptionOwner"` - SubscriptionId uint64 `json:"subscriptionId"` - Flags RequestFlags `json:"flags"` // marshalled as an array of numbers - NodeProvidedSecrets string `json:"nodeProvidedSecrets"` - Data *RequestData `json:"data"` + Endpoint string `json:"endpoint"` + RequestId string `json:"requestId"` + JobName string `json:"jobName"` + SubscriptionOwner string `json:"subscriptionOwner"` + SubscriptionId uint64 `json:"subscriptionId"` + Flags RequestFlags `json:"flags"` // marshalled as an array of numbers + NodeProvidedSecrets string `json:"nodeProvidedSecrets"` + Data *computationData `json:"data"` +} + +type computationData struct { + Source string `json:"source" cbor:"source"` + Language int `json:"language" cbor:"language"` + CodeLocation int `json:"codeLocation" cbor:"codeLocation"` + SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` + Args []string `json:"args,omitempty" cbor:"args"` + BytesArgs [][]byte `json:"bytesArgs,omitempty" cbor:"bytesArgs"` } type secretsPayload struct { @@ -138,7 +147,14 @@ func (ea *externalAdapterClient) RunComputation( SubscriptionId: subscriptionId, Flags: flags, NodeProvidedSecrets: nodeProvidedSecrets, - Data: requestData, + Data: &computationData{ + Source: requestData.Source, + Language: requestData.Language, + CodeLocation: requestData.CodeLocation, + SecretsLocation: requestData.SecretsLocation, + Args: requestData.Args, + BytesArgs: requestData.BytesArgs, + }, } userResult, userError, domains, err = ea.request(ctx, payload, requestId, jobName, "run_computation") diff --git a/core/services/functions/listener.go b/core/services/functions/listener.go index 084d1530a76..f32b904777d 100644 --- a/core/services/functions/listener.go +++ b/core/services/functions/listener.go @@ -706,8 +706,8 @@ func (l *FunctionsListener) getSecrets(ctx context.Context, eaClient ExternalAda if err != nil { return "", nil, errors.Wrap(err, "failed to fetch encrypted secrets") } - if len(userError) != 0 { - l.logger.Debugw("no valid threshold encrypted secrets detected, falling back to legacy secrets", "requestID", requestIDStr, "err", string(userError)) + if userError != nil { + return "", errors.New(string(userError)), nil } secrets = thresholdEncSecrets case LocationDONHosted: From ad203b522b05ca316a558bd940177d97c7bebcfd Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Thu, 5 Oct 2023 11:00:39 -0500 Subject: [PATCH 02/11] Update test case --- core/services/functions/external_adapter_client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/functions/external_adapter_client_test.go b/core/services/functions/external_adapter_client_test.go index a0d6d461099..9fd40ba8280 100644 --- a/core/services/functions/external_adapter_client_test.go +++ b/core/services/functions/external_adapter_client_test.go @@ -166,7 +166,7 @@ func TestRunComputation_CorrectAdapterRequest(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) assert.NoError(t, err) - expectedData := `{"source":"abcd","language":7,"codeLocation":42,"secrets":"qrvM","secretsLocation":88,"args":["arg1","arg2"]}` + expectedData := `{"source":"abcd","language":7,"codeLocation":42,"secretsLocation":88,"args":["arg1","arg2"]}` expectedBody := fmt.Sprintf(`{"endpoint":"lambda","requestId":"requestID1234","jobName":"TestJob","subscriptionOwner":"SubOwner","subscriptionId":1,"flags":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"nodeProvidedSecrets":"secRETS","data":%s}`, expectedData) assert.Equal(t, expectedBody, string(body)) From 79c2b8964605b8d3a858bb96aecb72b818297894 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Thu, 5 Oct 2023 12:30:22 -0500 Subject: [PATCH 03/11] Removed invalid secrets check from v0 tests --- .../functions/integration_tests/v0/internal/testutils.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go index 9013620e1e6..eee28bd8616 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go @@ -25,7 +25,6 @@ import ( "github.com/smartcontractkit/libocr/commontypes" confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/assets" @@ -415,9 +414,6 @@ func mockEALambdaExecutionResponse(t *testing.T, request map[string]any) []byte require.Equal(t, functions.LanguageJavaScript, int(data["language"].(float64))) require.Equal(t, functions.LocationInline, int(data["codeLocation"].(float64))) require.Equal(t, functions.LocationRemote, int(data["secretsLocation"].(float64))) - if data["secrets"] != DefaultSecretsBase64 && request["nodeProvidedSecrets"] != fmt.Sprintf(`{"0x0":"%s"}`, DefaultSecretsBase64) { - assert.Fail(t, "expected secrets or nodeProvidedSecrets to be '%s'", DefaultSecretsBase64) - } args := data["args"].([]interface{}) require.Equal(t, 2, len(args)) require.Equal(t, DefaultArg1, args[0].(string)) From 5c108eb43f53adf89fcde01a71b5c63f9096e39d Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Thu, 5 Oct 2023 14:33:33 -0500 Subject: [PATCH 04/11] Removed duplicate test which used legacy secrets --- .../v1/functions_integration_test.go | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go index 944bafadf75..8e4171c4ad2 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go @@ -27,33 +27,6 @@ func TestIntegration_Functions_MultipleV1Requests_Success(t *testing.T) { utils.SetupRouterRoutes(t, b, owner, routerContract, active.Address, proposed.Address, allowListContractAddress) - _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, nil, nil) - - pluginConfig := functionsConfig.ReportingPluginConfig{ - MaxQueryLengthBytes: 10_000, - MaxObservationLengthBytes: 15_000, - MaxReportLengthBytes: 15_000, - MaxRequestBatchSize: uint32(batchSize), - MaxReportTotalCallbackGas: uint32(maxTotalReportGas), - DefaultAggregationMethod: functionsConfig.AggregationMethod_AGGREGATION_MODE, - UniqueReports: true, - } - - // config for oracle contract - utils.SetOracleConfig(t, b, owner, active.Contract, oracleIdentities, batchSize, &pluginConfig) - - subscriptionId := utils.CreateAndFundSubscriptions(t, b, owner, linkToken, routerAddress, routerContract, clientContracts, allowListContract) - b.Commit() - utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, utils.DefaultSecretsBytes, subscriptionId, 1*time.Minute) -} - -func TestIntegration_Functions_MultipleV1Requests_ThresholdDecryptionSuccess(t *testing.T) { - // simulated chain with all contracts - owner, b, ticker, active, proposed, clientContracts, routerAddress, routerContract, linkToken, allowListContractAddress, allowListContract := utils.StartNewChainWithContracts(t, nClients) - defer ticker.Stop() - - utils.SetupRouterRoutes(t, b, owner, routerContract, active.Address, proposed.Address, allowListContractAddress) - _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, utils.ExportedOcr2Keystores, utils.MockThresholdKeyShares) pluginConfig := functionsConfig.ReportingPluginConfig{ From 017e33cdf921efebe33586ebd618d046d21c26f6 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Thu, 5 Oct 2023 14:40:07 -0500 Subject: [PATCH 05/11] Added threshold decryption setup to all v1 tests --- .../v1/functions_integration_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go index 8e4171c4ad2..36cb9ce2231 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go @@ -13,7 +13,7 @@ import ( var ( // a batch of 8 max-length results uses around 2M gas (assuming 70k gas per client callback - see FunctionsClientExample.sol) nOracleNodes = 4 - nClients = 50 + nClients = 1 requestLenBytes = 1_000 maxGas = 1_700_000 maxTotalReportGas = 560_000 @@ -64,7 +64,7 @@ func TestIntegration_Functions_MultipleV1Requests_WithUpgrade(t *testing.T) { utils.SetupRouterRoutes(t, b, owner, routerContract, active.Address, proposed.Address, allowListContractAddress) - _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, nil, nil) + _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, utils.ExportedOcr2Keystores, utils.MockThresholdKeyShares) pluginConfig := functionsConfig.ReportingPluginConfig{ MaxQueryLengthBytes: 10_000, @@ -74,6 +74,16 @@ func TestIntegration_Functions_MultipleV1Requests_WithUpgrade(t *testing.T) { MaxReportTotalCallbackGas: uint32(maxTotalReportGas), DefaultAggregationMethod: functionsConfig.AggregationMethod_AGGREGATION_MODE, UniqueReports: true, + ThresholdPluginConfig: &functionsConfig.ThresholdReportingPluginConfig{ + // approximately 750 bytes per test ciphertext + overhead + MaxQueryLengthBytes: 70_000, + MaxObservationLengthBytes: 70_000, + MaxReportLengthBytes: 70_000, + RequestCountLimit: 50, + RequestTotalBytesLimit: 50_000, + RequireLocalRequestCheck: true, + K: 2, + }, } // set config for both coordinators @@ -81,7 +91,7 @@ func TestIntegration_Functions_MultipleV1Requests_WithUpgrade(t *testing.T) { utils.SetOracleConfig(t, b, owner, proposed.Contract, oracleIdentities, batchSize, &pluginConfig) subscriptionId := utils.CreateAndFundSubscriptions(t, b, owner, linkToken, routerAddress, routerContract, clientContracts, allowListContract) - utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, utils.DefaultSecretsBytes, subscriptionId, 1*time.Minute) + utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, utils.DefaultSecretsUrlsBytes, subscriptionId, 1*time.Minute) // upgrade and send requests again _, err := routerContract.UpdateContracts(owner) From b09f6d10c235c58c633f4b3f6da122c37d6eb616 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Mon, 9 Oct 2023 13:56:14 -0500 Subject: [PATCH 06/11] Addressed feedback --- .../functions/external_adapter_client.go | 35 ++++++------------- core/services/functions/request.go | 2 +- .../v1/functions_integration_test.go | 31 ++++++++++++++-- .../v1/internal/testutils.go | 7 ++-- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/core/services/functions/external_adapter_client.go b/core/services/functions/external_adapter_client.go index 815a6ebf2a6..db4fed30e5f 100644 --- a/core/services/functions/external_adapter_client.go +++ b/core/services/functions/external_adapter_client.go @@ -62,23 +62,14 @@ type bridgeAccessor struct { var _ BridgeAccessor = (*bridgeAccessor)(nil) type requestPayload struct { - Endpoint string `json:"endpoint"` - RequestId string `json:"requestId"` - JobName string `json:"jobName"` - SubscriptionOwner string `json:"subscriptionOwner"` - SubscriptionId uint64 `json:"subscriptionId"` - Flags RequestFlags `json:"flags"` // marshalled as an array of numbers - NodeProvidedSecrets string `json:"nodeProvidedSecrets"` - Data *computationData `json:"data"` -} - -type computationData struct { - Source string `json:"source" cbor:"source"` - Language int `json:"language" cbor:"language"` - CodeLocation int `json:"codeLocation" cbor:"codeLocation"` - SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` - Args []string `json:"args,omitempty" cbor:"args"` - BytesArgs [][]byte `json:"bytesArgs,omitempty" cbor:"bytesArgs"` + Endpoint string `json:"endpoint"` + RequestId string `json:"requestId"` + JobName string `json:"jobName"` + SubscriptionOwner string `json:"subscriptionOwner"` + SubscriptionId uint64 `json:"subscriptionId"` + Flags RequestFlags `json:"flags"` // marshalled as an array of numbers + NodeProvidedSecrets string `json:"nodeProvidedSecrets"` + Data *RequestData `json:"data"` } type secretsPayload struct { @@ -138,6 +129,7 @@ func (ea *externalAdapterClient) RunComputation( nodeProvidedSecrets string, requestData *RequestData, ) (userResult, userError []byte, domains []string, err error) { + requestData.Secrets = nil // secrets are passed in nodeProvidedSecrets payload := requestPayload{ Endpoint: "lambda", @@ -147,14 +139,7 @@ func (ea *externalAdapterClient) RunComputation( SubscriptionId: subscriptionId, Flags: flags, NodeProvidedSecrets: nodeProvidedSecrets, - Data: &computationData{ - Source: requestData.Source, - Language: requestData.Language, - CodeLocation: requestData.CodeLocation, - SecretsLocation: requestData.SecretsLocation, - Args: requestData.Args, - BytesArgs: requestData.BytesArgs, - }, + Data: requestData, } userResult, userError, domains, err = ea.request(ctx, payload, requestId, jobName, "run_computation") diff --git a/core/services/functions/request.go b/core/services/functions/request.go index a6715e0a87f..847ca7ac461 100644 --- a/core/services/functions/request.go +++ b/core/services/functions/request.go @@ -22,7 +22,7 @@ type RequestData struct { Source string `json:"source" cbor:"source"` Language int `json:"language" cbor:"language"` CodeLocation int `json:"codeLocation" cbor:"codeLocation"` - Secrets []byte `json:"secrets" cbor:"secrets"` + Secrets []byte `json:"secrets,omitempty" cbor:"secrets"` SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` RequestSignature []byte `json:"requestSignature,omitempty" cbor:"requestSignature"` Args []string `json:"args,omitempty" cbor:"args"` diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go index 36cb9ce2231..e92cbe8bca4 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/functions_integration_test.go @@ -13,7 +13,7 @@ import ( var ( // a batch of 8 max-length results uses around 2M gas (assuming 70k gas per client callback - see FunctionsClientExample.sol) nOracleNodes = 4 - nClients = 1 + nClients = 50 requestLenBytes = 1_000 maxGas = 1_700_000 maxTotalReportGas = 560_000 @@ -27,6 +27,33 @@ func TestIntegration_Functions_MultipleV1Requests_Success(t *testing.T) { utils.SetupRouterRoutes(t, b, owner, routerContract, active.Address, proposed.Address, allowListContractAddress) + _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, nil, nil) + + pluginConfig := functionsConfig.ReportingPluginConfig{ + MaxQueryLengthBytes: 10_000, + MaxObservationLengthBytes: 15_000, + MaxReportLengthBytes: 15_000, + MaxRequestBatchSize: uint32(batchSize), + MaxReportTotalCallbackGas: uint32(maxTotalReportGas), + DefaultAggregationMethod: functionsConfig.AggregationMethod_AGGREGATION_MODE, + UniqueReports: true, + } + + // config for oracle contract + utils.SetOracleConfig(t, b, owner, active.Contract, oracleIdentities, batchSize, &pluginConfig) + + subscriptionId := utils.CreateAndFundSubscriptions(t, b, owner, linkToken, routerAddress, routerContract, clientContracts, allowListContract) + b.Commit() + utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, nil, subscriptionId, 1*time.Minute) +} + +func TestIntegration_Functions_MultipleV1Requests_ThresholdDecryptionSuccess(t *testing.T) { + // simulated chain with all contracts + owner, b, ticker, active, proposed, clientContracts, routerAddress, routerContract, linkToken, allowListContractAddress, allowListContract := utils.StartNewChainWithContracts(t, nClients) + defer ticker.Stop() + + utils.SetupRouterRoutes(t, b, owner, routerContract, active.Address, proposed.Address, allowListContractAddress) + _, _, oracleIdentities := utils.CreateFunctionsNodes(t, owner, b, routerAddress, nOracleNodes, maxGas, utils.ExportedOcr2Keystores, utils.MockThresholdKeyShares) pluginConfig := functionsConfig.ReportingPluginConfig{ @@ -97,5 +124,5 @@ func TestIntegration_Functions_MultipleV1Requests_WithUpgrade(t *testing.T) { _, err := routerContract.UpdateContracts(owner) require.NoError(t, err) b.Commit() - utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, utils.DefaultSecretsBytes, subscriptionId, 1*time.Minute) + utils.ClientTestRequests(t, owner, b, linkToken, routerAddress, routerContract, allowListContract, clientContracts, requestLenBytes, utils.DefaultSecretsUrlsBytes, subscriptionId, 1*time.Minute) } diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go index c376213ed13..fa9e34729f4 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go @@ -26,7 +26,6 @@ import ( "github.com/smartcontractkit/libocr/commontypes" confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" ocrtypes2 "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/assets" @@ -494,9 +493,9 @@ func mockEALambdaExecutionResponse(t *testing.T, request map[string]any) []byte data := request["data"].(map[string]any) require.Equal(t, functions.LanguageJavaScript, int(data["language"].(float64))) require.Equal(t, functions.LocationInline, int(data["codeLocation"].(float64))) - require.Equal(t, functions.LocationRemote, int(data["secretsLocation"].(float64))) - if data["secrets"] != DefaultSecretsBase64 && request["nodeProvidedSecrets"] != fmt.Sprintf(`{"0x0":"%s"}`, DefaultSecretsBase64) { - assert.Fail(t, "expected secrets or nodeProvidedSecrets to be '%s'", DefaultSecretsBase64) + if data["secrets"] != nil { + require.Equal(t, functions.LocationRemote, int(data["secretsLocation"].(float64))) + require.Equal(t, fmt.Sprintf(`{"0x0":"%s"}`, DefaultSecretsBase64), request["nodeProvidedSecrets"].(string)) } args := data["args"].([]interface{}) require.Equal(t, 2, len(args)) From de3b5449f7a143d0222246d28991655ad86e6e99 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Mon, 9 Oct 2023 13:59:47 -0500 Subject: [PATCH 07/11] Fixed import conflicts --- .../plugins/functions/integration_tests/v0/internal/testutils.go | 1 - .../plugins/functions/integration_tests/v1/internal/testutils.go | 1 - 2 files changed, 2 deletions(-) diff --git a/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go index e44b9f7a030..dc66536249d 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v0/internal/testutils.go @@ -21,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/smartcontractkit/libocr/commontypes" diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go index 97dbd2e991e..bb2fb378478 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go @@ -22,7 +22,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/onsi/gomega" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/smartcontractkit/libocr/commontypes" From ee730648f46b03fc29c3689c5ac071f13b15ba8d Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Tue, 10 Oct 2023 17:25:47 -0500 Subject: [PATCH 08/11] rolled back if statement change to prevent confusion --- core/services/functions/listener.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/functions/listener.go b/core/services/functions/listener.go index 7d9f763f081..f96fec6144c 100644 --- a/core/services/functions/listener.go +++ b/core/services/functions/listener.go @@ -697,7 +697,7 @@ func (l *FunctionsListener) getSecrets(ctx context.Context, eaClient ExternalAda if err != nil { return "", nil, errors.Wrap(err, "failed to fetch encrypted secrets") } - if userError != nil { + if len(userError) > 0 { return "", errors.New(string(userError)), nil } secrets = thresholdEncSecrets From dfa8e64c34ec95acb7f09f123352f43a2148c515 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Tue, 10 Oct 2023 17:26:27 -0500 Subject: [PATCH 09/11] rolled back change --- core/services/functions/listener.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/functions/listener.go b/core/services/functions/listener.go index f96fec6144c..f942629f515 100644 --- a/core/services/functions/listener.go +++ b/core/services/functions/listener.go @@ -697,7 +697,7 @@ func (l *FunctionsListener) getSecrets(ctx context.Context, eaClient ExternalAda if err != nil { return "", nil, errors.Wrap(err, "failed to fetch encrypted secrets") } - if len(userError) > 0 { + if len(userError) != 0 { return "", errors.New(string(userError)), nil } secrets = thresholdEncSecrets From 9bcd77d963bb1a0fb5da48ffe148f820cc717a93 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Wed, 11 Oct 2023 15:21:32 -0500 Subject: [PATCH 10/11] remove request signature field --- core/services/functions/request.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/services/functions/request.go b/core/services/functions/request.go index 755cfaa98ba..181058b83d0 100644 --- a/core/services/functions/request.go +++ b/core/services/functions/request.go @@ -10,14 +10,13 @@ const ( type RequestFlags [32]byte type RequestData struct { - Source string `json:"source" cbor:"source"` - Language int `json:"language" cbor:"language"` - CodeLocation int `json:"codeLocation" cbor:"codeLocation"` - Secrets []byte `json:"secrets,omitempty" cbor:"secrets"` - SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` - RequestSignature []byte `json:"requestSignature,omitempty" cbor:"requestSignature"` - Args []string `json:"args,omitempty" cbor:"args"` - BytesArgs [][]byte `json:"bytesArgs,omitempty" cbor:"bytesArgs"` + Source string `json:"source" cbor:"source"` + Language int `json:"language" cbor:"language"` + CodeLocation int `json:"codeLocation" cbor:"codeLocation"` + Secrets []byte `json:"secrets,omitempty" cbor:"secrets"` + SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` + Args []string `json:"args,omitempty" cbor:"args"` + BytesArgs [][]byte `json:"bytesArgs,omitempty" cbor:"bytesArgs"` } type DONHostedSecrets struct { From 208d4cfa4eee0f2bcbe20755503e55ed40c79342 Mon Sep 17 00:00:00 2001 From: Morgan Kuphal Date: Wed, 11 Oct 2023 15:32:58 -0500 Subject: [PATCH 11/11] fixed test check --- .../functions/integration_tests/v1/internal/testutils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go index 1042265fcc8..d90d14893c6 100644 --- a/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go +++ b/core/services/ocr2/plugins/functions/integration_tests/v1/internal/testutils.go @@ -494,7 +494,7 @@ func mockEALambdaExecutionResponse(t *testing.T, request map[string]any) []byte data := request["data"].(map[string]any) require.Equal(t, functions.LanguageJavaScript, int(data["language"].(float64))) require.Equal(t, functions.LocationInline, int(data["codeLocation"].(float64))) - if data["secrets"] != nil { + if len(request["nodeProvidedSecrets"].(string)) > 0 { require.Equal(t, functions.LocationRemote, int(data["secretsLocation"].(float64))) require.Equal(t, fmt.Sprintf(`{"0x0":"%s"}`, DefaultSecretsBase64), request["nodeProvidedSecrets"].(string)) }