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

fix: remove tags field from existed msgs #543

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 deployment/localup/localup_fullnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function init_fullnode() {
cp ${workspace}/.local/validator0/config/config.toml ${workspace}/.local/dataseed${i}/config/config.toml

# set state sync info
sed -i 'N;s/\# starting from the height of the snapshot\.\nenable = false/\# starting from the height of the snapshot\.\nenable = true/Mg'sed -i -e 'N;s/\# starting from the height of the snapshot\.\nenable = false/\# starting from the height of the snapshot\.\nenable = true/g' ${workspace}/.local/dataseed${i}/config/config.toml
sed -i -e 'N;s/\# starting from the height of the snapshot\.\nenable = false/\# starting from the height of the snapshot\.\nenable = true/g' ${workspace}/.local/dataseed${i}/config/config.toml
sed -i -e "s/trust_height = 0/trust_height = ${trust_height}/g" ${workspace}/.local/dataseed${i}/config/config.toml
sed -i -e "s/trust_hash = \"\"/trust_hash = \"${trust_hash}\"/g" ${workspace}/.local/dataseed${i}/config/config.toml
sed -i -e "s/rpc_servers = \"\"/rpc_servers = \"${rpc_servers}\"/g" ${workspace}/.local/dataseed${i}/config/config.toml
Expand Down
6 changes: 0 additions & 6 deletions proto/greenfield/storage/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ message EventCreateBucket {
uint32 global_virtual_group_family_id = 10;
// status define the status of the bucket.
BucketStatus status = 11;
// tags define the tag of the bucket
ResourceTags tags = 12;
}

// EventDeleteBucket is emitted on MsgDeleteBucket
Expand Down Expand Up @@ -140,8 +138,6 @@ message EventCreateObject {
repeated bytes checksums = 16;
// local_virtual_group_id defines the unique id of lvg which the object stored
uint32 local_virtual_group_id = 17;
// tags define the tag of the object
ResourceTags tags = 18;
}

// EventCancelCreateObject is emitted on MsgCancelCreateObject
Expand Down Expand Up @@ -296,8 +292,6 @@ message EventCreateGroup {
SourceType source_type = 4;
// extra defines extra info for the group
string extra = 5;
// tags define the tag of the group
ResourceTags tags = 6;
}

// EventDeleteGroup is emitted on MsgDeleteGroup
Expand Down
9 changes: 0 additions & 9 deletions proto/greenfield/storage/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ message MsgCreateBucket {
// The available read data for each user is the sum of the free read data provided by SP and
// the ChargeReadQuota specified here.
uint64 charged_read_quota = 7;

// tags defines a list of tags which will be set to the bucket
ResourceTags tags = 8 [(gogoproto.nullable) = false];
}

message MsgCreateBucketResponse {
Expand Down Expand Up @@ -159,9 +156,6 @@ message MsgCreateObject {

// redundancy_type can be ec or replica
RedundancyType redundancy_type = 9;

// tags defines a list of tags which will be set to the object
ResourceTags tags = 10 [(gogoproto.nullable) = false];
}

message MsgCreateObjectResponse {
Expand Down Expand Up @@ -287,9 +281,6 @@ message MsgCreateGroup {

// extra defines extra info for the group
string extra = 3;

// tags defines a list of tags which will be set to the group
ResourceTags tags = 4 [(gogoproto.nullable) = false];
}

message MsgCreateGroupResponse {
Expand Down
54 changes: 36 additions & 18 deletions x/storage/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"

types2 "github.com/bnb-chain/greenfield/types"
"github.com/bnb-chain/greenfield/types/common"
gnfderrors "github.com/bnb-chain/greenfield/types/errors"
"github.com/bnb-chain/greenfield/x/storage/types"
Expand Down Expand Up @@ -124,7 +125,7 @@ func CmdCreateBucket() *cobra.Command {
if err != nil {
return err
}
msg := types.NewMsgCreateBucket(
msgCreateBucket := types.NewMsgCreateBucket(
clientCtx.GetFromAddress(),
argBucketName,
visibilityType,
Expand All @@ -134,15 +135,20 @@ func CmdCreateBucket() *cobra.Command {
approveSignatureBytes,
chargedReadQuota,
)
if tags != nil {
msg.Tags = *tags
if err := msgCreateBucket.ValidateBasic(); err != nil {
return err
}

if err := msg.ValidateBasic(); err != nil {
return err
if tags != nil {
grn := types2.NewBucketGRN(argBucketName)
msgSetTag := types.NewMsgSetTag(clientCtx.GetFromAddress(), grn.String(), tags)
if err := msgSetTag.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateBucket, msgSetTag)
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateBucket)
},
}

Expand Down Expand Up @@ -325,7 +331,7 @@ func CmdCreateObject() *cobra.Command {
return types.ErrInvalidRedundancyType
}

msg := types.NewMsgCreateObject(
msgCreateObject := types.NewMsgCreateObject(
clientCtx.GetFromAddress(),
argBucketName,
argObjectName,
Expand All @@ -337,14 +343,20 @@ func CmdCreateObject() *cobra.Command {
approveTimeoutHeight,
approveSignatureBytes,
)
if tags != nil {
msg.Tags = *tags
if err := msgCreateObject.ValidateBasic(); err != nil {
return err
}

if err := msg.ValidateBasic(); err != nil {
return err
if tags != nil {
grn := types2.NewObjectGRN(argBucketName, argObjectName)
msgSetTag := types.NewMsgSetTag(clientCtx.GetFromAddress(), grn.String(), tags)
if err := msgSetTag.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateObject, msgSetTag)
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateObject)
},
}

Expand Down Expand Up @@ -541,19 +553,25 @@ func CmdCreateGroup() *cobra.Command {
tagsStr, _ := cmd.Flags().GetString(FlagTags)
tags := GetTags(tagsStr)

msg := types.NewMsgCreateGroup(
msgCreateGroup := types.NewMsgCreateGroup(
clientCtx.GetFromAddress(),
argGroupName,
extra,
)
if tags != nil {
msg.Tags = *tags
if err := msgCreateGroup.ValidateBasic(); err != nil {
return err
}

if err := msg.ValidateBasic(); err != nil {
return err
if tags != nil {
grn := types2.NewGroupGRN(clientCtx.GetFromAddress(), argGroupName)
msgSetTag := types.NewMsgSetTag(clientCtx.GetFromAddress(), grn.String(), tags)
if err := msgSetTag.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateGroup, msgSetTag)
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msgCreateGroup)
},
}

Expand Down
6 changes: 0 additions & 6 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (k Keeper) CreateBucket(
ChargedReadQuota: opts.ChargedReadQuota,
PaymentAddress: paymentAcc.String(),
GlobalVirtualGroupFamilyId: gvgFamily.Id,
Tags: opts.Tags,
}

internalBucketInfo := types.InternalBucketInfo{PriceTime: ctx.BlockTime().Unix()}
Expand Down Expand Up @@ -174,7 +173,6 @@ func (k Keeper) CreateBucket(
PaymentAddress: bucketInfo.PaymentAddress,
PrimarySpId: sp.Id,
GlobalVirtualGroupFamilyId: bucketInfo.GlobalVirtualGroupFamilyId,
Tags: bucketInfo.Tags,
}); err != nil {
return sdkmath.Uint{}, err
}
Expand Down Expand Up @@ -618,7 +616,6 @@ func (k Keeper) CreateObject(
RedundancyType: opts.RedundancyType,
SourceType: opts.SourceType,
Checksums: opts.Checksums,
Tags: opts.Tags,
}

if objectInfo.PayloadSize == 0 {
Expand Down Expand Up @@ -658,7 +655,6 @@ func (k Keeper) CreateObject(
SourceType: objectInfo.SourceType,
Checksums: objectInfo.Checksums,
LocalVirtualGroupId: objectInfo.LocalVirtualGroupId,
Tags: opts.Tags,
}); err != nil {
return objectInfo.Id, err
}
Expand Down Expand Up @@ -1259,7 +1255,6 @@ func (k Keeper) CreateGroup(
Id: k.GenNextGroupId(ctx),
GroupName: groupName,
Extra: opts.Extra,
Tags: opts.Tags,
}

// Can not create a group with the same name.
Expand All @@ -1278,7 +1273,6 @@ func (k Keeper) CreateGroup(
GroupId: groupInfo.Id,
SourceType: groupInfo.SourceType,
Extra: opts.Extra,
Tags: opts.Tags,
}); err != nil {
return sdkmath.ZeroUint(), err
}
Expand Down
4 changes: 1 addition & 3 deletions x/storage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func (k msgServer) CreateBucket(goCtx context.Context, msg *types.MsgCreateBucke
SourceType: types.SOURCE_TYPE_ORIGIN,
PrimarySpApproval: msg.PrimarySpApproval,
ApprovalMsgBytes: msg.GetApprovalBytes(),
Tags: &msg.Tags,
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -122,7 +121,6 @@ func (k msgServer) CreateObject(goCtx context.Context, msg *types.MsgCreateObjec
Checksums: msg.ExpectChecksums,
PrimarySpApproval: msg.PrimarySpApproval,
ApprovalMsgBytes: msg.GetApprovalBytes(),
Tags: &msg.Tags,
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -234,7 +232,7 @@ func (k msgServer) CreateGroup(goCtx context.Context, msg *types.MsgCreateGroup)

ownerAcc := sdk.MustAccAddressFromHex(msg.Creator)

id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, storagetypes.CreateGroupOptions{Extra: msg.Extra, Tags: &msg.Tags})
id, err := k.Keeper.CreateGroup(ctx, ownerAcc, msg.GroupName, storagetypes.CreateGroupOptions{Extra: msg.Extra})
if err != nil {
return nil, err
}
Expand Down
Loading
Loading