Skip to content

Conversation

@randy-cro
Copy link

@randy-cro randy-cro commented Nov 13, 2025

Description

This patch introduces a fixed gas consumption decorator in the antehandler to standardize gas usage for whitelisted messages.
Currently, only staking-related messages are included in the whitelist.

⚠️ Version Note:
As this is a v1.5 patch, all staking-related operations will be rejected at the antehandler level.
This serves as a warning for node operators about potential AppHash mismatches if inconsistent gas consumption is detected.


Purpose

This ensures consistent gas consumption across all nodes, regardless of variations in staking cache size.
By normalizing gas usage, it prevents potential AppHash mismatches caused by node-specific performance differences.

Implementation Details

  • A fixed gas amount is assigned per whitelisted message type.
  • The values are derived from the average gas usage observed on mainnet.

For example, the mean gas used for MsgUndelegate can be referenced here:
Mainnet reference

This change works in tandem with the staking cache introduced in the Cosmos SDK:
crypto-org-chain/cosmos-sdk#1733


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@randy-cro randy-cro requested a review from a team as a code owner November 13, 2025 07:39
@randy-cro randy-cro requested review from JayT106 and songgaoye and removed request for a team November 13, 2025 07:39
@randy-cro randy-cro changed the title fix:staking optimization fix: staking optimization Nov 13, 2025
@socket-security
Copy link

socket-security bot commented Nov 13, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​github.com/​randy-cro/​cosmos-sdk@​v0.0.0-20251113072857-fbecd698368d76100100100100

View full report

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.88%. Comparing base (1544264) to head (9220f2d).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##           release/v0.22.x     #779      +/-   ##
===================================================
+ Coverage            46.75%   46.88%   +0.12%     
===================================================
  Files                  187      188       +1     
  Lines                15221    15257      +36     
===================================================
+ Hits                  7117     7153      +36     
  Misses                7316     7316              
  Partials               788      788              
Files with missing lines Coverage Δ
ante/cosmos/fixed_gas.go 100.00% <100.00%> (ø)
evmd/ante/evm_handler.go 100.00% <100.00%> (ø)
evmd/ante/handler_options.go 61.05% <100.00%> (+0.41%) ⬆️
evmd/app.go 78.64% <100.00%> (+0.23%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from ff009f4 to 2cbdd91 Compare November 13, 2025 07:54
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from 2cbdd91 to c404b83 Compare November 13, 2025 08:09
@randy-cro randy-cro changed the title fix: staking optimization fix: staking optimization v1.5.x patch Nov 13, 2025
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from c404b83 to a64e281 Compare November 13, 2025 09:58
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from a64e281 to f373013 Compare November 14, 2025 03:33
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from f373013 to 632f519 Compare November 14, 2025 03:39
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.

1 participant