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
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 83.92857% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.88%. Comparing base (1544264) to head (7e9c1c2).

Files with missing lines Patch % Lines
ante/cosmos/reject_staking.go 43.75% 9 Missing ⚠️
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      189       +2     
  Lines                15221    15275      +54     
===================================================
+ Hits                  7117     7162      +45     
- Misses                7316     7325       +9     
  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.45% <100.00%> (+0.82%) ⬆️
evmd/app.go 78.64% <100.00%> (+0.23%) ⬆️
ante/cosmos/reject_staking.go 43.75% <43.75%> (ø)
🚀 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 2 times, most recently 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 3 times, most recently from 632f519 to 8b771f4 Compare November 17, 2025 08:22
@socket-security
Copy link

socket-security bot commented Nov 17, 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-20251119105920-c835be462a5d76100100100100

View full report

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 4 times, most recently from d2d7d02 to b338cac Compare November 18, 2025 03:26
Copy link

@JayT106 JayT106 left a comment

Choose a reason for hiding this comment

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

LGTM

@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch 2 times, most recently from 5be42f7 to a2d9338 Compare November 19, 2025 10:39
@randy-cro randy-cro force-pushed the fix/staking-optimization-1.5.x-patch branch from a2d9338 to 7e9c1c2 Compare November 19, 2025 11:14
@randy-cro randy-cro changed the title fix: staking optimization v1.5.x patch fix: staking optimization v1.6.x patch Nov 20, 2025
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