From 7b5e6a5ea6c4a450af73acd67a322553d033a16a Mon Sep 17 00:00:00 2001 From: Adam Hamrick Date: Mon, 6 Nov 2023 14:56:22 -0500 Subject: [PATCH 1/3] Fixes old pointer aliases (#11187) --- .../chaos/automation_chaos_test.go | 17 ++++++++--------- integration-tests/chaos/ocr2vrf_chaos_test.go | 17 ++++++++--------- integration-tests/chaos/ocr_chaos_test.go | 17 ++++++++--------- integration-tests/reorg/reorg_confirmer.go | 7 ++++--- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/integration-tests/chaos/automation_chaos_test.go b/integration-tests/chaos/automation_chaos_test.go index a3d4e37406d..22c9e742f38 100644 --- a/integration-tests/chaos/automation_chaos_test.go +++ b/integration-tests/chaos/automation_chaos_test.go @@ -14,7 +14,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/k8s/chaos" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - a "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/alias" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/cdk8s/blockscout" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" @@ -132,7 +131,7 @@ func TestAutomationChaos(t *testing.T) { chainlink.New(0, defaultAutomationSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -141,7 +140,7 @@ func TestAutomationChaos(t *testing.T) { chainlink.New(0, defaultAutomationSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -150,9 +149,9 @@ func TestAutomationChaos(t *testing.T) { chainlink.New(0, defaultAutomationSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, DurationStr: "1m", - ContainerNames: &[]*string{a.Str("chainlink-db")}, + ContainerNames: &[]*string{utils.Ptr("chainlink-db")}, }, }, NetworkChaosFailMajorityNetwork: { @@ -160,8 +159,8 @@ func TestAutomationChaos(t *testing.T) { chainlink.New(0, defaultAutomationSettings), chaos.NewNetworkPartition, &chaos.Props{ - FromLabels: &map[string]*string{ChaosGroupMajority: a.Str("1")}, - ToLabels: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + FromLabels: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, + ToLabels: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -170,8 +169,8 @@ func TestAutomationChaos(t *testing.T) { chainlink.New(0, defaultAutomationSettings), chaos.NewNetworkPartition, &chaos.Props{ - FromLabels: &map[string]*string{"app": a.Str("geth")}, - ToLabels: &map[string]*string{ChaosGroupMajorityPlus: a.Str("1")}, + FromLabels: &map[string]*string{"app": utils.Ptr("geth")}, + ToLabels: &map[string]*string{ChaosGroupMajorityPlus: utils.Ptr("1")}, DurationStr: "1m", }, }, diff --git a/integration-tests/chaos/ocr2vrf_chaos_test.go b/integration-tests/chaos/ocr2vrf_chaos_test.go index 0beccadddda..ba75974f01a 100644 --- a/integration-tests/chaos/ocr2vrf_chaos_test.go +++ b/integration-tests/chaos/ocr2vrf_chaos_test.go @@ -13,7 +13,6 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/k8s/chaos" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - a "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/alias" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/logging" @@ -68,7 +67,7 @@ func TestOCR2VRFChaos(t *testing.T) { chainlink.New(0, defaultOCR2VRFSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -78,7 +77,7 @@ func TestOCR2VRFChaos(t *testing.T) { // chainlink.New(0, defaultOCR2VRFSettings), // chaos.NewFailPods, // &chaos.Props{ - // LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + // LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, // DurationStr: "1m", // }, //}, @@ -88,9 +87,9 @@ func TestOCR2VRFChaos(t *testing.T) { // chainlink.New(0, defaultOCR2VRFSettings), // chaos.NewFailPods, // &chaos.Props{ - // LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + // LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, // DurationStr: "1m", - // ContainerNames: &[]*string{a.Str("chainlink-db")}, + // ContainerNames: &[]*string{utils.Ptr("chainlink-db")}, // }, //}, //NetworkChaosFailMajorityNetwork: { @@ -98,8 +97,8 @@ func TestOCR2VRFChaos(t *testing.T) { // chainlink.New(0, defaultOCR2VRFSettings), // chaos.NewNetworkPartition, // &chaos.Props{ - // FromLabels: &map[string]*string{ChaosGroupMajority: a.Str("1")}, - // ToLabels: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + // FromLabels: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, + // ToLabels: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, // DurationStr: "1m", // }, //}, @@ -108,8 +107,8 @@ func TestOCR2VRFChaos(t *testing.T) { // chainlink.New(0, defaultOCR2VRFSettings), // chaos.NewNetworkPartition, // &chaos.Props{ - // FromLabels: &map[string]*string{"app": a.Str("geth")}, - // ToLabels: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + // FromLabels: &map[string]*string{"app": utils.Ptr("geth")}, + // ToLabels: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, // DurationStr: "1m", // }, //}, diff --git a/integration-tests/chaos/ocr_chaos_test.go b/integration-tests/chaos/ocr_chaos_test.go index b65f8bb74f7..599fad8ddc5 100644 --- a/integration-tests/chaos/ocr_chaos_test.go +++ b/integration-tests/chaos/ocr_chaos_test.go @@ -15,7 +15,6 @@ import ( ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client" "github.com/smartcontractkit/chainlink-testing-framework/k8s/chaos" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - a "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/alias" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver" @@ -81,8 +80,8 @@ func TestOCRChaos(t *testing.T) { chainlink.New(0, defaultOCRSettings), chaos.NewNetworkPartition, &chaos.Props{ - FromLabels: &map[string]*string{ChaosGroupMajority: a.Str("1")}, - ToLabels: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + FromLabels: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, + ToLabels: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -91,8 +90,8 @@ func TestOCRChaos(t *testing.T) { chainlink.New(0, defaultOCRSettings), chaos.NewNetworkPartition, &chaos.Props{ - FromLabels: &map[string]*string{"app": a.Str("geth")}, - ToLabels: &map[string]*string{ChaosGroupMajorityPlus: a.Str("1")}, + FromLabels: &map[string]*string{"app": utils.Ptr("geth")}, + ToLabels: &map[string]*string{ChaosGroupMajorityPlus: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -101,7 +100,7 @@ func TestOCRChaos(t *testing.T) { chainlink.New(0, defaultOCRSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMinority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMinority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -110,7 +109,7 @@ func TestOCRChaos(t *testing.T) { chainlink.New(0, defaultOCRSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, DurationStr: "1m", }, }, @@ -119,9 +118,9 @@ func TestOCRChaos(t *testing.T) { chainlink.New(0, defaultOCRSettings), chaos.NewFailPods, &chaos.Props{ - LabelsSelector: &map[string]*string{ChaosGroupMajority: a.Str("1")}, + LabelsSelector: &map[string]*string{ChaosGroupMajority: utils.Ptr("1")}, DurationStr: "1m", - ContainerNames: &[]*string{a.Str("chainlink-db")}, + ContainerNames: &[]*string{utils.Ptr("chainlink-db")}, }, }, } diff --git a/integration-tests/reorg/reorg_confirmer.go b/integration-tests/reorg/reorg_confirmer.go index be535d2a6da..885bed2ad45 100644 --- a/integration-tests/reorg/reorg_confirmer.go +++ b/integration-tests/reorg/reorg_confirmer.go @@ -14,8 +14,9 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/blockchain" "github.com/smartcontractkit/chainlink-testing-framework/k8s/chaos" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" - a "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/alias" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/reorg" + + "github.com/smartcontractkit/chainlink/integration-tests/utils" ) // The steps are: @@ -231,8 +232,8 @@ func (rc *ReorgController) forkNetwork(header blockchain.NodeHeader) error { rc.cfg.Env.Cfg.Namespace, &chaos.Props{ DurationStr: "999h", - FromLabels: &map[string]*string{"app": a.Str(reorg.TXNodesAppLabel)}, - ToLabels: &map[string]*string{"app": a.Str(reorg.MinerNodesAppLabel)}, + FromLabels: &map[string]*string{"app": utils.Ptr(reorg.TXNodesAppLabel)}, + ToLabels: &map[string]*string{"app": utils.Ptr(reorg.MinerNodesAppLabel)}, }, )) rc.chaosExperimentName = expName From 2b3806209238ebe3b2d8199639bf5c864fe4ba3c Mon Sep 17 00:00:00 2001 From: Bolek <1416262+bolekk@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:01:26 -0800 Subject: [PATCH 2/3] [Functions] Respond with an error on insufficient balance (#11183) Co-authored-by: Morgan Kuphal <87319522+KuphJr@users.noreply.github.com> --- core/services/functions/connector_handler.go | 7 ++++++ .../functions/connector_handler_test.go | 24 ++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/services/functions/connector_handler.go b/core/services/functions/connector_handler.go index a018157a373..8a8710e6ea6 100644 --- a/core/services/functions/connector_handler.go +++ b/core/services/functions/connector_handler.go @@ -78,6 +78,13 @@ func (h *functionsConnectorHandler) HandleGatewayMessage(ctx context.Context, ga } if balance, err := h.subscriptions.GetMaxUserBalance(fromAddr); err != nil || balance.Cmp(h.minimumBalance.ToInt()) < 0 { h.lggr.Errorw("user subscription has insufficient balance", "id", gatewayId, "address", fromAddr, "balance", balance, "minBalance", h.minimumBalance) + response := functions.SecretsResponseBase{ + Success: false, + ErrorMessage: "user subscription has insufficient balance", + } + if err := h.sendResponse(ctx, gatewayId, body, response); err != nil { + h.lggr.Errorw("failed to send response to gateway", "id", gatewayId, "error", err) + } return } diff --git a/core/services/functions/connector_handler_test.go b/core/services/functions/connector_handler_test.go index bb3e2acbabd..7bf98d7501d 100644 --- a/core/services/functions/connector_handler_test.go +++ b/core/services/functions/connector_handler_test.go @@ -39,7 +39,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { allowlist.On("Close", mock.Anything).Return(nil) subscriptions.On("Start", mock.Anything).Return(nil) subscriptions.On("Close", mock.Anything).Return(nil) - handler, err := functions.NewFunctionsConnectorHandler(addr.Hex(), privateKey, storage, allowlist, rateLimiter, subscriptions, *assets.NewLinkFromJuels(0), logger) + handler, err := functions.NewFunctionsConnectorHandler(addr.Hex(), privateKey, storage, allowlist, rateLimiter, subscriptions, *assets.NewLinkFromJuels(100), logger) require.NoError(t, err) handler.SetConnector(connector) @@ -78,7 +78,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { } storage.On("List", ctx, addr).Return(snapshot, nil).Once() allowlist.On("Allow", addr).Return(true).Once() - subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil) + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -91,6 +91,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { t.Run("orm error", func(t *testing.T) { storage.On("List", ctx, addr).Return(nil, errors.New("boom")).Once() allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -135,7 +136,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { storage.On("Put", ctx, &key, &record, signature).Return(nil).Once() allowlist.On("Allow", addr).Return(true).Once() - subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil) + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -148,6 +149,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { t.Run("orm error", func(t *testing.T) { storage.On("Put", ctx, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("boom")).Once() allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -163,6 +165,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { require.NoError(t, msg.Sign(privateKey)) storage.On("Put", ctx, mock.Anything, mock.Anything, mock.Anything).Return(s4.ErrWrongSignature).Once() allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -177,6 +180,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { msg.Body.Payload = json.RawMessage(`{sdfgdfgoscsicosd:sdf:::sdf ::; xx}`) require.NoError(t, msg.Sign(privateKey)) allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { msg, ok := args[2].(*api.Message) require.True(t, ok) @@ -186,6 +190,19 @@ func TestFunctionsConnectorHandler(t *testing.T) { handler.HandleGatewayMessage(ctx, "gw1", &msg) }) + + t.Run("insufficient balance", func(t *testing.T) { + allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(0), nil).Once() + connector.On("SendToGateway", ctx, "gw1", mock.Anything).Run(func(args mock.Arguments) { + msg, ok := args[2].(*api.Message) + require.True(t, ok) + require.Equal(t, `{"success":false,"error_message":"user subscription has insufficient balance"}`, string(msg.Body.Payload)) + + }).Return(nil).Once() + + handler.HandleGatewayMessage(ctx, "gw1", &msg) + }) }) t.Run("unsupported method", func(t *testing.T) { @@ -201,6 +218,7 @@ func TestFunctionsConnectorHandler(t *testing.T) { require.NoError(t, msg.Sign(privateKey)) allowlist.On("Allow", addr).Return(true).Once() + subscriptions.On("GetMaxUserBalance", mock.Anything).Return(big.NewInt(100), nil).Once() handler.HandleGatewayMessage(testutils.Context(t), "gw1", &msg) }) }) From 0ae0b691466687ac7be2b49d9d4a1bd3136d6424 Mon Sep 17 00:00:00 2001 From: Erik Burton Date: Mon, 6 Nov 2023 13:24:15 -0800 Subject: [PATCH 3/3] chore: bump sigstore/cosign-installer from 2.1.0 to 3.1.2 (#11192) --- .github/actions/build-sign-publish-chainlink/action.yml | 2 +- .github/actions/goreleaser-build-sign-publish/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-sign-publish-chainlink/action.yml b/.github/actions/build-sign-publish-chainlink/action.yml index fe4ef858f58..62add53092a 100644 --- a/.github/actions/build-sign-publish-chainlink/action.yml +++ b/.github/actions/build-sign-publish-chainlink/action.yml @@ -223,7 +223,7 @@ runs: - if: inputs.sign-images == 'true' name: Install cosign - uses: sigstore/cosign-installer@581838fbedd492d2350a9ecd427a95d6de1e5d01 # v2.1.0 + uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 with: cosign-release: "v1.6.0" diff --git a/.github/actions/goreleaser-build-sign-publish/action.yml b/.github/actions/goreleaser-build-sign-publish/action.yml index 845d2443fc1..b2d42c1234e 100644 --- a/.github/actions/goreleaser-build-sign-publish/action.yml +++ b/.github/actions/goreleaser-build-sign-publish/action.yml @@ -84,7 +84,7 @@ runs: version: ${{ inputs.zig-version }} - name: Setup cosign if: inputs.enable-cosign == 'true' - uses: sigstore/cosign-installer@581838fbedd492d2350a9ecd427a95d6de1e5d01 # v2.1.0 + uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 with: cosign-release: ${{ inputs.cosign-version }} - name: Login to docker registry