Explorar o código

ci: upgrade golangci-lint to v2.1.2 (#4354)

* ci: update golangci-lint to 2.1.2

* fix importShadow violations

- Upgrading to golangci-lint 2.1.2 raised many new issues relating to
  the importShadow rule from go-critic
John Saigle hai 7 meses
pai
achega
a0349d8a3f

+ 1 - 1
.github/workflows/build.yml

@@ -297,7 +297,7 @@ jobs:
       - name: Formatting checks
         run: ./scripts/lint.sh -l -g format
       - name: Install linters
-        run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2
+        run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.2
       - name: Run linters
         run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint
       - name: Ensure generated proto matches

+ 1 - 1
DEVELOP.md

@@ -5,7 +5,7 @@
 The following dependencies are required for local development:
 
 - [Go](https://golang.org/dl/) >= 1.23.3 (latest minor release is recommended)
-    - [golangci-lint](https://golangci-lint.run/welcome/install/#install-from-sources) >= 2.0.0
+    - [golangci-lint](https://golangci-lint.run/welcome/install/#install-from-sources) >= 2.1.2
 - [Tilt](http://tilt.dev/) >= 0.20.8
 - Any of the local Kubernetes clusters supported by Tilt.
   We strongly recommend [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) >=

+ 6 - 6
node/cmd/ccq/query_server.go

@@ -206,14 +206,14 @@ func runQueryServer(cmd *cobra.Command, args []string) {
 
 	// Run p2p
 	pendingResponses := NewPendingResponses(logger)
-	p2p, err := runP2P(ctx, priv, *p2pPort, networkID, *p2pBootstrap, *ethRPC, *ethContract, pendingResponses, logger, *monitorPeers, loggingMap, *gossipAdvertiseAddress, protectedPeers)
+	p2pSub, err := runP2P(ctx, priv, *p2pPort, networkID, *p2pBootstrap, *ethRPC, *ethContract, pendingResponses, logger, *monitorPeers, loggingMap, *gossipAdvertiseAddress, protectedPeers)
 	if err != nil {
 		logger.Fatal("Failed to start p2p", zap.Error(err))
 	}
 
 	// Start the HTTP server
 	go func() {
-		s := NewHTTPServer(*listenAddr, p2p.topic_req, permissions, signerKey, pendingResponses, logger, env, loggingMap)
+		s := NewHTTPServer(*listenAddr, p2pSub.topic_req, permissions, signerKey, pendingResponses, logger, env, loggingMap)
 		logger.Sugar().Infof("Server listening on %s", *listenAddr)
 		err := s.ListenAndServe()
 		if err != nil && err != http.ErrServerClosed {
@@ -303,14 +303,14 @@ func runQueryServer(cmd *cobra.Command, args []string) {
 	permissions.StopWatcher()
 
 	// Shutdown p2p. Without this the same host won't properly discover peers until some timeout
-	p2p.sub.Cancel()
-	if err := p2p.topic_req.Close(); err != nil {
+	p2pSub.sub.Cancel()
+	if err := p2pSub.topic_req.Close(); err != nil {
 		logger.Error("Error closing the request topic", zap.Error(err))
 	}
-	if err := p2p.topic_resp.Close(); err != nil {
+	if err := p2pSub.topic_resp.Close(); err != nil {
 		logger.Error("Error closing the response topic", zap.Error(err))
 	}
-	if err := p2p.host.Close(); err != nil {
+	if err := p2pSub.host.Close(); err != nil {
 		logger.Error("Error closing the host", zap.Error(err))
 	}
 }

+ 7 - 7
node/cmd/guardiand/node.go

@@ -29,7 +29,7 @@ import (
 	"github.com/certusone/wormhole/node/pkg/watchers/sui"
 	"github.com/certusone/wormhole/node/pkg/wormconn"
 
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/telemetry"
 	"github.com/certusone/wormhole/node/pkg/version"
 	"github.com/gagliardetto/solana-go/rpc"
@@ -1100,7 +1100,7 @@ func runNode(cmd *cobra.Command, args []string) {
 	ipfslog.SetPrimaryCore(logger.Core())
 
 	// Database
-	db := db.OpenDb(logger.With(zap.String("component", "badgerDb")), dataDir)
+	db := guardianDB.OpenDb(logger.With(zap.String("component", "badgerDb")), dataDir)
 	defer db.Close()
 
 	wormchainId := "wormchain"
@@ -1948,21 +1948,21 @@ func runNode(cmd *cobra.Command, args []string) {
 	logger.Info("root context cancelled, exiting...")
 }
 
-func shouldStart(rpc *string) bool {
-	return *rpc != "" && *rpc != "none"
+func shouldStart(rpcURL *string) bool {
+	return *rpcURL != "" && *rpcURL != "none"
 }
 
 // checkEvmArgs verifies that the RPC and contract address parameters for an EVM chain make sense, given the environment.
 // If we are in devnet mode and the contract address is not specified, it returns the deterministic one for tilt.
-func checkEvmArgs(logger *zap.Logger, rpc string, contractAddr string, chainID vaa.ChainID) string {
+func checkEvmArgs(logger *zap.Logger, rpcURL string, contractAddr string, chainID vaa.ChainID) string {
 	if env != common.UnsafeDevNet {
 		// In mainnet / testnet, if either parameter is specified, they must both be specified.
-		if (rpc == "") != (contractAddr == "") {
+		if (rpcURL == "") != (contractAddr == "") {
 			logger.Fatal(fmt.Sprintf("Both contract and RPC for chain %s must be set or both unset", chainID.String()))
 		}
 	} else {
 		// In devnet, if RPC is set but contract is not set, use the deterministic one for tilt.
-		if rpc == "" {
+		if rpcURL == "" {
 			if contractAddr != "" {
 				logger.Fatal(fmt.Sprintf("If RPC is not set for chain %s, contract must not be set", chainID.String()))
 			}

+ 1 - 3
node/cmd/spy/spy_test.go

@@ -32,7 +32,7 @@ var govEmitter = vaa.Address{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 func getVAA(chainID vaa.ChainID, emitterAddr vaa.Address) *vaa.VAA {
 	var payload = []byte{97, 97, 97, 97, 97, 97}
 
-	vaa := &vaa.VAA{
+	return &vaa.VAA{
 		Version:          vaa.SupportedVAAVersion,
 		GuardianSetIndex: uint32(1),
 		Signatures:       nil,
@@ -44,8 +44,6 @@ func getVAA(chainID vaa.ChainID, emitterAddr vaa.Address) *vaa.VAA {
 		EmitterAddress:   emitterAddr,
 		Payload:          payload,
 	}
-
-	return vaa
 }
 
 // wait for the server to establish a client subscription before returning.

+ 3 - 3
node/pkg/accountant/accountant.go

@@ -13,7 +13,7 @@ import (
 	"time"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	"github.com/certusone/wormhole/node/pkg/supervisor"
@@ -77,7 +77,7 @@ type (
 type Accountant struct {
 	ctx                  context.Context
 	logger               *zap.Logger
-	db                   db.AccountantDB
+	db                   guardianDB.AccountantDB
 	obsvReqWriteC        chan<- *gossipv1.ObservationRequest
 	contract             string
 	wsUrl                string
@@ -112,7 +112,7 @@ func (acct *Accountant) baseEnabled() bool {
 func NewAccountant(
 	ctx context.Context,
 	logger *zap.Logger,
-	db db.AccountantDB,
+	db guardianDB.AccountantDB,
 	obsvReqWriteC chan<- *gossipv1.ObservationRequest,
 	contract string, // the address of the smart contract on wormchain
 	wsUrl string, // the URL of the wormchain websocket interface

+ 2 - 2
node/pkg/accountant/accountant_test.go

@@ -19,7 +19,7 @@ import (
 	sdktx "github.com/cosmos/cosmos-sdk/types/tx"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/devnet"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
@@ -100,7 +100,7 @@ func newAccountantForTest(
 	acctWriteC chan<- *common.MessagePublication,
 	wormchainConn *MockAccountantWormchainConn,
 ) *Accountant {
-	var db db.MockAccountantDB
+	var db guardianDB.MockAccountantDB
 
 	pk := devnet.InsecureDeterministicEcdsaKeyByIndex(ethCrypto.S256(), uint64(0))
 	guardianSigner, err := guardiansigner.GenerateSignerWithPrivatekeyUnsafe(pk)

+ 8 - 8
node/pkg/adminrpc/adminserver.go

@@ -26,7 +26,7 @@ import (
 	"github.com/prometheus/client_golang/prometheus/promauto"
 	"golang.org/x/exp/slices"
 
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	ethcommon "github.com/ethereum/go-ethereum/common"
@@ -55,7 +55,7 @@ var (
 
 type nodePrivilegedService struct {
 	nodev1.UnimplementedNodePrivilegedServiceServer
-	db              *db.Database
+	db              *guardianDB.Database
 	injectC         chan<- *common.MessagePublication
 	obsvReqSendC    chan<- *gossipv1.ObservationRequest
 	logger          *zap.Logger
@@ -70,12 +70,12 @@ type nodePrivilegedService struct {
 }
 
 func NewPrivService(
-	db *db.Database,
+	db *guardianDB.Database,
 	injectC chan<- *common.MessagePublication,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
 	logger *zap.Logger,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
-	governor *governor.ChainGovernor,
+	gov *governor.ChainGovernor,
 	evmConnector connectors.Connector,
 	guardianSigner guardiansigner.GuardianSigner,
 	guardianAddress ethcommon.Address,
@@ -89,7 +89,7 @@ func NewPrivService(
 		obsvReqSendC:    obsvReqSendC,
 		logger:          logger,
 		signedInC:       signedInC,
-		governor:        governor,
+		governor:        gov,
 		evmConnector:    evmConnector,
 		guardianSigner:  guardianSigner,
 		guardianAddress: guardianAddress,
@@ -933,7 +933,7 @@ func (s *nodePrivilegedService) FindMissingMessages(ctx context.Context, req *no
 	emitterAddress := vaa.Address{}
 	copy(emitterAddress[:], b)
 
-	ids, first, last, err := s.db.FindEmitterSequenceGap(db.VAAID{
+	ids, first, last, err := s.db.FindEmitterSequenceGap(guardianDB.VAAID{
 		EmitterChain:   vaa.ChainID(req.EmitterChain),
 		EmitterAddress: emitterAddress,
 	})
@@ -1080,7 +1080,7 @@ func (s *nodePrivilegedService) ChainGovernorResetReleaseTimer(ctx context.Conte
 }
 
 func (s *nodePrivilegedService) PurgePythNetVaas(ctx context.Context, req *nodev1.PurgePythNetVaasRequest) (*nodev1.PurgePythNetVaasResponse, error) {
-	prefix := db.VAAID{EmitterChain: vaa.ChainIDPythNet}
+	prefix := guardianDB.VAAID{EmitterChain: vaa.ChainIDPythNet}
 	oldestTime := time.Now().Add(-time.Hour * 24 * time.Duration(req.DaysOld)) // #nosec G115 -- This conversion is safe indefinitely
 	resp, err := s.db.PurgeVaas(prefix, oldestTime, req.LogOnly)
 	if err != nil {
@@ -1315,7 +1315,7 @@ func (s *nodePrivilegedService) GetAndObserveMissingVAAs(ctx context.Context, re
 			errCounter++
 			continue
 		}
-		vaaKey := db.VAAID{EmitterChain: vaa.ChainID(chainID), EmitterAddress: vaa.Address([]byte(splits[1])), Sequence: sequence} // #nosec G115 -- This chainId conversion is verified above
+		vaaKey := guardianDB.VAAID{EmitterChain: vaa.ChainID(chainID), EmitterAddress: vaa.Address([]byte(splits[1])), Sequence: sequence} // #nosec G115 -- This chainId conversion is verified above
 		hasVaa, err := s.db.HasVAA(vaaKey)
 		if err != nil || hasVaa {
 			errMsgs += fmt.Sprintf("\nerror checking for VAA %s", missingVAA.VaaKey)

+ 2 - 2
node/pkg/adminrpc/adminserver_test.go

@@ -327,10 +327,10 @@ func Test_adminCommands(t *testing.T) {
 			require.NoError(t, err)
 			require.Equal(t, 1, len(msg.Messages))
 			govMsg := msg.Messages[0]
-			vaa, err := GovMsgToVaa(govMsg, govGuardianSetIndex, govTimestamp)
+			govVAA, err := GovMsgToVaa(govMsg, govGuardianSetIndex, govTimestamp)
 			if tst.errText == "" {
 				require.NoError(t, err)
-				verifyGovernanceVAA(t, vaa, govMsg.Sequence, govMsg.Nonce)
+				verifyGovernanceVAA(t, govVAA, govMsg.Sequence, govMsg.Nonce)
 			} else {
 				require.ErrorContains(t, err, tst.errText)
 			}

+ 27 - 27
node/pkg/db/governor_test.go

@@ -49,10 +49,10 @@ func TestSerializeAndDeserializeOfTransfer(t *testing.T) {
 		Hash:           "Hash1",
 	}
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 
 	assert.Equal(t, xfer1, xfer2)
@@ -300,10 +300,10 @@ func TestSerializeAndDeserializeOfPendingTransfer(t *testing.T) {
 		Msg:         msg,
 	}
 
-	bytes, err := pending1.Marshal()
+	pending1Bytes, err := pending1.Marshal()
 	require.NoError(t, err)
 
-	pending2, err := UnmarshalPendingTransfer(bytes, false)
+	pending2, err := UnmarshalPendingTransfer(pending1Bytes, false)
 	require.NoError(t, err)
 
 	assert.Equal(t, pending1, pending2)
@@ -428,10 +428,10 @@ func TestMarshalUnmarshalNoMsgIdOrHash(t *testing.T) {
 		// Don't set MsgID or Hash, should handle empty slices.
 	}
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.Equal(t, xfer1, xfer2)
 }
@@ -461,60 +461,60 @@ func TestUnmarshalTransferFailures(t *testing.T) {
 		Hash:           "Hash1",
 	}
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 
 	// First make sure regular unmarshal works.
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.Equal(t, xfer1, xfer2)
 
 	// Truncate the timestamp.
-	_, err = UnmarshalTransfer(bytes[0 : 4-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4-1])
 	assert.ErrorContains(t, err, "failed to read timestamp: ")
 
 	// Truncate the value.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8-1])
 	assert.ErrorContains(t, err, "failed to read value: ")
 
 	// Truncate the origin chain.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2-1])
 	assert.ErrorContains(t, err, "failed to read origin chain id: ")
 
 	// Truncate the origin address.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32-1])
 	assert.ErrorContains(t, err, "failed to read origin address")
 
 	// Truncate the emitter chain.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2-1])
 	assert.ErrorContains(t, err, "failed to read emitter chain id: ")
 
 	// Truncate the emitter address.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32-1])
 	assert.ErrorContains(t, err, "failed to read emitter address")
 
 	// Truncate the message ID length.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2-1])
 	assert.ErrorContains(t, err, "failed to read msgID length: ")
 
 	// Truncate the message ID data.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2+3])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2+3])
 	assert.ErrorContains(t, err, "failed to read msg id")
 
 	// Truncate the hash length.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2+82+2-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2+82+2-1])
 	assert.ErrorContains(t, err, "failed to read hash length: ")
 
 	// Truncate the hash data.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2+82+2+3])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2+82+2+3])
 	assert.ErrorContains(t, err, "failed to read hash")
 
 	// Truncate the target chain.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2+82+2+5+2-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2+82+2+5+2-1])
 	assert.ErrorContains(t, err, "failed to read target chain id: ")
 
 	// Truncate the target address.
-	_, err = UnmarshalTransfer(bytes[0 : 4+8+2+32+2+32+2+82+2+5+2+32-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4+8+2+32+2+32+2+82+2+5+2+32-1])
 	assert.ErrorContains(t, err, "failed to read target address")
 }
 
@@ -541,26 +541,26 @@ func TestUnmarshalPendingTransferFailures(t *testing.T) {
 		Msg:         msg,
 	}
 
-	bytes, err := pending1.Marshal()
+	pending1Bytes, err := pending1.Marshal()
 	require.NoError(t, err)
 
 	// First make sure regular unmarshal works.
-	pending2, err := UnmarshalPendingTransfer(bytes, false)
+	pending2, err := UnmarshalPendingTransfer(pending1Bytes, false)
 	require.NoError(t, err)
 	assert.Equal(t, pending1, pending2)
 
 	// Truncate the release time.
-	_, err = UnmarshalPendingTransfer(bytes[0:4-1], false)
+	_, err = UnmarshalPendingTransfer(pending1Bytes[0:4-1], false)
 	assert.ErrorContains(t, err, "failed to read pending transfer release time: ")
 
 	// The remainder is the marshaled message publication as a single buffer.
 
 	// Truncate the entire serialized message.
-	_, err = UnmarshalPendingTransfer(bytes[0:4], false)
+	_, err = UnmarshalPendingTransfer(pending1Bytes[0:4], false)
 	assert.ErrorContains(t, err, "failed to read pending transfer msg")
 
 	// Truncate some of the serialized message.
-	_, err = UnmarshalPendingTransfer(bytes[0:len(bytes)-10], false)
+	_, err = UnmarshalPendingTransfer(pending1Bytes[0:len(pending1Bytes)-10], false)
 	assert.ErrorContains(t, err, "failed to unmarshal pending transfer msg")
 }
 
@@ -858,10 +858,10 @@ func TestDeserializeOfOldTransfer(t *testing.T) {
 		Hash:  "Hash1",
 	}
 
-	bytes, err := marshalOldTransfer(xfer1)
+	xfer1Bytes, err := marshalOldTransfer(xfer1)
 	require.NoError(t, err)
 
-	xfer2, err := unmarshalOldTransfer(bytes)
+	xfer2, err := unmarshalOldTransfer(xfer1Bytes)
 	require.NoError(t, err)
 
 	assert.Equal(t, xfer1, xfer2)

+ 10 - 10
node/pkg/governor/governor.go

@@ -38,7 +38,7 @@ import (
 	"time"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/wormhole-foundation/wormhole/sdk"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
 
@@ -94,14 +94,14 @@ type (
 		token  *tokenEntry // Store a reference to the token so we can get the current price to compute the value each interval.
 		amount *big.Int
 		hash   string
-		dbData db.PendingTransfer // This info gets persisted in the DB.
+		dbData guardianDB.PendingTransfer // This info gets persisted in the DB.
 	}
 
 	// Used in flow cancel calculations. Wraps a database Transfer. Also contains a signed amount field in order to
 	// hold negative values. This field will be used in flow cancel calculations to reduce the Governor usage for a
 	// supported token.
 	transfer struct {
-		dbTransfer *db.Transfer
+		dbTransfer *guardianDB.Transfer
 		value      int64
 	}
 
@@ -122,7 +122,7 @@ type (
 
 // newTransferFromDbTransfer performs a bounds check on dbTransfer.Value to ensure it can fit into int64.
 // This should always be the case for normal operation as dbTransfer.Value represents the USD value of a transfer.
-func newTransferFromDbTransfer(dbTransfer *db.Transfer) (tx transfer, err error) {
+func newTransferFromDbTransfer(dbTransfer *guardianDB.Transfer) (tx transfer, err error) {
 	if dbTransfer.Value > math.MaxInt64 {
 		return tx, fmt.Errorf("value for db.Transfer exceeds MaxInt64: %d", dbTransfer.Value)
 	}
@@ -159,7 +159,7 @@ func (ce *chainEntry) addFlowCancelTransfer(transfer transfer) error {
 // addFlowCancelTransferFromDbTransfer converts a dbTransfer to a transfer and adds it to the
 // Chain Entry.
 // Validation of transfer data is performed by other methods: see addFlowCancelTransfer, newTransferFromDbTransfer.
-func (ce *chainEntry) addFlowCancelTransferFromDbTransfer(dbTransfer *db.Transfer) error {
+func (ce *chainEntry) addFlowCancelTransferFromDbTransfer(dbTransfer *guardianDB.Transfer) error {
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	if err != nil {
 		return err
@@ -182,7 +182,7 @@ func (ce *chainEntry) isBigTransfer(value uint64) bool {
 }
 
 type ChainGovernor struct {
-	db                  db.GovernorDB // protected by `mutex`
+	db                  guardianDB.GovernorDB // protected by `mutex`
 	logger              *zap.Logger
 	mutex               sync.Mutex
 	tokens              map[tokenKey]*tokenEntry    // protected by `mutex`
@@ -206,7 +206,7 @@ type ChainGovernor struct {
 
 func NewChainGovernor(
 	logger *zap.Logger,
-	db db.GovernorDB,
+	db guardianDB.GovernorDB,
 	env common.Environment,
 	flowCancelEnabled bool,
 	coinGeckoApiKey string,
@@ -544,7 +544,7 @@ func (gov *ChainGovernor) ProcessMsgForTime(msg *common.MessagePublication, now
 	}
 
 	if enqueueIt {
-		dbData := db.PendingTransfer{ReleaseTime: releaseTime, Msg: *msg}
+		dbData := guardianDB.PendingTransfer{ReleaseTime: releaseTime, Msg: *msg}
 		err = gov.db.StorePendingMsg(&dbData)
 		if err != nil {
 			gov.logger.Error("failed to store pending vaa",
@@ -573,7 +573,7 @@ func (gov *ChainGovernor) ProcessMsgForTime(msg *common.MessagePublication, now
 		zap.String("txID", msg.TxIDString()),
 	)
 
-	dbTransfer := db.Transfer{
+	dbTransfer := guardianDB.Transfer{
 		Timestamp:      now,
 		Value:          value,
 		OriginChain:    token.token.chain,
@@ -818,7 +818,7 @@ func (gov *ChainGovernor) CheckPendingForTime(now time.Time) ([]*common.MessageP
 					msgsToPublish = append(msgsToPublish, &pe.dbData.Msg)
 
 					if countsTowardsTransfers {
-						dbTransfer := db.Transfer{Timestamp: now,
+						dbTransfer := guardianDB.Transfer{Timestamp: now,
 							Value:          value,
 							OriginChain:    pe.token.token.chain,
 							OriginAddress:  pe.token.token.addr,

+ 2 - 2
node/pkg/governor/governor_prices.go

@@ -22,7 +22,7 @@ import (
 	"go.uber.org/zap"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/supervisor"
 )
 
@@ -319,7 +319,7 @@ func (te tokenEntry) updatePrice() {
 func CheckQuery(logger *zap.Logger) error {
 	logger.Info("Instantiating governor.")
 	ctx := context.Background()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.MainNet, true, "")
 
 	if err := gov.initConfig(); err != nil {

+ 32 - 32
node/pkg/governor/governor_test.go

@@ -17,7 +17,7 @@ import (
 	"github.com/stretchr/testify/require"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
 	"go.uber.org/zap"
 	"go.uber.org/zap/zapcore"
@@ -212,7 +212,7 @@ func TestSumAllFromToday(t *testing.T) {
 	var transfers []transfer
 	transferTime, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Jun 1, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
-	dbTransfer := &db.Transfer{Value: 125000, Timestamp: transferTime}
+	dbTransfer := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime}
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer)
@@ -258,12 +258,12 @@ func TestSumWithFlowCancelling(t *testing.T) {
 	// - Transfer from emitter: we only care about Value
 	// - Transfer that flow cancels: Transfer must be a valid entry from FlowCancelTokenList()  (based on origin chain and origin address)
 	//				 and the destination chain must be the same as the emitter chain
-	outgoingDbTransfer := &db.Transfer{Value: emitterTransferValue, Timestamp: transferTime}
+	outgoingDbTransfer := &guardianDB.Transfer{Value: emitterTransferValue, Timestamp: transferTime}
 	outgoingTransfer, err := newTransferFromDbTransfer(outgoingDbTransfer)
 	require.NoError(t, err)
 
 	// Flow cancelling transfer
-	incomingDbTransfer := &db.Transfer{
+	incomingDbTransfer := &guardianDB.Transfer{
 		OriginChain:   originChain,
 		OriginAddress: originAddress,
 		TargetChain:   vaa.ChainID(emitterChainId), // emitter
@@ -301,7 +301,7 @@ func TestSumWithFlowCancelling(t *testing.T) {
 func TestFlowCancelFeatureFlag(t *testing.T) {
 
 	ctx := context.Background()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(zap.NewNop(), &db, common.GoTest, true, "")
 
 	// Trigger the evaluation of the flow cancelling config
@@ -384,12 +384,12 @@ func TestFlowCancelCannotUnderflow(t *testing.T) {
 	// - Transfer from emitter: we only care about Value
 	// - Transfer that flow cancels: Transfer must be a valid entry from FlowCancelTokenList()  (based on origin chain and origin address)
 	//				 and the destination chain must be the same as the emitter chain
-	emitterDbTransfer := &db.Transfer{Value: emitterTransferValue, Timestamp: transferTime}
+	emitterDbTransfer := &guardianDB.Transfer{Value: emitterTransferValue, Timestamp: transferTime}
 	emitterTransfer, err := newTransferFromDbTransfer(emitterDbTransfer)
 	require.NoError(t, err)
 	transfers_from_emitter = append(transfers_from_emitter, emitterTransfer)
 
-	flowCancelDbTransfer := &db.Transfer{
+	flowCancelDbTransfer := &guardianDB.Transfer{
 		OriginChain:   originChain,
 		OriginAddress: originAddress,
 		TargetChain:   vaa.ChainID(emitterChainId), // emitter
@@ -445,7 +445,7 @@ func TestChainEntrySumExceedsDailyLimit(t *testing.T) {
 
 	// Create a lot of transfers. Their total value should exceed `emitterLimit`
 	for i := 0; i < 25; i++ {
-		transfer, err := newTransferFromDbTransfer(&db.Transfer{Value: emitterTransferValue, Timestamp: transferTime})
+		transfer, err := newTransferFromDbTransfer(&guardianDB.Transfer{Value: emitterTransferValue, Timestamp: transferTime})
 		require.NoError(t, err)
 		transfers_from_emitter = append(
 			transfers_from_emitter,
@@ -488,9 +488,9 @@ func TestTrimAndSumValueOverflowErrors(t *testing.T) {
 
 	emitterChainId := vaa.ChainIDSolana
 
-	transfer, err := newTransferFromDbTransfer(&db.Transfer{Value: math.MaxInt64, Timestamp: transferTime})
+	transfer, err := newTransferFromDbTransfer(&guardianDB.Transfer{Value: math.MaxInt64, Timestamp: transferTime})
 	require.NoError(t, err)
-	transfer2, err := newTransferFromDbTransfer(&db.Transfer{Value: 1, Timestamp: transferTime})
+	transfer2, err := newTransferFromDbTransfer(&guardianDB.Transfer{Value: 1, Timestamp: transferTime})
 	require.NoError(t, err)
 	transfers_from_emitter = append(transfers_from_emitter, transfer, transfer2)
 
@@ -517,7 +517,7 @@ func TestTrimAndSumValueOverflowErrors(t *testing.T) {
 	gov.chains[emitter.emitterChainId] = emitter
 
 	// Now test underflow
-	transfer3 := &db.Transfer{Value: math.MaxInt64, Timestamp: transferTime, TargetChain: vaa.ChainIDSolana}
+	transfer3 := &guardianDB.Transfer{Value: math.MaxInt64, Timestamp: transferTime, TargetChain: vaa.ChainIDSolana}
 
 	ce := gov.chains[emitter.emitterChainId]
 	err = ce.addFlowCancelTransferFromDbTransfer(transfer3)
@@ -547,7 +547,7 @@ func TestTrimOneOfTwoTransfers(t *testing.T) {
 	// The first transfer should be expired.
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:59am (CST)")
 	require.NoError(t, err)
-	dbTransfer := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer)
@@ -555,7 +555,7 @@ func TestTrimOneOfTwoTransfers(t *testing.T) {
 	// But the second should not.
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	require.NoError(t, err)
-	dbTransfer = &db.Transfer{Value: 225000, Timestamp: transferTime2}
+	dbTransfer = &guardianDB.Transfer{Value: 225000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
@@ -581,14 +581,14 @@ func TestTrimSeveralTransfers(t *testing.T) {
 	// The first two transfers should be expired.
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 10:00am (CST)")
 	require.NoError(t, err)
-	dbTransfer1 := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer1 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer1)
 
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
-	dbTransfer2 := &db.Transfer{Value: 135000, Timestamp: transferTime2}
+	dbTransfer2 := &guardianDB.Transfer{Value: 135000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
@@ -596,21 +596,21 @@ func TestTrimSeveralTransfers(t *testing.T) {
 	// But the next three should not.
 	transferTime3, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	require.NoError(t, err)
-	dbTransfer3 := &db.Transfer{Value: 145000, Timestamp: transferTime3}
+	dbTransfer3 := &guardianDB.Transfer{Value: 145000, Timestamp: transferTime3}
 	transfer3, err := newTransferFromDbTransfer(dbTransfer3)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer3)
 
 	transferTime4, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	require.NoError(t, err)
-	dbTransfer4 := &db.Transfer{Value: 155000, Timestamp: transferTime4}
+	dbTransfer4 := &guardianDB.Transfer{Value: 155000, Timestamp: transferTime4}
 	transfer4, err := newTransferFromDbTransfer(dbTransfer4)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer4)
 
 	transferTime5, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	require.NoError(t, err)
-	dbTransfer5 := &db.Transfer{Value: 165000, Timestamp: transferTime5}
+	dbTransfer5 := &guardianDB.Transfer{Value: 165000, Timestamp: transferTime5}
 	transfer5, err := newTransferFromDbTransfer(dbTransfer5)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer5)
@@ -636,14 +636,14 @@ func TestTrimmingAllTransfersShouldReturnZero(t *testing.T) {
 
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
-	dbTransfer1 := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer1 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer1)
 
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:45am (CST)")
 	require.NoError(t, err)
-	dbTransfer2 := &db.Transfer{Value: 125000, Timestamp: transferTime2}
+	dbTransfer2 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
@@ -665,7 +665,7 @@ func newChainGovernorForTestWithLogger(ctx context.Context, logger *zap.Logger)
 		return nil, fmt.Errorf("ctx is nil")
 	}
 
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 	err := gov.Run(ctx)
@@ -2182,7 +2182,7 @@ func TestSmallerPendingTransfersAfterBigOneShouldGetReleased(t *testing.T) {
 
 func TestMainnetConfigIsValid(t *testing.T) {
 	logger := zap.NewNop()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 	gov.env = common.TestNet
@@ -2192,7 +2192,7 @@ func TestMainnetConfigIsValid(t *testing.T) {
 
 func TestTestnetConfigIsValid(t *testing.T) {
 	logger := zap.NewNop()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 	gov.env = common.TestNet
@@ -2654,9 +2654,9 @@ func TestDontReloadDuplicates(t *testing.T) {
 	now, _ := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Jun 2, 2022 at 12:01pm (CST)")
 	startTime := now.Add(-time.Minute * time.Duration(gov.dayLengthInMinutes))
 
-	var xfers []*db.Transfer
+	var xfers []*guardianDB.Transfer
 
-	xfer1 := &db.Transfer{
+	xfer1 := &guardianDB.Transfer{
 		Timestamp:      startTime.Add(time.Minute * 5),
 		Value:          uint64(1000),
 		OriginChain:    vaa.ChainIDEthereum,
@@ -2668,7 +2668,7 @@ func TestDontReloadDuplicates(t *testing.T) {
 	}
 	xfers = append(xfers, xfer1)
 
-	xfer2 := &db.Transfer{
+	xfer2 := &guardianDB.Transfer{
 		Timestamp:      startTime.Add(time.Minute * 5),
 		Value:          uint64(2000),
 		OriginChain:    vaa.ChainIDEthereum,
@@ -2693,8 +2693,8 @@ func TestDontReloadDuplicates(t *testing.T) {
 		1.25,
 	)
 
-	var pendings []*db.PendingTransfer
-	pending1 := &db.PendingTransfer{
+	var pendings []*guardianDB.PendingTransfer
+	pending1 := &guardianDB.PendingTransfer{
 		ReleaseTime: now.Add(time.Hour * 24),
 		Msg: common.MessagePublication{
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
@@ -2709,7 +2709,7 @@ func TestDontReloadDuplicates(t *testing.T) {
 	}
 	pendings = append(pendings, pending1)
 
-	pending2 := &db.PendingTransfer{
+	pending2 := &guardianDB.PendingTransfer{
 		ReleaseTime: now.Add(time.Hour * 24),
 		Msg: common.MessagePublication{
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
@@ -2803,7 +2803,7 @@ func TestReloadTransfersNearCapacity(t *testing.T) {
 	require.NoError(t, err)
 
 	// This transfer should exhaust the dailyLimit for the emitter chain
-	xfer1 := &db.Transfer{
+	xfer1 := &guardianDB.Transfer{
 		Timestamp:      transferTime.Add(-10),
 		Value:          uint64(10000),
 		OriginChain:    vaa.ChainIDSolana,
@@ -2817,7 +2817,7 @@ func TestReloadTransfersNearCapacity(t *testing.T) {
 	}
 
 	// This incoming transfer should free up some of the space on the previous emitter chain
-	xfer2 := &db.Transfer{
+	xfer2 := &guardianDB.Transfer{
 		Timestamp:      transferTime.Add(-9),
 		Value:          uint64(2000),
 		OriginChain:    vaa.ChainIDSolana,
@@ -2832,7 +2832,7 @@ func TestReloadTransfersNearCapacity(t *testing.T) {
 
 	// Send another transfer out from the original emitter chain so that we "exceed the daily limit" if flow
 	// cancel is not applied
-	xfer3 := &db.Transfer{
+	xfer3 := &guardianDB.Transfer{
 		Timestamp:      transferTime.Add(-8),
 		Value:          uint64(50),
 		OriginChain:    vaa.ChainIDSolana,

+ 2 - 2
node/pkg/node/adminServiceRunnable.go

@@ -9,7 +9,7 @@ import (
 
 	"github.com/certusone/wormhole/node/pkg/adminrpc"
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
@@ -31,7 +31,7 @@ func adminServiceRunnable(
 	injectC chan<- *common.MessagePublication,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
-	db *db.Database,
+	db *guardianDB.Database,
 	gst *common.GuardianSetState,
 	gov *governor.ChainGovernor,
 	guardianSigner guardiansigner.GuardianSigner,

+ 6 - 6
node/pkg/node/node_test.go

@@ -23,7 +23,7 @@ import (
 
 	"github.com/certusone/wormhole/node/pkg/adminrpc"
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/devnet"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/processor"
@@ -82,7 +82,7 @@ type mockGuardian struct {
 	guardianAddr     eth_common.Address
 	ready            bool
 	config           *guardianConfig
-	db               *db.Database
+	db               *guardianDB.Database
 }
 
 type guardianConfig struct {
@@ -148,7 +148,7 @@ func mockGuardianRunnable(t testing.TB, gs []*mockGuardian, mockGuardianIndex ui
 		defer ctxCancel()
 
 		// setup db
-		db := db.OpenDb(nil, nil)
+		db := guardianDB.OpenDb(nil, nil)
 		defer db.Close()
 		gs[mockGuardianIndex].db = db
 
@@ -457,14 +457,14 @@ func governedMsg(shouldBeDelayed bool) *common.MessagePublication {
 }
 
 func makeObsDb(tc []testCase) mock.ObservationDb {
-	db := make(map[eth_common.Hash]*common.MessagePublication)
+	obsDB := make(map[eth_common.Hash]*common.MessagePublication)
 	for _, t := range tc {
 		if t.unavailableInReobservation {
 			continue
 		}
-		db[eth_common.BytesToHash(t.msg.TxID)] = t.msg
+		obsDB[eth_common.BytesToHash(t.msg.TxID)] = t.msg
 	}
-	return db
+	return obsDB
 }
 
 // waitForStatusServer queries the /readyz and /metrics endpoints at `statusAddr` every 100ms until they are online.

+ 6 - 6
node/pkg/node/options.go

@@ -10,7 +10,7 @@ import (
 	"github.com/certusone/wormhole/node/pkg/accountant"
 	"github.com/certusone/wormhole/node/pkg/altpub"
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	"github.com/certusone/wormhole/node/pkg/p2p"
@@ -428,10 +428,10 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}(chainQueryResponseC[chainId], chainId)
 			}
 
-			watchers := make(map[watchers.NetworkID]interfaces.L1Finalizer)
+			configuredWatchers := make(map[watchers.NetworkID]interfaces.L1Finalizer)
 
 			for _, wc := range watcherConfigs {
-				if _, ok := watchers[wc.GetNetworkID()]; ok {
+				if _, ok := configuredWatchers[wc.GetNetworkID()]; ok {
 					return fmt.Errorf("NetworkID already configured: %s", string(wc.GetNetworkID()))
 				}
 
@@ -445,7 +445,7 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}
 
 				if wc.RequiredL1Finalizer() != "" {
-					l1watcher, ok := watchers[wc.RequiredL1Finalizer()]
+					l1watcher, ok := configuredWatchers[wc.RequiredL1Finalizer()]
 					if !ok || l1watcher == nil {
 						logger.Fatal("L1finalizer does not exist. Please check the order of the watcher configurations in watcherConfigs. The L1 must be configured before this one.",
 							zap.String("ChainID", wc.GetChainID().String()),
@@ -461,7 +461,7 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}
 
 				g.runnablesWithScissors[watcherName] = runnable
-				watchers[wc.GetNetworkID()] = l1finalizer
+				configuredWatchers[wc.GetNetworkID()] = l1finalizer
 
 				if reobserver != nil {
 					g.reobservers[wc.GetChainID()] = reobserver
@@ -588,7 +588,7 @@ func GuardianOptionPublicWeb(listenAddr string, publicGRPCSocketPath string, tls
 
 // GuardianOptionDatabase configures the main database to be used for this guardian node.
 // Dependencies: none
-func GuardianOptionDatabase(db *db.Database) *GuardianOption {
+func GuardianOptionDatabase(db *guardianDB.Database) *GuardianOption {
 	return &GuardianOption{
 		name: "db",
 		f: func(ctx context.Context, logger *zap.Logger, g *G) error {

+ 3 - 3
node/pkg/node/publicrpcRunnable.go

@@ -7,7 +7,7 @@ import (
 	"os"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	"github.com/certusone/wormhole/node/pkg/publicrpc"
@@ -16,7 +16,7 @@ import (
 	"google.golang.org/grpc"
 )
 
-func publicrpcTcpServiceRunnable(logger *zap.Logger, listenAddr string, publicRpcLogDetail common.GrpcLogDetail, db *db.Database, gst *common.GuardianSetState, gov *governor.ChainGovernor) supervisor.Runnable {
+func publicrpcTcpServiceRunnable(logger *zap.Logger, listenAddr string, publicRpcLogDetail common.GrpcLogDetail, db *guardianDB.Database, gst *common.GuardianSetState, gov *governor.ChainGovernor) supervisor.Runnable {
 	return func(ctx context.Context) error {
 		l, err := net.Listen("tcp", listenAddr)
 
@@ -41,7 +41,7 @@ func publicrpcTcpServiceRunnable(logger *zap.Logger, listenAddr string, publicRp
 	}
 }
 
-func publicrpcUnixServiceRunnable(logger *zap.Logger, socketPath string, publicRpcLogDetail common.GrpcLogDetail, db *db.Database, gst *common.GuardianSetState, gov *governor.ChainGovernor) (supervisor.Runnable, *grpc.Server, error) {
+func publicrpcUnixServiceRunnable(logger *zap.Logger, socketPath string, publicRpcLogDetail common.GrpcLogDetail, db *guardianDB.Database, gst *common.GuardianSetState, gov *governor.ChainGovernor) (supervisor.Runnable, *grpc.Server, error) {
 	// Delete existing UNIX socket, if present.
 	fi, err := os.Stat(socketPath)
 	if err == nil {

+ 3 - 3
node/pkg/p2p/netmetrics.go

@@ -60,9 +60,9 @@ var (
 )
 
 // sanitizeVersion cleans up the version string to prevent an attacker from executing a cardinality attack.
-func sanitizeVersion(version string, reference string) string {
+func sanitizeVersion(versionStr string, reference string) string {
 	// Match groups of reVersion
-	components := reVersion.FindStringSubmatch(version)
+	components := reVersion.FindStringSubmatch(versionStr)
 	referenceComponents := reVersion.FindStringSubmatch(reference)
 
 	// Compare components of the version string with the reference and ensure
@@ -80,7 +80,7 @@ func sanitizeVersion(version string, reference string) string {
 		}
 	}
 
-	v := reVersion.FindString(version)
+	v := reVersion.FindString(versionStr)
 	if v == "" {
 		return "other"
 	}

+ 2 - 2
node/pkg/p2p/p2p.go

@@ -965,8 +965,8 @@ func Run(params *RunParams) func(ctx context.Context) error {
 							default:
 								if params.components.WarnChannelOverflow {
 									var hexStr string
-									if vaa, err := vaa.Unmarshal(m.SignedVaaWithQuorum.Vaa); err == nil {
-										hexStr = vaa.HexDigest()
+									if signedVAA, err := vaa.Unmarshal(m.SignedVaaWithQuorum.Vaa); err == nil {
+										hexStr = signedVAA.HexDigest()
 									}
 									logger.Warn("Ignoring SignedVaaWithQuorum because signedIncomingVaaRecvC full", zap.String("hash", hexStr))
 								}

+ 4 - 6
node/pkg/processor/batch_obs_test.go

@@ -20,7 +20,7 @@ func getUniqueVAA(seqNo uint64) vaa.VAA {
 	var payload = []byte{97, 97, 97, 97, 97, 97}
 	var governanceEmitter = vaa.Address{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, 4}
 
-	vaa := vaa.VAA{
+	return vaa.VAA{
 		Version:          uint8(1),
 		GuardianSetIndex: uint32(1),
 		Signatures:       nil,
@@ -32,8 +32,6 @@ func getUniqueVAA(seqNo uint64) vaa.VAA {
 		EmitterAddress:   governanceEmitter,
 		Payload:          payload,
 	}
-
-	return vaa
 }
 
 func TestMarshalSignedObservationBatch(t *testing.T) {
@@ -44,8 +42,8 @@ func TestMarshalSignedObservationBatch(t *testing.T) {
 	observations := make([]*gossipv1.Observation, 0, NumObservations)
 	txHash := []byte("0123456789012345678901234567890123456789012345678901234567890123") // 64 bytes, the size of a Solana signature.
 	for seqNo := uint64(1); seqNo <= NumObservations; seqNo++ {
-		vaa := getUniqueVAA(seqNo)
-		digest := vaa.SigningDigest()
+		uniqueVAA := getUniqueVAA(seqNo)
+		digest := uniqueVAA.SigningDigest()
 		sig, err := crypto.Sign(digest.Bytes(), gk)
 		require.NoError(t, err)
 
@@ -53,7 +51,7 @@ func TestMarshalSignedObservationBatch(t *testing.T) {
 			Hash:      digest.Bytes(),
 			Signature: sig,
 			TxHash:    txHash,
-			MessageId: vaa.MessageID(),
+			MessageId: uniqueVAA.MessageID(),
 		})
 	}
 

+ 4 - 4
node/pkg/processor/benchmark_test.go

@@ -9,7 +9,7 @@ import (
 	"time"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
@@ -42,7 +42,7 @@ there were  100000  handle message calls, taking an average time of  28.704µs
 func BenchmarkHandleObservation(b *testing.B) {
 	const NumObservations = 100000
 	ctx := context.Background()
-	db := db.OpenDb(nil, nil)
+	db := guardianDB.OpenDb(nil, nil)
 	defer db.Close()
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	require.NotNil(b, p)
@@ -100,7 +100,7 @@ func BenchmarkProfileHandleObservation(b *testing.B) {
 	defer pprof.StopCPUProfile()
 
 	ctx := context.Background()
-	db := db.OpenDb(nil, nil)
+	db := guardianDB.OpenDb(nil, nil)
 	defer db.Close()
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	require.NotNil(b, p)
@@ -131,7 +131,7 @@ func (pd *ProcessorData) messageID(seqNum uint64) string {
 }
 
 // createProcessorForTest creates a processor for benchmarking. It assumes we are index zero in the guardian set.
-func createProcessorForTest(b *testing.B, numVAAs int, ctx context.Context, db *db.Database) (*Processor, *ProcessorData) {
+func createProcessorForTest(b *testing.B, numVAAs int, ctx context.Context, db *guardianDB.Database) (*Processor, *ProcessorData) {
 	b.Helper()
 	logger := zap.NewNop()
 

+ 6 - 8
node/pkg/processor/observation_test.go

@@ -20,7 +20,7 @@ func getVAA() vaa.VAA {
 	var payload = []byte{97, 97, 97, 97, 97, 97}
 	var governanceEmitter = vaa.Address{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, 4}
 
-	vaa := vaa.VAA{
+	return vaa.VAA{
 		Version:          uint8(1),
 		GuardianSetIndex: uint32(1),
 		Signatures:       nil,
@@ -32,13 +32,11 @@ func getVAA() vaa.VAA {
 		EmitterAddress:   governanceEmitter,
 		Payload:          payload,
 	}
-
-	return vaa
 }
 
 func TestHandleInboundSignedVAAWithQuorum_NilGuardianSet(t *testing.T) {
-	vaa := getVAA()
-	marshalVAA, _ := vaa.Marshal()
+	testVAA := getVAA()
+	marshalVAA, _ := testVAA.Marshal()
 
 	// Stub out the minimum to get processor to dance
 	observedZapCore, observedLogs := observer.New(zap.InfoLevel)
@@ -84,7 +82,7 @@ func TestHandleInboundSignedVAAWithQuorum(t *testing.T) {
 
 	for _, tc := range tests {
 		t.Run(tc.label, func(t *testing.T) {
-			vaa := getVAA()
+			testVAA := getVAA()
 
 			// Define a GuardianSet from test addrs
 			guardianSet := common.GuardianSet{
@@ -94,10 +92,10 @@ func TestHandleInboundSignedVAAWithQuorum(t *testing.T) {
 
 			// Sign with the keys at the proper index
 			for i, key := range tc.keyOrder {
-				vaa.AddSignature(key, tc.indexOrder[i])
+				testVAA.AddSignature(key, tc.indexOrder[i])
 			}
 
-			marshalVAA, err := vaa.Marshal()
+			marshalVAA, err := testVAA.Marshal()
 			if err != nil {
 				panic(err)
 			}

+ 4 - 4
node/pkg/processor/processor.go

@@ -8,7 +8,7 @@ import (
 	"time"
 
 	"github.com/certusone/wormhole/node/pkg/altpub"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/p2p"
@@ -129,7 +129,7 @@ type Processor struct {
 
 	logger *zap.Logger
 
-	db *db.Database
+	db *guardianDB.Database
 
 	alternatePublisher *altpub.AlternatePublisher
 
@@ -206,7 +206,7 @@ const batchObsvPubChanSize = p2p.MaxObservationBatchSize * 5
 
 func NewProcessor(
 	ctx context.Context,
-	db *db.Database,
+	db *guardianDB.Database,
 	msgC <-chan *common.MessagePublication,
 	setC <-chan *common.GuardianSet,
 	gossipAttestationSendC chan<- []byte,
@@ -360,7 +360,7 @@ func (p *Processor) storeSignedVAA(v *vaa.VAA) {
 }
 
 // haveSignedVAA returns true if we already have a VAA for the given VAAID
-func (p *Processor) haveSignedVAA(id db.VAAID) bool {
+func (p *Processor) haveSignedVAA(id guardianDB.VAAID) bool {
 	if id.EmitterChain == vaa.ChainIDPythNet {
 		if p.pythnetVaas == nil {
 			return false

+ 5 - 5
node/pkg/publicrpc/publicrpcserver.go

@@ -8,7 +8,7 @@ import (
 	"math"
 
 	"github.com/certusone/wormhole/node/pkg/common"
-	"github.com/certusone/wormhole/node/pkg/db"
+	guardianDB "github.com/certusone/wormhole/node/pkg/db"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
@@ -21,14 +21,14 @@ import (
 type PublicrpcServer struct {
 	publicrpcv1.UnsafePublicRPCServiceServer
 	logger *zap.Logger
-	db     *db.Database
+	db     *guardianDB.Database
 	gst    *common.GuardianSetState
 	gov    *governor.ChainGovernor
 }
 
 func NewPublicrpcServer(
 	logger *zap.Logger,
-	db *db.Database,
+	db *guardianDB.Database,
 	gst *common.GuardianSetState,
 	gov *governor.ChainGovernor,
 ) *PublicrpcServer {
@@ -92,14 +92,14 @@ func (s *PublicrpcServer) GetSignedVAA(ctx context.Context, req *publicrpcv1.Get
 	addr := vaa.Address{}
 	copy(addr[:], address)
 
-	b, err := s.db.GetSignedVAABytes(db.VAAID{
+	b, err := s.db.GetSignedVAABytes(guardianDB.VAAID{
 		EmitterChain:   chainID,
 		EmitterAddress: addr,
 		Sequence:       req.MessageId.Sequence,
 	})
 
 	if err != nil {
-		if errors.Is(err, db.ErrVAANotFound) {
+		if errors.Is(err, guardianDB.ErrVAANotFound) {
 			return nil, status.Error(codes.NotFound, err.Error())
 		}
 		s.logger.Error("failed to fetch VAA", zap.Error(err), zap.Any("request", req))

+ 2 - 2
node/pkg/telemetry/prom_remote_write/prom_test.go

@@ -198,10 +198,10 @@ func TestParseAndPushMetricsTextAndFormat(t *testing.T) {
 func TestMarshalUnmarshal(t *testing.T) {
 	timeseries := []*prometheusv1.TimeSeries{}
 	wr := prometheusv1.WriteRequest{Timeseries: timeseries}
-	bytes, err := proto.Marshal(&wr)
+	wrBytes, err := proto.Marshal(&wr)
 	require.NoError(t, err)
 
 	newWr := prometheusv1.WriteRequest{}
-	err = proto.Unmarshal(bytes, &newWr)
+	err = proto.Unmarshal(wrBytes, &newWr)
 	require.NoError(t, err)
 }

+ 2 - 2
node/pkg/telemetry/telemetry_test.go

@@ -19,14 +19,14 @@ type externalLoggerMock struct {
 	eventCounter *atomic.Int64
 }
 
-func (logger *externalLoggerMock) log(time time.Time, message json.RawMessage, level zapcore.Level) {
+func (logger *externalLoggerMock) log(timestamp time.Time, message json.RawMessage, level zapcore.Level) {
 	if logger.eventCounter != nil {
 		logger.eventCounter.Add(1)
 	}
 
 	// do the following to make sure that the conversion into a loki log entry works
 	entry := logproto.Entry{
-		Timestamp: time,
+		Timestamp: timestamp,
 		Line:      string(message),
 	}
 	_, err := entry.Marshal()

+ 10 - 10
node/pkg/watchers/ibc/watcher.go

@@ -327,11 +327,11 @@ func (w *Watcher) handleEvents(ctx context.Context, c *websocket.Conn) error {
 			}
 
 			// Received a message from the blockchain.
-			json := string(message)
+			jsonStr := string(message)
 
-			txHashRaw := gjson.Get(json, "result.events.tx\\.hash.0")
+			txHashRaw := gjson.Get(jsonStr, "result.events.tx\\.hash.0")
 			if !txHashRaw.Exists() {
-				w.logger.Warn("message does not have tx hash", zap.String("payload", json))
+				w.logger.Warn("message does not have tx hash", zap.String("payload", jsonStr))
 				continue
 			}
 			txHash, err := vaa.StringToHash(txHashRaw.String())
@@ -340,9 +340,9 @@ func (w *Watcher) handleEvents(ctx context.Context, c *websocket.Conn) error {
 				continue
 			}
 
-			events := gjson.Get(json, "result.data.value.TxResult.result.events")
+			events := gjson.Get(jsonStr, "result.data.value.TxResult.result.events")
 			if !events.Exists() {
-				w.logger.Warn("message has no events", zap.String("payload", json))
+				w.logger.Warn("message has no events", zap.String("payload", jsonStr))
 				continue
 			}
 
@@ -374,11 +374,11 @@ func (w *Watcher) handleEvents(ctx context.Context, c *websocket.Conn) error {
 
 // convertWsUrlToHttpUrl takes a string like "ws://wormchain:26657/websocket" and converts it to "http://wormchain:26657". This is
 // used to query for the abci_info. That query doesn't work on the LCD. We have to do it on the websocket port, using an http URL.
-func convertWsUrlToHttpUrl(url string) string {
-	url = strings.TrimPrefix(url, "ws://")
-	url = strings.TrimPrefix(url, "wss://")
-	url = strings.TrimSuffix(url, "/websocket")
-	return "http://" + url
+func convertWsUrlToHttpUrl(URL string) string {
+	URL = strings.TrimPrefix(URL, "ws://")
+	URL = strings.TrimPrefix(URL, "wss://")
+	URL = strings.TrimSuffix(URL, "/websocket")
+	return "http://" + URL
 }
 
 // handleQueryBlockHeight gets the latest block height from wormchain each interval and updates the status on all the connected chains.

+ 2 - 2
node/pkg/watchers/near/nearapi/nearapi.go

@@ -151,11 +151,11 @@ func (n NearApiImpl) GetFinalBlock(ctx context.Context) (Block, error) {
 // getChunk gets a chunk from the NEAR RPC API: https://docs.near.org/api/rpc/block-chunk#chunk-details
 func (n NearApiImpl) GetChunk(ctx context.Context, chunkHeader ChunkHeader) (Chunk, error) {
 	s := fmt.Sprintf(`{"id": "dontcare", "jsonrpc": "2.0", "method": "chunk", "params": {"chunk_id": "%s"}}`, chunkHeader.Hash)
-	bytes, err := n.nearRPC.Query(ctx, s)
+	resBytes, err := n.nearRPC.Query(ctx, s)
 	if err != nil {
 		return Chunk{}, err
 	}
-	newChunk, err := NewChunkFromBytes(bytes)
+	newChunk, err := NewChunkFromBytes(resBytes)
 	if err != nil {
 		return Chunk{}, err
 	}