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(invariants): add several invariants across modules #1514

Merged
merged 68 commits into from
Nov 22, 2024

Conversation

danwt
Copy link
Contributor

@danwt danwt commented Nov 19, 2024

Description

Adds hi prio invariants according to https://docs.google.com/spreadsheets/d/1uEvOizwu1RSLoUoQxdp5apVPo61QOKoQBOm4F5y0S9A/edit?gid=0#gid=0
Relevant for #1484


Closes #XXX

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.

x/eibc/keeper/invariants.go Show resolved Hide resolved
x/iro/keeper/invariants.go Show resolved Hide resolved
x/iro/keeper/invariants.go Show resolved Hide resolved
x/sponsorship/keeper/invariants.go Outdated Show resolved Hide resolved
x/sponsorship/keeper/invariants.go Show resolved Hide resolved
x/sponsorship/keeper/invariants.go Outdated Show resolved Hide resolved
x/sequencer/keeper/invariants.go Show resolved Hide resolved
x/sequencer/keeper/invariants.go Show resolved Hide resolved
// check module balance is equal
moduleAcc := k.accountK.GetModuleAccount(ctx, types.ModuleName)
balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress())
if 1 < len(balances) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe len(balances) > 1 is better?
1 < len(balances) broke my brain for a second haha

Copy link
Contributor

Choose a reason for hiding this comment

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

haha the amount of times this style broke my brain also.. 🫠

Copy link
Contributor Author

Choose a reason for hiding this comment

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

broskis
There is some research paper somewhere that says most people prefer the way I do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't you learn in school the numbers start with zero at the left and positive infinity to the right 😄
maybe hebrew is different
But you have no excuse @keruch

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 it's how you read it: left to right. Would you also say "two is less than how many apples I have"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair I guess peoples brains have a different preference, linguistic or spatial, when reading

Copy link
Contributor

Choose a reason for hiding this comment

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

@danwt actually when i saw this if, i also imagined a straight line with numbers increasing to the right. but anyway as Alex pointed out, the other way around sounds more natural (at least to me) when you "read" the code.

x/delayedack/keeper/invariants.go Show resolved Hide resolved
x/delayedack/keeper/invariants.go Show resolved Hide resolved
// check module balance is equal
moduleAcc := k.accountK.GetModuleAccount(ctx, types.ModuleName)
balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress())
if 1 < len(balances) {
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 it's how you read it: left to right. Would you also say "two is less than how many apples I have"?

x/sponsorship/keeper/invariants.go Outdated Show resolved Hide resolved
x/sponsorship/keeper/invariants.go Outdated Show resolved Hide resolved
x/sequencer/keeper/msg_server_create.go Outdated Show resolved Hide resolved
x/eibc/keeper/invariants.go Show resolved Hide resolved
danwt and others added 2 commits November 21, 2024 16:34
@danwt danwt requested a review from zale144 November 21, 2024 16:43
Copy link
Contributor

@keruch keruch left a comment

Choose a reason for hiding this comment

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

LGTM!

@omritoptix omritoptix merged commit 3109e57 into main Nov 22, 2024
9 checks passed
@omritoptix omritoptix deleted the danwt/adds-several-invariants-0000 branch November 22, 2024 10:38
omritoptix pushed a commit that referenced this pull request Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants