Skip to content

Add gas converter to mitigate precisebank deprecation#326

Open
Eric-Warehime wants to merge 2 commits into
mainfrom
eric/pbank
Open

Add gas converter to mitigate precisebank deprecation#326
Eric-Warehime wants to merge 2 commits into
mainfrom
eric/pbank

Conversation

@Eric-Warehime

Copy link
Copy Markdown
Contributor

Adds an example of how to mitigate the deprecation of precisebank.

@mintlify

mintlify Bot commented Jul 7, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
cosmos-docs 🟢 Ready View Preview Jul 7, 2026, 8:40 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@Eric-Warehime Eric-Warehime requested review from aljo242 and evanorti July 7, 2026 20:38
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new EVM migration guide for replacing x/precisebank. The main changes are:

  • New gas-converter migration pages for latest and next.
  • Navigation entries under the EVM Migrations group in docs.json.
  • Cross-links from the v0.6-to-v0.7 migration guide.
  • A work-log entry for the documentation update.

Confidence Score: 4/5

The example code snippets need fixes before merging.

  • UnderlyingDenom is referenced but never defined, so copied code fails to compile.
  • The ante decorator can panic on an empty transaction.
  • The remaining issues are smaller documentation and initialization hardening fixes.

evm/latest/documentation/migrations/gas-converter-migration.mdx and evm/next/documentation/migrations/gas-converter-migration.mdx

Security Review

The added guide is documentation-only, but its ante-handler example includes a reachable empty-transaction panic if copied into an app.

Important Files Changed

Filename Overview
docs.json Registers the new migration page under both EVM latest and next.
evm/latest/documentation/migrations/gas-converter-migration.mdx Adds the main migration guide and example code, with compile and ante-handler issues in the snippets.
evm/next/documentation/migrations/gas-converter-migration.mdx Mirrors the latest guide and is missing the expected next-page canonical metadata.
evm/latest/documentation/migrations/migration-v0.6-to-v0.7.mdx Adds a version-correct link to the new latest migration page.
evm/next/documentation/migrations/migration-v0.6-to-v0.7.mdx Adds a version-correct link to the new next migration page.
work-log/bstm-example-pr.md Records the added page, navigation registration, cross-link, and warning callout.

Reviews (1): Last reviewed commit: "Add gas converter to mitigate preciseban..." | Re-trigger Greptile

Comment on lines +57 to +62
const (
ModuleName = "gasconverter"
PrecompileAddress = "0x0000000000000000000000000000000000000900" // stock set ends at 0x807
)

var ScalingFactor = math.NewInt(1_000_000_000_000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Underlying Denom Is Undefined

The later fee-checker and mempool snippets use gasconverter.UnderlyingDenom, but this package example only defines ModuleName, PrecompileAddress, and ScalingFactor. Copying the example as written fails to compile at the AmountOf and SpendableCoin call sites.

Suggested change
const (
ModuleName = "gasconverter"
PrecompileAddress = "0x0000000000000000000000000000000000000900" // stock set ends at 0x807
)
var ScalingFactor = math.NewInt(1_000_000_000_000)
const (
ModuleName = "gasconverter"
UnderlyingDenom = "ustake"
PrecompileAddress = "0x0000000000000000000000000000000000000900" // stock set ends at 0x807
)
var ScalingFactor = math.NewInt(1_000_000_000_000)

Context Used: CLAUDE.md (source)

Comment on lines +146 to +149
_, ethTx, err := evmtypes.UnpackEthMsg(tx.GetMsgs()[0])
if err != nil || !isDepositTx(ethTx) { // to == PrecompileAddress && selector == deposit && value == 0
return next(ctx, tx, simulate)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Empty Tx Panics Ante

This decorator handles every transaction before forwarding non-deposit transactions, but it indexes tx.GetMsgs()[0] before checking the message count. An empty Cosmos SDK tx can panic during ante handling instead of falling through or returning a normal error, which can crash the affected CheckTx or DeliverTx path.

Suggested change
_, ethTx, err := evmtypes.UnpackEthMsg(tx.GetMsgs()[0])
if err != nil || !isDepositTx(ethTx) { // to == PrecompileAddress && selector == deposit && value == 0
return next(ctx, tx, simulate)
}
msgs := tx.GetMsgs()
if len(msgs) == 0 {
return next(ctx, tx, simulate)
}
_, ethTx, err := evmtypes.UnpackEthMsg(msgs[0])
if err != nil || !isDepositTx(ethTx) { // to == PrecompileAddress && selector == deposit && value == 0
return next(ctx, tx, simulate)
}

Context Used: CLAUDE.md (source)


// blocklist — module accounts are blocked via maccPerms; block the precompile
// address too, alongside the stock precompiles.
blockedPrecompilesHex := append(vmtypes.AvailableStaticPrecompiles, gasconverter.PrecompileAddress)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Shared Precompile Slice Mutates

This append uses vmtypes.AvailableStaticPrecompiles directly, unlike the cloned active-precompile list above. If the stock slice has spare capacity, the append writes the gas-converter address into the shared backing array, so later app setup or tests can observe a modified stock precompile set.

Suggested change
blockedPrecompilesHex := append(vmtypes.AvailableStaticPrecompiles, gasconverter.PrecompileAddress)
blockedPrecompilesHex := append(slices.Clone(vmtypes.AvailableStaticPrecompiles), gasconverter.PrecompileAddress)

Context Used: CLAUDE.md (source)

Comment thread evm/next/documentation/migrations/gas-converter-migration.mdx
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@evanorti evanorti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Made a small commit to add frontmatter in /next

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