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

x/chainmanager: Init types and params #22

Merged
merged 42 commits into from
Mar 20, 2024
Merged

Conversation

Raneet10
Copy link
Member

@Raneet10 Raneet10 commented Mar 4, 2024

Description

This PR initialises types and params for chainmanager module.
To compare changes with current heimdall code see:

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on mumbai
  • I have created new e2e tests into express-cli


// TODO HV2: uncomment when keeper is implemented. We probably don't need invariants
// RegisterInvariants registers the chainmanager module invariants.
// func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
Copy link

Choose a reason for hiding this comment

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

Yeah I'm not sure this will be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, will remove this then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 6b2380d.


// TODO HV2: might not be needed since Route() was previously used in side handler routing
// Route returns the message routing key for the chainmanager module.
// func (AppModule) Route() string {
Copy link

Choose a reason for hiding this comment

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

You shouldn't need this

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 925f939

// TODO HV2: uncomment when keeper is implemented
// InitGenesis performs genesis initialization for the chainmanager module. It returns
// no validator updates.
// func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
Copy link

Choose a reason for hiding this comment

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

Uncomment, see above re: fulfilling expected interfaces

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is uncommented in #23.


// TODO HV2: this is a no-op in current heimdall. Probably no need to implement this
// RegisterStoreDecoder registers a decoder for chainmanager module's types
// func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
Copy link

Choose a reason for hiding this comment

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

Would only need this for simulation

// TODO HV2: this is a no-op in current heimdall. Probably no need to implement this
// looks equivalent to https://github.com/maticnetwork/heimdall/blob/249aa798c2f23c533d2421f2101127c11684c76e/chainmanager/module.go#L161C18-L161C34
// ProposalMsgs returns msgs used for governance proposals for simulations.
// func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
Copy link

Choose a reason for hiding this comment

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

This is a gov module method for simulations, you don't need this in chain manager

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, will remove in the simulation PR.

// RegisterLegacyAminoCodec registers the necessary x/chainmanager interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&Params{}, "heimdall-v2/x/bank/Params", nil)
Copy link

Choose a reason for hiding this comment

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

Are there any others that could be included/executed here? I'm curious why a different module's type is registered here...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh that's a typo, my bad.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 9bd1bf1

// error for any failed validation criteria.
func (gs GenesisState) Validate() error {
return nil
}

Choose a reason for hiding this comment

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

Should we add the validation here as now our addresses are string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what you meant here. We originally don't really do any validation.

)

var (
ParamsKey = collections.NewPrefix(0) // ParamsKey is the key to store the params in the store

Choose a reason for hiding this comment

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

What is the major difference between heimdall approach of simply defining the key and by using collection?

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually second the usage of collections, I like its concept (see this @VAIBHAVJINDAL3012)
However: do we need to align any other module/PR?

return AppModule{
// keeper: keeper,
// contractCaller: contractCaller,
legacySubspace: ss,

Choose a reason for hiding this comment

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

Can we also remove it?
Why have you commented out the keeper?

And please remove contractCaller comment also as in chainmanager it doesn't hold any meaning.

Copy link
Contributor

@marcello33 marcello33 left a comment

Choose a reason for hiding this comment

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

Minor comments, else LGTM

@echo "Available targets:"
@echo " lint-deps - Install dependencies for GolangCI-Lint tool."
@echo " lint - Runs the GolangCI-Lint tool on the codebase."

Copy link
Contributor

Choose a reason for hiding this comment

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

This is all imported from @pratikspatil024 PR using the comos-sdk approach, right?

@@ -1,41 +1,52 @@
module github.com/0xPolygon/heimdall-v2

go 1.21.4
go 1.21
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for downgrade? I'd actually bump it up to 1.22, but can be addressed afterwards ofc


import "gogoproto/gogo.proto";

option go_package = "github.com/0xPolygon/heimdall-v2/x/chainmanager/types";
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 could go with v1 @Raneet10 ? We'd need consistency across all modules/PRs but I believe we can proceed as any refactoring afterwards will be more error prone.
If agreed, let's inform the others too 🙏

// This file is meant to track developer tools as dependencies in a go module
// See: https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md

package tools
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this? I'd keep it minimal if not really relevant for us

_ appmodule.AppModule = AppModule{}
)

// TODO HV2: what should this value be ?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need the ConsensusVersion at all, right @glnro ?


// ValidateGenesis performs basic validation of chainmanager genesis data returning an
// error for any failed validation criteria.
func (gs GenesisState) Validate() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to validate anything here? Compared to heimdall I mean, where it does nothing

return NewGenesisState(DefaultParams())
}

// ValidateGenesis performs basic validation of chainmanager genesis data returning an
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate

)

var (
ParamsKey = collections.NewPrefix(0) // ParamsKey is the key to store the params in the store
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually second the usage of collections, I like its concept (see this @VAIBHAVJINDAL3012)
However: do we need to align any other module/PR?

)

var (
ParamsKey = collections.NewPrefix(0) // ParamsKey is the key to store the params in the store
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 move the comment on top of the line (instead of next to it)?

if !common.IsHexAddress(value) {
return fmt.Errorf("invalid address for value %s for %s in chain_params", value, key)
}
if value == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this check done already by common.IsHexAddress?
There, we have len(s) == 2*AddressLength && isHex(s), so if I am not mistaken the first part of that check already validates the length, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the first check should suffice. Will remove.

x/chainmanager: Implement gRPC querier
x/chainmanager: Init keeper and genesis
@Raneet10 Raneet10 merged commit f83e2e4 into raneet10/pos-2017 Mar 20, 2024
2 of 3 checks passed
@Raneet10 Raneet10 deleted the raneet10/pos-2020 branch March 20, 2024 10:42
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.

4 participants