Add gas converter to mitigate precisebank deprecation#326
Add gas converter to mitigate precisebank deprecation#326Eric-Warehime wants to merge 2 commits into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Greptile SummaryThis PR adds a new EVM migration guide for replacing
Confidence Score: 4/5The example code snippets need fixes before merging.
evm/latest/documentation/migrations/gas-converter-migration.mdx and evm/next/documentation/migrations/gas-converter-migration.mdx
|
| 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
| const ( | ||
| ModuleName = "gasconverter" | ||
| PrecompileAddress = "0x0000000000000000000000000000000000000900" // stock set ends at 0x807 | ||
| ) | ||
|
|
||
| var ScalingFactor = math.NewInt(1_000_000_000_000) |
There was a problem hiding this comment.
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.
| 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)
| _, ethTx, err := evmtypes.UnpackEthMsg(tx.GetMsgs()[0]) | ||
| if err != nil || !isDepositTx(ethTx) { // to == PrecompileAddress && selector == deposit && value == 0 | ||
| return next(ctx, tx, simulate) | ||
| } |
There was a problem hiding this comment.
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.
| _, 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) |
There was a problem hiding this comment.
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.
| blockedPrecompilesHex := append(vmtypes.AvailableStaticPrecompiles, gasconverter.PrecompileAddress) | |
| blockedPrecompilesHex := append(slices.Clone(vmtypes.AvailableStaticPrecompiles), gasconverter.PrecompileAddress) |
Context Used: CLAUDE.md (source)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
evanorti
left a comment
There was a problem hiding this comment.
LGTM. Made a small commit to add frontmatter in /next
Adds an example of how to mitigate the deprecation of precisebank.