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: add invariants to x/foundation #758

Merged
merged 7 commits into from
Oct 26, 2022
Merged

Conversation

0Tech
Copy link
Collaborator

@0Tech 0Tech commented Oct 26, 2022

Description

This patch will add following invariants to x/foundation:

  • ModuleAccountInvariant
    • It checks whether each balances of the module accounts is in a sane state.
      • "treasury": It must be equal to the corresponding value in the pool.
  • TotalWeightInvariant
    • It checks whether the total weight is in a sane state.
      • Each weight of the member is implicitly one, hence the weight must be equal to the number of the members.
  • ProposalInvariant
    • It checks whether each proposal is in a sane state.
      • Old proposals must have been aborted, so they must not be in the submitted state.

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@0Tech 0Tech self-assigned this Oct 26, 2022
@0Tech 0Tech added A: improvement Changes in existing functionality C:x/foundation x/foundation module labels Oct 26, 2022
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #758 (98ec5d5) into main (eb1b5e2) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #758      +/-   ##
==========================================
+ Coverage   62.15%   62.20%   +0.05%     
==========================================
  Files         879      880       +1     
  Lines       99385    99431      +46     
==========================================
+ Hits        61772    61853      +81     
+ Misses      33996    33957      -39     
- Partials     3617     3621       +4     
Impacted Files Coverage Δ
x/foundation/client/testutil/grpc.go 92.50% <ø> (-0.19%) ⬇️
x/foundation/client/testutil/query.go 100.00% <ø> (ø)
simapp/app.go 86.11% <100.00%> (ø)
x/foundation/client/testutil/suite.go 97.66% <100.00%> (-0.03%) ⬇️
x/foundation/keeper/invariants.go 100.00% <100.00%> (ø)
x/token/msgs.go 49.42% <0.00%> (-1.91%) ⬇️
x/foundation/keeper/proposal.go 89.88% <0.00%> (+1.19%) ⬆️
x/collection/msgs.go 55.50% <0.00%> (+3.86%) ⬆️
x/token/validation.go 92.72% <0.00%> (+21.81%) ⬆️

@0Tech 0Tech marked this pull request as ready for review October 26, 2022 05:14
Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

If the invariants is broken, how can we resolve in the chain?

@0Tech
Copy link
Collaborator Author

0Tech commented Oct 26, 2022

If the invariants is broken, how can we resolve in the chain?

Halting the chain is the current short-term solution. The goal of the invariant feature is to prevent ripple effects from the violated invariant. Fixing the cause is not the goal of this feature.

@0Tech 0Tech requested a review from zemyblue October 26, 2022 06:29
@0Tech 0Tech requested a review from zemyblue October 26, 2022 07:00
@0Tech 0Tech merged commit 532154f into Finschia:main Oct 26, 2022
@0Tech 0Tech deleted the foundation_invariant branch October 26, 2022 07:47
@zemyblue zemyblue mentioned this pull request Oct 27, 2022
5 tasks
@zemyblue zemyblue mentioned this pull request Nov 28, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: improvement Changes in existing functionality C:x/foundation x/foundation module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants