Skip to content

Commit

Permalink
Merge branch 'develop' into TT-668-dockerhub-rate-issue-fix-internal-…
Browse files Browse the repository at this point in the history
…mirrors
  • Loading branch information
tateexon authored Nov 6, 2023
2 parents b2de27b + 0ae0b69 commit 47a7fd6
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-sign-publish-chainlink/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/goreleaser-build-sign-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions core/services/functions/connector_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
24 changes: 21 additions & 3 deletions core/services/functions/connector_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
})
})
Expand Down
17 changes: 8 additions & 9 deletions integration-tests/chaos/automation_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
},
Expand All @@ -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",
},
},
Expand All @@ -150,18 +149,18 @@ 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: {
ethereum.New(defaultEthereumSettings),
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",
},
},
Expand All @@ -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",
},
},
Expand Down
17 changes: 8 additions & 9 deletions integration-tests/chaos/ocr2vrf_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
},
Expand All @@ -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",
// },
//},
Expand All @@ -88,18 +87,18 @@ 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: {
// ethereum.New(defaultOCR2VRFEthereumSettings),
// 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",
// },
//},
Expand All @@ -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",
// },
//},
Expand Down
17 changes: 8 additions & 9 deletions integration-tests/chaos/ocr_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
},
Expand All @@ -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",
},
},
Expand All @@ -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",
},
},
Expand All @@ -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",
},
},
Expand All @@ -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")},
},
},
}
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/reorg/reorg_confirmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 47a7fd6

Please sign in to comment.