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

Add check that validator exists before allowing for staking #31

Merged
merged 2 commits into from
Aug 8, 2023

Conversation

KonradStaniec
Copy link
Collaborator

Fixes #20

Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Lgtm! Minor comments:

btcPk, err := response.BtcValidator.BtcPk.ToBTCPK()

if err != nil {
return nil, fmt.Errorf("received malfored btc pk in babylon response: %w", err)
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
return nil, fmt.Errorf("received malfored btc pk in babylon response: %w", err)
return nil, fmt.Errorf("received malformed btc pk in babylon response: %w", err)


resp, err = tm.BabylonClient.QueryValidators(100, 0)
require.NoError(t, err)
// No validators yet
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
// No validators yet
// Should be 1 validator

pop,
)

resp, err = tm.BabylonClient.QueryValidators(100, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can also test QueryValidator here as this is the scope of this PR

Comment on lines 786 to 791
_, err := app.babylonClient.QueryValidator(validatorPk)

if err != nil {
return nil, fmt.Errorf("error querying validator to stake funds to: %w", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be clearer if we wrap this into a method like func (app *StakerApp) validatorExists(valPk *btcec.PublicKey) (bool, error)

@KonradStaniec KonradStaniec merged commit 56b42b3 into main Aug 8, 2023
2 checks passed
@KonradStaniec KonradStaniec deleted the check-validator-exists branch August 8, 2023 07:31
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.

StakeFunds should check whether the btc validator exists
2 participants