Skip to content

refactor: Cover medium items - #10

Merged
sontrinh16 merged 2 commits into
auditfrom
son/cover_medium_low_items
Sep 21, 2026
Merged

sontrinh16 merged 2 commits into
auditfrom
son/cover_medium_low_items

Conversation

@sontrinh16

Copy link
Copy Markdown

Summary

Address medium-severity audit findings related to state consistency, validation, query safety, and parameter error handling.

Changes

  • Prevent partial multi-staking state updates during redelegation and undelegation:
    • Persist source and destination locks only after stakingMsgServer.BeginRedelegate succeeds.
    • Persist lock and unlock records only after staking undelegation succeeds.
    • Preserve existing lock state when staking returns an error or panics in a non-cached context.
  • Strengthen MultiStakingCoin.Validate:
    • Reject zero and negative amounts.
    • Reject invalid denominations.
    • Continue rejecting zero and negative bond weights.
  • Validate unlocking coins before converting unbonded amounts, preventing invalid bond weights from reaching division logic.
  • Reject nil requests in the validators gRPC query.
  • Update GetParams to return errors for:
    • Store read failures.
    • Missing parameter data.
    • Parameter decoding failures.
  • Update the expected staking keeper interface and all affected callers for the new GetParams signature.

Testing

Added regression coverage for:

  • Redelegation failures preserving source and destination lock state.
  • Undelegation failures preserving lock state and avoiding unlock creation.
  • Valid, zero, and negative multi-staking amounts.
  • Valid and invalid denominations.
  • Missing, malformed, and unreadable parameter data.

@sontrinh16
sontrinh16 requested a review from hieuvubk September 18, 2026 05:39

@hieuvubk hieuvubk left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm!
Let take a final review before merge. New commit pushed 7400cea.

It fix CancelUnbonding rounding error with bond_weight < 1. Currently we all use weight 1 => not exploited but worth to fix

@hieuvubk

Copy link
Copy Markdown

cc @sontrinh16

@sontrinh16
sontrinh16 marked this pull request as ready for review September 21, 2026 06:10
@sontrinh16
sontrinh16 merged commit 9ac7728 into audit Sep 21, 2026
4 checks passed
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