Skip to content
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): delayedack invariant for finalized and reverted packets #686

Merged
merged 28 commits into from
Mar 28, 2024

Conversation

srene
Copy link
Contributor

@srene srene commented Mar 18, 2024

Description

This PRs adds a new invariant that checks all IBC rollapp packets stored for the delayedack module for a finalized height are also in finalized status

Closes #672

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...

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Updated the scripts for local run, e.g genesis_config_commands.sh if the PR changes parameters
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here

----;

For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

---;

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

@srene srene requested a review from a team as a code owner March 18, 2024 11:00
@srene srene marked this pull request as draft March 18, 2024 11:00
Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 87.65432% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 31.37%. Comparing base (9a27004) to head (8cf9da0).
Report is 23 commits behind head on main.

Files Patch % Lines
x/delayedack/keeper/invariants.go 91.78% 3 Missing and 3 partials ⚠️
testutil/keeper/delayedack.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #686      +/-   ##
==========================================
+ Coverage   30.69%   31.37%   +0.68%     
==========================================
  Files         227      234       +7     
  Lines       32052    32661     +609     
==========================================
+ Hits         9837    10248     +411     
- Misses      20653    20781     +128     
- Partials     1562     1632      +70     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@omritoptix omritoptix changed the title feat: new delayedack invariant for finalized packets feat: delayedack invariant for finalized packets Mar 18, 2024
@srene srene changed the title feat: delayedack invariant for finalized packets feat: delayedack invariant for finalized and reverted packets Mar 18, 2024
@srene srene force-pushed the srene/672-finalized-rollapp-packets-invariant branch from 5338daa to 106dfd1 Compare March 18, 2024 17:49
@srene srene marked this pull request as ready for review March 18, 2024 18:20
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/types/rollapp_packet.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
@srene srene marked this pull request as draft March 22, 2024 09:20
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

I've just some questions to double check things, and improve some readability

x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
Comment on lines 51 to 52
ProofHeight: uint64(rollappBlocks[rollapp] + k),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this proof height right?
If it is, please comment above, it's hard to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment added

// send state updates
var lastHeight uint64 = 0

sequence := uint64(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you could move this inside the rollapp-wise loop? Maybe it doesn't matter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sequence should be per packet, so i think is ok outside

Comment on lines 63 to 64
lastHeight = lastHeight + numOfBlocks
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a little confusing to have a last height across all rollapps, rather than rollapp-wise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lastheight has been removed because it was not really necessary

x/delayedack/keeper/invariants_test.go Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants_test.go Show resolved Hide resolved
@srene srene marked this pull request as ready for review March 22, 2024 10:47
@srene srene requested a review from danwt March 24, 2024 07:11
@mtsitrin mtsitrin removed their assignment Mar 24, 2024
@omritoptix omritoptix changed the title feat: delayedack invariant for finalized and reverted packets feat(delayedack): delayedack invariant for finalized and reverted packets Mar 25, 2024
danwt
danwt previously approved these changes Mar 26, 2024
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

nice work


func (suite *DelayedAckTestSuite) TestInvariants() {
suite.SetupTest()
initialheight := int64(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

initialHeight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

suite.Require().NoError(err)
for k := uint64(1); k <= numOfBlocks; k++ {
// calculating a different proof height incrementing a block height for each new packet
proofheight := rollappBlocks[rollapp] + k
Copy link
Contributor

Choose a reason for hiding this comment

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

proofHeight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 77 to 78
msg, bool := keeper.AllInvariants(suite.App.DelayedAckKeeper)(suite.Ctx)
suite.Require().False(bool, msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
msg, bool := keeper.AllInvariants(suite.App.DelayedAckKeeper)(suite.Ctx)
suite.Require().False(bool, msg)
msg, fails := keeper.AllInvariants(suite.App.DelayedAckKeeper)(suite.Ctx)
suite.Require().False(bool, fails)

bool collides

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i guess you meant to replace bool by fails

@omritoptix omritoptix assigned srene and unassigned omritoptix and danwt Mar 26, 2024
x/rollapp/types/state_info.go Outdated Show resolved Hide resolved
x/delayedack/keeper/invariants.go Outdated Show resolved Hide resolved
@srene srene requested a review from mtsitrin March 27, 2024 17:30
@mtsitrin mtsitrin merged commit cecb03c into main Mar 28, 2024
17 of 26 checks passed
@mtsitrin mtsitrin deleted the srene/672-finalized-rollapp-packets-invariant branch March 28, 2024 07:16
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.

Add invariant that all IBC rollapp packets for a finalized and revert state check
4 participants