diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7c13f4aa1..8e86c26e6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,10 +13,9 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - # Required: setup-go, for all versions v3.0.0+ of golangci-lint - uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: '1.24' check-latest: true - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v6.1.2 @@ -26,14 +25,11 @@ jobs: go.mod go.sum *.toml - - uses: golangci/golangci-lint-action@v6.2.0 - with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: latest - args: --timeout 10m - github-token: ${{ secrets.github_token }} - # Check only if there are differences in the source code + - name: run linting if: env.GIT_DIFF + id: lint_long + run: | + make lint-go markdown-lint: name: Run markdown-lint runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml index d4a987bb9..64edf8d2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,20 +1,15 @@ +version: "2" run: tests: true - # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 5m - linters: - disable-all: true + default: none enable: + - copyloopvar - dogsled - errcheck - - copyloopvar - - gci - goconst - gocritic - - gofumpt - gosec - - gosimple - govet - ineffassign - misspell @@ -22,91 +17,101 @@ linters: - nolintlint - revive - staticcheck - - stylecheck - - typecheck - thelper - unconvert - unparam - unused - + settings: + dogsled: + max-blank-identifiers: 3 + nolintlint: + require-explanation: false + require-specific: false + allow-unused: false + revive: + severity: warning + rules: + - name: unused-parameter + disabled: true + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unreachable-code + - name: redefines-builtin-id + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - gosec + text: Use of weak random number generator + - linters: + - golint + text: comment on exported var + - linters: + - golint + text: don't use an underscore in package name + - linters: + - staticcheck + text: 'ST1003:' + - linters: + - staticcheck + text: 'ST1016:' + - linters: + - staticcheck + path: migrations + text: 'SA1019:' + paths: + - x/vm/core + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - text: 'Use of weak random number generator' - linters: - - gosec - - text: 'comment on exported var' - linters: - - golint - - text: "don't use an underscore in package name" - linters: - - golint - - text: 'ST1003:' - linters: - - stylecheck - # FIXME: Disabled until golangci-lint updates stylecheck with this fix: - # https://github.com/dominikh/go-tools/issues/389 - - text: 'ST1016:' - linters: - - stylecheck - - path: 'migrations' - text: 'SA1019:' - linters: - - staticcheck - exclude-dirs: - - x/vm/core - max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - gci: - custom-order: true - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - blank # blank imports - - dot # dot imports - - prefix(github.com/cometbft/cometbft) # comet - - prefix(github.com/cosmos) # cosmos org - - prefix(cosmossdk.io) # new modules - - prefix(github.com/cosmos/cosmos-sdk) # cosmos sdk - - prefix(github.com/CosmWasm/wasmd) # cosmwasm - - prefix(github.com/cosmos/gaia) # Gaia - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - nolintlint: - allow-unused: false - allow-leading-space: true - require-explanation: false - require-specific: false - revive: - ignore-generated-header: true - severity: warning - rules: - - name: unused-parameter - disabled: true - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: exported - - name: if-return - - name: increment-decrement - - name: var-naming - - name: var-declaration - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: empty-block - - name: superfluous-else - - name: unreachable-code - - name: redefines-builtin-id +formatters: + enable: + - gci + - gofumpt + settings: + gci: + sections: + - standard + - default + - blank + - dot + - prefix(github.com/cometbft/cometbft) + - prefix(github.com/cosmos) + - prefix(cosmossdk.io) + - prefix(github.com/cosmos/cosmos-sdk) + - prefix(github.com/CosmWasm/wasmd) + - prefix(github.com/cosmos/gaia) + custom-order: true + exclusions: + generated: lax + paths: + - x/vm/core + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index b6a460918..d0ab00236 100644 --- a/Makefile +++ b/Makefile @@ -167,13 +167,13 @@ benchmark: ### Linting ### ############################################################################### golangci_lint_cmd=golangci-lint -golangci_version=v1.64.8 +golangci_version=v2.1.6 lint: lint-go lint-python lint-contracts lint-go: @echo "--> Running linter" - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(golangci_version) @$(golangci_lint_cmd) run --timeout=10m lint-python: @@ -184,7 +184,7 @@ lint-contracts: solhint contracts/**/*.sol lint-fix: - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(golangci_version) @$(golangci_lint_cmd) run --timeout=10m --fix lint-fix-contracts: diff --git a/ethereum/eip712/eip712_test.go b/ethereum/eip712/eip712_test.go index 77627678f..5f09fa3ca 100644 --- a/ethereum/eip712/eip712_test.go +++ b/ethereum/eip712/eip712_test.go @@ -542,7 +542,7 @@ func (suite *EIP712TestSuite) TestTypedDataErrorHandling() { messagesArr.WriteString("[") for i := 0; i < maxRecursionDepth; i++ { - messagesArr.WriteString(fmt.Sprintf(`{ "type": "msgType", "value": { "field%v": 10 } }`, i)) + fmt.Fprintf(messagesArr, `{ "type": "msgType", "value": { "field%v": 10 } }`, i) if i != maxRecursionDepth-1 { messagesArr.WriteString(",") } diff --git a/evmd/app.go b/evmd/app.go index ba72b9728..4c19f8ddf 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -998,14 +998,14 @@ func (app *EVMD) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfi // RegisterTxService implements the Application.RegisterTxService method. func (app *EVMD) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService(app.GRPCQueryRouter(), clientCtx, app.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *EVMD) RegisterTendermintService(clientCtx client.Context) { cmtservice.RegisterTendermintService( clientCtx, - app.BaseApp.GRPCQueryRouter(), + app.GRPCQueryRouter(), app.interfaceRegistry, app.Query, ) diff --git a/evmd/export.go b/evmd/export.go index 7e695c59c..3352bf5cc 100644 --- a/evmd/export.go +++ b/evmd/export.go @@ -47,7 +47,7 @@ func (app *EVMD) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddr AppState: appState, Validators: validators, Height: height, - ConsensusParams: app.BaseApp.GetConsensusParams(ctx), + ConsensusParams: app.GetConsensusParams(ctx), }, err } @@ -56,15 +56,10 @@ func (app *EVMD) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddr // // in favour of export at a block height func (app *EVMD) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) error { - applyAllowedAddrs := false - - // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } + applyAllowedAddrs := len(jailAllowedAddrs) > 0 + // check if there is an allowed address list allowedAddrsMap := make(map[string]bool) - for _, addr := range jailAllowedAddrs { _, err := sdk.ValAddressFromBech32(addr) if err != nil { diff --git a/evmd/testutil/abci.go b/evmd/testutil/abci.go index 66e1ced6a..0b9a918a8 100644 --- a/evmd/testutil/abci.go +++ b/evmd/testutil/abci.go @@ -46,7 +46,7 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.EVMD, t time.Duration, vs * // NewContext function keeps the multistore // but resets other context fields // GasMeter is set as InfiniteGasMeter - newCtx := app.BaseApp.NewContextLegacy(false, header) + newCtx := app.NewContextLegacy(false, header) // set the reseted fields to keep the current ctx settings newCtx = newCtx.WithMinGasPrices(ctx.MinGasPrices()) newCtx = newCtx.WithEventManager(ctx.EventManager()) @@ -248,7 +248,7 @@ func checkTxBytes(app *app.EVMD, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.Respo } req := abci.RequestCheckTx{Tx: bz} - res, err := app.BaseApp.CheckTx(&req) + res, err := app.CheckTx(&req) if err != nil { return abci.ResponseCheckTx{}, err } diff --git a/indexer/kv_indexer.go b/indexer/kv_indexer.go index 35bf8c0ed..79e2159be 100644 --- a/indexer/kv_indexer.go +++ b/indexer/kv_indexer.go @@ -50,7 +50,7 @@ func NewKVIndexer(db dbm.DB, logger log.Logger, clientCtx client.Context) *KVInd // - Iterates over all the messages of the Tx // - Builds and stores a indexer.TxResult based on parsed events for every message func (kv *KVIndexer) IndexBlock(block *cmttypes.Block, txResults []*abci.ExecTxResult) error { - height := block.Header.Height + height := block.Height batch := kv.db.NewBatch() defer batch.Close() diff --git a/indexer/kv_indexer_test.go b/indexer/kv_indexer_test.go index 2e94456fe..03f535a91 100644 --- a/indexer/kv_indexer_test.go +++ b/indexer/kv_indexer_test.go @@ -174,11 +174,11 @@ func TestKVIndexer(t *testing.T) { } else { first, err := idxer.FirstIndexedBlock() require.NoError(t, err) - require.Equal(t, tc.block.Header.Height, first) + require.Equal(t, tc.block.Height, first) last, err := idxer.LastIndexedBlock() require.NoError(t, err) - require.Equal(t, tc.block.Header.Height, last) + require.Equal(t, tc.block.Height, last) res1, err := idxer.GetByTxHash(txHash) require.NoError(t, err) diff --git a/precompiles/distribution/events.go b/precompiles/distribution/events.go index 221a37516..18fdb06fb 100644 --- a/precompiles/distribution/events.go +++ b/precompiles/distribution/events.go @@ -71,7 +71,7 @@ func (p Precompile) EmitClaimRewardsEvent(ctx sdk.Context, stateDB vm.StateDB, d // EmitSetWithdrawAddressEvent creates a new event emitted on a SetWithdrawAddressMethod transaction. func (p Precompile) EmitSetWithdrawAddressEvent(ctx sdk.Context, stateDB vm.StateDB, caller common.Address, withdrawerAddress string) error { // Prepare the event topics - event := p.ABI.Events[EventTypeSetWithdrawAddress] + event := p.Events[EventTypeSetWithdrawAddress] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -108,7 +108,7 @@ func (p Precompile) EmitWithdrawDelegatorRewardEvent(ctx sdk.Context, stateDB vm } // Prepare the event topics - event := p.ABI.Events[EventTypeWithdrawDelegatorReward] + event := p.Events[EventTypeWithdrawDelegatorReward] topics := make([]common.Hash, 3) // The first topic is always the signature of the event. @@ -141,7 +141,7 @@ func (p Precompile) EmitWithdrawDelegatorRewardEvent(ctx sdk.Context, stateDB vm // EmitWithdrawValidatorCommissionEvent creates a new event emitted on a WithdrawValidatorCommission transaction. func (p Precompile) EmitWithdrawValidatorCommissionEvent(ctx sdk.Context, stateDB vm.StateDB, validatorAddress string, coins sdk.Coins) error { // Prepare the event topics - event := p.ABI.Events[EventTypeWithdrawValidatorCommission] + event := p.Events[EventTypeWithdrawValidatorCommission] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -170,7 +170,7 @@ func (p Precompile) EmitWithdrawValidatorCommissionEvent(ctx sdk.Context, stateD // EmitFundCommunityPoolEvent creates a new event emitted per Coin on a FundCommunityPool transaction. func (p Precompile) EmitFundCommunityPoolEvent(ctx sdk.Context, stateDB vm.StateDB, depositor common.Address, coins sdk.Coins) error { // Prepare the event topics - event := p.ABI.Events[EventTypeFundCommunityPool] + event := p.Events[EventTypeFundCommunityPool] for _, coin := range coins { topics := make([]common.Hash, 2) @@ -212,7 +212,7 @@ func (p Precompile) EmitDepositValidatorRewardsPoolEvent(ctx sdk.Context, stateD } // Prepare the event topics - event := p.ABI.Events[EventTypeDepositValidatorRewardsPool] + event := p.Events[EventTypeDepositValidatorRewardsPool] for _, coin := range coins { topics := make([]common.Hash, 3) diff --git a/precompiles/distribution/events_test.go b/precompiles/distribution/events_test.go index a9c5b012e..87a52a9da 100644 --- a/precompiles/distribution/events_test.go +++ b/precompiles/distribution/events_test.go @@ -50,7 +50,7 @@ func (s *PrecompileTestSuite) TestSetWithdrawAddressEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeSetWithdrawAddress] + event := s.precompile.Events[distribution.EventTypeSetWithdrawAddress] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -124,7 +124,7 @@ func (s *PrecompileTestSuite) TestWithdrawDelegatorRewardEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeWithdrawDelegatorReward] + event := s.precompile.Events[distribution.EventTypeWithdrawDelegatorReward] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -206,7 +206,7 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommissionEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeWithdrawValidatorCommission] + event := s.precompile.Events[distribution.EventTypeWithdrawValidatorCommission] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -265,7 +265,7 @@ func (s *PrecompileTestSuite) TestClaimRewardsEvent() { log := stDB.Logs()[0] s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeClaimRewards] + event := s.precompile.Events[distribution.EventTypeClaimRewards] s.Require().Equal(event.ID, common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -307,7 +307,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPoolEvent() { log := stDB.Logs()[0] s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeFundCommunityPool] + event := s.precompile.Events[distribution.EventTypeFundCommunityPool] s.Require().Equal(event.ID, common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -345,7 +345,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPoolEvent() { s.Require().Equal(log.Address, s.precompile.Address(), "log address must match the precompile address") // Check event signature - event := s.precompile.ABI.Events[distribution.EventTypeFundCommunityPool] + event := s.precompile.Events[distribution.EventTypeFundCommunityPool] s.Require().Equal(event.ID, common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(uint64(ctx.BlockHeight()), log.BlockNumber) //nolint:gosec // G115 @@ -415,7 +415,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolEvent() { s.Require().NoError(err) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeDepositValidatorRewardsPool] + event := s.precompile.Events[distribution.EventTypeDepositValidatorRewardsPool] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -466,7 +466,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolEvent() { s.Require().NoError(err) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[distribution.EventTypeDepositValidatorRewardsPool] + event := s.precompile.Events[distribution.EventTypeDepositValidatorRewardsPool] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 diff --git a/precompiles/distribution/integration_test.go b/precompiles/distribution/integration_test.go index db04415d2..6378a5da7 100644 --- a/precompiles/distribution/integration_test.go +++ b/precompiles/distribution/integration_test.go @@ -1355,7 +1355,7 @@ var _ = Describe("Calling distribution precompile from contract", Ordered, func( // make a delegation with contract as delegator logCheck := testutil.LogCheckArgs{ ExpPass: true, - ABIEvents: stkPrecompile.ABI.Events, + ABIEvents: stkPrecompile.Events, ExpEvents: []string{staking.EventTypeDelegate}, } delegateAmt := big.NewInt(1e18) @@ -1873,7 +1873,7 @@ var _ = Describe("Calling distribution precompile from contract", Ordered, func( // make a delegation with contract as delegator logCheck := testutil.LogCheckArgs{ ExpPass: true, - ABIEvents: stkPrecompile.ABI.Events, + ABIEvents: stkPrecompile.Events, ExpEvents: []string{staking.EventTypeDelegate}, } _, _, err = s.factory.CallContractAndCheckLogs( @@ -2060,7 +2060,7 @@ var _ = Describe("Calling distribution precompile from contract", Ordered, func( // make a delegation with contract as delegator logCheck := testutil.LogCheckArgs{ ExpPass: true, - ABIEvents: stkPrecompile.ABI.Events, + ABIEvents: stkPrecompile.Events, ExpEvents: []string{staking.EventTypeDelegate}, } _, _, err = s.factory.CallContractAndCheckLogs( @@ -2321,7 +2321,7 @@ var _ = Describe("Calling distribution precompile from contract", Ordered, func( // make a delegation with contract as delegator logCheck := testutil.LogCheckArgs{ ExpPass: true, - ABIEvents: stkPrecompile.ABI.Events, + ABIEvents: stkPrecompile.Events, ExpEvents: []string{staking.EventTypeDelegate}, } txArgs.GasLimit = 500_000 diff --git a/precompiles/erc20/erc20_test.go b/precompiles/erc20/erc20_test.go index 86bd5c7e3..aac8f4eb8 100644 --- a/precompiles/erc20/erc20_test.go +++ b/precompiles/erc20/erc20_test.go @@ -45,7 +45,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.BalanceOfMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.BalanceOfMethod, s.keyring.GetAddr(0)) + bz, err := s.precompile.Pack(erc20.BalanceOfMethod, s.keyring.GetAddr(0)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -54,7 +54,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.DecimalsMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.DecimalsMethod) + bz, err := s.precompile.Pack(erc20.DecimalsMethod) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -63,7 +63,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.NameMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.NameMethod) + bz, err := s.precompile.Pack(erc20.NameMethod) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -72,7 +72,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.SymbolMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.SymbolMethod) + bz, err := s.precompile.Pack(erc20.SymbolMethod) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -81,7 +81,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.TotalSupplyMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.TotalSupplyMethod) + bz, err := s.precompile.Pack(erc20.TotalSupplyMethod) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -90,7 +90,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.ApproveMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.ApproveMethod, s.keyring.GetAddr(0), big.NewInt(1)) + bz, err := s.precompile.Pack(erc20.ApproveMethod, s.keyring.GetAddr(0), big.NewInt(1)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -99,7 +99,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.IncreaseAllowanceMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.IncreaseAllowanceMethod, s.keyring.GetAddr(0), big.NewInt(1)) + bz, err := s.precompile.Pack(erc20.IncreaseAllowanceMethod, s.keyring.GetAddr(0), big.NewInt(1)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -108,7 +108,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.DecreaseAllowanceMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.DecreaseAllowanceMethod, s.keyring.GetAddr(0), big.NewInt(1)) + bz, err := s.precompile.Pack(erc20.DecreaseAllowanceMethod, s.keyring.GetAddr(0), big.NewInt(1)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -117,7 +117,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.TransferMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.TransferMethod, s.keyring.GetAddr(0), big.NewInt(1)) + bz, err := s.precompile.Pack(erc20.TransferMethod, s.keyring.GetAddr(0), big.NewInt(1)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -126,7 +126,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.TransferFromMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.TransferFromMethod, s.keyring.GetAddr(0), s.keyring.GetAddr(0), big.NewInt(1)) + bz, err := s.precompile.Pack(erc20.TransferFromMethod, s.keyring.GetAddr(0), s.keyring.GetAddr(0), big.NewInt(1)) s.Require().NoError(err, "expected no error packing ABI") return bz }, @@ -135,7 +135,7 @@ func (s *PrecompileTestSuite) TestRequiredGas() { { name: erc20.AllowanceMethod, malleate: func() []byte { - bz, err := s.precompile.ABI.Pack(erc20.AllowanceMethod, s.keyring.GetAddr(0), s.keyring.GetAddr(0)) + bz, err := s.precompile.Pack(erc20.AllowanceMethod, s.keyring.GetAddr(0), s.keyring.GetAddr(0)) s.Require().NoError(err, "expected no error packing ABI") return bz }, diff --git a/precompiles/erc20/events.go b/precompiles/erc20/events.go index d12dcf3a3..1f9d07f46 100644 --- a/precompiles/erc20/events.go +++ b/precompiles/erc20/events.go @@ -24,7 +24,7 @@ const ( // EmitTransferEvent creates a new Transfer event emitted on transfer and transferFrom transactions. func (p Precompile) EmitTransferEvent(ctx sdk.Context, stateDB vm.StateDB, from, to common.Address, value *big.Int) error { // Prepare the event topics - event := p.ABI.Events[EventTypeTransfer] + event := p.Events[EventTypeTransfer] topics := make([]common.Hash, 3) // The first topic is always the signature of the event. @@ -61,7 +61,7 @@ func (p Precompile) EmitTransferEvent(ctx sdk.Context, stateDB vm.StateDB, from, // and DecreaseAllowance transactions. func (p Precompile) EmitApprovalEvent(ctx sdk.Context, stateDB vm.StateDB, owner, spender common.Address, value *big.Int) error { // Prepare the event topics - event := p.ABI.Events[EventTypeApproval] + event := p.Events[EventTypeApproval] topics := make([]common.Hash, 3) // The first topic is always the signature of the event. diff --git a/precompiles/erc20/events_test.go b/precompiles/erc20/events_test.go index 462f87f6a..78b37e8d8 100644 --- a/precompiles/erc20/events_test.go +++ b/precompiles/erc20/events_test.go @@ -41,7 +41,7 @@ func (s *PrecompileTestSuite) TestEmitTransferEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[erc20precompile.EventTypeTransfer] + event := s.precompile.Events[erc20precompile.EventTypeTransfer] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(s.network.GetContext().BlockHeight())) //nolint:gosec // G115 @@ -88,7 +88,7 @@ func (s *PrecompileTestSuite) TestEmitApprovalEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[erc20precompile.EventTypeApproval] + event := s.precompile.Events[erc20precompile.EventTypeApproval] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(s.network.GetContext().BlockHeight())) //nolint:gosec // G115 diff --git a/precompiles/erc20/utils_test.go b/precompiles/erc20/utils_test.go index f8353ae11..73f021671 100644 --- a/precompiles/erc20/utils_test.go +++ b/precompiles/erc20/utils_test.go @@ -66,12 +66,12 @@ func (is *IntegrationTestSuite) setAllowanceForContract( ) { // NOTE: When using the caller contract, erc20 contract must be called instead of caller contract. // This is because caller of erc20 contract becomes the owner of allowance. - switch { - case callType == erc20V5CallerCall: + switch callType { + case erc20V5CallerCall: callType = erc20V5Call - case callType == contractCall: + case contractCall: callType = directCall - case callType == contractCallToken2: + case contractCallToken2: callType = directCallToken2 } diff --git a/precompiles/evidence/events.go b/precompiles/evidence/events.go index 8bd857ea6..a2f2a391c 100644 --- a/precompiles/evidence/events.go +++ b/precompiles/evidence/events.go @@ -19,7 +19,7 @@ const ( // EmitSubmitEvidenceEvent creates a new event emitted on a SubmitEvidence transaction. func (p Precompile) EmitSubmitEvidenceEvent(ctx sdk.Context, stateDB vm.StateDB, origin common.Address, evidenceHash []byte) error { // Prepare the event topics - event := p.ABI.Events[EventTypeSubmitEvidence] + event := p.Events[EventTypeSubmitEvidence] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. diff --git a/precompiles/gov/events.go b/precompiles/gov/events.go index 7c79d8a4e..cd594fb15 100644 --- a/precompiles/gov/events.go +++ b/precompiles/gov/events.go @@ -27,7 +27,7 @@ const ( // EmitSubmitProposalEvent creates a new event emitted on a SubmitProposal transaction. func (p Precompile) EmitSubmitProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, proposalID uint64) error { // Prepare the event topics - event := p.ABI.Events[EventTypeSubmitProposal] + event := p.Events[EventTypeSubmitProposal] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -59,7 +59,7 @@ func (p Precompile) EmitSubmitProposalEvent(ctx sdk.Context, stateDB vm.StateDB, // EmitCancelProposalEvent creates a new event emitted on a CancelProposal transaction. func (p Precompile) EmitCancelProposalEvent(ctx sdk.Context, stateDB vm.StateDB, proposerAddress common.Address, proposalID uint64) error { // Prepare the event topics - event := p.ABI.Events[EventTypeCancelProposal] + event := p.Events[EventTypeCancelProposal] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -91,7 +91,7 @@ func (p Precompile) EmitCancelProposalEvent(ctx sdk.Context, stateDB vm.StateDB, // EmitDepositEvent creates a new event emitted on a Deposit transaction. func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, depositorAddress common.Address, proposalID uint64, amount []sdk.Coin) error { // Prepare the event topics - event := p.ABI.Events[EventTypeDeposit] + event := p.Events[EventTypeDeposit] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -122,7 +122,7 @@ func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, deposi // EmitVoteEvent creates a new event emitted on a Vote transaction. func (p Precompile) EmitVoteEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, proposalID uint64, option int32) error { // Prepare the event topics - event := p.ABI.Events[EventTypeVote] + event := p.Events[EventTypeVote] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. @@ -154,7 +154,7 @@ func (p Precompile) EmitVoteEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddr // EmitVoteWeightedEvent creates a new event emitted on a VoteWeighted transaction. func (p Precompile) EmitVoteWeightedEvent(ctx sdk.Context, stateDB vm.StateDB, voterAddress common.Address, proposalID uint64, options WeightedVoteOptions) error { // Prepare the event topics - event := p.ABI.Events[EventTypeVoteWeighted] + event := p.Events[EventTypeVoteWeighted] topics := make([]common.Hash, 2) // The first topic is always the signature of the event. diff --git a/precompiles/gov/events_test.go b/precompiles/gov/events_test.go index bf5bee7e0..2096beffa 100644 --- a/precompiles/gov/events_test.go +++ b/precompiles/gov/events_test.go @@ -45,7 +45,7 @@ func (s *PrecompileTestSuite) TestVoteEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[gov.EventTypeVote] + event := s.precompile.Events[gov.EventTypeVote] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -115,7 +115,7 @@ func (s *PrecompileTestSuite) TestVoteWeightedEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[gov.EventTypeVoteWeighted] + event := s.precompile.Events[gov.EventTypeVoteWeighted] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 diff --git a/precompiles/gov/integration_test.go b/precompiles/gov/integration_test.go index 6a8071912..a5ca2f91f 100644 --- a/precompiles/gov/integration_test.go +++ b/precompiles/gov/integration_test.go @@ -84,7 +84,7 @@ var _ = Describe("Calling governance precompile from EOA", func() { ContractABI: s.precompile.ABI, } defaultLogCheck = testutil.LogCheckArgs{ - ABIEvents: s.precompile.ABI.Events, + ABIEvents: s.precompile.Events, } passCheck = defaultLogCheck.WithExpPass(true) outOfGasCheck = defaultLogCheck.WithErrContains(vm.ErrOutOfGas.Error()) diff --git a/precompiles/ics20/tx.go b/precompiles/ics20/tx.go index c2019b6fe..8a7ffca2b 100644 --- a/precompiles/ics20/tx.go +++ b/precompiles/ics20/tx.go @@ -91,7 +91,7 @@ func (p *Precompile) Transfer( if err = EmitIBCTransferEvent( ctx, stateDB, - p.ABI.Events[EventTypeIBCTransfer], + p.Events[EventTypeIBCTransfer], p.Address(), sender, msg.Receiver, diff --git a/precompiles/p256/integration_test.go b/precompiles/p256/integration_test.go index 5bbcb1ad8..3c897f58d 100644 --- a/precompiles/p256/integration_test.go +++ b/precompiles/p256/integration_test.go @@ -105,8 +105,8 @@ var _ = Describe("Calling p256 precompile directly", Label("P256 Precompile"), O copy(input[0:32], hash) copy(input[32:64], rInt.Bytes()) copy(input[64:96], sInt.Bytes()) - copy(input[96:128], privB.PublicKey.X.Bytes()) - copy(input[128:160], privB.PublicKey.Y.Bytes()) + copy(input[96:128], privB.X.Bytes()) + copy(input[128:160], privB.Y.Bytes()) return input, nil, "" }, ), @@ -163,8 +163,8 @@ var _ = Describe("Calling p256 precompile directly", Label("P256 Precompile"), O copy(input[0:32], hash) copy(input[32:64], rInt.Bytes()) copy(input[64:96], sInt.Bytes()) - copy(input[96:128], privB.PublicKey.X.Bytes()) - copy(input[128:160], privB.PublicKey.Y.Bytes()) + copy(input[96:128], privB.X.Bytes()) + copy(input[128:160], privB.Y.Bytes()) return input }, ), diff --git a/precompiles/p256/p256_test.go b/precompiles/p256/p256_test.go index 92d577ef1..4d514c36b 100644 --- a/precompiles/p256/p256_test.go +++ b/precompiles/p256/p256_test.go @@ -43,8 +43,8 @@ func (s *PrecompileTestSuite) TestRun() { copy(input[0:32], hash) copy(input[32:64], rInt.Bytes()) copy(input[64:96], sInt.Bytes()) - copy(input[96:128], s.p256Priv.PublicKey.X.Bytes()) - copy(input[128:160], s.p256Priv.PublicKey.Y.Bytes()) + copy(input[96:128], s.p256Priv.X.Bytes()) + copy(input[128:160], s.p256Priv.Y.Bytes()) return input }, @@ -66,8 +66,8 @@ func (s *PrecompileTestSuite) TestRun() { copy(input[0:32], hash) copy(input[32:64], rBz) copy(input[64:96], sBz) - copy(input[96:128], s.p256Priv.PublicKey.X.Bytes()) - copy(input[128:160], s.p256Priv.PublicKey.Y.Bytes()) + copy(input[96:128], s.p256Priv.X.Bytes()) + copy(input[128:160], s.p256Priv.Y.Bytes()) return input }, @@ -92,8 +92,8 @@ func (s *PrecompileTestSuite) TestRun() { copy(input[0:32], hash) copy(input[32:64], rInt.Bytes()) copy(input[64:96], sInt.Bytes()) - copy(input[96:128], privB.PublicKey.X.Bytes()) - copy(input[128:160], privB.PublicKey.Y.Bytes()) + copy(input[96:128], privB.X.Bytes()) + copy(input[128:160], privB.Y.Bytes()) return input }, diff --git a/precompiles/p256/setup_test.go b/precompiles/p256/setup_test.go index 35ffd6c38..0b8be32fc 100644 --- a/precompiles/p256/setup_test.go +++ b/precompiles/p256/setup_test.go @@ -55,8 +55,8 @@ func signMsg(msg []byte, priv *ecdsa.PrivateKey) []byte { copy(input[0:32], hash) copy(input[32:64], rInt.Bytes()) copy(input[64:96], sInt.Bytes()) - copy(input[96:128], priv.PublicKey.X.Bytes()) - copy(input[128:160], priv.PublicKey.Y.Bytes()) + copy(input[96:128], priv.X.Bytes()) + copy(input[128:160], priv.Y.Bytes()) return input } diff --git a/precompiles/slashing/events.go b/precompiles/slashing/events.go index fcaf07c21..dbc800f46 100644 --- a/precompiles/slashing/events.go +++ b/precompiles/slashing/events.go @@ -23,7 +23,7 @@ type EventValidatorUnjailed struct { // EmitValidatorUnjailedEvent emits the ValidatorUnjailed event func (p Precompile) EmitValidatorUnjailedEvent(ctx sdk.Context, stateDB vm.StateDB, validator common.Address) error { // Prepare the event topics - event := p.ABI.Events[EventTypeValidatorUnjailed] + event := p.Events[EventTypeValidatorUnjailed] topics := make([]common.Hash, 2) // The first topic is always the signature of the event diff --git a/precompiles/slashing/events_test.go b/precompiles/slashing/events_test.go index 881b370f8..c3c95db69 100644 --- a/precompiles/slashing/events_test.go +++ b/precompiles/slashing/events_test.go @@ -54,7 +54,7 @@ func (s *PrecompileTestSuite) TestUnjailEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[slashing.EventTypeValidatorUnjailed] + event := s.precompile.Events[slashing.EventTypeValidatorUnjailed] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 diff --git a/precompiles/staking/events.go b/precompiles/staking/events.go index 1718b2661..106e68510 100644 --- a/precompiles/staking/events.go +++ b/precompiles/staking/events.go @@ -34,7 +34,7 @@ const ( // EmitCreateValidatorEvent creates a new create validator event emitted on a CreateValidator transaction. func (p Precompile) EmitCreateValidatorEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgCreateValidator, validatorAddr common.Address) error { // Prepare the event topics - event := p.ABI.Events[EventTypeCreateValidator] + event := p.Events[EventTypeCreateValidator] topics, err := p.createEditValidatorTxTopics(2, event, validatorAddr) if err != nil { @@ -58,7 +58,7 @@ func (p Precompile) EmitCreateValidatorEvent(ctx sdk.Context, stateDB vm.StateDB // EmitEditValidatorEvent creates a new edit validator event emitted on a EditValidator transaction. func (p Precompile) EmitEditValidatorEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgEditValidator, validatorAddr common.Address) error { // Prepare the event topics - event := p.ABI.Events[EventTypeEditValidator] + event := p.Events[EventTypeEditValidator] topics, err := p.createEditValidatorTxTopics(2, event, validatorAddr) if err != nil { @@ -108,7 +108,7 @@ func (p Precompile) EmitDelegateEvent(ctx sdk.Context, stateDB vm.StateDB, msg * } // Prepare the event topics - event := p.ABI.Events[EventTypeDelegate] + event := p.Events[EventTypeDelegate] topics, err := p.createStakingTxTopics(3, event, delegatorAddr, common.BytesToAddress(valAddr.Bytes())) if err != nil { return err @@ -137,7 +137,7 @@ func (p Precompile) EmitUnbondEvent(ctx sdk.Context, stateDB vm.StateDB, msg *st } // Prepare the event topics - event := p.ABI.Events[EventTypeUnbond] + event := p.Events[EventTypeUnbond] topics, err := p.createStakingTxTopics(3, event, delegatorAddr, common.BytesToAddress(valAddr.Bytes())) if err != nil { return err @@ -171,7 +171,7 @@ func (p Precompile) EmitRedelegateEvent(ctx sdk.Context, stateDB vm.StateDB, msg } // Prepare the event topics - event := p.ABI.Events[EventTypeRedelegate] + event := p.Events[EventTypeRedelegate] topics, err := p.createStakingTxTopics(4, event, delegatorAddr, common.BytesToAddress(valSrcAddr.Bytes())) if err != nil { return err @@ -205,7 +205,7 @@ func (p Precompile) EmitCancelUnbondingDelegationEvent(ctx sdk.Context, stateDB } // Prepare the event topics - event := p.ABI.Events[EventTypeCancelUnbondingDelegation] + event := p.Events[EventTypeCancelUnbondingDelegation] topics, err := p.createStakingTxTopics(3, event, delegatorAddr, common.BytesToAddress(valAddr.Bytes())) if err != nil { return err diff --git a/precompiles/staking/events_test.go b/precompiles/staking/events_test.go index ad015835f..ab56654a7 100644 --- a/precompiles/staking/events_test.go +++ b/precompiles/staking/events_test.go @@ -61,7 +61,7 @@ func (s *PrecompileTestSuite) TestCreateValidatorEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeCreateValidator] + event := s.precompile.Events[staking.EventTypeCreateValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -135,7 +135,7 @@ func (s *PrecompileTestSuite) TestEditValidatorEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeEditValidator] + event := s.precompile.Events[staking.EventTypeEditValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -205,7 +205,7 @@ func (s *PrecompileTestSuite) TestDelegateEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeDelegate] + event := s.precompile.Events[staking.EventTypeDelegate] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -275,7 +275,7 @@ func (s *PrecompileTestSuite) TestUnbondEvent() { func(delegator common.Address) { log := stDB.Logs()[0] // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeUnbond] + event := s.precompile.Events[staking.EventTypeUnbond] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -345,7 +345,7 @@ func (s *PrecompileTestSuite) TestRedelegateEvent() { func(delegator common.Address) { log := stDB.Logs()[0] // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeRedelegate] + event := s.precompile.Events[staking.EventTypeRedelegate] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -429,7 +429,7 @@ func (s *PrecompileTestSuite) TestCancelUnbondingDelegationEvent() { log := stDB.Logs()[1] // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeCancelUnbondingDelegation] + event := s.precompile.Events[staking.EventTypeCancelUnbondingDelegation] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 diff --git a/precompiles/staking/integration_test.go b/precompiles/staking/integration_test.go index 1aeff01c1..93a3b3edf 100644 --- a/precompiles/staking/integration_test.go +++ b/precompiles/staking/integration_test.go @@ -82,7 +82,7 @@ var _ = Describe("Calling staking precompile directly", func() { To: &precompileAddr, } - defaultLogCheck = testutil.LogCheckArgs{ABIEvents: s.precompile.ABI.Events} + defaultLogCheck = testutil.LogCheckArgs{ABIEvents: s.precompile.Events} passCheck = defaultLogCheck.WithExpPass(true) outOfGasCheck = defaultLogCheck.WithErrContains(vm.ErrOutOfGas.Error()) }) diff --git a/precompiles/staking/tx_test.go b/precompiles/staking/tx_test.go index 345168354..da4728664 100644 --- a/precompiles/staking/tx_test.go +++ b/precompiles/staking/tx_test.go @@ -268,7 +268,7 @@ func (s *PrecompileTestSuite) TestCreateValidator() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeCreateValidator] + event := s.precompile.Events[staking.EventTypeCreateValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(s.network.GetContext().BlockHeight())) //nolint:gosec // G115 @@ -561,7 +561,7 @@ func (s *PrecompileTestSuite) TestEditValidator() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeEditValidator] + event := s.precompile.Events[staking.EventTypeEditValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -599,7 +599,7 @@ func (s *PrecompileTestSuite) TestEditValidator() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeEditValidator] + event := s.precompile.Events[staking.EventTypeEditValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -635,7 +635,7 @@ func (s *PrecompileTestSuite) TestEditValidator() { s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeEditValidator] + event := s.precompile.Events[staking.EventTypeEditValidator] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec // G115 @@ -816,7 +816,7 @@ func (s *PrecompileTestSuite) TestDelegate() { log := stDB.Logs()[0] s.Require().Equal(log.Address, s.precompile.Address()) // Check event signature matches the one emitted - event := s.precompile.ABI.Events[staking.EventTypeDelegate] + event := s.precompile.Events[staking.EventTypeDelegate] s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex())) s.Require().Equal(log.BlockNumber, uint64(s.network.GetContext().BlockHeight())) //nolint:gosec // G115 }, diff --git a/precompiles/staking/types.go b/precompiles/staking/types.go index fc01a96d6..b98152838 100644 --- a/precompiles/staking/types.go +++ b/precompiles/staking/types.go @@ -619,7 +619,7 @@ func (vo *ValidatorOutput) FromResponse(res *stakingtypes.QueryValidatorResponse Description: res.Validator.Description.Details, UnbondingHeight: res.Validator.UnbondingHeight, UnbondingTime: res.Validator.UnbondingTime.UTC().Unix(), - Commission: res.Validator.Commission.CommissionRates.Rate.BigInt(), + Commission: res.Validator.Commission.Rate.BigInt(), MinSelfDelegation: res.Validator.MinSelfDelegation.BigInt(), }, } @@ -657,7 +657,7 @@ func (vo *ValidatorsOutput) FromResponse(res *stakingtypes.QueryValidatorsRespon Description: v.Description.Details, UnbondingHeight: v.UnbondingHeight, UnbondingTime: v.UnbondingTime.UTC().Unix(), - Commission: v.Commission.CommissionRates.Rate.BigInt(), + Commission: v.Commission.Rate.BigInt(), MinSelfDelegation: v.MinSelfDelegation.BigInt(), } } diff --git a/precompiles/werc20/events.go b/precompiles/werc20/events.go index 90fd22fd1..e60ae97d6 100644 --- a/precompiles/werc20/events.go +++ b/precompiles/werc20/events.go @@ -27,7 +27,7 @@ func (p Precompile) EmitDepositEvent( caller common.Address, amount *big.Int, ) error { - event := p.ABI.Events[EventTypeDeposit] + event := p.Events[EventTypeDeposit] return p.createWERC20Event(ctx, stateDB, event, caller, amount) } @@ -38,7 +38,7 @@ func (p Precompile) EmitWithdrawalEvent( src common.Address, amount *big.Int, ) error { - event := p.ABI.Events[EventTypeWithdrawal] + event := p.Events[EventTypeWithdrawal] return p.createWERC20Event(ctx, stateDB, event, src, amount) } diff --git a/precompiles/werc20/events_test.go b/precompiles/werc20/events_test.go index 3512dc4ca..e621b0046 100644 --- a/precompiles/werc20/events_test.go +++ b/precompiles/werc20/events_test.go @@ -121,7 +121,7 @@ func (s *PrecompileUnitTestSuite) TestEmitDepositEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check on the topics - event := s.precompile.ABI.Events[werc20.EventTypeDeposit] + event := s.precompile.Events[werc20.EventTypeDeposit] s.Require().Equal( crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex()), @@ -180,7 +180,7 @@ func (s *PrecompileUnitTestSuite) TestEmitWithdrawalEvent() { s.Require().Equal(log.Address, s.precompile.Address()) // Check on the topics - event := s.precompile.ABI.Events[werc20.EventTypeWithdrawal] + event := s.precompile.Events[werc20.EventTypeWithdrawal] s.Require().Equal( crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex()), diff --git a/precompiles/werc20/werc20.go b/precompiles/werc20/werc20.go index a0b88d0e4..85dc7d695 100644 --- a/precompiles/werc20/werc20.go +++ b/precompiles/werc20/werc20.go @@ -66,7 +66,7 @@ func NewPrecompile( } // use the IWERC20 ABI - erc20Precompile.Precompile.ABI = newABI + erc20Precompile.ABI = newABI return &Precompile{ Precompile: erc20Precompile, @@ -127,7 +127,7 @@ func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz [ bz, err = p.Withdraw(ctx, contract, stateDB, args) default: // ERC20 transactions and queries - bz, err = p.Precompile.HandleMethod(ctx, contract, stateDB, method, args) + bz, err = p.HandleMethod(ctx, contract, stateDB, method, args) } if err != nil { diff --git a/rpc/backend/blocks_test.go b/rpc/backend/blocks_test.go index dfc192b1f..2a5165c9a 100644 --- a/rpc/backend/blocks_test.go +++ b/rpc/backend/blocks_test.go @@ -628,7 +628,7 @@ func (suite *BackendTestSuite) TestTendermintBlockByNumber() { suite.Require().Nil(resultBlock) } else { suite.Require().Equal(expResultBlock, resultBlock) - suite.Require().Equal(expResultBlock.Block.Header.Height, resultBlock.Block.Header.Height) + suite.Require().Equal(expResultBlock.Block.Height, resultBlock.Block.Height) } } else { suite.Require().Error(err) diff --git a/rpc/backend/filters.go b/rpc/backend/filters.go index 4d4ed5005..f3b6b9144 100644 --- a/rpc/backend/filters.go +++ b/rpc/backend/filters.go @@ -15,7 +15,7 @@ func (b *Backend) GetLogs(hash common.Hash) ([][]*ethtypes.Log, error) { if resBlock == nil { return nil, errors.Errorf("block not found for hash %s", hash) } - return b.GetLogsByHeight(&resBlock.Block.Header.Height) + return b.GetLogsByHeight(&resBlock.Block.Height) } // GetLogsByHeight returns all the logs from all the ethereum transactions in a block. diff --git a/rpc/namespaces/ethereum/eth/filters/api.go b/rpc/namespaces/ethereum/eth/filters/api.go index 2330c0d95..736310862 100644 --- a/rpc/namespaces/ethereum/eth/filters/api.go +++ b/rpc/namespaces/ethereum/eth/filters/api.go @@ -395,7 +395,7 @@ func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteri continue } - txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data) + txResponse, err := evmtypes.DecodeTxResponse(dataTx.Result.Data) if err != nil { api.logger.Error("fail to decode tx response", "error", err) return @@ -475,7 +475,7 @@ func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, continue } - txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data) + txResponse, err := evmtypes.DecodeTxResponse(dataTx.Result.Data) if err != nil { api.logger.Error("fail to decode tx response", "error", err) return diff --git a/rpc/websockets.go b/rpc/websockets.go index 2fc103297..9988e0874 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -575,7 +575,7 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac continue } - txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data) + txResponse, err := evmtypes.DecodeTxResponse(dataTx.Result.Data) if err != nil { api.logger.Error("failed to decode tx response", "error", err.Error()) return diff --git a/tests/ibc/ics20_precompile_transfer_test.go b/tests/ibc/ics20_precompile_transfer_test.go index 50316e670..972296163 100644 --- a/tests/ibc/ics20_precompile_transfer_test.go +++ b/tests/ibc/ics20_precompile_transfer_test.go @@ -151,7 +151,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { originalCoin := sdk.NewCoin(sourceDenomToTransfer, msgAmount) sourceAddr := common.BytesToAddress(suite.chainA.SenderAccount.GetAddress().Bytes()) - data, err := suite.chainAPrecompile.ABI.Pack("transfer", + data, err := suite.chainAPrecompile.Pack("transfer", pathAToB.EndpointA.ChannelConfig.PortID, pathAToB.EndpointA.ChannelID, originalCoin.Denom, diff --git a/tests/ibc/v2_ics20_precompile_transfer_test.go b/tests/ibc/v2_ics20_precompile_transfer_test.go index 1a96d9b5f..120b8d4cf 100644 --- a/tests/ibc/v2_ics20_precompile_transfer_test.go +++ b/tests/ibc/v2_ics20_precompile_transfer_test.go @@ -153,7 +153,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { originalCoin := sdk.NewCoin(sourceDenomToTransfer, msgAmount) sourceAddr := common.BytesToAddress(suite.chainA.SenderAccount.GetAddress().Bytes()) - data, err := suite.chainAPrecompile.ABI.Pack("transfer", + data, err := suite.chainAPrecompile.Pack("transfer", transfertypes.PortID, pathAToB.EndpointA.ClientID, // Note: should be client id on v2 packet originalCoin.Denom, diff --git a/tests/integration/ledger/evmosd_suite_test.go b/tests/integration/ledger/evmosd_suite_test.go index 23e6bced1..b7effc81a 100644 --- a/tests/integration/ledger/evmosd_suite_test.go +++ b/tests/integration/ledger/evmosd_suite_test.go @@ -89,7 +89,7 @@ func (suite *LedgerTestSuite) SetupEvmosApp() { // init app chainID := constants.ExampleChainID suite.app = exampleapp.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) - suite.ctx = suite.app.BaseApp.NewContextLegacy(false, tmproto.Header{ + suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, ChainID: chainID.ChainID, Time: time.Now().UTC(), diff --git a/testutil/integration/os/network/abci.go b/testutil/integration/os/network/abci.go index 3c50ee383..ffd4414fd 100644 --- a/testutil/integration/os/network/abci.go +++ b/testutil/integration/os/network/abci.go @@ -50,7 +50,7 @@ func (n *IntegrationNetwork) finalizeBlockAndCommit(duration time.Duration, txBy return nil, err } - newCtx := n.app.BaseApp.NewContextLegacy(false, header) + newCtx := n.app.NewContextLegacy(false, header) // Update context header newCtx = newCtx.WithMinGasPrices(n.ctx.MinGasPrices()) diff --git a/testutil/integration/os/network/network.go b/testutil/integration/os/network/network.go index 8f2537c2c..59f1a1c68 100644 --- a/testutil/integration/os/network/network.go +++ b/testutil/integration/os/network/network.go @@ -226,7 +226,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error { } // TODO - this might not be the best way to initilize the context - n.ctx = exampleApp.BaseApp.NewContextLegacy(false, header) + n.ctx = exampleApp.NewContextLegacy(false, header) // Commit genesis changes if _, err := exampleApp.Commit(); err != nil { @@ -337,7 +337,7 @@ func (n *IntegrationNetwork) BroadcastTxSync(txBytes []byte) (abcitypes.ExecTxRe // Simulate simulates the given txBytes to the network and returns the simulated response. // TODO - this should be change to gRPC func (n *IntegrationNetwork) Simulate(txBytes []byte) (*txtypes.SimulateResponse, error) { - gas, result, err := n.app.BaseApp.Simulate(txBytes) + gas, result, err := n.app.Simulate(txBytes) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (n *IntegrationNetwork) Simulate(txBytes []byte) (*txtypes.SimulateResponse // CheckTx calls the BaseApp's CheckTx method with the given txBytes to the network and returns the response. func (n *IntegrationNetwork) CheckTx(txBytes []byte) (*abcitypes.ResponseCheckTx, error) { req := &abcitypes.RequestCheckTx{Tx: txBytes} - res, err := n.app.BaseApp.CheckTx(req) + res, err := n.app.CheckTx(req) if err != nil { return nil, err } diff --git a/testutil/integration/os/utils/evm.go b/testutil/integration/os/utils/evm.go index a05bcf91c..7510098ff 100644 --- a/testutil/integration/os/utils/evm.go +++ b/testutil/integration/os/utils/evm.go @@ -42,7 +42,7 @@ func GetERC20Balance(nw network.Network, tokenAddress, accountAddress common.Add return nil, err } - fmt.Println("got ret: ", ethRes.Ret) + fmt.Println("got ret: ", string(ethRes.Ret)) fmt.Println("got eth call logs: ", ethRes.Logs) fmt.Println("got eth call error: ", ethRes.VmError) diff --git a/wallets/usbwallet/ledger.go b/wallets/usbwallet/ledger.go index d40716adc..134f987f1 100644 --- a/wallets/usbwallet/ledger.go +++ b/wallets/usbwallet/ledger.go @@ -137,7 +137,7 @@ func (w *ledgerDriver) SignTypedMessage(path gethaccounts.DerivationPath, domain // Ensure the wallet is capable of signing the given transaction if w.version[0] < 1 && w.version[1] < 5 { //nolint:stylecheck // ST1005 requires error strings to be lowercase but Ledger as a brand name should start with a capital letter - return nil, fmt.Errorf("Ledger version >= 1.5.0 required for EIP-712 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2]) + return nil, fmt.Errorf("ledger version >= 1.5.0 required for EIP-712 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2]) } // All infos gathered and metadata checks out, request signing return w.ledgerSignTypedMessage(path, domainHash, messageHash) diff --git a/wallets/usbwallet/wallet.go b/wallets/usbwallet/wallet.go index 9e9915fb4..205f9e678 100644 --- a/wallets/usbwallet/wallet.go +++ b/wallets/usbwallet/wallet.go @@ -319,7 +319,7 @@ func (w *wallet) signHash(_ accounts.Account, _ []byte) ([]byte, error) { // SignData signs keccak256(data). The mimetype parameter describes the type of data being signed func (w *wallet) signData(account accounts.Account, mimeType string, data []byte) ([]byte, error) { // Unless we are doing 712 signing, simply dispatch to signHash - if !(mimeType == gethaccounts.MimetypeTypedData && len(data) == 66 && data[0] == 0x19 && data[1] == 0x01) { + if mimeType != gethaccounts.MimetypeTypedData || len(data) != 66 || data[0] != 0x19 || data[1] != 0x01 { return w.signHash(account, crypto.Keccak256(data)) } diff --git a/x/erc20/genesis_test.go b/x/erc20/genesis_test.go index 30b31c327..3fb644035 100644 --- a/x/erc20/genesis_test.go +++ b/x/erc20/genesis_test.go @@ -45,7 +45,7 @@ func (suite *GenesisTestSuite) SetupTest() { chainID := constants.ExampleChainID suite.app = exampleapp.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) - suite.ctx = suite.app.BaseApp.NewContextLegacy(false, tmproto.Header{ + suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, ChainID: chainID.ChainID, Time: time.Now().UTC(), diff --git a/x/vm/wrappers/bank.go b/x/vm/wrappers/bank.go index 8b8eb0d26..d254a11c3 100644 --- a/x/vm/wrappers/bank.go +++ b/x/vm/wrappers/bank.go @@ -45,7 +45,7 @@ func (w BankWrapper) MintAmountToAccount(ctx context.Context, recipientAddr sdk. } coinsToMint := sdk.Coins{convertedCoin} - if err := w.BankKeeper.MintCoins(ctx, types.ModuleName, coinsToMint); err != nil { + if err := w.MintCoins(ctx, types.ModuleName, coinsToMint); err != nil { return errors.Wrap(err, "failed to mint coins to account in bank wrapper") } @@ -66,7 +66,7 @@ func (w BankWrapper) BurnAmountFromAccount(ctx context.Context, account sdk.AccA if err := w.BankKeeper.SendCoinsFromAccountToModule(ctx, account, types.ModuleName, coinsToBurn); err != nil { return errors.Wrap(err, "failed to burn coins from account in bank wrapper") } - return w.BankKeeper.BurnCoins(ctx, types.ModuleName, coinsToBurn) + return w.BurnCoins(ctx, types.ModuleName, coinsToBurn) } // ------------------------------------------------------------------------------------------