diff --git a/.golangci.yaml b/.golangci.yaml index eb60b6b..207a3cf 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -11,19 +11,24 @@ linters: - contextcheck - decorder - dogsled + - dupl - dupword - durationcheck - errcheck - errchkjson - errname + - errorlint - execinquery + - exhaustive - exportloopref - forbidigo + - forcetypeassert - ginkgolinter - gocheckcompilerdirectives - gochecksumtype - gocognit - goconst + - gocritic - gocyclo - gofmt - goheader @@ -71,12 +76,12 @@ linters-settings: max-func-lines: 100 issues: exclude-rules: - - path: codec\.go + - path: x/.*/types/message.*\.go linters: - - nosnakecase - - path: app\/simulation_test\.go + - dupl + - path: x/dao/client/cli/tx_reissue_rddl.*\.go linters: - - nosnakecase - - path: testutil\/rest\.go + - dupl + - path: testutil/nullify/nullify\.go linters: - - nosnakecase + - exhaustive diff --git a/cmd/planetmint-god/cmd/root.go b/cmd/planetmint-god/cmd/root.go index 4ff20ce..6f71b42 100644 --- a/cmd/planetmint-god/cmd/root.go +++ b/cmd/planetmint-god/cmd/root.go @@ -112,7 +112,10 @@ func initRootCmd( // Set config initSDKConfig() - gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) + gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) + if !ok { + panic("forced type assertion failed for gentxModule") + } rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator), diff --git a/cmd/planetmint-god/main.go b/cmd/planetmint-god/main.go index 0cea326..eb30ea2 100644 --- a/cmd/planetmint-god/main.go +++ b/cmd/planetmint-god/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "os" "github.com/cosmos/cosmos-sdk/server" @@ -13,12 +14,10 @@ import ( func main() { rootCmd, _ := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: + var e *server.ErrorCode + if errors.As(err, &e) { os.Exit(e.Code) - - default: - os.Exit(1) } + os.Exit(1) } } diff --git a/testutil/network/network.go b/testutil/network/network.go index 45f6834..6631102 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -40,7 +40,7 @@ func New(t *testing.T, configs ...Config) *Network { } validatorTmpDir := t.TempDir() - //set the proper root dir for the test environment so that the abci.go logic works + // set the proper root dir for the test environment so that the abci.go logic works appConfig := config.GetConfig() appConfig.SetRoot(validatorTmpDir + "/node0/simd") diff --git a/util/issue_commands.go b/util/issue_commands.go index ce19655..8bbc781 100644 --- a/util/issue_commands.go +++ b/util/issue_commands.go @@ -25,7 +25,7 @@ func buildSignBroadcastTx(goCtx context.Context, sendingValidatorAddress string, func InitRDDLReissuanceProcess(goCtx context.Context, proposerAddress string, txUnsigned string, blockHeight int64) (err error) { ctx := sdk.UnwrapSDKContext(goCtx) - //get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store + // get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store logger := ctx.Logger() sendingValidatorAddress := config.GetConfig().ValidatorAddress logger.Debug("REISSUE: create Reissuance Proposal") diff --git a/x/dao/keeper/distribution.go b/x/dao/keeper/distribution.go index 2cc5cd0..285c07f 100644 --- a/x/dao/keeper/distribution.go +++ b/x/dao/keeper/distribution.go @@ -65,10 +65,10 @@ func getLastPopBytes(height int64) []byte { return big.NewInt(height + 1).Bytes() } -func ComputeDistribution(lastReissuance int64, BlockHeight int64, amount uint64) (distribution types.DistributionOrder) { +func ComputeDistribution(lastReissuance int64, blockHeight int64, amount uint64) (distribution types.DistributionOrder) { conf := config.GetConfig() distribution.FirstPop = lastReissuance - distribution.LastPop = BlockHeight + distribution.LastPop = blockHeight distribution.DaoAddr = conf.DistributionAddrDAO distribution.InvestorAddr = conf.DistributionAddrInv @@ -105,11 +105,11 @@ func (k Keeper) GetDistributionForReissuedTokens(ctx sdk.Context, blockHeight in reissuances := k.getReissuancesRange(ctx, lastPoP) var overallAmount uint64 for index, obj := range reissuances { - if (index == 0 && lastPoP == 0 && obj.BlockHeight == 0) || //corner case (beginning of he chain) + if (index == 0 && lastPoP == 0 && obj.BlockHeight == 0) || // corner case (beginning of he chain) (lastPoP < obj.BlockHeight && obj.BlockHeight <= blockHeight) { amount, err := getUint64FromTxString(ctx, obj.Rawtx) if err == nil { - overallAmount = overallAmount + amount + overallAmount += amount } } else { ctx.Logger().Info("%u %u %u", lastPoP, obj.BlockHeight, blockHeight) diff --git a/x/dao/keeper/msg_server_reissue_rddl_proposal.go b/x/dao/keeper/msg_server_reissue_rddl_proposal.go index 364de94..c0f4bad 100644 --- a/x/dao/keeper/msg_server_reissue_rddl_proposal.go +++ b/x/dao/keeper/msg_server_reissue_rddl_proposal.go @@ -21,7 +21,7 @@ func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReis if err == nil { // 3. notarize result by notarizing the liquid tx-id _ = util.SendRDDLReissuanceResult(goCtx, msg.GetProposer(), txID, msg.GetBlockHeight()) - //TODO verify and resolve error + // TODO verify and resolve error } else { logger.Error("REISSUE: Asset reissuance failure: " + err.Error()) } diff --git a/x/dao/keeper/msg_server_report_pop_result.go b/x/dao/keeper/msg_server_report_pop_result.go index f0c6fd8..8d3a3cc 100644 --- a/x/dao/keeper/msg_server_report_pop_result.go +++ b/x/dao/keeper/msg_server_report_pop_result.go @@ -32,14 +32,14 @@ func (k msgServer) ReportPopResult(goCtx context.Context, msg *types.MsgReportPo // TODO: ensuer issuePoPrewards is only called once per PoP on all validators func (k msgServer) issuePoPRewards(_ types.Challenge) (err error) { - //cfg := config.GetConfig() - //client := osc.NewClient(cfg.WatchmenEndpoint, 1234) + // cfg := config.GetConfig() + // client := osc.NewClient(cfg.WatchmenEndpoint, 1234) // TODO: finalize message and endpoint - //msg := osc.NewMessage("/rddl/token") - //msg.Append(challenge.Challenger) - //msg.Append(challenge.Challengee) - //err := client.Send(msg) + // msg := osc.NewMessage("/rddl/token") + // msg.Append(challenge.Challenger) + // msg.Append(challenge.Challengee) + // err := client.Send(msg) return err } diff --git a/x/machine/keeper/msg_server_attest_machine.go b/x/machine/keeper/msg_server_attest_machine.go index 404a9e4..f3e147e 100644 --- a/x/machine/keeper/msg_server_attest_machine.go +++ b/x/machine/keeper/msg_server_attest_machine.go @@ -46,7 +46,7 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach if k.isNFTCreationRequest(msg.Machine) && util.IsValidatorBlockProposer(ctx, ctx.BlockHeader().ProposerAddress) { _ = k.issueMachineNFT(ctx, msg.Machine) - //TODO create NFTCreationMessage to be stored by all nodes + // TODO create NFTCreationMessage to be stored by all nodes // if err != nil { // return nil, types.ErrNFTIssuanceFailed // } @@ -113,9 +113,9 @@ func (k msgServer) issueMachineNFT(ctx sdk.Context, machine *types.Machine) erro _, _, err := k.issueNFTAsset(ctx, machine.Name, machine.Address) return err // asset registration is not performed in case of NFT issuance for machines - //assetID, contract, err := k.issueNFTAsset(machine.Name, machine.Address) + // assetID, contract, err := k.issueNFTAsset(machine.Name, machine.Address) // if err != nil { // return err // } - //return k.registerAsset(assetID, contract) + // return k.registerAsset(assetID, contract) }