Skip to content

Conversation

@zeroprooff
Copy link
Contributor

hey team! I found duplicate words and fixed them.

@zeroprooff zeroprooff requested a review from a team as a code owner April 18, 2025 18:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

📝 Walkthrough

Walkthrough

This update addresses minor typographical errors in documentation files. Specifically, it removes duplicated words in a changelog entry and in a code comment within a markdown file. No changes to code logic, structure, or public interfaces are included.

Changes

File(s) Change Summary
LEGACY-CHANGELOG.md Corrected a duplicated word ("set set" → "set") in a changelog entry.
x/evm/embeds/HACKING.md Fixed a duplicated word ("be be" → "be") in a NatSpec comment example.

Poem

A typo here, a typo there—
With gentle paws, I fix with care.
No code disturbed, just words made neat,
Documentation now complete!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f34e6fd and 1fa696a.

📒 Files selected for processing (2)
  • LEGACY-CHANGELOG.md (1 hunks)
  • x/evm/embeds/HACKING.md (1 hunks)
🔇 Additional comments (2)
LEGACY-CHANGELOG.md (1)

219-219: Typographical correction: removed duplicate 'set'
The changelog entry previously contained “to set set desired Tendermint consensus params…”, which has been cleaned up to “to set desired Tendermint consensus params…”.

x/evm/embeds/HACKING.md (1)

49-49: Typographical correction: removed duplicate 'be'
The NatSpec comment originally read “to be be passed on to the hook” and now correctly reads “to be passed on to the hook”.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Unique-Divine Unique-Divine changed the base branch from main to ud/geth/v1.13.15 April 19, 2025 20:44
@Unique-Divine Unique-Divine merged commit 2d82c81 into NibiruChain:ud/geth/v1.13.15 Apr 19, 2025
1 check passed
Unique-Divine added a commit that referenced this pull request Apr 21, 2025
…LE_ADDRS, and transient storage support (#2274)

* 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]>

* 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: tsinghuacoder <[email protected]>
Co-authored-by: Tomass <[email protected]>
Co-authored-by: tsinghuacoder <[email protected]>
Co-authored-by: Kevin Yang <[email protected]>
Co-authored-by: Dmitry <[email protected]>
Unique-Divine added a commit that referenced this pull request Apr 22, 2025
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants