From 2988caeb4eff57068253d1051cc2815a1a81c4a1 Mon Sep 17 00:00:00 2001 From: sampocs Date: Sun, 17 Sep 2023 21:35:02 -0500 Subject: [PATCH] added cap on undelegate messages (#940) Closes: #XXX ## Context and purpose of the change ## Brief Changelog ## Author's Checklist I have... - [ ] Run and PASSED locally all GAIA integration tests - [ ] If the change is contentful, I either: - [ ] Added a new unit test OR - [ ] Added test cases to existing unit tests - [ ] OR this change is a trivial rework / code cleanup without any test coverage If skipped any of the tests above, explain. ## Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] manually tested (if applicable) - [ ] confirmed the author wrote unit tests for new logic - [ ] reviewed documentation exists and is accurate ## Documentation and Release Note - [ ] Does this pull request introduce a new feature or user-facing behavior changes? - [ ] Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? - [ ] This pull request updates existing proto field values (and require a backend and frontend migration)? - [ ] Does this pull request change existing proto field names (and require a frontend migration)? How is the feature or change documented? - [ ] not applicable - [ ] jira ticket `XXX` - [ ] specification (`x//spec/`) - [ ] README.md - [ ] not documented --- x/stakeibc/keeper/unbonding_records.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/stakeibc/keeper/unbonding_records.go b/x/stakeibc/keeper/unbonding_records.go index 21e6100ea7..0b76d4f5d9 100644 --- a/x/stakeibc/keeper/unbonding_records.go +++ b/x/stakeibc/keeper/unbonding_records.go @@ -301,6 +301,10 @@ func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) err return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Target unbonded amount was 0 for each validator") } + if len(msgs) > UndelegateICABatchSize { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, fmt.Sprintf("too many undelegation messages (%d) for host zone %s", len(msgs), hostZone.ChainId)) + } + // Send the messages in batches so the gas limit isn't exceedeed for start := 0; start < len(msgs); start += UndelegateICABatchSize { end := start + UndelegateICABatchSize