Skip to content

Commit 20327b4

Browse files
Unique-Divinezeroproofftsinghuacodermdqst
authored
refactor: use importas linter for consistent imports (#2290)
* feat(evm)!: squashed commit commit aaf6431 Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:25:36 2025 -0500 refactor: linter and formatter commit f36399c Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:07:42 2025 -0500 chore: changelog commit f6bb649 Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:07:42 2025 -0500 chore: changelog commit a6877ee Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:06:45 2025 -0500 chore: move Go to v1.22 because it's required for geth commit a1e74e9 Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:06:45 2025 -0500 chore: move Go to v1.22 because it's required for geth commit b546151 Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:04:56 2025 -0500 feat(evm)!: update to geth v1.13 with EIP-1153, PRECOMPILE_ADDRS, and transient storage support This commit upgrades the Nibiru EVM module for compatibility with go-ethereum v1.13.14, introducing the following changes: - Updated all references from deprecated types in `rpc` to their new equivalents under `common/math`, such as replacing `rpc.DecimalOrHex` with `math.HexOrDecimal64`. - Removed deprecated EIP-155 seed hash API (`debug_seedHash`) and associated `ethash` import. - Aligned `vm.Config` and fee calculation logic with new EIP-based gas cost parameters (`isShanghai`, `isEIP3860`). - Introduced explicit `PRECOMPILE_ADDRS` constant to aggregate EVM precompiles with NibiruΓÇÖs extensions (FunToken, Wasm, Oracle). - Implemented support for **EIP-1153** (transient storage): - Added `transientStorage` map to `StateDB`, with getters/setters and journaling support. - Added `Prepare` method to reset access lists and transient storage for each tx. - Refactored `SelfDestruct` logic and exposed `HasSelfDestructed` (was `Suicide`) for better clarity and future EIP-6780 readiness. - Reworked balance mutation logic (`AddBalanceSigned`) to correctly handle signed values and prevent `uint256` overflow errors. - Minor typo corrections (e.g., "occured" ΓåÆ "occurred") in proto files and comments. This upgrade also adjusts `go.mod` to: - Replace `go-ethereum v1.10.x` with `v1.13.14` - Downgrade Go version to 1.21 for compatibility with `go-ethereum` and its Pebble dependency - Pin Pebble to a compatible commit required by geth's internal `ethdb` commit 803f9b4 Author: Unique-Divine <[email protected]> Date: Mon Apr 14 10:04:56 2025 -0500 feat(evm)!: update to geth v1.13 with EIP-1153, PRECOMPILE_ADDRS, and transient storage support This commit upgrades the Nibiru EVM module for compatibility with go-ethereum v1.13.14, introducing the following changes: - Updated all references from deprecated types in `rpc` to their new equivalents under `common/math`, such as replacing `rpc.DecimalOrHex` with `math.HexOrDecimal64`. - Removed deprecated EIP-155 seed hash API (`debug_seedHash`) and associated `ethash` import. - Aligned `vm.Config` and fee calculation logic with new EIP-based gas cost parameters (`isShanghai`, `isEIP3860`). - Introduced explicit `PRECOMPILE_ADDRS` constant to aggregate EVM precompiles with NibiruΓÇÖs extensions (FunToken, Wasm, Oracle). - Implemented support for **EIP-1153** (transient storage): - Added `transientStorage` map to `StateDB`, with getters/setters and journaling support. - Added `Prepare` method to reset access lists and transient storage for each tx. - Refactored `SelfDestruct` logic and exposed `HasSelfDestructed` (was `Suicide`) for better clarity and future EIP-6780 readiness. - Reworked balance mutation logic (`AddBalanceSigned`) to correctly handle signed values and prevent `uint256` overflow errors. - Minor typo corrections (e.g., "occured" ΓåÆ "occurred") in proto files and comments. This upgrade also adjusts `go.mod` to: - Replace `go-ethereum v1.10.x` with `v1.13.14` - Downgrade Go version to 1.21 for compatibility with `go-ethereum` and its Pebble dependency - Pin Pebble to a compatible commit required by geth's internal `ethdb` commit 1834a61 Author: Unique-Divine <[email protected]> Date: Sat Apr 12 19:51:44 2025 -0500 feat(evm): Adapt module to Geth v1.13 core package changes This commit updates the Nibiru EVM module to align with significant breaking changes introduced in the upstream go-ethereum v1.13 `core/vm` and `core/types` packages. The goal is to leverage the updated Geth dependencies while ensuring compatibility with Nibiru's specific requirements, particularly its custom precompiles that interact with the Cosmos SDK. This addresses several LSP errors and runtime issues arising from removed or modified upstream functions and interfaces: 1. **Replace `core.NewMessage` Calls:** - The `core.NewMessage` factory function was removed upstream in favor of direct struct instantiation. - All instances have been replaced with `core.Message{...}` struct literals, correctly mapping arguments to fields like `From`, `To`, `Nonce`, `Value`, `GasLimit`, gas price fields (`GasPrice`, `GasFeeCap`, `GasTipCap`), `Data`, `AccessList`. - Monetary and gas values are initialized as `*big.Int` per the `core.Message` definition. - Newer fields relevant to Cancun/EIP-4844 (`BlobGasFeeCap`, `BlobHashes`) and Nibiru-specific fields (`SkipAccountChecks`) are now correctly initialized. 2. **Revert `vm.PrecompiledContract` Interface for Nibiru Precompiles:** - Geth v1.13 simplified the `PrecompiledContract.Run` signature to `Run(input []byte)`. - This change breaks Nibiru's custom precompiles (e.g., Wasm) which require the `*vm.EVM` pointer to access `StateDB` and derive the `sdk.Context` needed for Cosmos SDK keeper interactions. - This commit *reverts* the interface definition within Nibiru's fork back to `Run(evm *vm.EVM, contract *vm.Contract, readonly bool)`. - The `Address() common.Address` method is also restored to the interface and implementations for use by the execution logic. - Standard precompile implementations included in this module have been adapted to match this reverted interface signature. - The `vm.RunPrecompiledContract` helper function is updated to pass the necessary `*vm.EVM`, `*vm.Contract`, and `readonly` context. 3. **Adopt `uint256` for VM Value/Balance Interactions:** - While `core.Message` retains `*big.Int`, the internal VM logic and `StateDB` methods (e.g., `vm.Call`, `vm.Create`, `AddBalance`, `SubBalance`, `Contract.value`) were updated upstream to use `*uint256.Int` (from `holiman/uint256`). - Code passing values into these VM contexts has been updated to perform the necessary `*big.Int` -> `*uint256.Int` conversions. - Added `holiman/uint256` as a direct dependency in `go.mod`. 4. **Replace `StateDB.PrepareAccessList`:** - The `PrepareAccessList` method was removed from the `vm.StateDB` interface upstream. - Calls have been replaced with the new, more comprehensive `StateDB.Prepare(rules, sender, ...)` method. 5. **Replace `evm.ActivePrecompiles` Method:** - The `ActivePrecompiles` method on the `vm.EVM` struct was removed. - Calls have been replaced with the standalone package function `vm.ActivePrecompiles(rules)`, passing the appropriate chain rules. These changes resolve the identified compatibility errors and ensure the EVM module integrates correctly with both the updated Geth core components and Nibiru's specific architecture and custom precompiles. commit af71ded Author: Unique-Divine <[email protected]> Date: Sat Apr 12 19:51:44 2025 -0500 feat(evm): Adapt module to Geth v1.13 core package changes This commit updates the Nibiru EVM module to align with significant breaking changes introduced in the upstream go-ethereum v1.13 `core/vm` and `core/types` packages. The goal is to leverage the updated Geth dependencies while ensuring compatibility with Nibiru's specific requirements, particularly its custom precompiles that interact with the Cosmos SDK. This addresses several LSP errors and runtime issues arising from removed or modified upstream functions and interfaces: 1. **Replace `core.NewMessage` Calls:** - The `core.NewMessage` factory function was removed upstream in favor of direct struct instantiation. - All instances have been replaced with `core.Message{...}` struct literals, correctly mapping arguments to fields like `From`, `To`, `Nonce`, `Value`, `GasLimit`, gas price fields (`GasPrice`, `GasFeeCap`, `GasTipCap`), `Data`, `AccessList`. - Monetary and gas values are initialized as `*big.Int` per the `core.Message` definition. - Newer fields relevant to Cancun/EIP-4844 (`BlobGasFeeCap`, `BlobHashes`) and Nibiru-specific fields (`SkipAccountChecks`) are now correctly initialized. 2. **Revert `vm.PrecompiledContract` Interface for Nibiru Precompiles:** - Geth v1.13 simplified the `PrecompiledContract.Run` signature to `Run(input []byte)`. - This change breaks Nibiru's custom precompiles (e.g., Wasm) which require the `*vm.EVM` pointer to access `StateDB` and derive the `sdk.Context` needed for Cosmos SDK keeper interactions. - This commit *reverts* the interface definition within Nibiru's fork back to `Run(evm *vm.EVM, contract *vm.Contract, readonly bool)`. - The `Address() common.Address` method is also restored to the interface and implementations for use by the execution logic. - Standard precompile implementations included in this module have been adapted to match this reverted interface signature. - The `vm.RunPrecompiledContract` helper function is updated to pass the necessary `*vm.EVM`, `*vm.Contract`, and `readonly` context. 3. **Adopt `uint256` for VM Value/Balance Interactions:** - While `core.Message` retains `*big.Int`, the internal VM logic and `StateDB` methods (e.g., `vm.Call`, `vm.Create`, `AddBalance`, `SubBalance`, `Contract.value`) were updated upstream to use `*uint256.Int` (from `holiman/uint256`). - Code passing values into these VM contexts has been updated to perform the necessary `*big.Int` -> `*uint256.Int` conversions. - Added `holiman/uint256` as a direct dependency in `go.mod`. 4. **Replace `StateDB.PrepareAccessList`:** - The `PrepareAccessList` method was removed from the `vm.StateDB` interface upstream. - Calls have been replaced with the new, more comprehensive `StateDB.Prepare(rules, sender, ...)` method. 5. **Replace `evm.ActivePrecompiles` Method:** - The `ActivePrecompiles` method on the `vm.EVM` struct was removed. - Calls have been replaced with the standalone package function `vm.ActivePrecompiles(rules)`, passing the appropriate chain rules. These changes resolve the identified compatibility errors and ensure the EVM module integrates correctly with both the updated Geth core components and Nibiru's specific architecture and custom precompiles. commit 6370b96 Author: Unique-Divine <[email protected]> Date: Sat Apr 12 10:38:30 2025 -0500 fix(evm): Pass block timestamp to MakeSigner and refactor MsgEthereumTx field usage - Update all calls to `gethcore.MakeSigner` to include the block time as a Unix timestamp (seconds), using `evm.ParseBlockTimeUnixU64(ctx)`. - Add `ParseBlockTimeUnixU64` utility to extract block time from `sdk.Context` in a safe, reusable way. - Refactor usage of MsgEthereumTx field getters to use direct struct fields (`From`, `To`, `Value`, `GasFeeCap`, etc.), improving efficiency and clarity. - Enhance `ParseWeiAsMultipleOfMicronibi` to return `uint256.Int` and handle nil, zero, negative, and overflow edge cases with clear error messages. commit 0fad842 Author: Unique-Divine <[email protected]> Date: Sat Apr 12 10:38:30 2025 -0500 fix(evm): Pass block timestamp to MakeSigner and refactor MsgEthereumTx field usage - Update all calls to `gethcore.MakeSigner` to include the block time as a Unix timestamp (seconds), using `evm.ParseBlockTimeUnixU64(ctx)`. - Add `ParseBlockTimeUnixU64` utility to extract block time from `sdk.Context` in a safe, reusable way. - Refactor usage of MsgEthereumTx field getters to use direct struct fields (`From`, `To`, `Value`, `GasFeeCap`, etc.), improving efficiency and clarity. - Enhance `ParseWeiAsMultipleOfMicronibi` to return `uint256.Int` and handle nil, zero, negative, and overflow edge cases with clear error messages. commit 1002634 Author: Unique-Divine <[email protected]> Date: Sat Apr 12 03:21:08 2025 -0500 refactor(evm): add more compatibility the new geth StateDB inteface, updating AddBalance and SubBalance to use uint256 commit d69a8c3 Author: Unique-Divine <[email protected]> Date: Sat Apr 12 03:21:08 2025 -0500 refactor(evm): add more compatibility the new geth StateDB inteface, updating AddBalance and SubBalance to use uint256 commit d07093c Author: Unique-Divine <[email protected]> Date: Fri Apr 11 21:18:53 2025 -0500 feat: impl slog.Handler for geth v1.13. used in json-rpc These changes update Nibiru's integration with the `go-ethereum/log` package to align with its upstream migration to Go's standard structured logging library (`slog`). The previous logging setup in Nibiru, which relied on `go-ethereum/log`'s deprecated `FuncHandler` and `Record` types, was removed. 1. **Added `LogHandler`:** A new file `app/server/geth_log_handler.go` introduces the `LogHandler` type. This type implements the standard `slog.Handler` interface. Its primary role is to receive log records generated by Geth components (which now use `slog`) and translate them into corresponding calls on Nibiru's standard `cmtlog.Logger` (CometBFT logger). It correctly maps Geth/`slog` levels (including `Trace` and `Crit`) and formats log attributes for compatibility. 2. **Updated Initialization:** In `app/server/json_rpc.go`, the old `ethlog.Root().SetHandler(...)` block was replaced. The code now instantiates the new `LogHandler` (providing it the context logger `ctx.Logger.With("module", "geth")`), wraps it using `gethlog.NewLogger()`, and sets the result as the default logger for `go-ethereum` components via `gethlog.SetDefault()`. The primary reason for this refactor was the breaking change in the `go-ethereum/log` dependency, which deprecated its custom logging implementation in favor of Go's standard `slog`. These changes adapt Nibiru to the new `slog`-based API, ensuring that logs generated within embedded Geth components are correctly captured and processed by Nibiru's existing logging infrastructure (`cmtlog.Logger`). This maintains consistent logging behavior and compatibility with the updated dependency. commit 5937bbe Author: Unique-Divine <[email protected]> Date: Fri Apr 11 21:18:53 2025 -0500 feat: impl slog.Handler for geth v1.13. used in json-rpc These changes update Nibiru's integration with the `go-ethereum/log` package to align with its upstream migration to Go's standard structured logging library (`slog`). The previous logging setup in Nibiru, which relied on `go-ethereum/log`'s deprecated `FuncHandler` and `Record` types, was removed. 1. **Added `LogHandler`:** A new file `app/server/geth_log_handler.go` introduces the `LogHandler` type. This type implements the standard `slog.Handler` interface. Its primary role is to receive log records generated by Geth components (which now use `slog`) and translate them into corresponding calls on Nibiru's standard `cmtlog.Logger` (CometBFT logger). It correctly maps Geth/`slog` levels (including `Trace` and `Crit`) and formats log attributes for compatibility. 2. **Updated Initialization:** In `app/server/json_rpc.go`, the old `ethlog.Root().SetHandler(...)` block was replaced. The code now instantiates the new `LogHandler` (providing it the context logger `ctx.Logger.With("module", "geth")`), wraps it using `gethlog.NewLogger()`, and sets the result as the default logger for `go-ethereum` components via `gethlog.SetDefault()`. The primary reason for this refactor was the breaking change in the `go-ethereum/log` dependency, which deprecated its custom logging implementation in favor of Go's standard `slog`. These changes adapt Nibiru to the new `slog`-based API, ensuring that logs generated within embedded Geth components are correctly captured and processed by Nibiru's existing logging infrastructure (`cmtlog.Logger`). This maintains consistent logging behavior and compatibility with the updated dependency. commit ca3c821 Author: Unique-Divine <[email protected]> Date: Fri Apr 11 19:03:04 2025 -0500 wip!: start with a local brute force jump to a geth v1.13.15 with no changes commit 10010d6 Author: Unique-Divine <[email protected]> Date: Fri Apr 11 19:03:04 2025 -0500 wip!: start with a local brute force jump to a geth v1.13.15 with no changes * feat(evm)!: Update to geth v1.14 with newer pebble and Go 1.24 (#2275) This upgrade bumps Nibiru's Geth dependency from v1.13 to v1.14.13 and updates the Go version to 1.24 across the codebase and CI workflows. The upgrade is motivated by the need to support modern database backends (e.g., Cockroach Pebble), leverage recent Go generics improvements, and remain aligned with upstream changes in the Geth EVM architecture. Key changes: - Refactored EVM backend logic to use Geth's new `core.Block` constructor signature, which requires `core.Body`, `Receipts`, and `TrieHasher` explicitly. - Migrated `TraceTransaction`, `TraceCall`, and `TraceBlock` methods to return `json.RawMessage` as required by Geth's new trace API interfaces. - Replaced `go-ethereum/log` with the new `log/slog` stdlib implementation, per Geth v1.14’s logging changes. - Introduced `SuccessfulTx` struct in EVM tests to simplify managing and reusing stateful block hashes and numbers across assertions. - Updated all Dockerfile and CI workflows to Go 1.24 to ensure compatibility. - Disabled the `revive` linter’s `exported` rule for smoother CI linting. Compatibility notes: - Nibiru remains on the Berlin hard fork to avoid breaking changes from Ethereum’s blob transactions (Cancun) and Verkle tree requirements that are not applicable to Nibiru’s consensus and storage design. - Geth v1.14 is the last compatible version before Cancun-related features become mandatory. BREAKING CHANGE: Trace API return types and internal block construction logic have changed to comply with Geth v1.14. Any downstream tools or integrations depending on older behaviors may need to be updated. * refactor: self-review changes * fix(evm-precompile): get new delegate call behavior using the sender arg * refactor: more self-review * refactor(evm): VerifyFee MUST use the same gethparams.Rules as the EVM * docs: remove consecutive duplicate words (#2285) * Update LEGACY-CHANGELOG.md * Update HACKING.md * chore: fix function name in comment (#2273) Signed-off-by: tsinghuacoder <[email protected]> Co-authored-by: Kevin Yang <[email protected]> * chore: fix typo in RewardBand description (#2234) Co-authored-by: Unique Divine <[email protected]> * test(rpcapi): prevent more regressions with runtime service inspection * fix(backend): fix error propagation * fix(eth): error propagation fixes and tests for the methods exposed by Nibiru's EVM JSON-RPC Replace legacy error aliases throughout the eth module with sdkioerrors.Wrapf and sdkerrors.Err* to ensure consistent wrapping of Cosmos SDK errors. Simplify EVM backend error reporting by using fmt.Errorf with clear method prefixes (e.g. “BlockNumberError”, “RPCBlockFromTendermintBlock error”) and defaulting the base fee to evm.BASE_FEE_WEI. Suppress pruning‑related bloom errors by returning empty blooms when data is missing. Unify RPC transaction conversion logic by renaming NewRPCTxFromMsg to NewRPCTxFromMsgEthTx, retiring the older NewRPCTxFromEthTx, and centralizing signer and signature‑value extraction. Refactor BackendSuite tests to use a SuccessfulTx map for structured receipt capture—eliminating global variables and improving setup clarity. Stub out unimplemented debugapi methods with context‑aware signatures and adjust filters, tracing, and utils to inline BlockBloom usage and align imports (e.g. eip1559, tracers) with modern patterns. * refactor: use importas linter for consistent imports * refactor: use importas linter for consistent imports * refactor: sdkmath import alias * linter fixes * Update CHANGELOG.md * fix(eth-rpc): error propagation fixes and tests for the methods exposed by Nibiru's EVM JSON-RPC (#2289) * test(rpcapi): prevent more regressions with runtime service inspection * fix(backend): fix error propagation * fix(eth): error propagation fixes and tests for the methods exposed by Nibiru's EVM JSON-RPC Replace legacy error aliases throughout the eth module with sdkioerrors.Wrapf and sdkerrors.Err* to ensure consistent wrapping of Cosmos SDK errors. Simplify EVM backend error reporting by using fmt.Errorf with clear method prefixes (e.g. “BlockNumberError”, “RPCBlockFromTendermintBlock error”) and defaulting the base fee to evm.BASE_FEE_WEI. Suppress pruning‑related bloom errors by returning empty blooms when data is missing. Unify RPC transaction conversion logic by renaming NewRPCTxFromMsg to NewRPCTxFromMsgEthTx, retiring the older NewRPCTxFromEthTx, and centralizing signer and signature‑value extraction. Refactor BackendSuite tests to use a SuccessfulTx map for structured receipt capture—eliminating global variables and improving setup clarity. Stub out unimplemented debugapi methods with context‑aware signatures and adjust filters, tracing, and utils to inline BlockBloom usage and align imports (e.g. eip1559, tracers) with modern patterns. * chore: changelog PR number --------- Signed-off-by: Unique-Divine <[email protected]> Co-authored-by: Tomass <[email protected]> Co-authored-by: tsinghuacoder <[email protected]> Co-authored-by: Dmitry <[email protected]>
1 parent fc902e2 commit 20327b4

File tree

171 files changed

+1181
-1152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1181
-1152
lines changed

.golangci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ linters:
1212
enable:
1313
- whitespace
1414
- goimports
15+
- importas
16+
disable:
17+
- typecheck
1518
linters-settings:
1619
misspell:
1720
locale: US
@@ -23,5 +26,34 @@ linters-settings:
2326
rules:
2427
- name: exported
2528
disabled: true
29+
importas:
30+
# no-unaliased: Forces the use of the specified alias
31+
no-unaliased: true
32+
# Disallows the use of aliases not specified by the linter.
33+
no-extra-aliases: false
34+
alias:
35+
- pkg: github.com/pkg/errors
36+
alias: pkgerrors
37+
- pkg: cosmossdk.io/errors
38+
alias: sdkioerrors
39+
- pkg: github.com/cosmos/cosmos-sdk/types/errors
40+
alias: sdkerrors
41+
- pkg: cosmossdk.io/math
42+
alias: sdkmath
43+
- pkg: github.com/cosmos/cosmos-sdk/types
44+
alias: sdk
45+
- pkg: github.com/cometbft/cometbft/rpc/core
46+
alias: cmtrpccoretypes
47+
- pkg: github.com/cometbft/cometbft/rpc/client
48+
alias: cmtrpcclient
49+
- pkg: github.com/cometbft/cometbft/config
50+
alias: cmtcfg
51+
- pkg: github.com/cometbft/cometbft/libs/cli
52+
alias: cmtcli
53+
- pkg: github.com/cometbft/cometbft/libs/rand
54+
alias: cmtrand
55+
- pkg: github.com/cometbft/cometbft/types
56+
alias: cmttypes
57+
2658
severity:
2759
default-severity: error

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ to geth v1.14 with tracing updates and new StateDB methods.
5353
- [#2278](https://github.com/NibiruChain/nibiru/pull/2278) - chore: migrate to cosmossdk.io/mathLegacyDec and cosmossdk.io/math.Int
5454
- [#2288](https://github.com/NibiruChain/nibiru/pull/2288) - chore(ci): add workflow to check for missing upgrade handler
5555
- [#2289](https://github.com/NibiruChain/nibiru/pull/2289) - fix(eth-rpc): error propagation fixes and tests for the methods exposed by Nibiru's EVM JSON-RPC
56+
- [#2290](https://github.com/NibiruChain/nibiru/pull/2290) - refactor: use importas linter for consistent imports
5657
- [#2292](https://github.com/NibiruChain/nibiru/pull/2292) - fix: use tmp directory for pre-instantiating app
5758
- [#2293](https://github.com/NibiruChain/nibiru/pull/2293) - ci(release): pack nibid binary with no enclosing directory
5859

app/ante/authz_guard.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
package ante
33

44
import (
5-
"cosmossdk.io/errors"
5+
sdkioerrors "cosmossdk.io/errors"
66
sdk "github.com/cosmos/cosmos-sdk/types"
7-
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
7+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
88
"github.com/cosmos/cosmos-sdk/x/authz"
99

1010
"github.com/NibiruChain/nibiru/v2/x/evm"
@@ -22,22 +22,22 @@ func (rmd AnteDecoratorAuthzGuard) AnteHandle(
2222
// Do not allow grant for MsgEthereumTx
2323
if msgGrant, ok := msg.(*authz.MsgGrant); ok {
2424
if msgGrant.Grant.Authorization == nil {
25-
return ctx, errors.Wrapf(
26-
errortypes.ErrInvalidType,
25+
return ctx, sdkioerrors.Wrapf(
26+
sdkerrors.ErrInvalidType,
2727
"grant authorization is missing",
2828
)
2929
}
3030
authorization, err := msgGrant.Grant.GetAuthorization()
3131
if err != nil {
32-
return ctx, errors.Wrapf(
33-
errortypes.ErrInvalidType,
32+
return ctx, sdkioerrors.Wrapf(
33+
sdkerrors.ErrInvalidType,
3434
"failed unmarshaling generic authorization %s", err,
3535
)
3636
}
3737
if genericAuth, ok := authorization.(*authz.GenericAuthorization); ok {
3838
if genericAuth.MsgTypeURL() == sdk.MsgTypeURL(&evm.MsgEthereumTx{}) {
39-
return ctx, errors.Wrapf(
40-
errortypes.ErrNotSupported,
39+
return ctx, sdkioerrors.Wrapf(
40+
sdkerrors.ErrNotSupported,
4141
"authz grant generic for msg type %s is not allowed",
4242
genericAuth.MsgTypeURL(),
4343
)
@@ -48,15 +48,15 @@ func (rmd AnteDecoratorAuthzGuard) AnteHandle(
4848
if msgExec, ok := msg.(*authz.MsgExec); ok {
4949
msgsInExec, err := msgExec.GetMessages()
5050
if err != nil {
51-
return ctx, errors.Wrapf(
52-
errortypes.ErrInvalidType,
51+
return ctx, sdkioerrors.Wrapf(
52+
sdkerrors.ErrInvalidType,
5353
"failed getting exec messages %s", err,
5454
)
5555
}
5656
for _, msgInExec := range msgsInExec {
5757
if _, ok := msgInExec.(*evm.MsgEthereumTx); ok {
58-
return ctx, errors.Wrapf(
59-
errortypes.ErrInvalidType,
58+
return ctx, sdkioerrors.Wrapf(
59+
sdkerrors.ErrInvalidType,
6060
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
6161
)
6262
}

app/ante/commission.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package ante
22

33
import (
4-
"cosmossdk.io/math"
4+
sdkmath "cosmossdk.io/math"
55
sdk "github.com/cosmos/cosmos-sdk/types"
66
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
77
)
88

9-
func MAX_COMMISSION() math.LegacyDec { return math.LegacyMustNewDecFromStr("0.25") }
9+
func MAX_COMMISSION() sdkmath.LegacyDec { return sdkmath.LegacyMustNewDecFromStr("0.25") }
1010

1111
var _ sdk.AnteDecorator = (*AnteDecoratorStakingCommission)(nil)
1212

app/ante/commission_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ante_test
22

33
import (
4-
"cosmossdk.io/math"
4+
sdkmath "cosmossdk.io/math"
55
sdkclienttx "github.com/cosmos/cosmos-sdk/client/tx"
66
sdk "github.com/cosmos/cosmos-sdk/types"
77
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -30,17 +30,17 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
3030
}
3131

3232
valAddr := sdk.ValAddress(testutil.AccAddress()).String()
33-
commissionRatePointer := new(math.LegacyDec)
34-
*commissionRatePointer = math.LegacyNewDecWithPrec(10, 2)
33+
commissionRatePointer := new(sdkmath.LegacyDec)
34+
*commissionRatePointer = sdkmath.LegacyNewDecWithPrec(10, 2)
3535
happyMsgs := []sdk.Msg{
3636
&stakingtypes.MsgCreateValidator{
3737
Description: mockDescription,
3838
Commission: stakingtypes.CommissionRates{
39-
Rate: math.LegacyNewDecWithPrec(6, 2), // 6%
40-
MaxRate: math.LegacyNewDec(420),
41-
MaxChangeRate: math.LegacyNewDec(420),
39+
Rate: sdkmath.LegacyNewDecWithPrec(6, 2), // 6%
40+
MaxRate: sdkmath.LegacyNewDec(420),
41+
MaxChangeRate: sdkmath.LegacyNewDec(420),
4242
},
43-
MinSelfDelegation: math.NewInt(1),
43+
MinSelfDelegation: sdkmath.NewInt(1),
4444
DelegatorAddress: testutil.AccAddress().String(),
4545
ValidatorAddress: valAddr,
4646
Pubkey: &codectypes.Any{},
@@ -57,12 +57,13 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
5757
createSadMsgs := func() []sdk.Msg {
5858
sadMsgCreateVal := new(stakingtypes.MsgCreateValidator)
5959
*sadMsgCreateVal = *(happyMsgs[0]).(*stakingtypes.MsgCreateValidator)
60-
sadMsgCreateVal.Commission.Rate = math.LegacyNewDecWithPrec(26, 2)
60+
sadMsgCreateVal.Commission.Rate = sdkmath.LegacyNewDecWithPrec(26, 2)
6161

6262
sadMsgEditVal := new(stakingtypes.MsgEditValidator)
6363
*sadMsgEditVal = *(happyMsgs[1]).(*stakingtypes.MsgEditValidator)
64-
newCommissionRate := new(math.LegacyDec)
65-
*newCommissionRate = math.LegacyNewDecWithPrec(26, 2)
64+
65+
newCommissionRate := new(sdkmath.LegacyDec)
66+
*newCommissionRate = sdkmath.LegacyNewDecWithPrec(26, 2)
6667
sadMsgEditVal.CommissionRate = newCommissionRate
6768

6869
return []sdk.Msg{
@@ -109,8 +110,8 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
109110
} {
110111
s.Run(tc.name, func() {
111112
txGasCoins := sdk.NewCoins(
112-
sdk.NewCoin("unibi", math.NewInt(1_000)),
113-
sdk.NewCoin("utoken", math.NewInt(500)),
113+
sdk.NewCoin("unibi", sdkmath.NewInt(1_000)),
114+
sdk.NewCoin("utoken", sdkmath.NewInt(500)),
114115
)
115116

116117
encCfg := app.MakeEncodingConfig()

app/ante/errors.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package ante
22

33
import (
4-
sdkerrors "cosmossdk.io/errors"
5-
"cosmossdk.io/math"
4+
sdkioerrors "cosmossdk.io/errors"
5+
sdkmath "cosmossdk.io/math"
66
)
77

88
var errorCodeIdx uint32 = 1
99

10-
func registerError(errMsg string) *sdkerrors.Error {
10+
func registerError(errMsg string) *sdkioerrors.Error {
1111
errorCodeIdx += 1
12-
return sdkerrors.Register("ante-nibiru", errorCodeIdx, errMsg)
12+
return sdkioerrors.Register("ante-nibiru", errorCodeIdx, errMsg)
1313
}
1414

1515
// app/ante "sentinel" errors
@@ -18,7 +18,7 @@ var (
1818
ErrMaxValidatorCommission = registerError("validator commission rate is above max")
1919
)
2020

21-
func NewErrMaxValidatorCommission(gotCommission math.LegacyDec) error {
21+
func NewErrMaxValidatorCommission(gotCommission sdkmath.LegacyDec) error {
2222
return ErrMaxValidatorCommission.Wrapf(
2323
"got (%s), max rate is (%s)", gotCommission, MAX_COMMISSION())
2424
}

app/ante/fixed_gas.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ante
22

33
import (
4-
sdkerrors "cosmossdk.io/errors"
4+
sdkioerrors "cosmossdk.io/errors"
55
sdk "github.com/cosmos/cosmos-sdk/types"
66

77
oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types"
@@ -37,13 +37,13 @@ func (gd AnteDecoratorEnsureSinglePostPriceMessage) AnteHandle(
3737

3838
if hasOracleVoteMsg && hasOraclePreVoteMsg {
3939
if len(msgs) > 2 {
40-
return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
40+
return ctx, sdkioerrors.Wrap(ErrOracleAnte, "a transaction cannot have more than a single oracle vote and prevote message")
4141
}
4242

4343
ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))
4444
} else if hasOraclePreVoteMsg || hasOracleVoteMsg {
4545
if len(msgs) > 1 {
46-
return ctx, sdkerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
46+
return ctx, sdkioerrors.Wrap(ErrOracleAnte, "a transaction that includes an oracle vote or prevote message cannot have more than those two messages")
4747
}
4848

4949
ctx = ctx.WithGasMeter(NewFixedGasMeter(OracleMessageGas))

app/ante/fixed_gas_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
77

88
sdkioerrors "cosmossdk.io/errors"
9-
"cosmossdk.io/math"
9+
sdkmath "cosmossdk.io/math"
1010
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
1111
"github.com/cosmos/cosmos-sdk/testutil/testdata"
1212
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -240,8 +240,8 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
240240
} else {
241241
suite.NoError(err)
242242
}
243-
want := math.NewInt(int64(tc.expectedGas))
244-
got := math.NewInt(int64(suite.ctx.GasMeter().GasConsumed()))
243+
want := sdkmath.NewInt(int64(tc.expectedGas))
244+
got := sdkmath.NewInt(int64(suite.ctx.GasMeter().GasConsumed()))
245245
suite.Equal(want.String(), got.String())
246246
})
247247
}

app/ante/gas.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ import (
55

66
storetypes "github.com/cosmos/cosmos-sdk/store/types"
77

8-
"github.com/cosmos/cosmos-sdk/types"
8+
sdk "github.com/cosmos/cosmos-sdk/types"
99
)
1010

1111
type fixedGasMeter struct {
12-
consumed types.Gas
12+
consumed sdk.Gas
1313
}
1414

1515
// NewFixedGasMeter returns a reference to a new fixedGasMeter.
16-
func NewFixedGasMeter(fixedGas types.Gas) types.GasMeter {
16+
func NewFixedGasMeter(fixedGas sdk.Gas) sdk.GasMeter {
1717
return &fixedGasMeter{
1818
consumed: fixedGas,
1919
}
2020
}
2121

22-
func (g *fixedGasMeter) GasConsumed() types.Gas {
22+
func (g *fixedGasMeter) GasConsumed() sdk.Gas {
2323
return g.consumed
2424
}
2525

26-
func (g *fixedGasMeter) GasConsumedToLimit() types.Gas {
26+
func (g *fixedGasMeter) GasConsumedToLimit() sdk.Gas {
2727
return g.consumed
2828
}
2929

30-
func (g *fixedGasMeter) Limit() types.Gas {
30+
func (g *fixedGasMeter) Limit() sdk.Gas {
3131
return g.consumed
3232
}
3333

@@ -36,10 +36,10 @@ func (g *fixedGasMeter) GasRemaining() storetypes.Gas {
3636
}
3737

3838
// ConsumeGas is a no-op because the fixed gas meter stays fixed.
39-
func (g *fixedGasMeter) ConsumeGas(types.Gas, string) {}
39+
func (g *fixedGasMeter) ConsumeGas(sdk.Gas, string) {}
4040

4141
// RefundGas is a no-op because the fixed gas meter stays fixed.
42-
func (g *fixedGasMeter) RefundGas(types.Gas, string) {}
42+
func (g *fixedGasMeter) RefundGas(sdk.Gas, string) {}
4343

4444
func (g *fixedGasMeter) IsPastLimit() bool {
4545
return false

app/ante/gas_wanted.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
package ante
33

44
import (
5-
"cosmossdk.io/errors"
5+
sdkioerrors "cosmossdk.io/errors"
66
sdk "github.com/cosmos/cosmos-sdk/types"
7-
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
7+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
88

99
"github.com/NibiruChain/nibiru/v2/eth"
1010
)
@@ -25,8 +25,8 @@ func (gwd AnteDecoratorGasWanted) AnteHandle(
2525
// return error if the tx gas is greater than the block limit (max gas)
2626
blockGasLimit := eth.BlockGasLimit(ctx)
2727
if gasWanted > blockGasLimit {
28-
return ctx, errors.Wrapf(
29-
errortypes.ErrOutOfGas,
28+
return ctx, sdkioerrors.Wrapf(
29+
sdkerrors.ErrOutOfGas,
3030
"tx gas (%d) exceeds block gas limit (%d)",
3131
gasWanted,
3232
blockGasLimit,

0 commit comments

Comments
 (0)