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

fix: Global min Self Delegation #134

Merged
merged 21 commits into from
Apr 13, 2022
Merged

Conversation

AlpinYukseloglu
Copy link

@AlpinYukseloglu AlpinYukseloglu commented Mar 7, 2022

Closes: #113

What is the purpose of the change

Our current implementation of Superfluid Staking exposes the chain to a specific vulnerability relating to the validator creation process. This PR adds the necessary guardrails to make sure that an attacker cannot halt the chain by generating an arbitrary number of empty validators.

This was not an issue prior to Superfluid Staking because the full validator set was not used in the ante anywhere, but our specific implementation of Superfluid introduced a linear-time search of the validator set at epoch end that made the issue fixed in this PR a vulnerability.

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

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

Would it be able to add tests for this change?(genesis_test, params_test in sim etc)

Also, how does this param enforce validators to have min_self_delegation?

x/staking/legacy/v040/migrate.go Outdated Show resolved Hide resolved
AlpinYukseloglu and others added 3 commits March 10, 2022 08:09
…east the provided MinSelfDelegation (#132)

* add check to make sure validator object is only created if min delegation threshold is met

* fix check location and use standard error type

* fix logic for check

* add test for new check

* update test comments for better context
@ValarDragon ValarDragon changed the base branch from v0.45.0x-osmo-v7 to v0.45.0x-osmo-v8 March 14, 2022 15:57
docs/core/proto-docs.md Outdated Show resolved Hide resolved
@ValarDragon
Copy link
Member

ValarDragon commented Mar 15, 2022

@AlpinYukseloglu you have to update the GetParams queries for the new field in the param struct before merge.

To test locally, inside of x/staking do go test ./..., the query tests should fail.

@ValarDragon
Copy link
Member

@AlpinYukseloglu
Copy link
Author

https://github.com/osmosis-labs/cosmos-sdk/runs/5564114018?check_suite_focus=true

still failing

Interesting... local tests seem to be passing (go test ./... in x/staking and then also in its parent folders) except for when I do it in the highest folder (cosmos-sdk), in which case the handful of tests that fail are all ledger-related ("support for ledger devices is not available in this executable"). Am I testing incorrectly @ValarDragon?

@github-actions github-actions bot added the C:CLI label Mar 21, 2022
@mattverse
Copy link
Member

FYI: The Rosetta test was broken in the main sdk branch as well

@mattverse mattverse requested review from mattverse and removed request for ValarDragon March 25, 2022 11:33
Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

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

Actually, it seems that something in this PR does seem to break the rosetta-test that needs further investigation on fixes. Also, by a brief look, it seems that the "build" action might be failing due to changes in go.sum, can you revert go.sum into the original state?

@ValarDragon
Copy link
Member

TODO: Ask in cosmos SDK discord how rosetta tests work / how to debug this failure.

If theres a genesis file somewhere for Rosetta, we did break it / would have to update it for this PR

@alexanderbez
Copy link
Collaborator

Frojdi told me to look at this function:

// ToRosetta attempts to converting an error into a rosetta
// error, if the error cannot be converted it will be parsed as unknown
func ToRosetta(err error) *types.Error {
    if err == nil {
        return nil
    }
    // if it's null or not known
    rosErr, ok := err.(*Error)
    if !ok {
        return ToRosetta(WrapError(ErrUnknown, err.Error()))
    }
    return rosErr.rosErr
}

I think we need to log err in the beginning of the function to get better insight into what's going on.

@AlpinYukseloglu AlpinYukseloglu changed the base branch from v0.45.0x-osmo-v8 to osmosis-main April 4, 2022 15:38
AlpinYukseloglu and others added 5 commits April 7, 2022 08:10
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Copy link
Collaborator

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀

x/staking/keeper/msg_server.go Outdated Show resolved Hide resolved
x/staking/keeper/msg_server.go Outdated Show resolved Hide resolved
x/staking/keeper/msg_server.go Outdated Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@ValarDragon ValarDragon merged commit 7a06fb2 into osmosis-main Apr 13, 2022
@ValarDragon ValarDragon deleted the global-min-selfdelegation branch April 13, 2022 18:58
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.

Add a global Minimum self delegation
4 participants