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

feat: add new msg MsgSetTag #526

Merged
merged 6 commits into from
Dec 1, 2023
Merged
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
9 changes: 9 additions & 0 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ func (suite *AnteTestSuite) TestAnteHandler() {
return txBuilder.GetTx()
}, true, false, true,
},
{
"success - DeliverTx EIP712 signed Cosmos Tx MsgCreateBucket",
func() sdk.Tx {
gas := uint64(16e3)
fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas)))
txBuilder := suite.CreateTestEIP712TxBuilderMsgCreateBucket(addr, privKey, test.TEST_CHAIN_ID, gas, fee)
return txBuilder.GetTx()
}, true, false, true,
},
{
"fails - DeliverTx legacy msg MsgSubmitProposal v1beta",
func() sdk.Tx {
Expand Down
19 changes: 19 additions & 0 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
"github.com/bnb-chain/greenfield/sdk/keys"
"github.com/bnb-chain/greenfield/testutil"
"github.com/bnb-chain/greenfield/testutil/sample"
"github.com/bnb-chain/greenfield/types/common"
storagetypes "github.com/bnb-chain/greenfield/x/storage/types"
)

type AnteTestSuite struct {
Expand Down Expand Up @@ -205,6 +207,23 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgGrant(from sdk.AccAddres
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgGrant)
}

func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgCreateBucket(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
msgCreateBucket := &storagetypes.MsgCreateBucket{
Creator: from.String(),
BucketName: "test",
Visibility: 0,
PaymentAddress: from.String(),
PrimarySpAddress: from.String(),
PrimarySpApproval: &common.Approval{
ExpiredHeight: 1,
GlobalVirtualGroupFamilyId: 1,
Sig: []byte("test"),
},
ChargedReadQuota: 0,
}
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgCreateBucket)
}

func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder(
from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins, msg sdk.Msg,
) client.TxBuilder {
Expand Down
5 changes: 5 additions & 0 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
gashubtypes "github.com/cosmos/cosmos-sdk/x/gashub/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

bridgemoduletypes "github.com/bnb-chain/greenfield/x/bridge/types"
Expand Down Expand Up @@ -112,6 +113,10 @@ func (app *App) registerEddystoneUpgradeHandler() {
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("upgrade to ", plan.Name)

typeUrl := sdk.MsgTypeURL(&storagemoduletypes.MsgSetTag{})
msgSetTagGasParams := gashubtypes.NewMsgGasParamsWithFixedGas(typeUrl, 1.2e3)
app.GashubKeeper.SetMsgGasParams(ctx, *msgSetTagGasParams)

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

Expand Down
2 changes: 0 additions & 2 deletions cmd/gnfd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func initRootCmd(
tmcli.NewCompletionCmd(rootCmd, true),
debug.Cmd(),
config.Cmd(),
// this line is used by starport scaffolding # root/commands
)

a := appCreator{
Expand Down Expand Up @@ -287,7 +286,6 @@ func txCommand() *cobra.Command {

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
// this line is used by starport scaffolding # root/arguments
}

func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
Expand Down
1 change: 1 addition & 0 deletions deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ function generate_genesis() {
sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml
echo -e '[[upgrade]]\nname = "Nagqu"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Pampas"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Eddystone"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
done

# enable swagger API for validator0
Expand Down
35 changes: 35 additions & 0 deletions e2e/tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bnb-chain/greenfield/sdk/keys"
"github.com/bnb-chain/greenfield/sdk/types"
storageutils "github.com/bnb-chain/greenfield/testutil/storage"
types2 "github.com/bnb-chain/greenfield/types"
sptypes "github.com/bnb-chain/greenfield/x/sp/types"
storagetypes "github.com/bnb-chain/greenfield/x/storage/types"
)
Expand Down Expand Up @@ -2073,3 +2074,37 @@ func (s *StorageTestSuite) TestMaintenanceSPCreateBucketAndObject() {
// s.Require().Error(err)
// s.Require().Equal(queryHeadBucketResponse.BucketInfo.BucketStatus, storagetypes.BUCKET_STATUS_CREATED)
//}

func (s *StorageTestSuite) TestSetTag() {
var err error
user := s.GenAndChargeAccounts(1, 1000000)

// CreateBucket
sp := s.BaseSuite.PickStorageProvider()
gvg, found := sp.GetFirstGlobalVirtualGroup()
s.Require().True(found)

bucketName := storageutils.GenRandomBucketName()
msgCreateBucket := storagetypes.NewMsgCreateBucket(
user[0].GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(),
nil, math.MaxUint, nil, 0)
msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId
msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(user[0], msgCreateBucket)

// Set tag
grn := types2.NewBucketGRN(bucketName)
var tags storagetypes.ResourceTags
tags.Tags = append(tags.Tags, storagetypes.ResourceTags_Tag{Key: "key1", Value: "value1"})
msgSetTag := storagetypes.NewMsgSetTag(user[0].GetAddr(), grn.String(), &tags)
s.SendTxBlock(user[0], msgSetTag)

// Query
req := storagetypes.QueryHeadBucketRequest{
BucketName: bucketName,
}
resp, err := s.Client.HeadBucket(context.Background(), &req)
s.Require().NoError(err)
s.Require().Equal(tags, *resp.BucketInfo.Tags)
}
2 changes: 0 additions & 2 deletions proto/greenfield/bridge/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package greenfield.bridge;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

enum RefundReason {
Expand Down
3 changes: 0 additions & 3 deletions proto/greenfield/bridge/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import "greenfield/bridge/params.proto";

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

// this line is used by starport scaffolding # genesis/proto/import

// GenesisState defines the bridge module's genesis state.
message GenesisState {
// Params defines all the paramaters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
4 changes: 0 additions & 4 deletions proto/greenfield/bridge/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "greenfield/bridge/params.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

Expand All @@ -15,7 +14,6 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/greenfield/bridge/params";
}
// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand All @@ -26,5 +24,3 @@ message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

// this line is used by starport scaffolding # 3
5 changes: 0 additions & 5 deletions proto/greenfield/bridge/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "greenfield/bridge/params.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

// Msg defines the Msg service.
Expand All @@ -20,7 +18,6 @@ service Msg {
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

// MsgTransferOut is the Msg/TransferOut request type.
Expand Down Expand Up @@ -54,5 +51,3 @@ message MsgUpdateParams {
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}

// this line is used by starport scaffolding # proto/tx/message
2 changes: 0 additions & 2 deletions proto/greenfield/challenge/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ package greenfield.challenge;
import "gogoproto/gogo.proto";
import "greenfield/challenge/params.proto";
import "greenfield/challenge/types.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/bnb-chain/greenfield/x/challenge/types";

// GenesisState defines the challenge module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
6 changes: 0 additions & 6 deletions proto/greenfield/challenge/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import "google/api/annotations.proto";
import "greenfield/challenge/params.proto";
import "greenfield/challenge/types.proto";

// this line is used by starport scaffolding # 1

option go_package = "github.com/bnb-chain/greenfield/x/challenge/types";

// Query defines the gRPC querier service.
Expand All @@ -31,8 +29,6 @@ service Query {
rpc InturnAttestationSubmitter(QueryInturnAttestationSubmitterRequest) returns (QueryInturnAttestationSubmitterResponse) {
option (google.api.http).get = "/greenfield/challenge/inturn_attestation_submitter";
}

// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down Expand Up @@ -77,5 +73,3 @@ message SubmitInterval {
uint64 start = 1;
uint64 end = 2;
}

// this line is used by starport scaffolding # 3
4 changes: 0 additions & 4 deletions proto/greenfield/challenge/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "gogoproto/gogo.proto";
import "greenfield/challenge/params.proto";
import "greenfield/challenge/types.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/challenge/types";

// Msg defines the Msg service.
Expand All @@ -21,7 +19,6 @@ service Msg {
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

// MsgSubmit defines the message for submitting challenges.
Expand Down Expand Up @@ -103,4 +100,3 @@ message MsgUpdateParams {

// MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message.
message MsgUpdateParamsResponse {}
// this line is used by starport scaffolding # proto/tx/message
3 changes: 0 additions & 3 deletions proto/greenfield/payment/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import "greenfield/payment/payment_account.proto";
import "greenfield/payment/payment_account_count.proto";
import "greenfield/payment/stream_record.proto";

// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/bnb-chain/greenfield/x/payment/types";

// GenesisState defines the payment module's genesis state.
Expand All @@ -20,5 +18,4 @@ message GenesisState {
repeated PaymentAccountCount payment_account_count_list = 3 [(gogoproto.nullable) = false];
repeated PaymentAccount payment_account_list = 4 [(gogoproto.nullable) = false];
repeated AutoSettleRecord auto_settle_record_list = 5 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
2 changes: 0 additions & 2 deletions proto/greenfield/payment/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import "greenfield/payment/payment_account.proto";
import "greenfield/payment/payment_account_count.proto";
import "greenfield/payment/stream_record.proto";

// this line is used by starport scaffolding # 1

option go_package = "github.com/bnb-chain/greenfield/x/payment/types";

// Query defines the gRPC querier service.
Expand Down
2 changes: 0 additions & 2 deletions proto/greenfield/payment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "greenfield/payment/params.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/payment/types";

// Msg defines the Msg service.
Expand Down
2 changes: 0 additions & 2 deletions proto/greenfield/permission/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ service Msg {
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

// this line is used by starport scaffolding # proto/tx/rpc
}

// MsgUpdateParams is the Msg/UpdateParams request type.
Expand Down
1 change: 0 additions & 1 deletion proto/greenfield/sp/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package greenfield.sp;
import "gogoproto/gogo.proto";
import "greenfield/sp/params.proto";
import "greenfield/sp/types.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/bnb-chain/greenfield/x/sp/types";

Expand Down
4 changes: 0 additions & 4 deletions proto/greenfield/sp/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "google/api/annotations.proto";
import "greenfield/sp/params.proto";
import "greenfield/sp/types.proto";

// this line is used by starport scaffolding # 1
option go_package = "github.com/bnb-chain/greenfield/x/sp/types";

// Query defines the gRPC querier service.
Expand All @@ -19,8 +18,6 @@ service Query {
option (google.api.http).get = "/greenfield/sp/params";
}

// this line is used by starport scaffolding # 2

// Queries a list of GetStorageProviders items.
rpc StorageProviders(QueryStorageProvidersRequest) returns (QueryStorageProvidersResponse) {
option (google.api.http).get = "/greenfield/storage_providers";
Expand Down Expand Up @@ -61,7 +58,6 @@ message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

// this line is used by starport scaffolding # 3
message QueryStorageProvidersRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
Expand Down
3 changes: 0 additions & 3 deletions proto/greenfield/sp/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import "gogoproto/gogo.proto";
import "greenfield/sp/params.proto";
import "greenfield/sp/types.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/sp/types";

// Msg defines the Msg service for creating a new storage provider.
Expand All @@ -26,7 +24,6 @@ service Msg {
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

// MsgCreateStorageProvider defines message for creating a new storage provider.
Expand Down
Loading
Loading