Skip to content

Commit

Permalink
feat: migrate params to dedicated stores
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jul 17, 2024
1 parent 3d9d1c3 commit d4521fc
Show file tree
Hide file tree
Showing 84 changed files with 8,021 additions and 2,298 deletions.
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/boz/go-lifecycle v0.1.1
github.com/cometbft/cometbft v0.37.5
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.47.12
github.com/cosmos/cosmos-sdk v0.47.13
github.com/cosmos/gogoproto v1.4.10
github.com/edwingeng/deque/v2 v2.1.1
github.com/gogo/protobuf v1.3.3
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/cosmos-sdk v0.47.12 h1:KOZHAVWrcilHywBN/FabBaXbDFMzoFmtdX0hqy5Ory8=
github.com/cosmos/cosmos-sdk v0.47.12/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0=
github.com/cosmos/cosmos-sdk v0.47.13 h1:9d57rl2ilSgc8a6u1JAulqNX/E5w8lbqbRe3NON3Jb4=
github.com/cosmos/cosmos-sdk v0.47.13/go.mod h1:pYMzhTfKFn9AJB5X64Epwe9NgYk0y3v7XN8Ks5xqWoo=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
8 changes: 6 additions & 2 deletions go/node/audit/v1/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var (
//
// The actual codec used for serialization should be provided to x/provider and
// defined at the application level.
//
// Deprecated: ModuleCdc use is deprecated
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)

Expand All @@ -26,9 +28,11 @@ var (
// }

// RegisterLegacyAminoCodec register concrete types on codec
//
// Deprecated: RegisterLegacyAminoCodec is deprecated
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgSignProviderAttributes{}, ModuleName+"/"+MsgTypeSignProviderAttributes, nil)
cdc.RegisterConcrete(&MsgDeleteProviderAttributes{}, ModuleName+"/"+MsgTypeDeleteProviderAttributes, nil)
cdc.RegisterConcrete(&MsgSignProviderAttributes{}, "akash-sdk/x"+ModuleName+"/"+MsgTypeSignProviderAttributes, nil)
cdc.RegisterConcrete(&MsgDeleteProviderAttributes{}, "akash-sdk/x"+ModuleName+"/"+MsgTypeDeleteProviderAttributes, nil)
}

// RegisterInterfaces registers the x/provider interfaces types with the interface registry
Expand Down
18 changes: 18 additions & 0 deletions go/node/audit/v1/migrate/v1beta3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package migrate

import (
"github.com/akash-network/akash-api/go/node/audit/v1beta3"

v1 "pkg.akt.dev/go/node/audit/v1"
attrmigrate "pkg.akt.dev/go/node/types/attributes/v1/migrate"
)

func AttributesFromV1beta3(from v1beta3.AuditedAttributes) v1.AuditedAttributes {
to := v1.AuditedAttributes{
Owner: from.Owner,
Auditor: from.Auditor,
Attributes: attrmigrate.AttributesFromV1Beta3(from.Attributes),
}

return to
}
58 changes: 29 additions & 29 deletions go/node/audit/v1/msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 57 additions & 27 deletions go/node/audit/v1/msgs.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
package v1

import (
"reflect"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const (
MsgTypeSignProviderAttributes = "audit-sign-provider-attributes"
MsgTypeDeleteProviderAttributes = "audit-delete-provider-attributes"
)

var (
_ sdk.Msg = &MsgSignProviderAttributes{}
_ sdk.Msg = &MsgDeleteProviderAttributes{}
)

// ====MsgSignProviderAttributes====
// Route implements the sdk.Msg interface
func (m MsgSignProviderAttributes) Route() string {
return RouterKey
var (
MsgTypeSignProviderAttributes = ""
MsgTypeDeleteProviderAttributes = ""
)

func init() {
MsgTypeSignProviderAttributes = reflect.TypeOf(&MsgSignProviderAttributes{}).Name()
MsgTypeDeleteProviderAttributes = reflect.TypeOf(&MsgDeleteProviderAttributes{}).Name()
}

// ====MsgSignProviderAttributes====

// Type implements the sdk.Msg interface
func (m MsgSignProviderAttributes) Type() string {
func (m *MsgSignProviderAttributes) Type() string {
return MsgTypeSignProviderAttributes
}

// ValidateBasic does basic validation
func (m MsgSignProviderAttributes) ValidateBasic() error {
func (m *MsgSignProviderAttributes) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil {
return sdkerrors.ErrInvalidAddress.Wrap("MsgCreate: Invalid Owner Address")
}
Expand All @@ -39,13 +42,8 @@ func (m MsgSignProviderAttributes) ValidateBasic() error {
return nil
}

// GetSignBytes encodes the message for signing
func (m MsgSignProviderAttributes) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// GetSigners defines whose signature is required
func (m MsgSignProviderAttributes) GetSigners() []sdk.AccAddress {
func (m *MsgSignProviderAttributes) GetSigners() []sdk.AccAddress {
auditor, err := sdk.AccAddressFromBech32(m.Auditor)
if err != nil {
panic(err)
Expand All @@ -55,18 +53,14 @@ func (m MsgSignProviderAttributes) GetSigners() []sdk.AccAddress {
}

// ====MsgRevokeProviderAttributes====
// Route implements the sdk.Msg interface
func (m MsgDeleteProviderAttributes) Route() string {
return RouterKey
}

// Type implements the sdk.Msg interface
func (m MsgDeleteProviderAttributes) Type() string {
func (m *MsgDeleteProviderAttributes) Type() string {
return MsgTypeDeleteProviderAttributes
}

// ValidateBasic does basic validation
func (m MsgDeleteProviderAttributes) ValidateBasic() error {
func (m *MsgDeleteProviderAttributes) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil {
return sdkerrors.ErrInvalidAddress.Wrap("MsgCreate: Invalid Owner Address")
}
Expand All @@ -79,16 +73,52 @@ func (m MsgDeleteProviderAttributes) ValidateBasic() error {
}

// GetSignBytes encodes the message for signing
func (m MsgDeleteProviderAttributes) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// GetSigners defines whose signature is required
func (m MsgDeleteProviderAttributes) GetSigners() []sdk.AccAddress {
func (m *MsgDeleteProviderAttributes) GetSigners() []sdk.AccAddress {
auditor, err := sdk.AccAddressFromBech32(m.Auditor)
if err != nil {
panic(err)
}

return []sdk.AccAddress{auditor}
}


// ============= GetSignBytes =============
// ModuleCdc is defined in codec.go
// TODO @troian to check if we need them at all

// GetSignBytes encodes the message for signing
//
// Deprecated: GetSignBytes is deprecated
func (m *MsgSignProviderAttributes) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
}

// GetSignBytes encodes the message for signing
//
// Deprecated: GetSignBytes is deprecated
func (m *MsgDeleteProviderAttributes) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
}



// ============= Route =============
// ModuleCdc is defined in codec.go
// TODO @troian to check if we need them at all since sdk.Msg does not not have Route defined anymore

// Route implements the sdk.Msg interface
//
// Deprecated: Route is deprecated
func (m *MsgSignProviderAttributes) Route() string {
return RouterKey
}

// Route implements the sdk.Msg interface
//
// Deprecated: Route is deprecated
func (m *MsgDeleteProviderAttributes) Route() string {
return RouterKey
}
8 changes: 6 additions & 2 deletions go/node/cert/v1/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ var (
//
// The actual codec used for serialization should be provided to x/provider and
// defined at the application level.
//
// Deprecated: ModuleCdc use is deprecated
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
)

// RegisterLegacyAminoCodec register concrete types on codec
//
// Deprecated: RegisterLegacyAminoCodec is deprecated
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgCreateCertificate{}, ModuleName+"/"+MsgTypeCreateCertificate, nil)
cdc.RegisterConcrete(&MsgRevokeCertificate{}, ModuleName+"/"+MsgTypeRevokeCertificate, nil)
cdc.RegisterConcrete(&MsgCreateCertificate{}, "akash-sdk/x"+ModuleName+"/"+(&MsgCreateCertificate{}).Type(), nil)
cdc.RegisterConcrete(&MsgRevokeCertificate{}, "akash-sdk/x"+ModuleName+"/"+(&MsgRevokeCertificate{}).Type(), nil)
}

// RegisterInterfaces registers the x/provider interfaces types with the interface registry
Expand Down
20 changes: 20 additions & 0 deletions go/node/cert/v1/migrate/v1beta3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package migrate

import (
"github.com/akash-network/akash-api/go/node/cert/v1beta3"

v1 "pkg.akt.dev/go/node/cert/v1"
)

func CertFromV1beta3(from v1beta3.Certificate) v1.Certificate {
to := v1.Certificate{
State: v1.State(from.State),
Cert: make([]byte, len(from.Cert)),
Pubkey: make([]byte, len(from.Pubkey)),
}

copy(to.Cert, from.Cert)
copy(to.Pubkey, from.Pubkey)

return to
}
52 changes: 26 additions & 26 deletions go/node/cert/v1/msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d4521fc

Please sign in to comment.