Commit 1834a61
committed
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.1 parent 6370b96 commit 1834a61
File tree
23 files changed
+1282
-237
lines changed- app
- x/evm
- evmtest
- keeper
- precompile
- statedb
23 files changed
+1282
-237
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments