diff --git a/.golangci.yml b/.golangci.yml index 152422ae..23d3d5e9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,9 +49,9 @@ linters-settings: min-len: 5 goimports: local-prefixes: github.com/smartcontractkit/mcms -# govet: -# enable: -# - shadow + govet: + enable: + - shadow nlreturn: block-size: 2 revive: diff --git a/pkg/proposal/mcms/executor.go b/pkg/proposal/mcms/executor.go index 98d2379d..7aedd004 100644 --- a/pkg/proposal/mcms/executor.go +++ b/pkg/proposal/mcms/executor.go @@ -171,10 +171,11 @@ func (e *Executor) CheckQuorum(client bind.ContractBackend, chain ChainIdentifie recoveredSigners := make([]common.Address, len(e.Proposal.Signatures)) for i, sig := range e.Proposal.Signatures { - recoveredAddr, err := sig.Recover(hash) - if err != nil { - return false, err + recoveredAddr, rerr := sig.Recover(hash) + if rerr != nil { + return false, rerr } + recoveredSigners[i] = recoveredAddr } @@ -229,10 +230,11 @@ func (e *Executor) ValidateSignatures(clients map[ChainIdentifier]ContractDeploy recoveredSigners := make([]common.Address, len(e.Proposal.Signatures)) for i, sig := range e.Proposal.Signatures { - recoveredAddr, err := sig.Recover(hash) - if err != nil { - return false, err + recoveredAddr, rerr := sig.Recover(hash) + if rerr != nil { + return false, rerr } + recoveredSigners[i] = recoveredAddr } diff --git a/pkg/proposal/mcms/executor_test.go b/pkg/proposal/mcms/executor_test.go index 2282d57a..134eebb3 100644 --- a/pkg/proposal/mcms/executor_test.go +++ b/pkg/proposal/mcms/executor_test.go @@ -300,12 +300,12 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerSingleTX_Success(t *testin // Sign the hash for i := range 3 { - sig, err := crypto.Sign(hash.Bytes(), keys[i]) - require.NoError(t, err) + sig, serr := crypto.Sign(hash.Bytes(), keys[i]) + require.NoError(t, serr) // Construct a signature - sigObj, err := NewSignatureFromBytes(sig) - require.NoError(t, err) + sigObj, serr := NewSignatureFromBytes(sig) + require.NoError(t, serr) proposal.Signatures = append(proposal.Signatures, sigObj) } @@ -392,8 +392,8 @@ func TestExecutor_ExecuteE2E_SingleChainSingleSignerMultipleTX_Success(t *testin operations := make([]ChainOperation, 4) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole, executorRole} { - data, err := timelockAbi.Pack("grantRole", role, mcms.Address()) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, mcms.Address()) + require.NoError(t, perr) operations[i] = ChainOperation{ ChainIdentifier: TestChain1, Operation: Operation{ @@ -466,8 +466,8 @@ func TestExecutor_ExecuteE2E_SingleChainSingleSignerMultipleTX_Success(t *testin sim.Commit() // Wait for the transaction to be mined - receipt, err := bind.WaitMined(auths[0].Context, sim, tx) - require.NoError(t, err) + receipt, merr := bind.WaitMined(auths[0].Context, sim, tx) + require.NoError(t, merr) assert.NotNil(t, receipt) assert.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) } @@ -530,8 +530,8 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_Success(t *test operations := make([]ChainOperation, 4) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole, executorRole} { - data, err := timelockAbi.Pack("grantRole", role, mcms.Address()) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, mcms.Address()) + require.NoError(t, perr) operations[i] = ChainOperation{ ChainIdentifier: TestChain1, Operation: Operation{ @@ -571,12 +571,12 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_Success(t *test // Sign the hash for i := range 3 { - sig, err := crypto.Sign(hash.Bytes(), keys[i]) - require.NoError(t, err) + sig, serr := crypto.Sign(hash.Bytes(), keys[i]) + require.NoError(t, serr) // Construct a signature - sigObj, err := NewSignatureFromBytes(sig) - require.NoError(t, err) + sigObj, serr := NewSignatureFromBytes(sig) + require.NoError(t, serr) proposal.Signatures = append(proposal.Signatures, sigObj) } @@ -606,8 +606,8 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_Success(t *test sim.Commit() // Wait for the transaction to be mined - receipt, err := bind.WaitMined(auths[0].Context, sim, tx) - require.NoError(t, err) + receipt, merr := bind.WaitMined(auths[0].Context, sim, tx) + require.NoError(t, merr) assert.NotNil(t, receipt) assert.Equal(t, types.ReceiptStatusSuccessful, receipt.Status) } @@ -670,8 +670,8 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_FailureMissingQ operations := make([]ChainOperation, 4) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole, executorRole} { - data, err := timelockAbi.Pack("grantRole", role, mcms.Address()) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, mcms.Address()) + require.NoError(t, perr) operations[i] = ChainOperation{ ChainIdentifier: TestChain1, Operation: Operation{ @@ -711,12 +711,12 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_FailureMissingQ // Sign the hash for i := range 2 { - sig, err := crypto.Sign(hash.Bytes(), keys[i]) - require.NoError(t, err) + sig, serr := crypto.Sign(hash.Bytes(), keys[i]) + require.NoError(t, serr) // Construct a signature - sigObj, err := NewSignatureFromBytes(sig) - require.NoError(t, err) + sigObj, serr := NewSignatureFromBytes(sig) + require.NoError(t, serr) proposal.Signatures = append(proposal.Signatures, sigObj) } @@ -774,8 +774,8 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_FailureInvalidS operations := make([]ChainOperation, 4) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole, executorRole} { - data, err := timelockAbi.Pack("grantRole", role, mcms.Address()) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, mcms.Address()) + require.NoError(t, perr) operations[i] = ChainOperation{ ChainIdentifier: TestChain1, Operation: Operation{ @@ -815,12 +815,12 @@ func TestExecutor_ExecuteE2E_SingleChainMultipleSignerMultipleTX_FailureInvalidS // Sign the hash for i := range 3 { - sig, err := crypto.Sign(hash.Bytes(), keys[i]) - require.NoError(t, err) + sig, serr := crypto.Sign(hash.Bytes(), keys[i]) + require.NoError(t, serr) // Construct a signature - sigObj, err := NewSignatureFromBytes(sig) - require.NoError(t, err) + sigObj, serr := NewSignatureFromBytes(sig) + require.NoError(t, serr) proposal.Signatures = append(proposal.Signatures, sigObj) } diff --git a/pkg/proposal/timelock/mcm_with_timelock_test.go b/pkg/proposal/timelock/mcm_with_timelock_test.go index 42b1f31a..f642fcaa 100644 --- a/pkg/proposal/timelock/mcm_with_timelock_test.go +++ b/pkg/proposal/timelock/mcm_with_timelock_test.go @@ -478,8 +478,8 @@ func TestE2E_ValidScheduleAndExecuteProposalOneTx(t *testing.T) { // Check all the logs var operationId common.Hash for _, log := range receipt.Logs { - event, err := timelock.ParseCallScheduled(*log) - if err == nil { + event, perr := timelock.ParseCallScheduled(*log) + if perr == nil { operationId = event.Id } } @@ -649,8 +649,8 @@ func TestE2E_ValidScheduleAndCancelProposalOneTx(t *testing.T) { // Check all the logs var operationId common.Hash for _, log := range receipt.Logs { - event, err := timelock.ParseCallScheduled(*log) - if err == nil { + event, perr := timelock.ParseCallScheduled(*log) + if perr == nil { operationId = event.Id } } @@ -872,8 +872,8 @@ func TestE2E_ValidScheduleAndExecuteProposalOneBatchTx(t *testing.T) { operations := make([]mcms.Operation, 3) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole} { - data, err := timelockAbi.Pack("grantRole", role, auths[0].From) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, auths[0].From) + require.NoError(t, perr) operations[i] = mcms.Operation{ To: timelock.Address(), Value: big.NewInt(0), @@ -973,8 +973,8 @@ func TestE2E_ValidScheduleAndExecuteProposalOneBatchTx(t *testing.T) { // Check all the logs var operationId common.Hash for _, log := range receipt.Logs { - event, err := timelock.ParseCallScheduled(*log) - if err == nil { + event, perr := timelock.ParseCallScheduled(*log) + if perr == nil { operationId = event.Id } } @@ -1072,8 +1072,8 @@ func TestE2E_ValidScheduleAndCancelProposalOneBatchTx(t *testing.T) { operations := make([]mcms.Operation, 3) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole} { - data, err := timelockAbi.Pack("grantRole", role, auths[0].From) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, auths[0].From) + require.NoError(t, perr) operations[i] = mcms.Operation{ To: timelock.Address(), Value: big.NewInt(0), @@ -1173,8 +1173,8 @@ func TestE2E_ValidScheduleAndCancelProposalOneBatchTx(t *testing.T) { // Check all the logs var operationId common.Hash for _, log := range receipt.Logs { - event, err := timelock.ParseCallScheduled(*log) - if err == nil { + event, perr := timelock.ParseCallScheduled(*log) + if perr == nil { operationId = event.Id } } @@ -1284,8 +1284,8 @@ func TestE2E_ValidBypassProposalOneBatchTx(t *testing.T) { operations := make([]mcms.Operation, 3) for i, role := range []common.Hash{proposerRole, bypasserRole, cancellerRole} { - data, err := timelockAbi.Pack("grantRole", role, auths[0].From) - require.NoError(t, err) + data, perr := timelockAbi.Pack("grantRole", role, auths[0].From) + require.NoError(t, perr) operations[i] = mcms.Operation{ To: timelock.Address(), Value: big.NewInt(0),