Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package auth

import (
"crypto/sha3"
"encoding/hex"
"fmt"
"hash"

pkgerrors "github.com/pkg/errors"

"github.com/smartcontractkit/chainlink/v2/core/utils"

"golang.org/x/crypto/sha3"
)

var (
Expand Down Expand Up @@ -55,7 +55,7 @@ func hashInput(ta *Token, salt string) []byte {
// HashedSecret generates a hashed password for an external initiator
// authentication
func HashedSecret(ta *Token, salt string) (string, error) {
hasher := sha3.New256()
hasher := hash.Hash(sha3.New256())
_, err := hasher.Write(hashInput(ta, salt))
if err != nil {
return "", pkgerrors.Wrap(err, "error writing external initiator authentication to hasher")
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ccipevm/msghasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"os"

"math/big"
"math/rand"
"strings"
Expand Down Expand Up @@ -464,7 +465,7 @@ func TestMessagerHasher_againstRmnSharedVector(t *testing.T) {
// onramp address: 0x89559ce6904d4c4b0f6aab9065ad02b1ed531be4
// sequence numbers 386 to 419.
var msgs []cciptypes.Message
data, err := ioutil.ReadFile("msgs_test_vector.json")
data, err := os.ReadFile("msgs_test_vector.json")
require.NoError(t, err)

err = json.Unmarshal(data, &msgs)
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipsolana/extradatacodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (d ExtraDataDecoder) DecodeExtraArgsToMap(extraArgs cciptypes.Bytes) (map[s
return nil, fmt.Errorf("failed to decode extra args: %w", err)
}
val = reflect.ValueOf(args)
typ = reflect.TypeOf(args)
typ = reflect.TypeFor[fee_quoter.GenericExtraArgsV2]()
case string(svmExtraArgsV1Tag):
var args fee_quoter.SVMExtraArgsV1
decoder := agbinary.NewBorshDecoder(extraArgs[4:])
Expand All @@ -61,7 +61,7 @@ func (d ExtraDataDecoder) DecodeExtraArgsToMap(extraArgs cciptypes.Bytes) (map[s
return nil, fmt.Errorf("failed to decode extra args: %w", err)
}
val = reflect.ValueOf(args)
typ = reflect.TypeOf(args)
typ = reflect.TypeFor[fee_quoter.SVMExtraArgsV1]()
default:
return nil, fmt.Errorf("unknown extra args tag: %x", extraArgs[:4])
}
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipsolana/msghasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func parseExtraDataMap(input map[string]any) (extraData, error) {
a[i] = solana.PublicKeyFromBytes(val[:])
}
accounts = a
case []interface{}: // LOOP gRPC converts [][32]byte -> []interface{}
case []any: // LOOP gRPC converts [][32]byte -> []interface{}
a := make([]solana.PublicKey, len(v))
for i, elem := range v {
bs, ok := elem.([]byte)
Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/ccip/ccipsolana/msghasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestParseExtraDataMap_LOOPConvertedTypes(t *testing.T) {
"AccountIsWritableBitmap": int64(6), // LOOP: uint64 -> int64
"AllowOutOfOrderExecution": true,
"TokenReceiver": receiver, // LOOP: [32]byte -> []byte
"Accounts": []interface{}{ // LOOP: [][32]byte -> []interface{}
"Accounts": []any{ // LOOP: [][32]byte -> []interface{}
account1,
account2,
},
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestParseExtraDataMap_InvalidTypes(t *testing.T) {

t.Run("Accounts element wrong length", func(t *testing.T) {
input := map[string]any{
"Accounts": []interface{}{
"Accounts": []any{
[]byte{0x01, 0x02}, // not 32 bytes
},
}
Expand All @@ -204,7 +204,7 @@ func TestParseExtraDataMap_InvalidTypes(t *testing.T) {

t.Run("Accounts element wrong type", func(t *testing.T) {
input := map[string]any{
"Accounts": []interface{}{
"Accounts": []any{
"not bytes",
},
}
Expand Down
16 changes: 9 additions & 7 deletions core/capabilities/ccip/configs/sui/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func GetChainWriterConfig(publicKeyStr string) (types.ChainWriterConfig, error)
PTBCommands: []types.ChainWriterPTBCommand{
{
Type: types.SuiPTBCommandMoveCall,
ModuleId: strPtr("offramp"),
Function: strPtr("commit"),
ModuleId: new("offramp"),
Function: new("commit"),
Params: []types.SuiFunctionParam{
{
Name: "ref",
Expand Down Expand Up @@ -77,8 +77,8 @@ func GetChainWriterConfig(publicKeyStr string) (types.ChainWriterConfig, error)
PTBCommands: []types.ChainWriterPTBCommand{
{
Type: types.SuiPTBCommandMoveCall,
ModuleId: strPtr("offramp"),
Function: strPtr("init_execute"),
ModuleId: new("offramp"),
Function: new("init_execute"),
Params: []types.SuiFunctionParam{
{
Name: "ref",
Expand Down Expand Up @@ -116,8 +116,8 @@ func GetChainWriterConfig(publicKeyStr string) (types.ChainWriterConfig, error)
},
{
Type: types.SuiPTBCommandMoveCall,
ModuleId: strPtr("offramp"),
Function: strPtr("finish_execute"),
ModuleId: new("offramp"),
Function: new("finish_execute"),
Params: []types.SuiFunctionParam{
{
Name: "ref",
Expand Down Expand Up @@ -151,6 +151,8 @@ func GetChainWriterConfig(publicKeyStr string) (types.ChainWriterConfig, error)
}

// Helper function to convert a string to a string pointer
//
//go:fix inline
func strPtr(s string) *string {
return &s
return new(s)
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,17 @@ func TestWrappedCounter_ConcurrentIncrements(t *testing.T) {
const incrementsPerGoroutine = 100
done := make(chan bool, numGoroutines)

for i := 0; i < numGoroutines; i++ {
for range numGoroutines {
go func() {
for j := 0; j < incrementsPerGoroutine; j++ {
for range incrementsPerGoroutine {
baseCounter.Inc()
}
done <- true
}()
}

// Wait for all goroutines
for i := 0; i < numGoroutines; i++ {
for range numGoroutines {
<-done
}

Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/fakes/confidential_http_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (fh *DirectConfidentialHTTPAction) SendRequest(ctx context.Context, metadat
method = strings.ToUpper(method)

// Prepare template data from loaded secrets
templateData := make(map[string]interface{})
templateData := make(map[string]any)
for k, v := range fh.secretsConfig.SecretsNames {
if len(v) == 1 {
templateData[k] = v[0]
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/triggers/trigger_event_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ UPDATE ` + triggerPendingEventsTable + `
SET last_sent_at = $3, attempts = $4
WHERE trigger_id = $1 AND event_id = $2
`
var lastSent interface{}
var lastSent any
if !lastSentAt.IsZero() {
lastSent = lastSentAt
}
Expand Down
54 changes: 18 additions & 36 deletions core/capabilities/vault/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ func TestCapability_CapabilityCall(t *testing.T) {
require.NoError(t, err)

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -116,7 +114,7 @@ func TestCapability_CapabilityCall(t *testing.T) {
}
}
}
}()
})

resp, err := capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -196,9 +194,7 @@ func TestCapability_CapabilityCall_DuringSubscriptionPhase(t *testing.T) {
require.NoError(t, err)

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -215,7 +211,7 @@ func TestCapability_CapabilityCall_DuringSubscriptionPhase(t *testing.T) {
}
}
}
}()
})

resp, err := capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -497,9 +493,7 @@ func TestCapability_CapabilityCall_SecretIdentifierOwnerMismatch(t *testing.T) {

if !tc.shouldReject {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -515,7 +509,7 @@ func TestCapability_CapabilityCall_SecretIdentifierOwnerMismatch(t *testing.T) {
}
}
}
}()
})
defer wg.Wait()
}

Expand Down Expand Up @@ -584,9 +578,7 @@ func TestCapability_CapabilityCall_UsesMetadataWorkflowOwner(t *testing.T) {
require.NoError(t, err)

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -599,7 +591,7 @@ func TestCapability_CapabilityCall_UsesMetadataWorkflowOwner(t *testing.T) {
}
}
}
}()
})

_, err = capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -664,9 +656,7 @@ func TestCapability_CapabilityCall_ForwardsRequestGetSecretsIdentity(t *testing.
forward *vault.GetSecretsRequest
forwardedOK bool
)
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -690,7 +680,7 @@ func TestCapability_CapabilityCall_ForwardsRequestGetSecretsIdentity(t *testing.
return
}
}
}()
})

_, err = capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -759,9 +749,7 @@ func TestCapability_CapabilityCall_BackfillsGetSecretsWorkflowOwnerFromFirstSecr
forward *vault.GetSecretsRequest
forwardedOK bool
)
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -785,7 +773,7 @@ func TestCapability_CapabilityCall_BackfillsGetSecretsWorkflowOwnerFromFirstSecr
return
}
}
}()
})

_, err = capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -846,9 +834,7 @@ func TestCapability_CapabilityCall_ReturnsIncorrectType(t *testing.T) {
require.NoError(t, err)

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -865,7 +851,7 @@ func TestCapability_CapabilityCall_ReturnsIncorrectType(t *testing.T) {
}
}
}
}()
})

_, err = capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -924,9 +910,7 @@ func TestCapability_CapabilityCall_TimeOut(t *testing.T) {
require.NoError(t, err)

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -939,7 +923,7 @@ func TestCapability_CapabilityCall_TimeOut(t *testing.T) {
}
}
}
}()
})

_, err = capability.Execute(t.Context(), capabilities.CapabilityRequest{
Payload: anyproto,
Expand Down Expand Up @@ -1613,9 +1597,7 @@ func TestCapability_CRUD(t *testing.T) {
wait := func() {}
if tc.error == "" {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for {
select {
case <-t.Context().Done():
Expand All @@ -1629,7 +1611,7 @@ func TestCapability_CRUD(t *testing.T) {
}
}
}
}()
})
wait = wg.Wait
}

Expand Down
Loading
Loading