-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(delayedack): paginate rollapp packets when deleting them #972
Conversation
Closes what issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Biggest open question I have is, there are several calls to ListRollappPackets in our code and after this PR not all of them are batched with a limit
So why can't memory problems occur at one of those places?
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal | ||
// must have written, in order for the state migration to go smoothly. | ||
// An upgrade must implement this struct, and then set it in the app.go. | ||
// The app.go will then define the handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously it defines a struct, dont need to say that
expPass bool | ||
}{ | ||
{ | ||
"Test that upgrade does not panic and sets correct parameters", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont need 'test that'
In general you dont need to repeat contextually obvious info all the time
@@ -135,6 +135,10 @@ func (suite *DelayedAckTestSuite) TestListRollappPackets() { | |||
revertedPackets := keeper.ListRollappPackets(ctx, types.ByStatus(commontypes.Status_REVERTED)) | |||
suite.Require().Equal(expectRevertedLength, len(revertedPackets)) | |||
|
|||
expectRevertedLengthLimit := 4 | |||
revertedPacketsLimit := keeper.ListRollappPackets(ctx, types.ByStatus(commontypes.Status_REVERTED).Take(4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 hardcoded in Take()
func (f RollappPacketListFilter) Take(limit int) RollappPacketListFilter { | ||
f.Limit = limit | ||
return f | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beaut ❤️
The scope of this PR is to address the potential DoS when deleting the finalized and reverted packets |
afe1b39
to
d565784
Compare
The task is really to fix the DOS, the one in after epoch is just an example. If you think it should be broken down into multiple PRs then create issues to fix the other places. I don't see why adding a limit to after epoch solves the problem when the grpc queries and FinalizeRollappPackets still do everything unlimited? Also, some of the naming is still sloppy IMO and the keepers/ module is unwarranted |
The FinalizeRollappPackets issue is tracked separately and will be addressed in another PR. For this one, it's just preventing out of bonds memory use. |
x/delayedack/keeper/hooks.go
Outdated
|
||
for _, packet := range toDeletePackets { | ||
// copy 'packet' not needed since Go 1.22 | ||
_ = osmoutils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's log any case of deletion error
x/delayedack/types/params.go
Outdated
) | ||
|
||
const ( | ||
defaultEpochIdentifier = "hour" | ||
defaultEpochIdentifier = "hour" | ||
defaultDeletePacketBatchSize = 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default valuie should be much higher IMO
the goal of this value is to be PROTECTION against memory exhasution, not optimization tuning
x/delayedack/keeper/hooks.go
Outdated
e.Logger(ctx).Debug("Deleting rollapp packets", "num_packets", len(toDeletePackets)) | ||
|
||
for _, packet := range toDeletePackets { | ||
// copy 'packet' not needed since Go 1.22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is irrelevant
@zale144 as discussed
@danwt u right regarding the finalization and queries
|
app/app.go
Outdated
|
||
v3upgrade "github.com/dymensionxyz/dymension/v3/app/upgrades/v3" | ||
) | ||
/* ---------------------------- upgrade handlers ---------------------------- */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seperator is misplaced
Description
Closes #320
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.
PR review checkboxes:
I have...
Unreleased
section inCHANGELOG.md
godoc
commentsSDK Checklist
map
time.Now()
sendCoin
and notSendCoins
Full security checklist here
----;
For Reviewer:
---;
After reviewer approval: