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

Implementation of stake module (which was named staking earlier) #17

Closed
wants to merge 18 commits into from

Conversation

VAIBHAVJINDAL3012
Copy link

@VAIBHAVJINDAL3012 VAIBHAVJINDAL3012 commented Feb 17, 2024

Description

In this PR I have implemented the stake module(which was called staking module earlier).
There are these four txs types supported by this module-
1.MsgValidatorJoin
2.MsgStakeUpdate
3.MsgSignerUpdate
4.MsgValidatorExit

@VAIBHAVJINDAL3012 VAIBHAVJINDAL3012 marked this pull request as ready for review February 17, 2024 18:39
@Raneet10 Raneet10 changed the base branch from main to develop February 22, 2024 10:51
)

// ExponentialBackoff performs exponential backoff attempts on a given action
func ExponentialBackoff(action func() error, max uint, wait time.Duration) error {
Copy link

Choose a reason for hiding this comment

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

What's the purpose of implementing this?

Copy link
Author

Choose a reason for hiding this comment

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

I have removed this helper directory from stake PR and have raised separate PR for it.

)

// FilterEvents filter events by fn
func FilterEvents(events []sdk.StringEvent, fn func(sdk.StringEvent) bool) *sdk.StringEvent {
Copy link

Choose a reason for hiding this comment

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

What's the use case for staking?

Copy link
Author

Choose a reason for hiding this comment

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

It filter out the event emitted by the Heimdall and use the result in the bridge.
I have removed this helper directory from stake PR and have raised separate PR for it.

}
}

// Migrate1to2 migrates from version 1 to 2.
Copy link

Choose a reason for hiding this comment

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

As there's nothing to migrate (first version of the module) there's no reason for these

Copy link
Author

Choose a reason for hiding this comment

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

Okay, Removed the migration file completely.

@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"

"github.com/0xPolygon/heimdall-v2/helper"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's sort the imports.

Copy link
Author

Choose a reason for hiding this comment

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

What to sort here?

@@ -116,7 +117,8 @@ type App struct {
ParamsKeeper paramskeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

// Custom Keepers
// contract keeper
Copy link
Contributor

Choose a reason for hiding this comment

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

you mean contract caller? Anyway not a useful comment, I'd remove it.

@@ -297,6 +299,18 @@ func NewApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

//
// Contract caller
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this useless comments section.


// contractCallerObj, err := helper.NewContractCaller()
// if err != nil {
// cmn.Exit(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

cmn exit?

@@ -0,0 +1,249 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

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

The contacts are already merged to develop right? Let's remove them from this PR.
Please find my comments in the relative PR.

indent)
}

//-------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these useless separators

valz[j] = it
}

///////////////////////////////////////////////////////////////////////////////
Copy link
Contributor

Choose a reason for hiding this comment

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

remove these useless separators

vals.Validators = merged[:i]
}

// Checks that the validators to be removed are part of the validator set.
Copy link
Contributor

Choose a reason for hiding this comment

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

Start the comment with the function's name

@@ -0,0 +1,134 @@
package types

// import (
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is everything commented out?
In case this can't be tested jut yet, please, leave a TODO HV2 with such reasons, and some info on how/when to re-enable it.
Also, use multiline comments.

x/types/vote.go Outdated
type Vote int32

const (
// TODO HV2: should we have an UNSPECIFIED value 0 tag as suggested here: https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think we should.

@marcello33
Copy link
Contributor

Left some comments to be addressed.
Please, submit a PR where code compile and tests can be executed.
Also, please solve conflicts.

@@ -0,0 +1,703 @@
package types
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe package types should go outside x
Also, please use naming conventions for this file, e.g. validator_set.go

Copy link

Choose a reason for hiding this comment

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

yes, chain level types should be defined outside of x/, and then each module will have its own types directory

rpc StakingSequence(QueryStakingSequenceRequest)
returns (QueryStakingSequenceResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/staking/isOldTx";
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is defined all as lower case in original heimdall, as in isoldtx.
Let's make sure we don't break API compatibility with v1

@marcello33
Copy link
Contributor

Closing in favour of #39

@marcello33 marcello33 closed this Apr 18, 2024
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.

3 participants