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

v3 compat for migration #447

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/upgrades/v4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (u *Upgrade) Handler() upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("\nNow updating the Jackal Protocol to:\n\n █████╗ ██████╗ █████╗ ██████╗██╗ █████╗ \n██╔══██╗██╔════╝██╔══██╗██╔════╝██║██╔══██╗\n███████║██║ ███████║██║ ██║███████║\n██╔══██║██║ ██╔══██║██║ ██║██╔══██║\n██║ ██║╚██████╗██║ ██║╚██████╗██║██║ ██║\n╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝╚═╝ ╚═╝\n \n")

fromVM[storagemoduletypes.ModuleName] = 5
fromVM[storagemoduletypes.ModuleName] = 7

fidMerkleMap := UpdateFiles(ctx, u.sk)

Expand Down
8 changes: 4 additions & 4 deletions proto/canine_chain/storage/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "canine_chain/storage/payment_info.proto";
option go_package = "github.com/jackalLabs/canine-chain/x/storage/types";

service Query {
rpc Params(QueryParams) returns (QueryParamsResponse) {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/jackal/canine-chain/storage/params";
}

Expand Down Expand Up @@ -120,7 +120,7 @@ service Query {
}

// Queries where a file is located by merkle.
rpc FindFile(QueryFindFile) returns (QueryFindFileResponse) {
rpc FindSomeFile(QueryFindFile) returns (QueryFindSomeFileResponse) {
option (google.api.http).get =
"/jackal/canine-chain/storage/find_file/{merkle}";
}
Expand Down Expand Up @@ -176,7 +176,7 @@ service Query {
}
}

message QueryParams {}
message QueryParamsRequest {}

message QueryParamsResponse {
Params params = 1 [ (gogoproto.nullable) = false ];
Expand Down Expand Up @@ -331,7 +331,7 @@ message QueryFindFile {
bytes merkle = 1;
}

message QueryFindFileResponse {
message QueryFindSomeFileResponse {
repeated string provider_ips = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion proto/canine_chain/storage/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ message MsgInitProvider {
string creator = 1;
string ip = 2;
string keybase = 3;
int64 total_space = 4;
string total_space = 4;
}

message MsgInitProviderResponse {}
Expand Down
2 changes: 1 addition & 1 deletion x/storage/client/cli/query_find_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func CmdFindFile() *cobra.Command {
Merkle: merkle,
}

res, err := queryClient.FindFile(cmd.Context(), params)
res, err := queryClient.FindSomeFile(cmd.Context(), params)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/storage/client/cli/query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func CmdQueryParams() *cobra.Command {

queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Params(context.Background(), &types.QueryParams{})
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/storage/client/cli/tx_init_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func CmdInitProvider() *cobra.Command {
argIP := args[0]
argTotalSpace := args[1]
argKeybase := args[2]
space, err := strconv.ParseInt(argTotalSpace, 10, 64)

if err != nil {
return err
}
Expand All @@ -33,7 +33,7 @@ func CmdInitProvider() *cobra.Command {
msg := types.NewMsgInitProvider(
clientCtx.GetFromAddress().String(),
argIP,
space,
argTotalSpace,
argKeybase,
)
if err := msg.ValidateBasic(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/storage/client/cli/tx_post_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func postFile(fileData []byte, cmd *cobra.Command) {
}
cl := types.NewQueryClient(clientCtx)

params, err := cl.Params(context.Background(), &types.QueryParams{})
params, err := cl.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/storage/keeper/grpc_query_find_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (k Keeper) ListFileLocations(ctx sdk.Context, merkle []byte) []string {
return providers
}

func (k Keeper) FindFile(goCtx context.Context, req *types.QueryFindFile) (*types.QueryFindFileResponse, error) {
func (k Keeper) FindSomeFile(goCtx context.Context, req *types.QueryFindFile) (*types.QueryFindSomeFileResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
Expand Down Expand Up @@ -78,5 +78,5 @@ func (k Keeper) FindFile(goCtx context.Context, req *types.QueryFindFile) (*type
}
}

return &types.QueryFindFileResponse{ProviderIps: ips}, nil
return &types.QueryFindSomeFileResponse{ProviderIps: ips}, nil
}
2 changes: 1 addition & 1 deletion x/storage/keeper/grpc_query_find_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestFindFile() {
suite.Require().NoError(err)
suite.Require().Equal(1, len(mres.Files))

ffres, err := suite.queryClient.FindFile(context.Background(), &types.QueryFindFile{Merkle: merkle})
ffres, err := suite.queryClient.FindSomeFile(context.Background(), &types.QueryFindFile{Merkle: merkle})
suite.Require().NoError(err)

suite.Require().Equal(1, len(ffres.ProviderIps))
Expand Down
2 changes: 1 addition & 1 deletion x/storage/keeper/grpc_query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"google.golang.org/grpc/status"
)

func (k Keeper) Params(c context.Context, req *types.QueryParams) (*types.QueryParamsResponse, error) {
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
Expand Down
3 changes: 1 addition & 2 deletions x/storage/keeper/msg_server_init_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -41,7 +40,7 @@ func (k msgServer) InitProvider(goCtx context.Context, msg *types.MsgInitProvide
provider := types.Providers{
Address: msg.Creator,
Ip: msg.Ip,
Totalspace: fmt.Sprintf("%d", msg.TotalSpace),
Totalspace: msg.TotalSpace,
Creator: msg.Creator,
BurnedContracts: "0",
KeybaseIdentity: msg.Keybase,
Expand Down
2 changes: 1 addition & 1 deletion x/storage/keeper/msg_server_proofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (suite *KeeperTestSuite) TestPostProof() {
_, err = msgSrvr.InitProvider(context, &types.MsgInitProvider{
Creator: testProvider.String(),
Ip: "192.168.0.1",
TotalSpace: 1_000_000,
TotalSpace: "1000000",
})
suite.Require().NoError(err)

Expand Down
2 changes: 1 addition & 1 deletion x/storage/keeper/msg_server_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (suite *KeeperTestSuite) TestMsgInitProvider() {
return types.NewMsgInitProvider(
user,
"127.0.0.1",
1000000000,
"1000000000",
"test-key",
)
},
Expand Down
6 changes: 2 additions & 4 deletions x/storage/keeper/providers_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper_test

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
testutil "github.com/jackalLabs/canine-chain/v3/testutil"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
Expand Down Expand Up @@ -63,7 +61,7 @@ func (suite *KeeperTestSuite) TestInitProviders() {
Creator: user,
Ip: "192.158.1.38",
Keybase: "",
TotalSpace: 9000,
TotalSpace: "9000",
}

_, err = msgSrvr.InitProvider(ctx, &initMsg)
Expand All @@ -77,7 +75,7 @@ func (suite *KeeperTestSuite) TestInitProviders() {
suite.Require().NoError(err)
suite.Require().Equal(res.Provider.Address, user)
suite.Require().Equal(res.Provider.Ip, initMsg.Ip)
suite.Require().Equal(res.Provider.Totalspace, fmt.Sprintf("%d", initMsg.TotalSpace))
suite.Require().Equal(res.Provider.Totalspace, initMsg.TotalSpace)
suite.Require().Equal(res.Provider.BurnedContracts, "0")
suite.Require().Equal(res.Provider.Creator, initMsg.Creator)

Expand Down
2 changes: 1 addition & 1 deletion x/storage/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 6 }
func (AppModule) ConsensusVersion() uint64 { return 8 }

// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { // Every x blocks we check for proven deals
Expand Down
3 changes: 2 additions & 1 deletion x/storage/simulation/init_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package simulation

import (
"math/rand"
"strconv"

"github.com/cosmos/cosmos-sdk/baseapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
Expand Down Expand Up @@ -39,7 +40,7 @@ func SimulateMsgInitProvider(
msg := &types.MsgInitProvider{
Creator: simAccount.Address.String(),
Ip: RandIPv4Url(r),
TotalSpace: int64(simtypes.RandIntBetween(r, 1_000_000_000, 1_000_000_000_000_000)),
TotalSpace: strconv.FormatInt(int64(simtypes.RandIntBetween(r, 1_000_000_000, 1_000_000_000_000_000)), 10),
Keybase: simtypes.RandStringOfLength(r, 10),
}

Expand Down
2 changes: 1 addition & 1 deletion x/storage/types/message_init_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TypeMsgInitProvider = "init_provider"

var _ sdk.Msg = &MsgInitProvider{}

func NewMsgInitProvider(creator string, ip string, totalspace int64, keybase string) *MsgInitProvider {
func NewMsgInitProvider(creator string, ip string, totalspace string, keybase string) *MsgInitProvider {
return &MsgInitProvider{
Creator: creator,
Ip: ip,
Expand Down
8 changes: 4 additions & 4 deletions x/storage/types/message_init_miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ func TestMsgInitProvider_ValidateBasic(t *testing.T) {
msg: MsgInitProvider{
Creator: "invalid_address",
Ip: "http://localhost:3333",
TotalSpace: 1000000000,
TotalSpace: "1000000000",
},
err: sdkerrors.ErrInvalidAddress,
}, {
name: "invalid ip",
msg: MsgInitProvider{
Creator: "jkl1j3p63s42w7ywaczlju626st55mzu5z399f5n6n",
Ip: "fake/localhost:3333",
TotalSpace: 1000000000,
TotalSpace: "1000000000",
},
err: sdkerrors.ErrInvalidType,
}, {
name: "valid ip",
msg: MsgInitProvider{
Creator: "jkl1j3p63s42w7ywaczlju626st55mzu5z399f5n6n",
Ip: "https://node.jackalprotocol.com",
TotalSpace: 1000000000,
TotalSpace: "1000000000",
},
}, {
name: "valid ip localhost",
msg: MsgInitProvider{
Creator: "jkl1j3p63s42w7ywaczlju626st55mzu5z399f5n6n",
Ip: "localhost:3333",
TotalSpace: 1000000000,
TotalSpace: "1000000000",
},
},
}
Expand Down
Loading
Loading