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

Introduce invariants in the fungible module #2903

Open
fbac opened this issue Sep 19, 2024 · 1 comment
Open

Introduce invariants in the fungible module #2903

fbac opened this issue Sep 19, 2024 · 1 comment

Comments

@fbac
Copy link
Contributor

fbac commented Sep 19, 2024

Original

This checks is valid but we should think about going further: this is an invariant that should never occur, if it occur it mean something wrong is with the blockchain like ability to mint the ZRC20 in the module

In the future we should look into adding an invariant: https://docs.cosmos.network/v0.46/building-modules/invariants.html

erc20Balance >= minted ZRC20 Cosmos coin

Originally posted by @lumtis in #2860 (comment)

Context

With the introduction of the bank precompile now an arbitrary EOA has the ability to mint cosmos coins by depositting ZRC20 into the bank precompile. There are multiple checks that prevent infinite minting/deposits/withdraw, and in order to extend the security mechanism this is a good use case to introduce invariants.

Goal

Introduce invariants in the fungible module to prevent from attacks and issues related to minting and burning cosmos coins.

An obvious check would be ZRC20 balance >= cosmos coins minted, as if there are more cosmos coin minted than the entire ZRC20 supply there's a problem that would require to stop minting tokens and revert the problem.

@fbac fbac changed the title This is the balanceOf for the ERC20 zrc20 balance in the contract address? Introduce invariants in the fungible module Sep 19, 2024
@fbac fbac mentioned this issue Sep 19, 2024
15 tasks
@kingpinXD
Copy link
Contributor

Consider initially adding a notification through an event or a simple logline before adding the invariant.
Invariant, when broken, might lead to a chain halt. We can easily more the logic into an invarient check after a few iterations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants