Преглед изворни кода

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 пре 7 месеци
родитељ
комит
a0349d8a3f

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

@@ -297,7 +297,7 @@ jobs:
       - name: Formatting checks
       - name: Formatting checks
         run: ./scripts/lint.sh -l -g format
         run: ./scripts/lint.sh -l -g format
       - name: Install linters
       - 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
       - name: Run linters
         run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint
         run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint
       - name: Ensure generated proto matches
       - name: Ensure generated proto matches

+ 1 - 1
DEVELOP.md

@@ -5,7 +5,7 @@
 The following dependencies are required for local development:
 The following dependencies are required for local development:
 
 
 - [Go](https://golang.org/dl/) >= 1.23.3 (latest minor release is recommended)
 - [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
 - [Tilt](http://tilt.dev/) >= 0.20.8
 - Any of the local Kubernetes clusters supported by Tilt.
 - Any of the local Kubernetes clusters supported by Tilt.
   We strongly recommend [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) >=
   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
 	// Run p2p
 	pendingResponses := NewPendingResponses(logger)
 	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 {
 	if err != nil {
 		logger.Fatal("Failed to start p2p", zap.Error(err))
 		logger.Fatal("Failed to start p2p", zap.Error(err))
 	}
 	}
 
 
 	// Start the HTTP server
 	// Start the HTTP server
 	go func() {
 	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)
 		logger.Sugar().Infof("Server listening on %s", *listenAddr)
 		err := s.ListenAndServe()
 		err := s.ListenAndServe()
 		if err != nil && err != http.ErrServerClosed {
 		if err != nil && err != http.ErrServerClosed {
@@ -303,14 +303,14 @@ func runQueryServer(cmd *cobra.Command, args []string) {
 	permissions.StopWatcher()
 	permissions.StopWatcher()
 
 
 	// Shutdown p2p. Without this the same host won't properly discover peers until some timeout
 	// 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))
 		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))
 		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))
 		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/watchers/sui"
 	"github.com/certusone/wormhole/node/pkg/wormconn"
 	"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/telemetry"
 	"github.com/certusone/wormhole/node/pkg/version"
 	"github.com/certusone/wormhole/node/pkg/version"
 	"github.com/gagliardetto/solana-go/rpc"
 	"github.com/gagliardetto/solana-go/rpc"
@@ -1100,7 +1100,7 @@ func runNode(cmd *cobra.Command, args []string) {
 	ipfslog.SetPrimaryCore(logger.Core())
 	ipfslog.SetPrimaryCore(logger.Core())
 
 
 	// Database
 	// Database
-	db := db.OpenDb(logger.With(zap.String("component", "badgerDb")), dataDir)
+	db := guardianDB.OpenDb(logger.With(zap.String("component", "badgerDb")), dataDir)
 	defer db.Close()
 	defer db.Close()
 
 
 	wormchainId := "wormchain"
 	wormchainId := "wormchain"
@@ -1948,21 +1948,21 @@ func runNode(cmd *cobra.Command, args []string) {
 	logger.Info("root context cancelled, exiting...")
 	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.
 // 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.
 // 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 {
 	if env != common.UnsafeDevNet {
 		// In mainnet / testnet, if either parameter is specified, they must both be specified.
 		// 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()))
 			logger.Fatal(fmt.Sprintf("Both contract and RPC for chain %s must be set or both unset", chainID.String()))
 		}
 		}
 	} else {
 	} else {
 		// In devnet, if RPC is set but contract is not set, use the deterministic one for tilt.
 		// In devnet, if RPC is set but contract is not set, use the deterministic one for tilt.
-		if rpc == "" {
+		if rpcURL == "" {
 			if contractAddr != "" {
 			if contractAddr != "" {
 				logger.Fatal(fmt.Sprintf("If RPC is not set for chain %s, contract must not be set", chainID.String()))
 				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 {
 func getVAA(chainID vaa.ChainID, emitterAddr vaa.Address) *vaa.VAA {
 	var payload = []byte{97, 97, 97, 97, 97, 97}
 	var payload = []byte{97, 97, 97, 97, 97, 97}
 
 
-	vaa := &vaa.VAA{
+	return &vaa.VAA{
 		Version:          vaa.SupportedVAAVersion,
 		Version:          vaa.SupportedVAAVersion,
 		GuardianSetIndex: uint32(1),
 		GuardianSetIndex: uint32(1),
 		Signatures:       nil,
 		Signatures:       nil,
@@ -44,8 +44,6 @@ func getVAA(chainID vaa.ChainID, emitterAddr vaa.Address) *vaa.VAA {
 		EmitterAddress:   emitterAddr,
 		EmitterAddress:   emitterAddr,
 		Payload:          payload,
 		Payload:          payload,
 	}
 	}
-
-	return vaa
 }
 }
 
 
 // wait for the server to establish a client subscription before returning.
 // wait for the server to establish a client subscription before returning.

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

@@ -13,7 +13,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	"github.com/certusone/wormhole/node/pkg/supervisor"
 	"github.com/certusone/wormhole/node/pkg/supervisor"
@@ -77,7 +77,7 @@ type (
 type Accountant struct {
 type Accountant struct {
 	ctx                  context.Context
 	ctx                  context.Context
 	logger               *zap.Logger
 	logger               *zap.Logger
-	db                   db.AccountantDB
+	db                   guardianDB.AccountantDB
 	obsvReqWriteC        chan<- *gossipv1.ObservationRequest
 	obsvReqWriteC        chan<- *gossipv1.ObservationRequest
 	contract             string
 	contract             string
 	wsUrl                string
 	wsUrl                string
@@ -112,7 +112,7 @@ func (acct *Accountant) baseEnabled() bool {
 func NewAccountant(
 func NewAccountant(
 	ctx context.Context,
 	ctx context.Context,
 	logger *zap.Logger,
 	logger *zap.Logger,
-	db db.AccountantDB,
+	db guardianDB.AccountantDB,
 	obsvReqWriteC chan<- *gossipv1.ObservationRequest,
 	obsvReqWriteC chan<- *gossipv1.ObservationRequest,
 	contract string, // the address of the smart contract on wormchain
 	contract string, // the address of the smart contract on wormchain
 	wsUrl string, // the URL of the wormchain websocket interface
 	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"
 	sdktx "github.com/cosmos/cosmos-sdk/types/tx"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/devnet"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
@@ -100,7 +100,7 @@ func newAccountantForTest(
 	acctWriteC chan<- *common.MessagePublication,
 	acctWriteC chan<- *common.MessagePublication,
 	wormchainConn *MockAccountantWormchainConn,
 	wormchainConn *MockAccountantWormchainConn,
 ) *Accountant {
 ) *Accountant {
-	var db db.MockAccountantDB
+	var db guardianDB.MockAccountantDB
 
 
 	pk := devnet.InsecureDeterministicEcdsaKeyByIndex(ethCrypto.S256(), uint64(0))
 	pk := devnet.InsecureDeterministicEcdsaKeyByIndex(ethCrypto.S256(), uint64(0))
 	guardianSigner, err := guardiansigner.GenerateSignerWithPrivatekeyUnsafe(pk)
 	guardianSigner, err := guardiansigner.GenerateSignerWithPrivatekeyUnsafe(pk)

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

@@ -26,7 +26,7 @@ import (
 	"github.com/prometheus/client_golang/prometheus/promauto"
 	"github.com/prometheus/client_golang/prometheus/promauto"
 	"golang.org/x/exp/slices"
 	"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"
 	"github.com/certusone/wormhole/node/pkg/governor"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	ethcommon "github.com/ethereum/go-ethereum/common"
 	ethcommon "github.com/ethereum/go-ethereum/common"
@@ -55,7 +55,7 @@ var (
 
 
 type nodePrivilegedService struct {
 type nodePrivilegedService struct {
 	nodev1.UnimplementedNodePrivilegedServiceServer
 	nodev1.UnimplementedNodePrivilegedServiceServer
-	db              *db.Database
+	db              *guardianDB.Database
 	injectC         chan<- *common.MessagePublication
 	injectC         chan<- *common.MessagePublication
 	obsvReqSendC    chan<- *gossipv1.ObservationRequest
 	obsvReqSendC    chan<- *gossipv1.ObservationRequest
 	logger          *zap.Logger
 	logger          *zap.Logger
@@ -70,12 +70,12 @@ type nodePrivilegedService struct {
 }
 }
 
 
 func NewPrivService(
 func NewPrivService(
-	db *db.Database,
+	db *guardianDB.Database,
 	injectC chan<- *common.MessagePublication,
 	injectC chan<- *common.MessagePublication,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
 	logger *zap.Logger,
 	logger *zap.Logger,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
-	governor *governor.ChainGovernor,
+	gov *governor.ChainGovernor,
 	evmConnector connectors.Connector,
 	evmConnector connectors.Connector,
 	guardianSigner guardiansigner.GuardianSigner,
 	guardianSigner guardiansigner.GuardianSigner,
 	guardianAddress ethcommon.Address,
 	guardianAddress ethcommon.Address,
@@ -89,7 +89,7 @@ func NewPrivService(
 		obsvReqSendC:    obsvReqSendC,
 		obsvReqSendC:    obsvReqSendC,
 		logger:          logger,
 		logger:          logger,
 		signedInC:       signedInC,
 		signedInC:       signedInC,
-		governor:        governor,
+		governor:        gov,
 		evmConnector:    evmConnector,
 		evmConnector:    evmConnector,
 		guardianSigner:  guardianSigner,
 		guardianSigner:  guardianSigner,
 		guardianAddress: guardianAddress,
 		guardianAddress: guardianAddress,
@@ -933,7 +933,7 @@ func (s *nodePrivilegedService) FindMissingMessages(ctx context.Context, req *no
 	emitterAddress := vaa.Address{}
 	emitterAddress := vaa.Address{}
 	copy(emitterAddress[:], b)
 	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),
 		EmitterChain:   vaa.ChainID(req.EmitterChain),
 		EmitterAddress: emitterAddress,
 		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) {
 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
 	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)
 	resp, err := s.db.PurgeVaas(prefix, oldestTime, req.LogOnly)
 	if err != nil {
 	if err != nil {
@@ -1315,7 +1315,7 @@ func (s *nodePrivilegedService) GetAndObserveMissingVAAs(ctx context.Context, re
 			errCounter++
 			errCounter++
 			continue
 			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)
 		hasVaa, err := s.db.HasVAA(vaaKey)
 		if err != nil || hasVaa {
 		if err != nil || hasVaa {
 			errMsgs += fmt.Sprintf("\nerror checking for VAA %s", missingVAA.VaaKey)
 			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.NoError(t, err)
 			require.Equal(t, 1, len(msg.Messages))
 			require.Equal(t, 1, len(msg.Messages))
 			govMsg := msg.Messages[0]
 			govMsg := msg.Messages[0]
-			vaa, err := GovMsgToVaa(govMsg, govGuardianSetIndex, govTimestamp)
+			govVAA, err := GovMsgToVaa(govMsg, govGuardianSetIndex, govTimestamp)
 			if tst.errText == "" {
 			if tst.errText == "" {
 				require.NoError(t, err)
 				require.NoError(t, err)
-				verifyGovernanceVAA(t, vaa, govMsg.Sequence, govMsg.Nonce)
+				verifyGovernanceVAA(t, govVAA, govMsg.Sequence, govMsg.Nonce)
 			} else {
 			} else {
 				require.ErrorContains(t, err, tst.errText)
 				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",
 		Hash:           "Hash1",
 	}
 	}
 
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	assert.Equal(t, xfer1, xfer2)
 	assert.Equal(t, xfer1, xfer2)
@@ -300,10 +300,10 @@ func TestSerializeAndDeserializeOfPendingTransfer(t *testing.T) {
 		Msg:         msg,
 		Msg:         msg,
 	}
 	}
 
 
-	bytes, err := pending1.Marshal()
+	pending1Bytes, err := pending1.Marshal()
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
-	pending2, err := UnmarshalPendingTransfer(bytes, false)
+	pending2, err := UnmarshalPendingTransfer(pending1Bytes, false)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	assert.Equal(t, pending1, pending2)
 	assert.Equal(t, pending1, pending2)
@@ -428,10 +428,10 @@ func TestMarshalUnmarshalNoMsgIdOrHash(t *testing.T) {
 		// Don't set MsgID or Hash, should handle empty slices.
 		// Don't set MsgID or Hash, should handle empty slices.
 	}
 	}
 
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	require.Equal(t, xfer1, xfer2)
 	require.Equal(t, xfer1, xfer2)
 }
 }
@@ -461,60 +461,60 @@ func TestUnmarshalTransferFailures(t *testing.T) {
 		Hash:           "Hash1",
 		Hash:           "Hash1",
 	}
 	}
 
 
-	bytes, err := xfer1.Marshal()
+	xfer1Bytes, err := xfer1.Marshal()
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	// First make sure regular unmarshal works.
 	// First make sure regular unmarshal works.
-	xfer2, err := UnmarshalTransfer(bytes)
+	xfer2, err := UnmarshalTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	require.Equal(t, xfer1, xfer2)
 	require.Equal(t, xfer1, xfer2)
 
 
 	// Truncate the timestamp.
 	// Truncate the timestamp.
-	_, err = UnmarshalTransfer(bytes[0 : 4-1])
+	_, err = UnmarshalTransfer(xfer1Bytes[0 : 4-1])
 	assert.ErrorContains(t, err, "failed to read timestamp: ")
 	assert.ErrorContains(t, err, "failed to read timestamp: ")
 
 
 	// Truncate the value.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read value: ")
 
 
 	// Truncate the origin chain.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read origin chain id: ")
 
 
 	// Truncate the origin address.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read origin address")
 
 
 	// Truncate the emitter chain.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read emitter chain id: ")
 
 
 	// Truncate the emitter address.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read emitter address")
 
 
 	// Truncate the message ID length.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read msgID length: ")
 
 
 	// Truncate the message ID data.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read msg id")
 
 
 	// Truncate the hash length.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read hash length: ")
 
 
 	// Truncate the hash data.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read hash")
 
 
 	// Truncate the target chain.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read target chain id: ")
 
 
 	// Truncate the target address.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read target address")
 }
 }
 
 
@@ -541,26 +541,26 @@ func TestUnmarshalPendingTransferFailures(t *testing.T) {
 		Msg:         msg,
 		Msg:         msg,
 	}
 	}
 
 
-	bytes, err := pending1.Marshal()
+	pending1Bytes, err := pending1.Marshal()
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	// First make sure regular unmarshal works.
 	// First make sure regular unmarshal works.
-	pending2, err := UnmarshalPendingTransfer(bytes, false)
+	pending2, err := UnmarshalPendingTransfer(pending1Bytes, false)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	assert.Equal(t, pending1, pending2)
 	assert.Equal(t, pending1, pending2)
 
 
 	// Truncate the release time.
 	// 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: ")
 	assert.ErrorContains(t, err, "failed to read pending transfer release time: ")
 
 
 	// The remainder is the marshaled message publication as a single buffer.
 	// The remainder is the marshaled message publication as a single buffer.
 
 
 	// Truncate the entire serialized message.
 	// 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")
 	assert.ErrorContains(t, err, "failed to read pending transfer msg")
 
 
 	// Truncate some of the serialized message.
 	// 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")
 	assert.ErrorContains(t, err, "failed to unmarshal pending transfer msg")
 }
 }
 
 
@@ -858,10 +858,10 @@ func TestDeserializeOfOldTransfer(t *testing.T) {
 		Hash:  "Hash1",
 		Hash:  "Hash1",
 	}
 	}
 
 
-	bytes, err := marshalOldTransfer(xfer1)
+	xfer1Bytes, err := marshalOldTransfer(xfer1)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
-	xfer2, err := unmarshalOldTransfer(bytes)
+	xfer2, err := unmarshalOldTransfer(xfer1Bytes)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	assert.Equal(t, xfer1, xfer2)
 	assert.Equal(t, xfer1, xfer2)

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

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

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

@@ -22,7 +22,7 @@ import (
 	"go.uber.org/zap"
 	"go.uber.org/zap"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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"
 	"github.com/certusone/wormhole/node/pkg/supervisor"
 )
 )
 
 
@@ -319,7 +319,7 @@ func (te tokenEntry) updatePrice() {
 func CheckQuery(logger *zap.Logger) error {
 func CheckQuery(logger *zap.Logger) error {
 	logger.Info("Instantiating governor.")
 	logger.Info("Instantiating governor.")
 	ctx := context.Background()
 	ctx := context.Background()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.MainNet, true, "")
 	gov := NewChainGovernor(logger, &db, common.MainNet, true, "")
 
 
 	if err := gov.initConfig(); err != nil {
 	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/stretchr/testify/require"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
 	"go.uber.org/zap"
 	"go.uber.org/zap"
 	"go.uber.org/zap/zapcore"
 	"go.uber.org/zap/zapcore"
@@ -212,7 +212,7 @@ func TestSumAllFromToday(t *testing.T) {
 	var transfers []transfer
 	var transfers []transfer
 	transferTime, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Jun 1, 2022 at 11:00am (CST)")
 	transferTime, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Jun 1, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer := &db.Transfer{Value: 125000, Timestamp: transferTime}
+	dbTransfer := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime}
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer)
 	transfers = append(transfers, transfer)
@@ -258,12 +258,12 @@ func TestSumWithFlowCancelling(t *testing.T) {
 	// - Transfer from emitter: we only care about Value
 	// - 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)
 	// - 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
 	//				 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)
 	outgoingTransfer, err := newTransferFromDbTransfer(outgoingDbTransfer)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	// Flow cancelling transfer
 	// Flow cancelling transfer
-	incomingDbTransfer := &db.Transfer{
+	incomingDbTransfer := &guardianDB.Transfer{
 		OriginChain:   originChain,
 		OriginChain:   originChain,
 		OriginAddress: originAddress,
 		OriginAddress: originAddress,
 		TargetChain:   vaa.ChainID(emitterChainId), // emitter
 		TargetChain:   vaa.ChainID(emitterChainId), // emitter
@@ -301,7 +301,7 @@ func TestSumWithFlowCancelling(t *testing.T) {
 func TestFlowCancelFeatureFlag(t *testing.T) {
 func TestFlowCancelFeatureFlag(t *testing.T) {
 
 
 	ctx := context.Background()
 	ctx := context.Background()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(zap.NewNop(), &db, common.GoTest, true, "")
 	gov := NewChainGovernor(zap.NewNop(), &db, common.GoTest, true, "")
 
 
 	// Trigger the evaluation of the flow cancelling config
 	// 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 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)
 	// - 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
 	//				 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)
 	emitterTransfer, err := newTransferFromDbTransfer(emitterDbTransfer)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers_from_emitter = append(transfers_from_emitter, emitterTransfer)
 	transfers_from_emitter = append(transfers_from_emitter, emitterTransfer)
 
 
-	flowCancelDbTransfer := &db.Transfer{
+	flowCancelDbTransfer := &guardianDB.Transfer{
 		OriginChain:   originChain,
 		OriginChain:   originChain,
 		OriginAddress: originAddress,
 		OriginAddress: originAddress,
 		TargetChain:   vaa.ChainID(emitterChainId), // emitter
 		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`
 	// Create a lot of transfers. Their total value should exceed `emitterLimit`
 	for i := 0; i < 25; i++ {
 	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)
 		require.NoError(t, err)
 		transfers_from_emitter = append(
 		transfers_from_emitter = append(
 			transfers_from_emitter,
 			transfers_from_emitter,
@@ -488,9 +488,9 @@ func TestTrimAndSumValueOverflowErrors(t *testing.T) {
 
 
 	emitterChainId := vaa.ChainIDSolana
 	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)
 	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)
 	require.NoError(t, err)
 	transfers_from_emitter = append(transfers_from_emitter, transfer, transfer2)
 	transfers_from_emitter = append(transfers_from_emitter, transfer, transfer2)
 
 
@@ -517,7 +517,7 @@ func TestTrimAndSumValueOverflowErrors(t *testing.T) {
 	gov.chains[emitter.emitterChainId] = emitter
 	gov.chains[emitter.emitterChainId] = emitter
 
 
 	// Now test underflow
 	// 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]
 	ce := gov.chains[emitter.emitterChainId]
 	err = ce.addFlowCancelTransferFromDbTransfer(transfer3)
 	err = ce.addFlowCancelTransferFromDbTransfer(transfer3)
@@ -547,7 +547,7 @@ func TestTrimOneOfTwoTransfers(t *testing.T) {
 	// The first transfer should be expired.
 	// The first transfer should be expired.
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:59am (CST)")
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:59am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	transfer, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer)
 	transfers = append(transfers, transfer)
@@ -555,7 +555,7 @@ func TestTrimOneOfTwoTransfers(t *testing.T) {
 	// But the second should not.
 	// But the second should not.
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer = &db.Transfer{Value: 225000, Timestamp: transferTime2}
+	dbTransfer = &guardianDB.Transfer{Value: 225000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer)
 	transfer2, err := newTransferFromDbTransfer(dbTransfer)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
 	transfers = append(transfers, transfer2)
@@ -581,14 +581,14 @@ func TestTrimSeveralTransfers(t *testing.T) {
 	// The first two transfers should be expired.
 	// 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)")
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 10:00am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer1 := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer1 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer1)
 	transfers = append(transfers, transfer1)
 
 
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:00am (CST)")
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer2 := &db.Transfer{Value: 135000, Timestamp: transferTime2}
+	dbTransfer2 := &guardianDB.Transfer{Value: 135000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
 	transfers = append(transfers, transfer2)
@@ -596,21 +596,21 @@ func TestTrimSeveralTransfers(t *testing.T) {
 	// But the next three should not.
 	// But the next three should not.
 	transferTime3, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	transferTime3, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 1:00pm (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer3 := &db.Transfer{Value: 145000, Timestamp: transferTime3}
+	dbTransfer3 := &guardianDB.Transfer{Value: 145000, Timestamp: transferTime3}
 	transfer3, err := newTransferFromDbTransfer(dbTransfer3)
 	transfer3, err := newTransferFromDbTransfer(dbTransfer3)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer3)
 	transfers = append(transfers, transfer3)
 
 
 	transferTime4, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	transferTime4, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer4 := &db.Transfer{Value: 155000, Timestamp: transferTime4}
+	dbTransfer4 := &guardianDB.Transfer{Value: 155000, Timestamp: transferTime4}
 	transfer4, err := newTransferFromDbTransfer(dbTransfer4)
 	transfer4, err := newTransferFromDbTransfer(dbTransfer4)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer4)
 	transfers = append(transfers, transfer4)
 
 
 	transferTime5, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	transferTime5, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 2:00pm (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer5 := &db.Transfer{Value: 165000, Timestamp: transferTime5}
+	dbTransfer5 := &guardianDB.Transfer{Value: 165000, Timestamp: transferTime5}
 	transfer5, err := newTransferFromDbTransfer(dbTransfer5)
 	transfer5, err := newTransferFromDbTransfer(dbTransfer5)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer5)
 	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)")
 	transferTime1, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:00am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer1 := &db.Transfer{Value: 125000, Timestamp: transferTime1}
+	dbTransfer1 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime1}
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	transfer1, err := newTransferFromDbTransfer(dbTransfer1)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer1)
 	transfers = append(transfers, transfer1)
 
 
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:45am (CST)")
 	transferTime2, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "May 31, 2022 at 11:45am (CST)")
 	require.NoError(t, err)
 	require.NoError(t, err)
-	dbTransfer2 := &db.Transfer{Value: 125000, Timestamp: transferTime2}
+	dbTransfer2 := &guardianDB.Transfer{Value: 125000, Timestamp: transferTime2}
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	transfer2, err := newTransferFromDbTransfer(dbTransfer2)
 	require.NoError(t, err)
 	require.NoError(t, err)
 	transfers = append(transfers, transfer2)
 	transfers = append(transfers, transfer2)
@@ -665,7 +665,7 @@ func newChainGovernorForTestWithLogger(ctx context.Context, logger *zap.Logger)
 		return nil, fmt.Errorf("ctx is nil")
 		return nil, fmt.Errorf("ctx is nil")
 	}
 	}
 
 
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 
 	err := gov.Run(ctx)
 	err := gov.Run(ctx)
@@ -2182,7 +2182,7 @@ func TestSmallerPendingTransfersAfterBigOneShouldGetReleased(t *testing.T) {
 
 
 func TestMainnetConfigIsValid(t *testing.T) {
 func TestMainnetConfigIsValid(t *testing.T) {
 	logger := zap.NewNop()
 	logger := zap.NewNop()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 
 	gov.env = common.TestNet
 	gov.env = common.TestNet
@@ -2192,7 +2192,7 @@ func TestMainnetConfigIsValid(t *testing.T) {
 
 
 func TestTestnetConfigIsValid(t *testing.T) {
 func TestTestnetConfigIsValid(t *testing.T) {
 	logger := zap.NewNop()
 	logger := zap.NewNop()
-	var db db.MockGovernorDB
+	var db guardianDB.MockGovernorDB
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 	gov := NewChainGovernor(logger, &db, common.GoTest, true, "")
 
 
 	gov.env = common.TestNet
 	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)")
 	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))
 	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),
 		Timestamp:      startTime.Add(time.Minute * 5),
 		Value:          uint64(1000),
 		Value:          uint64(1000),
 		OriginChain:    vaa.ChainIDEthereum,
 		OriginChain:    vaa.ChainIDEthereum,
@@ -2668,7 +2668,7 @@ func TestDontReloadDuplicates(t *testing.T) {
 	}
 	}
 	xfers = append(xfers, xfer1)
 	xfers = append(xfers, xfer1)
 
 
-	xfer2 := &db.Transfer{
+	xfer2 := &guardianDB.Transfer{
 		Timestamp:      startTime.Add(time.Minute * 5),
 		Timestamp:      startTime.Add(time.Minute * 5),
 		Value:          uint64(2000),
 		Value:          uint64(2000),
 		OriginChain:    vaa.ChainIDEthereum,
 		OriginChain:    vaa.ChainIDEthereum,
@@ -2693,8 +2693,8 @@ func TestDontReloadDuplicates(t *testing.T) {
 		1.25,
 		1.25,
 	)
 	)
 
 
-	var pendings []*db.PendingTransfer
-	pending1 := &db.PendingTransfer{
+	var pendings []*guardianDB.PendingTransfer
+	pending1 := &guardianDB.PendingTransfer{
 		ReleaseTime: now.Add(time.Hour * 24),
 		ReleaseTime: now.Add(time.Hour * 24),
 		Msg: common.MessagePublication{
 		Msg: common.MessagePublication{
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
@@ -2709,7 +2709,7 @@ func TestDontReloadDuplicates(t *testing.T) {
 	}
 	}
 	pendings = append(pendings, pending1)
 	pendings = append(pendings, pending1)
 
 
-	pending2 := &db.PendingTransfer{
+	pending2 := &guardianDB.PendingTransfer{
 		ReleaseTime: now.Add(time.Hour * 24),
 		ReleaseTime: now.Add(time.Hour * 24),
 		Msg: common.MessagePublication{
 		Msg: common.MessagePublication{
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
 			TxID:             hashToTxID("0x06f541f5ecfc43407c31587aa6ac3a689e8960f36dc23c332db5510dfc6a4063"),
@@ -2803,7 +2803,7 @@ func TestReloadTransfersNearCapacity(t *testing.T) {
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	// This transfer should exhaust the dailyLimit for the emitter chain
 	// This transfer should exhaust the dailyLimit for the emitter chain
-	xfer1 := &db.Transfer{
+	xfer1 := &guardianDB.Transfer{
 		Timestamp:      transferTime.Add(-10),
 		Timestamp:      transferTime.Add(-10),
 		Value:          uint64(10000),
 		Value:          uint64(10000),
 		OriginChain:    vaa.ChainIDSolana,
 		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
 	// 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),
 		Timestamp:      transferTime.Add(-9),
 		Value:          uint64(2000),
 		Value:          uint64(2000),
 		OriginChain:    vaa.ChainIDSolana,
 		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
 	// Send another transfer out from the original emitter chain so that we "exceed the daily limit" if flow
 	// cancel is not applied
 	// cancel is not applied
-	xfer3 := &db.Transfer{
+	xfer3 := &guardianDB.Transfer{
 		Timestamp:      transferTime.Add(-8),
 		Timestamp:      transferTime.Add(-8),
 		Value:          uint64(50),
 		Value:          uint64(50),
 		OriginChain:    vaa.ChainIDSolana,
 		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/adminrpc"
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/governor"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
@@ -31,7 +31,7 @@ func adminServiceRunnable(
 	injectC chan<- *common.MessagePublication,
 	injectC chan<- *common.MessagePublication,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
 	signedInC chan<- *gossipv1.SignedVAAWithQuorum,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
 	obsvReqSendC chan<- *gossipv1.ObservationRequest,
-	db *db.Database,
+	db *guardianDB.Database,
 	gst *common.GuardianSetState,
 	gst *common.GuardianSetState,
 	gov *governor.ChainGovernor,
 	gov *governor.ChainGovernor,
 	guardianSigner guardiansigner.GuardianSigner,
 	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/adminrpc"
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/devnet"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/processor"
 	"github.com/certusone/wormhole/node/pkg/processor"
@@ -82,7 +82,7 @@ type mockGuardian struct {
 	guardianAddr     eth_common.Address
 	guardianAddr     eth_common.Address
 	ready            bool
 	ready            bool
 	config           *guardianConfig
 	config           *guardianConfig
-	db               *db.Database
+	db               *guardianDB.Database
 }
 }
 
 
 type guardianConfig struct {
 type guardianConfig struct {
@@ -148,7 +148,7 @@ func mockGuardianRunnable(t testing.TB, gs []*mockGuardian, mockGuardianIndex ui
 		defer ctxCancel()
 		defer ctxCancel()
 
 
 		// setup db
 		// setup db
-		db := db.OpenDb(nil, nil)
+		db := guardianDB.OpenDb(nil, nil)
 		defer db.Close()
 		defer db.Close()
 		gs[mockGuardianIndex].db = db
 		gs[mockGuardianIndex].db = db
 
 
@@ -457,14 +457,14 @@ func governedMsg(shouldBeDelayed bool) *common.MessagePublication {
 }
 }
 
 
 func makeObsDb(tc []testCase) mock.ObservationDb {
 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 {
 	for _, t := range tc {
 		if t.unavailableInReobservation {
 		if t.unavailableInReobservation {
 			continue
 			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.
 // 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/accountant"
 	"github.com/certusone/wormhole/node/pkg/altpub"
 	"github.com/certusone/wormhole/node/pkg/altpub"
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/governor"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	"github.com/certusone/wormhole/node/pkg/p2p"
 	"github.com/certusone/wormhole/node/pkg/p2p"
@@ -428,10 +428,10 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}(chainQueryResponseC[chainId], chainId)
 				}(chainQueryResponseC[chainId], chainId)
 			}
 			}
 
 
-			watchers := make(map[watchers.NetworkID]interfaces.L1Finalizer)
+			configuredWatchers := make(map[watchers.NetworkID]interfaces.L1Finalizer)
 
 
 			for _, wc := range watcherConfigs {
 			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()))
 					return fmt.Errorf("NetworkID already configured: %s", string(wc.GetNetworkID()))
 				}
 				}
 
 
@@ -445,7 +445,7 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}
 				}
 
 
 				if wc.RequiredL1Finalizer() != "" {
 				if wc.RequiredL1Finalizer() != "" {
-					l1watcher, ok := watchers[wc.RequiredL1Finalizer()]
+					l1watcher, ok := configuredWatchers[wc.RequiredL1Finalizer()]
 					if !ok || l1watcher == nil {
 					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.",
 						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()),
 							zap.String("ChainID", wc.GetChainID().String()),
@@ -461,7 +461,7 @@ func GuardianOptionWatchers(watcherConfigs []watchers.WatcherConfig, ibcWatcherC
 				}
 				}
 
 
 				g.runnablesWithScissors[watcherName] = runnable
 				g.runnablesWithScissors[watcherName] = runnable
-				watchers[wc.GetNetworkID()] = l1finalizer
+				configuredWatchers[wc.GetNetworkID()] = l1finalizer
 
 
 				if reobserver != nil {
 				if reobserver != nil {
 					g.reobservers[wc.GetChainID()] = reobserver
 					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.
 // GuardianOptionDatabase configures the main database to be used for this guardian node.
 // Dependencies: none
 // Dependencies: none
-func GuardianOptionDatabase(db *db.Database) *GuardianOption {
+func GuardianOptionDatabase(db *guardianDB.Database) *GuardianOption {
 	return &GuardianOption{
 	return &GuardianOption{
 		name: "db",
 		name: "db",
 		f: func(ctx context.Context, logger *zap.Logger, g *G) error {
 		f: func(ctx context.Context, logger *zap.Logger, g *G) error {

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

@@ -7,7 +7,7 @@ import (
 	"os"
 	"os"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/governor"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	"github.com/certusone/wormhole/node/pkg/publicrpc"
 	"github.com/certusone/wormhole/node/pkg/publicrpc"
@@ -16,7 +16,7 @@ import (
 	"google.golang.org/grpc"
 	"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 {
 	return func(ctx context.Context) error {
 		l, err := net.Listen("tcp", listenAddr)
 		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.
 	// Delete existing UNIX socket, if present.
 	fi, err := os.Stat(socketPath)
 	fi, err := os.Stat(socketPath)
 	if err == nil {
 	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.
 // 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
 	// Match groups of reVersion
-	components := reVersion.FindStringSubmatch(version)
+	components := reVersion.FindStringSubmatch(versionStr)
 	referenceComponents := reVersion.FindStringSubmatch(reference)
 	referenceComponents := reVersion.FindStringSubmatch(reference)
 
 
 	// Compare components of the version string with the reference and ensure
 	// 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 == "" {
 	if v == "" {
 		return "other"
 		return "other"
 	}
 	}

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

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

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

@@ -9,7 +9,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	"github.com/certusone/wormhole/node/pkg/gwrelayer"
 	gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
 	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) {
 func BenchmarkHandleObservation(b *testing.B) {
 	const NumObservations = 100000
 	const NumObservations = 100000
 	ctx := context.Background()
 	ctx := context.Background()
-	db := db.OpenDb(nil, nil)
+	db := guardianDB.OpenDb(nil, nil)
 	defer db.Close()
 	defer db.Close()
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	require.NotNil(b, p)
 	require.NotNil(b, p)
@@ -100,7 +100,7 @@ func BenchmarkProfileHandleObservation(b *testing.B) {
 	defer pprof.StopCPUProfile()
 	defer pprof.StopCPUProfile()
 
 
 	ctx := context.Background()
 	ctx := context.Background()
-	db := db.OpenDb(nil, nil)
+	db := guardianDB.OpenDb(nil, nil)
 	defer db.Close()
 	defer db.Close()
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	p, pd := createProcessorForTest(b, NumObservations, ctx, db)
 	require.NotNil(b, p)
 	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.
 // 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()
 	b.Helper()
 	logger := zap.NewNop()
 	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 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}
 	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),
 		Version:          uint8(1),
 		GuardianSetIndex: uint32(1),
 		GuardianSetIndex: uint32(1),
 		Signatures:       nil,
 		Signatures:       nil,
@@ -32,13 +32,11 @@ func getVAA() vaa.VAA {
 		EmitterAddress:   governanceEmitter,
 		EmitterAddress:   governanceEmitter,
 		Payload:          payload,
 		Payload:          payload,
 	}
 	}
-
-	return vaa
 }
 }
 
 
 func TestHandleInboundSignedVAAWithQuorum_NilGuardianSet(t *testing.T) {
 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
 	// Stub out the minimum to get processor to dance
 	observedZapCore, observedLogs := observer.New(zap.InfoLevel)
 	observedZapCore, observedLogs := observer.New(zap.InfoLevel)
@@ -84,7 +82,7 @@ func TestHandleInboundSignedVAAWithQuorum(t *testing.T) {
 
 
 	for _, tc := range tests {
 	for _, tc := range tests {
 		t.Run(tc.label, func(t *testing.T) {
 		t.Run(tc.label, func(t *testing.T) {
-			vaa := getVAA()
+			testVAA := getVAA()
 
 
 			// Define a GuardianSet from test addrs
 			// Define a GuardianSet from test addrs
 			guardianSet := common.GuardianSet{
 			guardianSet := common.GuardianSet{
@@ -94,10 +92,10 @@ func TestHandleInboundSignedVAAWithQuorum(t *testing.T) {
 
 
 			// Sign with the keys at the proper index
 			// Sign with the keys at the proper index
 			for i, key := range tc.keyOrder {
 			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 {
 			if err != nil {
 				panic(err)
 				panic(err)
 			}
 			}

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

@@ -8,7 +8,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/certusone/wormhole/node/pkg/altpub"
 	"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/governor"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/guardiansigner"
 	"github.com/certusone/wormhole/node/pkg/p2p"
 	"github.com/certusone/wormhole/node/pkg/p2p"
@@ -129,7 +129,7 @@ type Processor struct {
 
 
 	logger *zap.Logger
 	logger *zap.Logger
 
 
-	db *db.Database
+	db *guardianDB.Database
 
 
 	alternatePublisher *altpub.AlternatePublisher
 	alternatePublisher *altpub.AlternatePublisher
 
 
@@ -206,7 +206,7 @@ const batchObsvPubChanSize = p2p.MaxObservationBatchSize * 5
 
 
 func NewProcessor(
 func NewProcessor(
 	ctx context.Context,
 	ctx context.Context,
-	db *db.Database,
+	db *guardianDB.Database,
 	msgC <-chan *common.MessagePublication,
 	msgC <-chan *common.MessagePublication,
 	setC <-chan *common.GuardianSet,
 	setC <-chan *common.GuardianSet,
 	gossipAttestationSendC chan<- []byte,
 	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
 // 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 id.EmitterChain == vaa.ChainIDPythNet {
 		if p.pythnetVaas == nil {
 		if p.pythnetVaas == nil {
 			return false
 			return false

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

@@ -8,7 +8,7 @@ import (
 	"math"
 	"math"
 
 
 	"github.com/certusone/wormhole/node/pkg/common"
 	"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/governor"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	publicrpcv1 "github.com/certusone/wormhole/node/pkg/proto/publicrpc/v1"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
 	"github.com/wormhole-foundation/wormhole/sdk/vaa"
@@ -21,14 +21,14 @@ import (
 type PublicrpcServer struct {
 type PublicrpcServer struct {
 	publicrpcv1.UnsafePublicRPCServiceServer
 	publicrpcv1.UnsafePublicRPCServiceServer
 	logger *zap.Logger
 	logger *zap.Logger
-	db     *db.Database
+	db     *guardianDB.Database
 	gst    *common.GuardianSetState
 	gst    *common.GuardianSetState
 	gov    *governor.ChainGovernor
 	gov    *governor.ChainGovernor
 }
 }
 
 
 func NewPublicrpcServer(
 func NewPublicrpcServer(
 	logger *zap.Logger,
 	logger *zap.Logger,
-	db *db.Database,
+	db *guardianDB.Database,
 	gst *common.GuardianSetState,
 	gst *common.GuardianSetState,
 	gov *governor.ChainGovernor,
 	gov *governor.ChainGovernor,
 ) *PublicrpcServer {
 ) *PublicrpcServer {
@@ -92,14 +92,14 @@ func (s *PublicrpcServer) GetSignedVAA(ctx context.Context, req *publicrpcv1.Get
 	addr := vaa.Address{}
 	addr := vaa.Address{}
 	copy(addr[:], address)
 	copy(addr[:], address)
 
 
-	b, err := s.db.GetSignedVAABytes(db.VAAID{
+	b, err := s.db.GetSignedVAABytes(guardianDB.VAAID{
 		EmitterChain:   chainID,
 		EmitterChain:   chainID,
 		EmitterAddress: addr,
 		EmitterAddress: addr,
 		Sequence:       req.MessageId.Sequence,
 		Sequence:       req.MessageId.Sequence,
 	})
 	})
 
 
 	if err != nil {
 	if err != nil {
-		if errors.Is(err, db.ErrVAANotFound) {
+		if errors.Is(err, guardianDB.ErrVAANotFound) {
 			return nil, status.Error(codes.NotFound, err.Error())
 			return nil, status.Error(codes.NotFound, err.Error())
 		}
 		}
 		s.logger.Error("failed to fetch VAA", zap.Error(err), zap.Any("request", req))
 		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) {
 func TestMarshalUnmarshal(t *testing.T) {
 	timeseries := []*prometheusv1.TimeSeries{}
 	timeseries := []*prometheusv1.TimeSeries{}
 	wr := prometheusv1.WriteRequest{Timeseries: timeseries}
 	wr := prometheusv1.WriteRequest{Timeseries: timeseries}
-	bytes, err := proto.Marshal(&wr)
+	wrBytes, err := proto.Marshal(&wr)
 	require.NoError(t, err)
 	require.NoError(t, err)
 
 
 	newWr := prometheusv1.WriteRequest{}
 	newWr := prometheusv1.WriteRequest{}
-	err = proto.Unmarshal(bytes, &newWr)
+	err = proto.Unmarshal(wrBytes, &newWr)
 	require.NoError(t, err)
 	require.NoError(t, err)
 }
 }

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

@@ -19,14 +19,14 @@ type externalLoggerMock struct {
 	eventCounter *atomic.Int64
 	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 {
 	if logger.eventCounter != nil {
 		logger.eventCounter.Add(1)
 		logger.eventCounter.Add(1)
 	}
 	}
 
 
 	// do the following to make sure that the conversion into a loki log entry works
 	// do the following to make sure that the conversion into a loki log entry works
 	entry := logproto.Entry{
 	entry := logproto.Entry{
-		Timestamp: time,
+		Timestamp: timestamp,
 		Line:      string(message),
 		Line:      string(message),
 	}
 	}
 	_, err := entry.Marshal()
 	_, 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.
 			// 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() {
 			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
 				continue
 			}
 			}
 			txHash, err := vaa.StringToHash(txHashRaw.String())
 			txHash, err := vaa.StringToHash(txHashRaw.String())
@@ -340,9 +340,9 @@ func (w *Watcher) handleEvents(ctx context.Context, c *websocket.Conn) error {
 				continue
 				continue
 			}
 			}
 
 
-			events := gjson.Get(json, "result.data.value.TxResult.result.events")
+			events := gjson.Get(jsonStr, "result.data.value.TxResult.result.events")
 			if !events.Exists() {
 			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
 				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
 // 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.
 // 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.
 // 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
 // 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) {
 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)
 	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 {
 	if err != nil {
 		return Chunk{}, err
 		return Chunk{}, err
 	}
 	}
-	newChunk, err := NewChunkFromBytes(bytes)
+	newChunk, err := NewChunkFromBytes(resBytes)
 	if err != nil {
 	if err != nil {
 		return Chunk{}, err
 		return Chunk{}, err
 	}
 	}