diff --git a/.golangci.yml b/.golangci.yml index 63b061c2951..d35b6459e05 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,7 +8,6 @@ linters: - errname - errorlint - exhaustive - - exportloopref - fatcontext - ginkgolinter - gocritic diff --git a/deployment/.golangci.yml b/deployment/.golangci.yml index ff1303e26ce..7341210ce00 100644 --- a/deployment/.golangci.yml +++ b/deployment/.golangci.yml @@ -8,7 +8,6 @@ linters: - errname - errorlint - exhaustive - - exportloopref - fatcontext - ginkgolinter - gocritic diff --git a/deployment/address_book.go b/deployment/address_book.go index 3ce0332a4c3..fde0adc2d97 100644 --- a/deployment/address_book.go +++ b/deployment/address_book.go @@ -14,9 +14,9 @@ import ( ) var ( - ErrInvalidChainSelector = fmt.Errorf("invalid chain selector") - ErrInvalidAddress = fmt.Errorf("invalid address") - ErrChainNotFound = fmt.Errorf("chain not found") + ErrInvalidChainSelector = errors.New("invalid chain selector") + ErrInvalidAddress = errors.New("invalid address") + ErrChainNotFound = errors.New("chain not found") ) // ContractType is a simple string type for identifying contract types. @@ -117,7 +117,7 @@ func (m *AddressBookMap) save(chainSelector uint64, address string, typeAndVersi // TODO NONEVM-960: Add validation for non-EVM chain addresses if typeAndVersion.Type == "" { - return fmt.Errorf("type cannot be empty") + return errors.New("type cannot be empty") } if _, exists := m.addressesByChain[chainSelector]; !exists { @@ -256,7 +256,7 @@ func SearchAddressBook(ab AddressBook, chain uint64, typ ContractType) (string, } } - return "", fmt.Errorf("not found") + return "", errors.New("not found") } func AddressBookContains(ab AddressBook, chain uint64, addrToFind string) (bool, error) { diff --git a/deployment/ccip/changeset/cs_ccip_home.go b/deployment/ccip/changeset/cs_ccip_home.go index 0c82afee261..7d3327a31f2 100644 --- a/deployment/ccip/changeset/cs_ccip_home.go +++ b/deployment/ccip/changeset/cs_ccip_home.go @@ -3,6 +3,7 @@ package changeset import ( "bytes" "encoding/hex" + "errors" "fmt" "math/big" "os" @@ -139,7 +140,7 @@ func (p PromoteCandidatesChangesetConfig) Validate(e deployment.Environment) ([] if p.PluginType != types.PluginTypeCCIPCommit && p.PluginType != types.PluginTypeCCIPExec { - return nil, fmt.Errorf("PluginType must be set to either CCIPCommit or CCIPExec") + return nil, errors.New("PluginType must be set to either CCIPCommit or CCIPExec") } var donIDs []uint32 @@ -153,7 +154,7 @@ func (p PromoteCandidatesChangesetConfig) Validate(e deployment.Environment) ([] } if chainState.OffRamp == nil { // should not be possible, but a defensive check. - return nil, fmt.Errorf("OffRamp contract does not exist") + return nil, errors.New("OffRamp contract does not exist") } donID, err := internal.DonIDForChain( @@ -182,13 +183,13 @@ func (p PromoteCandidatesChangesetConfig) Validate(e deployment.Environment) ([] donIDs = append(donIDs, donID) } if len(e.NodeIDs) == 0 { - return nil, fmt.Errorf("NodeIDs must be set") + return nil, errors.New("NodeIDs must be set") } if state.Chains[p.HomeChainSelector].CCIPHome == nil { - return nil, fmt.Errorf("CCIPHome contract does not exist") + return nil, errors.New("CCIPHome contract does not exist") } if state.Chains[p.HomeChainSelector].CapabilityRegistry == nil { - return nil, fmt.Errorf("CapabilityRegistry contract does not exist") + return nil, errors.New("CapabilityRegistry contract does not exist") } return donIDs, nil @@ -316,7 +317,7 @@ func (s SetCandidateConfigBase) Validate(e deployment.Environment, state CCIPOnC } if s.PluginType != types.PluginTypeCCIPCommit && s.PluginType != types.PluginTypeCCIPExec { - return fmt.Errorf("PluginType must be set to either CCIPCommit or CCIPExec") + return errors.New("PluginType must be set to either CCIPCommit or CCIPExec") } // no donID check since this config is used for both adding a new DON and updating an existing one. @@ -340,17 +341,17 @@ func (s SetCandidateConfigBase) Validate(e deployment.Environment, state CCIPOnC // TODO: validate gas config in the chain config in cciphome for this RemoteChainSelectors. } if len(e.NodeIDs) == 0 { - return fmt.Errorf("nodeIDs must be set") + return errors.New("nodeIDs must be set") } if state.Chains[s.HomeChainSelector].CCIPHome == nil { - return fmt.Errorf("CCIPHome contract does not exist") + return errors.New("CCIPHome contract does not exist") } if state.Chains[s.HomeChainSelector].CapabilityRegistry == nil { - return fmt.Errorf("CapabilityRegistry contract does not exist") + return errors.New("CapabilityRegistry contract does not exist") } if e.OCRSecrets.IsEmpty() { - return fmt.Errorf("OCR secrets must be set") + return errors.New("OCR secrets must be set") } return nil @@ -443,7 +444,7 @@ func AddDonAndSetCandidateChangeset( pluginOCR3Config, ok := newDONArgs[cfg.PluginType] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("missing commit plugin in ocr3Configs") + return deployment.ChangesetOutput{}, errors.New("missing commit plugin in ocr3Configs") } expectedDonID := latestDon.Id + 1 @@ -476,7 +477,7 @@ func AddDonAndSetCandidateChangeset( ChainIdentifier: mcms.ChainIdentifier(cfg.HomeChainSelector), Batch: donOps, }}, - fmt.Sprintf("addDON on new Chain && setCandidate for plugin %s", cfg.PluginType.String()), + "addDON on new Chain && setCandidate for plugin "+cfg.PluginType.String(), cfg.MCMS.MinDelay, ) if err != nil { @@ -671,7 +672,7 @@ func setCandidateOnExistingDon( mcmsEnabled bool, ) ([]mcms.Operation, error) { if donID == 0 { - return nil, fmt.Errorf("donID is zero") + return nil, errors.New("donID is zero") } encodedSetCandidateCall, err := internal.CCIPHomeABI.Pack( @@ -791,7 +792,7 @@ func promoteAllCandidatesForChainOps( mcmsEnabled bool, ) (mcms.Operation, error) { if donID == 0 { - return mcms.Operation{}, fmt.Errorf("donID is zero") + return mcms.Operation{}, errors.New("donID is zero") } updatePluginOp, err := promoteCandidateOp( @@ -831,13 +832,13 @@ func (r RevokeCandidateChangesetConfig) Validate(e deployment.Environment, state return 0, fmt.Errorf("don chain selector invalid: %w", err) } if len(e.NodeIDs) == 0 { - return 0, fmt.Errorf("NodeIDs must be set") + return 0, errors.New("NodeIDs must be set") } if state.Chains[r.HomeChainSelector].CCIPHome == nil { - return 0, fmt.Errorf("CCIPHome contract does not exist") + return 0, errors.New("CCIPHome contract does not exist") } if state.Chains[r.HomeChainSelector].CapabilityRegistry == nil { - return 0, fmt.Errorf("CapabilityRegistry contract does not exist") + return 0, errors.New("CapabilityRegistry contract does not exist") } homeChainState, exists := state.Chains[r.HomeChainSelector] if !exists { @@ -866,7 +867,7 @@ func (r RevokeCandidateChangesetConfig) Validate(e deployment.Environment, state return 0, fmt.Errorf("fetching candidate digest from cciphome: %w", err) } if candidateDigest == [32]byte{} { - return 0, fmt.Errorf("candidate config digest is zero, can't revoke it") + return 0, errors.New("candidate config digest is zero, can't revoke it") } return donID, nil @@ -947,7 +948,7 @@ func revokeCandidateOps( mcmsEnabled bool, ) ([]mcms.Operation, error) { if donID == 0 { - return nil, fmt.Errorf("donID is zero") + return nil, errors.New("donID is zero") } candidateDigest, err := ccipHome.GetCandidateDigest(nil, donID, pluginType) @@ -1017,7 +1018,7 @@ func (c UpdateChainConfigConfig) Validate(e deployment.Environment) error { return fmt.Errorf("home chain selector invalid: %w", err) } if len(c.RemoteChainRemoves) == 0 && len(c.RemoteChainAdds) == 0 { - return fmt.Errorf("no chain adds or removes") + return errors.New("no chain adds or removes") } homeChainState, exists := state.Chains[c.HomeChainSelector] if !exists { @@ -1042,10 +1043,10 @@ func (c UpdateChainConfigConfig) Validate(e deployment.Environment) error { return fmt.Errorf("chain to add %d is not supported", add) } if ccfg.FChain == 0 { - return fmt.Errorf("FChain must be set") + return errors.New("FChain must be set") } if len(ccfg.Readers) == 0 { - return fmt.Errorf("Readers must be set") + return errors.New("Readers must be set") } } return nil diff --git a/deployment/ccip/changeset/cs_ccip_home_test.go b/deployment/ccip/changeset/cs_ccip_home_test.go index dae32557f8b..eb22f05a703 100644 --- a/deployment/ccip/changeset/cs_ccip_home_test.go +++ b/deployment/ccip/changeset/cs_ccip_home_test.go @@ -459,7 +459,7 @@ func Test_UpdateChainConfigs(t *testing.T) { ccipHome := state.Chains[tenv.HomeChainSel].CCIPHome otherChainConfig, err := ccipHome.GetChainConfig(nil, otherChain) require.NoError(t, err) - assert.True(t, otherChainConfig.FChain != 0) + assert.NotZero(t, otherChainConfig.FChain) var mcmsConfig *MCMSConfig if tc.mcmsEnabled { @@ -488,7 +488,7 @@ func Test_UpdateChainConfigs(t *testing.T) { // other chain should be gone chainConfigAfter, err := ccipHome.GetChainConfig(nil, otherChain) require.NoError(t, err) - assert.True(t, chainConfigAfter.FChain == 0) + assert.Zero(t, chainConfigAfter.FChain) // Lets add it back now. _, err = commonchangeset.ApplyChangesets(t, tenv.Env, map[uint64]*proposalutils.TimelockExecutionContracts{ diff --git a/deployment/ccip/changeset/cs_chain_contracts.go b/deployment/ccip/changeset/cs_chain_contracts.go index f85814f1768..e87e66e06b5 100644 --- a/deployment/ccip/changeset/cs_chain_contracts.go +++ b/deployment/ccip/changeset/cs_chain_contracts.go @@ -221,7 +221,7 @@ func UpdateNonceManagersCS(e deployment.Environment, cfg UpdateNonceManagerConfi type UpdateOnRampDestsConfig struct { UpdatesByChain map[uint64]map[uint64]OnRampDestinationUpdate // Disallow mixing MCMS/non-MCMS per chain for simplicity. - // (can still be acheived by calling this function multiple times) + // (can still be achieved by calling this function multiple times) MCMS *MCMSConfig } @@ -265,7 +265,7 @@ func (cfg UpdateOnRampDestsConfig) Validate(e deployment.Environment) error { return fmt.Errorf("failed to get onramp static config %s: %w", chainState.OnRamp.Address(), err) } if destination == sc.ChainSelector { - return fmt.Errorf("cannot update onramp destination to the same chain") + return errors.New("cannot update onramp destination to the same chain") } } } @@ -514,7 +514,7 @@ func UpdateFeeQuoterPricesCS(e deployment.Environment, cfg UpdateFeeQuoterPrices type UpdateFeeQuoterDestsConfig struct { UpdatesByChain map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig // Disallow mixing MCMS/non-MCMS per chain for simplicity. - // (can still be acheived by calling this function multiple times) + // (can still be achieved by calling this function multiple times) MCMS *MCMSConfig } @@ -552,7 +552,7 @@ func (cfg UpdateFeeQuoterDestsConfig) Validate(e deployment.Environment) error { return fmt.Errorf("failed to get onramp static config %s: %w", chainState.OnRamp.Address(), err) } if destination == sc.ChainSelector { - return fmt.Errorf("source and destination chain cannot be the same") + return errors.New("source and destination chain cannot be the same") } } } @@ -824,7 +824,6 @@ func (cfg UpdateRouterRampsConfig) Validate(e deployment.Environment) error { return fmt.Errorf("missing offramp for dest %d", destination) } } - } return nil } diff --git a/deployment/ccip/changeset/cs_chain_contracts_test.go b/deployment/ccip/changeset/cs_chain_contracts_test.go index 0a1e0ce3b7b..adbcc078373 100644 --- a/deployment/ccip/changeset/cs_chain_contracts_test.go +++ b/deployment/ccip/changeset/cs_chain_contracts_test.go @@ -81,11 +81,11 @@ func TestUpdateOnRampsDests(t *testing.T) { sourceCfg, err := state.Chains[source].OnRamp.GetDestChainConfig(&bind.CallOpts{Context: ctx}, dest) require.NoError(t, err) require.Equal(t, state.Chains[source].TestRouter.Address(), sourceCfg.Router) - require.Equal(t, false, sourceCfg.AllowlistEnabled) + require.False(t, sourceCfg.AllowlistEnabled) destCfg, err := state.Chains[dest].OnRamp.GetDestChainConfig(&bind.CallOpts{Context: ctx}, source) require.NoError(t, err) require.Equal(t, state.Chains[dest].Router.Address(), destCfg.Router) - require.Equal(t, true, destCfg.AllowlistEnabled) + require.True(t, destCfg.AllowlistEnabled) }) } } diff --git a/deployment/ccip/changeset/cs_deploy_chain.go b/deployment/ccip/changeset/cs_deploy_chain.go index 5a6085202a9..68655377f2e 100644 --- a/deployment/ccip/changeset/cs_deploy_chain.go +++ b/deployment/ccip/changeset/cs_deploy_chain.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "math/big" @@ -81,7 +82,7 @@ func deployChainContractsForChains( capReg := existingState.Chains[homeChainSel].CapabilityRegistry if capReg == nil { e.Logger.Errorw("Failed to get capability registry") - return fmt.Errorf("capability registry not found") + return errors.New("capability registry not found") } cr, err := capReg.GetHashedCapabilityId( &bind.CallOpts{}, internal.CapabilityLabelledName, internal.CapabilityVersion) @@ -105,12 +106,12 @@ func deployChainContractsForChains( return err } if ccipHome.Address() != existingState.Chains[homeChainSel].CCIPHome.Address() { - return fmt.Errorf("ccip home address mismatch") + return errors.New("ccip home address mismatch") } rmnHome := existingState.Chains[homeChainSel].RMNHome if rmnHome == nil { e.Logger.Errorw("Failed to get rmn home", "err", err) - return fmt.Errorf("rmn home not found") + return errors.New("rmn home not found") } deployGrp := errgroup.Group{} for _, chainSel := range chainsToDeploy { @@ -203,7 +204,7 @@ func deployChainContracts( rmnLegacyAddr, ) return deployment.ContractDeploy[*rmn_remote.RMNRemote]{ - rmnRemoteAddr, rmnRemote, tx, deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev), err2, + Address: rmnRemoteAddr, Contract: rmnRemote, Tx: tx, Tv: deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev), Err: err2, } }) if err != nil { @@ -243,7 +244,7 @@ func deployChainContracts( RMNProxy.Address(), ) return deployment.ContractDeploy[*router.Router]{ - routerAddr, routerC, tx2, deployment.NewTypeAndVersion(TestRouter, deployment.Version1_2_0), err2, + Address: routerAddr, Contract: routerC, Tx: tx2, Tv: deployment.NewTypeAndVersion(TestRouter, deployment.Version1_2_0), Err: err2, } }) if err != nil { @@ -264,7 +265,7 @@ func deployChainContracts( []common.Address{}, // Need to add onRamp after ) return deployment.ContractDeploy[*nonce_manager.NonceManager]{ - nonceManagerAddr, nonceManager, tx2, deployment.NewTypeAndVersion(NonceManager, deployment.Version1_6_0_dev), err2, + Address: nonceManagerAddr, Contract: nonceManager, Tx: tx2, Tv: deployment.NewTypeAndVersion(NonceManager, deployment.Version1_6_0_dev), Err: err2, } }) if err != nil { @@ -304,7 +305,7 @@ func deployChainContracts( []fee_quoter.FeeQuoterDestChainConfigArgs{}, ) return deployment.ContractDeploy[*fee_quoter.FeeQuoter]{ - prAddr, pr, tx2, deployment.NewTypeAndVersion(FeeQuoter, deployment.Version1_6_0_dev), err2, + Address: prAddr, Contract: pr, Tx: tx2, Tv: deployment.NewTypeAndVersion(FeeQuoter, deployment.Version1_6_0_dev), Err: err2, } }) if err != nil { @@ -335,7 +336,7 @@ func deployChainContracts( []onramp.OnRampDestChainConfigArgs{}, ) return deployment.ContractDeploy[*onramp.OnRamp]{ - onRampAddr, onRamp, tx2, deployment.NewTypeAndVersion(OnRamp, deployment.Version1_6_0_dev), err2, + Address: onRampAddr, Contract: onRamp, Tx: tx2, Tv: deployment.NewTypeAndVersion(OnRamp, deployment.Version1_6_0_dev), Err: err2, } }) if err != nil { diff --git a/deployment/ccip/changeset/cs_home_chain.go b/deployment/ccip/changeset/cs_home_chain.go index b92a8d132a4..3b985f5c526 100644 --- a/deployment/ccip/changeset/cs_home_chain.go +++ b/deployment/ccip/changeset/cs_home_chain.go @@ -61,23 +61,23 @@ type DeployHomeChainConfig struct { func (c DeployHomeChainConfig) Validate() error { if c.HomeChainSel == 0 { - return fmt.Errorf("home chain selector must be set") + return errors.New("home chain selector must be set") } if c.RMNDynamicConfig.OffchainConfig == nil { - return fmt.Errorf("offchain config for RMNHomeDynamicConfig must be set") + return errors.New("offchain config for RMNHomeDynamicConfig must be set") } if c.RMNStaticConfig.OffchainConfig == nil { - return fmt.Errorf("offchain config for RMNHomeStaticConfig must be set") + return errors.New("offchain config for RMNHomeStaticConfig must be set") } if len(c.NodeOperators) == 0 { - return fmt.Errorf("node operators must be set") + return errors.New("node operators must be set") } for _, nop := range c.NodeOperators { if nop.Admin == (common.Address{}) { - return fmt.Errorf("node operator admin address must be set") + return errors.New("node operator admin address must be set") } if nop.Name == "" { - return fmt.Errorf("node operator name must be set") + return errors.New("node operator name must be set") } if len(c.NodeP2PIDsPerNodeOpAdmin[nop.Name]) == 0 { return fmt.Errorf("node operator %s must have node p2p ids provided", nop.Name) @@ -338,14 +338,14 @@ func (c RemoveDONsConfig) Validate(homeChain CCIPChainState) error { return fmt.Errorf("home chain selector must be set %w", err) } if len(c.DonIDs) == 0 { - return fmt.Errorf("don ids must be set") + return errors.New("don ids must be set") } // Cap reg must exist if homeChain.CapabilityRegistry == nil { - return fmt.Errorf("cap reg does not exist") + return errors.New("cap reg does not exist") } if homeChain.CCIPHome == nil { - return fmt.Errorf("ccip home does not exist") + return errors.New("ccip home does not exist") } if err := internal.DONIdExists(homeChain.CapabilityRegistry, c.DonIDs); err != nil { return err diff --git a/deployment/ccip/changeset/cs_home_chain_test.go b/deployment/ccip/changeset/cs_home_chain_test.go index 8a2d4f87709..e96cd878305 100644 --- a/deployment/ccip/changeset/cs_home_chain_test.go +++ b/deployment/ccip/changeset/cs_home_chain_test.go @@ -52,12 +52,12 @@ func TestDeployHomeChain(t *testing.T) { capRegSnap, ok := snap[chainName].CapabilityRegistry[state.Chains[homeChainSel].CapabilityRegistry.Address().String()] require.True(t, ok) require.NotNil(t, capRegSnap) - require.Equal(t, capRegSnap.Nops, []v1_0.NopView{ + require.Equal(t, []v1_0.NopView{ { Admin: e.Chains[homeChainSel].DeployerKey.From, Name: "NodeOperator", }, - }) + }, capRegSnap.Nops) require.Len(t, capRegSnap.Nodes, len(p2pIds)) } diff --git a/deployment/ccip/changeset/cs_update_rmn_config.go b/deployment/ccip/changeset/cs_update_rmn_config.go index 96f8eacb4cc..337b3756881 100644 --- a/deployment/ccip/changeset/cs_update_rmn_config.go +++ b/deployment/ccip/changeset/cs_update_rmn_config.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "math/big" "reflect" @@ -178,14 +179,14 @@ func (c SetRMNHomeCandidateConfig) Validate(state CCIPOnChainState) error { } if len(c.RMNDynamicConfig.OffchainConfig) != 0 { - return fmt.Errorf("RMNDynamicConfig.OffchainConfig must be empty") + return errors.New("RMNDynamicConfig.OffchainConfig must be empty") } if len(c.RMNStaticConfig.OffchainConfig) != 0 { - return fmt.Errorf("RMNStaticConfig.OffchainConfig must be empty") + return errors.New("RMNStaticConfig.OffchainConfig must be empty") } if len(c.RMNStaticConfig.Nodes) > 256 { - return fmt.Errorf("RMNStaticConfig.Nodes must be less than 256") + return errors.New("RMNStaticConfig.Nodes must be less than 256") } var ( diff --git a/deployment/ccip/changeset/state.go b/deployment/ccip/changeset/state.go index b50724eaa16..aa07168a6d2 100644 --- a/deployment/ccip/changeset/state.go +++ b/deployment/ccip/changeset/state.go @@ -2,6 +2,7 @@ package changeset import ( "fmt" + "strconv" "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" @@ -366,7 +367,7 @@ func (s CCIPOnChainState) View(chains []uint64) (map[string]view.ChainView, erro } name := chainInfo.ChainName if chainInfo.ChainName == "" { - name = fmt.Sprintf("%d", chainSelector) + name = strconv.FormatUint(chainSelector, 10) } m[name] = chainView } diff --git a/deployment/ccip/changeset/test_assertions.go b/deployment/ccip/changeset/test_assertions.go index bcfb49250d4..c83d6e3597a 100644 --- a/deployment/ccip/changeset/test_assertions.go +++ b/deployment/ccip/changeset/test_assertions.go @@ -2,6 +2,7 @@ package changeset import ( "context" + "errors" "fmt" "math/big" "sync" @@ -360,12 +361,12 @@ func ConfirmCommitWithExpectedSeqNumRange( if mr.SourceChainSelector == src.Selector && uint64(expectedSeqNumRange.Start()) >= mr.MinSeqNr && uint64(expectedSeqNumRange.End()) <= mr.MaxSeqNr { - t.Logf("All sequence numbers commited in a single report [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) + t.Logf("All sequence numbers committed in a single report [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) return event, nil } if !enforceSingleCommit && seenMessages.allCommited(src.Selector) { - t.Logf("All sequence numbers already commited from range [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) + t.Logf("All sequence numbers already committed from range [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) return event, nil } } @@ -389,12 +390,12 @@ func ConfirmCommitWithExpectedSeqNumRange( if mr.SourceChainSelector == src.Selector && uint64(expectedSeqNumRange.Start()) >= mr.MinSeqNr && uint64(expectedSeqNumRange.End()) <= mr.MaxSeqNr { - t.Logf("All sequence numbers commited in a single report [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) + t.Logf("All sequence numbers committed in a single report [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) return report, nil } if !enforceSingleCommit && seenMessages.allCommited(src.Selector) { - t.Logf("All sequence numbers already commited from range [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) + t.Logf("All sequence numbers already committed from range [%d, %d]", expectedSeqNumRange.Start(), expectedSeqNumRange.End()) return report, nil } } @@ -482,7 +483,7 @@ func ConfirmExecWithSeqNrs( expectedSeqNrs []uint64, ) (executionStates map[uint64]int, err error) { if len(expectedSeqNrs) == 0 { - return nil, fmt.Errorf("no expected sequence numbers provided") + return nil, errors.New("no expected sequence numbers provided") } timer := time.NewTimer(8 * time.Minute) diff --git a/deployment/ccip/changeset/test_environment.go b/deployment/ccip/changeset/test_environment.go index f723efbf619..a1307d9820b 100644 --- a/deployment/ccip/changeset/test_environment.go +++ b/deployment/ccip/changeset/test_environment.go @@ -2,7 +2,7 @@ package changeset import ( "context" - "fmt" + "errors" "math/big" "os" "testing" @@ -61,16 +61,16 @@ type TestConfigs struct { func (tc *TestConfigs) Validate() error { if tc.Chains < 2 { - return fmt.Errorf("chains must be at least 2") + return errors.New("chains must be at least 2") } if tc.Nodes < 4 { - return fmt.Errorf("nodes must be at least 4") + return errors.New("nodes must be at least 4") } if tc.Bootstraps < 1 { - return fmt.Errorf("bootstraps must be at least 1") + return errors.New("bootstraps must be at least 1") } if tc.Type == Memory && tc.RMNEnabled { - return fmt.Errorf("cannot run RMN tests in memory mode") + return errors.New("cannot run RMN tests in memory mode") } return nil } diff --git a/deployment/ccip/changeset/test_helpers.go b/deployment/ccip/changeset/test_helpers.go index 2069030191c..03c3ffb175d 100644 --- a/deployment/ccip/changeset/test_helpers.go +++ b/deployment/ccip/changeset/test_helpers.go @@ -582,7 +582,7 @@ func deploySingleFeed( deployFunc func(deployment.Chain) deployment.ContractDeploy[*aggregator_v3_interface.AggregatorV3Interface], symbol TokenSymbol, ) (common.Address, string, error) { - //tokenTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0) + // tokenTV := deployment.NewTypeAndVersion(PriceFeed, deployment.Version1_0_0) mockTokenFeed, err := deployment.DeployContract(lggr, chain, ab, deployFunc) if err != nil { lggr.Errorw("Failed to deploy token feed", "err", err, "symbol", symbol) @@ -736,7 +736,7 @@ func deployTokenPoolsInParallel( return nil, nil, nil, nil, err } if srcToken == nil || srcPool == nil || dstToken == nil || dstPool == nil { - return nil, nil, nil, nil, fmt.Errorf("failed to deploy token and pool") + return nil, nil, nil, nil, errors.New("failed to deploy token and pool") } return srcToken, srcPool, dstToken, dstPool, nil } @@ -763,7 +763,7 @@ func setUSDCTokenPoolCounterPart( var fixedAddr [32]byte copy(fixedAddr[:], allowedCaller[:32]) - domain, _ := reader.AllAvailableDomains()[destChainSelector] + domain := reader.AllAvailableDomains()[destChainSelector] domains := []usdc_token_pool.USDCTokenPoolDomainUpdate{ { @@ -917,7 +917,7 @@ func deployTransferTokenOneEnd( big.NewInt(0).Mul(big.NewInt(1e9), big.NewInt(1e18)), ) return deployment.ContractDeploy[*burn_mint_erc677.BurnMintERC677]{ - tokenAddress, token, tx, deployment.NewTypeAndVersion(BurnMintToken, deployment.Version1_0_0), err2, + Address: tokenAddress, Contract: token, Tx: tx, Tv: deployment.NewTypeAndVersion(BurnMintToken, deployment.Version1_0_0), Err: err2, } }) if err != nil { @@ -946,7 +946,7 @@ func deployTransferTokenOneEnd( common.HexToAddress(routerAddress), ) return deployment.ContractDeploy[*burn_mint_token_pool.BurnMintTokenPool]{ - tokenPoolAddress, tokenPoolContract, tx, deployment.NewTypeAndVersion(BurnMintTokenPool, deployment.Version1_5_1), err2, + Address: tokenPoolAddress, Contract: tokenPoolContract, Tx: tx, Tv: deployment.NewTypeAndVersion(BurnMintTokenPool, deployment.Version1_5_1), Err: err2, } }) if err != nil { diff --git a/deployment/ccip/changeset/test_usdc_helpers.go b/deployment/ccip/changeset/test_usdc_helpers.go index 55f1bd25a36..c9dd87b866e 100644 --- a/deployment/ccip/changeset/test_usdc_helpers.go +++ b/deployment/ccip/changeset/test_usdc_helpers.go @@ -115,8 +115,8 @@ func UpdateFeeQuoterForUSDC( DestChainSelector: dstChain, TokenTransferFeeConfigs: []fee_quoter.FeeQuoterTokenTransferFeeConfigSingleTokenArgs{ { - usdcToken.Address(), - fee_quoter.FeeQuoterTokenTransferFeeConfig{ + Token: usdcToken.Address(), + TokenTransferFeeConfig: fee_quoter.FeeQuoterTokenTransferFeeConfig{ MinFeeUSDCents: 50, MaxFeeUSDCents: 50_000, DeciBps: 0, diff --git a/deployment/ccip/changeset/v1_5/cs_jobspec.go b/deployment/ccip/changeset/v1_5/cs_jobspec.go index bdb36d531f8..e1cd73f1e30 100644 --- a/deployment/ccip/changeset/v1_5/cs_jobspec.go +++ b/deployment/ccip/changeset/v1_5/cs_jobspec.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment" @@ -41,14 +42,14 @@ func (j JobSpecInput) Validate() error { return fmt.Errorf("DestinationChainSelector is invalid: %w", err) } if j.TokenPricesUSDPipeline == "" && j.PriceGetterConfigJson == "" { - return fmt.Errorf("TokenPricesUSDPipeline or PriceGetterConfigJson is required") + return errors.New("TokenPricesUSDPipeline or PriceGetterConfigJson is required") } if j.USDCCfg != nil { if err := j.USDCCfg.ValidateUSDCConfig(); err != nil { return fmt.Errorf("USDCCfg is invalid: %w", err) } if j.USDCAttestationAPI == "" { - return fmt.Errorf("USDCAttestationAPI is required") + return errors.New("USDCAttestationAPI is required") } } return nil diff --git a/deployment/ccip/view/v1_0/rmn_proxy_contract.go b/deployment/ccip/view/v1_0/rmn_proxy_contract.go index 818b9fcac93..5a2ea2807f6 100644 --- a/deployment/ccip/view/v1_0/rmn_proxy_contract.go +++ b/deployment/ccip/view/v1_0/rmn_proxy_contract.go @@ -1,6 +1,7 @@ package v1_0 import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/common" @@ -16,7 +17,7 @@ type RMNProxyView struct { func GenerateRMNProxyView(r *rmn_proxy_contract.RMNProxy) (RMNProxyView, error) { if r == nil { - return RMNProxyView{}, fmt.Errorf("cannot generate view for nil RMNProxy") + return RMNProxyView{}, errors.New("cannot generate view for nil RMNProxy") } meta, err := types.NewContractMetaData(r, r.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_2/price_registry.go b/deployment/ccip/view/v1_2/price_registry.go index ee0f1067b6c..269c48fccaf 100644 --- a/deployment/ccip/view/v1_2/price_registry.go +++ b/deployment/ccip/view/v1_2/price_registry.go @@ -1,6 +1,7 @@ package v1_2 import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/common" @@ -18,7 +19,7 @@ type PriceRegistryView struct { func GeneratePriceRegistryView(pr *price_registry_1_2_0.PriceRegistry) (PriceRegistryView, error) { if pr == nil { - return PriceRegistryView{}, fmt.Errorf("cannot generate view for nil PriceRegistry") + return PriceRegistryView{}, errors.New("cannot generate view for nil PriceRegistry") } meta, err := types.NewContractMetaData(pr, pr.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_2/price_registry_test.go b/deployment/ccip/view/v1_2/price_registry_test.go index cbcdbe253ce..8248f55335b 100644 --- a/deployment/ccip/view/v1_2/price_registry_test.go +++ b/deployment/ccip/view/v1_2/price_registry_test.go @@ -29,10 +29,10 @@ func TestGeneratePriceRegistryView(t *testing.T) { v, err := GeneratePriceRegistryView(c) require.NoError(t, err) assert.Equal(t, v.Owner, chain.DeployerKey.From) - assert.Equal(t, v.TypeAndVersion, "PriceRegistry 1.2.0") - assert.Equal(t, v.FeeTokens, []common.Address{f1, f2}) - assert.Equal(t, v.StalenessThreshold, "10") - assert.Equal(t, v.Updaters, []common.Address{chain.DeployerKey.From}) + assert.Equal(t, "PriceRegistry 1.2.0", v.TypeAndVersion) + assert.Equal(t, []common.Address{f1, f2}, v.FeeTokens) + assert.Equal(t, "10", v.StalenessThreshold) + assert.Equal(t, []common.Address{chain.DeployerKey.From}, v.Updaters) _, err = json.MarshalIndent(v, "", " ") require.NoError(t, err) } diff --git a/deployment/ccip/view/v1_5/commit_store.go b/deployment/ccip/view/v1_5/commit_store.go index ffea3b61f5f..396aa8b737a 100644 --- a/deployment/ccip/view/v1_5/commit_store.go +++ b/deployment/ccip/view/v1_5/commit_store.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/common" @@ -24,7 +25,7 @@ type CommitStoreView struct { func GenerateCommitStoreView(c *commit_store.CommitStore) (CommitStoreView, error) { if c == nil { - return CommitStoreView{}, fmt.Errorf("cannot generate view for nil CommitStore") + return CommitStoreView{}, errors.New("cannot generate view for nil CommitStore") } meta, err := types.NewContractMetaData(c, c.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_5/offramp.go b/deployment/ccip/view/v1_5/offramp.go index 95e40d9da27..95d92c445e4 100644 --- a/deployment/ccip/view/v1_5/offramp.go +++ b/deployment/ccip/view/v1_5/offramp.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment/common/view/types" @@ -15,7 +16,7 @@ type OffRampView struct { func GenerateOffRampView(r *evm_2_evm_offramp.EVM2EVMOffRamp) (OffRampView, error) { if r == nil { - return OffRampView{}, fmt.Errorf("cannot generate view for nil OffRamp") + return OffRampView{}, errors.New("cannot generate view for nil OffRamp") } meta, err := types.NewContractMetaData(r, r.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_5/offramp_test.go b/deployment/ccip/view/v1_5/offramp_test.go index d6539fe2ba5..47370501424 100644 --- a/deployment/ccip/view/v1_5/offramp_test.go +++ b/deployment/ccip/view/v1_5/offramp_test.go @@ -54,7 +54,7 @@ func TestOffRampView(t *testing.T) { v, err := GenerateOffRampView(c2) require.NoError(t, err) assert.Equal(t, v.StaticConfig, sc) - assert.Equal(t, v.TypeAndVersion, "EVM2EVMOffRamp 1.5.0") + assert.Equal(t, "EVM2EVMOffRamp 1.5.0", v.TypeAndVersion) _, err = json.MarshalIndent(v, "", " ") require.NoError(t, err) } diff --git a/deployment/ccip/view/v1_5/onramp.go b/deployment/ccip/view/v1_5/onramp.go index d679f6c14c0..c211c493cbc 100644 --- a/deployment/ccip/view/v1_5/onramp.go +++ b/deployment/ccip/view/v1_5/onramp.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment/common/view/types" @@ -15,7 +16,7 @@ type OnRampView struct { func GenerateOnRampView(r *evm_2_evm_onramp.EVM2EVMOnRamp) (OnRampView, error) { if r == nil { - return OnRampView{}, fmt.Errorf("cannot generate view for nil OnRamp") + return OnRampView{}, errors.New("cannot generate view for nil OnRamp") } meta, err := types.NewContractMetaData(r, r.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_5/onramp_test.go b/deployment/ccip/view/v1_5/onramp_test.go index 4d7ef0225a6..6ce21c9f032 100644 --- a/deployment/ccip/view/v1_5/onramp_test.go +++ b/deployment/ccip/view/v1_5/onramp_test.go @@ -64,8 +64,7 @@ func TestOnRampView(t *testing.T) { // Check a few fields. assert.Equal(t, v.StaticConfig.ChainSelector, chain.Selector) assert.Equal(t, v.DynamicConfig.Router, common.HexToAddress("0x4")) - assert.Equal(t, v.TypeAndVersion, "EVM2EVMOnRamp 1.5.0") + assert.Equal(t, "EVM2EVMOnRamp 1.5.0", v.TypeAndVersion) _, err = json.MarshalIndent(v, "", " ") require.NoError(t, err) - } diff --git a/deployment/ccip/view/v1_5/rmn.go b/deployment/ccip/view/v1_5/rmn.go index cef55460446..19535cf508e 100644 --- a/deployment/ccip/view/v1_5/rmn.go +++ b/deployment/ccip/view/v1_5/rmn.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment/common/view/types" @@ -14,7 +15,7 @@ type RMNView struct { func GenerateRMNView(r *rmn_contract.RMNContract) (RMNView, error) { if r == nil { - return RMNView{}, fmt.Errorf("cannot generate view for nil RMN") + return RMNView{}, errors.New("cannot generate view for nil RMN") } meta, err := types.NewContractMetaData(r, r.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_5/rmn_test.go b/deployment/ccip/view/v1_5/rmn_test.go index 3ec7d7a9cc9..f4ea35a116f 100644 --- a/deployment/ccip/view/v1_5/rmn_test.go +++ b/deployment/ccip/view/v1_5/rmn_test.go @@ -45,8 +45,8 @@ func TestGenerateRMNView(t *testing.T) { v, err := GenerateRMNView(c) require.NoError(t, err) assert.Equal(t, v.Owner, chain.DeployerKey.From) - assert.Equal(t, v.TypeAndVersion, "RMN 1.5.0") - assert.Equal(t, v.ConfigDetails.Version, uint32(1)) + assert.Equal(t, "RMN 1.5.0", v.TypeAndVersion) + assert.Equal(t, uint32(1), v.ConfigDetails.Version) assert.Equal(t, v.ConfigDetails.Config, cfg) _, err = json.MarshalIndent(v, "", " ") require.NoError(t, err) diff --git a/deployment/ccip/view/v1_5/tokenadminregistry.go b/deployment/ccip/view/v1_5/tokenadminregistry.go index 2fd36615bcd..e4a88996247 100644 --- a/deployment/ccip/view/v1_5/tokenadminregistry.go +++ b/deployment/ccip/view/v1_5/tokenadminregistry.go @@ -1,6 +1,7 @@ package v1_5 import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/common" @@ -20,7 +21,7 @@ type TokenAdminRegistryView struct { func GenerateTokenAdminRegistryView(taContract *token_admin_registry.TokenAdminRegistry) (TokenAdminRegistryView, error) { if taContract == nil { - return TokenAdminRegistryView{}, fmt.Errorf("token admin registry contract is nil") + return TokenAdminRegistryView{}, errors.New("token admin registry contract is nil") } tokens, err := getAllConfiguredTokensPaginated(taContract) if err != nil { diff --git a/deployment/ccip/view/v1_6/ccip_home.go b/deployment/ccip/view/v1_6/ccip_home.go index b188c32c079..04b7dc8c1af 100644 --- a/deployment/ccip/view/v1_6/ccip_home.go +++ b/deployment/ccip/view/v1_6/ccip_home.go @@ -1,6 +1,7 @@ package v1_6 import ( + "errors" "fmt" "math/big" @@ -33,7 +34,7 @@ type CCIPHomeView struct { func GenerateCCIPHomeView(cr *capabilities_registry.CapabilitiesRegistry, ch *ccip_home.CCIPHome) (CCIPHomeView, error) { if ch == nil { - return CCIPHomeView{}, fmt.Errorf("cannot generate view for nil CCIPHome") + return CCIPHomeView{}, errors.New("cannot generate view for nil CCIPHome") } meta, err := types.NewContractMetaData(ch, ch.Address()) if err != nil { diff --git a/deployment/ccip/view/v1_6/ccip_home_test.go b/deployment/ccip/view/v1_6/ccip_home_test.go index 8ea79e8eac3..3d4701d705a 100644 --- a/deployment/ccip/view/v1_6/ccip_home_test.go +++ b/deployment/ccip/view/v1_6/ccip_home_test.go @@ -33,7 +33,7 @@ func TestCCIPHomeView(t *testing.T) { v, err := GenerateCCIPHomeView(cr, ch) require.NoError(t, err) - assert.Equal(t, v.TypeAndVersion, "CCIPHome 1.6.0-dev") + assert.Equal(t, "CCIPHome 1.6.0-dev", v.TypeAndVersion) _, err = json.MarshalIndent(v, "", " ") require.NoError(t, err) diff --git a/deployment/ccip/view/v1_6/rmnhome.go b/deployment/ccip/view/v1_6/rmnhome.go index 82d39074d6f..b05d15bc223 100644 --- a/deployment/ccip/view/v1_6/rmnhome.go +++ b/deployment/ccip/view/v1_6/rmnhome.go @@ -7,6 +7,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/smartcontractkit/chainlink/deployment/common/view/types" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home" ) diff --git a/deployment/common/changeset/deploy_link_token.go b/deployment/common/changeset/deploy_link_token.go index c115a7ee083..0c648939c9f 100644 --- a/deployment/common/changeset/deploy_link_token.go +++ b/deployment/common/changeset/deploy_link_token.go @@ -1,7 +1,7 @@ package changeset import ( - "fmt" + "errors" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -17,7 +17,7 @@ func DeployLinkToken(e deployment.Environment, chains []uint64) (deployment.Chan for _, chain := range chains { _, ok := e.Chains[chain] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment") + return deployment.ChangesetOutput{}, errors.New("chain not found in environment") } } newAddresses := deployment.NewMemoryAddressBook() diff --git a/deployment/common/changeset/example/add_mint_burners_link.go b/deployment/common/changeset/example/add_mint_burners_link.go index 7322f99dd60..d41734519d7 100644 --- a/deployment/common/changeset/example/add_mint_burners_link.go +++ b/deployment/common/changeset/example/add_mint_burners_link.go @@ -18,7 +18,6 @@ var _ deployment.ChangeSet[*AddMintersBurnersLinkConfig] = AddMintersBurnersLink // AddMintersBurnersLink grants the minter / burner role to the provided addresses. func AddMintersBurnersLink(e deployment.Environment, cfg *AddMintersBurnersLinkConfig) (deployment.ChangesetOutput, error) { - chain := e.Chains[cfg.ChainSelector] addresses, err := e.ExistingAddresses.AddressesForChain(cfg.ChainSelector) if err != nil { @@ -66,5 +65,4 @@ func AddMintersBurnersLink(e deployment.Environment, cfg *AddMintersBurnersLinkC } } return deployment.ChangesetOutput{}, nil - } diff --git a/deployment/common/changeset/example/link_transfer.go b/deployment/common/changeset/example/link_transfer.go index 2e3be48a4d1..6253be187c0 100644 --- a/deployment/common/changeset/example/link_transfer.go +++ b/deployment/common/changeset/example/link_transfer.go @@ -135,7 +135,6 @@ func initStatePerChain(cfg *LinkTransferConfig, e deployment.Environment) ( mcmsStatePerChain, err = changeset.MaybeLoadMCMSWithTimelockState(e, chainSelectors) if err != nil { return nil, nil, err - } return linkStatePerChain, mcmsStatePerChain, nil } @@ -160,12 +159,10 @@ func transferOrBuildTx( } } return tx, nil - } // LinkTransfer takes the given link transfers and executes them or creates an MCMS proposal for them. func LinkTransfer(e deployment.Environment, cfg *LinkTransferConfig) (deployment.ChangesetOutput, error) { - err := cfg.Validate(e) if err != nil { return deployment.ChangesetOutput{}, fmt.Errorf("invalid LinkTransferConfig: %w", err) diff --git a/deployment/common/changeset/example/link_transfer_test.go b/deployment/common/changeset/example/link_transfer_test.go index eecfbd37c95..4cc2bd0880b 100644 --- a/deployment/common/changeset/example/link_transfer_test.go +++ b/deployment/common/changeset/example/link_transfer_test.go @@ -25,7 +25,6 @@ import ( // setupLinkTransferContracts deploys all required contracts for the link transfer tests and returns the updated env. func setupLinkTransferTestEnv(t *testing.T) deployment.Environment { - lggr := logger.TestLogger(t) cfg := memory.MemoryEnvironmentConfig{ Nodes: 1, diff --git a/deployment/common/changeset/example/mint_link.go b/deployment/common/changeset/example/mint_link.go index dc50f8a1a27..8a71555928e 100644 --- a/deployment/common/changeset/example/mint_link.go +++ b/deployment/common/changeset/example/mint_link.go @@ -19,7 +19,6 @@ var _ deployment.ChangeSet[*MintLinkConfig] = MintLink // MintLink mints LINK to the provided contract. func MintLink(e deployment.Environment, cfg *MintLinkConfig) (deployment.ChangesetOutput, error) { - chain := e.Chains[cfg.ChainSelector] addresses, err := e.ExistingAddresses.AddressesForChain(cfg.ChainSelector) if err != nil { @@ -39,5 +38,4 @@ func MintLink(e deployment.Environment, cfg *MintLinkConfig) (deployment.Changes return deployment.ChangesetOutput{}, err } return deployment.ChangesetOutput{}, nil - } diff --git a/deployment/common/changeset/internal/mcms.go b/deployment/common/changeset/internal/mcms.go index baa82d77c8f..61808e1cbbd 100644 --- a/deployment/common/changeset/internal/mcms.go +++ b/deployment/common/changeset/internal/mcms.go @@ -27,7 +27,7 @@ func DeployMCMSWithConfig( chain.Client, ) return deployment.ContractDeploy[*owner_helpers.ManyChainMultiSig]{ - mcmAddr, mcm, tx, deployment.NewTypeAndVersion(contractType, deployment.Version1_0_0), err2, + Address: mcmAddr, Contract: mcm, Tx: tx, Tv: deployment.NewTypeAndVersion(contractType, deployment.Version1_0_0), Err: err2, } }) if err != nil { @@ -115,7 +115,7 @@ func DeployMCMSWithTimelockContracts( []common.Address{bypasser.Address}, // bypassers ) return deployment.ContractDeploy[*owner_helpers.RBACTimelock]{ - timelock, cc, tx2, deployment.NewTypeAndVersion(types.RBACTimelock, deployment.Version1_0_0), err2, + Address: timelock, Contract: cc, Tx: tx2, Tv: deployment.NewTypeAndVersion(types.RBACTimelock, deployment.Version1_0_0), Err: err2, } }) if err != nil { @@ -131,7 +131,7 @@ func DeployMCMSWithTimelockContracts( timelock.Address, ) return deployment.ContractDeploy[*owner_helpers.CallProxy]{ - callProxy, cc, tx2, deployment.NewTypeAndVersion(types.CallProxy, deployment.Version1_0_0), err2, + Address: callProxy, Contract: cc, Tx: tx2, Tv: deployment.NewTypeAndVersion(types.CallProxy, deployment.Version1_0_0), Err: err2, } }) if err != nil { diff --git a/deployment/common/changeset/save_existing.go b/deployment/common/changeset/save_existing.go index a5177c8e49b..57e53607cdc 100644 --- a/deployment/common/changeset/save_existing.go +++ b/deployment/common/changeset/save_existing.go @@ -30,13 +30,13 @@ func (cfg ExistingContractsConfig) Validate() error { return fmt.Errorf("invalid chain selector: %d - %w", ec.ChainSelector, err) } if ec.Address == (common.Address{}) { - return fmt.Errorf("address must be set") + return errors.New("address must be set") } if ec.TypeAndVersion.Type == "" { - return fmt.Errorf("type must be set") + return errors.New("type must be set") } if val, err := ec.TypeAndVersion.Version.Value(); err != nil || val == "" { - return fmt.Errorf("version must be set") + return errors.New("version must be set") } } return nil diff --git a/deployment/common/changeset/set_config_mcms.go b/deployment/common/changeset/set_config_mcms.go index 3ba5d2db4b6..5e2dc718b95 100644 --- a/deployment/common/changeset/set_config_mcms.go +++ b/deployment/common/changeset/set_config_mcms.go @@ -192,7 +192,6 @@ func SetConfigMCMS(e deployment.Environment, cfg MCMSConfig) (deployment.Changes batch := addTxsToProposalBatch(setConfigTxsChain, chainSelector, *state) batches = append(batches, batch) } - } if useMCMS { diff --git a/deployment/common/changeset/set_config_mcms_test.go b/deployment/common/changeset/set_config_mcms_test.go index 7220bdd755a..207b37c00f3 100644 --- a/deployment/common/changeset/set_config_mcms_test.go +++ b/deployment/common/changeset/set_config_mcms_test.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/config" chain_selectors "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" @@ -24,7 +25,6 @@ import ( // setupSetConfigTestEnv deploys all required contracts for the setConfig MCMS contract call. func setupSetConfigTestEnv(t *testing.T) deployment.Environment { - lggr := logger.TestLogger(t) cfg := memory.MemoryEnvironmentConfig{ Nodes: 1, @@ -53,7 +53,6 @@ func setupSetConfigTestEnv(t *testing.T) deployment.Environment { // TestSetConfigMCMSVariants tests the SetConfigMCMS changeset variants. func TestSetConfigMCMSVariants(t *testing.T) { - // Add the timelock as a signer to check state changes for _, tc := range []struct { name string @@ -62,7 +61,6 @@ func TestSetConfigMCMSVariants(t *testing.T) { { name: "MCMS disabled", changeSets: func(mcmsState *commonchangeset.MCMSWithTimelockState, chainSel uint64, cfgProp, cfgCancel, cfgBypass config.Config) []commonchangeset.ChangesetApplication { - return []commonchangeset.ChangesetApplication{ { Changeset: commonchangeset.WrapChangeSet(commonchangeset.SetConfigMCMS), diff --git a/deployment/common/changeset/test_helpers.go b/deployment/common/changeset/test_helpers.go index e92b36e5b55..5d524e542ad 100644 --- a/deployment/common/changeset/test_helpers.go +++ b/deployment/common/changeset/test_helpers.go @@ -5,6 +5,7 @@ import ( "testing" mapset "github.com/deckarep/golang-set/v2" + jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" diff --git a/deployment/common/changeset/transfer_to_mcms_with_timelock.go b/deployment/common/changeset/transfer_to_mcms_with_timelock.go index 45efccefd2e..ab0883cc9a7 100644 --- a/deployment/common/changeset/transfer_to_mcms_with_timelock.go +++ b/deployment/common/changeset/transfer_to_mcms_with_timelock.go @@ -36,11 +36,11 @@ func LoadOwnableContract(addr common.Address, client bind.ContractBackend) (comm // Just using the ownership interface from here. c, err := burn_mint_erc677.NewBurnMintERC677(addr, client) if err != nil { - return common.Address{}, nil, fmt.Errorf("failed to create contract: %v", err) + return common.Address{}, nil, fmt.Errorf("failed to create contract: %w", err) } owner, err := c.Owner(nil) if err != nil { - return common.Address{}, nil, fmt.Errorf("failed to get owner of contract: %v", err) + return common.Address{}, nil, fmt.Errorf("failed to get owner of contract: %w", err) } return owner, c, nil } @@ -52,13 +52,13 @@ func (t TransferToMCMSWithTimelockConfig) Validate(e deployment.Environment) err // Note this also assures non-zero addresses. if exists, err := deployment.AddressBookContains(e.ExistingAddresses, chainSelector, contract.String()); err != nil || !exists { if err != nil { - return fmt.Errorf("failed to check address book: %v", err) + return fmt.Errorf("failed to check address book: %w", err) } return fmt.Errorf("contract %s not found in address book", contract) } owner, _, err := LoadOwnableContract(contract, e.Chains[chainSelector].Client) if err != nil { - return fmt.Errorf("failed to load ownable: %v", err) + return fmt.Errorf("failed to load ownable: %w", err) } if owner != e.Chains[chainSelector].DeployerKey.From { return fmt.Errorf("contract %s is not owned by the deployer key", contract) @@ -66,10 +66,10 @@ func (t TransferToMCMSWithTimelockConfig) Validate(e deployment.Environment) err } // If there is no timelock and mcms proposer on the chain, the transfer will fail. if _, err := deployment.SearchAddressBook(e.ExistingAddresses, chainSelector, types.RBACTimelock); err != nil { - return fmt.Errorf("timelock not present on the chain %v", err) + return fmt.Errorf("timelock not present on the chain %w", err) } if _, err := deployment.SearchAddressBook(e.ExistingAddresses, chainSelector, types.ProposerManyChainMultisig); err != nil { - return fmt.Errorf("mcms proposer not present on the chain %v", err) + return fmt.Errorf("mcms proposer not present on the chain %w", err) } } @@ -101,7 +101,7 @@ func TransferToMCMSWithTimelock( timelocksByChain[chainSelector] = common.HexToAddress(timelockAddr) proposer, err := owner_helpers.NewManyChainMultiSig(common.HexToAddress(proposerAddr), e.Chains[chainSelector].Client) if err != nil { - return deployment.ChangesetOutput{}, fmt.Errorf("failed to create proposer mcms: %v", err) + return deployment.ChangesetOutput{}, fmt.Errorf("failed to create proposer mcms: %w", err) } proposersByChain[chainSelector] = proposer @@ -118,7 +118,7 @@ func TransferToMCMSWithTimelock( tx, err := c.TransferOwnership(e.Chains[chainSelector].DeployerKey, common.HexToAddress(timelockAddr)) _, err = deployment.ConfirmIfNoError(e.Chains[chainSelector], tx, err) if err != nil { - return deployment.ChangesetOutput{}, fmt.Errorf("failed to transfer ownership of contract %T: %v", contract, err) + return deployment.ChangesetOutput{}, fmt.Errorf("failed to transfer ownership of contract %T: %w", contract, err) } tx, err = c.AcceptOwnership(deployment.SimTransactOpts()) if err != nil { diff --git a/deployment/common/proposalutils/mcms_helpers.go b/deployment/common/proposalutils/mcms_helpers.go index 51a720a4389..8b7153e526b 100644 --- a/deployment/common/proposalutils/mcms_helpers.go +++ b/deployment/common/proposalutils/mcms_helpers.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" owner_helpers "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/types" @@ -76,21 +77,21 @@ type RunTimelockExecutorConfig struct { func (cfg RunTimelockExecutorConfig) Validate() error { if cfg.Executor == nil { - return fmt.Errorf("executor is nil") + return errors.New("executor is nil") } if cfg.TimelockContracts == nil { - return fmt.Errorf("timelock contracts is nil") + return errors.New("timelock contracts is nil") } if cfg.ChainSelector == 0 { - return fmt.Errorf("chain selector is 0") + return errors.New("chain selector is 0") } if cfg.BlockStart != nil && cfg.BlockEnd == nil { if *cfg.BlockStart > *cfg.BlockEnd { - return fmt.Errorf("block start is greater than block end") + return errors.New("block start is greater than block end") } } if cfg.BlockStart == nil && cfg.BlockEnd != nil { - return fmt.Errorf("block start must not be nil when block end is not nil") + return errors.New("block start must not be nil when block end is not nil") } if len(cfg.Executor.Operations[mcms.ChainIdentifier(cfg.ChainSelector)]) == 0 { diff --git a/deployment/common/proposalutils/propose.go b/deployment/common/proposalutils/propose.go index baf506cb2f8..874bbecbdb8 100644 --- a/deployment/common/proposalutils/propose.go +++ b/deployment/common/proposalutils/propose.go @@ -1,6 +1,7 @@ package proposalutils import ( + "errors" "fmt" "time" @@ -15,7 +16,6 @@ const ( DefaultValidUntil = 72 * time.Hour ) - func BuildProposalMetadata( chainSelectors []uint64, proposerMcmsesPerChain map[uint64]*gethwrappers.ManyChainMultiSig, @@ -55,7 +55,7 @@ func BuildProposalFromBatches( minDelay time.Duration, ) (*timelock.MCMSWithTimelockProposal, error) { if len(batches) == 0 { - return nil, fmt.Errorf("no operations in batch") + return nil, errors.New("no operations in batch") } chains := mapset.NewSet[uint64]() diff --git a/deployment/common/types/types.go b/deployment/common/types/types.go index 0f04421af43..c86fb3e9887 100644 --- a/deployment/common/types/types.go +++ b/deployment/common/types/types.go @@ -1,7 +1,7 @@ package types import ( - "fmt" + "errors" "math/big" "time" @@ -52,40 +52,40 @@ type OCRParameters struct { func (params OCRParameters) Validate() error { if params.DeltaProgress <= 0 { - return fmt.Errorf("deltaProgress must be positive") + return errors.New("deltaProgress must be positive") } if params.DeltaResend <= 0 { - return fmt.Errorf("deltaResend must be positive") + return errors.New("deltaResend must be positive") } if params.DeltaInitial <= 0 { - return fmt.Errorf("deltaInitial must be positive") + return errors.New("deltaInitial must be positive") } if params.DeltaRound <= 0 { - return fmt.Errorf("deltaRound must be positive") + return errors.New("deltaRound must be positive") } if params.DeltaGrace <= 0 { - return fmt.Errorf("deltaGrace must be positive") + return errors.New("deltaGrace must be positive") } if params.DeltaCertifiedCommitRequest <= 0 { - return fmt.Errorf("deltaCertifiedCommitRequest must be positive") + return errors.New("deltaCertifiedCommitRequest must be positive") } if params.DeltaStage <= 0 { - return fmt.Errorf("deltaStage must be positive") + return errors.New("deltaStage must be positive") } if params.Rmax <= 0 { - return fmt.Errorf("rmax must be positive") + return errors.New("rmax must be positive") } if params.MaxDurationQuery <= 0 { - return fmt.Errorf("maxDurationQuery must be positive") + return errors.New("maxDurationQuery must be positive") } if params.MaxDurationObservation <= 0 { - return fmt.Errorf("maxDurationObservation must be positive") + return errors.New("maxDurationObservation must be positive") } if params.MaxDurationShouldAcceptAttestedReport <= 0 { - return fmt.Errorf("maxDurationShouldAcceptAttestedReport must be positive") + return errors.New("maxDurationShouldAcceptAttestedReport must be positive") } if params.MaxDurationShouldTransmitAcceptedReport <= 0 { - return fmt.Errorf("maxDurationShouldTransmitAcceptedReport must be positive") + return errors.New("maxDurationShouldTransmitAcceptedReport must be positive") } return nil } diff --git a/deployment/common/view/nops.go b/deployment/common/view/nops.go index 61e16d59145..74f011dfe44 100644 --- a/deployment/common/view/nops.go +++ b/deployment/common/view/nops.go @@ -2,9 +2,11 @@ package view import ( "context" + "encoding/hex" "fmt" "github.com/pkg/errors" + nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" "github.com/smartcontractkit/chainlink/deployment" @@ -62,11 +64,11 @@ func GenerateNopsView(nodeIds []string, oc deployment.OffchainClient) (map[strin } for details, ocrConfig := range node.SelToOCRConfig { nop.OCRKeys[details.ChainName] = OCRKeyView{ - OffchainPublicKey: fmt.Sprintf("%x", ocrConfig.OffchainPublicKey[:]), + OffchainPublicKey: hex.EncodeToString(ocrConfig.OffchainPublicKey[:]), OnchainPublicKey: fmt.Sprintf("%x", ocrConfig.OnchainPublicKey[:]), PeerID: ocrConfig.PeerID.String(), TransmitAccount: string(ocrConfig.TransmitAccount), - ConfigEncryptionPublicKey: fmt.Sprintf("%x", ocrConfig.ConfigEncryptionPublicKey[:]), + ConfigEncryptionPublicKey: hex.EncodeToString(ocrConfig.ConfigEncryptionPublicKey[:]), KeyBundleID: ocrConfig.KeyBundleID, } } diff --git a/deployment/common/view/v1_0/capreg_test.go b/deployment/common/view/v1_0/capreg_test.go index 15fe23be00e..eb7c8a83bd4 100644 --- a/deployment/common/view/v1_0/capreg_test.go +++ b/deployment/common/view/v1_0/capreg_test.go @@ -149,7 +149,7 @@ func TestCapRegView_Denormalize(t *testing.T) { {Name: "third nop"}, }, Capabilities: []CapabilityView{ - //capabilities for don1 + // capabilities for don1 NewCapabilityView(cr.CapabilitiesRegistryCapabilityInfo{ HashedId: [32]byte{0: 1}, LabelledName: "cap1", @@ -161,7 +161,7 @@ func TestCapRegView_Denormalize(t *testing.T) { Version: "1.0.0", }), - //capabilities for don2 + // capabilities for don2 NewCapabilityView(cr.CapabilitiesRegistryCapabilityInfo{ HashedId: [32]byte{2: 2}, // matches don ID 2, capabitility ID 1 LabelledName: "other cap", diff --git a/deployment/common/view/v1_0/link_token.go b/deployment/common/view/v1_0/link_token.go index 6dd1a00be3b..2d345f1fd3c 100644 --- a/deployment/common/view/v1_0/link_token.go +++ b/deployment/common/view/v1_0/link_token.go @@ -44,8 +44,8 @@ func GenerateLinkTokenView(lt *link_token.LinkToken) (LinkTokenView, error) { return LinkTokenView{ ContractMetaData: types.ContractMetaData{ TypeAndVersion: deployment.TypeAndVersion{ - commontypes.LinkToken, - deployment.Version1_0_0, + Type: commontypes.LinkToken, + Version: deployment.Version1_0_0, }.String(), Address: lt.Address(), Owner: owner, diff --git a/deployment/common/view/v1_0/link_token_test.go b/deployment/common/view/v1_0/link_token_test.go index c83c0b3e3c2..735d7789169 100644 --- a/deployment/common/view/v1_0/link_token_test.go +++ b/deployment/common/view/v1_0/link_token_test.go @@ -26,12 +26,12 @@ func TestLinkTokenView(t *testing.T) { require.NoError(t, err) assert.Equal(t, v.Owner, chain.DeployerKey.From) - assert.Equal(t, v.TypeAndVersion, "LinkToken 1.0.0") - assert.Equal(t, v.Decimals, uint8(18)) + assert.Equal(t, "LinkToken 1.0.0", v.TypeAndVersion) + assert.Equal(t, uint8(18), v.Decimals) // Initially nothing minted and no minters/burners. - assert.Equal(t, v.Supply.String(), "0") - require.Len(t, v.Minters, 0) - require.Len(t, v.Burners, 0) + assert.Equal(t, "0", v.Supply.String()) + require.Empty(t, v.Minters) + require.Empty(t, v.Burners) // Add some minters tx, err = lt.GrantMintAndBurnRoles(chain.DeployerKey, chain.DeployerKey.From) @@ -45,7 +45,7 @@ func TestLinkTokenView(t *testing.T) { v, err = GenerateLinkTokenView(lt) require.NoError(t, err) - assert.Equal(t, v.Supply.String(), "100") + assert.Equal(t, "100", v.Supply.String()) require.Len(t, v.Minters, 1) require.Equal(t, v.Minters[0].String(), chain.DeployerKey.From.String()) require.Len(t, v.Burners, 1) diff --git a/deployment/common/view/v1_0/static_link_token.go b/deployment/common/view/v1_0/static_link_token.go index 525f1a9f0c5..2c9c60531b2 100644 --- a/deployment/common/view/v1_0/static_link_token.go +++ b/deployment/common/view/v1_0/static_link_token.go @@ -28,8 +28,8 @@ func GenerateStaticLinkTokenView(lt *link_token_interface.LinkToken) (StaticLink return StaticLinkTokenView{ ContractMetaData: types.ContractMetaData{ TypeAndVersion: deployment.TypeAndVersion{ - commontypes.StaticLinkToken, - deployment.Version1_0_0, + Type: commontypes.StaticLinkToken, + Version: deployment.Version1_0_0, }.String(), Address: lt.Address(), // No owner. diff --git a/deployment/common/view/v1_0/static_link_token_test.go b/deployment/common/view/v1_0/static_link_token_test.go index 517efac9438..b276a80fb2e 100644 --- a/deployment/common/view/v1_0/static_link_token_test.go +++ b/deployment/common/view/v1_0/static_link_token_test.go @@ -26,7 +26,7 @@ func TestStaticLinkTokenView(t *testing.T) { require.NoError(t, err) assert.Equal(t, v.Owner, common.HexToAddress("0x0")) // Ownerless - assert.Equal(t, v.TypeAndVersion, "StaticLinkToken 1.0.0") - assert.Equal(t, v.Decimals, uint8(18)) - assert.Equal(t, v.Supply.String(), "1000000000000000000000000000") + assert.Equal(t, "StaticLinkToken 1.0.0", v.TypeAndVersion) + assert.Equal(t, uint8(18), v.Decimals) + assert.Equal(t, "1000000000000000000000000000", v.Supply.String()) } diff --git a/deployment/environment.go b/deployment/environment.go index bfbeac2f0c4..6fc28fac764 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -7,6 +7,7 @@ import ( "fmt" "math/big" "sort" + "strconv" "strings" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -75,7 +76,7 @@ func (c Chain) Name() string { panic(err) } if chainInfo.ChainName == "" { - return fmt.Sprintf("%d", c.Selector) + return strconv.FormatUint(c.Selector, 10) } return chainInfo.ChainName } diff --git a/deployment/environment/crib/types.go b/deployment/environment/crib/types.go index d19c8424443..99baf8e8774 100644 --- a/deployment/environment/crib/types.go +++ b/deployment/environment/crib/types.go @@ -2,6 +2,7 @@ package crib import ( "context" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/environment/devenv" diff --git a/deployment/environment/devenv/chain.go b/deployment/environment/devenv/chain.go index 5c6c4336ed7..265a6647050 100644 --- a/deployment/environment/devenv/chain.go +++ b/deployment/environment/devenv/chain.go @@ -2,6 +2,7 @@ package devenv import ( "context" + "errors" "fmt" "math/big" "time" @@ -39,7 +40,7 @@ func (c *ChainConfig) SetUsers(pvtkeys []string) error { c.Users = []*bind.TransactOpts{c.DeployerKey} return nil } else { - return fmt.Errorf("no private keys provided for users, deployer key is also not set") + return errors.New("no private keys provided for users, deployer key is also not set") } } for _, pvtKeyStr := range pvtkeys { diff --git a/deployment/environment/devenv/don.go b/deployment/environment/devenv/don.go index 76f6ee92b68..a132fe72a2f 100644 --- a/deployment/environment/devenv/don.go +++ b/deployment/environment/devenv/don.go @@ -4,14 +4,16 @@ import ( "context" "errors" "fmt" - chainsel "github.com/smartcontractkit/chain-selectors" "strconv" "strings" "time" + chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/hashicorp/go-multierror" "github.com/rs/zerolog" "github.com/sethvargo/go-retry" + nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" clclient "github.com/smartcontractkit/chainlink/deployment/environment/nodeclient" "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/client" @@ -395,7 +397,7 @@ func (n *Node) CreateJobDistributor(ctx context.Context, jd JobDistributor) (str // create the job distributor in the node with the csa key resp, err := n.gqlClient.ListJobDistributors(ctx) if err != nil { - return "", fmt.Errorf("could not list job distrubutors: %w", err) + return "", fmt.Errorf("could not list job distributors: %w", err) } if len(resp.FeedsManagers.Results) > 0 { for _, fm := range resp.FeedsManagers.Results { diff --git a/deployment/environment/devenv/don_test.go b/deployment/environment/devenv/don_test.go index f93436f72f5..0e0578f8275 100644 --- a/deployment/environment/devenv/don_test.go +++ b/deployment/environment/devenv/don_test.go @@ -7,7 +7,6 @@ import ( ) func TestPtrVal(t *testing.T) { - x := "hello" xptr := ptr(x) got := value(xptr) diff --git a/deployment/environment/devenv/environment.go b/deployment/environment/devenv/environment.go index 121caea43bb..2fffe6adf2b 100644 --- a/deployment/environment/devenv/environment.go +++ b/deployment/environment/devenv/environment.go @@ -2,6 +2,7 @@ package devenv import ( "context" + "errors" "fmt" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -30,10 +31,10 @@ func NewEnvironment(ctx func() context.Context, lggr logger.Logger, config Envir jd, ok := offChain.(*JobDistributor) if !ok { - return nil, nil, fmt.Errorf("offchain client does not implement JobDistributor") + return nil, nil, errors.New("offchain client does not implement JobDistributor") } if jd == nil { - return nil, nil, fmt.Errorf("offchain client is not set up") + return nil, nil, errors.New("offchain client is not set up") } var nodeIDs []string if jd.don != nil { diff --git a/deployment/environment/devenv/jd.go b/deployment/environment/devenv/jd.go index 818f9b09400..844068e50da 100644 --- a/deployment/environment/devenv/jd.go +++ b/deployment/environment/devenv/jd.go @@ -2,6 +2,7 @@ package devenv import ( "context" + "errors" "fmt" "golang.org/x/oauth2" @@ -121,7 +122,7 @@ func (jd JobDistributor) GetCSAPublicKey(ctx context.Context) (string, error) { return "", err } if keypairs == nil || len(keypairs.Keypairs) == 0 { - return "", fmt.Errorf("no keypairs found") + return "", errors.New("no keypairs found") } csakey := keypairs.Keypairs[0].PublicKey return csakey, nil @@ -138,7 +139,7 @@ func (jd JobDistributor) ProposeJob(ctx context.Context, in *jobv1.ProposeJobReq return nil, fmt.Errorf("failed to propose job. err: %w", err) } if res.Proposal == nil { - return nil, fmt.Errorf("failed to propose job. err: proposal is nil") + return nil, errors.New("failed to propose job. err: proposal is nil") } if jd.don == nil || len(jd.don.Nodes) == 0 { return res, nil diff --git a/deployment/environment/memory/job_client.go b/deployment/environment/memory/job_client.go index a3cfee41608..e44c664b77e 100644 --- a/deployment/environment/memory/job_client.go +++ b/deployment/environment/memory/job_client.go @@ -29,42 +29,42 @@ type JobClient struct { } func (j JobClient) BatchProposeJob(ctx context.Context, in *jobv1.BatchProposeJobRequest, opts ...grpc.CallOption) (*jobv1.BatchProposeJobResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) UpdateJob(ctx context.Context, in *jobv1.UpdateJobRequest, opts ...grpc.CallOption) (*jobv1.UpdateJobResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) DisableNode(ctx context.Context, in *nodev1.DisableNodeRequest, opts ...grpc.CallOption) (*nodev1.DisableNodeResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) EnableNode(ctx context.Context, in *nodev1.EnableNodeRequest, opts ...grpc.CallOption) (*nodev1.EnableNodeResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) RegisterNode(ctx context.Context, in *nodev1.RegisterNodeRequest, opts ...grpc.CallOption) (*nodev1.RegisterNodeResponse, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (j JobClient) UpdateNode(ctx context.Context, in *nodev1.UpdateNodeRequest, opts ...grpc.CallOption) (*nodev1.UpdateNodeResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) GetKeypair(ctx context.Context, in *csav1.GetKeypairRequest, opts ...grpc.CallOption) (*csav1.GetKeypairResponse, error) { - //TODO implement me + // TODO implement me panic("implement me") } func (j JobClient) ListKeypairs(ctx context.Context, in *csav1.ListKeypairsRequest, opts ...grpc.CallOption) (*csav1.ListKeypairsResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } @@ -84,7 +84,7 @@ func (j JobClient) GetNode(ctx context.Context, in *nodev1.GetNodeRequest, opts } func (j JobClient) ListNodes(ctx context.Context, in *nodev1.ListNodesRequest, opts ...grpc.CallOption) (*nodev1.ListNodesResponse, error) { - //TODO CCIP-3108 + // TODO CCIP-3108 include := func(node *nodev1.Node) bool { if in.Filter == nil { return true @@ -273,22 +273,22 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode } func (j JobClient) GetJob(ctx context.Context, in *jobv1.GetJobRequest, opts ...grpc.CallOption) (*jobv1.GetJobResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) GetProposal(ctx context.Context, in *jobv1.GetProposalRequest, opts ...grpc.CallOption) (*jobv1.GetProposalResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) ListJobs(ctx context.Context, in *jobv1.ListJobsRequest, opts ...grpc.CallOption) (*jobv1.ListJobsResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) ListProposals(ctx context.Context, in *jobv1.ListProposalsRequest, opts ...grpc.CallOption) (*jobv1.ListProposalsResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } @@ -338,12 +338,12 @@ func (j JobClient) ProposeJob(ctx context.Context, in *jobv1.ProposeJobRequest, } func (j JobClient) RevokeJob(ctx context.Context, in *jobv1.RevokeJobRequest, opts ...grpc.CallOption) (*jobv1.RevokeJobResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } func (j JobClient) DeleteJob(ctx context.Context, in *jobv1.DeleteJobRequest, opts ...grpc.CallOption) (*jobv1.DeleteJobResponse, error) { - //TODO CCIP-3108 implement me + // TODO CCIP-3108 implement me panic("implement me") } diff --git a/deployment/environment/nodeclient/chainlink.go b/deployment/environment/nodeclient/chainlink.go index 9b92dd12759..9aed808d5be 100644 --- a/deployment/environment/nodeclient/chainlink.go +++ b/deployment/environment/nodeclient/chainlink.go @@ -7,6 +7,7 @@ import ( "math/big" "net/http" "os" + "strconv" "strings" "sync" "time" @@ -492,7 +493,7 @@ func (c *ChainlinkClient) DeleteP2PKey(id int) (*http.Response, error) { c.l.Info().Str(NodeURL, c.Config.URL).Int("ID", id).Msg("Deleting P2P Key") resp, err := c.APIClient.R(). SetPathParams(map[string]string{ - "id": fmt.Sprint(id), + "id": strconv.Itoa(id), }). Delete("/v2/keys/p2p/{id}") if err != nil { @@ -528,7 +529,7 @@ func (c *ChainlinkClient) UpdateEthKeyMaxGasPriceGWei(keyId string, gWei int) (* "keyId": keyId, }). SetQueryParams(map[string]string{ - "maxGasPriceGWei": fmt.Sprint(gWei), + "maxGasPriceGWei": strconv.Itoa(gWei), }). SetResult(ethKey). Put("/v2/keys/eth/{keyId}") @@ -1031,7 +1032,7 @@ func (c *ChainlinkClient) Profile(profileTime time.Duration, profileFunction fun "reportType": profileReport.Type, }). SetQueryParams(map[string]string{ - "seconds": fmt.Sprint(profileSeconds), + "seconds": strconv.Itoa(profileSeconds), }). Get("/v2/debug/pprof/{reportType}") if err != nil { @@ -1222,10 +1223,10 @@ func (c *ChainlinkClient) ReplayLogPollerFromBlock(fromBlock, evmChainID int64) resp, err := c.APIClient.R(). SetResult(&specObj). SetQueryParams(map[string]string{ - "evmChainID": fmt.Sprint(evmChainID), + "evmChainID": strconv.FormatInt(evmChainID, 10), }). SetPathParams(map[string]string{ - "fromBlock": fmt.Sprint(fromBlock), + "fromBlock": strconv.FormatInt(fromBlock, 10), }). Post("/v2/replay_from_block/{fromBlock}") if err != nil { diff --git a/deployment/environment/web/sdk/client/client.go b/deployment/environment/web/sdk/client/client.go index e0a56b9e642..331376b2e9f 100644 --- a/deployment/environment/web/sdk/client/client.go +++ b/deployment/environment/web/sdk/client/client.go @@ -3,13 +3,15 @@ package client import ( "context" "encoding/json" + "errors" "fmt" - "github.com/Khan/genqlient/graphql" - "github.com/sethvargo/go-retry" "net/http" "strings" "time" + "github.com/Khan/genqlient/graphql" + "github.com/sethvargo/go-retry" + "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/client/doer" "github.com/smartcontractkit/chainlink/deployment/environment/web/sdk/internal/generated" ) @@ -61,7 +63,7 @@ func New(baseURI string, creds Credentials) (Client, error) { endpoints: ep, credentials: creds, } - + err := retry.Do(context.Background(), retry.WithMaxDuration(10*time.Second, retry.NewFibonacci(2*time.Second)), func(ctx context.Context) error { err := c.login() if err != nil { @@ -87,7 +89,7 @@ func (c *client) FetchCSAPublicKey(ctx context.Context) (*string, error) { return nil, err } if keys == nil || len(keys.CsaKeys.GetResults()) == 0 { - return nil, fmt.Errorf("no CSA keys found") + return nil, errors.New("no CSA keys found") } return &keys.CsaKeys.GetResults()[0].PublicKey, nil } @@ -98,7 +100,7 @@ func (c *client) FetchP2PPeerID(ctx context.Context) (*string, error) { return nil, err } if keys == nil || len(keys.P2pKeys.GetResults()) == 0 { - return nil, fmt.Errorf("no P2P keys found") + return nil, errors.New("no P2P keys found") } return &keys.P2pKeys.GetResults()[0].PeerID, nil } @@ -109,7 +111,7 @@ func (c *client) FetchOCR2KeyBundleID(ctx context.Context, chainType string) (st return "", err } if keyBundles == nil || len(keyBundles.GetOcr2KeyBundles().Results) == 0 { - return "", fmt.Errorf("no ocr2 keybundle found, check if ocr2 is enabled") + return "", errors.New("no ocr2 keybundle found, check if ocr2 is enabled") } for _, keyBundle := range keyBundles.GetOcr2KeyBundles().Results { if keyBundle.ChainType == generated.OCR2ChainType(chainType) { @@ -125,7 +127,7 @@ func (c *client) FetchAccountAddress(ctx context.Context, chainID string) (*stri return nil, err } if keys == nil || len(keys.EthKeys.GetResults()) == 0 { - return nil, fmt.Errorf("no accounts found") + return nil, errors.New("no accounts found") } for _, keyDetail := range keys.EthKeys.GetResults() { if keyDetail.GetChain().Enabled && keyDetail.GetChain().Id == chainID { @@ -141,7 +143,7 @@ func (c *client) FetchKeys(ctx context.Context, chainType string) ([]string, err return nil, err } if keys == nil { - return nil, fmt.Errorf("no accounts found") + return nil, errors.New("no accounts found") } switch generated.OCR2ChainType(chainType) { case generated.OCR2ChainTypeAptos: @@ -183,12 +185,12 @@ func (c *client) GetJobDistributor(ctx context.Context, id string) (generated.Fe return generated.FeedsManagerParts{}, err } if res == nil { - return generated.FeedsManagerParts{}, fmt.Errorf("no feeds manager found") + return generated.FeedsManagerParts{}, errors.New("no feeds manager found") } if success, ok := res.GetFeedsManager().(*generated.GetFeedsManagerFeedsManager); ok { return success.FeedsManagerParts, nil } - return generated.FeedsManagerParts{}, fmt.Errorf("failed to get feeds manager") + return generated.FeedsManagerParts{}, errors.New("failed to get feeds manager") } func (c *client) ListJobDistributors(ctx context.Context) (*generated.ListFeedsManagersResponse, error) { @@ -238,12 +240,12 @@ func (c *client) CreateJobDistributorChainConfig(ctx context.Context, in JobDist return "", err } if res == nil { - return "", fmt.Errorf("failed to create feeds manager chain config") + return "", errors.New("failed to create feeds manager chain config") } if success, ok := res.GetCreateFeedsManagerChainConfig().(*generated.CreateFeedsManagerChainConfigCreateFeedsManagerChainConfigCreateFeedsManagerChainConfigSuccess); ok { return success.ChainConfig.Id, nil } - return "", fmt.Errorf("failed to create feeds manager chain config") + return "", errors.New("failed to create feeds manager chain config") } func (c *client) DeleteJobDistributorChainConfig(ctx context.Context, id string) error { @@ -252,12 +254,12 @@ func (c *client) DeleteJobDistributorChainConfig(ctx context.Context, id string) return err } if res == nil { - return fmt.Errorf("failed to delete feeds manager chain config") + return errors.New("failed to delete feeds manager chain config") } if _, ok := res.GetDeleteFeedsManagerChainConfig().(*generated.DeleteFeedsManagerChainConfigDeleteFeedsManagerChainConfigDeleteFeedsManagerChainConfigSuccess); ok { return nil } - return fmt.Errorf("failed to delete feeds manager chain config") + return errors.New("failed to delete feeds manager chain config") } func (c *client) GetJobProposal(ctx context.Context, id string) (*generated.GetJobProposalJobProposal, error) { @@ -266,12 +268,12 @@ func (c *client) GetJobProposal(ctx context.Context, id string) (*generated.GetJ return nil, err } if proposal == nil { - return nil, fmt.Errorf("no job proposal found") + return nil, errors.New("no job proposal found") } if success, ok := proposal.GetJobProposal().(*generated.GetJobProposalJobProposal); ok { return success, nil } - return nil, fmt.Errorf("failed to get job proposal") + return nil, errors.New("failed to get job proposal") } func (c *client) ApproveJobProposalSpec(ctx context.Context, id string, force bool) (*JobProposalApprovalSuccessSpec, error) { @@ -289,7 +291,7 @@ func (c *client) ApproveJobProposalSpec(ctx context.Context, id string, force bo return &cmd, nil } } - return nil, fmt.Errorf("failed to approve job proposal spec") + return nil, errors.New("failed to approve job proposal spec") } func (c *client) CancelJobProposalSpec(ctx context.Context, id string) (*generated.CancelJobProposalSpecResponse, error) { @@ -327,7 +329,7 @@ func (c *client) login() error { cookieHeader := res.Header.Get("Set-Cookie") if cookieHeader == "" { - return fmt.Errorf("no cookie found in header") + return errors.New("no cookie found in header") } c.cookie = strings.Split(cookieHeader, ";")[0] diff --git a/deployment/environment/web/sdk/client/types.go b/deployment/environment/web/sdk/client/types.go index d213ee161c6..9ecc2cc72ea 100644 --- a/deployment/environment/web/sdk/client/types.go +++ b/deployment/environment/web/sdk/client/types.go @@ -3,7 +3,7 @@ package client import ( "bytes" "encoding/json" - "fmt" + "errors" "reflect" ) @@ -47,7 +47,7 @@ type JobProposalApprovalSuccessSpec struct { func DecodeInput(in, out any) error { if reflect.TypeOf(out).Kind() != reflect.Ptr || reflect.ValueOf(out).IsNil() { - return fmt.Errorf("out type must be a non-nil pointer") + return errors.New("out type must be a non-nil pointer") } jsonBytes, err := json.Marshal(in) if err != nil { diff --git a/deployment/evm_kmsclient.go b/deployment/evm_kmsclient.go index b28a3842930..811125827af 100644 --- a/deployment/evm_kmsclient.go +++ b/deployment/evm_kmsclient.go @@ -11,6 +11,7 @@ import ( "os" "github.com/aws/aws-sdk-go/aws/session" + "github.com/pkg/errors" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/kms" @@ -59,10 +60,10 @@ type KMS struct { func NewKMSClient(config KMS) (KMSClient, error) { if config.KmsDeployerKeyId == "" { - return nil, fmt.Errorf("KMS key ID is required") + return nil, errors.New("KMS key ID is required") } if config.KmsDeployerKeyRegion == "" { - return nil, fmt.Errorf("KMS key region is required") + return nil, errors.New("KMS key region is required") } var awsSessionFn AwsSessionFn if config.AwsProfileName != "" { @@ -94,7 +95,7 @@ func (c *EVMKMSClient) GetKMSTransactOpts(ctx context.Context, chainID *big.Int) pubKeyBytes := secp256k1.S256().Marshal(ecdsaPublicKey.X, ecdsaPublicKey.Y) keyAddr := crypto.PubkeyToAddress(*ecdsaPublicKey) if chainID == nil { - return nil, fmt.Errorf("chainID is required") + return nil, errors.New("chainID is required") } signer := types.LatestSignerForChainID(chainID) @@ -195,7 +196,7 @@ func recoverEthSignature(expectedPublicKeyBytes, txHash, r, s []byte) ([]byte, e } if hex.EncodeToString(recoveredPublicKeyBytes) != hex.EncodeToString(expectedPublicKeyBytes) { - return nil, fmt.Errorf("can not reconstruct public key from sig") + return nil, errors.New("can not reconstruct public key from sig") } } @@ -238,15 +239,15 @@ func KMSConfigFromEnvVars() (KMS, error) { var exists bool config.KmsDeployerKeyId, exists = os.LookupEnv("KMS_DEPLOYER_KEY_ID") if !exists { - return config, fmt.Errorf("KMS_DEPLOYER_KEY_ID is required") + return config, errors.New("KMS_DEPLOYER_KEY_ID is required") } config.KmsDeployerKeyRegion, exists = os.LookupEnv("KMS_DEPLOYER_KEY_REGION") if !exists { - return config, fmt.Errorf("KMS_DEPLOYER_KEY_REGION is required") + return config, errors.New("KMS_DEPLOYER_KEY_REGION is required") } config.AwsProfileName, exists = os.LookupEnv("AWS_PROFILE") if !exists { - return config, fmt.Errorf("AWS_PROFILE is required") + return config, errors.New("AWS_PROFILE is required") } return config, nil } diff --git a/deployment/helpers.go b/deployment/helpers.go index 34a2584a544..d8e15d0200d 100644 --- a/deployment/helpers.go +++ b/deployment/helpers.go @@ -132,7 +132,6 @@ func DecodeErr(encodedABI string, err error) error { return fmt.Errorf("failed to decode error '%s' with abi: %w", encErr, parseErr) } return fmt.Errorf("contract error: %s", errStr) - } return fmt.Errorf("cannot decode error with abi: %w", err) } @@ -182,7 +181,7 @@ func DeployContract[C any]( func IsValidChainSelector(cs uint64) error { if cs == 0 { - return fmt.Errorf("chain selector must be set") + return errors.New("chain selector must be set") } _, err := chain_selectors.GetSelectorFamily(cs) if err != nil { diff --git a/deployment/keystone/changeset/append_node_capabilities.go b/deployment/keystone/changeset/append_node_capabilities.go index d558cf39c95..9ae1923d270 100644 --- a/deployment/keystone/changeset/append_node_capabilities.go +++ b/deployment/keystone/changeset/append_node_capabilities.go @@ -1,11 +1,13 @@ package changeset import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" @@ -30,7 +32,7 @@ func AppendNodeCapabilities(env deployment.Environment, req *AppendNodeCapabilit out := deployment.ChangesetOutput{} if req.UseMCMS() { if r.Ops == nil { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } timelocksPerChain := map[uint64]common.Address{ c.Chain.Selector: c.ContractSet.Timelock.Address(), diff --git a/deployment/keystone/changeset/append_node_capabilities_test.go b/deployment/keystone/changeset/append_node_capabilities_test.go index fb2c99ed15e..3cf6081e966 100644 --- a/deployment/keystone/changeset/append_node_capabilities_test.go +++ b/deployment/keystone/changeset/append_node_capabilities_test.go @@ -38,7 +38,7 @@ func TestAppendNodeCapabilities(t *testing.T) { }) newCapabilities := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) newCapabilities[k] = caps @@ -52,7 +52,7 @@ func TestAppendNodeCapabilities(t *testing.T) { csOut, err := changeset.AppendNodeCapabilities(te.Env, &cfg) require.NoError(t, err) - require.Len(t, csOut.Proposals, 0) + require.Empty(t, csOut.Proposals) require.Nil(t, csOut.AddressBook) validateCapabilityAppends(t, te, newCapabilities) @@ -68,7 +68,7 @@ func TestAppendNodeCapabilities(t *testing.T) { }) newCapabilities := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) newCapabilities[k] = caps @@ -105,7 +105,6 @@ func TestAppendNodeCapabilities(t *testing.T) { require.NoError(t, err) validateCapabilityAppends(t, te, newCapabilities) }) - } // validateUpdate checks reads nodes from the registry and checks they have the expected updates diff --git a/deployment/keystone/changeset/deploy_consumer.go b/deployment/keystone/changeset/deploy_consumer.go index d94d7ac0adc..5442a21576a 100644 --- a/deployment/keystone/changeset/deploy_consumer.go +++ b/deployment/keystone/changeset/deploy_consumer.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment" @@ -19,7 +20,7 @@ func DeployFeedsConsumer(env deployment.Environment, req *DeployFeedsConsumerReq lggr := env.Logger chain, ok := env.Chains[chainSelector] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment") + return deployment.ChangesetOutput{}, errors.New("chain not found in environment") } ab := deployment.NewMemoryAddressBook() deployResp, err := kslib.DeployFeedsConsumer(chain, ab) diff --git a/deployment/keystone/changeset/deploy_consumer_test.go b/deployment/keystone/changeset/deploy_consumer_test.go index 9a1e8f57da7..e73986b6ecf 100644 --- a/deployment/keystone/changeset/deploy_consumer_test.go +++ b/deployment/keystone/changeset/deploy_consumer_test.go @@ -36,5 +36,5 @@ func TestDeployFeedsConsumer(t *testing.T) { // no feeds consumer registry on chain 1 require.NotEqual(t, registrySel, env.AllChainSelectors()[1]) oaddrs, _ := resp.AddressBook.AddressesForChain(env.AllChainSelectors()[1]) - require.Len(t, oaddrs, 0) + require.Empty(t, oaddrs) } diff --git a/deployment/keystone/changeset/deploy_forwarder.go b/deployment/keystone/changeset/deploy_forwarder.go index 66923140e6a..8a9cdf4d681 100644 --- a/deployment/keystone/changeset/deploy_forwarder.go +++ b/deployment/keystone/changeset/deploy_forwarder.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "maps" "slices" @@ -8,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" @@ -59,7 +61,7 @@ type ConfigureForwardContractsRequest struct { func (r ConfigureForwardContractsRequest) Validate() error { if len(r.WFNodeIDs) == 0 { - return fmt.Errorf("WFNodeIDs must not be empty") + return errors.New("WFNodeIDs must not be empty") } return nil } @@ -96,7 +98,7 @@ func ConfigureForwardContracts(env deployment.Environment, req ConfigureForwardC var out deployment.ChangesetOutput if req.UseMCMS() { if len(r.OpsPerChain) == 0 { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } for chainSelector, op := range r.OpsPerChain { contracts := cresp.ContractSets[chainSelector] diff --git a/deployment/keystone/changeset/deploy_forwarder_test.go b/deployment/keystone/changeset/deploy_forwarder_test.go index ec80a9432b0..40ef0c02aeb 100644 --- a/deployment/keystone/changeset/deploy_forwarder_test.go +++ b/deployment/keystone/changeset/deploy_forwarder_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "go.uber.org/zap/zapcore" - "github.com/stretchr/testify/require" + "go.uber.org/zap/zapcore" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" @@ -65,7 +64,7 @@ func TestConfigureForwarders(t *testing.T) { }) var wfNodes []string - for id, _ := range te.WFNodes { + for id := range te.WFNodes { wfNodes = append(wfNodes, id) } @@ -77,7 +76,7 @@ func TestConfigureForwarders(t *testing.T) { csOut, err := changeset.ConfigureForwardContracts(te.Env, cfg) require.NoError(t, err) require.Nil(t, csOut.AddressBook) - require.Len(t, csOut.Proposals, 0) + require.Empty(t, csOut.Proposals) // check that forwarder // TODO set up a listener to check that the forwarder is configured contractSet := te.ContractSets() @@ -103,7 +102,7 @@ func TestConfigureForwarders(t *testing.T) { }) var wfNodes []string - for id, _ := range te.WFNodes { + for id := range te.WFNodes { wfNodes = append(wfNodes, id) } @@ -134,9 +133,7 @@ func TestConfigureForwarders(t *testing.T) { }, }) require.NoError(t, err) - }) } }) - } diff --git a/deployment/keystone/changeset/deploy_ocr3.go b/deployment/keystone/changeset/deploy_ocr3.go index ba5ea2921d9..75f9b75ecd1 100644 --- a/deployment/keystone/changeset/deploy_ocr3.go +++ b/deployment/keystone/changeset/deploy_ocr3.go @@ -2,6 +2,7 @@ package changeset import ( "encoding/json" + "errors" "fmt" "io" @@ -23,7 +24,7 @@ func DeployOCR3(env deployment.Environment, registryChainSel uint64) (deployment // ocr3 only deployed on registry chain c, ok := env.Chains[registryChainSel] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment") + return deployment.ChangesetOutput{}, errors.New("chain not found in environment") } ocr3Resp, err := kslib.DeployOCR3(c, ab) if err != nil { @@ -74,14 +75,14 @@ func ConfigureOCR3Contract(env deployment.Environment, cfg ConfigureOCR3Config) return deployment.ChangesetOutput{}, fmt.Errorf("failed to write response output: %w", err) } if n != len(b) { - return deployment.ChangesetOutput{}, fmt.Errorf("failed to write all bytes") + return deployment.ChangesetOutput{}, errors.New("failed to write all bytes") } } // does not create any new addresses var out deployment.ChangesetOutput if cfg.UseMCMS() { if resp.Ops == nil { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } r, err := kslib.GetContractSets(env.Logger, &kslib.GetContractSetsRequest{ Chains: env.Chains, @@ -109,7 +110,6 @@ func ConfigureOCR3Contract(env deployment.Environment, cfg ConfigureOCR3Config) return out, fmt.Errorf("failed to build proposal: %w", err) } out.Proposals = []timelock.MCMSWithTimelockProposal{*proposal} - } return out, nil } diff --git a/deployment/keystone/changeset/deploy_ocr3_test.go b/deployment/keystone/changeset/deploy_ocr3_test.go index ea984989703..5ede6c5e6c7 100644 --- a/deployment/keystone/changeset/deploy_ocr3_test.go +++ b/deployment/keystone/changeset/deploy_ocr3_test.go @@ -5,11 +5,10 @@ import ( "encoding/json" "testing" - "go.uber.org/zap/zapcore" - "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/zap/zapcore" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -43,7 +42,7 @@ func TestDeployOCR3(t *testing.T) { // nothing on chain 1 require.NotEqual(t, registrySel, env.AllChainSelectors()[1]) oaddrs, _ := resp.AddressBook.AddressesForChain(env.AllChainSelectors()[1]) - assert.Len(t, oaddrs, 0) + assert.Empty(t, oaddrs) } func TestConfigureOCR3(t *testing.T) { @@ -55,7 +54,6 @@ func TestConfigureOCR3(t *testing.T) { } t.Run("no mcms", func(t *testing.T) { - te := test.SetupTestEnv(t, test.TestConfig{ WFDonConfig: test.DonConfig{N: 4}, AssetDonConfig: test.DonConfig{N: 4}, @@ -295,5 +293,4 @@ func TestConfigureOCR3(t *testing.T) { }) require.NoError(t, err) }) - } diff --git a/deployment/keystone/changeset/deploy_registry.go b/deployment/keystone/changeset/deploy_registry.go index 2b8342c06dd..f78b6762f9e 100644 --- a/deployment/keystone/changeset/deploy_registry.go +++ b/deployment/keystone/changeset/deploy_registry.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment" @@ -13,7 +14,7 @@ func DeployCapabilityRegistry(env deployment.Environment, registrySelector uint6 lggr := env.Logger chain, ok := env.Chains[registrySelector] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment") + return deployment.ChangesetOutput{}, errors.New("chain not found in environment") } ab := deployment.NewMemoryAddressBook() capabilitiesRegistryResp, err := kslib.DeployCapabilitiesRegistry(chain, ab) diff --git a/deployment/keystone/changeset/deploy_registry_test.go b/deployment/keystone/changeset/deploy_registry_test.go index 9abf357f2a8..713ef897197 100644 --- a/deployment/keystone/changeset/deploy_registry_test.go +++ b/deployment/keystone/changeset/deploy_registry_test.go @@ -34,5 +34,5 @@ func TestDeployCapabilityRegistry(t *testing.T) { // no capabilities registry on chain 1 require.NotEqual(t, registrySel, env.AllChainSelectors()[1]) oaddrs, _ := resp.AddressBook.AddressesForChain(env.AllChainSelectors()[1]) - require.Len(t, oaddrs, 0) + require.Empty(t, oaddrs) } diff --git a/deployment/keystone/changeset/internal/append_node_capabilities.go b/deployment/keystone/changeset/internal/append_node_capabilities.go index 32fe8572da3..c6379fd24fd 100644 --- a/deployment/keystone/changeset/internal/append_node_capabilities.go +++ b/deployment/keystone/changeset/internal/append_node_capabilities.go @@ -1,6 +1,7 @@ package internal import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -20,10 +21,10 @@ type AppendNodeCapabilitiesRequest struct { func (req *AppendNodeCapabilitiesRequest) Validate() error { if len(req.P2pToCapabilities) == 0 { - return fmt.Errorf("p2pToCapabilities is empty") + return errors.New("p2pToCapabilities is empty") } if req.ContractSet.CapabilitiesRegistry == nil { - return fmt.Errorf("registry is nil") + return errors.New("registry is nil") } return nil } diff --git a/deployment/keystone/changeset/internal/capability_management.go b/deployment/keystone/changeset/internal/capability_management.go index 268b4fd0d01..d85c3f0dfff 100644 --- a/deployment/keystone/changeset/internal/capability_management.go +++ b/deployment/keystone/changeset/internal/capability_management.go @@ -6,6 +6,7 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" diff --git a/deployment/keystone/changeset/internal/contract_set.go b/deployment/keystone/changeset/internal/contract_set.go index e60f37d6f76..540ab80097b 100644 --- a/deployment/keystone/changeset/internal/contract_set.go +++ b/deployment/keystone/changeset/internal/contract_set.go @@ -108,7 +108,6 @@ func DeployFeedsConsumer(chain deployment.Chain, ab deployment.AddressBook) (*De } err = ab.Save(chain.Selector, consumerResp.Address.String(), consumerResp.Tv) if err != nil { - return nil, fmt.Errorf("failed to save FeedsConsumer: %w", err) } return consumerResp, nil diff --git a/deployment/keystone/changeset/internal/deploy.go b/deployment/keystone/changeset/internal/deploy.go index acaabd22131..b52d269518d 100644 --- a/deployment/keystone/changeset/internal/deploy.go +++ b/deployment/keystone/changeset/internal/deploy.go @@ -19,6 +19,7 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "google.golang.org/protobuf/proto" @@ -187,7 +188,7 @@ func GetRegistryContract(e *deployment.Environment, registryChainSel uint64) (*c } registry = registryChainContracts.CapabilitiesRegistry if registry == nil { - return nil, deployment.Chain{}, fmt.Errorf("no registry contract found") + return nil, deployment.Chain{}, errors.New("no registry contract found") } e.Logger.Debugf("registry contract address: %s, chain %d", registry.Address().String(), registryChainSel) return registry, registryChain, nil @@ -409,7 +410,6 @@ func ConfigureOCR3ContractFromJD(env *deployment.Environment, cfg ConfigureOCR3C OCR2OracleConfig: r.ocrConfig, Ops: r.ops, }, nil - } type RegisterCapabilitiesRequest struct { @@ -445,7 +445,7 @@ func FromCapabilitiesRegistryCapability(cap *capabilities_registry.CapabilitiesR // RegisterCapabilities add computes the capability id, adds it to the registry and associates the registered capabilities with appropriate don(s) func RegisterCapabilities(lggr logger.Logger, req RegisterCapabilitiesRequest) (*RegisterCapabilitiesResponse, error) { if len(req.DonToCapabilities) == 0 { - return nil, fmt.Errorf("no capabilities to register") + return nil, errors.New("no capabilities to register") } cresp, err := GetContractSets(req.Env.Logger, &GetContractSetsRequest{ Chains: req.Env.Chains, @@ -891,7 +891,7 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes return nil, fmt.Errorf("failed to call GetDONs: %w", err) } if !foundAll { - return nil, fmt.Errorf("did not find all desired DONS") + return nil, errors.New("did not find all desired DONS") } resp := RegisterDonsResponse{ @@ -903,7 +903,7 @@ func RegisterDons(lggr logger.Logger, req RegisterDonsRequest) (*RegisterDonsRes lggr.Debugw("irrelevant DON found in the registry, ignoring", "p2p sorted hash", sortedHash(donInfo.NodeP2PIds)) continue } - lggr.Debugw("adding don info to the reponse (keyed by DON name)", "don", donName) + lggr.Debugw("adding don info to the response (keyed by DON name)", "don", donName) resp.DonInfos[donName] = donInfos[i] } return &resp, nil diff --git a/deployment/keystone/changeset/internal/forwarder_deployer.go b/deployment/keystone/changeset/internal/forwarder_deployer.go index 2ce3ae88146..6e374e200d7 100644 --- a/deployment/keystone/changeset/internal/forwarder_deployer.go +++ b/deployment/keystone/changeset/internal/forwarder_deployer.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" diff --git a/deployment/keystone/changeset/internal/ocr3_deployer.go b/deployment/keystone/changeset/internal/ocr3_deployer.go index beafe9bb9e2..35e75b5ec43 100644 --- a/deployment/keystone/changeset/internal/ocr3_deployer.go +++ b/deployment/keystone/changeset/internal/ocr3_deployer.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" diff --git a/deployment/keystone/changeset/internal/ocr3config.go b/deployment/keystone/changeset/internal/ocr3config.go index 74f8a9dabd5..d1d2e337efb 100644 --- a/deployment/keystone/changeset/internal/ocr3config.go +++ b/deployment/keystone/changeset/internal/ocr3config.go @@ -222,7 +222,7 @@ func GenerateOCR3Config(cfg OracleConfig, nca []NodeKeys, secrets deployment.OCR for index := range nca { identities = append(identities, confighelper.OracleIdentityExtra{ OracleIdentity: confighelper.OracleIdentity{ - OnchainPublicKey: onchainPubKeys[index][:], + OnchainPublicKey: onchainPubKeys[index], OffchainPublicKey: offchainPubKeysBytes[index], PeerID: nca[index].P2PPeerID, TransmitAccount: types.Account(nca[index].EthAddress), @@ -303,7 +303,7 @@ type configureOCR3Response struct { func configureOCR3contract(req configureOCR3Request) (*configureOCR3Response, error) { if req.contract == nil { - return nil, fmt.Errorf("OCR3 contract is nil") + return nil, errors.New("OCR3 contract is nil") } ocrConfig, err := req.generateOCR3Config() if err != nil { diff --git a/deployment/keystone/changeset/internal/ocr3config_test.go b/deployment/keystone/changeset/internal/ocr3config_test.go index b412a727eb9..55769fdaece 100644 --- a/deployment/keystone/changeset/internal/ocr3config_test.go +++ b/deployment/keystone/changeset/internal/ocr3config_test.go @@ -115,7 +115,7 @@ func loadTestData(t *testing.T, path string) []deployment.Node { // in general we can map from the view to the node, but we know the test data var nodes []deployment.Node - //for _, nv := range nodeViews { + // for _, nv := range nodeViews { for _, name := range names { nv := nodeViews[name] node := deployment.Node{ diff --git a/deployment/keystone/changeset/internal/types.go b/deployment/keystone/changeset/internal/types.go index 173e3ba1ad0..cffd69f85e6 100644 --- a/deployment/keystone/changeset/internal/types.go +++ b/deployment/keystone/changeset/internal/types.go @@ -1,6 +1,7 @@ package internal import ( + "encoding/hex" "errors" "fmt" "slices" @@ -14,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" + capabilities_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" ) @@ -81,9 +82,9 @@ func toNodeKeys(o *deployment.Node, registryChainSel uint64) NodeKeys { EthAddress: string(evmCC.TransmitAccount), P2PPeerID: strings.TrimPrefix(o.PeerID.String(), "p2p_"), OCR2BundleID: evmCC.KeyBundleID, - OCR2OffchainPublicKey: fmt.Sprintf("%x", evmCC.OffchainPublicKey[:]), + OCR2OffchainPublicKey: hex.EncodeToString(evmCC.OffchainPublicKey[:]), OCR2OnchainPublicKey: fmt.Sprintf("%x", evmCC.OnchainPublicKey[:]), - OCR2ConfigPublicKey: fmt.Sprintf("%x", evmCC.ConfigEncryptionPublicKey[:]), + OCR2ConfigPublicKey: hex.EncodeToString(evmCC.ConfigEncryptionPublicKey[:]), CSAPublicKey: o.CSAKey, // default value of encryption public key is the CSA public key // TODO: DEVSVCS-760 @@ -266,7 +267,7 @@ func NewRegisteredDon(env deployment.Environment, cfg RegisteredDonConfig) (*Reg } } if don == nil { - return nil, fmt.Errorf("don not found in registry") + return nil, errors.New("don not found in registry") } return &RegisteredDon{ Name: cfg.Name, @@ -286,11 +287,10 @@ func (d RegisteredDon) Signers(chainFamily string) []common.Address { } var found bool var registryChainDetails chainsel.ChainDetails - for details, _ := range n.SelToOCRConfig { + for details := range n.SelToOCRConfig { if family, err := chainsel.GetSelectorFamily(details.ChainSelector); err == nil && family == chainFamily { found = true registryChainDetails = details - } } if !found { @@ -319,7 +319,6 @@ func joinInfoAndNodes(donInfos map[string]kcr.CapabilitiesRegistryDONInfo, dons } var out []RegisteredDon for donName, info := range donInfos { - ocr2nodes, ok := nodes[donName] if !ok { return nil, fmt.Errorf("nodes not found for don %s", donName) diff --git a/deployment/keystone/changeset/internal/types_test.go b/deployment/keystone/changeset/internal/types_test.go index cfc953d6126..e8d02f51df0 100644 --- a/deployment/keystone/changeset/internal/types_test.go +++ b/deployment/keystone/changeset/internal/types_test.go @@ -10,10 +10,11 @@ import ( "github.com/ethereum/go-ethereum/common" chainsel "github.com/smartcontractkit/chain-selectors" - "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" ) func Test_toNodeKeys(t *testing.T) { @@ -49,7 +50,7 @@ func Test_toNodeKeys(t *testing.T) { SelToOCRConfig: map[chainsel.ChainDetails]deployment.OCRConfig{ registryChainDetails: { OffchainPublicKey: types.OffchainPublicKey(common.FromHex("1111111111111111111111111111111111111111111111111111111111111111")), - OnchainPublicKey: signing_1[:], + OnchainPublicKey: signing_1, PeerID: p2pID.PeerID(), TransmitAccount: types.Account(admin_1.String()), ConfigEncryptionPublicKey: encryptionpubkey, diff --git a/deployment/keystone/changeset/internal/update_don.go b/deployment/keystone/changeset/internal/update_don.go index 3cfc386b2ba..aa3e203e5e4 100644 --- a/deployment/keystone/changeset/internal/update_don.go +++ b/deployment/keystone/changeset/internal/update_don.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "math/big" "sort" @@ -12,10 +13,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "google.golang.org/protobuf/proto" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" - "google.golang.org/protobuf/proto" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" ) @@ -56,10 +58,10 @@ func (r *UpdateDonRequest) AppendNodeCapabilitiesRequest() *AppendNodeCapabiliti func (r *UpdateDonRequest) Validate() error { if r.ContractSet.CapabilitiesRegistry == nil { - return fmt.Errorf("registry is required") + return errors.New("registry is required") } if len(r.P2PIDs) == 0 { - return fmt.Errorf("p2pIDs is required") + return errors.New("p2pIDs is required") } return nil } diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index 57b15138538..bf9ab96fecb 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -11,6 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" kscs "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" @@ -18,8 +21,6 @@ import ( kstest "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal/test" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var ( @@ -153,7 +154,6 @@ func TestUpdateDon(t *testing.T) { assert.Equal(t, want.DonInfo.ConfigCount, got.DonInfo.ConfigCount) assert.Equal(t, sortedP2Pids(want.DonInfo.NodeP2PIds), sortedP2Pids(got.DonInfo.NodeP2PIds)) assert.Equal(t, capIds(want.DonInfo.CapabilityConfigurations), capIds(got.DonInfo.CapabilityConfigurations)) - }) } @@ -234,7 +234,6 @@ func registerTestDon(t *testing.T, lggr logger.Logger, cfg setupUpdateDonTestCon t.Helper() req := newSetupTestRegistryRequest(t, cfg.dons, cfg.nops) return kstest.SetupTestRegistry(t, lggr, req) - } func newSetupTestRegistryRequest(t *testing.T, dons []internal.DonInfo, nops []internal.NOP) *kstest.SetupTestRegistryRequest { diff --git a/deployment/keystone/changeset/internal/update_node_capabilities.go b/deployment/keystone/changeset/internal/update_node_capabilities.go index 16c37267060..23e3d66965c 100644 --- a/deployment/keystone/changeset/internal/update_node_capabilities.go +++ b/deployment/keystone/changeset/internal/update_node_capabilities.go @@ -1,6 +1,7 @@ package internal import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -19,10 +20,10 @@ type UpdateNodeCapabilitiesImplRequest struct { func (req *UpdateNodeCapabilitiesImplRequest) Validate() error { if len(req.P2pToCapabilities) == 0 { - return fmt.Errorf("p2pToCapabilities is empty") + return errors.New("p2pToCapabilities is empty") } if req.ContractSet == nil { - return fmt.Errorf("registry is nil") + return errors.New("registry is nil") } return nil diff --git a/deployment/keystone/changeset/internal/update_nodes.go b/deployment/keystone/changeset/internal/update_nodes.go index b27c17ad19f..976125e582d 100644 --- a/deployment/keystone/changeset/internal/update_nodes.go +++ b/deployment/keystone/changeset/internal/update_nodes.go @@ -12,6 +12,7 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink-common/pkg/logger" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry_1_1_0" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" @@ -194,7 +195,6 @@ func AppendCapabilities(lggr logger.Logger, registry *kcr.CapabilitiesRegistry, func makeNodeParams(registry *kcr.CapabilitiesRegistry, p2pToUpdates map[p2pkey.PeerID]NodeUpdate) ([]kcr.CapabilitiesRegistryNodeParams, error) { - var out []kcr.CapabilitiesRegistryNodeParams var p2pIds []p2pkey.PeerID for p2pID := range p2pToUpdates { @@ -257,7 +257,6 @@ func makeNodeParams(registry *kcr.CapabilitiesRegistry, }) return out, nil - } // fetchCapabilityIDs fetches the capability ids for the given capabilities diff --git a/deployment/keystone/changeset/internal/update_nodes_test.go b/deployment/keystone/changeset/internal/update_nodes_test.go index 0f22120998a..1b532129e48 100644 --- a/deployment/keystone/changeset/internal/update_nodes_test.go +++ b/deployment/keystone/changeset/internal/update_nodes_test.go @@ -597,7 +597,6 @@ func TestUpdateNodes(t *testing.T) { } func TestAppendCapabilities(t *testing.T) { - var ( capMap = map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability{ testPeerID(t, "peerID_1"): []kcr.CapabilitiesRegistryCapability{ @@ -663,7 +662,6 @@ func TestAppendCapabilities(t *testing.T) { gotCaps2 := appendedResp2[testPeerID(t, "peerID_1")] require.Len(t, gotCaps2, 3) require.EqualValues(t, gotCaps, gotCaps2) - } func testPeerID(t *testing.T, s string) p2pkey.PeerID { diff --git a/deployment/keystone/changeset/update_don.go b/deployment/keystone/changeset/update_don.go index 5b381a4e498..47cb7c82507 100644 --- a/deployment/keystone/changeset/update_don.go +++ b/deployment/keystone/changeset/update_don.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment" @@ -26,10 +27,10 @@ type UpdateDonRequest struct { func (r *UpdateDonRequest) Validate() error { if len(r.P2PIDs) == 0 { - return fmt.Errorf("p2pIDs is required") + return errors.New("p2pIDs is required") } if len(r.CapabilityConfigs) == 0 { - return fmt.Errorf("capabilityConfigs is required") + return errors.New("capabilityConfigs is required") } return nil } @@ -63,10 +64,10 @@ func UpdateDon(env deployment.Environment, req *UpdateDonRequest) (deployment.Ch out := deployment.ChangesetOutput{} if req.UseMCMS() { if updateResult.Ops == nil { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } if len(appendResult.Proposals) == 0 { - return out, fmt.Errorf("expected append node capabilities to return proposals") + return out, errors.New("expected append node capabilities to return proposals") } out.Proposals = appendResult.Proposals @@ -75,10 +76,8 @@ func UpdateDon(env deployment.Environment, req *UpdateDonRequest) (deployment.Ch // this makes the proposal all-or-nothing because all the operations are in the same batch, there is only one tr // transaction and only one proposal out.Proposals[0].Transactions[0].Batch = append(out.Proposals[0].Transactions[0].Batch, updateResult.Ops.Batch...) - } return out, nil - } func appendRequest(r *UpdateDonRequest) *AppendNodeCapabilitiesRequest { diff --git a/deployment/keystone/changeset/update_don_test.go b/deployment/keystone/changeset/update_don_test.go index 2487087e235..74e2609b0a1 100644 --- a/deployment/keystone/changeset/update_don_test.go +++ b/deployment/keystone/changeset/update_don_test.go @@ -41,7 +41,7 @@ func TestUpdateDon(t *testing.T) { // we have to keep track of the existing capabilities to add to the new ones var p2pIDs []p2pkey.PeerID newCapabilities := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) p2pIDs = append(p2pIDs, k) @@ -64,7 +64,7 @@ func TestUpdateDon(t *testing.T) { csOut, err := changeset.UpdateDon(te.Env, &cfg) require.NoError(t, err) - require.Len(t, csOut.Proposals, 0) + require.Empty(t, csOut.Proposals) require.Nil(t, csOut.AddressBook) assertDonContainsCapabilities(t, te.ContractSets()[te.RegistrySelector].CapabilitiesRegistry, caps, p2pIDs) @@ -82,7 +82,7 @@ func TestUpdateDon(t *testing.T) { // contract set is already deployed with capabilities // we have to keep track of the existing capabilities to add to the new ones var p2pIDs []p2pkey.PeerID - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) p2pIDs = append(p2pIDs, k) diff --git a/deployment/keystone/changeset/update_node_capabilities.go b/deployment/keystone/changeset/update_node_capabilities.go index 8c4d01159ed..c96393328db 100644 --- a/deployment/keystone/changeset/update_node_capabilities.go +++ b/deployment/keystone/changeset/update_node_capabilities.go @@ -1,6 +1,7 @@ package changeset import ( + "errors" "fmt" "strconv" @@ -9,6 +10,7 @@ import ( "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal" @@ -61,7 +63,7 @@ type MutateNodeCapabilitiesRequest struct { func (req *MutateNodeCapabilitiesRequest) Validate() error { if len(req.P2pToCapabilities) == 0 { - return fmt.Errorf("p2pToCapabilities is empty") + return errors.New("p2pToCapabilities is empty") } _, exists := chainsel.ChainBySelector(req.RegistryChainSel) if !exists { @@ -118,7 +120,7 @@ func UpdateNodeCapabilities(env deployment.Environment, req *UpdateNodeCapabilit out := deployment.ChangesetOutput{} if req.UseMCMS() { if r.Ops == nil { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } timelocksPerChain := map[uint64]common.Address{ c.Chain.Selector: c.ContractSet.Timelock.Address(), diff --git a/deployment/keystone/changeset/update_node_capabilities_test.go b/deployment/keystone/changeset/update_node_capabilities_test.go index cf6b9601039..8962dfc389d 100644 --- a/deployment/keystone/changeset/update_node_capabilities_test.go +++ b/deployment/keystone/changeset/update_node_capabilities_test.go @@ -41,7 +41,7 @@ func TestUpdateNodeCapabilities(t *testing.T) { // we have to keep track of the existing capabilities to add to the new ones var p2pIDs []p2pkey.PeerID newCapabilities := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) p2pIDs = append(p2pIDs, k) @@ -49,7 +49,6 @@ func TestUpdateNodeCapabilities(t *testing.T) { } t.Run("fails if update drops existing capabilities", func(t *testing.T) { - cfg := changeset.UpdateNodeCapabilitiesRequest{ RegistryChainSel: te.RegistrySelector, P2pToCapabilities: newCapabilities, @@ -73,7 +72,7 @@ func TestUpdateNodeCapabilities(t *testing.T) { csOut, err := changeset.UpdateNodeCapabilities(te.Env, &cfg) require.NoError(t, err) - require.Len(t, csOut.Proposals, 0) + require.Empty(t, csOut.Proposals) require.Nil(t, csOut.AddressBook) validateCapabilityUpdates(t, te, capabiltiesToSet) @@ -92,7 +91,7 @@ func TestUpdateNodeCapabilities(t *testing.T) { // we have to keep track of the existing capabilities to add to the new ones var p2pIDs []p2pkey.PeerID newCapabilities := make(map[p2pkey.PeerID][]kcr.CapabilitiesRegistryCapability) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) p2pIDs = append(p2pIDs, k) @@ -135,9 +134,7 @@ func TestUpdateNodeCapabilities(t *testing.T) { }) require.NoError(t, err) validateCapabilityUpdates(t, te, capabiltiesToSet) - }) - } // validateUpdate checks reads nodes from the registry and checks they have the expected updates diff --git a/deployment/keystone/changeset/update_nodes.go b/deployment/keystone/changeset/update_nodes.go index 10a7ad4e441..4a98f8b06e9 100644 --- a/deployment/keystone/changeset/update_nodes.go +++ b/deployment/keystone/changeset/update_nodes.go @@ -1,12 +1,14 @@ package changeset import ( + "errors" "fmt" "time" "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" "github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" + "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/proposalutils" @@ -30,7 +32,7 @@ type UpdateNodesRequest struct { func (r *UpdateNodesRequest) Validate() error { if r.P2pToUpdates == nil { - return fmt.Errorf("P2pToUpdates must be non-nil") + return errors.New("P2pToUpdates must be non-nil") } return nil } @@ -74,7 +76,7 @@ func UpdateNodes(env deployment.Environment, req *UpdateNodesRequest) (deploymen out := deployment.ChangesetOutput{} if req.UseMCMS() { if resp.Ops == nil { - return out, fmt.Errorf("expected MCMS operation to be non-nil") + return out, errors.New("expected MCMS operation to be non-nil") } timelocksPerChain := map[uint64]common.Address{ req.RegistryChainSel: contracts.Timelock.Address(), diff --git a/deployment/keystone/changeset/update_nodes_test.go b/deployment/keystone/changeset/update_nodes_test.go index 33662aa669d..5709482ddb3 100644 --- a/deployment/keystone/changeset/update_nodes_test.go +++ b/deployment/keystone/changeset/update_nodes_test.go @@ -28,7 +28,7 @@ func TestUpdateNodes(t *testing.T) { updates := make(map[p2pkey.PeerID]changeset.NodeUpdate) i := uint8(0) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) pubKey := [32]byte{31: i + 1} @@ -48,7 +48,7 @@ func TestUpdateNodes(t *testing.T) { csOut, err := changeset.UpdateNodes(te.Env, &cfg) require.NoError(t, err) - require.Len(t, csOut.Proposals, 0) + require.Empty(t, csOut.Proposals) require.Nil(t, csOut.AddressBook) validateUpdate(t, te, updates) @@ -65,7 +65,7 @@ func TestUpdateNodes(t *testing.T) { updates := make(map[p2pkey.PeerID]changeset.NodeUpdate) i := uint8(0) - for id, _ := range te.WFNodes { + for id := range te.WFNodes { k, err := p2pkey.MakePeerID(id) require.NoError(t, err) pubKey := [32]byte{31: i + 1} @@ -111,7 +111,6 @@ func TestUpdateNodes(t *testing.T) { validateUpdate(t, te, updates) }) - } // validateUpdate checks reads nodes from the registry and checks they have the expected updates diff --git a/deployment/keystone/changeset/view.go b/deployment/keystone/changeset/view.go index 9c8678d8778..f6f495fd30b 100644 --- a/deployment/keystone/changeset/view.go +++ b/deployment/keystone/changeset/view.go @@ -37,7 +37,6 @@ func ViewKeystone(e deployment.Environment) (json.Marshaler, error) { return nil, fmt.Errorf("failed to view contract set: %w", err) } chainViews[chainName] = v - } nopsView, err := commonview.GenerateNopsView(e.NodeIDs, e.Offchain) if err != nil { diff --git a/deployment/keystone/changeset/workflowregistry/deploy.go b/deployment/keystone/changeset/workflowregistry/deploy.go index e55484aa711..bb88918594c 100644 --- a/deployment/keystone/changeset/workflowregistry/deploy.go +++ b/deployment/keystone/changeset/workflowregistry/deploy.go @@ -1,6 +1,7 @@ package workflowregistry import ( + "errors" "fmt" "github.com/smartcontractkit/chainlink/deployment" @@ -12,7 +13,7 @@ func Deploy(env deployment.Environment, registrySelector uint64) (deployment.Cha lggr := env.Logger chain, ok := env.Chains[registrySelector] if !ok { - return deployment.ChangesetOutput{}, fmt.Errorf("chain not found in environment") + return deployment.ChangesetOutput{}, errors.New("chain not found in environment") } ab := deployment.NewMemoryAddressBook() wrResp, err := deployWorkflowRegistry(chain, ab) diff --git a/deployment/keystone/changeset/workflowregistry/deploy_test.go b/deployment/keystone/changeset/workflowregistry/deploy_test.go index 16eb6fa8512..ec40646b378 100644 --- a/deployment/keystone/changeset/workflowregistry/deploy_test.go +++ b/deployment/keystone/changeset/workflowregistry/deploy_test.go @@ -34,5 +34,5 @@ func Test_Deploy(t *testing.T) { // nothing on chain 1 require.NotEqual(t, registrySel, env.AllChainSelectors()[1]) oaddrs, _ := resp.AddressBook.AddressesForChain(env.AllChainSelectors()[1]) - assert.Len(t, oaddrs, 0) + assert.Empty(t, oaddrs) } diff --git a/deployment/keystone/changeset/workflowregistry/setup_test.go b/deployment/keystone/changeset/workflowregistry/setup_test.go index 78e7d852080..ec4d448b93c 100644 --- a/deployment/keystone/changeset/workflowregistry/setup_test.go +++ b/deployment/keystone/changeset/workflowregistry/setup_test.go @@ -3,12 +3,13 @@ package workflowregistry import ( "testing" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/environment/memory" "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" workflow_registry "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/workflow/generated/workflow_registry_wrapper" - "github.com/stretchr/testify/require" ) type SetupTestWorkflowRegistryResponse struct { diff --git a/deployment/keystone/changeset/workflowregistry/update_allowed_dons_test.go b/deployment/keystone/changeset/workflowregistry/update_allowed_dons_test.go index f24db609553..aa869ce1517 100644 --- a/deployment/keystone/changeset/workflowregistry/update_allowed_dons_test.go +++ b/deployment/keystone/changeset/workflowregistry/update_allowed_dons_test.go @@ -29,7 +29,7 @@ func TestUpdateAllowedDons(t *testing.T) { dons, err := registry.GetAllAllowedDONs(&bind.CallOpts{}) require.NoError(t, err) - assert.Len(t, dons, 0) + assert.Empty(t, dons) env := deployment.Environment{ Logger: lggr, @@ -53,7 +53,7 @@ func TestUpdateAllowedDons(t *testing.T) { require.NoError(t, err) assert.Len(t, dons, 1) - assert.Equal(t, dons[0], uint32(1)) + assert.Equal(t, uint32(1), dons[0]) _, err = workflowregistry.UpdateAllowedDons( env, @@ -68,7 +68,7 @@ func TestUpdateAllowedDons(t *testing.T) { dons, err = registry.GetAllAllowedDONs(&bind.CallOpts{}) require.NoError(t, err) - assert.Len(t, dons, 0) + assert.Empty(t, dons) } func Test_UpdateAllowedDons_WithMCMS(t *testing.T) { diff --git a/deployment/keystone/changeset/workflowregistry/update_authorized_addresses_test.go b/deployment/keystone/changeset/workflowregistry/update_authorized_addresses_test.go index a8d969fce0c..ed650ed52c6 100644 --- a/deployment/keystone/changeset/workflowregistry/update_authorized_addresses_test.go +++ b/deployment/keystone/changeset/workflowregistry/update_authorized_addresses_test.go @@ -30,7 +30,7 @@ func TestUpdateAuthorizedAddresses(t *testing.T) { dons, err := registry.GetAllAuthorizedAddresses(&bind.CallOpts{}) require.NoError(t, err) - assert.Len(t, dons, 0) + assert.Empty(t, dons) env := deployment.Environment{ Logger: lggr, @@ -70,7 +70,7 @@ func TestUpdateAuthorizedAddresses(t *testing.T) { dons, err = registry.GetAllAuthorizedAddresses(&bind.CallOpts{}) require.NoError(t, err) - assert.Len(t, dons, 0) + assert.Empty(t, dons) } func Test_UpdateAuthorizedAddresses_WithMCMS(t *testing.T) { diff --git a/deployment/keystone/changeset/workflowregistry/workflow_registry_deployer.go b/deployment/keystone/changeset/workflowregistry/workflow_registry_deployer.go index ac5bbd16cc8..6ebe6693482 100644 --- a/deployment/keystone/changeset/workflowregistry/workflow_registry_deployer.go +++ b/deployment/keystone/changeset/workflowregistry/workflow_registry_deployer.go @@ -30,7 +30,6 @@ func (c *workflowRegistryDeployer) Contract() *workflow_registry.WorkflowRegistr } func (c *workflowRegistryDeployer) Deploy(req changeset.DeployRequest) (*changeset.DeployResponse, error) { - addr, tx, wr, err := workflow_registry.DeployWorkflowRegistry( req.Chain.DeployerKey, req.Chain.Client) diff --git a/deployment/multiclient_test.go b/deployment/multiclient_test.go index 2e10c46e33f..152cdbc8d0e 100644 --- a/deployment/multiclient_test.go +++ b/deployment/multiclient_test.go @@ -38,7 +38,7 @@ func TestMultiClient(t *testing.T) { require.NoError(t, err) require.NotNil(t, mc) assert.Equal(t, mc.RetryConfig.Attempts, uint(RPC_DEFAULT_RETRY_ATTEMPTS)) - assert.Equal(t, mc.RetryConfig.Delay, RPC_DEFAULT_RETRY_DELAY) + assert.Equal(t, RPC_DEFAULT_RETRY_DELAY, mc.RetryConfig.Delay) _, err = NewMultiClient(lggr, []RPC{}) require.Error(t, err) @@ -49,5 +49,5 @@ func TestMultiClient(t *testing.T) { {WSURL: s.URL}, }) require.NoError(t, err) - require.Equal(t, len(mc.Backups), 1) + require.Len(t, mc.Backups, 1) } diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml index 337555e17cb..957d11e04ff 100644 --- a/integration-tests/.golangci.yml +++ b/integration-tests/.golangci.yml @@ -8,7 +8,6 @@ linters: - errname - errorlint - exhaustive - - exportloopref - fatcontext - ginkgolinter - gocritic