From 8c891bfe25c95242f73761c04822ea34cdba4466 Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Tue, 9 May 2023 17:49:13 +0800 Subject: [PATCH 1/8] fix: export/import issue (#44) --- proto/sao/node/genesis.proto | 2 + x/node/genesis.go | 8 +++ x/node/types/genesis.pb.go | 94 ++++++++++++++++++++++++++++++------ 3 files changed, 89 insertions(+), 15 deletions(-) diff --git a/proto/sao/node/genesis.proto b/proto/sao/node/genesis.proto index c1d0ecc9..1efd3edb 100644 --- a/proto/sao/node/genesis.proto +++ b/proto/sao/node/genesis.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "sao/node/params.proto"; import "sao/node/node.proto"; import "sao/node/pool.proto"; +import "sao/node/pledge.proto"; // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/SaoNetwork/sao/x/node/types"; @@ -14,5 +15,6 @@ message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; Pool pool = 2; repeated Node nodeList = 3 [(gogoproto.nullable) = false]; + repeated Pledge pledgeList = 4 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/x/node/genesis.go b/x/node/genesis.go index 2bdf5800..f88ade04 100644 --- a/x/node/genesis.go +++ b/x/node/genesis.go @@ -12,6 +12,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.NodeList { k.SetNode(ctx, elem) } + for _, elem := range genState.PledgeList { + k.SetPledge(ctx, elem) + } // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) @@ -24,6 +27,11 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.Params = k.GetParams(ctx) genesis.NodeList = k.GetAllNode(ctx) + pool, foundPool := k.GetPool(ctx) + if foundPool { + genesis.Pool = &pool + } + genesis.PledgeList = k.GetAllPledge(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/node/types/genesis.pb.go b/x/node/types/genesis.pb.go index a5b79e81..699dd8cc 100644 --- a/x/node/types/genesis.pb.go +++ b/x/node/types/genesis.pb.go @@ -25,9 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the node module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - Pool *Pool `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` - NodeList []Node `protobuf:"bytes,3,rep,name=nodeList,proto3" json:"nodeList"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Pool *Pool `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` + NodeList []Node `protobuf:"bytes,3,rep,name=nodeList,proto3" json:"nodeList"` + PledgeList []Pledge `protobuf:"bytes,4,rep,name=pledgeList,proto3" json:"pledgeList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -84,6 +85,13 @@ func (m *GenesisState) GetNodeList() []Node { return nil } +func (m *GenesisState) GetPledgeList() []Pledge { + if m != nil { + return m.PledgeList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "saonetwork.sao.node.GenesisState") } @@ -91,23 +99,25 @@ func init() { func init() { proto.RegisterFile("sao/node/genesis.proto", fileDescriptor_4f8106b05cd6903f) } var fileDescriptor_4f8106b05cd6903f = []byte{ - // 256 bytes of a gzipped FileDescriptorProto + // 282 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x4e, 0xcc, 0xd7, 0xcf, 0xcb, 0x4f, 0x49, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0xcc, 0xd7, 0x03, 0x29, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0xa2, 0x70, 0x23, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x26, 0x48, 0x09, 0xc3, - 0x85, 0x41, 0x04, 0x86, 0x60, 0x41, 0x7e, 0x7e, 0x0e, 0x44, 0x50, 0x69, 0x2b, 0x23, 0x17, 0x8f, - 0x3b, 0xc4, 0xf6, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x36, 0x88, 0x51, 0x12, 0x8c, - 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0x5c, 0xa3, 0x17, 0x00, 0x56, 0xe2, 0xc4, 0x72, - 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x83, 0x90, 0x2e, 0x17, 0x0b, 0xc8, 0x64, 0x09, 0x26, 0xb0, - 0x46, 0x49, 0xec, 0x1a, 0xf3, 0xf3, 0x73, 0x82, 0xc0, 0xca, 0x84, 0xac, 0xb9, 0x38, 0x40, 0x42, - 0x3e, 0x99, 0xc5, 0x25, 0x12, 0xcc, 0x0a, 0xcc, 0x38, 0xb5, 0xf8, 0xe5, 0xa7, 0xa4, 0x42, 0x6d, - 0x82, 0x6b, 0x70, 0x72, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xb5, - 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe0, 0xc4, 0x7c, 0x3f, 0x88, - 0x71, 0xfa, 0x20, 0xcf, 0x57, 0x40, 0xbc, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, - 0x00, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x96, 0xd6, 0xd4, 0x54, 0x86, 0x01, 0x00, 0x00, + 0x85, 0x41, 0x04, 0x86, 0x60, 0x41, 0x7e, 0x7e, 0x0e, 0xa6, 0x01, 0x39, 0xa9, 0x29, 0xe9, 0x50, + 0xb5, 0x4a, 0x3f, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x8e, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, + 0xe4, 0x62, 0x83, 0xd8, 0x20, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x91, + 0x7a, 0x01, 0x60, 0x25, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x35, 0x08, 0xe9, 0x72, + 0xb1, 0x80, 0x2c, 0x94, 0x60, 0x02, 0x6b, 0x94, 0xc4, 0xae, 0x31, 0x3f, 0x3f, 0x27, 0x08, 0xac, + 0x4c, 0xc8, 0x9a, 0x8b, 0x03, 0x24, 0xe4, 0x93, 0x59, 0x5c, 0x22, 0xc1, 0xac, 0xc0, 0x8c, 0x53, + 0x8b, 0x5f, 0x7e, 0x4a, 0x2a, 0xd4, 0x26, 0xb8, 0x06, 0x21, 0x47, 0x2e, 0x2e, 0x88, 0x3f, 0xc0, + 0xda, 0x59, 0xc0, 0xda, 0x71, 0x38, 0x15, 0xac, 0x0c, 0x6a, 0x00, 0x92, 0x26, 0x27, 0x87, 0x13, + 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, + 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, + 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x4e, 0xcc, 0xf7, 0x83, 0x18, 0xa9, 0x0f, 0x0a, 0xc1, 0x0a, + 0x48, 0x18, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xc3, 0xd0, 0x18, 0x10, 0x00, 0x00, + 0xff, 0xff, 0x15, 0xd4, 0x80, 0x05, 0xe0, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -130,6 +140,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PledgeList) > 0 { + for iNdEx := len(m.PledgeList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PledgeList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.NodeList) > 0 { for iNdEx := len(m.NodeList) - 1; iNdEx >= 0; iNdEx-- { { @@ -198,6 +222,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PledgeList) > 0 { + for _, e := range m.PledgeList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -339,6 +369,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PledgeList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PledgeList = append(m.PledgeList, Pledge{}) + if err := m.PledgeList[len(m.PledgeList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) From 28013115a878af282c2097bbe2ead788b6736ff7 Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Thu, 11 May 2023 16:47:44 +0800 Subject: [PATCH 2/8] refactor: shard record storage duration (#46) * refactor: shard reord storage duration * recored reward per byte in order, order v3 migration logic * fix terminate, stop decrease reputation, enhance shard error judgment, fix shard pledge calculate, fix worker income calculate, metadata duration extend * rename RewardPerByte feild to UnitPrice, add provider arg in cli, fix cancel --- CHANGELOG.md | 44 +- app/app.go | 6 + app/upgrades/v0_1_5/constants.go | 6 + app/upgrades/v0_1_5/upgrades.go | 21 + proto/sao/order/order.proto | 2 + proto/sao/order/shard.proto | 2 + x/market/keeper/pool_management.go | 147 +- x/market/types/expected_keepers.go | 10 - x/model/keeper/data_management.go | 22 +- x/node/keeper/shard_pledge_management.go | 66 +- x/node/types/expected_keepers.go | 10 - x/order/keeper/grpc_query_order.go | 1 + x/order/keeper/migrations.go | 5 + x/order/keeper/shard_management.go | 12 +- x/order/migrations/v2/types/order.pb.go | 2089 ++++++++++++++++++++++ x/order/migrations/v2/types/shard.pb.go | 621 +++++++ x/order/migrations/v3/migrations.go | 87 + x/order/module.go | 5 +- x/order/types/order.pb.go | 252 ++- x/order/types/shard.pb.go | 128 +- x/sao/client/cli/tx_cancel.go | 6 +- x/sao/client/cli/tx_complete.go | 8 +- x/sao/client/cli/tx_migrate.go | 6 +- x/sao/client/cli/tx_ready.go | 6 +- x/sao/client/cli/tx_renew.go | 6 +- x/sao/client/cli/tx_store.go | 6 +- x/sao/client/cli/tx_terminate.go | 6 +- x/sao/client/cli/tx_updata_permission.go | 6 +- x/sao/keeper/msg_server_cancel.go | 16 +- x/sao/keeper/msg_server_complete.go | 117 +- x/sao/keeper/msg_server_migrate.go | 2 +- x/sao/keeper/msg_server_store.go | 2 +- x/sao/keeper/timeout_management.go | 4 +- x/sao/types/expected_keepers.go | 6 +- x/sao/types/message_cancel.go | 7 +- x/sao/types/message_complete.go | 11 +- x/sao/types/message_migrate.go | 7 +- x/sao/types/message_ready.go | 7 +- x/sao/types/message_renew.go | 3 +- x/sao/types/message_store.go | 3 +- x/sao/types/message_terminate.go | 3 +- x/sao/types/message_updata_permission.go | 3 +- 42 files changed, 3447 insertions(+), 330 deletions(-) create mode 100644 app/upgrades/v0_1_5/constants.go create mode 100644 app/upgrades/v0_1_5/upgrades.go create mode 100644 x/order/migrations/v2/types/order.pb.go create mode 100644 x/order/migrations/v2/types/shard.pb.go create mode 100644 x/order/migrations/v3/migrations.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 131a72b5..14ca8d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,40 @@ ## [Unreleased] +### Bug Fixes +- export/import issue ([#44](https://github.com/SAONetwork/sao-consensus/issues/44)) + +### Code Refactoring +- shard reord storage duration + + + +## [v0.1.4](https://github.com/SAONetwork/sao-consensus/compare/v0.1.3...v0.1.4) (2023-04-20) + ### Features -- handle timeout order ([#37](https://github.com/SAONetwork/sao-consensus/issues/37)) + +* migration for v0.1.4 ([#41](https://github.com/SAONetwork/sao-consensus/issues/41)) *#0* *#1* *#4* *#41* *#014* +* handle timeout order ([#37](https://github.com/SAONetwork/sao-consensus/issues/37)) *#37* ### Bug Fixes -- eth address binding proof verify -- update timeout shards ([#40](https://github.com/SAONetwork/sao-consensus/issues/40)) -- add ignore list in random sp for migration and resize ([#33](https://github.com/SAONetwork/sao-consensus/issues/33)) -- fill migrate shard sp and size ([#32](https://github.com/SAONetwork/sao-consensus/issues/32)) -- add worker migrate logic ([#30](https://github.com/SAONetwork/sao-consensus/issues/30)) -- shard pledge reward debt ([#29](https://github.com/SAONetwork/sao-consensus/issues/29)) -- use block height to calculate reward ([#27](https://github.com/SAONetwork/sao-consensus/issues/27)) -- remove reset_store ([#25](https://github.com/SAONetwork/sao-consensus/issues/25)) + +* eth address binding proof verify ([#42](https://github.com/SAONetwork/sao-consensus/issues/42)) *#42* +* update timeout shards ([#40](https://github.com/SAONetwork/sao-consensus/issues/40)) *#40* +* add ignore list in random sp for migration and resize ([#33](https://github.com/SAONetwork/sao-consensus/issues/33)) *#33* +* fill migrate shard sp and size ([#32](https://github.com/SAONetwork/sao-consensus/issues/32)) *#32* +* add worker migrate logic ([#30](https://github.com/SAONetwork/sao-consensus/issues/30)) *#30* +* shard pledge reward debt ([#29](https://github.com/SAONetwork/sao-consensus/issues/29)) *#29* +* use block height to calculate reward ([#27](https://github.com/SAONetwork/sao-consensus/issues/27)) *#27* +* remove reset_store ([#25](https://github.com/SAONetwork/sao-consensus/issues/25)) *#25* ### Code Refactoring -- node info enhancement for UI display and tx address pool supporting ([#39](https://github.com/SAONetwork/sao-consensus/issues/39)) -- metadata ([#38](https://github.com/SAONetwork/sao-consensus/issues/38)) -- remove order instead of set cancel/terminate status ([#36](https://github.com/SAONetwork/sao-consensus/issues/36)) -- data management ([#35](https://github.com/SAONetwork/sao-consensus/issues/35)) -- uniform order status ([#31](https://github.com/SAONetwork/sao-consensus/issues/31)) -- pool_management ([#28](https://github.com/SAONetwork/sao-consensus/issues/28)) + +* node info enhancement for UI display and tx address pool supporting ([#39](https://github.com/SAONetwork/sao-consensus/issues/39)) *#39* +* metadata ([#38](https://github.com/SAONetwork/sao-consensus/issues/38)) *#38* +* remove order instead of set cancel/terminate status ([#36](https://github.com/SAONetwork/sao-consensus/issues/36)) *#36* +* data management ([#35](https://github.com/SAONetwork/sao-consensus/issues/35)) *#35* +* uniform order status ([#31](https://github.com/SAONetwork/sao-consensus/issues/31)) *#31* +* pool_management ([#28](https://github.com/SAONetwork/sao-consensus/issues/28)) *#28* diff --git a/app/app.go b/app/app.go index 15d89ed4..5b14eda5 100644 --- a/app/app.go +++ b/app/app.go @@ -2,6 +2,7 @@ package app import ( "fmt" + v015 "github.com/SaoNetwork/sao/app/upgrades/v0_1_5" "io" "net/http" "os" @@ -836,6 +837,11 @@ func (app *App) setupUpgradeHandlers() { v014.CreateUpgradeHandler(app.mm, app.configurator, app.NodeKeeper), ) + app.UpgradeKeeper.SetUpgradeHandler( + v015.UpgradeName, + v015.CreateUpgradeHandler(app.mm, app.configurator, app.NodeKeeper), + ) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Errorf("failed to read upgrade info from disk: %w", err)) diff --git a/app/upgrades/v0_1_5/constants.go b/app/upgrades/v0_1_5/constants.go new file mode 100644 index 00000000..f7af9d99 --- /dev/null +++ b/app/upgrades/v0_1_5/constants.go @@ -0,0 +1,6 @@ +package v015 + +const ( + UpgradeName = "v0.1.5" + UpgradeInfo = `'upgrade to v0.1.5'` +) diff --git a/app/upgrades/v0_1_5/upgrades.go b/app/upgrades/v0_1_5/upgrades.go new file mode 100644 index 00000000..b819f499 --- /dev/null +++ b/app/upgrades/v0_1_5/upgrades.go @@ -0,0 +1,21 @@ +package v015 + +import ( + nodekeeper "github.com/SaoNetwork/sao/x/node/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + node nodekeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + logger := ctx.Logger().With("upgrade", UpgradeName) + + logger.Debug("running module migrations ...") + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/proto/sao/order/order.proto b/proto/sao/order/order.proto index 60b69bdb..72c51aa6 100644 --- a/proto/sao/order/order.proto +++ b/proto/sao/order/order.proto @@ -24,6 +24,7 @@ message Order { uint64 timeout = 14; string data_id = 15; string commit = 16; + cosmos.base.v1beta1.DecCoin unitPrice = 17 [(gogoproto.nullable) = false]; } message FullOrder { @@ -44,4 +45,5 @@ message FullOrder { uint64 timeout = 15; string data_id = 16; string commit = 17; + cosmos.base.v1beta1.DecCoin unitPrice = 18 [(gogoproto.nullable) = false]; } diff --git a/proto/sao/order/shard.proto b/proto/sao/order/shard.proto index fd7bf3d1..9419bd33 100644 --- a/proto/sao/order/shard.proto +++ b/proto/sao/order/shard.proto @@ -14,4 +14,6 @@ message Shard { cosmos.base.v1beta1.Coin pledge = 6 [(gogoproto.nullable) = false]; string from = 7; string sp = 8; + uint64 duration = 9; + uint64 createdAt = 10; } diff --git a/x/market/keeper/pool_management.go b/x/market/keeper/pool_management.go index d7eaea6e..057c9603 100644 --- a/x/market/keeper/pool_management.go +++ b/x/market/keeper/pool_management.go @@ -30,10 +30,11 @@ func (k Keeper) Deposit(ctx sdk.Context, order ordertypes.Order) error { if !found { return status.Errorf(codes.NotFound, "shard %d not found", id) } - - err := k.WorkerAppend(ctx, &order, &shard) - if err != nil { - return err + if shard.Status == ordertypes.ShardCompleted { + err := k.WorkerAppend(ctx, &order, &shard) + if err != nil { + return err + } } } @@ -44,47 +45,47 @@ func (k Keeper) Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, err logger := k.Logger(ctx) amount := sdk.NewDecCoinFromCoin(order.Amount) - duration := int64(order.Duration) if amount.IsZero() { return sdk.Coin{}, sdkerrors.Wrap(types.ErrInvalidAmount, "") } - orderFinishHeight := int64(order.CreatedAt) + duration - - refundCoin := sdk.NewCoin(amount.Denom, sdk.NewInt(0)) - - if orderFinishHeight < ctx.BlockHeight() { - return sdk.Coin{}, status.Errorf( - codes.Aborted, - "invalid height to withdraw, order: %v, finishHeight: %v, currentHeight: %v", order.Id, orderFinishHeight, ctx.BlockHeight(), - ) - } else if orderFinishHeight > ctx.BlockHeight() { - incomePerBlock := amount.Amount.QuoInt64(duration) - refund := incomePerBlock.MulInt64(orderFinishHeight - ctx.BlockHeight()).TruncateInt() - - refundCoin = sdk.NewCoin(amount.Denom, refund) - - err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) - if err != nil { - return sdk.Coin{}, err - } - logger.Debug("CoinTrace: withdraw", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) - } + // add all refund parts, + // refundDec = amount - price * size * replica * duration + refundDec := amount.Amount.Sub(order.UnitPrice.Amount.MulInt64(int64(order.Size_)).MulInt64(int64(order.Replica)).MulInt64(int64(order.Duration))) for _, id := range order.Shards { shard, found := k.order.GetShard(ctx, id) if !found { - return sdk.Coin{}, status.Errorf(codes.NotFound, "shard %d not found", id) + continue } - err := k.WorkerRelease(ctx, &order, &shard) - if err != nil { - return sdk.Coin{}, err + shardIncomePerBlock := order.UnitPrice.Amount.MulInt64(int64(shard.Size_)) + + if shard.Status == ordertypes.ShardCompleted { + + // refundDec += price * shardSize * (shardExpiredAt - currentHeight) + refundDec = refundDec.Add(shardIncomePerBlock.MulInt64(int64(shard.CreatedAt+shard.Duration) - ctx.BlockHeight())) + + err := k.WorkerRelease(ctx, &order, &shard) + if err != nil { + return sdk.Coin{}, err + } + } else { + // refundDec += price * shardSize * shardDuration + refundDec = refundDec.Add(shardIncomePerBlock.MulInt64(int64(order.Duration))) } } + refundCoin, _ := sdk.NewDecCoinFromDec(amount.Denom, refundDec).TruncateDecimal() + + err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) + if err != nil { + return sdk.Coin{}, err + } + logger.Debug("CoinTrace: withdraw", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) + return refundCoin, nil } @@ -158,39 +159,39 @@ func (k Keeper) Migrate(ctx sdk.Context, order ordertypes.Order, from string, to return nil } -func (k Keeper) Release(ctx sdk.Context, order ordertypes.Order, sp string) (sdk.Coin, error) { - logger := k.Logger(ctx) - amount := sdk.NewDecCoinFromCoin(order.Amount) - empty := sdk.NewCoin(amount.Denom, sdk.NewInt(0)) - duration := int64(order.Duration) - orderFinishHeight := int64(order.CreatedAt) + duration - if orderFinishHeight < ctx.BlockHeight() { - return empty, status.Errorf( - codes.Aborted, - "invalid height to withdraw, order: %v, finishHeight: %v, currentHeight: %v", order.Id, orderFinishHeight, ctx.BlockHeight(), - ) - } - - incomePerBlock := amount.Amount.QuoInt64(duration * int64(order.Replica)) - - refund := incomePerBlock.MulInt64(orderFinishHeight - ctx.BlockHeight()).TruncateInt() - - refundCoin := sdk.NewCoin(amount.Denom, refund) - - err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) - if err != nil { - return empty, err - } - logger.Debug("CoinTrace: release single worker", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) - - shard := k.order.GetOrderShardBySP(ctx, &order, sp) - err = k.WorkerRelease(ctx, &order, shard) - if err != nil { - return empty, err - } - - return refundCoin, nil -} +//func (k Keeper) Release(ctx sdk.Context, order ordertypes.Order, sp string) (sdk.Coin, error) { +// logger := k.Logger(ctx) +// amount := sdk.NewDecCoinFromCoin(order.Amount) +// empty := sdk.NewCoin(amount.Denom, sdk.NewInt(0)) +// duration := int64(order.Duration) +// orderFinishHeight := int64(order.CreatedAt) + duration +// if orderFinishHeight < ctx.BlockHeight() { +// return empty, status.Errorf( +// codes.Aborted, +// "invalid height to withdraw, order: %v, finishHeight: %v, currentHeight: %v", order.Id, orderFinishHeight, ctx.BlockHeight(), +// ) +// } +// +// incomePerBlock := amount.Amount.QuoInt64(duration * int64(order.Replica)) +// +// refund := incomePerBlock.MulInt64(orderFinishHeight - ctx.BlockHeight()).TruncateInt() +// +// refundCoin := sdk.NewCoin(amount.Denom, refund) +// +// err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) +// if err != nil { +// return empty, err +// } +// logger.Debug("CoinTrace: release single worker", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) +// +// shard := k.order.GetOrderShardBySP(ctx, &order, sp) +// err = k.WorkerRelease(ctx, &order, shard) +// if err != nil { +// return empty, err +// } +// +// return refundCoin, nil +//} func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error { logger := k.Logger(ctx) @@ -198,6 +199,9 @@ func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard * if order == nil { return status.Errorf(codes.NotFound, "WorkerRelease order not found") } + if shard == nil { + return status.Errorf(codes.NotFound, "WorkerRelease shard not found") + } amount := sdk.NewDecCoinFromCoin(order.Amount) @@ -206,7 +210,7 @@ func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard * if !foundWorker { return status.Errorf(codes.NotFound, "worker: %v not found", workerName) } - incomePerSecond := amount.Amount.QuoInt64(int64(order.Replica) * int64(order.Duration)) + IncomePerBlock := order.UnitPrice.Amount.MulInt64(int64(shard.Size_)) reward := worker.IncomePerSecond.Amount.MulInt64(ctx.BlockHeight() - worker.LastRewardAt) logger.Debug("WorkerTrace: worker release", "Worker", workerName, @@ -216,9 +220,9 @@ func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard * "lastRewardAt", worker.LastRewardAt, "currentHeight", ctx.BlockHeight(), "incomePerBlock", worker.IncomePerSecond.String(), - "incomePerBlockToSub", incomePerSecond.String()) + "incomePerBlockToSub", IncomePerBlock.String()) worker.Reward.Amount = worker.Reward.Amount.Add(reward) - worker.IncomePerSecond.Amount = worker.IncomePerSecond.Amount.Sub(incomePerSecond) + worker.IncomePerSecond.Amount = worker.IncomePerSecond.Amount.Sub(IncomePerBlock) worker.Storage -= shard.Size_ worker.LastRewardAt = ctx.BlockHeight() k.SetWorker(ctx, worker) @@ -231,9 +235,11 @@ func (k *Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *o if order == nil { return status.Errorf(codes.NotFound, "WorkerRelease order not found") } + if shard == nil { + return status.Errorf(codes.NotFound, "WorkerRelease shard not found") + } amount := sdk.NewDecCoinFromCoin(order.Amount) - duration := int64(order.Duration) workerName := fmt.Sprintf("%s-%s", amount.Denom, shard.Sp) worker, found := k.GetWorker(ctx, workerName) @@ -246,9 +252,10 @@ func (k *Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *o } } - incomePerSecond := amount.Amount.QuoInt64(int64(order.Replica) * duration) + IncomePerBlock := order.UnitPrice.Amount.MulInt64(int64(shard.Size_)) if worker.Storage > 0 { reward := worker.IncomePerSecond.Amount.MulInt64(ctx.BlockHeight() - worker.LastRewardAt) + reward = reward.Add(IncomePerBlock.MulInt64(ctx.BlockHeight() - int64(shard.CreatedAt))) logger.Debug("WorkerTrace: deposit 1", "Worker", workerName, "orderId", order.Id, @@ -265,9 +272,9 @@ func (k *Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *o "Worker", workerName, "orderId", order.Id, "incomePerBlock", worker.IncomePerSecond.String(), - "incomePerBlockToAdd", incomePerSecond.String()) + "incomePerBlockToAdd", IncomePerBlock.String()) worker.Storage += shard.Size_ - worker.IncomePerSecond.Amount = worker.IncomePerSecond.Amount.Add(incomePerSecond) + worker.IncomePerSecond.Amount = worker.IncomePerSecond.Amount.Add(IncomePerBlock) k.SetWorker(ctx, worker) diff --git a/x/market/types/expected_keepers.go b/x/market/types/expected_keepers.go index 81ba2e4d..6f5dc1e5 100644 --- a/x/market/types/expected_keepers.go +++ b/x/market/types/expected_keepers.go @@ -24,16 +24,6 @@ type BankKeeper interface { // OrderKeeper interface type OrderKeeper interface { - NewOrder(ctx sdk.Context, order *ordertypes.Order, sp []string) (uint64, error) - GenerateShards(ctx sdk.Context, order *ordertypes.Order, sps []string) - MigrateShard(ctx sdk.Context, order *ordertypes.Order, from string, to string) *ordertypes.Shard - GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) - SetOrder(ctx sdk.Context, order ordertypes.Order) - TerminateOrder(ctx sdk.Context, orderId uint64, refundCoin sdk.Coin) error - FulfillShard(ctx sdk.Context, order *ordertypes.Order, sp string, cid string, size uint64) error - TerminateShard(ctx sdk.Context, shard *ordertypes.Shard, sp string, owner string, orderId uint64) error GetOrderShardBySP(ctx sdk.Context, order *ordertypes.Order, sp string) *ordertypes.Shard GetShard(ctx sdk.Context, id uint64) (val ordertypes.Shard, found bool) - RemoveShard(ctx sdk.Context, id uint64) - GetAllOrder(ctx sdk.Context) (list []ordertypes.Order) } diff --git a/x/model/keeper/data_management.go b/x/model/keeper/data_management.go index 406d0df4..214555e4 100644 --- a/x/model/keeper/data_management.go +++ b/x/model/keeper/data_management.go @@ -236,11 +236,16 @@ func (k Keeper) removeDataExpireBlock(ctx sdk.Context, dataId string, expiredAt } func (k Keeper) TerminateOrder(ctx sdk.Context, order ordertypes.Order) error { + refund, err := k.market.Withdraw(ctx, order) + if err != nil { + return err + } + // change pledge and pool status for _, id := range order.Shards { shard, found := k.order.GetShard(ctx, id) if !found { - return status.Errorf(codes.NotFound, "shard %d not found", id) + continue } if shard.Status == ordertypes.ShardCompleted { err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &order) @@ -251,11 +256,6 @@ func (k Keeper) TerminateOrder(ctx sdk.Context, order ordertypes.Order) error { k.order.RemoveShard(ctx, id) } - refund, err := k.market.Withdraw(ctx, order) - if err != nil { - return err - } - err = k.order.TerminateOrder(ctx, order.Id, refund) if err != nil { return err @@ -305,3 +305,13 @@ func (k Keeper) RollbackMeta(ctx sdk.Context, dataId string) { k.SetMetadata(ctx, metadata) return } + +func (k Keeper) ExtendMetaDuration(ctx sdk.Context, meta types.Metadata, expiredAt uint64) { + newDuration := expiredAt - meta.CreatedAt + if meta.Duration < newDuration { + k.removeDataExpireBlock(ctx, meta.DataId, meta.CreatedAt+meta.Duration) + meta.Duration = newDuration + k.setDataExpireBlock(ctx, meta.DataId, expiredAt) + k.SetMetadata(ctx, meta) + } +} diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index b7ed9109..0e3a4fbd 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -1,8 +1,6 @@ package keeper import ( - "math/big" - "github.com/SaoNetwork/sao/x/node/types" ordertypes "github.com/SaoNetwork/sao/x/order/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -84,16 +82,16 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype storageDecPledge := sdk.NewInt64DecCoin(params.BlockReward.Denom, 0) // 1. first N% rewards - projectionPeriod := order.Duration * ProjectionPeriodNumerator / ProjectionPeriodDenominator - projectionPeriodPledge := rewardPerByte.MulInt64(int64(shard.Size_) * int64(projectionPeriod)) + //projectionPeriod := order.Duration * ProjectionPeriodNumerator / ProjectionPeriodDenominator + + projectionPeriodPledge := k.BlockRewardPledge(shard.Duration, shard.Size_, sdk.NewDecCoinFromDec(denom, rewardPerByte)) logger.Debug("pledge ", "part1", projectionPeriodPledge) storageDecPledge.Amount.AddMut(projectionPeriodPledge) // 2. order price N%. collateral amount can be negotiated between client and SP in the future. - orderAmountPledge := order.Amount.Amount.BigInt() - orderAmountPledge.Div(orderAmountPledge, big.NewInt(int64(order.Replica))).Mul(orderAmountPledge, big.NewInt(OrderAmountNumerator)).Div(orderAmountPledge, big.NewInt(OrderAmountDenominator)) + orderAmountPledge := k.StoreRewardPledge(shard.Duration, shard.Size_, order.UnitPrice) logger.Debug("pledge ", "part2", orderAmountPledge) - storageDecPledge.Amount.AddMut(sdk.NewDecFromBigInt(orderAmountPledge)) + storageDecPledge.Amount.AddMut(orderAmountPledge) // 3. circulating_supply_sp * shard size / network power * ratio // pool, found := k.GetPool(ctx) @@ -107,11 +105,10 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype // } logger.Debug("order pledge ", "amount", storageDecPledge, "pool", pool.TotalStorage, "reward_per_byte", rewardPerByte, "size", shard.Size_, "duration", order.Duration) - shardPledge, _ = storageDecPledge.TruncateDecimal() - - // set shard pledge to min price if zero - if shardPledge.IsZero() { - shardPledge = sdk.NewInt64Coin(params.BlockReward.Denom, 1) + var dec sdk.DecCoin + shardPledge, dec = storageDecPledge.TruncateDecimal() + if !dec.IsZero() { + shardPledge = shardPledge.AddAmount(sdk.NewInt(1)) } coins = coins.Add(shardPledge) @@ -192,24 +189,19 @@ func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertyp shardPledge := shard.Pledge - if shardPledge.IsZero() { - return nil - } coins = coins.Add(shardPledge) - - pledge.TotalStorage -= int64(shard.Size_) - logger.Debug("CoinTrace: order release", "from", types.ModuleName, "to", sp.String(), "amount", coins.String()) err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, coins) - if err != nil { return err } + pledge.TotalStorage -= int64(shard.Size_) + pledge.TotalStoragePledged = pledge.TotalStoragePledged.Sub(shardPledge) logger.Debug("PoolTrace: order release", @@ -277,3 +269,39 @@ func (k Keeper) OrderSlash(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes return nil } + +// +//func (Keeper) OrderPricePledge(remainingDuration, duration uint64, amount sdk.Int, replica int32) sdk.Dec { +// // 2. order price N%. collateral amount can be negotiated between client and SP in the future. +// orderAmountPledge := amount.BigInt() +// if duration != remainingDuration { +// orderAmountPledge.Mul(orderAmountPledge, big.NewInt(int64(remainingDuration))).Div(orderAmountPledge, big.NewInt(int64(duration))) +// } +// orderAmountPledge.Div(orderAmountPledge, big.NewInt(int64(replica))).Mul(orderAmountPledge, big.NewInt(OrderAmountNumerator)).Div(orderAmountPledge, big.NewInt(OrderAmountDenominator)) +// +// return sdk.NewDecFromBigInt(orderAmountPledge) +//} + +func (Keeper) BlockRewardPledge(duration uint64, size uint64, rewardPerByte sdk.DecCoin) sdk.Dec { + + // 1. first N% block rewards + + return rewardPerByte. + Amount. + MulInt64(int64(size)). + MulInt64(int64(duration)). + MulInt64(ProjectionPeriodNumerator). + QuoInt64(ProjectionPeriodDenominator) +} + +func (Keeper) StoreRewardPledge(duration uint64, size uint64, rewardPerByte sdk.DecCoin) sdk.Dec { + + // 2. first N% store rewards + + return rewardPerByte. + Amount. + MulInt64(int64(size)). + MulInt64(int64(duration)). + MulInt64(OrderAmountNumerator). + QuoInt64(OrderAmountDenominator) +} diff --git a/x/node/types/expected_keepers.go b/x/node/types/expected_keepers.go index 4b520243..3a145517 100644 --- a/x/node/types/expected_keepers.go +++ b/x/node/types/expected_keepers.go @@ -45,17 +45,7 @@ type StakingKeeper interface { // OrderKeeper interface type OrderKeeper interface { - NewOrder(ctx sdk.Context, order *ordertypes.Order, sp []string) (uint64, error) - GenerateShards(ctx sdk.Context, order *ordertypes.Order, sps []string) - MigrateShard(ctx sdk.Context, order *ordertypes.Order, from string, to string) *ordertypes.Shard - GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) - SetOrder(ctx sdk.Context, order ordertypes.Order) - TerminateOrder(ctx sdk.Context, orderId uint64, refundCoin sdk.Coin) error - FulfillShard(ctx sdk.Context, order *ordertypes.Order, sp string, cid string, size uint64) error - TerminateShard(ctx sdk.Context, shard *ordertypes.Shard, sp string, owner string, orderId uint64) error GetOrderShardBySP(ctx sdk.Context, order *ordertypes.Order, sp string) *ordertypes.Shard - GetShard(ctx sdk.Context, id uint64) (val ordertypes.Shard, found bool) - RemoveShard(ctx sdk.Context, id uint64) SetShard(ctx sdk.Context, shard ordertypes.Shard) } diff --git a/x/order/keeper/grpc_query_order.go b/x/order/keeper/grpc_query_order.go index c62ac44f..55460d19 100644 --- a/x/order/keeper/grpc_query_order.go +++ b/x/order/keeper/grpc_query_order.go @@ -170,6 +170,7 @@ func (k Keeper) Order(c context.Context, req *types.QueryGetOrderRequest) (*type Timeout: order.Timeout, DataId: order.DataId, Commit: order.Commit, + UnitPrice: order.UnitPrice, } return &types.QueryGetOrderResponse{Order: fullOrder}, nil diff --git a/x/order/keeper/migrations.go b/x/order/keeper/migrations.go index 8513c522..f5007cf1 100644 --- a/x/order/keeper/migrations.go +++ b/x/order/keeper/migrations.go @@ -2,6 +2,7 @@ package keeper import ( v2 "github.com/SaoNetwork/sao/x/order/migrations/v2" + v3 "github.com/SaoNetwork/sao/x/order/migrations/v3" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,3 +17,7 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v2.MigrateStore(ctx, m.keeper.RefundOrder, m.keeper.storeKey, m.keeper.modelStoreKey, m.keeper.cdc) } + +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/order/keeper/shard_management.go b/x/order/keeper/shard_management.go index ad60936e..673fee6b 100644 --- a/x/order/keeper/shard_management.go +++ b/x/order/keeper/shard_management.go @@ -34,25 +34,17 @@ func (k Keeper) NewShardTask(ctx sdk.Context, order *types.Order, provider strin return &shard } -func (k Keeper) FulfillShard(ctx sdk.Context, order *types.Order, sp string, cid string, _ uint64) error { - - shard := k.GetOrderShardBySP(ctx, order, sp) - if shard == nil { - return status.Errorf(codes.NotFound, "shard of %s not found", sp) - } +func (k Keeper) FulfillShard(ctx sdk.Context, shard *types.Shard, sp string, cid string) { shard.Status = types.ShardCompleted shard.Cid = cid ctx.EventManager().EmitEvent( sdk.NewEvent(types.ShardCompletedEventType, - sdk.NewAttribute(types.EventOrderId, fmt.Sprintf("%d", order.Id)), + sdk.NewAttribute(types.EventOrderId, fmt.Sprintf("%d", shard.OrderId)), sdk.NewAttribute(types.ShardEventProvider, sp), ), ) - - k.SetShard(ctx, *shard) - return nil } func (k Keeper) TerminateShard(ctx sdk.Context, shard *types.Shard, sp string, owner string, orderId uint64) error { diff --git a/x/order/migrations/v2/types/order.pb.go b/x/order/migrations/v2/types/order.pb.go new file mode 100644 index 00000000..962ce20f --- /dev/null +++ b/x/order/migrations/v2/types/order.pb.go @@ -0,0 +1,2089 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/order/order.proto + +package types + +import ( + fmt "fmt" + ordertypes "github.com/SaoNetwork/sao/x/order/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Order struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + Provider string `protobuf:"bytes,4,opt,name=provider,proto3" json:"provider,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Duration uint64 `protobuf:"varint,6,opt,name=duration,proto3" json:"duration,omitempty"` + Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` + Replica int32 `protobuf:"varint,8,opt,name=replica,proto3" json:"replica,omitempty"` + Shards []uint64 `protobuf:"varint,9,rep,packed,name=shards,proto3" json:"shards,omitempty"` + Amount types.Coin `protobuf:"bytes,10,opt,name=amount,proto3" json:"amount"` + Size_ uint64 `protobuf:"varint,11,opt,name=size,proto3" json:"size,omitempty"` + Operation uint32 `protobuf:"varint,12,opt,name=operation,proto3" json:"operation,omitempty"` + CreatedAt uint64 `protobuf:"varint,13,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Timeout uint64 `protobuf:"varint,14,opt,name=timeout,proto3" json:"timeout,omitempty"` + DataId string `protobuf:"bytes,15,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"` + Commit string `protobuf:"bytes,16,opt,name=commit,proto3" json:"commit,omitempty"` +} + +func (m *Order) Reset() { *m = Order{} } +func (m *Order) String() string { return proto.CompactTextString(m) } +func (*Order) ProtoMessage() {} +func (*Order) Descriptor() ([]byte, []int) { + return fileDescriptor_c44268bce5a81caa, []int{0} +} +func (m *Order) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Order) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Order.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Order) XXX_Merge(src proto.Message) { + xxx_messageInfo_Order.Merge(m, src) +} +func (m *Order) XXX_Size() int { + return m.Size() +} +func (m *Order) XXX_DiscardUnknown() { + xxx_messageInfo_Order.DiscardUnknown(m) +} + +var xxx_messageInfo_Order proto.InternalMessageInfo + +func (m *Order) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *Order) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Order) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *Order) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +func (m *Order) GetCid() string { + if m != nil { + return m.Cid + } + return "" +} + +func (m *Order) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *Order) GetStatus() int32 { + if m != nil { + return m.Status + } + return 0 +} + +func (m *Order) GetReplica() int32 { + if m != nil { + return m.Replica + } + return 0 +} + +func (m *Order) GetShards() []uint64 { + if m != nil { + return m.Shards + } + return nil +} + +func (m *Order) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *Order) GetSize_() uint64 { + if m != nil { + return m.Size_ + } + return 0 +} + +func (m *Order) GetOperation() uint32 { + if m != nil { + return m.Operation + } + return 0 +} + +func (m *Order) GetCreatedAt() uint64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + +func (m *Order) GetTimeout() uint64 { + if m != nil { + return m.Timeout + } + return 0 +} + +func (m *Order) GetDataId() string { + if m != nil { + return m.DataId + } + return "" +} + +func (m *Order) GetCommit() string { + if m != nil { + return m.Commit + } + return "" +} + +type FullOrder struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + Provider string `protobuf:"bytes,4,opt,name=provider,proto3" json:"provider,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Duration uint64 `protobuf:"varint,6,opt,name=duration,proto3" json:"duration,omitempty"` + Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` + Replica int32 `protobuf:"varint,8,opt,name=replica,proto3" json:"replica,omitempty"` + ShardIds []uint64 `protobuf:"varint,9,rep,packed,name=shardIds,proto3" json:"shardIds,omitempty"` + Shards map[string]*ordertypes.Shard `protobuf:"bytes,10,rep,name=shards,proto3" json:"shards,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Amount types.Coin `protobuf:"bytes,11,opt,name=amount,proto3" json:"amount"` + Size_ uint64 `protobuf:"varint,12,opt,name=size,proto3" json:"size,omitempty"` + Operation uint32 `protobuf:"varint,13,opt,name=operation,proto3" json:"operation,omitempty"` + CreatedAt uint64 `protobuf:"varint,14,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Timeout uint64 `protobuf:"varint,15,opt,name=timeout,proto3" json:"timeout,omitempty"` + DataId string `protobuf:"bytes,16,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"` + Commit string `protobuf:"bytes,17,opt,name=commit,proto3" json:"commit,omitempty"` +} + +func (m *FullOrder) Reset() { *m = FullOrder{} } +func (m *FullOrder) String() string { return proto.CompactTextString(m) } +func (*FullOrder) ProtoMessage() {} +func (*FullOrder) Descriptor() ([]byte, []int) { + return fileDescriptor_c44268bce5a81caa, []int{1} +} +func (m *FullOrder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FullOrder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FullOrder.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FullOrder) XXX_Merge(src proto.Message) { + xxx_messageInfo_FullOrder.Merge(m, src) +} +func (m *FullOrder) XXX_Size() int { + return m.Size() +} +func (m *FullOrder) XXX_DiscardUnknown() { + xxx_messageInfo_FullOrder.DiscardUnknown(m) +} + +var xxx_messageInfo_FullOrder proto.InternalMessageInfo + +func (m *FullOrder) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *FullOrder) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *FullOrder) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *FullOrder) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +func (m *FullOrder) GetCid() string { + if m != nil { + return m.Cid + } + return "" +} + +func (m *FullOrder) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *FullOrder) GetStatus() int32 { + if m != nil { + return m.Status + } + return 0 +} + +func (m *FullOrder) GetReplica() int32 { + if m != nil { + return m.Replica + } + return 0 +} + +func (m *FullOrder) GetShardIds() []uint64 { + if m != nil { + return m.ShardIds + } + return nil +} + +func (m *FullOrder) GetShards() map[string]*ordertypes.Shard { + if m != nil { + return m.Shards + } + return nil +} + +func (m *FullOrder) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *FullOrder) GetSize_() uint64 { + if m != nil { + return m.Size_ + } + return 0 +} + +func (m *FullOrder) GetOperation() uint32 { + if m != nil { + return m.Operation + } + return 0 +} + +func (m *FullOrder) GetCreatedAt() uint64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + +func (m *FullOrder) GetTimeout() uint64 { + if m != nil { + return m.Timeout + } + return 0 +} + +func (m *FullOrder) GetDataId() string { + if m != nil { + return m.DataId + } + return "" +} + +func (m *FullOrder) GetCommit() string { + if m != nil { + return m.Commit + } + return "" +} + +func init() { + proto.RegisterType((*Order)(nil), "saonetwork.sao.order.V2Order") + proto.RegisterType((*FullOrder)(nil), "saonetwork.sao.order.V2FullOrder") + proto.RegisterMapType((map[string]*ordertypes.Shard)(nil), "saonetwork.sao.order.FullOrder.V2ShardsEntry") +} + +func init() { proto.RegisterFile("sao/order/order.proto", fileDescriptor_c44268bce5a81caa) } + +var fileDescriptor_c44268bce5a81caa = []byte{ + // 557 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x9b, 0x36, 0xed, 0x56, 0x67, 0xed, 0x8a, 0x55, 0xc0, 0x14, 0x08, 0xd1, 0x2e, 0x44, + 0x42, 0x4a, 0xd4, 0x72, 0x00, 0x71, 0xdb, 0x26, 0x90, 0x76, 0x01, 0x29, 0x93, 0x38, 0x70, 0x99, + 0xdc, 0xc4, 0xea, 0xac, 0x35, 0x79, 0x95, 0xed, 0x74, 0x94, 0x4f, 0xc1, 0x47, 0xe1, 0x63, 0xec, + 0xb8, 0x0b, 0x12, 0x27, 0x84, 0xda, 0x2f, 0x82, 0xec, 0xa4, 0x59, 0x0f, 0xed, 0x0e, 0xdc, 0xb8, + 0x44, 0xef, 0xff, 0xde, 0xf3, 0xd3, 0xf3, 0xff, 0xa7, 0x18, 0x3d, 0x94, 0x14, 0x42, 0x10, 0x09, + 0x13, 0xc5, 0x37, 0x98, 0x09, 0x50, 0x80, 0xfb, 0x92, 0x42, 0xc6, 0xd4, 0x35, 0x88, 0xab, 0x40, + 0x52, 0x08, 0x4c, 0x6d, 0x40, 0xee, 0x9a, 0x53, 0xa6, 0x68, 0x42, 0x15, 0x2d, 0xfa, 0x07, 0x1b, + 0x63, 0xe4, 0x25, 0x15, 0x49, 0x99, 0xee, 0x4f, 0x60, 0x02, 0x26, 0x0c, 0x75, 0x54, 0x66, 0xdd, + 0x18, 0x64, 0x0a, 0x32, 0x1c, 0x53, 0xc9, 0xc2, 0xf9, 0x70, 0xcc, 0x14, 0x1d, 0x86, 0x31, 0xf0, + 0xac, 0xa8, 0x1f, 0xfd, 0x68, 0xa0, 0xe6, 0x27, 0x3d, 0x0b, 0x13, 0xb4, 0x17, 0x0b, 0x46, 0x15, + 0x08, 0x62, 0x79, 0x96, 0xdf, 0x8e, 0xd6, 0x12, 0xf7, 0x51, 0x13, 0xae, 0x33, 0x26, 0x48, 0xdd, + 0xe4, 0x0b, 0x81, 0xbb, 0xa8, 0xce, 0x13, 0xd2, 0xf0, 0x2c, 0xdf, 0x8e, 0xea, 0x3c, 0xc1, 0x03, + 0xb4, 0x3f, 0x13, 0x30, 0xe7, 0x09, 0x13, 0xc4, 0x36, 0x8d, 0x95, 0xc6, 0x3d, 0xd4, 0x88, 0x79, + 0x42, 0x9a, 0x26, 0xad, 0x43, 0xdd, 0x9d, 0xe4, 0x82, 0x2a, 0x0e, 0x19, 0x69, 0x99, 0x19, 0x95, + 0xc6, 0x8f, 0x50, 0x4b, 0x2a, 0xaa, 0x72, 0x49, 0xf6, 0x3c, 0xcb, 0x6f, 0x46, 0xa5, 0xd2, 0x1b, + 0x0a, 0x36, 0x9b, 0xf2, 0x98, 0x92, 0x7d, 0x53, 0x58, 0x4b, 0x73, 0x42, 0x5b, 0x21, 0x49, 0xdb, + 0x6b, 0xf8, 0x76, 0x54, 0x2a, 0xfc, 0x06, 0xb5, 0x68, 0x0a, 0x79, 0xa6, 0x08, 0xf2, 0x2c, 0xdf, + 0x19, 0x3d, 0x09, 0x0a, 0x3b, 0x02, 0x6d, 0x47, 0x50, 0xda, 0x11, 0x9c, 0x02, 0xcf, 0x4e, 0xec, + 0x9b, 0xdf, 0x2f, 0x6a, 0x51, 0xd9, 0x8e, 0x31, 0xb2, 0x25, 0xff, 0xc6, 0x88, 0x63, 0x56, 0x33, + 0x31, 0x7e, 0x86, 0xda, 0x30, 0x63, 0xe5, 0xce, 0x07, 0x9e, 0xe5, 0x77, 0xa2, 0xbb, 0x04, 0x7e, + 0x8e, 0x90, 0xf1, 0x8b, 0x25, 0x17, 0x54, 0x91, 0x8e, 0x39, 0xd7, 0x2e, 0x33, 0xc7, 0x4a, 0xef, + 0xae, 0x78, 0xca, 0x20, 0x57, 0xa4, 0x6b, 0x6a, 0x6b, 0x89, 0x1f, 0xa3, 0x3d, 0x0d, 0xf7, 0x82, + 0x27, 0xe4, 0xd0, 0xf8, 0xd3, 0xd2, 0xf2, 0x2c, 0xd1, 0x97, 0x8a, 0x21, 0x4d, 0xb9, 0x22, 0xbd, + 0x22, 0x5f, 0xa8, 0xa3, 0x9f, 0x36, 0x6a, 0x7f, 0xc8, 0xa7, 0xd3, 0xff, 0x1f, 0xdb, 0x00, 0xed, + 0x1b, 0x50, 0x67, 0x15, 0xb8, 0x4a, 0xe3, 0xd3, 0x0a, 0x29, 0xf2, 0x1a, 0xbe, 0x33, 0x7a, 0x15, + 0x6c, 0xfb, 0x4d, 0x82, 0xca, 0x88, 0xe0, 0xdc, 0x74, 0xbf, 0xcf, 0x94, 0x58, 0x6c, 0xe1, 0xef, + 0xfc, 0x1b, 0xff, 0x83, 0x5d, 0xfc, 0x3b, 0xf7, 0xf3, 0xef, 0xde, 0xc3, 0xff, 0x70, 0x27, 0xff, + 0xde, 0x0e, 0xfe, 0x0f, 0x36, 0xf9, 0x0f, 0x3e, 0x23, 0x67, 0xe3, 0xae, 0x1a, 0xd2, 0x15, 0x5b, + 0x94, 0xf0, 0x75, 0x88, 0x87, 0xa8, 0x39, 0xa7, 0xd3, 0x9c, 0x19, 0xf0, 0xce, 0xe8, 0xe9, 0x76, + 0xe7, 0xcc, 0x8c, 0xa8, 0xe8, 0x7c, 0x57, 0x7f, 0x6b, 0x9d, 0x1c, 0xdf, 0x2c, 0x5d, 0xeb, 0x76, + 0xe9, 0x5a, 0x7f, 0x96, 0xae, 0xf5, 0x7d, 0xe5, 0xd6, 0x6e, 0x57, 0x6e, 0xed, 0xd7, 0xca, 0xad, + 0x7d, 0x79, 0x39, 0xe1, 0xea, 0x32, 0x1f, 0x07, 0x31, 0xa4, 0xe1, 0x39, 0x85, 0x8f, 0xc5, 0xac, + 0x50, 0xbf, 0x43, 0x5f, 0xcb, 0x97, 0x48, 0x2d, 0x66, 0x4c, 0x8e, 0x5b, 0xe6, 0x51, 0x79, 0xfd, + 0x37, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x67, 0x90, 0x90, 0xea, 0x04, 0x00, 0x00, +} + +func (m *Order) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Order) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Commit) > 0 { + i -= len(m.Commit) + copy(dAtA[i:], m.Commit) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Commit))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if len(m.DataId) > 0 { + i -= len(m.DataId) + copy(dAtA[i:], m.DataId) + i = encodeVarintOrder(dAtA, i, uint64(len(m.DataId))) + i-- + dAtA[i] = 0x7a + } + if m.Timeout != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Timeout)) + i-- + dAtA[i] = 0x70 + } + if m.CreatedAt != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x68 + } + if m.Operation != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Operation)) + i-- + dAtA[i] = 0x60 + } + if m.Size_ != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Size_)) + i-- + dAtA[i] = 0x58 + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if len(m.Shards) > 0 { + dAtA3 := make([]byte, len(m.Shards)*10) + var j2 int + for _, num := range m.Shards { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintOrder(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0x4a + } + if m.Replica != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Replica)) + i-- + dAtA[i] = 0x40 + } + if m.Status != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x38 + } + if m.Duration != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x30 + } + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Cid))) + i-- + dAtA[i] = 0x2a + } + if len(m.Provider) > 0 { + i -= len(m.Provider) + copy(dAtA[i:], m.Provider) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Provider))) + i-- + dAtA[i] = 0x22 + } + if m.Id != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FullOrder) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FullOrder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FullOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Commit) > 0 { + i -= len(m.Commit) + copy(dAtA[i:], m.Commit) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Commit))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + if len(m.DataId) > 0 { + i -= len(m.DataId) + copy(dAtA[i:], m.DataId) + i = encodeVarintOrder(dAtA, i, uint64(len(m.DataId))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + if m.Timeout != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Timeout)) + i-- + dAtA[i] = 0x78 + } + if m.CreatedAt != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x70 + } + if m.Operation != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Operation)) + i-- + dAtA[i] = 0x68 + } + if m.Size_ != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Size_)) + i-- + dAtA[i] = 0x60 + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + if len(m.Shards) > 0 { + for k := range m.Shards { + v := m.Shards[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintOrder(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintOrder(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x52 + } + } + if len(m.ShardIds) > 0 { + dAtA7 := make([]byte, len(m.ShardIds)*10) + var j6 int + for _, num := range m.ShardIds { + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + i -= j6 + copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintOrder(dAtA, i, uint64(j6)) + i-- + dAtA[i] = 0x4a + } + if m.Replica != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Replica)) + i-- + dAtA[i] = 0x40 + } + if m.Status != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x38 + } + if m.Duration != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x30 + } + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Cid))) + i-- + dAtA[i] = 0x2a + } + if len(m.Provider) > 0 { + i -= len(m.Provider) + copy(dAtA[i:], m.Provider) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Provider))) + i-- + dAtA[i] = 0x22 + } + if m.Id != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x18 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintOrder(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOrder(dAtA []byte, offset int, v uint64) int { + offset -= sovOrder(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Order) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovOrder(uint64(m.Id)) + } + l = len(m.Provider) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + l = len(m.Cid) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovOrder(uint64(m.Duration)) + } + if m.Status != 0 { + n += 1 + sovOrder(uint64(m.Status)) + } + if m.Replica != 0 { + n += 1 + sovOrder(uint64(m.Replica)) + } + if len(m.Shards) > 0 { + l = 0 + for _, e := range m.Shards { + l += sovOrder(uint64(e)) + } + n += 1 + sovOrder(uint64(l)) + l + } + l = m.Amount.Size() + n += 1 + l + sovOrder(uint64(l)) + if m.Size_ != 0 { + n += 1 + sovOrder(uint64(m.Size_)) + } + if m.Operation != 0 { + n += 1 + sovOrder(uint64(m.Operation)) + } + if m.CreatedAt != 0 { + n += 1 + sovOrder(uint64(m.CreatedAt)) + } + if m.Timeout != 0 { + n += 1 + sovOrder(uint64(m.Timeout)) + } + l = len(m.DataId) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + l = len(m.Commit) + if l > 0 { + n += 2 + l + sovOrder(uint64(l)) + } + return n +} + +func (m *FullOrder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovOrder(uint64(m.Id)) + } + l = len(m.Provider) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + l = len(m.Cid) + if l > 0 { + n += 1 + l + sovOrder(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovOrder(uint64(m.Duration)) + } + if m.Status != 0 { + n += 1 + sovOrder(uint64(m.Status)) + } + if m.Replica != 0 { + n += 1 + sovOrder(uint64(m.Replica)) + } + if len(m.ShardIds) > 0 { + l = 0 + for _, e := range m.ShardIds { + l += sovOrder(uint64(e)) + } + n += 1 + sovOrder(uint64(l)) + l + } + if len(m.Shards) > 0 { + for k, v := range m.Shards { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOrder(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOrder(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOrder(uint64(mapEntrySize)) + } + } + l = m.Amount.Size() + n += 1 + l + sovOrder(uint64(l)) + if m.Size_ != 0 { + n += 1 + sovOrder(uint64(m.Size_)) + } + if m.Operation != 0 { + n += 1 + sovOrder(uint64(m.Operation)) + } + if m.CreatedAt != 0 { + n += 1 + sovOrder(uint64(m.CreatedAt)) + } + if m.Timeout != 0 { + n += 1 + sovOrder(uint64(m.Timeout)) + } + l = len(m.DataId) + if l > 0 { + n += 2 + l + sovOrder(uint64(l)) + } + l = len(m.Commit) + if l > 0 { + n += 2 + l + sovOrder(uint64(l)) + } + return n +} + +func sovOrder(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOrder(x uint64) (n int) { + return sovOrder(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Order) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Order: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Order: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Provider", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Provider = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Replica", wireType) + } + m.Replica = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Replica |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Shards = append(m.Shards, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Shards) == 0 { + m.Shards = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Shards = append(m.Shards, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Shards", wireType) + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + m.Operation = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Operation |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + m.Timeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timeout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DataId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FullOrder) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FullOrder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FullOrder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Provider", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Provider = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Replica", wireType) + } + m.Replica = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Replica |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ShardIds = append(m.ShardIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ShardIds) == 0 { + m.ShardIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ShardIds = append(m.ShardIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ShardIds", wireType) + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Shards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Shards == nil { + m.Shards = make(map[string]*ordertypes.Shard) + } + var mapkey string + var mapvalue *ordertypes.Shard + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOrder + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOrder + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOrder + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOrder + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ordertypes.Shard{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Shards[mapkey] = mapvalue + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + m.Operation = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Operation |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeout", wireType) + } + m.Timeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timeout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DataId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOrder(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOrder + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOrder + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOrder + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOrder = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOrder = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOrder = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/order/migrations/v2/types/shard.pb.go b/x/order/migrations/v2/types/shard.pb.go new file mode 100644 index 00000000..a7d92f17 --- /dev/null +++ b/x/order/migrations/v2/types/shard.pb.go @@ -0,0 +1,621 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/order/shard.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Shard struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + OrderId uint64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` + Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Pledge types.Coin `protobuf:"bytes,6,opt,name=pledge,proto3" json:"pledge"` + From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"` + Sp string `protobuf:"bytes,8,opt,name=sp,proto3" json:"sp,omitempty"` +} + +func (m *Shard) Reset() { *m = Shard{} } +func (m *Shard) String() string { return proto.CompactTextString(m) } +func (*Shard) ProtoMessage() {} +func (*Shard) Descriptor() ([]byte, []int) { + return fileDescriptor_b050d2e483ae2036, []int{0} +} +func (m *Shard) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Shard) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Shard.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Shard) XXX_Merge(src proto.Message) { + xxx_messageInfo_Shard.Merge(m, src) +} +func (m *Shard) XXX_Size() int { + return m.Size() +} +func (m *Shard) XXX_DiscardUnknown() { + xxx_messageInfo_Shard.DiscardUnknown(m) +} + +var xxx_messageInfo_Shard proto.InternalMessageInfo + +func (m *Shard) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *Shard) GetOrderId() uint64 { + if m != nil { + return m.OrderId + } + return 0 +} + +func (m *Shard) GetStatus() int32 { + if m != nil { + return m.Status + } + return 0 +} + +func (m *Shard) GetSize_() uint64 { + if m != nil { + return m.Size_ + } + return 0 +} + +func (m *Shard) GetCid() string { + if m != nil { + return m.Cid + } + return "" +} + +func (m *Shard) GetPledge() types.Coin { + if m != nil { + return m.Pledge + } + return types.Coin{} +} + +func (m *Shard) GetFrom() string { + if m != nil { + return m.From + } + return "" +} + +func (m *Shard) GetSp() string { + if m != nil { + return m.Sp + } + return "" +} + +func init() { + proto.RegisterType((*Shard)(nil), "saonetwork.sao.order.V2Shard") +} + +func init() { proto.RegisterFile("sao/order/shard.proto", fileDescriptor_b050d2e483ae2036) } + +var fileDescriptor_b050d2e483ae2036 = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x90, 0xbf, 0x4e, 0xeb, 0x30, + 0x18, 0xc5, 0xe3, 0x34, 0x4d, 0xef, 0xf5, 0x95, 0xae, 0x90, 0x55, 0x90, 0xe9, 0x60, 0x22, 0x16, + 0x32, 0xd9, 0x2a, 0x0c, 0xcc, 0x94, 0x89, 0x85, 0x21, 0xdd, 0xd8, 0x9c, 0xd8, 0xa4, 0x16, 0xb4, + 0x5f, 0x14, 0xbb, 0xfc, 0x7b, 0x0a, 0x1e, 0xab, 0x03, 0x43, 0x47, 0x26, 0x84, 0xda, 0x17, 0x41, + 0x76, 0xc2, 0xf6, 0xfb, 0x8e, 0xce, 0x77, 0x74, 0x74, 0xf0, 0xa1, 0x95, 0x20, 0xa0, 0x55, 0xba, + 0x15, 0x76, 0x21, 0x5b, 0xc5, 0x9b, 0x16, 0x1c, 0x90, 0xb1, 0x95, 0xb0, 0xd2, 0xee, 0x19, 0xda, + 0x07, 0x6e, 0x25, 0xf0, 0xe0, 0x98, 0xb0, 0x0a, 0xec, 0x12, 0xac, 0x28, 0xa5, 0xd5, 0xe2, 0x69, + 0x5a, 0x6a, 0x27, 0xa7, 0xa2, 0x02, 0xb3, 0xea, 0xbe, 0x26, 0xe3, 0x1a, 0x6a, 0x08, 0x28, 0x3c, + 0x75, 0xea, 0xe9, 0x07, 0xc2, 0xc3, 0xb9, 0xcf, 0x26, 0xff, 0x71, 0x6c, 0x14, 0x45, 0x19, 0xca, + 0x93, 0x22, 0x36, 0x8a, 0x50, 0x3c, 0x0a, 0xc1, 0x37, 0x8a, 0xc6, 0x41, 0xfc, 0x3d, 0xc9, 0x11, + 0x4e, 0xad, 0x93, 0x6e, 0x6d, 0xe9, 0x20, 0x43, 0xf9, 0xb0, 0xe8, 0x2f, 0x42, 0x70, 0x62, 0xcd, + 0x9b, 0xa6, 0x49, 0xb0, 0x07, 0x26, 0x07, 0x78, 0x50, 0x19, 0x45, 0x87, 0x19, 0xca, 0xff, 0x16, + 0x1e, 0xc9, 0x25, 0x4e, 0x9b, 0x47, 0xad, 0x6a, 0x4d, 0xd3, 0x0c, 0xe5, 0xff, 0xce, 0x8f, 0x79, + 0x57, 0x9c, 0xfb, 0xe2, 0xbc, 0x2f, 0xce, 0xaf, 0xc1, 0xac, 0x66, 0xc9, 0xe6, 0xeb, 0x24, 0x2a, + 0x7a, 0xbb, 0x8f, 0xbf, 0x6f, 0x61, 0x49, 0x47, 0x21, 0x2b, 0xb0, 0x2f, 0x6d, 0x1b, 0xfa, 0x27, + 0x28, 0xb1, 0x6d, 0x66, 0x57, 0x9b, 0x1d, 0x43, 0xdb, 0x1d, 0x43, 0xdf, 0x3b, 0x86, 0xde, 0xf7, + 0x2c, 0xda, 0xee, 0x59, 0xf4, 0xb9, 0x67, 0xd1, 0xdd, 0x59, 0x6d, 0xdc, 0x62, 0x5d, 0xf2, 0x0a, + 0x96, 0x62, 0x2e, 0xe1, 0xb6, 0xdb, 0x4f, 0xf8, 0x85, 0x5f, 0xfa, 0x8d, 0xdd, 0x6b, 0xa3, 0x6d, + 0x99, 0x86, 0x61, 0x2e, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xc7, 0x4a, 0xbc, 0x7d, 0x01, + 0x00, 0x00, +} + +func (m *Shard) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Shard) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Shard) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sp) > 0 { + i -= len(m.Sp) + copy(dAtA[i:], m.Sp) + i = encodeVarintShard(dAtA, i, uint64(len(m.Sp))) + i-- + dAtA[i] = 0x42 + } + if len(m.From) > 0 { + i -= len(m.From) + copy(dAtA[i:], m.From) + i = encodeVarintShard(dAtA, i, uint64(len(m.From))) + i-- + dAtA[i] = 0x3a + } + { + size, err := m.Pledge.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintShard(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintShard(dAtA, i, uint64(len(m.Cid))) + i-- + dAtA[i] = 0x2a + } + if m.Size_ != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.Size_)) + i-- + dAtA[i] = 0x20 + } + if m.Status != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if m.OrderId != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.OrderId)) + i-- + dAtA[i] = 0x10 + } + if m.Id != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintShard(dAtA []byte, offset int, v uint64) int { + offset -= sovShard(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Shard) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovShard(uint64(m.Id)) + } + if m.OrderId != 0 { + n += 1 + sovShard(uint64(m.OrderId)) + } + if m.Status != 0 { + n += 1 + sovShard(uint64(m.Status)) + } + if m.Size_ != 0 { + n += 1 + sovShard(uint64(m.Size_)) + } + l = len(m.Cid) + if l > 0 { + n += 1 + l + sovShard(uint64(l)) + } + l = m.Pledge.Size() + n += 1 + l + sovShard(uint64(l)) + l = len(m.From) + if l > 0 { + n += 1 + l + sovShard(uint64(l)) + } + l = len(m.Sp) + if l > 0 { + n += 1 + l + sovShard(uint64(l)) + } + return n +} + +func sovShard(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozShard(x uint64) (n int) { + return sovShard(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Shard) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Shard: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Shard: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderId", wireType) + } + m.OrderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OrderId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShard + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShard + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pledge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShard + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.From = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sp", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthShard + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipShard(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthShard + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipShard(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthShard + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupShard + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthShard + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthShard = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowShard = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupShard = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/order/migrations/v3/migrations.go b/x/order/migrations/v3/migrations.go new file mode 100644 index 00000000..fdbd38fd --- /dev/null +++ b/x/order/migrations/v3/migrations.go @@ -0,0 +1,87 @@ +package v3 + +import ( + "encoding/binary" + v2order "github.com/SaoNetwork/sao/x/order/migrations/v2/types" + "github.com/SaoNetwork/sao/x/order/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + orderStore := prefix.NewStore(store, types.KeyPrefix(types.OrderKey)) + + iterator := sdk.KVStorePrefixIterator(orderStore, []byte{}) + + shardStore := prefix.NewStore(store, types.KeyPrefix(types.ShardKey)) + + logger := ctx.Logger() + logger.Debug("v3 order migrations, reward per byte") + for ; iterator.Valid(); iterator.Next() { + orderKey := iterator.Key() + oldVal := orderStore.Get(orderKey) + var order v2order.Order + cdc.MustUnmarshal(oldVal, &order) + amount := sdk.NewDecCoinFromCoin(order.Amount) + rewardPerByte := amount.Amount.QuoInt64(int64(order.Replica)).QuoInt64(int64(order.Duration)).QuoInt64(int64(order.Size_)) + newOrder := types.Order{ + Creator: order.Creator, + Owner: order.Owner, + Id: order.Id, + Provider: order.Provider, + Cid: order.Cid, + Duration: order.Duration, + Status: order.Status, + Replica: order.Replica, + Shards: order.Shards, + Amount: order.Amount, + Size_: order.Size_, + Operation: order.Operation, + CreatedAt: order.CreatedAt, + Timeout: order.Timeout, + DataId: order.DataId, + Commit: order.Commit, + UnitPrice: sdk.NewDecCoinFromDec(amount.Denom, rewardPerByte), + } + + newVal := cdc.MustMarshal(&newOrder) + orderStore.Set(orderKey, newVal) + + for _, shardId := range order.Shards { + shardKey := GetShardIDBytes(shardId) + val := shardStore.Get(shardKey) + var shard v2order.Shard + cdc.MustUnmarshal(val, &shard) + + newShard := types.Shard{ + Id: shard.Id, + OrderId: shard.OrderId, + Status: shard.Status, + Size_: shard.Size_, + Cid: shard.Cid, + Pledge: shard.Pledge, + From: shard.From, + Sp: shard.Sp, + Duration: order.Duration, + CreatedAt: order.CreatedAt, + } + + newVal := cdc.MustMarshal(&newShard) + shardStore.Set(shardKey, newVal) + } + + } + + return nil +} + +// GetShardIDBytes returns the byte representation of the ID +func GetShardIDBytes(id uint64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, id) + return bz +} diff --git a/x/order/module.go b/x/order/module.go index e0d98481..54e5d669 100644 --- a/x/order/module.go +++ b/x/order/module.go @@ -132,6 +132,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) } + if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate2to3); err != nil { + panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) + } } @@ -156,7 +159,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/order/types/order.pb.go b/x/order/types/order.pb.go index 55fb8308..6bdaf1fd 100644 --- a/x/order/types/order.pb.go +++ b/x/order/types/order.pb.go @@ -25,22 +25,23 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Order struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` - Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` - Provider string `protobuf:"bytes,4,opt,name=provider,proto3" json:"provider,omitempty"` - Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` - Duration uint64 `protobuf:"varint,6,opt,name=duration,proto3" json:"duration,omitempty"` - Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` - Replica int32 `protobuf:"varint,8,opt,name=replica,proto3" json:"replica,omitempty"` - Shards []uint64 `protobuf:"varint,9,rep,packed,name=shards,proto3" json:"shards,omitempty"` - Amount types.Coin `protobuf:"bytes,10,opt,name=amount,proto3" json:"amount"` - Size_ uint64 `protobuf:"varint,11,opt,name=size,proto3" json:"size,omitempty"` - Operation uint32 `protobuf:"varint,12,opt,name=operation,proto3" json:"operation,omitempty"` - CreatedAt uint64 `protobuf:"varint,13,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - Timeout uint64 `protobuf:"varint,14,opt,name=timeout,proto3" json:"timeout,omitempty"` - DataId string `protobuf:"bytes,15,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"` - Commit string `protobuf:"bytes,16,opt,name=commit,proto3" json:"commit,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + Provider string `protobuf:"bytes,4,opt,name=provider,proto3" json:"provider,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Duration uint64 `protobuf:"varint,6,opt,name=duration,proto3" json:"duration,omitempty"` + Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` + Replica int32 `protobuf:"varint,8,opt,name=replica,proto3" json:"replica,omitempty"` + Shards []uint64 `protobuf:"varint,9,rep,packed,name=shards,proto3" json:"shards,omitempty"` + Amount types.Coin `protobuf:"bytes,10,opt,name=amount,proto3" json:"amount"` + Size_ uint64 `protobuf:"varint,11,opt,name=size,proto3" json:"size,omitempty"` + Operation uint32 `protobuf:"varint,12,opt,name=operation,proto3" json:"operation,omitempty"` + CreatedAt uint64 `protobuf:"varint,13,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Timeout uint64 `protobuf:"varint,14,opt,name=timeout,proto3" json:"timeout,omitempty"` + DataId string `protobuf:"bytes,15,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"` + Commit string `protobuf:"bytes,16,opt,name=commit,proto3" json:"commit,omitempty"` + UnitPrice types.DecCoin `protobuf:"bytes,17,opt,name=unitPrice,proto3" json:"unitPrice"` } func (m *Order) Reset() { *m = Order{} } @@ -188,6 +189,13 @@ func (m *Order) GetCommit() string { return "" } +func (m *Order) GetUnitPrice() types.DecCoin { + if m != nil { + return m.UnitPrice + } + return types.DecCoin{} +} + type FullOrder struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` @@ -206,6 +214,7 @@ type FullOrder struct { Timeout uint64 `protobuf:"varint,15,opt,name=timeout,proto3" json:"timeout,omitempty"` DataId string `protobuf:"bytes,16,opt,name=data_id,json=dataId,proto3" json:"data_id,omitempty"` Commit string `protobuf:"bytes,17,opt,name=commit,proto3" json:"commit,omitempty"` + UnitPrice types.DecCoin `protobuf:"bytes,18,opt,name=unitPrice,proto3" json:"unitPrice"` } func (m *FullOrder) Reset() { *m = FullOrder{} } @@ -360,6 +369,13 @@ func (m *FullOrder) GetCommit() string { return "" } +func (m *FullOrder) GetUnitPrice() types.DecCoin { + if m != nil { + return m.UnitPrice + } + return types.DecCoin{} +} + func init() { proto.RegisterType((*Order)(nil), "saonetwork.sao.order.Order") proto.RegisterType((*FullOrder)(nil), "saonetwork.sao.order.FullOrder") @@ -369,42 +385,44 @@ func init() { func init() { proto.RegisterFile("sao/order/order.proto", fileDescriptor_c44268bce5a81caa) } var fileDescriptor_c44268bce5a81caa = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x9b, 0x36, 0xed, 0x56, 0x67, 0xed, 0x8a, 0x55, 0xc0, 0x14, 0x08, 0xd1, 0x2e, 0x44, - 0x42, 0x4a, 0xd4, 0x72, 0x00, 0x71, 0xdb, 0x26, 0x90, 0x76, 0x01, 0x29, 0x93, 0x38, 0x70, 0x99, - 0xdc, 0xc4, 0xea, 0xac, 0x35, 0x79, 0x95, 0xed, 0x74, 0x94, 0x4f, 0xc1, 0x47, 0xe1, 0x63, 0xec, - 0xb8, 0x0b, 0x12, 0x27, 0x84, 0xda, 0x2f, 0x82, 0xec, 0xa4, 0x59, 0x0f, 0xed, 0x0e, 0xdc, 0xb8, - 0x44, 0xef, 0xff, 0xde, 0xf3, 0xd3, 0xf3, 0xff, 0xa7, 0x18, 0x3d, 0x94, 0x14, 0x42, 0x10, 0x09, - 0x13, 0xc5, 0x37, 0x98, 0x09, 0x50, 0x80, 0xfb, 0x92, 0x42, 0xc6, 0xd4, 0x35, 0x88, 0xab, 0x40, - 0x52, 0x08, 0x4c, 0x6d, 0x40, 0xee, 0x9a, 0x53, 0xa6, 0x68, 0x42, 0x15, 0x2d, 0xfa, 0x07, 0x1b, - 0x63, 0xe4, 0x25, 0x15, 0x49, 0x99, 0xee, 0x4f, 0x60, 0x02, 0x26, 0x0c, 0x75, 0x54, 0x66, 0xdd, - 0x18, 0x64, 0x0a, 0x32, 0x1c, 0x53, 0xc9, 0xc2, 0xf9, 0x70, 0xcc, 0x14, 0x1d, 0x86, 0x31, 0xf0, - 0xac, 0xa8, 0x1f, 0xfd, 0x68, 0xa0, 0xe6, 0x27, 0x3d, 0x0b, 0x13, 0xb4, 0x17, 0x0b, 0x46, 0x15, - 0x08, 0x62, 0x79, 0x96, 0xdf, 0x8e, 0xd6, 0x12, 0xf7, 0x51, 0x13, 0xae, 0x33, 0x26, 0x48, 0xdd, - 0xe4, 0x0b, 0x81, 0xbb, 0xa8, 0xce, 0x13, 0xd2, 0xf0, 0x2c, 0xdf, 0x8e, 0xea, 0x3c, 0xc1, 0x03, - 0xb4, 0x3f, 0x13, 0x30, 0xe7, 0x09, 0x13, 0xc4, 0x36, 0x8d, 0x95, 0xc6, 0x3d, 0xd4, 0x88, 0x79, - 0x42, 0x9a, 0x26, 0xad, 0x43, 0xdd, 0x9d, 0xe4, 0x82, 0x2a, 0x0e, 0x19, 0x69, 0x99, 0x19, 0x95, - 0xc6, 0x8f, 0x50, 0x4b, 0x2a, 0xaa, 0x72, 0x49, 0xf6, 0x3c, 0xcb, 0x6f, 0x46, 0xa5, 0xd2, 0x1b, - 0x0a, 0x36, 0x9b, 0xf2, 0x98, 0x92, 0x7d, 0x53, 0x58, 0x4b, 0x73, 0x42, 0x5b, 0x21, 0x49, 0xdb, - 0x6b, 0xf8, 0x76, 0x54, 0x2a, 0xfc, 0x06, 0xb5, 0x68, 0x0a, 0x79, 0xa6, 0x08, 0xf2, 0x2c, 0xdf, - 0x19, 0x3d, 0x09, 0x0a, 0x3b, 0x02, 0x6d, 0x47, 0x50, 0xda, 0x11, 0x9c, 0x02, 0xcf, 0x4e, 0xec, - 0x9b, 0xdf, 0x2f, 0x6a, 0x51, 0xd9, 0x8e, 0x31, 0xb2, 0x25, 0xff, 0xc6, 0x88, 0x63, 0x56, 0x33, - 0x31, 0x7e, 0x86, 0xda, 0x30, 0x63, 0xe5, 0xce, 0x07, 0x9e, 0xe5, 0x77, 0xa2, 0xbb, 0x04, 0x7e, - 0x8e, 0x90, 0xf1, 0x8b, 0x25, 0x17, 0x54, 0x91, 0x8e, 0x39, 0xd7, 0x2e, 0x33, 0xc7, 0x4a, 0xef, - 0xae, 0x78, 0xca, 0x20, 0x57, 0xa4, 0x6b, 0x6a, 0x6b, 0x89, 0x1f, 0xa3, 0x3d, 0x0d, 0xf7, 0x82, - 0x27, 0xe4, 0xd0, 0xf8, 0xd3, 0xd2, 0xf2, 0x2c, 0xd1, 0x97, 0x8a, 0x21, 0x4d, 0xb9, 0x22, 0xbd, - 0x22, 0x5f, 0xa8, 0xa3, 0x9f, 0x36, 0x6a, 0x7f, 0xc8, 0xa7, 0xd3, 0xff, 0x1f, 0xdb, 0x00, 0xed, - 0x1b, 0x50, 0x67, 0x15, 0xb8, 0x4a, 0xe3, 0xd3, 0x0a, 0x29, 0xf2, 0x1a, 0xbe, 0x33, 0x7a, 0x15, - 0x6c, 0xfb, 0x4d, 0x82, 0xca, 0x88, 0xe0, 0xdc, 0x74, 0xbf, 0xcf, 0x94, 0x58, 0x6c, 0xe1, 0xef, - 0xfc, 0x1b, 0xff, 0x83, 0x5d, 0xfc, 0x3b, 0xf7, 0xf3, 0xef, 0xde, 0xc3, 0xff, 0x70, 0x27, 0xff, - 0xde, 0x0e, 0xfe, 0x0f, 0x36, 0xf9, 0x0f, 0x3e, 0x23, 0x67, 0xe3, 0xae, 0x1a, 0xd2, 0x15, 0x5b, - 0x94, 0xf0, 0x75, 0x88, 0x87, 0xa8, 0x39, 0xa7, 0xd3, 0x9c, 0x19, 0xf0, 0xce, 0xe8, 0xe9, 0x76, - 0xe7, 0xcc, 0x8c, 0xa8, 0xe8, 0x7c, 0x57, 0x7f, 0x6b, 0x9d, 0x1c, 0xdf, 0x2c, 0x5d, 0xeb, 0x76, - 0xe9, 0x5a, 0x7f, 0x96, 0xae, 0xf5, 0x7d, 0xe5, 0xd6, 0x6e, 0x57, 0x6e, 0xed, 0xd7, 0xca, 0xad, - 0x7d, 0x79, 0x39, 0xe1, 0xea, 0x32, 0x1f, 0x07, 0x31, 0xa4, 0xe1, 0x39, 0x85, 0x8f, 0xc5, 0xac, - 0x50, 0xbf, 0x43, 0x5f, 0xcb, 0x97, 0x48, 0x2d, 0x66, 0x4c, 0x8e, 0x5b, 0xe6, 0x51, 0x79, 0xfd, - 0x37, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x67, 0x90, 0x90, 0xea, 0x04, 0x00, 0x00, + // 588 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x6e, 0xda, 0xa6, 0x6d, 0x9c, 0xb5, 0xeb, 0xac, 0x02, 0xa6, 0x8c, 0x10, 0xed, 0x42, 0x24, + 0xa4, 0x44, 0x2d, 0x07, 0x10, 0x27, 0xb6, 0x01, 0xd2, 0x2e, 0x80, 0x32, 0x89, 0x03, 0x97, 0xc9, + 0x4d, 0xac, 0xce, 0x5a, 0x13, 0x57, 0xb6, 0xd3, 0x51, 0x7e, 0x05, 0x37, 0xfe, 0xd2, 0x8e, 0x3b, + 0x72, 0x42, 0xa8, 0xfd, 0x07, 0xfc, 0x02, 0x64, 0x27, 0x4d, 0x7b, 0x68, 0x77, 0xd8, 0x8d, 0x4b, + 0xf4, 0xbe, 0xe7, 0xcf, 0x4f, 0xef, 0x7d, 0xef, 0x8b, 0xc1, 0x03, 0x81, 0x59, 0xc0, 0x78, 0x4c, + 0x78, 0xfe, 0xf5, 0xa7, 0x9c, 0x49, 0x06, 0x7b, 0x02, 0xb3, 0x94, 0xc8, 0x6b, 0xc6, 0xaf, 0x7c, + 0x81, 0x99, 0xaf, 0xcf, 0xfa, 0x68, 0x4d, 0x4e, 0x88, 0xc4, 0x31, 0x96, 0x38, 0xe7, 0xf7, 0x37, + 0xca, 0x88, 0x4b, 0xcc, 0xe3, 0x22, 0xdd, 0x1b, 0xb3, 0x31, 0xd3, 0x61, 0xa0, 0xa2, 0x22, 0xeb, + 0x44, 0x4c, 0x24, 0x4c, 0x04, 0x23, 0x2c, 0x48, 0x30, 0x1b, 0x8c, 0x88, 0xc4, 0x83, 0x20, 0x62, + 0x34, 0xcd, 0xcf, 0x8f, 0xfe, 0xd6, 0x80, 0xf9, 0x49, 0xd5, 0x82, 0x08, 0x34, 0x23, 0x4e, 0xb0, + 0x64, 0x1c, 0x19, 0xae, 0xe1, 0x59, 0xe1, 0x0a, 0xc2, 0x1e, 0x30, 0xd9, 0x75, 0x4a, 0x38, 0xaa, + 0xea, 0x7c, 0x0e, 0x60, 0x07, 0x54, 0x69, 0x8c, 0x6a, 0xae, 0xe1, 0xd5, 0xc3, 0x2a, 0x8d, 0x61, + 0x1f, 0xb4, 0xa6, 0x9c, 0xcd, 0x68, 0x4c, 0x38, 0xaa, 0x6b, 0x62, 0x89, 0x61, 0x17, 0xd4, 0x22, + 0x1a, 0x23, 0x53, 0xa7, 0x55, 0xa8, 0xd8, 0x71, 0xc6, 0xb1, 0xa4, 0x2c, 0x45, 0x0d, 0x5d, 0xa3, + 0xc4, 0xf0, 0x21, 0x68, 0x08, 0x89, 0x65, 0x26, 0x50, 0xd3, 0x35, 0x3c, 0x33, 0x2c, 0x90, 0xea, + 0x90, 0x93, 0xe9, 0x84, 0x46, 0x18, 0xb5, 0xf4, 0xc1, 0x0a, 0xea, 0x1b, 0x4a, 0x0a, 0x81, 0x2c, + 0xb7, 0xe6, 0xd5, 0xc3, 0x02, 0xc1, 0x57, 0xa0, 0x81, 0x13, 0x96, 0xa5, 0x12, 0x01, 0xd7, 0xf0, + 0xec, 0xe1, 0x63, 0x3f, 0x97, 0xc3, 0x57, 0x72, 0xf8, 0x85, 0x1c, 0xfe, 0x29, 0xa3, 0xe9, 0x49, + 0xfd, 0xe6, 0xf7, 0xb3, 0x4a, 0x58, 0xd0, 0x21, 0x04, 0x75, 0x41, 0xbf, 0x13, 0x64, 0xeb, 0xd6, + 0x74, 0x0c, 0x0f, 0x81, 0xc5, 0xa6, 0xa4, 0xe8, 0x79, 0xcf, 0x35, 0xbc, 0x76, 0xb8, 0x4e, 0xc0, + 0xa7, 0x00, 0x68, 0xbd, 0x48, 0x7c, 0x81, 0x25, 0x6a, 0xeb, 0x7b, 0x56, 0x91, 0x39, 0x96, 0xaa, + 0x77, 0x49, 0x13, 0xc2, 0x32, 0x89, 0x3a, 0xfa, 0x6c, 0x05, 0xe1, 0x23, 0xd0, 0x54, 0xcb, 0xbd, + 0xa0, 0x31, 0xda, 0xd7, 0xfa, 0x34, 0x14, 0x3c, 0x8b, 0xd5, 0x50, 0x11, 0x4b, 0x12, 0x2a, 0x51, + 0x37, 0xcf, 0xe7, 0x08, 0xbe, 0x05, 0x56, 0x96, 0x52, 0xf9, 0x99, 0xd3, 0x88, 0xa0, 0x03, 0x3d, + 0xd7, 0xe1, 0xd6, 0xb9, 0xde, 0x91, 0x68, 0x63, 0xb4, 0xf5, 0xa5, 0xa3, 0x9f, 0x26, 0xb0, 0x3e, + 0x64, 0x93, 0xc9, 0xff, 0xbf, 0xf8, 0x3e, 0x68, 0xe9, 0x55, 0x9f, 0x95, 0xab, 0x2f, 0x31, 0x3c, + 0x2d, 0x4d, 0x01, 0xdc, 0x9a, 0x67, 0x0f, 0x5f, 0xf8, 0xdb, 0x7e, 0x34, 0xbf, 0x14, 0xc2, 0x3f, + 0xd7, 0xec, 0xf7, 0xa9, 0xe4, 0xf3, 0x2d, 0x0e, 0xb2, 0xef, 0xe7, 0xa0, 0xbd, 0x5d, 0x0e, 0x6a, + 0xdf, 0xed, 0xa0, 0xce, 0x1d, 0x0e, 0xda, 0xdf, 0xe9, 0xa0, 0xee, 0x0e, 0x07, 0x1d, 0xec, 0x76, + 0x10, 0xbc, 0x87, 0x83, 0xfa, 0x5f, 0x80, 0xbd, 0xa1, 0x96, 0x5a, 0xf3, 0x15, 0x99, 0x17, 0xf6, + 0x51, 0x21, 0x1c, 0x00, 0x73, 0x86, 0x27, 0x19, 0xd1, 0xd6, 0xb1, 0x87, 0x4f, 0xb6, 0x6b, 0xaf, + 0x6b, 0x84, 0x39, 0xf3, 0x4d, 0xf5, 0xb5, 0x71, 0x72, 0x7c, 0xb3, 0x70, 0x8c, 0xdb, 0x85, 0x63, + 0xfc, 0x59, 0x38, 0xc6, 0x8f, 0xa5, 0x53, 0xb9, 0x5d, 0x3a, 0x95, 0x5f, 0x4b, 0xa7, 0xf2, 0xf5, + 0xf9, 0x98, 0xca, 0xcb, 0x6c, 0xe4, 0x47, 0x2c, 0x09, 0xce, 0x31, 0xfb, 0x98, 0xd7, 0x0a, 0xd4, + 0x5b, 0xf8, 0xad, 0x78, 0x0d, 0xe5, 0x7c, 0x4a, 0xc4, 0xa8, 0xa1, 0x1f, 0xb6, 0x97, 0xff, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xde, 0x63, 0xf5, 0xf2, 0x6e, 0x05, 0x00, 0x00, } func (m *Order) Marshal() (dAtA []byte, err error) { @@ -427,6 +445,18 @@ func (m *Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.UnitPrice.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a if len(m.Commit) > 0 { i -= len(m.Commit) copy(dAtA[i:], m.Commit) @@ -474,20 +504,20 @@ func (m *Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 if len(m.Shards) > 0 { - dAtA3 := make([]byte, len(m.Shards)*10) - var j2 int + dAtA4 := make([]byte, len(m.Shards)*10) + var j3 int for _, num := range m.Shards { for num >= 1<<7 { - dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j2++ + j3++ } - dAtA3[j2] = uint8(num) - j2++ + dAtA4[j3] = uint8(num) + j3++ } - i -= j2 - copy(dAtA[i:], dAtA3[:j2]) - i = encodeVarintOrder(dAtA, i, uint64(j2)) + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintOrder(dAtA, i, uint64(j3)) i-- dAtA[i] = 0x4a } @@ -562,6 +592,18 @@ func (m *FullOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.UnitPrice.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 if len(m.Commit) > 0 { i -= len(m.Commit) copy(dAtA[i:], m.Commit) @@ -637,20 +679,20 @@ func (m *FullOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } if len(m.ShardIds) > 0 { - dAtA7 := make([]byte, len(m.ShardIds)*10) - var j6 int + dAtA9 := make([]byte, len(m.ShardIds)*10) + var j8 int for _, num := range m.ShardIds { for num >= 1<<7 { - dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j6++ + j8++ } - dAtA7[j6] = uint8(num) - j6++ + dAtA9[j8] = uint8(num) + j8++ } - i -= j6 - copy(dAtA[i:], dAtA7[:j6]) - i = encodeVarintOrder(dAtA, i, uint64(j6)) + i -= j8 + copy(dAtA[i:], dAtA9[:j8]) + i = encodeVarintOrder(dAtA, i, uint64(j8)) i-- dAtA[i] = 0x4a } @@ -779,6 +821,8 @@ func (m *Order) Size() (n int) { if l > 0 { n += 2 + l + sovOrder(uint64(l)) } + l = m.UnitPrice.Size() + n += 2 + l + sovOrder(uint64(l)) return n } @@ -858,6 +902,8 @@ func (m *FullOrder) Size() (n int) { if l > 0 { n += 2 + l + sovOrder(uint64(l)) } + l = m.UnitPrice.Size() + n += 2 + l + sovOrder(uint64(l)) return n } @@ -1349,6 +1395,39 @@ func (m *Order) Unmarshal(dAtA []byte) error { } m.Commit = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnitPrice", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnitPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOrder(dAtA[iNdEx:]) @@ -1981,6 +2060,39 @@ func (m *FullOrder) Unmarshal(dAtA []byte) error { } m.Commit = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 18: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnitPrice", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnitPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOrder(dAtA[iNdEx:]) diff --git a/x/order/types/shard.pb.go b/x/order/types/shard.pb.go index e95fb566..299340c5 100644 --- a/x/order/types/shard.pb.go +++ b/x/order/types/shard.pb.go @@ -25,14 +25,16 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Shard struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - OrderId uint64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` - Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` - Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` - Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` - Pledge types.Coin `protobuf:"bytes,6,opt,name=pledge,proto3" json:"pledge"` - From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"` - Sp string `protobuf:"bytes,8,opt,name=sp,proto3" json:"sp,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + OrderId uint64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` + Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Pledge types.Coin `protobuf:"bytes,6,opt,name=pledge,proto3" json:"pledge"` + From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"` + Sp string `protobuf:"bytes,8,opt,name=sp,proto3" json:"sp,omitempty"` + Duration uint64 `protobuf:"varint,9,opt,name=duration,proto3" json:"duration,omitempty"` + CreatedAt uint64 `protobuf:"varint,10,opt,name=createdAt,proto3" json:"createdAt,omitempty"` } func (m *Shard) Reset() { *m = Shard{} } @@ -124,6 +126,20 @@ func (m *Shard) GetSp() string { return "" } +func (m *Shard) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *Shard) GetCreatedAt() uint64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + func init() { proto.RegisterType((*Shard)(nil), "saonetwork.sao.order.Shard") } @@ -131,26 +147,28 @@ func init() { func init() { proto.RegisterFile("sao/order/shard.proto", fileDescriptor_b050d2e483ae2036) } var fileDescriptor_b050d2e483ae2036 = []byte{ - // 306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x90, 0xbf, 0x4e, 0xeb, 0x30, - 0x18, 0xc5, 0xe3, 0x34, 0x4d, 0xef, 0xf5, 0x95, 0xae, 0x90, 0x55, 0x90, 0xe9, 0x60, 0x22, 0x16, - 0x32, 0xd9, 0x2a, 0x0c, 0xcc, 0x94, 0x89, 0x85, 0x21, 0xdd, 0xd8, 0x9c, 0xd8, 0xa4, 0x16, 0xb4, - 0x5f, 0x14, 0xbb, 0xfc, 0x7b, 0x0a, 0x1e, 0xab, 0x03, 0x43, 0x47, 0x26, 0x84, 0xda, 0x17, 0x41, - 0x76, 0xc2, 0xf6, 0xfb, 0x8e, 0xce, 0x77, 0x74, 0x74, 0xf0, 0xa1, 0x95, 0x20, 0xa0, 0x55, 0xba, - 0x15, 0x76, 0x21, 0x5b, 0xc5, 0x9b, 0x16, 0x1c, 0x90, 0xb1, 0x95, 0xb0, 0xd2, 0xee, 0x19, 0xda, - 0x07, 0x6e, 0x25, 0xf0, 0xe0, 0x98, 0xb0, 0x0a, 0xec, 0x12, 0xac, 0x28, 0xa5, 0xd5, 0xe2, 0x69, - 0x5a, 0x6a, 0x27, 0xa7, 0xa2, 0x02, 0xb3, 0xea, 0xbe, 0x26, 0xe3, 0x1a, 0x6a, 0x08, 0x28, 0x3c, - 0x75, 0xea, 0xe9, 0x07, 0xc2, 0xc3, 0xb9, 0xcf, 0x26, 0xff, 0x71, 0x6c, 0x14, 0x45, 0x19, 0xca, - 0x93, 0x22, 0x36, 0x8a, 0x50, 0x3c, 0x0a, 0xc1, 0x37, 0x8a, 0xc6, 0x41, 0xfc, 0x3d, 0xc9, 0x11, - 0x4e, 0xad, 0x93, 0x6e, 0x6d, 0xe9, 0x20, 0x43, 0xf9, 0xb0, 0xe8, 0x2f, 0x42, 0x70, 0x62, 0xcd, - 0x9b, 0xa6, 0x49, 0xb0, 0x07, 0x26, 0x07, 0x78, 0x50, 0x19, 0x45, 0x87, 0x19, 0xca, 0xff, 0x16, - 0x1e, 0xc9, 0x25, 0x4e, 0x9b, 0x47, 0xad, 0x6a, 0x4d, 0xd3, 0x0c, 0xe5, 0xff, 0xce, 0x8f, 0x79, - 0x57, 0x9c, 0xfb, 0xe2, 0xbc, 0x2f, 0xce, 0xaf, 0xc1, 0xac, 0x66, 0xc9, 0xe6, 0xeb, 0x24, 0x2a, - 0x7a, 0xbb, 0x8f, 0xbf, 0x6f, 0x61, 0x49, 0x47, 0x21, 0x2b, 0xb0, 0x2f, 0x6d, 0x1b, 0xfa, 0x27, - 0x28, 0xb1, 0x6d, 0x66, 0x57, 0x9b, 0x1d, 0x43, 0xdb, 0x1d, 0x43, 0xdf, 0x3b, 0x86, 0xde, 0xf7, - 0x2c, 0xda, 0xee, 0x59, 0xf4, 0xb9, 0x67, 0xd1, 0xdd, 0x59, 0x6d, 0xdc, 0x62, 0x5d, 0xf2, 0x0a, - 0x96, 0x62, 0x2e, 0xe1, 0xb6, 0xdb, 0x4f, 0xf8, 0x85, 0x5f, 0xfa, 0x8d, 0xdd, 0x6b, 0xa3, 0x6d, - 0x99, 0x86, 0x61, 0x2e, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xc7, 0x4a, 0xbc, 0x7d, 0x01, + // 338 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0xbd, 0x6e, 0xdb, 0x30, + 0x14, 0x85, 0x45, 0x59, 0x96, 0x6d, 0x16, 0x28, 0x0a, 0xc2, 0x2d, 0x58, 0xa3, 0x50, 0x85, 0x2e, + 0xd5, 0x44, 0xc2, 0xed, 0x90, 0xd9, 0xce, 0x94, 0x25, 0x83, 0xbc, 0x65, 0xa3, 0x44, 0x46, 0x26, + 0x12, 0xeb, 0x0a, 0x24, 0x9d, 0xbf, 0x07, 0xc8, 0x9c, 0xc7, 0xf2, 0xe8, 0x31, 0x53, 0x10, 0xd8, + 0x2f, 0x12, 0x88, 0x52, 0x92, 0xed, 0xdc, 0xc3, 0xc3, 0x83, 0x0f, 0xf7, 0xe2, 0xef, 0x56, 0x00, + 0x07, 0x23, 0x95, 0xe1, 0x76, 0x2d, 0x8c, 0x64, 0x8d, 0x01, 0x07, 0x64, 0x6a, 0x05, 0xd4, 0xca, + 0xdd, 0x82, 0xb9, 0x62, 0x56, 0x00, 0xf3, 0x89, 0x59, 0x52, 0x82, 0xdd, 0x80, 0xe5, 0x85, 0xb0, + 0x8a, 0xdf, 0xcc, 0x0b, 0xe5, 0xc4, 0x9c, 0x97, 0xa0, 0xeb, 0xee, 0xd7, 0x6c, 0x5a, 0x41, 0x05, + 0x5e, 0xf2, 0x56, 0x75, 0xee, 0x9f, 0xc7, 0x10, 0x0f, 0x57, 0x6d, 0x37, 0xf9, 0x8a, 0x43, 0x2d, + 0x29, 0x4a, 0x51, 0x16, 0xe5, 0xa1, 0x96, 0x84, 0xe2, 0x91, 0x2f, 0x3e, 0x93, 0x34, 0xf4, 0xe6, + 0xfb, 0x48, 0x7e, 0xe0, 0xd8, 0x3a, 0xe1, 0xb6, 0x96, 0x0e, 0x52, 0x94, 0x0d, 0xf3, 0x7e, 0x22, + 0x04, 0x47, 0x56, 0x3f, 0x28, 0x1a, 0xf9, 0xb8, 0xd7, 0xe4, 0x1b, 0x1e, 0x94, 0x5a, 0xd2, 0x61, + 0x8a, 0xb2, 0x49, 0xde, 0x4a, 0x72, 0x82, 0xe3, 0xe6, 0x5a, 0xc9, 0x4a, 0xd1, 0x38, 0x45, 0xd9, + 0x97, 0x7f, 0x3f, 0x59, 0x07, 0xce, 0x5a, 0x70, 0xd6, 0x83, 0xb3, 0x53, 0xd0, 0xf5, 0x32, 0xda, + 0xbd, 0xfc, 0x0e, 0xf2, 0x3e, 0xde, 0xd6, 0x5f, 0x1a, 0xd8, 0xd0, 0x91, 0xef, 0xf2, 0xba, 0x85, + 0xb6, 0x0d, 0x1d, 0x7b, 0x27, 0xb4, 0x0d, 0x99, 0xe1, 0xb1, 0xdc, 0x1a, 0xe1, 0x34, 0xd4, 0x74, + 0xe2, 0x31, 0x3e, 0x66, 0xf2, 0x0b, 0x4f, 0x4a, 0xa3, 0x84, 0x53, 0x72, 0xe1, 0x28, 0xf6, 0x8f, + 0x9f, 0xc6, 0x72, 0xb1, 0x3b, 0x24, 0x68, 0x7f, 0x48, 0xd0, 0xeb, 0x21, 0x41, 0x4f, 0xc7, 0x24, + 0xd8, 0x1f, 0x93, 0xe0, 0xf9, 0x98, 0x04, 0x17, 0x7f, 0x2b, 0xed, 0xd6, 0xdb, 0x82, 0x95, 0xb0, + 0xe1, 0x2b, 0x01, 0xe7, 0xdd, 0xe6, 0x79, 0x7b, 0x9b, 0xbb, 0xfe, 0x3a, 0xee, 0xbe, 0x51, 0xb6, + 0x88, 0xfd, 0x4a, 0xff, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff, 0x85, 0x30, 0xb7, 0xef, 0xb7, 0x01, 0x00, 0x00, } @@ -174,6 +192,16 @@ func (m *Shard) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CreatedAt != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x50 + } + if m.Duration != 0 { + i = encodeVarintShard(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x48 + } if len(m.Sp) > 0 { i -= len(m.Sp) copy(dAtA[i:], m.Sp) @@ -271,6 +299,12 @@ func (m *Shard) Size() (n int) { if l > 0 { n += 1 + l + sovShard(uint64(l)) } + if m.Duration != 0 { + n += 1 + sovShard(uint64(m.Duration)) + } + if m.CreatedAt != 0 { + n += 1 + sovShard(uint64(m.CreatedAt)) + } return n } @@ -514,6 +548,44 @@ func (m *Shard) Unmarshal(dAtA []byte) error { } m.Sp = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipShard(dAtA[iNdEx:]) diff --git a/x/sao/client/cli/tx_cancel.go b/x/sao/client/cli/tx_cancel.go index 1464c0a7..60e3fcf0 100644 --- a/x/sao/client/cli/tx_cancel.go +++ b/x/sao/client/cli/tx_cancel.go @@ -15,14 +15,15 @@ var _ = strconv.Itoa(0) func CmdCancel() *cobra.Command { cmd := &cobra.Command{ - Use: "cancel [order-id]", + Use: "cancel [order-id] [provider]", Short: "Broadcast message cancel", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argOrderId, err := cast.ToUint64E(args[0]) if err != nil { return err } + argProvider := args[1] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -32,6 +33,7 @@ func CmdCancel() *cobra.Command { msg := types.NewMsgCancel( clientCtx.GetFromAddress().String(), argOrderId, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_complete.go b/x/sao/client/cli/tx_complete.go index ccae263a..31ac688a 100644 --- a/x/sao/client/cli/tx_complete.go +++ b/x/sao/client/cli/tx_complete.go @@ -15,9 +15,9 @@ var _ = strconv.Itoa(0) func CmdComplete() *cobra.Command { cmd := &cobra.Command{ - Use: "complete [order-id] [cid] [size]", - Short: "Broadcast message complete1", - Args: cobra.ExactArgs(3), + Use: "complete [order-id] [cid] [size] [provider]", + Short: "Broadcast message complete", + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argOrderId, err := cast.ToUint64E(args[0]) if err != nil { @@ -28,6 +28,7 @@ func CmdComplete() *cobra.Command { if err != nil { return err } + argProvider := args[3] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -39,6 +40,7 @@ func CmdComplete() *cobra.Command { argOrderId, argCid, argSize, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_migrate.go b/x/sao/client/cli/tx_migrate.go index 26746768..47843ffa 100644 --- a/x/sao/client/cli/tx_migrate.go +++ b/x/sao/client/cli/tx_migrate.go @@ -17,11 +17,12 @@ var listSeparator = "," func CmdMigrate() *cobra.Command { cmd := &cobra.Command{ - Use: "migrate [data]", + Use: "migrate [data] [provider]", Short: "Broadcast message migrate", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argData := strings.Split(args[0], listSeparator) + argProvider := args[1] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -31,6 +32,7 @@ func CmdMigrate() *cobra.Command { msg := types.NewMsgMigrate( clientCtx.GetFromAddress().String(), argData, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_ready.go b/x/sao/client/cli/tx_ready.go index 8268306c..dd350a6d 100644 --- a/x/sao/client/cli/tx_ready.go +++ b/x/sao/client/cli/tx_ready.go @@ -15,11 +15,12 @@ var _ = strconv.Itoa(0) func CmdReady() *cobra.Command { cmd := &cobra.Command{ - Use: "ready [order-id]", + Use: "ready [order-id] [provider]", Short: "Broadcast message ready", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argOrderId, err := cast.ToUint64E(args[0]) + argProvider := args[1] if err != nil { return err @@ -33,6 +34,7 @@ func CmdReady() *cobra.Command { msg := types.NewMsgReady( clientCtx.GetFromAddress().String(), argOrderId, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_renew.go b/x/sao/client/cli/tx_renew.go index 64a0eb3b..d558422f 100644 --- a/x/sao/client/cli/tx_renew.go +++ b/x/sao/client/cli/tx_renew.go @@ -15,9 +15,9 @@ var _ = strconv.Itoa(0) func CmdRenew() *cobra.Command { cmd := &cobra.Command{ - Use: "renew [proposal] [signature]", + Use: "renew [proposal] [signature] [provider]", Short: "Broadcast message renew", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argProposal := new(types.RenewProposal) err = json.Unmarshal([]byte(args[0]), argProposal) @@ -29,6 +29,7 @@ func CmdRenew() *cobra.Command { if err != nil { return err } + argProvider := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -39,6 +40,7 @@ func CmdRenew() *cobra.Command { clientCtx.GetFromAddress().String(), argProposal, argSignature, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_store.go b/x/sao/client/cli/tx_store.go index 92b3927e..fe30e72f 100644 --- a/x/sao/client/cli/tx_store.go +++ b/x/sao/client/cli/tx_store.go @@ -16,9 +16,9 @@ var _ = strconv.Itoa(0) func CmdStore() *cobra.Command { cmd := &cobra.Command{ - Use: "store [proposal] [signature]", + Use: "store [proposal] [signature] [provider]", Short: "Broadcast message store", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argProposal := new(types.Proposal) err = json.Unmarshal([]byte(args[0]), argProposal) @@ -30,6 +30,7 @@ func CmdStore() *cobra.Command { if err != nil { return err } + argProvider := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -40,6 +41,7 @@ func CmdStore() *cobra.Command { clientCtx.GetFromAddress().String(), argProposal, argSignature, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_terminate.go b/x/sao/client/cli/tx_terminate.go index e8000019..e186a420 100644 --- a/x/sao/client/cli/tx_terminate.go +++ b/x/sao/client/cli/tx_terminate.go @@ -15,9 +15,9 @@ var _ = strconv.Itoa(0) func CmdTerminate() *cobra.Command { cmd := &cobra.Command{ - Use: "terminate [proposal] [signature]", + Use: "terminate [proposal] [signature] [provider]", Short: "Broadcast message terminate", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { var proposal types.TerminateProposal err = json.Unmarshal([]byte(args[0]), &proposal) @@ -29,6 +29,7 @@ func CmdTerminate() *cobra.Command { if err != nil { return err } + argProvider := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -39,6 +40,7 @@ func CmdTerminate() *cobra.Command { clientCtx.GetFromAddress().String(), proposal, signature, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/client/cli/tx_updata_permission.go b/x/sao/client/cli/tx_updata_permission.go index e518736e..b02031db 100644 --- a/x/sao/client/cli/tx_updata_permission.go +++ b/x/sao/client/cli/tx_updata_permission.go @@ -15,9 +15,9 @@ var _ = strconv.Itoa(0) func CmdUpdataPermission() *cobra.Command { cmd := &cobra.Command{ - Use: "updata-permission [proposal] [signature]", + Use: "updata-permission [proposal] [signature] [provider]", Short: "Broadcast message UpdataPermission", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { var proposal types.PermissionProposal err = json.Unmarshal([]byte(args[0]), &proposal) @@ -29,6 +29,7 @@ func CmdUpdataPermission() *cobra.Command { if err != nil { return err } + argProvider := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -39,6 +40,7 @@ func CmdUpdataPermission() *cobra.Command { clientCtx.GetFromAddress().String(), proposal, signature, + argProvider, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/sao/keeper/msg_server_cancel.go b/x/sao/keeper/msg_server_cancel.go index be5929d2..2c091e89 100644 --- a/x/sao/keeper/msg_server_cancel.go +++ b/x/sao/keeper/msg_server_cancel.go @@ -20,7 +20,21 @@ func (k msgServer) Cancel(goCtx context.Context, msg *types.MsgCancel) (*types.M return nil, sdkerrors.Wrapf(types.ErrOrderNotFound, "order %d not found", msg.OrderId) } - if order.Creator != msg.Creator { + isCreator := false + if order.Creator == msg.Creator { + isCreator = true + } else { + node, found := k.node.GetNode(ctx, msg.Provider) + if found { + for _, address := range node.TxAddresses { + if order.Creator == address { + isCreator = true + } + } + } + } + + if !isCreator { return nil, sdkerrors.Wrapf(types.ErrNotCreator, "only order creator allowed") } diff --git a/x/sao/keeper/msg_server_complete.go b/x/sao/keeper/msg_server_complete.go index 06047f5c..bde2c003 100644 --- a/x/sao/keeper/msg_server_complete.go +++ b/x/sao/keeper/msg_server_complete.go @@ -3,8 +3,6 @@ package keeper import ( "context" "fmt" - "strings" - nodetypes "github.com/SaoNetwork/sao/x/node/types" ordertypes "github.com/SaoNetwork/sao/x/order/types" "github.com/SaoNetwork/sao/x/sao/types" @@ -13,6 +11,7 @@ import ( "github.com/ipfs/go-cid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "strings" ) func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*types.MsgCompleteResponse, error) { @@ -79,32 +78,9 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ return &types.MsgCompleteResponse{}, err } - logger := k.Logger(ctx) - - // check cid - _, err = cid.Decode(msg.Cid) - if err != nil { - err = sdkerrors.Wrapf(types.ErrInvalidCid, "invali cid: %s", msg.Cid) - return &types.MsgCompleteResponse{}, err - } - - // active shard - k.order.FulfillShard(ctx, &order, msg.Provider, msg.Cid, msg.Size_) - - // shard = order.Shards[msg.Provider] - - err = k.node.OrderPledge(ctx, sdk.MustAccAddressFromBech32(msg.Provider), &order) - if err != nil { - err = sdkerrors.Wrap(types.ErrorOrderPledgeFailed, err.Error()) - return &types.MsgCompleteResponse{}, err - } - - amount := sdk.NewCoin(order.Amount.Denom, order.Amount.Amount.QuoRaw(int64(order.Replica))) - k.node.IncreaseReputation(ctx, msg.Provider, float32(amount.Amount.Int64())) - // avoid version conflicts - meta, isFound := k.model.GetMetadata(ctx, order.DataId) - if isFound && order.Status == ordertypes.OrderCompleted { + meta, isFoundMeta := k.model.GetMetadata(ctx, order.DataId) + if isFoundMeta && order.Status == ordertypes.OrderCompleted { if meta.OrderId > orderId { // report error if order id is less than the latest version return nil, sdkerrors.Wrapf(nodetypes.ErrInvalidCommitId, "invalid commitId: %s, detected version conficts with order: %d", order.Commit, meta.OrderId) @@ -131,17 +107,13 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ } } - order.Status = ordertypes.OrderCompleted + logger := k.Logger(ctx) - // set order status - for _, id := range order.Shards { - _shard, found := k.order.GetShard(ctx, id) - if !found { - return nil, status.Errorf(codes.NotFound, "shard %d not found", id) - } - if _shard.Status != ordertypes.ShardCompleted { - order.Status = ordertypes.OrderInProgress - } + // check cid + _, err = cid.Decode(msg.Cid) + if err != nil { + err = sdkerrors.Wrapf(types.ErrInvalidCid, "invalid cid: %s", msg.Cid) + return &types.MsgCompleteResponse{}, err } if shard.From != "" { @@ -156,6 +128,8 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ return nil, err } oldShard := k.order.GetOrderShardBySP(ctx, &order, shard.From) + shard.CreatedAt = uint64(ctx.BlockHeight()) + shard.Duration = oldShard.CreatedAt + oldShard.Duration - shard.CreatedAt if oldShard != nil { k.order.RemoveShard(ctx, oldShard.Id) newShards := make([]uint64, 0) @@ -166,28 +140,75 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ } order.Shards = newShards } - } else if order.Status == ordertypes.OrderCompleted { - // order complete + } else { + shard.CreatedAt = uint64(ctx.BlockHeight()) + shard.Duration = order.Duration + } + + // active shard + k.order.FulfillShard(ctx, shard, msg.Provider, msg.Cid) + k.order.SetShard(ctx, *shard) + + // shard = order.Shards[msg.Provider] + + err = k.node.OrderPledge(ctx, sdk.MustAccAddressFromBech32(msg.Provider), &order) + if err != nil { + err = sdkerrors.Wrap(types.ErrorOrderPledgeFailed, err.Error()) + return &types.MsgCompleteResponse{}, err + } + + amount := sdk.NewCoin(order.Amount.Denom, order.Amount.Amount.QuoRaw(int64(order.Replica))) + k.node.IncreaseReputation(ctx, msg.Provider, float32(amount.Amount.Int64())) + + if order.Status != ordertypes.OrderMigrating { + order.Status = ordertypes.OrderCompleted + + // set order status + for _, id := range order.Shards { + _shard, found := k.order.GetShard(ctx, id) + if !found { + return nil, status.Errorf(codes.NotFound, "shard %d not found", id) + } + if _shard.Status != ordertypes.ShardCompleted { + order.Status = ordertypes.OrderInProgress + } + } - _, foundMeta := k.model.GetMetadata(ctx, order.DataId) + if order.Status == ordertypes.OrderCompleted { + // order complete + if isFoundMeta { + err = k.Keeper.model.UpdateMeta(ctx, order) - if foundMeta { - err = k.Keeper.model.UpdateMeta(ctx, order) + if err != nil { + logger.Error("failed to update metadata", "err", err.Error()) + return nil, err + } + } else { + return nil, status.Errorf(codes.NotFound, "metadata %d not found", order.DataId) + } + err = k.market.Deposit(ctx, order) if err != nil { - logger.Error("failed to update metadata", "err", err.Error()) return nil, err } - } else { - return nil, status.Errorf(codes.NotFound, "metadata %d not found", order.DataId) } + } else { - err = k.market.Deposit(ctx, order) - if err != nil { - return nil, err + order.Status = ordertypes.OrderCompleted + + // set order status + for _, id := range order.Shards { + _shard, found := k.order.GetShard(ctx, id) + if !found { + continue + } + if _shard.Status != ordertypes.ShardCompleted { + order.Status = ordertypes.OrderMigrating + } } } + k.model.ExtendMetaDuration(ctx, meta, shard.CreatedAt+shard.Duration) k.order.SetOrder(ctx, order) return &types.MsgCompleteResponse{}, err diff --git a/x/sao/keeper/msg_server_migrate.go b/x/sao/keeper/msg_server_migrate.go index 73125209..a6ce8033 100644 --- a/x/sao/keeper/msg_server_migrate.go +++ b/x/sao/keeper/msg_server_migrate.go @@ -73,7 +73,7 @@ func (k msgServer) Migrate(goCtx context.Context, msg *types.MsgMigrate) (*types for _, id := range oldOrder.Shards { shard, found := k.order.GetShard(ctx, id) if !found { - return nil, status.Errorf(codes.NotFound, "shard %d not found", id) + continue } ignoreList = append(ignoreList, shard.Sp) } diff --git a/x/sao/keeper/msg_server_store.go b/x/sao/keeper/msg_server_store.go index dea98f40..424582ea 100644 --- a/x/sao/keeper/msg_server_store.go +++ b/x/sao/keeper/msg_server_store.go @@ -95,7 +95,7 @@ func (k msgServer) Store(goCtx context.Context, msg *types.MsgStore) (*types.Msg } var order = ordertypes.Order{ - Creator: msg.Creator, + Creator: msg.Provider, Owner: proposal.Owner, Cid: proposal.Cid, Timeout: uint64(proposal.Timeout), diff --git a/x/sao/keeper/timeout_management.go b/x/sao/keeper/timeout_management.go index 90be659b..8c771619 100644 --- a/x/sao/keeper/timeout_management.go +++ b/x/sao/keeper/timeout_management.go @@ -2,7 +2,6 @@ package keeper import ( ordertypes "github.com/SaoNetwork/sao/x/order/types" - "github.com/SaoNetwork/sao/x/sao/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -37,7 +36,8 @@ func (k Keeper) HandleTimeoutOrder(ctx sdk.Context, orderId uint64) { continue } if shard.Status == ordertypes.ShardWaiting { - k.node.DecreaseReputation(ctx, shard.Sp, types.TimeoutReputationPunishment) + // TODO: sp punishment + //k.node.DecreaseReputation(ctx, shard.Sp, types.TimeoutReputationPunishment) } randSp := k.node.RandomSP(ctx, 1, sps) diff --git a/x/sao/types/expected_keepers.go b/x/sao/types/expected_keepers.go index c1f85828..4caa48dd 100644 --- a/x/sao/types/expected_keepers.go +++ b/x/sao/types/expected_keepers.go @@ -57,9 +57,7 @@ type OrderKeeper interface { MigrateShard(ctx sdk.Context, order *ordertypes.Order, from string, to string) *ordertypes.Shard GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) SetOrder(ctx sdk.Context, order ordertypes.Order) - TerminateOrder(ctx sdk.Context, orderId uint64, refundCoin sdk.Coin) error - FulfillShard(ctx sdk.Context, order *ordertypes.Order, sp string, cid string, size uint64) error - TerminateShard(ctx sdk.Context, shard *ordertypes.Shard, sp string, owner string, orderId uint64) error + FulfillShard(ctx sdk.Context, shard *ordertypes.Shard, sp string, cid string) GetOrderShardBySP(ctx sdk.Context, order *ordertypes.Order, sp string) *ordertypes.Shard GetShard(ctx sdk.Context, id uint64) (val ordertypes.Shard, found bool) RemoveShard(ctx sdk.Context, id uint64) @@ -86,6 +84,8 @@ type ModelKeeper interface { TerminateOrder(ctx sdk.Context, order ordertypes.Order) error CancelOrder(ctx sdk.Context, orderId uint64) error + + ExtendMetaDuration(ctx sdk.Context, meta modeltypes.Metadata, expiredAt uint64) } // DidKeeper diff --git a/x/sao/types/message_cancel.go b/x/sao/types/message_cancel.go index 6e1a5b20..6476780b 100644 --- a/x/sao/types/message_cancel.go +++ b/x/sao/types/message_cancel.go @@ -9,10 +9,11 @@ const TypeMsgCancel = "cancel" var _ sdk.Msg = &MsgCancel{} -func NewMsgCancel(creator string, orderId uint64) *MsgCancel { +func NewMsgCancel(creator string, orderId uint64, provider string) *MsgCancel { return &MsgCancel{ - Creator: creator, - OrderId: orderId, + Creator: creator, + OrderId: orderId, + Provider: provider, } } diff --git a/x/sao/types/message_complete.go b/x/sao/types/message_complete.go index 4ad89d31..d8789e8f 100644 --- a/x/sao/types/message_complete.go +++ b/x/sao/types/message_complete.go @@ -9,12 +9,13 @@ const TypeMsgComplete = "complete" var _ sdk.Msg = &MsgComplete{} -func NewMsgComplete(creator string, orderId uint64, cid string, size uint64) *MsgComplete { +func NewMsgComplete(creator string, orderId uint64, cid string, size uint64, provider string) *MsgComplete { return &MsgComplete{ - Creator: creator, - OrderId: orderId, - Cid: cid, - Size_: size, + Creator: creator, + OrderId: orderId, + Cid: cid, + Size_: size, + Provider: provider, } } diff --git a/x/sao/types/message_migrate.go b/x/sao/types/message_migrate.go index 843bc7b9..428061a0 100644 --- a/x/sao/types/message_migrate.go +++ b/x/sao/types/message_migrate.go @@ -9,10 +9,11 @@ const TypeMsgMigrate = "migrate" var _ sdk.Msg = &MsgMigrate{} -func NewMsgMigrate(creator string, data []string) *MsgMigrate { +func NewMsgMigrate(creator string, data []string, provider string) *MsgMigrate { return &MsgMigrate{ - Creator: creator, - Data: data, + Creator: creator, + Data: data, + Provider: provider, } } diff --git a/x/sao/types/message_ready.go b/x/sao/types/message_ready.go index fe732c62..51125fe5 100644 --- a/x/sao/types/message_ready.go +++ b/x/sao/types/message_ready.go @@ -9,10 +9,11 @@ const TypeMsgReady = "ready" var _ sdk.Msg = &MsgReady{} -func NewMsgReady(creator string, orderId uint64) *MsgReady { +func NewMsgReady(creator string, orderId uint64, provider string) *MsgReady { return &MsgReady{ - Creator: creator, - OrderId: orderId, + Creator: creator, + OrderId: orderId, + Provider: provider, } } diff --git a/x/sao/types/message_renew.go b/x/sao/types/message_renew.go index de520f47..5472a392 100644 --- a/x/sao/types/message_renew.go +++ b/x/sao/types/message_renew.go @@ -9,11 +9,12 @@ const TypeMsgRenew = "renew" var _ sdk.Msg = &MsgRenew{} -func NewMsgRenew(creator string, proposal *RenewProposal, signature *JwsSignature) *MsgRenew { +func NewMsgRenew(creator string, proposal *RenewProposal, signature *JwsSignature, provider string) *MsgRenew { return &MsgRenew{ Creator: creator, Proposal: *proposal, JwsSignature: *signature, + Provider: provider, } } diff --git a/x/sao/types/message_store.go b/x/sao/types/message_store.go index bf3ef41a..cb691f7d 100644 --- a/x/sao/types/message_store.go +++ b/x/sao/types/message_store.go @@ -9,11 +9,12 @@ const TypeMsgStore = "store" var _ sdk.Msg = &MsgStore{} -func NewMsgStore(creator string, proposal *Proposal, signature *JwsSignature) *MsgStore { +func NewMsgStore(creator string, proposal *Proposal, signature *JwsSignature, provider string) *MsgStore { return &MsgStore{ Creator: creator, Proposal: *proposal, JwsSignature: *signature, + Provider: provider, } } diff --git a/x/sao/types/message_terminate.go b/x/sao/types/message_terminate.go index ba44457d..7b07faca 100644 --- a/x/sao/types/message_terminate.go +++ b/x/sao/types/message_terminate.go @@ -9,11 +9,12 @@ const TypeMsgTerminate = "terminate" var _ sdk.Msg = &MsgTerminate{} -func NewMsgTerminate(creator string, proposal TerminateProposal, signature JwsSignature) *MsgTerminate { +func NewMsgTerminate(creator string, proposal TerminateProposal, signature JwsSignature, provider string) *MsgTerminate { return &MsgTerminate{ Creator: creator, Proposal: proposal, JwsSignature: signature, + Provider: provider, } } diff --git a/x/sao/types/message_updata_permission.go b/x/sao/types/message_updata_permission.go index 84dd11ca..613e736a 100644 --- a/x/sao/types/message_updata_permission.go +++ b/x/sao/types/message_updata_permission.go @@ -9,11 +9,12 @@ const TypeMsgUpdataPermission = "updata_permission" var _ sdk.Msg = &MsgUpdataPermission{} -func NewMsgUpdataPermission(creator string, proposal PermissionProposal, signature JwsSignature) *MsgUpdataPermission { +func NewMsgUpdataPermission(creator string, proposal PermissionProposal, signature JwsSignature, provider string) *MsgUpdataPermission { return &MsgUpdataPermission{ Creator: creator, Proposal: proposal, JwsSignature: signature, + Provider: provider, } } From ee59e7f08f38d0ad23774d3441742230395afac6 Mon Sep 17 00:00:00 2001 From: MattL <89444556+mattkb@users.noreply.github.com> Date: Mon, 15 May 2023 18:20:36 +0800 Subject: [PATCH 3/8] feat: storage pledge baseline (#48) * add baseline * node v2 type * upgrade node param --------- Co-authored-by: Matt --- config.yml | 5 +- docs/static/openapi.yml | 4934 ++++++++++++++++++---- go.mod | 1 + go.sum | 2 + proto/sao/node/params.proto | 4 + proto/sao/node/pool.proto | 5 +- x/node/abci.go | 56 +- x/node/keeper/migrations.go | 9 + x/node/keeper/params.go | 13 +- x/node/keeper/shard_pledge_management.go | 6 +- x/node/migrations/v1/types/pool.pb.go | 613 +++ x/node/migrations/v2/types/params.pb.go | 323 ++ x/node/migrations/v3/migrations.go | 72 + x/node/module.go | 8 +- x/node/types/params.go | 40 +- x/node/types/params.pb.go | 142 +- x/node/types/pool.pb.go | 112 +- 17 files changed, 5463 insertions(+), 882 deletions(-) create mode 100644 x/node/migrations/v1/types/pool.pb.go create mode 100644 x/node/migrations/v2/types/params.pb.go create mode 100644 x/node/migrations/v3/migrations.go diff --git a/config.yml b/config.yml index e2d3f19a..f0f59394 100644 --- a/config.yml +++ b/config.yml @@ -29,8 +29,10 @@ genesis: node: params: block_reward: - amount: "10000000" + amount: "6250000" denom: "sao" + baseline: "100000000000" + annual_percentage_yield : "1" staking: params: bond_denom: "sao" @@ -52,6 +54,7 @@ genesis: inflation_min: "0" inflation_rate_change: "0" mint_denom: "sao" + blocks_per_year: "16000000" validators: - name: alice bonded: 100000000sao diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index e43a62cf..ce031642 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -471,7 +471,6 @@ paths: type: object properties: account: - description: account defines the account of the corresponding address. type: object properties: '@type': @@ -532,217 +531,117 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - QueryAccountResponse is the response type for the Query/Account - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a - URL that describes the type of the serialized message. + URL that describes the type of the serialized message. - Protobuf library provides support to pack/unpack Any values - in the form + Protobuf library provides support to pack/unpack Any values in + the form - of utility functions or additional generated methods of the - Any type. + of utility functions or additional generated methods of the + Any type. - Example 1: Pack and unpack a message in C++. + Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { ... - if (any.UnpackTo(&foo)) { - ... - } + } - Example 2: Pack and unpack a message in Java. + Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - The pack methods provided by protobuf library will by - default use + The pack methods provided by protobuf library will by default + use - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - methods only use the fully qualified type name after the - last '/' + methods only use the fully qualified type name after the last + '/' - in the type URL, for example "foo.bar.com/x/y.z" will yield - type + in the type URL, for example "foo.bar.com/x/y.z" will yield + type - name "y.z". + name "y.z". - JSON + JSON - ==== + ==== - The JSON representation of an `Any` value uses the regular + The JSON representation of an `Any` value uses the regular - representation of the deserialized, embedded message, with - an + representation of the deserialized, embedded message, with an - additional field `@type` which contains the type URL. - Example: + additional field `@type` which contains the type URL. Example: - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - If the embedded message type is well-known and has a custom - JSON + If the embedded message type is well-known and has a custom + JSON - representation, that representation will be embedded adding - a field + representation, that representation will be embedded adding a + field - `value` which holds the custom JSON in addition to the - `@type` + `value` which holds the custom JSON in addition to the `@type` - field. Example (for message [google.protobuf.Duration][]): + field. Example (for message [google.protobuf.Duration][]): - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address defines the address to query for. - in: path - required: true - type: string - tags: - - Query - /cosmos/auth/v1beta1/address_by_id/{id}: - get: - summary: AccountAddressByID returns account address based on account id - operationId: CosmosAuthV1Beta1AccountAddressByID - responses: - '200': - description: A successful response. - schema: - type: object - properties: - account_address: - type: string - title: >- - QueryAccountAddressByIDResponse is the response type for - AccountAddressByID rpc method + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + description: >- + QueryAccountResponse is the response type for the Query/Account + RPC method. default: description: An unexpected error response. schema: @@ -929,32 +828,28 @@ paths: "value": "1.212s" } parameters: - - name: id + - name: address + description: address defines the address to query for. in: path required: true type: string - format: int64 tags: - Query - /cosmos/auth/v1beta1/bech32: + /cosmos/auth/v1beta1/address_by_id/{id}: get: - summary: Bech32Prefix queries bech32Prefix - description: 'Since: cosmos-sdk 0.46' - operationId: CosmosAuthV1Beta1Bech32Prefix + summary: AccountAddressByID returns account address based on account id + operationId: CosmosAuthV1Beta1AccountAddressByID responses: '200': description: A successful response. schema: type: object properties: - bech32_prefix: + account_address: type: string - description: >- - Bech32PrefixResponse is the response type for Bech32Prefix rpc - method. - - - Since: cosmos-sdk 0.46 + title: >- + QueryAccountAddressByIDResponse is the response type for + AccountAddressByID rpc method default: description: An unexpected error response. schema: @@ -1140,24 +1035,236 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + parameters: + - name: id + in: path + required: true + type: string + format: int64 tags: - Query - /cosmos/auth/v1beta1/bech32/{address_bytes}: + /cosmos/auth/v1beta1/bech32: get: - summary: AddressBytesToString converts Account Address bytes to string + summary: Bech32Prefix queries bech32Prefix description: 'Since: cosmos-sdk 0.46' - operationId: CosmosAuthV1Beta1AddressBytesToString + operationId: CosmosAuthV1Beta1Bech32Prefix responses: '200': description: A successful response. schema: type: object properties: - address_string: + bech32_prefix: type: string description: >- - AddressBytesToStringResponse is the response type for - AddressString rpc method. + Bech32PrefixResponse is the response type for Bech32Prefix rpc + method. + + + Since: cosmos-sdk 0.46 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + tags: + - Query + /cosmos/auth/v1beta1/bech32/{address_bytes}: + get: + summary: AddressBytesToString converts Account Address bytes to string + description: 'Since: cosmos-sdk 0.46' + operationId: CosmosAuthV1Beta1AddressBytesToString + responses: + '200': + description: A successful response. + schema: + type: object + properties: + address_string: + type: string + description: >- + AddressBytesToStringResponse is the response type for + AddressString rpc method. Since: cosmos-sdk 0.46 @@ -3745,13 +3852,20 @@ paths: type: object properties: balance: - description: balance is the balance of the coin. type: object properties: denom: type: string amount: type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. description: >- QueryBalanceResponse is the response type for the Query/Balance RPC method. @@ -3812,15 +3926,20 @@ paths: address defines the address that owns a particular denomination. balance: - description: >- - balance is the balance of the denominated coin for an - account. type: object properties: denom: type: string amount: type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. description: >- DenomOwner defines structure representing an account that owns or holds a @@ -4159,9 +4278,6 @@ paths: type: object properties: metadata: - description: >- - metadata describes and provides all the client information for - the requested token. type: object properties: description: @@ -4247,6 +4363,9 @@ paths: Since: cosmos-sdk 0.46 + description: |- + Metadata represents a struct that describes + a basic token. description: >- QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC @@ -4614,13 +4733,20 @@ paths: type: object properties: amount: - description: amount is the supply of the coin. type: object properties: denom: type: string amount: type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. description: >- QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. @@ -10171,7 +10297,6 @@ paths: type: object properties: evidence: - description: evidence returns the requested evidence. type: object properties: '@type': @@ -10232,6 +10357,114 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- QueryEvidenceResponse is the response type for the Query/Evidence RPC method. @@ -13104,7 +13337,6 @@ paths: type: object properties: deposit: - description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -13129,6 +13361,11 @@ paths: custom method signatures required by gogoproto. + description: >- + Deposit defines an amount deposited by an account address to + an active + + proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -13892,7 +14129,6 @@ paths: type: object properties: vote: - description: vote defined the queried vote. type: object properties: proposal_id: @@ -13933,6 +14169,11 @@ paths: description: >- metadata is any arbitrary metadata to attached to the vote. + description: >- + Vote defines a vote on a governance proposal. + + A Vote consists of a proposal ID, the voter, and the vote + option. description: >- QueryVoteResponse is the response type for the Query/Vote RPC method. @@ -15768,7 +16009,6 @@ paths: type: object properties: deposit: - description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -15793,6 +16033,11 @@ paths: custom method signatures required by gogoproto. + description: >- + Deposit defines an amount deposited by an account address to + an active + + proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -16573,7 +16818,6 @@ paths: type: object properties: vote: - description: vote defined the queried vote. type: object properties: proposal_id: @@ -16631,6 +16875,11 @@ paths: Since: cosmos-sdk 0.43 title: 'Since: cosmos-sdk 0.43' + description: >- + Vote defines a vote on a governance proposal. + + A Vote consists of a proposal ID, the voter, and the vote + option. description: >- QueryVoteResponse is the response type for the Query/Vote RPC method. @@ -17435,9 +17684,6 @@ paths: would create a different result on a running proposal. decision_policy: - description: >- - decision_policy specifies the group policy's decision - policy. type: object properties: '@type': @@ -17499,6 +17745,119 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the + regular + + representation of the deserialized, embedded message, + with an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message + [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time @@ -17821,9 +18180,6 @@ paths: would create a different result on a running proposal. decision_policy: - description: >- - decision_policy specifies the group policy's decision - policy. type: object properties: '@type': @@ -17885,6 +18241,119 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the + regular + + representation of the deserialized, embedded message, + with an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message + [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time @@ -18182,7 +18651,6 @@ paths: type: object properties: info: - description: info is the GroupPolicyInfo for the group policy. type: object properties: address: @@ -18209,9 +18677,6 @@ paths: would create a different result on a running proposal. decision_policy: - description: >- - decision_policy specifies the group policy's decision - policy. type: object properties: '@type': @@ -18273,12 +18738,126 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time description: >- created_at is a timestamp specifying when a group policy was created. + description: >- + GroupPolicyInfo represents the high-level on-chain information + for a group policy. description: >- QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. @@ -21724,9 +22303,6 @@ paths: uri_hash is a hash of the document pointed by uri. Optional data: - title: >- - data is the app specific metadata of the NFT class. - Optional type: object properties: '@type': @@ -21901,6 +22477,9 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: >- + data is the app specific metadata of the NFT class. + Optional description: Class defines the class of the nft type. pagination: type: object @@ -22221,9 +22800,6 @@ paths: uri_hash is a hash of the document pointed by uri. Optional data: - title: >- - data is the app specific metadata of the NFT class. - Optional type: object properties: '@type': @@ -22396,6 +22972,9 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: >- + data is the app specific metadata of the NFT class. + Optional description: Class defines the class of the nft type. title: >- QueryClassResponse is the response type for the Query/Class RPC @@ -22626,7 +23205,6 @@ paths: type: string title: uri_hash is a hash of the document pointed by uri data: - title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -22801,6 +23379,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. pagination: type: object @@ -23113,7 +23692,6 @@ paths: type: string title: uri_hash is a hash of the document pointed by uri data: - title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -23286,6 +23864,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. title: QueryNFTResponse is the response type for the Query/NFT RPC method default: @@ -24260,9 +24839,6 @@ paths: type: object properties: val_signing_info: - title: >- - val_signing_info is the signing info of requested val cons - address type: object properties: address: @@ -24312,6 +24888,9 @@ paths: monitoring their liveness activity. + title: >- + val_signing_info is the signing info of requested val cons + address title: >- QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC @@ -25452,9 +26031,6 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -25516,6 +26092,119 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the + regular + + representation of the deserialized, embedded message, + with an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message + [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -25929,7 +26618,6 @@ paths: type: object properties: validator: - description: validator defines the validator info. type: object properties: operator_address: @@ -25938,9 +26626,6 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -26002,6 +26687,117 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -26106,6 +26902,29 @@ paths: Since: cosmos-sdk 0.46 + description: >- + Validator defines a validator, together with the total amount + of the + + Validator's bond shares and their exchange rate to coins. + Slashing results in + + a decrease in the exchange rate, allowing correct calculation + of future + + undelegations without iterating over delegators. When coins + are delegated to + + this validator, the validator is credited with a delegation + whose number of + + bond shares is based on the amount of coins delegated divided + by the current + + exchange rate. Voting power can be calculated as total bonded + shares + + multiplied by exchange rate. description: |- QueryDelegatorValidatorResponse response type for the Query/DelegatorValidator RPC method. @@ -26420,9 +27239,6 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -26484,6 +27300,120 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol + buffer message along with a + + URL that describes the type of the serialized + message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods + of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will + by default use + + 'type.googleapis.com/full.type.name' as the type URL + and the unpack + + methods only use the fully qualified type name after + the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" + will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the + regular + + representation of the deserialized, embedded + message, with an + + additional field `@type` which contains the type + URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to + the `@type` + + field. Example (for message + [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -27270,9 +28200,6 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -27334,6 +28261,119 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the + regular + + representation of the deserialized, embedded message, + with an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message + [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -27745,7 +28785,6 @@ paths: type: object properties: validator: - description: validator defines the validator info. type: object properties: operator_address: @@ -27754,9 +28793,6 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -27818,6 +28854,117 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -27922,6 +29069,29 @@ paths: Since: cosmos-sdk 0.46 + description: >- + Validator defines a validator, together with the total amount + of the + + Validator's bond shares and their exchange rate to coins. + Slashing results in + + a decrease in the exchange rate, allowing correct calculation + of future + + undelegations without iterating over delegators. When coins + are delegated to + + this validator, the validator is credited with a delegation + whose number of + + bond shares is based on the amount of coins delegated divided + by the current + + exchange rate. Voting power can be calculated as total bonded + shares + + multiplied by exchange rate. title: >- QueryValidatorResponse is response type for the Query/Validator RPC method @@ -28460,9 +29630,6 @@ paths: type: object properties: delegation_response: - description: >- - delegation_responses defines the delegation info of a - delegation. type: object properties: delegation: @@ -28504,6 +29671,12 @@ paths: custom method signatures required by gogoproto. + description: >- + DelegationResponse is equivalent to Delegation except that it + contains a + + balance in addition to shares which is more suitable for + client responses. description: >- QueryDelegationResponse is response type for the Query/Delegation RPC method. @@ -28718,7 +29891,6 @@ paths: type: object properties: unbond: - description: unbond defines the unbonding information of a delegation. type: object properties: delegator_address: @@ -28763,6 +29935,11 @@ paths: entries are the unbonding delegation entries. unbonding delegation entries + description: >- + UnbondingDelegation stores all of a single delegator's + unbonding bonds + + for a single validator in an time-ordered list. description: >- QueryDelegationResponse is response type for the Query/UnbondingDelegation @@ -30073,7 +31250,6 @@ paths: type: object properties: tx_response: - description: tx_response is the queried TxResponses. type: object properties: height: @@ -30160,7 +31336,6 @@ paths: format: int64 description: Amount of gas consumed by transaction. tx: - description: The request transaction bytes. type: object properties: '@type': @@ -30222,6 +31397,117 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } timestamp: type: string description: >- @@ -30279,6 +31565,11 @@ paths: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + description: >- + TxResponse defines a structure containing relevant tx data and + metadata. The + + tags are stringified and the log is JSON decoded. description: |- BroadcastTxResponse is the response type for the Service.BroadcastTx method. @@ -31446,13 +32737,6 @@ paths: such as a git commit that validators could automatically upgrade to upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. - IBC upgrade logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -31514,6 +32798,117 @@ paths: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any + values in the form + + of utility functions or additional generated methods of + the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and + the unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will + yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a + custom JSON + + representation, that representation will be embedded + adding a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC @@ -32992,9 +34387,6 @@ paths: type: object properties: denom_trace: - description: >- - denom_trace returns the requested denomination trace - information. type: object properties: path: @@ -33007,6 +34399,11 @@ paths: base_denom: type: string description: base denomination of the relayed fungible token. + description: >- + DenomTrace contains the base denomination for ICS20 fungible + tokens and the + + source tracing information path. description: >- QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC @@ -34165,7 +35562,6 @@ paths: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -34338,6 +35734,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -34590,7 +35987,6 @@ paths: type: object properties: consensus_state: - title: consensus state associated with the channel type: object properties: '@type': @@ -34759,6 +36155,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -37914,7 +39311,6 @@ paths: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -38089,6 +39485,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -38384,7 +39781,6 @@ paths: type: object properties: client_state: - title: client state associated with the request identifier type: object properties: '@type': @@ -38553,6 +39949,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state associated with the request identifier proof: type: string format: byte @@ -39044,7 +40441,6 @@ paths: gets reset consensus_state: - title: consensus state type: object properties: '@type': @@ -39219,6 +40615,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -39852,9 +41249,6 @@ paths: type: object properties: consensus_state: - title: >- - consensus state associated with the client identifier at the - given height type: object properties: '@type': @@ -40023,12 +41417,14 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: >- + consensus state associated with the client identifier at the + given height proof: type: string format: byte title: merkle proof of existence proof_height: - title: height at which the proof was retrieved type: object properties: revision_number: @@ -40056,6 +41452,13 @@ paths: RevisionHeight gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes + of updating and + + freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState @@ -40286,7 +41689,6 @@ paths: type: object properties: upgraded_client_state: - title: client state associated with the request identifier type: object properties: '@type': @@ -40455,6 +41857,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state associated with the request identifier description: |- QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC method. @@ -40656,7 +42059,6 @@ paths: type: object properties: upgraded_consensus_state: - title: Consensus state associated with the request identifier type: object properties: '@type': @@ -40825,6 +42227,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: Consensus state associated with the request identifier description: |- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState RPC method. @@ -42022,7 +43425,6 @@ paths: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -42195,6 +43597,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -42442,7 +43845,6 @@ paths: type: object properties: consensus_state: - title: consensus state associated with the channel type: object properties: '@type': @@ -42611,6 +44013,7 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -45497,6 +46900,23 @@ paths: custom method signatures required by gogoproto. + baseline: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + annual_percentage_yield: + type: string description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -45934,44 +47354,6 @@ paths: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shards: type: array items: @@ -46158,44 +47540,6 @@ paths: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shardIds: type: array items: @@ -46269,6 +47613,8 @@ paths: format: uint64 data_id: type: string + commit: + type: string default: description: An unexpected error response. schema: @@ -47026,7 +48372,6 @@ definitions: type: object properties: account: - description: account defines the account of the corresponding address. type: object properties: '@type': @@ -47082,6 +48427,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- QueryAccountResponse is the response type for the Query/Account RPC method. @@ -48869,13 +50315,17 @@ definitions: type: string description: address defines the address that owns a particular denomination. balance: - description: balance is the balance of the denominated coin for an account. type: object properties: denom: type: string amount: type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. description: |- DenomOwner defines structure representing an account that owns or holds a particular denominated token. It contains the account address and account @@ -49106,13 +50556,17 @@ definitions: type: object properties: balance: - description: balance is the balance of the coin. type: object properties: denom: type: string amount: type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. description: >- QueryBalanceResponse is the response type for the Query/Balance RPC method. @@ -49120,9 +50574,6 @@ definitions: type: object properties: metadata: - description: >- - metadata describes and provides all the client information for the - requested token. type: object properties: description: @@ -49203,6 +50654,9 @@ definitions: Since: cosmos-sdk 0.46 + description: |- + Metadata represents a struct that describes + a basic token. description: >- QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC @@ -49220,13 +50674,20 @@ definitions: type: string description: address defines the address that owns a particular denomination. balance: - description: balance is the balance of the denominated coin for an account. type: object properties: denom: type: string amount: type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. description: >- DenomOwner defines structure representing an account that owns or holds a @@ -49454,13 +50915,17 @@ definitions: type: object properties: amount: - description: amount is the supply of the coin. type: object properties: denom: type: string amount: type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. description: >- QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. @@ -56380,7 +57845,6 @@ definitions: type: object properties: evidence: - description: evidence returns the requested evidence. type: object properties: '@type': @@ -56436,6 +57900,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- QueryEvidenceResponse is the response type for the Query/Evidence RPC method. @@ -57148,7 +58713,6 @@ definitions: type: object properties: deposit: - description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -57173,6 +58737,9 @@ definitions: method signatures required by gogoproto. + description: |- + Deposit defines an amount deposited by an account address to an active + proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -57851,7 +59418,6 @@ definitions: type: object properties: vote: - description: vote defined the queried vote. type: object properties: proposal_id: @@ -57888,6 +59454,9 @@ definitions: metadata: type: string description: metadata is any arbitrary metadata to attached to the vote. + description: |- + Vote defines a vote on a governance proposal. + A Vote consists of a proposal ID, the voter, and the vote option. description: QueryVoteResponse is the response type for the Query/Vote RPC method. cosmos.gov.v1.QueryVotesResponse: type: object @@ -58401,7 +59970,6 @@ definitions: type: object properties: deposit: - description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -58426,6 +59994,9 @@ definitions: method signatures required by gogoproto. + description: |- + Deposit defines an amount deposited by an account address to an active + proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -59091,7 +60662,6 @@ definitions: type: object properties: vote: - description: vote defined the queried vote. type: object properties: proposal_id: @@ -59146,6 +60716,9 @@ definitions: Since: cosmos-sdk 0.43 title: 'Since: cosmos-sdk 0.43' + description: |- + Vote defines a vote on a governance proposal. + A Vote consists of a proposal ID, the voter, and the vote option. description: QueryVoteResponse is the response type for the Query/Vote RPC method. cosmos.gov.v1beta1.QueryVotesResponse: type: object @@ -59476,7 +61049,6 @@ definitions: would create a different result on a running proposal. decision_policy: - description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -59532,6 +61104,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time @@ -60103,7 +61776,6 @@ definitions: would create a different result on a running proposal. decision_policy: - description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -60164,6 +61836,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time @@ -60228,7 +62006,6 @@ definitions: would create a different result on a running proposal. decision_policy: - description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -60289,6 +62066,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time @@ -60327,7 +62210,6 @@ definitions: type: object properties: info: - description: info is the GroupPolicyInfo for the group policy. type: object properties: address: @@ -60354,7 +62236,6 @@ definitions: would create a different result on a running proposal. decision_policy: - description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -60413,12 +62294,119 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } created_at: type: string format: date-time description: >- created_at is a timestamp specifying when a group policy was created. + description: >- + GroupPolicyInfo represents the high-level on-chain information for a + group policy. description: QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. cosmos.group.v1.QueryGroupsByAdminResponse: type: object @@ -61483,7 +63471,185 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: + type: object + properties: + '@type': + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + + protocol buffer message. This string must contain at least + + one "/" character. The last segment of the URL's path must + represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in a + canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the + + scheme `http`, `https`, or no scheme, one can optionally set up a + type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the + official + + protobuf release, and it is not used for type URLs beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } title: data is the app specific metadata of the NFT class. Optional + description: Class defines the class of the nft type. + cosmos.nft.v1beta1.MsgSendResponse: + type: object + description: MsgSendResponse defines the Msg/Send response type. + cosmos.nft.v1beta1.NFT: + type: object + properties: + class_id: + type: string + title: >- + class_id associated with the NFT, similar to the contract address of + ERC721 + id: + type: string + title: id is a unique identifier of the NFT + uri: + type: string + title: uri for the NFT metadata stored off chain + uri_hash: + type: string + title: uri_hash is a hash of the document pointed by uri + data: type: object properties: '@type': @@ -61640,185 +63806,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - description: Class defines the class of the nft type. - cosmos.nft.v1beta1.MsgSendResponse: - type: object - description: MsgSendResponse defines the Msg/Send response type. - cosmos.nft.v1beta1.NFT: - type: object - properties: - class_id: - type: string - title: >- - class_id associated with the NFT, similar to the contract address of - ERC721 - id: - type: string - title: id is a unique identifier of the NFT - uri: - type: string - title: uri for the NFT metadata stored off chain - uri_hash: - type: string - title: uri_hash is a hash of the document pointed by uri - data: title: data is an app specific data of the NFT. Optional - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: NFT defines the NFT. cosmos.nft.v1beta1.QueryBalanceResponse: type: object @@ -61858,7 +63846,6 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: - title: data is the app specific metadata of the NFT class. Optional type: object properties: '@type': @@ -62021,6 +64008,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is the app specific metadata of the NFT class. Optional description: Class defines the class of the nft type. title: QueryClassResponse is the response type for the Query/Class RPC method cosmos.nft.v1beta1.QueryClassesResponse: @@ -62058,7 +64046,6 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: - title: data is the app specific metadata of the NFT class. Optional type: object properties: '@type': @@ -62225,6 +64212,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is the app specific metadata of the NFT class. Optional description: Class defines the class of the nft type. pagination: type: object @@ -62274,7 +64262,6 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri data: - title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -62437,6 +64424,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. title: QueryNFTResponse is the response type for the Query/NFT RPC method cosmos.nft.v1beta1.QueryNFTsResponse: @@ -62462,7 +64450,6 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri data: - title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -62629,6 +64616,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. pagination: type: object @@ -62784,7 +64772,6 @@ definitions: type: object properties: val_signing_info: - title: val_signing_info is the signing info of requested val cons address type: object properties: address: @@ -62831,6 +64818,7 @@ definitions: their liveness activity. + title: val_signing_info is the signing info of requested val cons address title: >- QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC @@ -63201,9 +65189,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, - as a Protobuf Any. type: object properties: '@type': @@ -63264,6 +65249,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -63461,7 +65552,6 @@ definitions: type: object properties: delegation_response: - description: delegation_responses defines the delegation info of a delegation. type: object properties: delegation: @@ -63503,6 +65593,12 @@ definitions: method signatures required by gogoproto. + description: >- + DelegationResponse is equivalent to Delegation except that it contains + a + + balance in addition to shares which is more suitable for client + responses. description: >- QueryDelegationResponse is response type for the Query/Delegation RPC method. @@ -63661,7 +65757,6 @@ definitions: type: object properties: validator: - description: validator defines the validator info. type: object properties: operator_address: @@ -63670,9 +65765,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, as - a Protobuf Any. type: object properties: '@type': @@ -63731,6 +65823,110 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -63825,6 +66021,27 @@ definitions: Since: cosmos-sdk 0.46 + description: >- + Validator defines a validator, together with the total amount of the + + Validator's bond shares and their exchange rate to coins. Slashing + results in + + a decrease in the exchange rate, allowing correct calculation of + future + + undelegations without iterating over delegators. When coins are + delegated to + + this validator, the validator is credited with a delegation whose + number of + + bond shares is based on the amount of coins delegated divided by the + current + + exchange rate. Voting power can be calculated as total bonded shares + + multiplied by exchange rate. description: |- QueryDelegatorValidatorResponse response type for the Query/DelegatorValidator RPC method. @@ -63842,9 +66059,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, - as a Protobuf Any. type: object properties: '@type': @@ -63905,6 +66119,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -64149,9 +66469,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the - validator, as a Protobuf Any. type: object properties: '@type': @@ -64213,6 +66530,117 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -64527,7 +66955,6 @@ definitions: type: object properties: unbond: - description: unbond defines the unbonding information of a delegation. type: object properties: delegator_address: @@ -64566,6 +66993,9 @@ definitions: entries are the unbonding delegation entries. unbonding delegation entries + description: |- + UnbondingDelegation stores all of a single delegator's unbonding bonds + for a single validator in an time-ordered list. description: |- QueryDelegationResponse is response type for the Query/UnbondingDelegation RPC method. @@ -64648,7 +67078,6 @@ definitions: type: object properties: validator: - description: validator defines the validator info. type: object properties: operator_address: @@ -64657,9 +67086,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, as - a Protobuf Any. type: object properties: '@type': @@ -64718,6 +67144,110 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -64812,6 +67342,27 @@ definitions: Since: cosmos-sdk 0.46 + description: >- + Validator defines a validator, together with the total amount of the + + Validator's bond shares and their exchange rate to coins. Slashing + results in + + a decrease in the exchange rate, allowing correct calculation of + future + + undelegations without iterating over delegators. When coins are + delegated to + + this validator, the validator is credited with a delegation whose + number of + + bond shares is based on the amount of coins delegated divided by the + current + + exchange rate. Voting power can be calculated as total bonded shares + + multiplied by exchange rate. title: QueryValidatorResponse is response type for the Query/Validator RPC method cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse: type: object @@ -64902,9 +67453,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, - as a Protobuf Any. type: object properties: '@type': @@ -64965,6 +67513,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -65398,9 +68052,6 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: - description: >- - consensus_pubkey is the consensus public key of the validator, as a - Protobuf Any. type: object properties: '@type': @@ -65456,6 +68107,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } jailed: type: boolean description: >- @@ -65956,7 +68708,6 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: - description: The request transaction bytes. type: object properties: '@type': @@ -66012,6 +68763,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } timestamp: type: string description: >- @@ -66137,7 +68989,6 @@ definitions: signer_infos: type: array items: - type: object $ref: '#/definitions/cosmos.tx.v1beta1.SignerInfo' description: >- signer_infos defines the signing modes for the required signers. The @@ -66301,7 +69152,6 @@ definitions: type: object properties: tx_response: - description: tx_response is the queried TxResponses. type: object properties: height: @@ -66386,7 +69236,6 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: - description: The request transaction bytes. type: object properties: '@type': @@ -66445,6 +69294,110 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } timestamp: type: string description: >- @@ -66500,6 +69453,11 @@ definitions: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + description: >- + TxResponse defines a structure containing relevant tx data and + metadata. The + + tags are stringified and the log is JSON decoded. description: |- BroadcastTxResponse is the response type for the Service.BroadcastTx method. @@ -66563,7 +69521,6 @@ definitions: txs: type: array items: - type: object $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: txs are the transactions in the block. block_id: @@ -67167,7 +70124,6 @@ definitions: $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: tx is the queried transaction. tx_response: - description: tx_response is the queried TxResponses. type: object properties: height: @@ -67252,7 +70208,6 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: - description: The request transaction bytes. type: object properties: '@type': @@ -67311,6 +70266,110 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } timestamp: type: string description: >- @@ -67366,6 +70425,11 @@ definitions: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + description: >- + TxResponse defines a structure containing relevant tx data and + metadata. The + + tags are stringified and the log is JSON decoded. description: GetTxResponse is the response type for the Service.GetTx method. cosmos.tx.v1beta1.GetTxsEventResponse: type: object @@ -67373,7 +70437,6 @@ definitions: txs: type: array items: - type: object $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: txs is the list of queried transactions. tx_responses: @@ -67463,7 +70526,6 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: - description: The request transaction bytes. type: object properties: '@type': @@ -67524,6 +70586,112 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in + the form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default + use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last + '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } timestamp: type: string description: >- @@ -67718,7 +70886,6 @@ definitions: mode_infos: type: array items: - type: object $ref: '#/definitions/cosmos.tx.v1beta1.ModeInfo' title: |- mode_infos is the corresponding modes of the signers of the multisig @@ -67814,14 +70981,6 @@ definitions: type: object properties: public_key: - description: >- - public_key is the public key of the signer. It is optional for - accounts - - that already exist in state. If unset, the verifier can use the - required \ - - signer address for this position and lookup the public key. type: object properties: '@type': @@ -67877,6 +71036,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } mode_info: $ref: '#/definitions/cosmos.tx.v1beta1.ModeInfo' title: |- @@ -69425,13 +72685,6 @@ definitions: Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. IBC upgrade - logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -69487,6 +72740,107 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- Plan specifies information about a planned upgrade and when it should occur. @@ -69562,13 +72916,6 @@ definitions: such as a git commit that validators could automatically upgrade to upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. IBC - upgrade logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -69627,6 +72974,110 @@ definitions: used with implementation specific semantics. additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message + along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any + type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a + field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: >- QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC @@ -69832,7 +73283,6 @@ definitions: type: object properties: denom_trace: - description: denom_trace returns the requested denomination trace information. type: object properties: path: @@ -69845,6 +73295,11 @@ definitions: base_denom: type: string description: base denomination of the relayed fungible token. + description: >- + DenomTrace contains the base denomination for ICS20 fungible tokens + and the + + source tracing information path. description: |- QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC method. @@ -70311,7 +73766,6 @@ definitions: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -70474,6 +73928,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -70516,7 +73971,6 @@ definitions: type: object properties: consensus_state: - title: consensus state associated with the channel type: object properties: '@type': @@ -70673,6 +74127,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -71569,7 +75024,6 @@ definitions: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -71726,6 +75180,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -71761,7 +75216,6 @@ definitions: gets reset consensus_state: - title: consensus state type: object properties: '@type': @@ -71918,6 +75372,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -71967,7 +75422,6 @@ definitions: type: object properties: client_state: - title: client state associated with the request identifier type: object properties: '@type': @@ -72124,6 +75578,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state associated with the request identifier proof: type: string format: byte @@ -72175,7 +75630,6 @@ definitions: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -72342,6 +75796,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -72465,9 +75920,6 @@ definitions: type: object properties: consensus_state: - title: >- - consensus state associated with the client identifier at the given - height type: object properties: '@type': @@ -72624,12 +76076,14 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: >- + consensus state associated with the client identifier at the given + height proof: type: string format: byte title: merkle proof of existence proof_height: - title: height at which the proof was retrieved type: object properties: revision_number: @@ -72656,6 +76110,13 @@ definitions: RevisionHeight gets reset + title: >- + Height is a monotonically increasing data type + + that can be compared against another Height for the purposes of + updating and + + freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState @@ -72699,7 +76160,6 @@ definitions: gets reset consensus_state: - title: consensus state type: object properties: '@type': @@ -72866,6 +76326,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -72906,7 +76367,6 @@ definitions: type: object properties: upgraded_client_state: - title: client state associated with the request identifier type: object properties: '@type': @@ -73063,6 +76523,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state associated with the request identifier description: |- QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC method. @@ -73070,7 +76531,6 @@ definitions: type: object properties: upgraded_consensus_state: - title: Consensus state associated with the request identifier type: object properties: '@type': @@ -73227,6 +76687,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: Consensus state associated with the request identifier description: |- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState RPC method. @@ -73513,7 +76974,6 @@ definitions: type: string title: client identifier client_state: - title: client state type: object properties: '@type': @@ -73676,6 +77136,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -73718,7 +77179,6 @@ definitions: type: object properties: consensus_state: - title: consensus state associated with the channel type: object properties: '@type': @@ -73875,6 +77335,7 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -75339,6 +78800,20 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + baseline: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + annual_percentage_yield: + type: string description: Params defines the parameters for the module. saonetwork.sao.node.Pledge: type: object @@ -75804,6 +79279,23 @@ definitions: method signatures required by gogoproto. + baseline: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + annual_percentage_yield: + type: string description: QueryParamsResponse is response type for the Query/Params RPC method. saonetwork.sao.order.FullOrder: type: object @@ -75828,44 +79320,6 @@ definitions: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shardIds: type: array items: @@ -75935,44 +79389,8 @@ definitions: format: uint64 data_id: type: string - saonetwork.sao.order.Metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean commit: type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 saonetwork.sao.order.Order: type: object properties: @@ -75996,44 +79414,6 @@ definitions: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shards: type: array items: @@ -76098,44 +79478,6 @@ definitions: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shards: type: array items: @@ -76291,44 +79633,6 @@ definitions: replica: type: integer format: int32 - metadata: - type: object - properties: - dataId: - type: string - owner: - type: string - alias: - type: string - groupId: - type: string - orderId: - type: string - format: uint64 - tags: - type: array - items: - type: string - cid: - type: string - commits: - type: array - items: - type: string - extendInfo: - type: string - update: - type: boolean - commit: - type: string - rule: - type: string - duration: - type: string - format: uint64 - createdAt: - type: string - format: uint64 shardIds: type: array items: @@ -76401,6 +79705,8 @@ definitions: format: uint64 data_id: type: string + commit: + type: string saonetwork.sao.order.QueryGetShardResponse: type: object properties: diff --git a/go.mod b/go.mod index c1d823c0..4ff1c127 100644 --- a/go.mod +++ b/go.mod @@ -113,6 +113,7 @@ require ( github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 1f992d9b..20478c78 100644 --- a/go.sum +++ b/go.sum @@ -764,6 +764,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= diff --git a/proto/sao/node/params.proto b/proto/sao/node/params.proto index a0feb764..de06ae7f 100644 --- a/proto/sao/node/params.proto +++ b/proto/sao/node/params.proto @@ -11,4 +11,8 @@ message Params { option (gogoproto.goproto_stringer) = false; cosmos.base.v1beta1.Coin block_reward = 1 [(gogoproto.nullable) = false]; + + cosmos.base.v1beta1.Coin baseline = 2 [(gogoproto.nullable) = false]; + + string annual_percentage_yield = 3; } diff --git a/proto/sao/node/pool.proto b/proto/sao/node/pool.proto index 8baefb6d..6ea37df7 100644 --- a/proto/sao/node/pool.proto +++ b/proto/sao/node/pool.proto @@ -11,6 +11,7 @@ message Pool { cosmos.base.v1beta1.DecCoin acc_pledge_per_byte = 3 [(gogoproto.nullable) = false]; cosmos.base.v1beta1.DecCoin acc_reward_per_byte = 4 [(gogoproto.nullable) = false]; cosmos.base.v1beta1.DecCoin reward_per_block = 5 [(gogoproto.nullable) = false]; - int64 total_storage = 6; - int64 rewarded_block_count = 7; + cosmos.base.v1beta1.DecCoin next_reward_per_block = 6 [(gogoproto.nullable) = false]; + int64 total_storage = 7; + int64 rewarded_block_count = 8; } diff --git a/x/node/abci.go b/x/node/abci.go index 5faf0049..72e0261a 100644 --- a/x/node/abci.go +++ b/x/node/abci.go @@ -1,6 +1,7 @@ package node import ( + "math" "math/big" "time" @@ -11,8 +12,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +const TOTAL_REWARD = "400000000000000sao" + func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + // 1st age 6.25 * 32000000 blocks + // 16000000 blocks per year + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) logger := k.Logger(ctx) @@ -28,24 +34,51 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { } params := k.GetParams(ctx) + if params.BlockReward.IsZero() { logger.Error("invalid block reward") return } - bitLen := uint(params.BlockReward.Amount.BigInt().BitLen()) - halvings := uint(pool.RewardedBlockCount / types.NODE_SUBSIDY_HALVING_INTERVAL) - if halvings >= bitLen { - return - } + var rewardCoin sdk.Coin subsidy := params.BlockReward.Amount.BigInt() - subsidy.Rsh(subsidy, halvings) - if subsidy.Cmp(big.NewInt(0)) <= 0 { + subsidy.Rsh(subsidy, GetRewardAge(pool)) + rewardCoin = sdk.NewCoin(params.BlockReward.Denom, sdkmath.NewIntFromBigInt(subsidy)) + logger.Debug("reward age", "age", GetRewardAge(pool)) + + if pool.TotalPledged.IsLT(params.Baseline) { + apy, err := sdk.NewDecFromStr(params.AnnualPercentageYield) + if err != nil { + logger.Error("error node apy params", "err", err.Error()) + return + } + + reward := sdk.NewDecCoinFromCoin(pool.TotalPledged).Amount.Mul(apy).QuoInt64(16000000).TruncateInt() + logger.Debug("baseline mint", "reward", reward) + if reward.LT(rewardCoin.Amount) { + rewardCoin = sdk.NewCoin(params.BlockReward.Denom, reward) + } + } + + if rewardCoin.IsZero() { + logger.Debug("waiting for more storage pledge", "current", pool.TotalPledged) return } - rewardCoin := sdk.NewCoin(params.BlockReward.Denom, sdkmath.NewIntFromBigInt(subsidy)) + if pool.NextRewardPerBlock.IsZero() { + pool.NextRewardPerBlock = sdk.NewDecCoinFromCoin(rewardCoin) + } + + // reset reward accumulation every 2000 blocks + + if ctx.BlockHeight()%100 == 0 { + pool.RewardPerBlock = pool.NextRewardPerBlock + pool.NextRewardPerBlock = sdk.NewDecCoinFromCoin(rewardCoin) + } + + pool.NextRewardPerBlock.Amount = pool.NextRewardPerBlock.Amount.Add(sdk.NewDecFromInt(rewardCoin.Amount)).Quo(sdk.NewDec(2)) + rewardCoins := sdk.NewCoins(rewardCoin) logger.Debug("mint node incentive coins", "coin", rewardCoin) @@ -59,3 +92,10 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { pool.RewardedBlockCount += 1 k.SetPool(ctx, pool) } + +func GetRewardAge(pool types.Pool) uint { + totalReward, _ := sdk.ParseCoinNormalized(TOTAL_REWARD) + remain := totalReward.Sub(pool.TotalReward) + t, _ := new(big.Float).SetInt(totalReward.Amount.Quo(remain.Amount).BigInt()).Float64() + return uint(math.Log2(t)) +} diff --git a/x/node/keeper/migrations.go b/x/node/keeper/migrations.go index 9dd14eda..6b7525e0 100644 --- a/x/node/keeper/migrations.go +++ b/x/node/keeper/migrations.go @@ -2,6 +2,7 @@ package keeper import ( v2 "github.com/SaoNetwork/sao/x/node/migrations/v2" + v3 "github.com/SaoNetwork/sao/x/node/migrations/v3" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,3 +17,11 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v2.MigrateStore(ctx, m.keeper.bank, m.keeper.storeKey, m.keeper.orderStoreKey, m.keeper.cdc) } + +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + err := v3.UpdateNodeParams(ctx, &m.keeper.paramstore) + if err != nil { + return err + } + return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/node/keeper/params.go b/x/node/keeper/params.go index a43593fa..98e47f6c 100644 --- a/x/node/keeper/params.go +++ b/x/node/keeper/params.go @@ -7,8 +7,11 @@ import ( // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) types.Params { + apy, _ := sdk.NewDecFromStr(k.AnnualPercentageYield(ctx)) return types.NewParams( k.BlockReward(ctx), + k.Baseline(ctx), + apy, ) } @@ -23,8 +26,12 @@ func (k Keeper) BlockReward(ctx sdk.Context) (res sdk.Coin) { return } -// EarnDenom returns the EarnDenom param -func (k Keeper) EarnDenom(ctx sdk.Context) (res string) { - k.paramstore.Get(ctx, types.KeyEarnDenom, &res) +func (k Keeper) Baseline(ctx sdk.Context) (res sdk.Coin) { + k.paramstore.Get(ctx, types.KeyBaseLine, &res) + return +} + +func (k Keeper) AnnualPercentageYield(ctx sdk.Context) (res string) { + k.paramstore.Get(ctx, types.KeyAPY, &res) return } diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 0e3a4fbd..57d3c0c9 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -75,10 +75,10 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype "shardSizeToAdd", shard.Size_) pledge.TotalStorage += int64(shard.Size_) - if !params.BlockReward.Amount.IsZero() { - //rewardPerByte := sdk.NewDecFromInt(params.BlockReward.Amount).QuoInt64(pool.TotalStorage) + if !pool.RewardPerBlock.Amount.IsZero() { + rewardPerByte := pool.RewardPerBlock.Amount.Quo(sdk.NewDec(pool.TotalStorage)) // rewardPerByte := sdk.NewDecFromBigInt(big.NewInt(1)) - rewardPerByte := sdk.NewDecWithPrec(1, 6) + //rewardPerByte := sdk.NewDecWithPrec(1, 6) storageDecPledge := sdk.NewInt64DecCoin(params.BlockReward.Denom, 0) // 1. first N% rewards diff --git a/x/node/migrations/v1/types/pool.pb.go b/x/node/migrations/v1/types/pool.pb.go new file mode 100644 index 00000000..769d4b1f --- /dev/null +++ b/x/node/migrations/v1/types/pool.pb.go @@ -0,0 +1,613 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/node/pool.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Pool struct { + TotalPledged types.Coin `protobuf:"bytes,1,opt,name=total_pledged,json=totalPledged,proto3" json:"total_pledged"` + TotalReward types.Coin `protobuf:"bytes,2,opt,name=total_reward,json=totalReward,proto3" json:"total_reward"` + AccPledgePerByte types.DecCoin `protobuf:"bytes,3,opt,name=acc_pledge_per_byte,json=accPledgePerByte,proto3" json:"acc_pledge_per_byte"` + AccRewardPerByte types.DecCoin `protobuf:"bytes,4,opt,name=acc_reward_per_byte,json=accRewardPerByte,proto3" json:"acc_reward_per_byte"` + RewardPerBlock types.DecCoin `protobuf:"bytes,5,opt,name=reward_per_block,json=rewardPerBlock,proto3" json:"reward_per_block"` + TotalStorage int64 `protobuf:"varint,6,opt,name=total_storage,json=totalStorage,proto3" json:"total_storage,omitempty"` + RewardedBlockCount int64 `protobuf:"varint,7,opt,name=rewarded_block_count,json=rewardedBlockCount,proto3" json:"rewarded_block_count,omitempty"` +} + +func (m *Pool) Reset() { *m = Pool{} } +func (m *Pool) String() string { return proto.CompactTextString(m) } +func (*Pool) ProtoMessage() {} +func (*Pool) Descriptor() ([]byte, []int) { + return fileDescriptor_d299d3261ef03a4f, []int{0} +} +func (m *Pool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pool.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Pool) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pool.Merge(m, src) +} +func (m *Pool) XXX_Size() int { + return m.Size() +} +func (m *Pool) XXX_DiscardUnknown() { + xxx_messageInfo_Pool.DiscardUnknown(m) +} + +var xxx_messageInfo_Pool proto.InternalMessageInfo + +func (m *Pool) GetTotalPledged() types.Coin { + if m != nil { + return m.TotalPledged + } + return types.Coin{} +} + +func (m *Pool) GetTotalReward() types.Coin { + if m != nil { + return m.TotalReward + } + return types.Coin{} +} + +func (m *Pool) GetAccPledgePerByte() types.DecCoin { + if m != nil { + return m.AccPledgePerByte + } + return types.DecCoin{} +} + +func (m *Pool) GetAccRewardPerByte() types.DecCoin { + if m != nil { + return m.AccRewardPerByte + } + return types.DecCoin{} +} + +func (m *Pool) GetRewardPerBlock() types.DecCoin { + if m != nil { + return m.RewardPerBlock + } + return types.DecCoin{} +} + +func (m *Pool) GetTotalStorage() int64 { + if m != nil { + return m.TotalStorage + } + return 0 +} + +func (m *Pool) GetRewardedBlockCount() int64 { + if m != nil { + return m.RewardedBlockCount + } + return 0 +} + +func init() { + proto.RegisterType((*Pool)(nil), "saonetwork.sao.node.V1Pool") +} + +func init() { proto.RegisterFile("sao/node/pool.proto", fileDescriptor_d299d3261ef03a4f) } + +var fileDescriptor_d299d3261ef03a4f = []byte{ + // 362 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0xdb, 0x0b, 0x97, 0x9b, 0x94, 0x7b, 0x6f, 0x48, 0x61, 0x51, 0x89, 0xa9, 0x44, 0x13, + 0xc3, 0x6a, 0x46, 0xf4, 0x05, 0x4c, 0x61, 0x69, 0x0c, 0xc2, 0xce, 0x4d, 0x33, 0x9d, 0x9e, 0x54, + 0x42, 0xe9, 0x69, 0xa6, 0x83, 0xc8, 0x5b, 0xf8, 0x58, 0x2c, 0x59, 0x9a, 0x98, 0x18, 0x03, 0x2f, + 0x62, 0x66, 0x86, 0x2a, 0x0b, 0x17, 0xb8, 0x6b, 0xcf, 0x7f, 0xfe, 0x6f, 0xfe, 0x9c, 0xfc, 0x4e, + 0xb3, 0x60, 0x48, 0x33, 0x8c, 0x81, 0xe6, 0x88, 0x29, 0xc9, 0x05, 0x4a, 0x74, 0xd5, 0x30, 0x03, + 0xb9, 0x40, 0x31, 0x25, 0x05, 0x43, 0xa2, 0xf4, 0x76, 0x2b, 0xc1, 0x04, 0xb5, 0x4e, 0xd5, 0x97, + 0x59, 0x6d, 0xfb, 0x1c, 0x8b, 0x19, 0x16, 0x34, 0x62, 0x05, 0xd0, 0xc7, 0x5e, 0x04, 0x92, 0xf5, + 0x28, 0xc7, 0x49, 0x66, 0xf4, 0xd3, 0xd7, 0x8a, 0x53, 0x1d, 0x22, 0xa6, 0xee, 0xc0, 0xf9, 0x27, + 0x51, 0xb2, 0x34, 0xcc, 0x53, 0x88, 0x13, 0x88, 0x3d, 0xbb, 0x63, 0x77, 0xeb, 0x97, 0x47, 0xc4, + 0x00, 0x88, 0x02, 0x90, 0x1d, 0x80, 0xf4, 0x71, 0x92, 0x05, 0xd5, 0xd5, 0xdb, 0x89, 0x35, 0xfa, + 0xab, 0x5d, 0x43, 0x63, 0x72, 0x03, 0xc7, 0xfc, 0x87, 0x02, 0x16, 0x4c, 0xc4, 0xde, 0xaf, 0xc3, + 0x20, 0x75, 0x6d, 0x1a, 0x69, 0x8f, 0x7b, 0xe7, 0x34, 0x19, 0xe7, 0xbb, 0x1c, 0x61, 0x0e, 0x22, + 0x8c, 0x96, 0x12, 0xbc, 0x8a, 0x46, 0x1d, 0x7f, 0x8b, 0x1a, 0x00, 0xdf, 0xa3, 0x35, 0x18, 0xe7, + 0x26, 0xd0, 0x10, 0x44, 0xb0, 0x94, 0x50, 0x22, 0x4d, 0xa8, 0x2f, 0x64, 0xf5, 0x47, 0x48, 0x13, + 0xaf, 0x44, 0xde, 0x38, 0x8d, 0x7d, 0x5c, 0x8a, 0x7c, 0xea, 0xfd, 0x3e, 0x98, 0xf7, 0x5f, 0x7c, + 0xc2, 0x94, 0xd3, 0x3d, 0x2b, 0xaf, 0x5f, 0x48, 0x14, 0x2c, 0x01, 0xaf, 0xd6, 0xb1, 0xbb, 0x95, + 0xdd, 0x71, 0xc7, 0x66, 0xe6, 0x5e, 0x38, 0x2d, 0x63, 0x83, 0xd8, 0x3c, 0x18, 0x72, 0x9c, 0x67, + 0xd2, 0xfb, 0xa3, 0x77, 0xdd, 0x52, 0xd3, 0xc4, 0xbe, 0x52, 0x82, 0xeb, 0xd5, 0xc6, 0xb7, 0xd7, + 0x1b, 0xdf, 0x7e, 0xdf, 0xf8, 0xf6, 0xf3, 0xd6, 0xb7, 0xd6, 0x5b, 0xdf, 0x7a, 0xd9, 0xfa, 0xd6, + 0xfd, 0x79, 0x32, 0x91, 0x0f, 0xf3, 0x88, 0x70, 0x9c, 0xd1, 0x31, 0xc3, 0x5b, 0xd3, 0x26, 0xaa, + 0xda, 0xf6, 0x64, 0xfa, 0x26, 0x97, 0x39, 0x14, 0x51, 0x4d, 0xd7, 0xe4, 0xea, 0x23, 0x00, 0x00, + 0xff, 0xff, 0xfd, 0x4d, 0x62, 0x21, 0x88, 0x02, 0x00, 0x00, +} + +func (m *Pool) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Pool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RewardedBlockCount != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.RewardedBlockCount)) + i-- + dAtA[i] = 0x38 + } + if m.TotalStorage != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.TotalStorage)) + i-- + dAtA[i] = 0x30 + } + { + size, err := m.RewardPerBlock.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size, err := m.AccRewardPerByte.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.AccPledgePerByte.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.TotalReward.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.TotalPledged.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintPool(dAtA []byte, offset int, v uint64) int { + offset -= sovPool(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Pool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TotalPledged.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.TotalReward.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.AccPledgePerByte.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.AccRewardPerByte.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.RewardPerBlock.Size() + n += 1 + l + sovPool(uint64(l)) + if m.TotalStorage != 0 { + n += 1 + sovPool(uint64(m.TotalStorage)) + } + if m.RewardedBlockCount != 0 { + n += 1 + sovPool(uint64(m.RewardedBlockCount)) + } + return n +} + +func sovPool(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPool(x uint64) (n int) { + return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Pool) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Pool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalPledged", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalPledged.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalReward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccPledgePerByte", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AccPledgePerByte.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccRewardPerByte", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AccRewardPerByte.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPerBlock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardPerBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalStorage", wireType) + } + m.TotalStorage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalStorage |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardedBlockCount", wireType) + } + m.RewardedBlockCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RewardedBlockCount |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPool(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPool + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPool + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPool + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPool + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/node/migrations/v2/types/params.pb.go b/x/node/migrations/v2/types/params.pb.go new file mode 100644 index 00000000..470a9c8c --- /dev/null +++ b/x/node/migrations/v2/types/params.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/node/params.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + BlockReward types.Coin `protobuf:"bytes,1,opt,name=block_reward,json=blockReward,proto3" json:"block_reward"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_c6a39a6c05c26f45, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetBlockReward() types.Coin { + if m != nil { + return m.BlockReward + } + return types.Coin{} +} + +func init() { + proto.RegisterType((*Params)(nil), "saonetwork.sao.node.Params") +} + +func init() { proto.RegisterFile("sao/node/params.proto", fileDescriptor_c6a39a6c05c26f45) } + +var fileDescriptor_c6a39a6c05c26f45 = []byte{ + // 235 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4e, 0xcc, 0xd7, + 0xcf, 0xcb, 0x4f, 0x49, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, + 0xcc, 0xd7, 0x03, 0xa9, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, + 0xa5, 0x52, 0x72, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, 0x65, + 0x86, 0x49, 0xa9, 0x25, 0x89, 0x86, 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0x20, 0x2e, + 0xb6, 0x00, 0xb0, 0xd1, 0x42, 0x4e, 0x5c, 0x3c, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0xf1, 0x45, 0xa9, + 0xe5, 0x89, 0x45, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x10, 0x03, 0xf4, + 0x40, 0x06, 0xe8, 0x41, 0x0d, 0xd0, 0x73, 0xce, 0xcf, 0xcc, 0x73, 0x62, 0x39, 0x71, 0x4f, 0x9e, + 0x21, 0x88, 0x1b, 0xac, 0x29, 0x08, 0xac, 0xc7, 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x27, 0x87, + 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, + 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x4e, 0xcc, 0xf7, 0x83, 0xf8, 0x41, 0x1f, 0xe4, 0xcb, + 0x0a, 0x88, 0x3f, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x8e, 0x33, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xf8, 0x11, 0xe7, 0xa8, 0x00, 0x01, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.BlockReward.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.BlockReward.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockReward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BlockReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/node/migrations/v3/migrations.go b/x/node/migrations/v3/migrations.go new file mode 100644 index 00000000..e866a9ad --- /dev/null +++ b/x/node/migrations/v3/migrations.go @@ -0,0 +1,72 @@ +package v3 + +import ( + "errors" + + v1 "github.com/SaoNetwork/sao/x/node/migrations/v1/types" + "github.com/SaoNetwork/sao/x/node/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + pool, found := GetV1Pool(ctx, storeKey, cdc) + if !found { + return errors.New("pool not found") + } + + rewardPerBlock := pool.TotalReward.Amount.QuoRaw(pool.RewardedBlockCount) + newPool := types.Pool{ + TotalPledged: pool.TotalPledged, + TotalReward: pool.TotalReward, + TotalStorage: pool.TotalStorage, + AccPledgePerByte: pool.AccPledgePerByte, + AccRewardPerByte: pool.AccRewardPerByte, + RewardPerBlock: sdk.NewDecCoin(pool.TotalReward.Denom, rewardPerBlock), + RewardedBlockCount: pool.RewardedBlockCount, + NextRewardPerBlock: sdk.NewInt64DecCoin(pool.TotalReward.Denom, 0), + } + + SetPool(ctx, storeKey, cdc, newPool) + + return nil +} + +func UpdateNodeParams(ctx sdk.Context, paramStore *paramtypes.Subspace) error { + var blockReward sdk.Coin + //blockReward = paramstore + paramStore.GetIfExists(ctx, types.KeyBlockReward, &blockReward) + + // set baseLine + baseLine := sdk.NewInt64Coin(blockReward.Denom, 2000000) + paramStore.Set(ctx, types.KeyBaseLine, &baseLine) + + // blockReward = 6.25 SAO + blockReward = sdk.NewInt64Coin(blockReward.Denom, 6250000) + paramStore.Set(ctx, types.KeyBlockReward, &blockReward) + + // set apy + paramStore.Set(ctx, types.KeyAPY, "8.0") + return nil +} + +func GetV1Pool(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) (val v1.Pool, found bool) { + store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.PoolKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + cdc.MustUnmarshal(b, &val) + return val, true +} + +func SetPool(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, pool types.Pool) { + store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.PoolKey)) + b := cdc.MustMarshal(&pool) + store.Set([]byte{0}, b) +} diff --git a/x/node/module.go b/x/node/module.go index 3ad3eeba..8d088cfb 100644 --- a/x/node/module.go +++ b/x/node/module.go @@ -133,7 +133,11 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { migrator := keeper.NewMigrator(am.keeper) if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { - panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) + panic(fmt.Errorf("failed to migrate %s to v2: %w", types.ModuleName, err)) + } + + if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate2to3); err != nil { + panic(fmt.Errorf("failed to migrate %s to v3: %w", types.ModuleName, err)) } } @@ -158,7 +162,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/node/types/params.go b/x/node/types/params.go index 15e7ea92..a47863a2 100644 --- a/x/node/types/params.go +++ b/x/node/types/params.go @@ -15,9 +15,15 @@ var ( ) var ( - KeyEarnDenom = []byte("EarnDenom") + KeyBaseLine = []byte("Baseline") // TODO: Determine the default value - DefaultEarnDenom string = "earn_denom" + DefaultBaseline sdk.Coin +) + +var ( + KeyAPY = []byte("AnnualPercentageYield") + // TODO: Determine the default value + DefaultAPY = sdk.NewDecWithPrec(50, 2) ) // ParamKeyTable the param key table for launch module @@ -28,9 +34,13 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( blockReward sdk.Coin, + baseline sdk.Coin, + apy sdk.Dec, ) Params { return Params{ - BlockReward: blockReward, + BlockReward: blockReward, + Baseline: baseline, + AnnualPercentageYield: apy.String(), } } @@ -38,6 +48,8 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultBlockReward, + DefaultBaseline, + DefaultAPY, ) } @@ -45,6 +57,8 @@ func DefaultParams() Params { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyBlockReward, &p.BlockReward, validateBlockReward), + paramtypes.NewParamSetPair(KeyBaseLine, &p.Baseline, validateBaseline), + paramtypes.NewParamSetPair(KeyAPY, &p.AnnualPercentageYield, validateAPY), } } @@ -54,6 +68,13 @@ func (p Params) Validate() error { return err } + if err := validateBaseline(p.Baseline); err != nil { + return err + } + + if err := validateAPY(p.AnnualPercentageYield); err != nil { + return err + } return nil } @@ -69,3 +90,16 @@ func validateBlockReward(v interface{}) error { return nil } + +// validateBaseline validates the BlockReward param +func validateBaseline(v interface{}) error { + _ = v.(sdk.Coin) + + return nil +} + +// validateAPY validates the BlockReward param +func validateAPY(v interface{}) error { + _, err := sdk.NewDecFromStr(v.(string)) + return err +} diff --git a/x/node/types/params.pb.go b/x/node/types/params.pb.go index 470a9c8c..e129ea80 100644 --- a/x/node/types/params.pb.go +++ b/x/node/types/params.pb.go @@ -26,7 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - BlockReward types.Coin `protobuf:"bytes,1,opt,name=block_reward,json=blockReward,proto3" json:"block_reward"` + BlockReward types.Coin `protobuf:"bytes,1,opt,name=block_reward,json=blockReward,proto3" json:"block_reward"` + Baseline types.Coin `protobuf:"bytes,2,opt,name=baseline,proto3" json:"baseline"` + AnnualPercentageYield string `protobuf:"bytes,3,opt,name=annual_percentage_yield,json=annualPercentageYield,proto3" json:"annual_percentage_yield,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -68,6 +70,20 @@ func (m *Params) GetBlockReward() types.Coin { return types.Coin{} } +func (m *Params) GetBaseline() types.Coin { + if m != nil { + return m.Baseline + } + return types.Coin{} +} + +func (m *Params) GetAnnualPercentageYield() string { + if m != nil { + return m.AnnualPercentageYield + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "saonetwork.sao.node.Params") } @@ -75,22 +91,26 @@ func init() { func init() { proto.RegisterFile("sao/node/params.proto", fileDescriptor_c6a39a6c05c26f45) } var fileDescriptor_c6a39a6c05c26f45 = []byte{ - // 235 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4e, 0xcc, 0xd7, - 0xcf, 0xcb, 0x4f, 0x49, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, - 0xcc, 0xd7, 0x03, 0xa9, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, - 0xa5, 0x52, 0x72, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, 0x65, - 0x86, 0x49, 0xa9, 0x25, 0x89, 0x86, 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0x20, 0x2e, - 0xb6, 0x00, 0xb0, 0xd1, 0x42, 0x4e, 0x5c, 0x3c, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0xf1, 0x45, 0xa9, - 0xe5, 0x89, 0x45, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x10, 0x03, 0xf4, - 0x40, 0x06, 0xe8, 0x41, 0x0d, 0xd0, 0x73, 0xce, 0xcf, 0xcc, 0x73, 0x62, 0x39, 0x71, 0x4f, 0x9e, - 0x21, 0x88, 0x1b, 0xac, 0x29, 0x08, 0xac, 0xc7, 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x27, 0x87, - 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, - 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, - 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x4e, 0xcc, 0xf7, 0x83, 0xf8, 0x41, 0x1f, 0xe4, 0xcb, - 0x0a, 0x88, 0x3f, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x8e, 0x33, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xf8, 0x11, 0xe7, 0xa8, 0x00, 0x01, 0x00, 0x00, + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x46, 0xe3, 0xff, 0xaf, 0x2a, 0x48, 0x99, 0x02, 0x15, 0xa5, 0x83, 0x5b, 0x31, 0xa0, 0x4e, + 0xb6, 0x0a, 0x12, 0x03, 0x2c, 0xa8, 0xec, 0xa8, 0x0a, 0x13, 0x2c, 0xd1, 0x4d, 0x62, 0x85, 0xa8, + 0x89, 0x6f, 0x64, 0xbb, 0x94, 0xbe, 0x05, 0x23, 0x23, 0x6f, 0x43, 0xc7, 0x8e, 0x4c, 0x08, 0x25, + 0x2f, 0x82, 0x1c, 0xa3, 0xce, 0x6c, 0x57, 0x3a, 0xf7, 0x3b, 0xc3, 0xf1, 0xfb, 0x1a, 0x90, 0x4b, + 0x4c, 0x05, 0xaf, 0x40, 0x41, 0xa9, 0x59, 0xa5, 0xd0, 0x60, 0x70, 0xa8, 0x01, 0xa5, 0x30, 0x2b, + 0x54, 0x0b, 0xa6, 0x01, 0x99, 0xfd, 0x18, 0x1e, 0x65, 0x98, 0x61, 0xcb, 0xb9, 0xbd, 0xdc, 0xeb, + 0x90, 0x26, 0xa8, 0x4b, 0xd4, 0x3c, 0x06, 0x2d, 0xf8, 0xf3, 0x34, 0x16, 0x06, 0xa6, 0x3c, 0xc1, + 0x5c, 0x3a, 0x7e, 0xfa, 0x41, 0xfc, 0xee, 0xbc, 0x75, 0x07, 0x33, 0xff, 0x20, 0x2e, 0x30, 0x59, + 0x44, 0x4a, 0xac, 0x40, 0xa5, 0x03, 0x32, 0x26, 0x93, 0xde, 0xf9, 0x09, 0x73, 0x06, 0x66, 0x0d, + 0xec, 0xd7, 0xc0, 0x6e, 0x31, 0x97, 0xb3, 0xce, 0xe6, 0x6b, 0xe4, 0x85, 0xbd, 0x76, 0x14, 0xb6, + 0x9b, 0xe0, 0xda, 0xdf, 0xb3, 0x7f, 0x45, 0x2e, 0xc5, 0xe0, 0xdf, 0xdf, 0xf6, 0xbb, 0x41, 0x70, + 0xe9, 0x1f, 0x83, 0x94, 0x4b, 0x28, 0xa2, 0x4a, 0xa8, 0x44, 0x48, 0x03, 0x99, 0x88, 0xd6, 0xb9, + 0x28, 0xd2, 0xc1, 0xff, 0x31, 0x99, 0xec, 0x87, 0x7d, 0x87, 0xe7, 0x3b, 0xfa, 0x60, 0xe1, 0x55, + 0xe7, 0xed, 0x7d, 0xe4, 0xcd, 0x6e, 0x36, 0x35, 0x25, 0xdb, 0x9a, 0x92, 0xef, 0x9a, 0x92, 0xd7, + 0x86, 0x7a, 0xdb, 0x86, 0x7a, 0x9f, 0x0d, 0xf5, 0x1e, 0xcf, 0xb2, 0xdc, 0x3c, 0x2d, 0x63, 0x96, + 0x60, 0xc9, 0xef, 0x01, 0xef, 0x5c, 0x39, 0x6e, 0xdb, 0xbe, 0xb8, 0xba, 0x66, 0x5d, 0x09, 0x1d, + 0x77, 0xdb, 0x24, 0x17, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x04, 0x5e, 0x99, 0x71, 0x76, 0x01, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -113,6 +133,23 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AnnualPercentageYield) > 0 { + i -= len(m.AnnualPercentageYield) + copy(dAtA[i:], m.AnnualPercentageYield) + i = encodeVarintParams(dAtA, i, uint64(len(m.AnnualPercentageYield))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Baseline.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 { size, err := m.BlockReward.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -145,6 +182,12 @@ func (m *Params) Size() (n int) { _ = l l = m.BlockReward.Size() n += 1 + l + sovParams(uint64(l)) + l = m.Baseline.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.AnnualPercentageYield) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -216,6 +259,71 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Baseline", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Baseline.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualPercentageYield", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AnnualPercentageYield = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/node/types/pool.pb.go b/x/node/types/pool.pb.go index 716f504c..a4b16d08 100644 --- a/x/node/types/pool.pb.go +++ b/x/node/types/pool.pb.go @@ -30,8 +30,9 @@ type Pool struct { AccPledgePerByte types.DecCoin `protobuf:"bytes,3,opt,name=acc_pledge_per_byte,json=accPledgePerByte,proto3" json:"acc_pledge_per_byte"` AccRewardPerByte types.DecCoin `protobuf:"bytes,4,opt,name=acc_reward_per_byte,json=accRewardPerByte,proto3" json:"acc_reward_per_byte"` RewardPerBlock types.DecCoin `protobuf:"bytes,5,opt,name=reward_per_block,json=rewardPerBlock,proto3" json:"reward_per_block"` - TotalStorage int64 `protobuf:"varint,6,opt,name=total_storage,json=totalStorage,proto3" json:"total_storage,omitempty"` - RewardedBlockCount int64 `protobuf:"varint,7,opt,name=rewarded_block_count,json=rewardedBlockCount,proto3" json:"rewarded_block_count,omitempty"` + NextRewardPerBlock types.DecCoin `protobuf:"bytes,6,opt,name=next_reward_per_block,json=nextRewardPerBlock,proto3" json:"next_reward_per_block"` + TotalStorage int64 `protobuf:"varint,7,opt,name=total_storage,json=totalStorage,proto3" json:"total_storage,omitempty"` + RewardedBlockCount int64 `protobuf:"varint,8,opt,name=rewarded_block_count,json=rewardedBlockCount,proto3" json:"rewarded_block_count,omitempty"` } func (m *Pool) Reset() { *m = Pool{} } @@ -102,6 +103,13 @@ func (m *Pool) GetRewardPerBlock() types.DecCoin { return types.DecCoin{} } +func (m *Pool) GetNextRewardPerBlock() types.DecCoin { + if m != nil { + return m.NextRewardPerBlock + } + return types.DecCoin{} +} + func (m *Pool) GetTotalStorage() int64 { if m != nil { return m.TotalStorage @@ -123,30 +131,31 @@ func init() { func init() { proto.RegisterFile("sao/node/pool.proto", fileDescriptor_d299d3261ef03a4f) } var fileDescriptor_d299d3261ef03a4f = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4e, 0xea, 0x40, - 0x14, 0x86, 0xdb, 0x0b, 0x97, 0x9b, 0x94, 0x7b, 0x6f, 0x48, 0x61, 0x51, 0x89, 0xa9, 0x44, 0x13, - 0xc3, 0x6a, 0x46, 0xf4, 0x05, 0x4c, 0x61, 0x69, 0x0c, 0xc2, 0xce, 0x4d, 0x33, 0x9d, 0x9e, 0x54, - 0x42, 0xe9, 0x69, 0xa6, 0x83, 0xc8, 0x5b, 0xf8, 0x58, 0x2c, 0x59, 0x9a, 0x98, 0x18, 0x03, 0x2f, - 0x62, 0x66, 0x86, 0x2a, 0x0b, 0x17, 0xb8, 0x6b, 0xcf, 0x7f, 0xfe, 0x6f, 0xfe, 0x9c, 0xfc, 0x4e, - 0xb3, 0x60, 0x48, 0x33, 0x8c, 0x81, 0xe6, 0x88, 0x29, 0xc9, 0x05, 0x4a, 0x74, 0xd5, 0x30, 0x03, - 0xb9, 0x40, 0x31, 0x25, 0x05, 0x43, 0xa2, 0xf4, 0x76, 0x2b, 0xc1, 0x04, 0xb5, 0x4e, 0xd5, 0x97, - 0x59, 0x6d, 0xfb, 0x1c, 0x8b, 0x19, 0x16, 0x34, 0x62, 0x05, 0xd0, 0xc7, 0x5e, 0x04, 0x92, 0xf5, - 0x28, 0xc7, 0x49, 0x66, 0xf4, 0xd3, 0xd7, 0x8a, 0x53, 0x1d, 0x22, 0xa6, 0xee, 0xc0, 0xf9, 0x27, - 0x51, 0xb2, 0x34, 0xcc, 0x53, 0x88, 0x13, 0x88, 0x3d, 0xbb, 0x63, 0x77, 0xeb, 0x97, 0x47, 0xc4, - 0x00, 0x88, 0x02, 0x90, 0x1d, 0x80, 0xf4, 0x71, 0x92, 0x05, 0xd5, 0xd5, 0xdb, 0x89, 0x35, 0xfa, - 0xab, 0x5d, 0x43, 0x63, 0x72, 0x03, 0xc7, 0xfc, 0x87, 0x02, 0x16, 0x4c, 0xc4, 0xde, 0xaf, 0xc3, - 0x20, 0x75, 0x6d, 0x1a, 0x69, 0x8f, 0x7b, 0xe7, 0x34, 0x19, 0xe7, 0xbb, 0x1c, 0x61, 0x0e, 0x22, - 0x8c, 0x96, 0x12, 0xbc, 0x8a, 0x46, 0x1d, 0x7f, 0x8b, 0x1a, 0x00, 0xdf, 0xa3, 0x35, 0x18, 0xe7, - 0x26, 0xd0, 0x10, 0x44, 0xb0, 0x94, 0x50, 0x22, 0x4d, 0xa8, 0x2f, 0x64, 0xf5, 0x47, 0x48, 0x13, - 0xaf, 0x44, 0xde, 0x38, 0x8d, 0x7d, 0x5c, 0x8a, 0x7c, 0xea, 0xfd, 0x3e, 0x98, 0xf7, 0x5f, 0x7c, - 0xc2, 0x94, 0xd3, 0x3d, 0x2b, 0xaf, 0x5f, 0x48, 0x14, 0x2c, 0x01, 0xaf, 0xd6, 0xb1, 0xbb, 0x95, - 0xdd, 0x71, 0xc7, 0x66, 0xe6, 0x5e, 0x38, 0x2d, 0x63, 0x83, 0xd8, 0x3c, 0x18, 0x72, 0x9c, 0x67, - 0xd2, 0xfb, 0xa3, 0x77, 0xdd, 0x52, 0xd3, 0xc4, 0xbe, 0x52, 0x82, 0xeb, 0xd5, 0xc6, 0xb7, 0xd7, - 0x1b, 0xdf, 0x7e, 0xdf, 0xf8, 0xf6, 0xf3, 0xd6, 0xb7, 0xd6, 0x5b, 0xdf, 0x7a, 0xd9, 0xfa, 0xd6, - 0xfd, 0x79, 0x32, 0x91, 0x0f, 0xf3, 0x88, 0x70, 0x9c, 0xd1, 0x31, 0xc3, 0x5b, 0xd3, 0x26, 0xaa, - 0xda, 0xf6, 0x64, 0xfa, 0x26, 0x97, 0x39, 0x14, 0x51, 0x4d, 0xd7, 0xe4, 0xea, 0x23, 0x00, 0x00, - 0xff, 0xff, 0xfd, 0x4d, 0x62, 0x21, 0x88, 0x02, 0x00, 0x00, + // 381 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd2, 0xc1, 0xce, 0xd2, 0x40, + 0x10, 0x07, 0xf0, 0xd6, 0xaf, 0xa2, 0x59, 0xd4, 0x90, 0x05, 0x93, 0x4a, 0x4c, 0x25, 0x9a, 0x18, + 0x4e, 0xbb, 0xa2, 0x2f, 0x60, 0x0a, 0x47, 0x63, 0x10, 0xe2, 0xc5, 0x4b, 0xb3, 0xdd, 0x4e, 0x2a, + 0xa1, 0x74, 0x9a, 0xed, 0x22, 0xf0, 0x16, 0x3e, 0x8b, 0x4f, 0xc1, 0x91, 0xa3, 0x27, 0x63, 0xe0, + 0x45, 0xcc, 0xee, 0x52, 0xc5, 0xe8, 0x81, 0xef, 0xd6, 0xee, 0xec, 0xff, 0xb7, 0x93, 0xcc, 0x90, + 0x6e, 0x2d, 0x90, 0x97, 0x98, 0x01, 0xaf, 0x10, 0x0b, 0x56, 0x29, 0xd4, 0x48, 0xcd, 0x61, 0x09, + 0x7a, 0x83, 0x6a, 0xc9, 0x6a, 0x81, 0xcc, 0xd4, 0xfb, 0xbd, 0x1c, 0x73, 0xb4, 0x75, 0x6e, 0xbe, + 0xdc, 0xd5, 0x7e, 0x24, 0xb1, 0x5e, 0x61, 0xcd, 0x53, 0x51, 0x03, 0xff, 0x32, 0x4a, 0x41, 0x8b, + 0x11, 0x97, 0xb8, 0x28, 0x5d, 0xfd, 0xf9, 0xb7, 0x80, 0x04, 0x53, 0xc4, 0x82, 0x4e, 0xc8, 0x43, + 0x8d, 0x5a, 0x14, 0x49, 0x55, 0x40, 0x96, 0x43, 0x16, 0xfa, 0x03, 0x7f, 0xd8, 0x7e, 0xfd, 0x84, + 0x39, 0x80, 0x19, 0x80, 0x9d, 0x01, 0x36, 0xc6, 0x45, 0x19, 0x07, 0xfb, 0x1f, 0xcf, 0xbc, 0xd9, + 0x03, 0x9b, 0x9a, 0xba, 0x10, 0x8d, 0x89, 0xfb, 0x4f, 0x14, 0x6c, 0x84, 0xca, 0xc2, 0x3b, 0xd7, + 0x21, 0x6d, 0x1b, 0x9a, 0xd9, 0x0c, 0xfd, 0x40, 0xba, 0x42, 0xca, 0x73, 0x1f, 0x49, 0x05, 0x2a, + 0x49, 0x77, 0x1a, 0xc2, 0x1b, 0x4b, 0x3d, 0xfd, 0x2f, 0x35, 0x01, 0x79, 0xa1, 0x75, 0x84, 0x94, + 0xae, 0xa1, 0x29, 0xa8, 0x78, 0xa7, 0xa1, 0x21, 0x5d, 0x53, 0x7f, 0xc8, 0xe0, 0x56, 0xa4, 0x6b, + 0xaf, 0x21, 0xdf, 0x91, 0xce, 0x25, 0x57, 0xa0, 0x5c, 0x86, 0x77, 0xaf, 0xf6, 0x1e, 0xa9, 0xdf, + 0x98, 0x49, 0xd2, 0x8f, 0xe4, 0x71, 0x09, 0x5b, 0x9d, 0xfc, 0x43, 0xb6, 0xae, 0x26, 0xa9, 0x01, + 0x66, 0x7f, 0xb3, 0x2f, 0x9a, 0xa1, 0xd6, 0x1a, 0x95, 0xc8, 0x21, 0xbc, 0x37, 0xf0, 0x87, 0x37, + 0xe7, 0x99, 0xcd, 0xdd, 0x19, 0x7d, 0x45, 0x7a, 0xee, 0x59, 0xc8, 0xdc, 0xa3, 0x89, 0xc4, 0x75, + 0xa9, 0xc3, 0xfb, 0xf6, 0x2e, 0x6d, 0x6a, 0x56, 0x1c, 0x9b, 0x4a, 0xfc, 0x76, 0x7f, 0x8c, 0xfc, + 0xc3, 0x31, 0xf2, 0x7f, 0x1e, 0x23, 0xff, 0xeb, 0x29, 0xf2, 0x0e, 0xa7, 0xc8, 0xfb, 0x7e, 0x8a, + 0xbc, 0x4f, 0x2f, 0xf3, 0x85, 0xfe, 0xbc, 0x4e, 0x99, 0xc4, 0x15, 0x9f, 0x0b, 0x7c, 0xef, 0x96, + 0x94, 0x9b, 0x25, 0xde, 0xba, 0x35, 0xd6, 0xbb, 0x0a, 0xea, 0xb4, 0x65, 0xb7, 0xef, 0xcd, 0xaf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xab, 0xdf, 0xe7, 0xdf, 0x02, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -172,13 +181,23 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.RewardedBlockCount != 0 { i = encodeVarintPool(dAtA, i, uint64(m.RewardedBlockCount)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if m.TotalStorage != 0 { i = encodeVarintPool(dAtA, i, uint64(m.TotalStorage)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 + } + { + size, err := m.NextRewardPerBlock.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x32 { size, err := m.RewardPerBlock.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -259,6 +278,8 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovPool(uint64(l)) l = m.RewardPerBlock.Size() n += 1 + l + sovPool(uint64(l)) + l = m.NextRewardPerBlock.Size() + n += 1 + l + sovPool(uint64(l)) if m.TotalStorage != 0 { n += 1 + sovPool(uint64(m.TotalStorage)) } @@ -469,6 +490,39 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextRewardPerBlock", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NextRewardPerBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TotalStorage", wireType) } @@ -487,7 +541,7 @@ func (m *Pool) Unmarshal(dAtA []byte) error { break } } - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RewardedBlockCount", wireType) } From df7d5d4838b242a3783474b02e7624ebceb43fc9 Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Tue, 16 May 2023 12:04:29 +0800 Subject: [PATCH 4/8] feat: expired shard (#49) * add expiredShard type to handle expired shards * shard expired management * expired shards migration --- CHANGELOG.md | 2 +- app/app.go | 1 + docs/static/openapi.yml | 5110 ++++------------- go.mod | 1 - go.sum | 2 - proto/sao/sao/expired_shard.proto | 11 + proto/sao/sao/genesis.proto | 2 + proto/sao/sao/query.proto | 29 + x/market/keeper/pool_management.go | 4 +- x/model/keeper/data_management.go | 2 +- x/model/types/expected_keepers.go | 2 +- x/node/keeper/shard_pledge_management.go | 10 +- x/sao/abci.go | 9 + x/sao/client/cli/query.go | 2 + x/sao/client/cli/query_expired_shard.go | 77 + x/sao/client/cli/query_expired_shard_test.go | 161 + x/sao/genesis.go | 5 + x/sao/genesis_test.go | 9 + x/sao/keeper/expire_management.go | 34 + x/sao/keeper/expired_shard.go | 96 + x/sao/keeper/expired_shard_test.go | 63 + x/sao/keeper/grpc_query_expired_shard.go | 57 + x/sao/keeper/grpc_query_expired_shard_test.go | 126 + x/sao/keeper/keeper.go | 26 +- x/sao/keeper/migrations.go | 18 + x/sao/keeper/msg_server_cancel.go | 2 +- x/sao/keeper/msg_server_complete.go | 5 +- x/sao/migrations/v2/migrations.go | 36 + x/sao/module.go | 8 +- x/sao/types/expected_keepers.go | 4 +- x/sao/types/expired_shard.pb.go | 409 ++ x/sao/types/genesis.go | 11 + x/sao/types/genesis.pb.go | 88 +- x/sao/types/genesis_test.go | 22 + x/sao/types/key_expired_shard.go | 24 + x/sao/types/query.pb.go | 1046 +++- x/sao/types/query.pb.gw.go | 184 + 37 files changed, 3441 insertions(+), 4257 deletions(-) create mode 100644 proto/sao/sao/expired_shard.proto create mode 100644 x/sao/client/cli/query_expired_shard.go create mode 100644 x/sao/client/cli/query_expired_shard_test.go create mode 100644 x/sao/keeper/expire_management.go create mode 100644 x/sao/keeper/expired_shard.go create mode 100644 x/sao/keeper/expired_shard_test.go create mode 100644 x/sao/keeper/grpc_query_expired_shard.go create mode 100644 x/sao/keeper/grpc_query_expired_shard_test.go create mode 100644 x/sao/keeper/migrations.go create mode 100644 x/sao/migrations/v2/migrations.go create mode 100644 x/sao/types/expired_shard.pb.go create mode 100644 x/sao/types/key_expired_shard.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ca8d68..739a6c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - export/import issue ([#44](https://github.com/SAONetwork/sao-consensus/issues/44)) ### Code Refactoring -- shard reord storage duration +- shard record storage duration ([#46](https://github.com/SAONetwork/sao-consensus/issues/46)) diff --git a/app/app.go b/app/app.go index 5b14eda5..d53eba14 100644 --- a/app/app.go +++ b/app/app.go @@ -599,6 +599,7 @@ func New( app.StakingKeeper, appCodec, keys[saomoduletypes.StoreKey], + keys[ordermoduletypes.StoreKey], keys[saomoduletypes.MemStoreKey], app.GetSubspace(saomoduletypes.ModuleName), ) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index ce031642..273dc522 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -471,6 +471,7 @@ paths: type: object properties: account: + description: account defines the account of the corresponding address. type: object properties: '@type': @@ -531,117 +532,217 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a + description: >- + QueryAccountResponse is the response type for the Query/Account + RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized - URL that describes the type of the serialized message. + protocol buffer message. This string must contain at + least + one "/" character. The last segment of the URL's path + must represent - Protobuf library provides support to pack/unpack Any values in - the form + the fully qualified name of the type (as in - of utility functions or additional generated methods of the - Any type. + `path/google.protobuf.Duration`). The name should be in + a canonical form + (e.g., leading "." is not accepted). - Example 1: Pack and unpack a message in C++. - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); ... - } + if (any.UnpackTo(&foo)) { + ... + } - Example 2: Pack and unpack a message in Java. + Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } - Example 3: Pack and unpack a message in Python. + Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) + foo = Foo(...) + any = Any() + any.Pack(foo) ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - Example 4: Pack and unpack a message in Go + Example 4: Pack and unpack a message in Go - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } ... - } + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - The pack methods provided by protobuf library will by default - use + The pack methods provided by protobuf library will by + default use - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + 'type.googleapis.com/full.type.name' as the type URL and the + unpack - methods only use the fully qualified type name after the last - '/' + methods only use the fully qualified type name after the + last '/' - in the type URL, for example "foo.bar.com/x/y.z" will yield - type + in the type URL, for example "foo.bar.com/x/y.z" will yield + type - name "y.z". + name "y.z". - JSON + JSON - ==== + ==== - The JSON representation of an `Any` value uses the regular + The JSON representation of an `Any` value uses the regular - representation of the deserialized, embedded message, with an + representation of the deserialized, embedded message, with + an - additional field `@type` which contains the type URL. Example: + additional field `@type` which contains the type URL. + Example: - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - If the embedded message type is well-known and has a custom - JSON + If the embedded message type is well-known and has a custom + JSON - representation, that representation will be embedded adding a - field + representation, that representation will be embedded adding + a field - `value` which holds the custom JSON in addition to the `@type` + `value` which holds the custom JSON in addition to the + `@type` - field. Example (for message [google.protobuf.Duration][]): + field. Example (for message [google.protobuf.Duration][]): - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: >- - QueryAccountResponse is the response type for the Query/Account - RPC method. + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: address + description: address defines the address to query for. + in: path + required: true + type: string + tags: + - Query + /cosmos/auth/v1beta1/address_by_id/{id}: + get: + summary: AccountAddressByID returns account address based on account id + operationId: CosmosAuthV1Beta1AccountAddressByID + responses: + '200': + description: A successful response. + schema: + type: object + properties: + account_address: + type: string + title: >- + QueryAccountAddressByIDResponse is the response type for + AccountAddressByID rpc method default: description: An unexpected error response. schema: @@ -828,28 +929,32 @@ paths: "value": "1.212s" } parameters: - - name: address - description: address defines the address to query for. + - name: id in: path required: true type: string + format: int64 tags: - Query - /cosmos/auth/v1beta1/address_by_id/{id}: + /cosmos/auth/v1beta1/bech32: get: - summary: AccountAddressByID returns account address based on account id - operationId: CosmosAuthV1Beta1AccountAddressByID + summary: Bech32Prefix queries bech32Prefix + description: 'Since: cosmos-sdk 0.46' + operationId: CosmosAuthV1Beta1Bech32Prefix responses: '200': description: A successful response. schema: type: object properties: - account_address: + bech32_prefix: type: string - title: >- - QueryAccountAddressByIDResponse is the response type for - AccountAddressByID rpc method + description: >- + Bech32PrefixResponse is the response type for Bech32Prefix rpc + method. + + + Since: cosmos-sdk 0.46 default: description: An unexpected error response. schema: @@ -1035,236 +1140,24 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - parameters: - - name: id - in: path - required: true - type: string - format: int64 tags: - Query - /cosmos/auth/v1beta1/bech32: + /cosmos/auth/v1beta1/bech32/{address_bytes}: get: - summary: Bech32Prefix queries bech32Prefix + summary: AddressBytesToString converts Account Address bytes to string description: 'Since: cosmos-sdk 0.46' - operationId: CosmosAuthV1Beta1Bech32Prefix + operationId: CosmosAuthV1Beta1AddressBytesToString responses: '200': description: A successful response. schema: type: object properties: - bech32_prefix: + address_string: type: string description: >- - Bech32PrefixResponse is the response type for Bech32Prefix rpc - method. - - - Since: cosmos-sdk 0.46 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - tags: - - Query - /cosmos/auth/v1beta1/bech32/{address_bytes}: - get: - summary: AddressBytesToString converts Account Address bytes to string - description: 'Since: cosmos-sdk 0.46' - operationId: CosmosAuthV1Beta1AddressBytesToString - responses: - '200': - description: A successful response. - schema: - type: object - properties: - address_string: - type: string - description: >- - AddressBytesToStringResponse is the response type for - AddressString rpc method. + AddressBytesToStringResponse is the response type for + AddressString rpc method. Since: cosmos-sdk 0.46 @@ -3852,20 +3745,13 @@ paths: type: object properties: balance: + description: balance is the balance of the coin. type: object properties: denom: type: string amount: type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. description: >- QueryBalanceResponse is the response type for the Query/Balance RPC method. @@ -3926,20 +3812,15 @@ paths: address defines the address that owns a particular denomination. balance: + description: >- + balance is the balance of the denominated coin for an + account. type: object properties: denom: type: string amount: type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. description: >- DenomOwner defines structure representing an account that owns or holds a @@ -4278,6 +4159,9 @@ paths: type: object properties: metadata: + description: >- + metadata describes and provides all the client information for + the requested token. type: object properties: description: @@ -4363,9 +4247,6 @@ paths: Since: cosmos-sdk 0.46 - description: |- - Metadata represents a struct that describes - a basic token. description: >- QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC @@ -4733,20 +4614,13 @@ paths: type: object properties: amount: + description: amount is the supply of the coin. type: object properties: denom: type: string amount: type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. description: >- QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. @@ -10297,6 +10171,7 @@ paths: type: object properties: evidence: + description: evidence returns the requested evidence. type: object properties: '@type': @@ -10357,114 +10232,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- QueryEvidenceResponse is the response type for the Query/Evidence RPC method. @@ -13337,6 +13104,7 @@ paths: type: object properties: deposit: + description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -13361,11 +13129,6 @@ paths: custom method signatures required by gogoproto. - description: >- - Deposit defines an amount deposited by an account address to - an active - - proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -14129,6 +13892,7 @@ paths: type: object properties: vote: + description: vote defined the queried vote. type: object properties: proposal_id: @@ -14169,11 +13933,6 @@ paths: description: >- metadata is any arbitrary metadata to attached to the vote. - description: >- - Vote defines a vote on a governance proposal. - - A Vote consists of a proposal ID, the voter, and the vote - option. description: >- QueryVoteResponse is the response type for the Query/Vote RPC method. @@ -16009,6 +15768,7 @@ paths: type: object properties: deposit: + description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -16033,11 +15793,6 @@ paths: custom method signatures required by gogoproto. - description: >- - Deposit defines an amount deposited by an account address to - an active - - proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -16818,6 +16573,7 @@ paths: type: object properties: vote: + description: vote defined the queried vote. type: object properties: proposal_id: @@ -16875,11 +16631,6 @@ paths: Since: cosmos-sdk 0.43 title: 'Since: cosmos-sdk 0.43' - description: >- - Vote defines a vote on a governance proposal. - - A Vote consists of a proposal ID, the voter, and the vote - option. description: >- QueryVoteResponse is the response type for the Query/Vote RPC method. @@ -17684,6 +17435,9 @@ paths: would create a different result on a running proposal. decision_policy: + description: >- + decision_policy specifies the group policy's decision + policy. type: object properties: '@type': @@ -17745,119 +17499,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the - regular - - representation of the deserialized, embedded message, - with an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message - [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time @@ -18180,6 +17821,9 @@ paths: would create a different result on a running proposal. decision_policy: + description: >- + decision_policy specifies the group policy's decision + policy. type: object properties: '@type': @@ -18241,119 +17885,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the - regular - - representation of the deserialized, embedded message, - with an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message - [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time @@ -18651,6 +18182,7 @@ paths: type: object properties: info: + description: info is the GroupPolicyInfo for the group policy. type: object properties: address: @@ -18677,6 +18209,9 @@ paths: would create a different result on a running proposal. decision_policy: + description: >- + decision_policy specifies the group policy's decision + policy. type: object properties: '@type': @@ -18738,126 +18273,12 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time description: >- created_at is a timestamp specifying when a group policy was created. - description: >- - GroupPolicyInfo represents the high-level on-chain information - for a group policy. description: >- QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. @@ -22303,6 +21724,9 @@ paths: uri_hash is a hash of the document pointed by uri. Optional data: + title: >- + data is the app specific metadata of the NFT class. + Optional type: object properties: '@type': @@ -22477,9 +21901,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: >- - data is the app specific metadata of the NFT class. - Optional description: Class defines the class of the nft type. pagination: type: object @@ -22800,6 +22221,9 @@ paths: uri_hash is a hash of the document pointed by uri. Optional data: + title: >- + data is the app specific metadata of the NFT class. + Optional type: object properties: '@type': @@ -22972,9 +22396,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: >- - data is the app specific metadata of the NFT class. - Optional description: Class defines the class of the nft type. title: >- QueryClassResponse is the response type for the Query/Class RPC @@ -23205,6 +22626,7 @@ paths: type: string title: uri_hash is a hash of the document pointed by uri data: + title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -23379,7 +22801,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. pagination: type: object @@ -23692,6 +23113,7 @@ paths: type: string title: uri_hash is a hash of the document pointed by uri data: + title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -23864,7 +23286,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. title: QueryNFTResponse is the response type for the Query/NFT RPC method default: @@ -24839,6 +24260,9 @@ paths: type: object properties: val_signing_info: + title: >- + val_signing_info is the signing info of requested val cons + address type: object properties: address: @@ -24888,9 +24312,6 @@ paths: monitoring their liveness activity. - title: >- - val_signing_info is the signing info of requested val cons - address title: >- QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC @@ -26031,6 +25452,9 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -26092,119 +25516,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the - regular - - representation of the deserialized, embedded message, - with an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message - [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -26618,6 +25929,7 @@ paths: type: object properties: validator: + description: validator defines the validator info. type: object properties: operator_address: @@ -26626,6 +25938,9 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -26687,117 +26002,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -26902,29 +26106,6 @@ paths: Since: cosmos-sdk 0.46 - description: >- - Validator defines a validator, together with the total amount - of the - - Validator's bond shares and their exchange rate to coins. - Slashing results in - - a decrease in the exchange rate, allowing correct calculation - of future - - undelegations without iterating over delegators. When coins - are delegated to - - this validator, the validator is credited with a delegation - whose number of - - bond shares is based on the amount of coins delegated divided - by the current - - exchange rate. Voting power can be calculated as total bonded - shares - - multiplied by exchange rate. description: |- QueryDelegatorValidatorResponse response type for the Query/DelegatorValidator RPC method. @@ -27239,6 +26420,9 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -27300,120 +26484,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol - buffer message along with a - - URL that describes the type of the serialized - message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods - of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will - by default use - - 'type.googleapis.com/full.type.name' as the type URL - and the unpack - - methods only use the fully qualified type name after - the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" - will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the - regular - - representation of the deserialized, embedded - message, with an - - additional field `@type` which contains the type - URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to - the `@type` - - field. Example (for message - [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -28200,6 +27270,9 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -28261,119 +27334,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the - regular - - representation of the deserialized, embedded message, - with an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message - [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -28785,6 +27745,7 @@ paths: type: object properties: validator: + description: validator defines the validator info. type: object properties: operator_address: @@ -28793,6 +27754,9 @@ paths: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -28854,117 +27818,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -29069,29 +27922,6 @@ paths: Since: cosmos-sdk 0.46 - description: >- - Validator defines a validator, together with the total amount - of the - - Validator's bond shares and their exchange rate to coins. - Slashing results in - - a decrease in the exchange rate, allowing correct calculation - of future - - undelegations without iterating over delegators. When coins - are delegated to - - this validator, the validator is credited with a delegation - whose number of - - bond shares is based on the amount of coins delegated divided - by the current - - exchange rate. Voting power can be calculated as total bonded - shares - - multiplied by exchange rate. title: >- QueryValidatorResponse is response type for the Query/Validator RPC method @@ -29630,6 +28460,9 @@ paths: type: object properties: delegation_response: + description: >- + delegation_responses defines the delegation info of a + delegation. type: object properties: delegation: @@ -29671,12 +28504,6 @@ paths: custom method signatures required by gogoproto. - description: >- - DelegationResponse is equivalent to Delegation except that it - contains a - - balance in addition to shares which is more suitable for - client responses. description: >- QueryDelegationResponse is response type for the Query/Delegation RPC method. @@ -29891,6 +28718,7 @@ paths: type: object properties: unbond: + description: unbond defines the unbonding information of a delegation. type: object properties: delegator_address: @@ -29935,11 +28763,6 @@ paths: entries are the unbonding delegation entries. unbonding delegation entries - description: >- - UnbondingDelegation stores all of a single delegator's - unbonding bonds - - for a single validator in an time-ordered list. description: >- QueryDelegationResponse is response type for the Query/UnbondingDelegation @@ -31250,6 +30073,7 @@ paths: type: object properties: tx_response: + description: tx_response is the queried TxResponses. type: object properties: height: @@ -31336,6 +30160,7 @@ paths: format: int64 description: Amount of gas consumed by transaction. tx: + description: The request transaction bytes. type: object properties: '@type': @@ -31397,117 +30222,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } timestamp: type: string description: >- @@ -31565,11 +30279,6 @@ paths: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 - description: >- - TxResponse defines a structure containing relevant tx data and - metadata. The - - tags are stringified and the log is JSON decoded. description: |- BroadcastTxResponse is the response type for the Service.BroadcastTx method. @@ -32737,6 +31446,13 @@ paths: such as a git commit that validators could automatically upgrade to upgraded_client_state: + description: >- + Deprecated: UpgradedClientState field has been deprecated. + IBC upgrade logic has been + + moved to the IBC module in the sub module 02-client. + + If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -32798,117 +31514,6 @@ paths: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and - the unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will - yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC @@ -34387,6 +32992,9 @@ paths: type: object properties: denom_trace: + description: >- + denom_trace returns the requested denomination trace + information. type: object properties: path: @@ -34399,11 +33007,6 @@ paths: base_denom: type: string description: base denomination of the relayed fungible token. - description: >- - DenomTrace contains the base denomination for ICS20 fungible - tokens and the - - source tracing information path. description: >- QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC @@ -35562,6 +34165,7 @@ paths: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -35734,7 +34338,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -35987,6 +34590,7 @@ paths: type: object properties: consensus_state: + title: consensus state associated with the channel type: object properties: '@type': @@ -36155,7 +34759,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -39311,6 +37914,7 @@ paths: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -39485,7 +38089,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -39781,6 +38384,7 @@ paths: type: object properties: client_state: + title: client state associated with the request identifier type: object properties: '@type': @@ -39949,7 +38553,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier proof: type: string format: byte @@ -40441,6 +39044,7 @@ paths: gets reset consensus_state: + title: consensus state type: object properties: '@type': @@ -40615,7 +39219,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -41249,6 +39852,9 @@ paths: type: object properties: consensus_state: + title: >- + consensus state associated with the client identifier at the + given height type: object properties: '@type': @@ -41417,14 +40023,12 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: >- - consensus state associated with the client identifier at the - given height proof: type: string format: byte title: merkle proof of existence proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -41452,13 +40056,6 @@ paths: RevisionHeight gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState @@ -41689,6 +40286,7 @@ paths: type: object properties: upgraded_client_state: + title: client state associated with the request identifier type: object properties: '@type': @@ -41857,7 +40455,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier description: |- QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC method. @@ -42059,6 +40656,7 @@ paths: type: object properties: upgraded_consensus_state: + title: Consensus state associated with the request identifier type: object properties: '@type': @@ -42227,7 +40825,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: Consensus state associated with the request identifier description: |- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState RPC method. @@ -43425,6 +42022,7 @@ paths: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -43597,7 +42195,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -43845,6 +42442,7 @@ paths: type: object properties: consensus_state: + title: consensus state associated with the channel type: object properties: '@type': @@ -44013,7 +42611,6 @@ paths: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -47289,6 +45886,22 @@ paths: amount. + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. + next_reward_per_block: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + NOTE: The amount field is an Dec which implements the custom method @@ -47390,6 +46003,22 @@ paths: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a + decimal amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. pagination: type: object properties: @@ -47584,6 +46213,12 @@ paths: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 amount: type: object properties: @@ -47615,6 +46250,22 @@ paths: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the + custom method + + signatures required by gogoproto. default: description: An unexpected error response. schema: @@ -47725,6 +46376,218 @@ paths: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /SaoNetwork/sao/order/shard/{id}: + get: + summary: Queries a Shard by id. + operationId: SaonetworkSaoOrderShard + responses: + '200': + description: A successful response. + schema: + type: object + properties: + Shard: + type: object + properties: + id: + type: string + format: uint64 + orderId: + type: string + format: uint64 + status: + type: integer + format: int32 + size: + type: string + format: uint64 + cid: + type: string + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + from: + type: string + sp: + type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: id + in: path + required: true + type: string + format: uint64 + tags: + - Query + /SaoNetwork/sao/sao/expired_shard: + get: + summary: Queries a list of ExpiredShard items. + operationId: SaonetworkSaoSaoExpiredShardAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + expiredShard: + type: array + items: + type: object + properties: + height: + type: string + format: uint64 + shardList: + type: array + items: + type: string + format: uint64 pagination: type: object properties: @@ -47830,52 +46693,27 @@ paths: type: boolean tags: - Query - /SaoNetwork/sao/order/shard/{id}: + /SaoNetwork/sao/sao/expired_shard/{height}: get: - summary: Queries a Shard by id. - operationId: SaonetworkSaoOrderShard + summary: Queries a ExpiredShard by index. + operationId: SaonetworkSaoSaoExpiredShard responses: '200': description: A successful response. schema: type: object properties: - Shard: + expiredShard: type: object properties: - id: - type: string - format: uint64 - orderId: - type: string - format: uint64 - status: - type: integer - format: int32 - size: + height: type: string format: uint64 - cid: - type: string - pledge: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - from: - type: string - sp: - type: string + shardList: + type: array + items: + type: string + format: uint64 default: description: An unexpected error response. schema: @@ -47895,7 +46733,7 @@ paths: type: string additionalProperties: {} parameters: - - name: id + - name: height in: path required: true type: string @@ -48372,6 +47210,7 @@ definitions: type: object properties: account: + description: account defines the account of the corresponding address. type: object properties: '@type': @@ -48427,107 +47266,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- QueryAccountResponse is the response type for the Query/Account RPC method. @@ -50315,17 +49053,13 @@ definitions: type: string description: address defines the address that owns a particular denomination. balance: + description: balance is the balance of the denominated coin for an account. type: object properties: denom: type: string amount: type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. description: |- DenomOwner defines structure representing an account that owns or holds a particular denominated token. It contains the account address and account @@ -50556,17 +49290,13 @@ definitions: type: object properties: balance: + description: balance is the balance of the coin. type: object properties: denom: type: string amount: type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. description: >- QueryBalanceResponse is the response type for the Query/Balance RPC method. @@ -50574,6 +49304,9 @@ definitions: type: object properties: metadata: + description: >- + metadata describes and provides all the client information for the + requested token. type: object properties: description: @@ -50654,9 +49387,6 @@ definitions: Since: cosmos-sdk 0.46 - description: |- - Metadata represents a struct that describes - a basic token. description: >- QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC @@ -50674,20 +49404,13 @@ definitions: type: string description: address defines the address that owns a particular denomination. balance: + description: balance is the balance of the denominated coin for an account. type: object properties: denom: type: string amount: type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. description: >- DenomOwner defines structure representing an account that owns or holds a @@ -50915,17 +49638,13 @@ definitions: type: object properties: amount: + description: amount is the supply of the coin. type: object properties: denom: type: string amount: type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. description: >- QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. @@ -57845,6 +56564,7 @@ definitions: type: object properties: evidence: + description: evidence returns the requested evidence. type: object properties: '@type': @@ -57900,107 +56620,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- QueryEvidenceResponse is the response type for the Query/Evidence RPC method. @@ -58713,6 +57332,7 @@ definitions: type: object properties: deposit: + description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -58737,9 +57357,6 @@ definitions: method signatures required by gogoproto. - description: |- - Deposit defines an amount deposited by an account address to an active - proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -59418,6 +58035,7 @@ definitions: type: object properties: vote: + description: vote defined the queried vote. type: object properties: proposal_id: @@ -59454,9 +58072,6 @@ definitions: metadata: type: string description: metadata is any arbitrary metadata to attached to the vote. - description: |- - Vote defines a vote on a governance proposal. - A Vote consists of a proposal ID, the voter, and the vote option. description: QueryVoteResponse is the response type for the Query/Vote RPC method. cosmos.gov.v1.QueryVotesResponse: type: object @@ -59970,6 +58585,7 @@ definitions: type: object properties: deposit: + description: deposit defines the requested deposit. type: object properties: proposal_id: @@ -59994,9 +58610,6 @@ definitions: method signatures required by gogoproto. - description: |- - Deposit defines an amount deposited by an account address to an active - proposal. description: >- QueryDepositResponse is the response type for the Query/Deposit RPC method. @@ -60662,6 +59275,7 @@ definitions: type: object properties: vote: + description: vote defined the queried vote. type: object properties: proposal_id: @@ -60716,9 +59330,6 @@ definitions: Since: cosmos-sdk 0.43 title: 'Since: cosmos-sdk 0.43' - description: |- - Vote defines a vote on a governance proposal. - A Vote consists of a proposal ID, the voter, and the vote option. description: QueryVoteResponse is the response type for the Query/Vote RPC method. cosmos.gov.v1beta1.QueryVotesResponse: type: object @@ -61049,6 +59660,7 @@ definitions: would create a different result on a running proposal. decision_policy: + description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -61104,107 +59716,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time @@ -61776,6 +60287,7 @@ definitions: would create a different result on a running proposal. decision_policy: + description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -61836,112 +60348,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time @@ -62006,6 +60412,7 @@ definitions: would create a different result on a running proposal. decision_policy: + description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -62066,112 +60473,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time @@ -62210,6 +60511,7 @@ definitions: type: object properties: info: + description: info is the GroupPolicyInfo for the group policy. type: object properties: address: @@ -62236,6 +60538,7 @@ definitions: would create a different result on a running proposal. decision_policy: + description: decision_policy specifies the group policy's decision policy. type: object properties: '@type': @@ -62294,119 +60597,12 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } created_at: type: string format: date-time description: >- created_at is a timestamp specifying when a group policy was created. - description: >- - GroupPolicyInfo represents the high-level on-chain information for a - group policy. description: QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. cosmos.group.v1.QueryGroupsByAdminResponse: type: object @@ -63471,185 +61667,7 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } title: data is the app specific metadata of the NFT class. Optional - description: Class defines the class of the nft type. - cosmos.nft.v1beta1.MsgSendResponse: - type: object - description: MsgSendResponse defines the Msg/Send response type. - cosmos.nft.v1beta1.NFT: - type: object - properties: - class_id: - type: string - title: >- - class_id associated with the NFT, similar to the contract address of - ERC721 - id: - type: string - title: id is a unique identifier of the NFT - uri: - type: string - title: uri for the NFT metadata stored off chain - uri_hash: - type: string - title: uri_hash is a hash of the document pointed by uri - data: type: object properties: '@type': @@ -63806,7 +61824,185 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } + description: Class defines the class of the nft type. + cosmos.nft.v1beta1.MsgSendResponse: + type: object + description: MsgSendResponse defines the Msg/Send response type. + cosmos.nft.v1beta1.NFT: + type: object + properties: + class_id: + type: string + title: >- + class_id associated with the NFT, similar to the contract address of + ERC721 + id: + type: string + title: id is a unique identifier of the NFT + uri: + type: string + title: uri for the NFT metadata stored off chain + uri_hash: + type: string + title: uri_hash is a hash of the document pointed by uri + data: title: data is an app specific data of the NFT. Optional + type: object + properties: + '@type': + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + + protocol buffer message. This string must contain at least + + one "/" character. The last segment of the URL's path must + represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in a + canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary all types + that they + + expect it to use in the context of Any. However, for URLs which + use the + + scheme `http`, `https`, or no scheme, one can optionally set up a + type + + server that maps type URLs to message definitions as follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the + official + + protobuf release, and it is not used for type URLs beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) might be + + used with implementation specific semantics. + additionalProperties: {} + description: >- + `Any` contains an arbitrary serialized protocol buffer message along + with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values in the + form + + of utility functions or additional generated methods of the Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by default use + + 'type.googleapis.com/full.type.name' as the type URL and the unpack + + methods only use the fully qualified type name after the last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with an + + additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom JSON + + representation, that representation will be embedded adding a field + + `value` which holds the custom JSON in addition to the `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } description: NFT defines the NFT. cosmos.nft.v1beta1.QueryBalanceResponse: type: object @@ -63846,6 +62042,7 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: + title: data is the app specific metadata of the NFT class. Optional type: object properties: '@type': @@ -64008,7 +62205,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is the app specific metadata of the NFT class. Optional description: Class defines the class of the nft type. title: QueryClassResponse is the response type for the Query/Class RPC method cosmos.nft.v1beta1.QueryClassesResponse: @@ -64046,6 +62242,7 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri. Optional data: + title: data is the app specific metadata of the NFT class. Optional type: object properties: '@type': @@ -64212,7 +62409,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is the app specific metadata of the NFT class. Optional description: Class defines the class of the nft type. pagination: type: object @@ -64262,6 +62458,7 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri data: + title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -64424,7 +62621,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. title: QueryNFTResponse is the response type for the Query/NFT RPC method cosmos.nft.v1beta1.QueryNFTsResponse: @@ -64450,6 +62646,7 @@ definitions: type: string title: uri_hash is a hash of the document pointed by uri data: + title: data is an app specific data of the NFT. Optional type: object properties: '@type': @@ -64616,7 +62813,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: data is an app specific data of the NFT. Optional description: NFT defines the NFT. pagination: type: object @@ -64772,6 +62968,7 @@ definitions: type: object properties: val_signing_info: + title: val_signing_info is the signing info of requested val cons address type: object properties: address: @@ -64818,7 +63015,6 @@ definitions: their liveness activity. - title: val_signing_info is the signing info of requested val cons address title: >- QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC @@ -65189,6 +63385,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, + as a Protobuf Any. type: object properties: '@type': @@ -65249,112 +63448,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -65552,6 +63645,7 @@ definitions: type: object properties: delegation_response: + description: delegation_responses defines the delegation info of a delegation. type: object properties: delegation: @@ -65593,12 +63687,6 @@ definitions: method signatures required by gogoproto. - description: >- - DelegationResponse is equivalent to Delegation except that it contains - a - - balance in addition to shares which is more suitable for client - responses. description: >- QueryDelegationResponse is response type for the Query/Delegation RPC method. @@ -65757,6 +63845,7 @@ definitions: type: object properties: validator: + description: validator defines the validator info. type: object properties: operator_address: @@ -65765,6 +63854,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, as + a Protobuf Any. type: object properties: '@type': @@ -65823,110 +63915,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -66021,27 +64009,6 @@ definitions: Since: cosmos-sdk 0.46 - description: >- - Validator defines a validator, together with the total amount of the - - Validator's bond shares and their exchange rate to coins. Slashing - results in - - a decrease in the exchange rate, allowing correct calculation of - future - - undelegations without iterating over delegators. When coins are - delegated to - - this validator, the validator is credited with a delegation whose - number of - - bond shares is based on the amount of coins delegated divided by the - current - - exchange rate. Voting power can be calculated as total bonded shares - - multiplied by exchange rate. description: |- QueryDelegatorValidatorResponse response type for the Query/DelegatorValidator RPC method. @@ -66059,6 +64026,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, + as a Protobuf Any. type: object properties: '@type': @@ -66119,112 +64089,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -66469,6 +64333,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the + validator, as a Protobuf Any. type: object properties: '@type': @@ -66530,117 +64397,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -66955,6 +64711,7 @@ definitions: type: object properties: unbond: + description: unbond defines the unbonding information of a delegation. type: object properties: delegator_address: @@ -66993,9 +64750,6 @@ definitions: entries are the unbonding delegation entries. unbonding delegation entries - description: |- - UnbondingDelegation stores all of a single delegator's unbonding bonds - for a single validator in an time-ordered list. description: |- QueryDelegationResponse is response type for the Query/UnbondingDelegation RPC method. @@ -67078,6 +64832,7 @@ definitions: type: object properties: validator: + description: validator defines the validator info. type: object properties: operator_address: @@ -67086,6 +64841,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, as + a Protobuf Any. type: object properties: '@type': @@ -67144,110 +64902,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -67342,27 +64996,6 @@ definitions: Since: cosmos-sdk 0.46 - description: >- - Validator defines a validator, together with the total amount of the - - Validator's bond shares and their exchange rate to coins. Slashing - results in - - a decrease in the exchange rate, allowing correct calculation of - future - - undelegations without iterating over delegators. When coins are - delegated to - - this validator, the validator is credited with a delegation whose - number of - - bond shares is based on the amount of coins delegated divided by the - current - - exchange rate. Voting power can be calculated as total bonded shares - - multiplied by exchange rate. title: QueryValidatorResponse is response type for the Query/Validator RPC method cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse: type: object @@ -67453,6 +65086,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, + as a Protobuf Any. type: object properties: '@type': @@ -67513,112 +65149,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -68052,6 +65582,9 @@ definitions: operator_address defines the address of the validator's operator; bech encoded in JSON. consensus_pubkey: + description: >- + consensus_pubkey is the consensus public key of the validator, as a + Protobuf Any. type: object properties: '@type': @@ -68107,107 +65640,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } jailed: type: boolean description: >- @@ -68708,6 +66140,7 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: + description: The request transaction bytes. type: object properties: '@type': @@ -68763,107 +66196,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } timestamp: type: string description: >- @@ -68989,6 +66321,7 @@ definitions: signer_infos: type: array items: + type: object $ref: '#/definitions/cosmos.tx.v1beta1.SignerInfo' description: >- signer_infos defines the signing modes for the required signers. The @@ -69152,6 +66485,7 @@ definitions: type: object properties: tx_response: + description: tx_response is the queried TxResponses. type: object properties: height: @@ -69236,6 +66570,7 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: + description: The request transaction bytes. type: object properties: '@type': @@ -69294,110 +66629,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } timestamp: type: string description: >- @@ -69453,11 +66684,6 @@ definitions: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 - description: >- - TxResponse defines a structure containing relevant tx data and - metadata. The - - tags are stringified and the log is JSON decoded. description: |- BroadcastTxResponse is the response type for the Service.BroadcastTx method. @@ -69521,6 +66747,7 @@ definitions: txs: type: array items: + type: object $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: txs are the transactions in the block. block_id: @@ -70124,6 +67351,7 @@ definitions: $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: tx is the queried transaction. tx_response: + description: tx_response is the queried TxResponses. type: object properties: height: @@ -70208,6 +67436,7 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: + description: The request transaction bytes. type: object properties: '@type': @@ -70266,110 +67495,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } timestamp: type: string description: >- @@ -70425,11 +67550,6 @@ definitions: Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 - description: >- - TxResponse defines a structure containing relevant tx data and - metadata. The - - tags are stringified and the log is JSON decoded. description: GetTxResponse is the response type for the Service.GetTx method. cosmos.tx.v1beta1.GetTxsEventResponse: type: object @@ -70437,6 +67557,7 @@ definitions: txs: type: array items: + type: object $ref: '#/definitions/cosmos.tx.v1beta1.Tx' description: txs is the list of queried transactions. tx_responses: @@ -70526,6 +67647,7 @@ definitions: format: int64 description: Amount of gas consumed by transaction. tx: + description: The request transaction bytes. type: object properties: '@type': @@ -70586,112 +67708,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default - use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last - '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } timestamp: type: string description: >- @@ -70886,6 +67902,7 @@ definitions: mode_infos: type: array items: + type: object $ref: '#/definitions/cosmos.tx.v1beta1.ModeInfo' title: |- mode_infos is the corresponding modes of the signers of the multisig @@ -70981,6 +67998,14 @@ definitions: type: object properties: public_key: + description: >- + public_key is the public key of the signer. It is optional for + accounts + + that already exist in state. If unset, the verifier can use the + required \ + + signer address for this position and lookup the public key. type: object properties: '@type': @@ -71036,107 +68061,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } mode_info: $ref: '#/definitions/cosmos.tx.v1beta1.ModeInfo' title: |- @@ -72685,6 +69609,13 @@ definitions: Any application specific upgrade info to be included on-chain such as a git commit that validators could automatically upgrade to upgraded_client_state: + description: >- + Deprecated: UpgradedClientState field has been deprecated. IBC upgrade + logic has been + + moved to the IBC module in the sub module 02-client. + + If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -72740,107 +69671,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- Plan specifies information about a planned upgrade and when it should occur. @@ -72916,6 +69746,13 @@ definitions: such as a git commit that validators could automatically upgrade to upgraded_client_state: + description: >- + Deprecated: UpgradedClientState field has been deprecated. IBC + upgrade logic has been + + moved to the IBC module in the sub module 02-client. + + If this field is not empty, an error will be thrown. type: object properties: '@type': @@ -72974,110 +69811,6 @@ definitions: used with implementation specific semantics. additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } description: >- QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC @@ -73283,6 +70016,7 @@ definitions: type: object properties: denom_trace: + description: denom_trace returns the requested denomination trace information. type: object properties: path: @@ -73295,11 +70029,6 @@ definitions: base_denom: type: string description: base denomination of the relayed fungible token. - description: >- - DenomTrace contains the base denomination for ICS20 fungible tokens - and the - - source tracing information path. description: |- QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC method. @@ -73766,6 +70495,7 @@ definitions: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -73928,7 +70658,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -73971,6 +70700,7 @@ definitions: type: object properties: consensus_state: + title: consensus state associated with the channel type: object properties: '@type': @@ -74127,7 +70857,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -75024,6 +71753,7 @@ definitions: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -75180,7 +71910,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -75216,6 +71945,7 @@ definitions: gets reset consensus_state: + title: consensus state type: object properties: '@type': @@ -75372,7 +72102,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -75422,6 +72151,7 @@ definitions: type: object properties: client_state: + title: client state associated with the request identifier type: object properties: '@type': @@ -75578,7 +72308,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier proof: type: string format: byte @@ -75630,6 +72359,7 @@ definitions: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -75796,7 +72526,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: >- IdentifiedClientState defines a client state with an additional client @@ -75920,6 +72649,9 @@ definitions: type: object properties: consensus_state: + title: >- + consensus state associated with the client identifier at the given + height type: object properties: '@type': @@ -76076,14 +72808,12 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: >- - consensus state associated with the client identifier at the given - height proof: type: string format: byte title: merkle proof of existence proof_height: + title: height at which the proof was retrieved type: object properties: revision_number: @@ -76110,13 +72840,6 @@ definitions: RevisionHeight gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients title: >- QueryConsensusStateResponse is the response type for the Query/ConsensusState @@ -76160,6 +72883,7 @@ definitions: gets reset consensus_state: + title: consensus state type: object properties: '@type': @@ -76326,7 +73050,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state description: >- ConsensusStateWithHeight defines a consensus state with an additional height @@ -76367,6 +73090,7 @@ definitions: type: object properties: upgraded_client_state: + title: client state associated with the request identifier type: object properties: '@type': @@ -76523,7 +73247,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state associated with the request identifier description: |- QueryUpgradedClientStateResponse is the response type for the Query/UpgradedClientState RPC method. @@ -76531,6 +73254,7 @@ definitions: type: object properties: upgraded_consensus_state: + title: Consensus state associated with the request identifier type: object properties: '@type': @@ -76687,7 +73411,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: Consensus state associated with the request identifier description: |- QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState RPC method. @@ -76974,6 +73697,7 @@ definitions: type: string title: client identifier client_state: + title: client state type: object properties: '@type': @@ -77136,7 +73860,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: client state description: |- IdentifiedClientState defines a client state with an additional client identifier field. @@ -77179,6 +73902,7 @@ definitions: type: object properties: consensus_state: + title: consensus state associated with the channel type: object properties: '@type': @@ -77335,7 +74059,6 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - title: consensus state associated with the channel client_id: type: string title: client ID associated with the consensus state @@ -78922,6 +75645,18 @@ definitions: NOTE: The amount field is an Dec which implements the custom method signatures required by gogoproto. + next_reward_per_block: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. total_storage: type: string format: int64 @@ -79247,6 +75982,21 @@ definitions: DecCoin defines a token with a denomination and a decimal amount. + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. + next_reward_per_block: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method @@ -79363,6 +76113,12 @@ definitions: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 amount: type: object properties: @@ -79391,6 +76147,18 @@ definitions: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. saonetwork.sao.order.Order: type: object properties: @@ -79447,6 +76215,18 @@ definitions: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + DecCoin defines a token with a denomination and a decimal amount. + + NOTE: The amount field is an Dec which implements the custom method + signatures required by gogoproto. saonetwork.sao.order.Params: type: object description: Params defines the parameters for the module. @@ -79514,6 +76294,22 @@ definitions: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal + amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. pagination: type: object properties: @@ -79581,6 +76377,12 @@ definitions: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 pagination: type: object properties: @@ -79676,6 +76478,12 @@ definitions: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 amount: type: object properties: @@ -79707,6 +76515,21 @@ definitions: type: string commit: type: string + unitPrice: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + DecCoin defines a token with a denomination and a decimal amount. + + + NOTE: The amount field is an Dec which implements the custom + method + + signatures required by gogoproto. saonetwork.sao.order.QueryGetShardResponse: type: object properties: @@ -79746,6 +76569,12 @@ definitions: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 saonetwork.sao.order.QueryParamsResponse: type: object properties: @@ -79786,6 +76615,23 @@ definitions: type: string sp: type: string + duration: + type: string + format: uint64 + createdAt: + type: string + format: uint64 + saonetwork.sao.sao.ExpiredShard: + type: object + properties: + height: + type: string + format: uint64 + shardList: + type: array + items: + type: string + format: uint64 saonetwork.sao.sao.JwsSignature: type: object properties: @@ -80010,6 +76856,48 @@ definitions: type: array items: type: string + saonetwork.sao.sao.QueryAllExpiredShardResponse: + type: object + properties: + expiredShard: + type: array + items: + type: object + properties: + height: + type: string + format: uint64 + shardList: + type: array + items: + type: string + format: uint64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } saonetwork.sao.sao.QueryAllTimeoutOrderResponse: type: object properties: @@ -80052,6 +76940,20 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + saonetwork.sao.sao.QueryGetExpiredShardResponse: + type: object + properties: + expiredShard: + type: object + properties: + height: + type: string + format: uint64 + shardList: + type: array + items: + type: string + format: uint64 saonetwork.sao.sao.QueryGetTimeoutOrderResponse: type: object properties: diff --git a/go.mod b/go.mod index 4ff1c127..c1d823c0 100644 --- a/go.mod +++ b/go.mod @@ -113,7 +113,6 @@ require ( github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 20478c78..1f992d9b 100644 --- a/go.sum +++ b/go.sum @@ -764,8 +764,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= diff --git a/proto/sao/sao/expired_shard.proto b/proto/sao/sao/expired_shard.proto new file mode 100644 index 00000000..461ff3a7 --- /dev/null +++ b/proto/sao/sao/expired_shard.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package saonetwork.sao.sao; + +option go_package = "github.com/SaoNetwork/sao/x/sao/types"; + +message ExpiredShard { + uint64 height = 1; + repeated uint64 shardList = 2; + +} + diff --git a/proto/sao/sao/genesis.proto b/proto/sao/sao/genesis.proto index b1669f7b..91f878e4 100644 --- a/proto/sao/sao/genesis.proto +++ b/proto/sao/sao/genesis.proto @@ -4,6 +4,7 @@ package saonetwork.sao.sao; import "gogoproto/gogo.proto"; import "sao/sao/params.proto"; import "sao/sao/timeout_order.proto"; +import "sao/sao/expired_shard.proto"; // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/SaoNetwork/sao/x/sao/types"; @@ -12,5 +13,6 @@ option go_package = "github.com/SaoNetwork/sao/x/sao/types"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated TimeoutOrder timeoutOrderList = 2 [(gogoproto.nullable) = false]; + repeated ExpiredShard expiredShardList = 3 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/sao/sao/query.proto b/proto/sao/sao/query.proto index 79945c16..c12e0035 100644 --- a/proto/sao/sao/query.proto +++ b/proto/sao/sao/query.proto @@ -10,6 +10,7 @@ import "sao/sao/metadata.proto"; import "sao/sao/shard_meta.proto"; import "sao/sao/jws_signature.proto"; import "sao/sao/timeout_order.proto"; +import "sao/sao/expired_shard.proto"; // this line is used by starport scaffolding # 1 option go_package = "github.com/SaoNetwork/sao/x/sao/types"; @@ -41,6 +42,16 @@ service Query { option (google.api.http).get = "/SaoNetwork/sao/sao/timeout_order"; } +// Queries a ExpiredShard by index. + rpc ExpiredShard(QueryGetExpiredShardRequest) returns (QueryGetExpiredShardResponse) { + option (google.api.http).get = "/SaoNetwork/sao/sao/expired_shard/{height}"; + } + + // Queries a list of ExpiredShard items. + rpc ExpiredShardAll(QueryAllExpiredShardRequest) returns (QueryAllExpiredShardResponse) { + option (google.api.http).get = "/SaoNetwork/sao/sao/expired_shard"; + } + // this line is used by starport scaffolding # 2 } @@ -89,4 +100,22 @@ message QueryAllTimeoutOrderResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +message QueryGetExpiredShardRequest { + uint64 height = 1; + +} + +message QueryGetExpiredShardResponse { + ExpiredShard expiredShard = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllExpiredShardRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllExpiredShardResponse { + repeated ExpiredShard expiredShard = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // this line is used by starport scaffolding # 3 diff --git a/x/market/keeper/pool_management.go b/x/market/keeper/pool_management.go index 057c9603..6c150135 100644 --- a/x/market/keeper/pool_management.go +++ b/x/market/keeper/pool_management.go @@ -193,7 +193,7 @@ func (k Keeper) Migrate(ctx sdk.Context, order ordertypes.Order, from string, to // return refundCoin, nil //} -func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error { +func (k Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error { logger := k.Logger(ctx) if order == nil { @@ -229,7 +229,7 @@ func (k *Keeper) WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard * return nil } -func (k *Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error { +func (k Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error { logger := k.Logger(ctx) if order == nil { diff --git a/x/model/keeper/data_management.go b/x/model/keeper/data_management.go index 214555e4..ad6415df 100644 --- a/x/model/keeper/data_management.go +++ b/x/model/keeper/data_management.go @@ -248,7 +248,7 @@ func (k Keeper) TerminateOrder(ctx sdk.Context, order ordertypes.Order) error { continue } if shard.Status == ordertypes.ShardCompleted { - err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &order) + err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) if err != nil { return err } diff --git a/x/model/types/expected_keepers.go b/x/model/types/expected_keepers.go index 0bbdb3d3..64b14be6 100644 --- a/x/model/types/expected_keepers.go +++ b/x/model/types/expected_keepers.go @@ -37,7 +37,7 @@ type OrderKeeper interface { // SaoKeeper type NodeKeeper interface { GetNode(ctx sdk.Context, creator string) (val nodetypes.Node, found bool) - OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error + OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error } // DidKeeper diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 57d3c0c9..53fba215 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -148,7 +148,7 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype return nil } -func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error { +func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error { logger := k.Logger(ctx) pledge, foundPledge := k.GetPledge(ctx, sp.String()) @@ -176,14 +176,10 @@ func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertyp var coins sdk.Coins - if order != nil { - shard := k.order.GetOrderShardBySP(ctx, order, sp.String()) - if shard == nil { - return status.Errorf(codes.NotFound, "shard of %s in order %d not found", sp, order.Id) - } + if shard != nil { logger.Debug("PledgeTrace: order release 2", "sp", sp.String(), - "orderId", order.Id, + "orderId", shard.OrderId, "totalStorage", pledge.TotalStorage, "shardSize", shard.Size_) diff --git a/x/sao/abci.go b/x/sao/abci.go index 572bb283..94234c19 100644 --- a/x/sao/abci.go +++ b/x/sao/abci.go @@ -24,4 +24,13 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) { ) } + ExpiredShard, found := k.GetExpiredShard(ctx, uint64(ctx.BlockHeight())) + if found { + + for _, shardId := range ExpiredShard.ShardList { + k.HandleExpiredShard(ctx, shardId) + } + + k.RemoveExpiredShard(ctx, ExpiredShard.Height) + } } diff --git a/x/sao/client/cli/query.go b/x/sao/client/cli/query.go index 4eabc295..9361e895 100644 --- a/x/sao/client/cli/query.go +++ b/x/sao/client/cli/query.go @@ -31,6 +31,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListTimeoutOrder()) cmd.AddCommand(CmdShowTimeoutOrder()) + cmd.AddCommand(CmdListExpiredShard()) + cmd.AddCommand(CmdShowExpiredShard()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/sao/client/cli/query_expired_shard.go b/x/sao/client/cli/query_expired_shard.go new file mode 100644 index 00000000..d3bb2fdd --- /dev/null +++ b/x/sao/client/cli/query_expired_shard.go @@ -0,0 +1,77 @@ +package cli + +import ( + "context" + + "github.com/SaoNetwork/sao/x/sao/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cast" + "github.com/spf13/cobra" +) + +func CmdListExpiredShard() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-expired-shard", + Short: "list all ExpiredShard", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllExpiredShardRequest{ + Pagination: pageReq, + } + + res, err := queryClient.ExpiredShardAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowExpiredShard() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-expired-shard [height]", + Short: "shows a ExpiredShard", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argHeight, err := cast.ToUint64E(args[0]) + if err != nil { + return err + } + + params := &types.QueryGetExpiredShardRequest{ + Height: argHeight, + } + + res, err := queryClient.ExpiredShard(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/sao/client/cli/query_expired_shard_test.go b/x/sao/client/cli/query_expired_shard_test.go new file mode 100644 index 00000000..ce21fe17 --- /dev/null +++ b/x/sao/client/cli/query_expired_shard_test.go @@ -0,0 +1,161 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/SaoNetwork/sao/testutil/network" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/sao/client/cli" + "github.com/SaoNetwork/sao/x/sao/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithExpiredShardObjects(t *testing.T, n int) (*network.Network, []types.ExpiredShard) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + expiredShard := types.ExpiredShard{ + Height: uint64(i), + } + nullify.Fill(&expiredShard) + state.ExpiredShardList = append(state.ExpiredShardList, expiredShard) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.ExpiredShardList +} + +func TestShowExpiredShard(t *testing.T) { + net, objs := networkWithExpiredShardObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idHeight uint64 + + args []string + err error + obj types.ExpiredShard + }{ + { + desc: "found", + idHeight: objs[0].Height, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idHeight: 100000, + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + strconv.Itoa(int(tc.idHeight)), + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowExpiredShard(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetExpiredShardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.ExpiredShard) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.ExpiredShard), + ) + } + }) + } +} + +func TestListExpiredShard(t *testing.T) { + net, objs := networkWithExpiredShardObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListExpiredShard(), args) + require.NoError(t, err) + var resp types.QueryAllExpiredShardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.ExpiredShard), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.ExpiredShard), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListExpiredShard(), args) + require.NoError(t, err) + var resp types.QueryAllExpiredShardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.ExpiredShard), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.ExpiredShard), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListExpiredShard(), args) + require.NoError(t, err) + var resp types.QueryAllExpiredShardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.ExpiredShard), + ) + }) +} diff --git a/x/sao/genesis.go b/x/sao/genesis.go index e7159ea5..fac6121e 100644 --- a/x/sao/genesis.go +++ b/x/sao/genesis.go @@ -12,6 +12,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.TimeoutOrderList { k.SetTimeoutOrder(ctx, elem) } + // Set all the expiredShard + for _, elem := range genState.ExpiredShardList { + k.SetExpiredShard(ctx, elem) + } // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) } @@ -23,6 +27,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.Params = k.GetParams(ctx) genesis.TimeoutOrderList = k.GetAllTimeoutOrder(ctx) + genesis.ExpiredShardList = k.GetAllExpiredShard(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/sao/genesis_test.go b/x/sao/genesis_test.go index aa9276da..2d71fbb2 100644 --- a/x/sao/genesis_test.go +++ b/x/sao/genesis_test.go @@ -21,6 +21,14 @@ func TestGenesis(t *testing.T) { Height: 1, }, }, + ExpiredShardList: []types.ExpiredShard{ + { + Height: 0, + }, + { + Height: 1, + }, + }, // this line is used by starport scaffolding # genesis/test/state } @@ -32,5 +40,6 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) require.ElementsMatch(t, genesisState.TimeoutOrderList, got.TimeoutOrderList) + require.ElementsMatch(t, genesisState.ExpiredShardList, got.ExpiredShardList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/sao/keeper/expire_management.go b/x/sao/keeper/expire_management.go new file mode 100644 index 00000000..fb215e11 --- /dev/null +++ b/x/sao/keeper/expire_management.go @@ -0,0 +1,34 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) HandleExpiredShard(ctx sdk.Context, shardId uint64) { + shard, found := k.order.GetShard(ctx, shardId) + if !found { + return + } + + order, found := k.order.GetOrder(ctx, shard.OrderId) + if !found { + return + } + + k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) + k.market.WorkerRelease(ctx, &order, &shard) + k.order.RemoveShard(ctx, shardId) + if len(order.Shards) == 1 { + if order.Shards[0] == shardId { + k.order.RemoveOrder(ctx, order.Id) + } + } else { + for i, id := range order.Shards { + if id == shardId { + order.Shards = append(order.Shards[:i], order.Shards[i+1:]...) + break + } + } + k.order.SetOrder(ctx, order) + } +} diff --git a/x/sao/keeper/expired_shard.go b/x/sao/keeper/expired_shard.go new file mode 100644 index 00000000..23d84188 --- /dev/null +++ b/x/sao/keeper/expired_shard.go @@ -0,0 +1,96 @@ +package keeper + +import ( + ordertypes "github.com/SaoNetwork/sao/x/order/types" + "github.com/SaoNetwork/sao/x/sao/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetExpiredShard set a specific expiredShard in the store from its index +func (k Keeper) SetExpiredShard(ctx sdk.Context, expiredShard types.ExpiredShard) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExpiredShardKeyPrefix)) + b := k.cdc.MustMarshal(&expiredShard) + store.Set(types.ExpiredShardKey( + expiredShard.Height, + ), b) +} + +// GetExpiredShard returns a expiredShard from its index +func (k Keeper) GetExpiredShard( + ctx sdk.Context, + height uint64, + +) (val types.ExpiredShard, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExpiredShardKeyPrefix)) + + b := store.Get(types.ExpiredShardKey( + height, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveExpiredShard removes a expiredShard from the store +func (k Keeper) RemoveExpiredShard( + ctx sdk.Context, + height uint64, + +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExpiredShardKeyPrefix)) + store.Delete(types.ExpiredShardKey( + height, + )) +} + +// GetAllExpiredShard returns all expiredShard +func (k Keeper) GetAllExpiredShard(ctx sdk.Context) (list []types.ExpiredShard) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExpiredShardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.ExpiredShard + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) SetExpiredShardBlock(ctx sdk.Context, shard ordertypes.Shard, expiredAt uint64) { + + expiredShard, found := k.GetExpiredShard(ctx, expiredAt) + if found { + expiredShard.ShardList = append(expiredShard.ShardList, shard.Id) + } else { + expiredShard = types.ExpiredShard{ + Height: expiredAt, + ShardList: []uint64{shard.Id}, + } + } + + k.SetExpiredShard(ctx, expiredShard) +} + +func (k Keeper) SetExpiredShardsBlock(ctx sdk.Context, expiredShardsMap map[uint64][]uint64) { + + for expiredAt, shards := range expiredShardsMap { + expiredShard, found := k.GetExpiredShard(ctx, expiredAt) + if found { + expiredShard.ShardList = append(expiredShard.ShardList, shards...) + } else { + expiredShard = types.ExpiredShard{ + Height: expiredAt, + ShardList: shards, + } + } + + k.SetExpiredShard(ctx, expiredShard) + } +} diff --git a/x/sao/keeper/expired_shard_test.go b/x/sao/keeper/expired_shard_test.go new file mode 100644 index 00000000..77592442 --- /dev/null +++ b/x/sao/keeper/expired_shard_test.go @@ -0,0 +1,63 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/SaoNetwork/sao/testutil/keeper" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/sao/keeper" + "github.com/SaoNetwork/sao/x/sao/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNExpiredShard(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.ExpiredShard { + items := make([]types.ExpiredShard, n) + for i := range items { + items[i].Height = uint64(i) + + keeper.SetExpiredShard(ctx, items[i]) + } + return items +} + +func TestExpiredShardGet(t *testing.T) { + keeper, ctx := keepertest.SaoKeeper(t) + items := createNExpiredShard(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetExpiredShard(ctx, + item.Height, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestExpiredShardRemove(t *testing.T) { + keeper, ctx := keepertest.SaoKeeper(t) + items := createNExpiredShard(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveExpiredShard(ctx, + item.Height, + ) + _, found := keeper.GetExpiredShard(ctx, + item.Height, + ) + require.False(t, found) + } +} + +func TestExpiredShardGetAll(t *testing.T) { + keeper, ctx := keepertest.SaoKeeper(t) + items := createNExpiredShard(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllExpiredShard(ctx)), + ) +} diff --git a/x/sao/keeper/grpc_query_expired_shard.go b/x/sao/keeper/grpc_query_expired_shard.go new file mode 100644 index 00000000..9c219b41 --- /dev/null +++ b/x/sao/keeper/grpc_query_expired_shard.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + "github.com/SaoNetwork/sao/x/sao/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) ExpiredShardAll(c context.Context, req *types.QueryAllExpiredShardRequest) (*types.QueryAllExpiredShardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var expiredShards []types.ExpiredShard + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + expiredShardStore := prefix.NewStore(store, types.KeyPrefix(types.ExpiredShardKeyPrefix)) + + pageRes, err := query.Paginate(expiredShardStore, req.Pagination, func(key []byte, value []byte) error { + var expiredShard types.ExpiredShard + if err := k.cdc.Unmarshal(value, &expiredShard); err != nil { + return err + } + + expiredShards = append(expiredShards, expiredShard) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllExpiredShardResponse{ExpiredShard: expiredShards, Pagination: pageRes}, nil +} + +func (k Keeper) ExpiredShard(c context.Context, req *types.QueryGetExpiredShardRequest) (*types.QueryGetExpiredShardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetExpiredShard( + ctx, + req.Height, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetExpiredShardResponse{ExpiredShard: val}, nil +} diff --git a/x/sao/keeper/grpc_query_expired_shard_test.go b/x/sao/keeper/grpc_query_expired_shard_test.go new file mode 100644 index 00000000..934b5d02 --- /dev/null +++ b/x/sao/keeper/grpc_query_expired_shard_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/SaoNetwork/sao/testutil/keeper" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/sao/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestExpiredShardQuerySingle(t *testing.T) { + keeper, ctx := keepertest.SaoKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNExpiredShard(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetExpiredShardRequest + response *types.QueryGetExpiredShardResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetExpiredShardRequest{ + Height: msgs[0].Height, + }, + response: &types.QueryGetExpiredShardResponse{ExpiredShard: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetExpiredShardRequest{ + Height: msgs[1].Height, + }, + response: &types.QueryGetExpiredShardResponse{ExpiredShard: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetExpiredShardRequest{ + Height: 100000, + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.ExpiredShard(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestExpiredShardQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.SaoKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNExpiredShard(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllExpiredShardRequest { + return &types.QueryAllExpiredShardRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.ExpiredShardAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.ExpiredShard), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.ExpiredShard), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.ExpiredShardAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.ExpiredShard), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.ExpiredShard), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.ExpiredShardAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.ExpiredShard), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.ExpiredShardAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/sao/keeper/keeper.go b/x/sao/keeper/keeper.go index 1fe199fe..854314a8 100644 --- a/x/sao/keeper/keeper.go +++ b/x/sao/keeper/keeper.go @@ -15,18 +15,19 @@ import ( type ( Keeper struct { - auth types.AccountKeeper - bank types.BankKeeper - node types.NodeKeeper - order types.OrderKeeper - model types.ModelKeeper - did types.DidKeeper - market types.MarketKeeper - staking types.StakingKeeper - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace + auth types.AccountKeeper + bank types.BankKeeper + node types.NodeKeeper + order types.OrderKeeper + model types.ModelKeeper + did types.DidKeeper + market types.MarketKeeper + staking types.StakingKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + orderStoreKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace } ) @@ -41,6 +42,7 @@ func NewKeeper( staking types.StakingKeeper, cdc codec.BinaryCodec, storeKey, + orderStoreKey storetypes.StoreKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, ) *Keeper { diff --git a/x/sao/keeper/migrations.go b/x/sao/keeper/migrations.go new file mode 100644 index 00000000..9ddd6c12 --- /dev/null +++ b/x/sao/keeper/migrations.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "github.com/SaoNetwork/sao/x/sao/migrations/v2" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Migrator struct { + keeper Keeper +} + +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.keeper.SetExpiredShardsBlock, m.keeper.orderStoreKey, m.keeper.cdc) +} diff --git a/x/sao/keeper/msg_server_cancel.go b/x/sao/keeper/msg_server_cancel.go index 2c091e89..6ccf75a7 100644 --- a/x/sao/keeper/msg_server_cancel.go +++ b/x/sao/keeper/msg_server_cancel.go @@ -66,7 +66,7 @@ func (k msgServer) Cancel(goCtx context.Context, msg *types.MsgCancel) (*types.M return nil, status.Errorf(codes.NotFound, "shard %d not found", id) } if shard.Status == ordertypes.ShardCompleted { - err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &order) + err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) if err != nil { return nil, err } diff --git a/x/sao/keeper/msg_server_complete.go b/x/sao/keeper/msg_server_complete.go index bde2c003..dfa7f35a 100644 --- a/x/sao/keeper/msg_server_complete.go +++ b/x/sao/keeper/msg_server_complete.go @@ -119,7 +119,8 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ if shard.From != "" { // shard migrate sp := sdk.MustAccAddressFromBech32(shard.From) - err := k.node.OrderRelease(ctx, sp, &order) + oldShard := k.order.GetOrderShardBySP(ctx, &order, shard.From) + err := k.node.OrderRelease(ctx, sp, oldShard) if err != nil { return nil, err } @@ -127,7 +128,6 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ if err != nil { return nil, err } - oldShard := k.order.GetOrderShardBySP(ctx, &order, shard.From) shard.CreatedAt = uint64(ctx.BlockHeight()) shard.Duration = oldShard.CreatedAt + oldShard.Duration - shard.CreatedAt if oldShard != nil { @@ -148,6 +148,7 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ // active shard k.order.FulfillShard(ctx, shard, msg.Provider, msg.Cid) k.order.SetShard(ctx, *shard) + k.SetExpiredShardBlock(ctx, *shard, shard.CreatedAt+shard.Duration) // shard = order.Shards[msg.Provider] diff --git a/x/sao/migrations/v2/migrations.go b/x/sao/migrations/v2/migrations.go new file mode 100644 index 00000000..9b7a7d34 --- /dev/null +++ b/x/sao/migrations/v2/migrations.go @@ -0,0 +1,36 @@ +package v2 + +import ( + v2order "github.com/SaoNetwork/sao/x/order/migrations/v2/types" + "github.com/SaoNetwork/sao/x/order/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type SetExpiredShardsBlock func(ctx sdk.Context, expiredShardsMap map[uint64][]uint64) + +func MigrateStore(ctx sdk.Context, setExpiredShardsBlock SetExpiredShardsBlock, orderStoreKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + orderstore := ctx.KVStore(orderStoreKey) + + orderStore := prefix.NewStore(orderstore, types.KeyPrefix(types.OrderKey)) + + orderIterator := sdk.KVStorePrefixIterator(orderStore, []byte{}) + + expiredShardsMap := make(map[uint64][]uint64) + + for ; orderIterator.Valid(); orderIterator.Next() { + orderKey := orderIterator.Key() + oldVal := orderStore.Get(orderKey) + var order v2order.Order + cdc.MustUnmarshal(oldVal, &order) + + expiredAt := order.CreatedAt + order.Duration + expiredShardsMap[expiredAt] = append(expiredShardsMap[expiredAt], order.Shards...) + } + + setExpiredShardsBlock(ctx, expiredShardsMap) + + return nil +} diff --git a/x/sao/module.go b/x/sao/module.go index 29fb6e35..b5d2a10a 100644 --- a/x/sao/module.go +++ b/x/sao/module.go @@ -129,6 +129,12 @@ func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + migrator := keeper.NewMigrator(am.keeper) + + if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { + panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) + } } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) @@ -152,7 +158,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/sao/types/expected_keepers.go b/x/sao/types/expected_keepers.go index 4caa48dd..3fe88b3f 100644 --- a/x/sao/types/expected_keepers.go +++ b/x/sao/types/expected_keepers.go @@ -42,7 +42,7 @@ type NodeKeeper interface { OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error - OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error + OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Shard) error } // EarnKeeper @@ -57,6 +57,7 @@ type OrderKeeper interface { MigrateShard(ctx sdk.Context, order *ordertypes.Order, from string, to string) *ordertypes.Shard GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) SetOrder(ctx sdk.Context, order ordertypes.Order) + RemoveOrder(ctx sdk.Context, orderId uint64) FulfillShard(ctx sdk.Context, shard *ordertypes.Shard, sp string, cid string) GetOrderShardBySP(ctx sdk.Context, order *ordertypes.Order, sp string) *ordertypes.Shard GetShard(ctx sdk.Context, id uint64) (val ordertypes.Shard, found bool) @@ -101,4 +102,5 @@ type MarketKeeper interface { Deposit(ctx sdk.Context, order ordertypes.Order) error Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, error) Migrate(ctx sdk.Context, order ordertypes.Order, from string, to string) error + WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error } diff --git a/x/sao/types/expired_shard.pb.go b/x/sao/types/expired_shard.pb.go new file mode 100644 index 00000000..fdeeaf5a --- /dev/null +++ b/x/sao/types/expired_shard.pb.go @@ -0,0 +1,409 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/sao/expired_shard.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ExpiredShard struct { + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + ShardList []uint64 `protobuf:"varint,2,rep,packed,name=shardList,proto3" json:"shardList,omitempty"` +} + +func (m *ExpiredShard) Reset() { *m = ExpiredShard{} } +func (m *ExpiredShard) String() string { return proto.CompactTextString(m) } +func (*ExpiredShard) ProtoMessage() {} +func (*ExpiredShard) Descriptor() ([]byte, []int) { + return fileDescriptor_15db09f895192250, []int{0} +} +func (m *ExpiredShard) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExpiredShard) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExpiredShard.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExpiredShard) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpiredShard.Merge(m, src) +} +func (m *ExpiredShard) XXX_Size() int { + return m.Size() +} +func (m *ExpiredShard) XXX_DiscardUnknown() { + xxx_messageInfo_ExpiredShard.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpiredShard proto.InternalMessageInfo + +func (m *ExpiredShard) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *ExpiredShard) GetShardList() []uint64 { + if m != nil { + return m.ShardList + } + return nil +} + +func init() { + proto.RegisterType((*ExpiredShard)(nil), "saonetwork.sao.sao.ExpiredShard") +} + +func init() { proto.RegisterFile("sao/sao/expired_shard.proto", fileDescriptor_15db09f895192250) } + +var fileDescriptor_15db09f895192250 = []byte{ + // 178 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x4e, 0xcc, 0xd7, + 0x07, 0xe1, 0xd4, 0x8a, 0x82, 0xcc, 0xa2, 0xd4, 0x94, 0xf8, 0xe2, 0x8c, 0xc4, 0xa2, 0x14, 0xbd, + 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0xa1, 0xe2, 0xc4, 0xfc, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, + 0x6c, 0xbd, 0xe2, 0xc4, 0x7c, 0x10, 0x56, 0x72, 0xe1, 0xe2, 0x71, 0x85, 0x28, 0x0d, 0x06, 0xa9, + 0x14, 0x12, 0xe3, 0x62, 0xcb, 0x48, 0xcd, 0x4c, 0xcf, 0x28, 0x91, 0x60, 0x54, 0x60, 0xd4, 0x60, + 0x09, 0x82, 0xf2, 0x84, 0x64, 0xb8, 0x38, 0xc1, 0x46, 0xf9, 0x64, 0x16, 0x97, 0x48, 0x30, 0x29, + 0x30, 0x6b, 0xb0, 0x04, 0x21, 0x04, 0x9c, 0xec, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, + 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, + 0x8e, 0x21, 0x4a, 0x35, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x38, + 0x31, 0xdf, 0x0f, 0x62, 0x3d, 0xd8, 0x89, 0x15, 0x60, 0xb2, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, + 0x0d, 0xec, 0x42, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xab, 0x41, 0x17, 0xf3, 0xc0, 0x00, + 0x00, 0x00, +} + +func (m *ExpiredShard) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExpiredShard) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExpiredShard) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ShardList) > 0 { + dAtA2 := make([]byte, len(m.ShardList)*10) + var j1 int + for _, num := range m.ShardList { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintExpiredShard(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if m.Height != 0 { + i = encodeVarintExpiredShard(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintExpiredShard(dAtA []byte, offset int, v uint64) int { + offset -= sovExpiredShard(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExpiredShard) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovExpiredShard(uint64(m.Height)) + } + if len(m.ShardList) > 0 { + l = 0 + for _, e := range m.ShardList { + l += sovExpiredShard(uint64(e)) + } + n += 1 + sovExpiredShard(uint64(l)) + l + } + return n +} + +func sovExpiredShard(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExpiredShard(x uint64) (n int) { + return sovExpiredShard(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExpiredShard) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ExpiredShard: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExpiredShard: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ShardList = append(m.ShardList, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthExpiredShard + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthExpiredShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ShardList) == 0 { + m.ShardList = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ShardList = append(m.ShardList, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ShardList", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipExpiredShard(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExpiredShard + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExpiredShard(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpiredShard + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthExpiredShard + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExpiredShard + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExpiredShard + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExpiredShard = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExpiredShard = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExpiredShard = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/sao/types/genesis.go b/x/sao/types/genesis.go index e0dc56a1..c0a0e821 100644 --- a/x/sao/types/genesis.go +++ b/x/sao/types/genesis.go @@ -11,6 +11,7 @@ const DefaultIndex uint64 = 1 func DefaultGenesis() *GenesisState { return &GenesisState{ TimeoutOrderList: []TimeoutOrder{}, + ExpiredShardList: []ExpiredShard{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -30,6 +31,16 @@ func (gs GenesisState) Validate() error { } timeoutOrderIndexMap[index] = struct{}{} } + // Check for duplicated index in expiredShard + expiredShardIndexMap := make(map[string]struct{}) + + for _, elem := range gs.ExpiredShardList { + index := string(ExpiredShardKey(elem.Height)) + if _, ok := expiredShardIndexMap[index]; ok { + return fmt.Errorf("duplicated index for expiredShard") + } + expiredShardIndexMap[index] = struct{}{} + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/sao/types/genesis.pb.go b/x/sao/types/genesis.pb.go index c867f0ae..35508ec0 100644 --- a/x/sao/types/genesis.pb.go +++ b/x/sao/types/genesis.pb.go @@ -27,6 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` TimeoutOrderList []TimeoutOrder `protobuf:"bytes,2,rep,name=timeoutOrderList,proto3" json:"timeoutOrderList"` + ExpiredShardList []ExpiredShard `protobuf:"bytes,3,rep,name=expiredShardList,proto3" json:"expiredShardList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -76,6 +77,13 @@ func (m *GenesisState) GetTimeoutOrderList() []TimeoutOrder { return nil } +func (m *GenesisState) GetExpiredShardList() []ExpiredShard { + if m != nil { + return m.ExpiredShardList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "saonetwork.sao.sao.GenesisState") } @@ -83,23 +91,25 @@ func init() { func init() { proto.RegisterFile("sao/sao/genesis.proto", fileDescriptor_2505de80dfdc4558) } var fileDescriptor_2505de80dfdc4558 = []byte{ - // 241 bytes of a gzipped FileDescriptorProto + // 277 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4e, 0xcc, 0xd7, 0x07, 0xe1, 0xf4, 0xd4, 0xbc, 0xd4, 0xe2, 0xcc, 0x62, 0xbd, 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0xa1, 0xe2, 0xc4, 0xfc, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0xbd, 0xe2, 0xc4, 0x7c, 0x10, 0x96, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x52, 0x22, 0x30, 0x03, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xfa, 0xa5, 0xa4, 0x61, 0xa2, 0x25, 0x99, 0xb9, 0xa9, - 0xf9, 0xa5, 0x25, 0xf1, 0xf9, 0x45, 0x29, 0xa9, 0x45, 0x10, 0x49, 0xa5, 0x39, 0x8c, 0x5c, 0x3c, - 0xee, 0x10, 0xeb, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x2c, 0xb8, 0xd8, 0x20, 0xba, 0x25, 0x18, - 0x15, 0x18, 0x35, 0xb8, 0x8d, 0xa4, 0xf4, 0x30, 0xad, 0xd7, 0x0b, 0x00, 0xab, 0x70, 0x62, 0x39, - 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0x5e, 0x28, 0x88, 0x4b, 0x00, 0x6a, 0x83, 0x3f, 0xc8, 0x02, - 0x9f, 0xcc, 0xe2, 0x12, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x05, 0x6c, 0x66, 0x84, 0x20, - 0xa9, 0x85, 0x9a, 0x84, 0xa1, 0xdf, 0xc9, 0xfe, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, - 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, - 0x18, 0xa2, 0x54, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x83, 0x13, - 0xf3, 0xfd, 0x20, 0xa6, 0x83, 0xfd, 0x59, 0x01, 0xf1, 0x6d, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, - 0xd8, 0x9b, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x94, 0x63, 0xd7, 0x5c, 0x01, 0x00, - 0x00, + 0xf9, 0xa5, 0x25, 0xf1, 0xf9, 0x45, 0x29, 0xa9, 0x45, 0xe8, 0x92, 0xa9, 0x15, 0x05, 0x99, 0x45, + 0xa9, 0x29, 0xf1, 0xc5, 0x19, 0x89, 0x45, 0x29, 0x10, 0x49, 0xa5, 0x0f, 0x8c, 0x5c, 0x3c, 0xee, + 0x10, 0xb7, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x59, 0x70, 0xb1, 0x41, 0x8c, 0x96, 0x60, 0x54, + 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd2, 0xc3, 0x74, 0x9b, 0x5e, 0x00, 0x58, 0x85, 0x13, 0xcb, 0x89, + 0x7b, 0xf2, 0x0c, 0x41, 0x50, 0xf5, 0x42, 0x41, 0x5c, 0x02, 0x50, 0xeb, 0xfd, 0x41, 0xb6, 0xfb, + 0x64, 0x16, 0x97, 0x48, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x29, 0x60, 0x33, 0x23, 0x04, 0x49, + 0x2d, 0xd4, 0x24, 0x0c, 0xfd, 0x20, 0x33, 0xa1, 0xae, 0x0e, 0x06, 0x39, 0x1a, 0x6c, 0x26, 0x33, + 0x6e, 0x33, 0x5d, 0x91, 0xd4, 0xc2, 0xcc, 0x44, 0xd7, 0xef, 0x64, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, + 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, + 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xaa, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, + 0xb9, 0xfa, 0xc1, 0x89, 0xf9, 0x7e, 0x10, 0xd3, 0xc1, 0x61, 0x57, 0x01, 0x09, 0xde, 0xca, 0x82, + 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xd0, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x22, 0xa2, 0x50, + 0xa9, 0xcd, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -122,6 +132,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ExpiredShardList) > 0 { + for iNdEx := len(m.ExpiredShardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExpiredShardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } if len(m.TimeoutOrderList) > 0 { for iNdEx := len(m.TimeoutOrderList) - 1; iNdEx >= 0; iNdEx-- { { @@ -174,6 +198,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.ExpiredShardList) > 0 { + for _, e := range m.ExpiredShardList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -279,6 +309,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpiredShardList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExpiredShardList = append(m.ExpiredShardList, ExpiredShard{}) + if err := m.ExpiredShardList[len(m.ExpiredShardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/sao/types/genesis_test.go b/x/sao/types/genesis_test.go index fa60bd0f..2d63a8e5 100644 --- a/x/sao/types/genesis_test.go +++ b/x/sao/types/genesis_test.go @@ -29,6 +29,14 @@ func TestGenesisState_Validate(t *testing.T) { Height: 1, }, }, + ExpiredShardList: []types.ExpiredShard{ + { + Height: 0, + }, + { + Height: 1, + }, + }, // this line is used by starport scaffolding # types/genesis/validField }, valid: true, @@ -67,6 +75,20 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "duplicated expiredShard", + genState: &types.GenesisState{ + ExpiredShardList: []types.ExpiredShard{ + { + Height: 0, + }, + { + Height: 0, + }, + }, + }, + valid: false, + }, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/sao/types/key_expired_shard.go b/x/sao/types/key_expired_shard.go new file mode 100644 index 00000000..d7d18311 --- /dev/null +++ b/x/sao/types/key_expired_shard.go @@ -0,0 +1,24 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // ExpiredShardKeyPrefix is the prefix to retrieve all ExpiredShard + ExpiredShardKeyPrefix = "ExpiredShard/value/" +) + +// ExpiredShardKey returns the store key to retrieve a ExpiredShard from the index fields +func ExpiredShardKey( + height uint64, +) []byte { + var key []byte + + heightBytes := make([]byte, 8) + binary.BigEndian.PutUint64(heightBytes, height) + key = append(key, heightBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/sao/types/query.pb.go b/x/sao/types/query.pb.go index b8dac648..45f5cdc5 100644 --- a/x/sao/types/query.pb.go +++ b/x/sao/types/query.pb.go @@ -489,6 +489,190 @@ func (m *QueryAllTimeoutOrderResponse) GetPagination() *query.PageResponse { return nil } +type QueryGetExpiredShardRequest struct { + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryGetExpiredShardRequest) Reset() { *m = QueryGetExpiredShardRequest{} } +func (m *QueryGetExpiredShardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetExpiredShardRequest) ProtoMessage() {} +func (*QueryGetExpiredShardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5c097aa6efc06297, []int{10} +} +func (m *QueryGetExpiredShardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetExpiredShardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetExpiredShardRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetExpiredShardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetExpiredShardRequest.Merge(m, src) +} +func (m *QueryGetExpiredShardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetExpiredShardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetExpiredShardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetExpiredShardRequest proto.InternalMessageInfo + +func (m *QueryGetExpiredShardRequest) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +type QueryGetExpiredShardResponse struct { + ExpiredShard ExpiredShard `protobuf:"bytes,1,opt,name=expiredShard,proto3" json:"expiredShard"` +} + +func (m *QueryGetExpiredShardResponse) Reset() { *m = QueryGetExpiredShardResponse{} } +func (m *QueryGetExpiredShardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetExpiredShardResponse) ProtoMessage() {} +func (*QueryGetExpiredShardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5c097aa6efc06297, []int{11} +} +func (m *QueryGetExpiredShardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetExpiredShardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetExpiredShardResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetExpiredShardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetExpiredShardResponse.Merge(m, src) +} +func (m *QueryGetExpiredShardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetExpiredShardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetExpiredShardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetExpiredShardResponse proto.InternalMessageInfo + +func (m *QueryGetExpiredShardResponse) GetExpiredShard() ExpiredShard { + if m != nil { + return m.ExpiredShard + } + return ExpiredShard{} +} + +type QueryAllExpiredShardRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllExpiredShardRequest) Reset() { *m = QueryAllExpiredShardRequest{} } +func (m *QueryAllExpiredShardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllExpiredShardRequest) ProtoMessage() {} +func (*QueryAllExpiredShardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5c097aa6efc06297, []int{12} +} +func (m *QueryAllExpiredShardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllExpiredShardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllExpiredShardRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllExpiredShardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllExpiredShardRequest.Merge(m, src) +} +func (m *QueryAllExpiredShardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllExpiredShardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllExpiredShardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllExpiredShardRequest proto.InternalMessageInfo + +func (m *QueryAllExpiredShardRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllExpiredShardResponse struct { + ExpiredShard []ExpiredShard `protobuf:"bytes,1,rep,name=expiredShard,proto3" json:"expiredShard"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllExpiredShardResponse) Reset() { *m = QueryAllExpiredShardResponse{} } +func (m *QueryAllExpiredShardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllExpiredShardResponse) ProtoMessage() {} +func (*QueryAllExpiredShardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5c097aa6efc06297, []int{13} +} +func (m *QueryAllExpiredShardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllExpiredShardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllExpiredShardResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllExpiredShardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllExpiredShardResponse.Merge(m, src) +} +func (m *QueryAllExpiredShardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllExpiredShardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllExpiredShardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllExpiredShardResponse proto.InternalMessageInfo + +func (m *QueryAllExpiredShardResponse) GetExpiredShard() []ExpiredShard { + if m != nil { + return m.ExpiredShard + } + return nil +} + +func (m *QueryAllExpiredShardResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "saonetwork.sao.sao.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "saonetwork.sao.sao.QueryParamsResponse") @@ -501,64 +685,74 @@ func init() { proto.RegisterType((*QueryGetTimeoutOrderResponse)(nil), "saonetwork.sao.sao.QueryGetTimeoutOrderResponse") proto.RegisterType((*QueryAllTimeoutOrderRequest)(nil), "saonetwork.sao.sao.QueryAllTimeoutOrderRequest") proto.RegisterType((*QueryAllTimeoutOrderResponse)(nil), "saonetwork.sao.sao.QueryAllTimeoutOrderResponse") + proto.RegisterType((*QueryGetExpiredShardRequest)(nil), "saonetwork.sao.sao.QueryGetExpiredShardRequest") + proto.RegisterType((*QueryGetExpiredShardResponse)(nil), "saonetwork.sao.sao.QueryGetExpiredShardResponse") + proto.RegisterType((*QueryAllExpiredShardRequest)(nil), "saonetwork.sao.sao.QueryAllExpiredShardRequest") + proto.RegisterType((*QueryAllExpiredShardResponse)(nil), "saonetwork.sao.sao.QueryAllExpiredShardResponse") } func init() { proto.RegisterFile("sao/sao/query.proto", fileDescriptor_5c097aa6efc06297) } var fileDescriptor_5c097aa6efc06297 = []byte{ - // 822 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x95, 0xcd, 0x4e, 0x1b, 0x57, - 0x14, 0xc7, 0x3d, 0x06, 0x2c, 0xb8, 0xa6, 0xa2, 0x5c, 0x5c, 0xea, 0x0e, 0xae, 0x81, 0x69, 0xcb, - 0x57, 0xd1, 0x4c, 0x31, 0x42, 0x42, 0x5d, 0xb4, 0x82, 0xaa, 0xa5, 0x22, 0x21, 0x90, 0x81, 0x45, - 0x94, 0x8d, 0x75, 0x0d, 0x57, 0xe3, 0x81, 0xf1, 0xdc, 0x61, 0xee, 0x35, 0xc4, 0x8a, 0x90, 0xa2, - 0x48, 0xd9, 0x27, 0xca, 0x03, 0x64, 0x15, 0x29, 0xfb, 0xbc, 0x04, 0x4b, 0xa4, 0x6c, 0xb2, 0x8a, - 0x22, 0xc8, 0x32, 0x0f, 0x11, 0xcd, 0xfd, 0x20, 0x33, 0xf6, 0x18, 0xac, 0x2c, 0x2c, 0xd9, 0xe7, - 0x7f, 0x3e, 0x7e, 0x67, 0xe6, 0x9c, 0x63, 0x30, 0x46, 0x11, 0xb1, 0xa2, 0xcf, 0x71, 0x13, 0x87, - 0x2d, 0x33, 0x08, 0x09, 0x23, 0x10, 0x52, 0x44, 0x7c, 0xcc, 0x4e, 0x49, 0x78, 0x64, 0x52, 0x44, - 0xa2, 0x8f, 0x5e, 0x70, 0x88, 0x43, 0xb8, 0x6c, 0x45, 0xdf, 0x84, 0xa7, 0x5e, 0x72, 0x08, 0x71, - 0x3c, 0x6c, 0xa1, 0xc0, 0xb5, 0x90, 0xef, 0x13, 0x86, 0x98, 0x4b, 0x7c, 0x2a, 0xd5, 0x85, 0x7d, - 0x42, 0x1b, 0x84, 0x5a, 0x35, 0x44, 0xb1, 0x28, 0x60, 0x9d, 0x2c, 0xd5, 0x30, 0x43, 0x4b, 0x56, - 0x80, 0x1c, 0xd7, 0xe7, 0xce, 0xd2, 0xb7, 0xa0, 0x40, 0x02, 0x14, 0xa2, 0x86, 0xca, 0x50, 0x4a, - 0xe0, 0x55, 0x83, 0x90, 0x04, 0x84, 0x22, 0x4f, 0xaa, 0xe3, 0x4a, 0x6d, 0x60, 0x86, 0x0e, 0x10, - 0x43, 0xd2, 0x5e, 0x54, 0x76, 0x5a, 0x47, 0xe1, 0x41, 0x35, 0x52, 0xa5, 0x32, 0xa1, 0x94, 0xc3, - 0x53, 0x5a, 0xa5, 0xae, 0xe3, 0x23, 0xd6, 0x0c, 0x71, 0xbb, 0xc8, 0xdc, 0x06, 0x26, 0x4d, 0x56, - 0x25, 0xe1, 0x01, 0x0e, 0x85, 0x68, 0x14, 0x00, 0xbc, 0x1f, 0x31, 0xec, 0x70, 0x3c, 0x1b, 0x1f, - 0x37, 0x31, 0x65, 0xc6, 0x36, 0x18, 0x4b, 0x58, 0x69, 0x40, 0x7c, 0x8a, 0xe1, 0x2a, 0xc8, 0x89, - 0x36, 0x8a, 0xda, 0x94, 0x36, 0x97, 0xaf, 0xe8, 0x66, 0xe7, 0x13, 0x35, 0x45, 0xcc, 0x7a, 0xff, - 0xf9, 0x87, 0xc9, 0x8c, 0x2d, 0xfd, 0x8d, 0x37, 0x1a, 0x28, 0xf0, 0x8c, 0x5b, 0xb2, 0x25, 0x59, - 0x09, 0xfe, 0x03, 0x06, 0x55, 0xf7, 0x32, 0xe9, 0x74, 0x5a, 0x52, 0x41, 0x23, 0x1d, 0x65, 0xee, - 0xeb, 0x40, 0x78, 0x07, 0x7c, 0x97, 0x68, 0xbc, 0x98, 0xe5, 0x99, 0xa6, 0xd2, 0x32, 0x6d, 0x9e, - 0xd2, 0x5d, 0xe5, 0x27, 0x13, 0x0d, 0x1f, 0xc6, 0x6c, 0xc6, 0x93, 0x2c, 0xf8, 0xa1, 0x0d, 0x55, - 0xb6, 0xff, 0x17, 0x18, 0x54, 0x6f, 0x44, 0xb2, 0x96, 0xd2, 0x2a, 0xa8, 0x38, 0x85, 0xa9, 0x62, - 0xe0, 0x16, 0xc8, 0xf1, 0x37, 0x47, 0x8b, 0xd9, 0xa9, 0xbe, 0xb9, 0x7c, 0x65, 0xa5, 0x6b, 0xa7, - 0xed, 0xa5, 0xcd, 0x5d, 0x1e, 0xf7, 0xaf, 0xcf, 0xc2, 0x96, 0x2d, 0x93, 0xe8, 0x0f, 0x40, 0x3e, - 0x66, 0x86, 0xdf, 0x83, 0xbe, 0x23, 0xdc, 0xe2, 0x60, 0x43, 0x76, 0xf4, 0x15, 0x2e, 0x83, 0x81, - 0x13, 0xe4, 0x35, 0xd5, 0xe3, 0xf8, 0x39, 0xad, 0x1c, 0xcf, 0x10, 0x95, 0xb3, 0x85, 0xef, 0x9f, - 0xd9, 0x55, 0xcd, 0xf8, 0x09, 0xfc, 0xc8, 0x31, 0xee, 0x22, 0x86, 0x29, 0xab, 0xbb, 0x4e, 0x9d, - 0xa9, 0xc9, 0x38, 0x01, 0xc5, 0x4e, 0x49, 0x3e, 0x1f, 0x13, 0x8c, 0x79, 0xdc, 0x5c, 0xad, 0x79, - 0x64, 0xff, 0xa8, 0x5a, 0xc7, 0x91, 0xcc, 0x89, 0xfa, 0xed, 0x51, 0x21, 0xad, 0x47, 0xca, 0xff, - 0x5c, 0x80, 0x0b, 0x60, 0x34, 0xe1, 0x1f, 0xcd, 0x27, 0x67, 0x1d, 0xb2, 0x47, 0x62, 0xde, 0x7b, - 0x6e, 0x03, 0x1b, 0x2b, 0x60, 0x82, 0xd7, 0xdd, 0xc0, 0x6c, 0x4f, 0x8c, 0xf1, 0x76, 0x34, 0xc5, - 0x6a, 0x8c, 0xc6, 0x41, 0x2e, 0x51, 0x4d, 0xfe, 0x32, 0x0e, 0x41, 0x29, 0x3d, 0x4c, 0x22, 0x6f, - 0x82, 0x61, 0x16, 0xb3, 0xcb, 0xd7, 0x9a, 0x3a, 0x38, 0xf1, 0x78, 0x35, 0x38, 0xf1, 0x58, 0x03, - 0x4b, 0xc4, 0x35, 0xcf, 0x4b, 0x43, 0xfc, 0x0f, 0x80, 0xaf, 0xd7, 0x41, 0x16, 0x9a, 0x31, 0xc5, - 0x29, 0x31, 0xa3, 0x53, 0x62, 0x8a, 0x5b, 0x25, 0x4f, 0x89, 0xb9, 0x83, 0x1c, 0x2c, 0x63, 0xed, - 0x58, 0xa4, 0xf1, 0x56, 0x93, 0x3d, 0x75, 0xd4, 0xe9, 0xda, 0x53, 0xdf, 0xb7, 0xf6, 0x04, 0x37, - 0x12, 0xd0, 0x62, 0x8e, 0x66, 0x6f, 0x85, 0x16, 0x20, 0x71, 0xea, 0xca, 0xe7, 0x01, 0x30, 0xc0, - 0xa9, 0xe1, 0x19, 0xc8, 0x89, 0x13, 0x01, 0x67, 0xba, 0x6f, 0x7a, 0xfc, 0x1a, 0xe9, 0xb3, 0xb7, - 0xfa, 0x89, 0x82, 0x86, 0xf1, 0xf4, 0xdd, 0xa7, 0x97, 0xd9, 0x12, 0xd4, 0xad, 0x5d, 0x44, 0xee, - 0x89, 0x00, 0x2b, 0x79, 0x80, 0xe1, 0x33, 0x0d, 0x0c, 0xaa, 0xf5, 0x82, 0x73, 0x3d, 0x6c, 0xa0, - 0x60, 0x98, 0xef, 0x79, 0x57, 0x8d, 0x5f, 0x39, 0x45, 0x19, 0x96, 0xd2, 0x28, 0xae, 0x8f, 0xc1, - 0x0b, 0x0d, 0xe4, 0x63, 0x4b, 0x04, 0x7f, 0xef, 0x5a, 0xa0, 0x73, 0x0b, 0xf5, 0xc5, 0xde, 0x9c, - 0x25, 0xd0, 0x2c, 0x07, 0x9a, 0x86, 0x93, 0x69, 0x40, 0x5e, 0x8c, 0xe1, 0xb5, 0x06, 0x86, 0xe3, - 0x23, 0x01, 0xad, 0xae, 0x75, 0xd2, 0xf7, 0x50, 0xff, 0xa3, 0xf7, 0x00, 0x09, 0x57, 0xe1, 0x70, - 0x8b, 0x70, 0x21, 0x0d, 0x2e, 0xf1, 0x8f, 0x65, 0x3d, 0x16, 0x4b, 0x7d, 0x06, 0x5f, 0x69, 0x60, - 0x24, 0x9e, 0x6c, 0xcd, 0xf3, 0x6e, 0x40, 0x4d, 0xdf, 0xc7, 0x1b, 0x50, 0xbb, 0x2c, 0x96, 0x31, - 0xcf, 0x51, 0x7f, 0x81, 0xd3, 0xb7, 0xa2, 0xae, 0xff, 0x7d, 0x7e, 0x59, 0xd6, 0x2e, 0x2e, 0xcb, - 0xda, 0xc7, 0xcb, 0xb2, 0xf6, 0xfc, 0xaa, 0x9c, 0xb9, 0xb8, 0x2a, 0x67, 0xde, 0x5f, 0x95, 0x33, - 0x0f, 0x7f, 0x73, 0x5c, 0x56, 0x6f, 0xd6, 0xcc, 0x7d, 0xd2, 0x68, 0x4f, 0xf3, 0x48, 0x24, 0x6a, - 0x05, 0x98, 0xd6, 0x72, 0xfc, 0xef, 0x79, 0xf9, 0x4b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x88, - 0x7c, 0x98, 0xc9, 0x08, 0x00, 0x00, + // 915 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xc7, 0xe3, 0x64, 0x37, 0xca, 0x4e, 0x8a, 0x96, 0x9d, 0x86, 0x25, 0x78, 0x43, 0xb6, 0x35, + 0xb0, 0xed, 0x96, 0x95, 0xcd, 0x66, 0xb5, 0x52, 0xc5, 0x01, 0xd4, 0xa2, 0x52, 0x54, 0x28, 0x2d, + 0x6e, 0x0f, 0x88, 0x4b, 0x34, 0x69, 0x46, 0x8e, 0x5b, 0xc7, 0xe3, 0x7a, 0x26, 0x6d, 0x23, 0x54, + 0x09, 0x21, 0x71, 0x07, 0xf1, 0x01, 0x38, 0x21, 0x71, 0x47, 0xe2, 0x33, 0xf4, 0x58, 0x89, 0x0b, + 0x27, 0x84, 0x5a, 0x3e, 0x08, 0xf2, 0xbc, 0xb4, 0xe3, 0xc4, 0x79, 0x69, 0xc5, 0x1e, 0x22, 0x25, + 0xf3, 0xbc, 0xfd, 0x9e, 0x67, 0x1e, 0xff, 0x63, 0x30, 0x4b, 0x11, 0x71, 0x92, 0xcf, 0x61, 0x0f, + 0xc7, 0x7d, 0x3b, 0x8a, 0x09, 0x23, 0x10, 0x52, 0x44, 0x42, 0xcc, 0x8e, 0x49, 0x7c, 0x60, 0x53, + 0x44, 0x92, 0x8f, 0x59, 0xf1, 0x88, 0x47, 0xb8, 0xd9, 0x49, 0xbe, 0x09, 0x4f, 0xb3, 0xe6, 0x11, + 0xe2, 0x05, 0xd8, 0x41, 0x91, 0xef, 0xa0, 0x30, 0x24, 0x0c, 0x31, 0x9f, 0x84, 0x54, 0x5a, 0x97, + 0xf6, 0x08, 0xed, 0x12, 0xea, 0xb4, 0x10, 0xc5, 0xa2, 0x80, 0x73, 0xf4, 0xbc, 0x85, 0x19, 0x7a, + 0xee, 0x44, 0xc8, 0xf3, 0x43, 0xee, 0x2c, 0x7d, 0x2b, 0x0a, 0x24, 0x42, 0x31, 0xea, 0xaa, 0x0c, + 0xb5, 0x14, 0x5e, 0x33, 0x8a, 0x49, 0x44, 0x28, 0x0a, 0xa4, 0xf5, 0xa1, 0xb2, 0x76, 0x31, 0x43, + 0x6d, 0xc4, 0x90, 0x3c, 0xaf, 0xaa, 0x73, 0xda, 0x41, 0x71, 0xbb, 0x99, 0x58, 0xa5, 0xe5, 0x91, + 0xb2, 0xec, 0x1f, 0xd3, 0x26, 0xf5, 0xbd, 0x10, 0xb1, 0x5e, 0x8c, 0x07, 0x8d, 0xcc, 0xef, 0x62, + 0xd2, 0x63, 0x4d, 0x12, 0xb7, 0x71, 0x3c, 0x68, 0xc4, 0x27, 0x91, 0x1f, 0xe3, 0x76, 0x93, 0xe7, + 0x16, 0x46, 0xab, 0x02, 0xe0, 0x57, 0x09, 0xe0, 0x36, 0x67, 0x77, 0xf1, 0x61, 0x0f, 0x53, 0x66, + 0x6d, 0x81, 0xd9, 0xd4, 0x29, 0x8d, 0x48, 0x48, 0x31, 0x5c, 0x06, 0x45, 0xd1, 0x63, 0xd5, 0x98, + 0x33, 0x16, 0xcb, 0x0d, 0xd3, 0x1e, 0x1e, 0xb7, 0x2d, 0x62, 0x56, 0xef, 0x9c, 0xfd, 0xfd, 0x38, + 0xe7, 0x4a, 0x7f, 0xeb, 0x37, 0x03, 0x54, 0x78, 0xc6, 0x4d, 0xd9, 0xaf, 0xac, 0x04, 0x3f, 0x01, + 0x25, 0x35, 0x1a, 0x99, 0x74, 0x3e, 0x2b, 0xa9, 0xa0, 0x91, 0x8e, 0x32, 0xf7, 0x55, 0x20, 0xfc, + 0x1c, 0xbc, 0x96, 0x9a, 0x4a, 0x35, 0xcf, 0x33, 0xcd, 0x65, 0x65, 0xda, 0x38, 0xa6, 0x3b, 0xca, + 0x4f, 0x26, 0x9a, 0xd9, 0xd7, 0xce, 0xac, 0xef, 0xf2, 0xe0, 0x8d, 0x01, 0x54, 0xd9, 0xfe, 0x47, + 0xa0, 0xa4, 0xae, 0x4b, 0xb2, 0xd6, 0xb2, 0x2a, 0xa8, 0x38, 0x85, 0xa9, 0x62, 0xe0, 0x26, 0x28, + 0xf2, 0xd1, 0xd3, 0x6a, 0x7e, 0xae, 0xb0, 0x58, 0x6e, 0xbc, 0x1c, 0xd9, 0xe9, 0x60, 0x69, 0x7b, + 0x87, 0xc7, 0xad, 0x85, 0x2c, 0xee, 0xbb, 0x32, 0x89, 0xf9, 0x35, 0x28, 0x6b, 0xc7, 0xf0, 0x75, + 0x50, 0x38, 0xc0, 0x7d, 0x0e, 0x76, 0xcf, 0x4d, 0xbe, 0xc2, 0x17, 0xe0, 0xee, 0x11, 0x0a, 0x7a, + 0x6a, 0x1c, 0x6f, 0x67, 0x95, 0xe3, 0x19, 0x92, 0x72, 0xae, 0xf0, 0xfd, 0x30, 0xbf, 0x6c, 0x58, + 0x6f, 0x81, 0x37, 0x39, 0xc6, 0x17, 0x88, 0x61, 0xca, 0x3a, 0xbe, 0xd7, 0x61, 0x6a, 0x33, 0x8e, + 0x40, 0x75, 0xd8, 0x24, 0xe7, 0x63, 0x83, 0xd9, 0x80, 0x1f, 0x37, 0x5b, 0x01, 0xd9, 0x3b, 0x68, + 0x76, 0x70, 0x62, 0xe6, 0x44, 0x77, 0xdc, 0x07, 0xc2, 0xb4, 0x9a, 0x58, 0x3e, 0xe3, 0x06, 0xb8, + 0x04, 0x1e, 0xa4, 0xfc, 0x93, 0xe5, 0xe5, 0xac, 0xf7, 0xdc, 0xfb, 0x9a, 0xf7, 0xae, 0xdf, 0xc5, + 0xd6, 0x4b, 0xf0, 0x88, 0xd7, 0x5d, 0xc7, 0x6c, 0x57, 0xec, 0xf8, 0x56, 0xb2, 0xe2, 0x6a, 0x8d, + 0x1e, 0x82, 0x62, 0xaa, 0x9a, 0xfc, 0x65, 0xed, 0x83, 0x5a, 0x76, 0x98, 0x44, 0xde, 0x00, 0x33, + 0x4c, 0x3b, 0x97, 0xd7, 0x9a, 0xb9, 0x38, 0x7a, 0xbc, 0x5a, 0x1c, 0x3d, 0xd6, 0xc2, 0x12, 0x71, + 0x25, 0x08, 0xb2, 0x10, 0x3f, 0x05, 0xe0, 0x5a, 0x3a, 0x64, 0xa1, 0x27, 0xb6, 0xd0, 0x19, 0x3b, + 0xd1, 0x19, 0x5b, 0x08, 0x99, 0xd4, 0x19, 0x7b, 0x1b, 0x79, 0x58, 0xc6, 0xba, 0x5a, 0xa4, 0xf5, + 0xbb, 0x21, 0x7b, 0x1a, 0xaa, 0x33, 0xb2, 0xa7, 0xc2, 0x6d, 0x7b, 0x82, 0xeb, 0x29, 0x68, 0xb1, + 0x47, 0x0b, 0x13, 0xa1, 0x05, 0x48, 0x8a, 0x5a, 0xbb, 0xbf, 0x35, 0x21, 0x43, 0x7c, 0xf3, 0x6e, + 0x70, 0x7f, 0xe9, 0xb0, 0xeb, 0x5e, 0xb1, 0x76, 0x3e, 0xee, 0xfe, 0xf4, 0x78, 0xd5, 0xab, 0x1e, + 0xab, 0xdf, 0x5f, 0x16, 0xe2, 0xab, 0xb8, 0xbf, 0x29, 0x7b, 0x2a, 0xdc, 0xb6, 0xa7, 0xff, 0xed, + 0xfe, 0x1a, 0x7f, 0x94, 0xc0, 0x5d, 0x4e, 0x0d, 0x4f, 0x41, 0x51, 0x48, 0x3c, 0x7c, 0x32, 0x5a, + 0xa9, 0xf5, 0x7f, 0x13, 0x73, 0x61, 0xa2, 0x9f, 0x28, 0x68, 0x59, 0xdf, 0xff, 0xf9, 0xef, 0xcf, + 0xf9, 0x1a, 0x34, 0x9d, 0x1d, 0x44, 0xbe, 0x14, 0x01, 0x4e, 0xfa, 0xdf, 0x15, 0xfe, 0x60, 0x80, + 0x92, 0x92, 0x47, 0xb8, 0x38, 0x85, 0x82, 0x0a, 0x86, 0xa7, 0x53, 0x6b, 0xad, 0xf5, 0x2e, 0xa7, + 0xa8, 0xc3, 0x5a, 0x16, 0xc5, 0x95, 0x98, 0xff, 0x64, 0x80, 0xb2, 0x26, 0x82, 0xf0, 0xfd, 0x91, + 0x05, 0x86, 0x55, 0xd4, 0x7c, 0x36, 0x9d, 0xb3, 0x04, 0x5a, 0xe0, 0x40, 0xf3, 0xf0, 0x71, 0x16, + 0x50, 0xa0, 0x31, 0xfc, 0x6a, 0x80, 0x19, 0xfd, 0x91, 0x86, 0xce, 0xc8, 0x3a, 0xd9, 0x3a, 0x6a, + 0x7e, 0x30, 0x7d, 0x80, 0x84, 0x6b, 0x70, 0xb8, 0x67, 0x70, 0x29, 0x0b, 0x2e, 0xf5, 0x3a, 0xe2, + 0x7c, 0x2b, 0x1e, 0xea, 0x53, 0xf8, 0x8b, 0x01, 0xee, 0xeb, 0xc9, 0x56, 0x82, 0x60, 0x0c, 0x6a, + 0xb6, 0x9e, 0x8e, 0x41, 0x1d, 0x21, 0x8c, 0xd6, 0x53, 0x8e, 0xfa, 0x0e, 0x9c, 0x9f, 0x88, 0xca, + 0x27, 0xa9, 0x3f, 0x5c, 0xe3, 0x27, 0x99, 0x21, 0x17, 0xe3, 0x27, 0x99, 0xf5, 0xdc, 0x8f, 0x9f, + 0x64, 0xea, 0xdd, 0x2d, 0x3d, 0x49, 0x3d, 0xd9, 0xc4, 0x49, 0xde, 0x0c, 0x75, 0x84, 0x44, 0x8d, + 0x9f, 0x64, 0x0a, 0x75, 0xf5, 0xe3, 0xb3, 0x8b, 0xba, 0x71, 0x7e, 0x51, 0x37, 0xfe, 0xb9, 0xa8, + 0x1b, 0x3f, 0x5e, 0xd6, 0x73, 0xe7, 0x97, 0xf5, 0xdc, 0x5f, 0x97, 0xf5, 0xdc, 0x37, 0xef, 0x79, + 0x3e, 0xeb, 0xf4, 0x5a, 0xf6, 0x1e, 0xe9, 0x0e, 0xa6, 0x39, 0x11, 0x57, 0xd2, 0x8f, 0x30, 0x6d, + 0x15, 0xf9, 0x8b, 0xea, 0x8b, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x70, 0x79, 0x29, 0xf7, 0xf0, + 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -583,6 +777,10 @@ type QueryClient interface { TimeoutOrder(ctx context.Context, in *QueryGetTimeoutOrderRequest, opts ...grpc.CallOption) (*QueryGetTimeoutOrderResponse, error) // Queries a list of TimeoutOrder items. TimeoutOrderAll(ctx context.Context, in *QueryAllTimeoutOrderRequest, opts ...grpc.CallOption) (*QueryAllTimeoutOrderResponse, error) + // Queries a ExpiredShard by index. + ExpiredShard(ctx context.Context, in *QueryGetExpiredShardRequest, opts ...grpc.CallOption) (*QueryGetExpiredShardResponse, error) + // Queries a list of ExpiredShard items. + ExpiredShardAll(ctx context.Context, in *QueryAllExpiredShardRequest, opts ...grpc.CallOption) (*QueryAllExpiredShardResponse, error) } type queryClient struct { @@ -638,6 +836,24 @@ func (c *queryClient) TimeoutOrderAll(ctx context.Context, in *QueryAllTimeoutOr return out, nil } +func (c *queryClient) ExpiredShard(ctx context.Context, in *QueryGetExpiredShardRequest, opts ...grpc.CallOption) (*QueryGetExpiredShardResponse, error) { + out := new(QueryGetExpiredShardResponse) + err := c.cc.Invoke(ctx, "/saonetwork.sao.sao.Query/ExpiredShard", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ExpiredShardAll(ctx context.Context, in *QueryAllExpiredShardRequest, opts ...grpc.CallOption) (*QueryAllExpiredShardResponse, error) { + out := new(QueryAllExpiredShardResponse) + err := c.cc.Invoke(ctx, "/saonetwork.sao.sao.Query/ExpiredShardAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -650,6 +866,10 @@ type QueryServer interface { TimeoutOrder(context.Context, *QueryGetTimeoutOrderRequest) (*QueryGetTimeoutOrderResponse, error) // Queries a list of TimeoutOrder items. TimeoutOrderAll(context.Context, *QueryAllTimeoutOrderRequest) (*QueryAllTimeoutOrderResponse, error) + // Queries a ExpiredShard by index. + ExpiredShard(context.Context, *QueryGetExpiredShardRequest) (*QueryGetExpiredShardResponse, error) + // Queries a list of ExpiredShard items. + ExpiredShardAll(context.Context, *QueryAllExpiredShardRequest) (*QueryAllExpiredShardResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -671,6 +891,12 @@ func (*UnimplementedQueryServer) TimeoutOrder(ctx context.Context, req *QueryGet func (*UnimplementedQueryServer) TimeoutOrderAll(ctx context.Context, req *QueryAllTimeoutOrderRequest) (*QueryAllTimeoutOrderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TimeoutOrderAll not implemented") } +func (*UnimplementedQueryServer) ExpiredShard(ctx context.Context, req *QueryGetExpiredShardRequest) (*QueryGetExpiredShardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExpiredShard not implemented") +} +func (*UnimplementedQueryServer) ExpiredShardAll(ctx context.Context, req *QueryAllExpiredShardRequest) (*QueryAllExpiredShardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExpiredShardAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -766,6 +992,42 @@ func _Query_TimeoutOrderAll_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_ExpiredShard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetExpiredShardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ExpiredShard(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/saonetwork.sao.sao.Query/ExpiredShard", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ExpiredShard(ctx, req.(*QueryGetExpiredShardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ExpiredShardAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllExpiredShardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ExpiredShardAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/saonetwork.sao.sao.Query/ExpiredShardAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ExpiredShardAll(ctx, req.(*QueryAllExpiredShardRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "saonetwork.sao.sao.Query", HandlerType: (*QueryServer)(nil), @@ -790,6 +1052,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TimeoutOrderAll", Handler: _Query_TimeoutOrderAll_Handler, }, + { + MethodName: "ExpiredShard", + Handler: _Query_ExpiredShard_Handler, + }, + { + MethodName: "ExpiredShardAll", + Handler: _Query_ExpiredShardAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sao/sao/query.proto", @@ -1156,80 +1426,225 @@ func (m *QueryAllTimeoutOrderResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryGetExpiredShardRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n + +func (m *QueryGetExpiredShardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetExpiredShardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *QueryMetadataRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetExpiredShardResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.Proposal.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.JwsSignature.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil } -func (m *QueryMetadataResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetExpiredShardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetExpiredShardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Metadata.Size() - n += 1 + l + sovQuery(uint64(l)) - if len(m.Shards) > 0 { - for k, v := range m.Shards { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) - } - mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + { + size, err := m.ExpiredShard.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - return n + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *QueryLatesthightRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryAllExpiredShardRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l + return dAtA[:n], nil +} + +func (m *QueryAllExpiredShardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllExpiredShardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllExpiredShardResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllExpiredShardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllExpiredShardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ExpiredShard) > 0 { + for iNdEx := len(m.ExpiredShard) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExpiredShard[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Proposal.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.JwsSignature.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Metadata.Size() + n += 1 + l + sovQuery(uint64(l)) + if len(m.Shards) > 0 { + for k, v := range m.Shards { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovQuery(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovQuery(uint64(len(k))) + l + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + return n +} + +func (m *QueryLatesthightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l return n } @@ -1304,6 +1719,61 @@ func (m *QueryAllTimeoutOrderResponse) Size() (n int) { return n } +func (m *QueryGetExpiredShardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryGetExpiredShardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ExpiredShard.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllExpiredShardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllExpiredShardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ExpiredShard) > 0 { + for _, e := range m.ExpiredShard { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2280,6 +2750,364 @@ func (m *QueryAllTimeoutOrderResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetExpiredShardRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetExpiredShardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetExpiredShardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetExpiredShardResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetExpiredShardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetExpiredShardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpiredShard", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ExpiredShard.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllExpiredShardRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllExpiredShardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllExpiredShardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllExpiredShardResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllExpiredShardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllExpiredShardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpiredShard", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExpiredShard = append(m.ExpiredShard, ExpiredShard{}) + if err := m.ExpiredShard[len(m.ExpiredShard)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/sao/types/query.pb.gw.go b/x/sao/types/query.pb.gw.go index 4b30b5bb..b4ce919c 100644 --- a/x/sao/types/query.pb.gw.go +++ b/x/sao/types/query.pb.gw.go @@ -195,6 +195,96 @@ func local_request_Query_TimeoutOrderAll_0(ctx context.Context, marshaler runtim } +func request_Query_ExpiredShard_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetExpiredShardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := client.ExpiredShard(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ExpiredShard_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetExpiredShardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := server.ExpiredShard(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ExpiredShardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ExpiredShardAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllExpiredShardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExpiredShardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ExpiredShardAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ExpiredShardAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllExpiredShardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ExpiredShardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ExpiredShardAll(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -316,6 +406,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ExpiredShard_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ExpiredShard_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ExpiredShard_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ExpiredShardAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ExpiredShardAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ExpiredShardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -457,6 +593,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ExpiredShard_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ExpiredShard_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ExpiredShard_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ExpiredShardAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ExpiredShardAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ExpiredShardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -470,6 +646,10 @@ var ( pattern_Query_TimeoutOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"SaoNetwork", "sao", "timeout_order", "height"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_TimeoutOrderAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 2, 2}, []string{"SaoNetwork", "sao", "timeout_order"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ExpiredShard_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"SaoNetwork", "sao", "expired_shard", "height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ExpiredShardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 2, 2}, []string{"SaoNetwork", "sao", "expired_shard"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -482,4 +662,8 @@ var ( forward_Query_TimeoutOrder_0 = runtime.ForwardResponseMessage forward_Query_TimeoutOrderAll_0 = runtime.ForwardResponseMessage + + forward_Query_ExpiredShard_0 = runtime.ForwardResponseMessage + + forward_Query_ExpiredShardAll_0 = runtime.ForwardResponseMessage ) From 3c15e25a051bd3a140295d575e905160b9c673c7 Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Tue, 23 May 2023 11:31:54 +0800 Subject: [PATCH 5/8] feat: pledge_debt, refactor node module funcs (#51) --- CHANGELOG.md | 4 + docs/static/openapi.yml | 283 ++++ proto/sao/node/genesis.proto | 2 + proto/sao/node/pledge_debt.proto | 13 + proto/sao/node/query.proto | 32 +- x/model/keeper/data_management.go | 2 +- x/model/types/expected_keepers.go | 2 +- x/node/client/cli/query.go | 2 + x/node/client/cli/query_pledge_debt.go | 73 + x/node/client/cli/query_pledge_debt_test.go | 161 ++ x/node/genesis.go | 5 + x/node/genesis_test.go | 9 + x/node/keeper/grpc_query_pledge_debt.go | 57 + x/node/keeper/grpc_query_pledge_debt_test.go | 126 ++ x/node/keeper/msg_server_claim_reward.go | 62 +- x/node/keeper/pledge_debt.go | 63 + x/node/keeper/pledge_debt_test.go | 63 + x/node/keeper/shard_pledge_management.go | 119 +- x/node/types/genesis.go | 15 +- x/node/types/genesis.pb.go | 110 +- x/node/types/genesis_test.go | 22 + x/node/types/key_pledge_debt.go | 23 + x/node/types/pledge_debt.pb.go | 374 +++++ x/node/types/query.pb.go | 1486 ++++++++++++++---- x/node/types/query.pb.gw.go | 184 +++ x/sao/keeper/expire_management.go | 2 +- x/sao/keeper/msg_server_cancel.go | 2 +- x/sao/keeper/msg_server_complete.go | 4 +- x/sao/types/expected_keepers.go | 4 +- 29 files changed, 2866 insertions(+), 438 deletions(-) create mode 100644 proto/sao/node/pledge_debt.proto create mode 100644 x/node/client/cli/query_pledge_debt.go create mode 100644 x/node/client/cli/query_pledge_debt_test.go create mode 100644 x/node/keeper/grpc_query_pledge_debt.go create mode 100644 x/node/keeper/grpc_query_pledge_debt_test.go create mode 100644 x/node/keeper/pledge_debt.go create mode 100644 x/node/keeper/pledge_debt_test.go create mode 100644 x/node/types/key_pledge_debt.go create mode 100644 x/node/types/pledge_debt.pb.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 739a6c63..b2a88202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ ## [Unreleased] +### Features +- expired shard ([#49](https://github.com/SAONetwork/sao-consensus/issues/49)) +- storage pledge baseline ([#48](https://github.com/SAONetwork/sao-consensus/issues/48)) + ### Bug Fixes - export/import issue ([#44](https://github.com/SAONetwork/sao-consensus/issues/44)) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 273dc522..03b04a26 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -45799,6 +45799,198 @@ paths: type: string tags: - Query + /SaoNetwork/sao/node/pledge_debt: + get: + summary: Queries a list of PledgeDebt items. + operationId: SaonetworkSaoNodePledgeDebtAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pledgeDebt: + type: array + items: + type: object + properties: + sp: + type: string + debt: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /SaoNetwork/sao/node/pledge_debt/{sp}: + get: + summary: Queries a PledgeDebt by index. + operationId: SaonetworkSaoNodePledgeDebt + responses: + '200': + description: A successful response. + schema: + type: object + properties: + pledgeDebt: + type: object + properties: + sp: + type: string + debt: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: sp + in: path + required: true + type: string + tags: + - Query /SaoNetwork/sao/node/pool: get: summary: Queries a Pool by index. @@ -75582,6 +75774,23 @@ definitions: total_storage: type: string format: int64 + saonetwork.sao.node.PledgeDebt: + type: object + properties: + sp: + type: string + debt: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. saonetwork.sao.node.Pool: type: object properties: @@ -75727,6 +75936,57 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + saonetwork.sao.node.QueryAllPledgeDebtResponse: + type: object + properties: + pledgeDebt: + type: array + items: + type: object + properties: + sp: + type: string + debt: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } saonetwork.sao.node.QueryAllPledgeResponse: type: object properties: @@ -75849,6 +76109,29 @@ definitions: type: string website: type: string + saonetwork.sao.node.QueryGetPledgeDebtResponse: + type: object + properties: + pledgeDebt: + type: object + properties: + sp: + type: string + debt: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. saonetwork.sao.node.QueryGetPledgeResponse: type: object properties: diff --git a/proto/sao/node/genesis.proto b/proto/sao/node/genesis.proto index 1efd3edb..481e59d9 100644 --- a/proto/sao/node/genesis.proto +++ b/proto/sao/node/genesis.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "sao/node/params.proto"; import "sao/node/node.proto"; import "sao/node/pool.proto"; +import "sao/node/pledge_debt.proto"; import "sao/node/pledge.proto"; // this line is used by starport scaffolding # genesis/proto/import @@ -16,5 +17,6 @@ message GenesisState { Pool pool = 2; repeated Node nodeList = 3 [(gogoproto.nullable) = false]; repeated Pledge pledgeList = 4 [(gogoproto.nullable) = false]; + repeated PledgeDebt pledgeDebtList = 5 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/sao/node/pledge_debt.proto b/proto/sao/node/pledge_debt.proto new file mode 100644 index 00000000..184d2549 --- /dev/null +++ b/proto/sao/node/pledge_debt.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package saonetwork.sao.node; + +option go_package = "github.com/SaoNetwork/sao/x/node/types"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +message PledgeDebt { + string sp = 1; + cosmos.base.v1beta1.Coin debt = 2 [(gogoproto.nullable) = false]; + +} + diff --git a/proto/sao/node/query.proto b/proto/sao/node/query.proto index f925d395..8b7e5a6f 100644 --- a/proto/sao/node/query.proto +++ b/proto/sao/node/query.proto @@ -1,14 +1,16 @@ syntax = "proto3"; package saonetwork.sao.node; -import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "sao/node/params.proto"; import "sao/node/node.proto"; import "sao/node/pool.proto"; import "sao/node/pledge.proto"; +import "sao/node/pledge_debt.proto"; // this line is used by starport scaffolding # 1 +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/SaoNetwork/sao/x/node/types"; @@ -44,6 +46,16 @@ service Query { } +// Queries a PledgeDebt by index. + rpc PledgeDebt(QueryGetPledgeDebtRequest) returns (QueryGetPledgeDebtResponse) { + option (google.api.http).get = "/SaoNetwork/sao/node/pledge_debt/{sp}"; + } + + // Queries a list of PledgeDebt items. + rpc PledgeDebtAll(QueryAllPledgeDebtRequest) returns (QueryAllPledgeDebtResponse) { + option (google.api.http).get = "/SaoNetwork/sao/node/pledge_debt"; + } + // this line is used by starport scaffolding # 2 } @@ -99,5 +111,23 @@ message QueryAllPledgeResponse { } +message QueryGetPledgeDebtRequest { + string sp = 1; + +} + +message QueryGetPledgeDebtResponse { + PledgeDebt pledgeDebt = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllPledgeDebtRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllPledgeDebtResponse { + repeated PledgeDebt pledgeDebt = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // this line is used by starport scaffolding # 3 diff --git a/x/model/keeper/data_management.go b/x/model/keeper/data_management.go index ad6415df..4b3b2600 100644 --- a/x/model/keeper/data_management.go +++ b/x/model/keeper/data_management.go @@ -248,7 +248,7 @@ func (k Keeper) TerminateOrder(ctx sdk.Context, order ordertypes.Order) error { continue } if shard.Status == ordertypes.ShardCompleted { - err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) + err := k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) if err != nil { return err } diff --git a/x/model/types/expected_keepers.go b/x/model/types/expected_keepers.go index 64b14be6..0462f085 100644 --- a/x/model/types/expected_keepers.go +++ b/x/model/types/expected_keepers.go @@ -37,7 +37,7 @@ type OrderKeeper interface { // SaoKeeper type NodeKeeper interface { GetNode(ctx sdk.Context, creator string) (val nodetypes.Node, found bool) - OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error + ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error } // DidKeeper diff --git a/x/node/client/cli/query.go b/x/node/client/cli/query.go index 2f722b92..98655d9f 100644 --- a/x/node/client/cli/query.go +++ b/x/node/client/cli/query.go @@ -30,6 +30,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdShowPool()) cmd.AddCommand(CmdListPledge()) cmd.AddCommand(CmdShowPledge()) + cmd.AddCommand(CmdListPledgeDebt()) + cmd.AddCommand(CmdShowPledgeDebt()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/node/client/cli/query_pledge_debt.go b/x/node/client/cli/query_pledge_debt.go new file mode 100644 index 00000000..2493be53 --- /dev/null +++ b/x/node/client/cli/query_pledge_debt.go @@ -0,0 +1,73 @@ +package cli + +import ( + "context" + + "github.com/SaoNetwork/sao/x/node/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdListPledgeDebt() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-pledge-debt", + Short: "list all PledgeDebt", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllPledgeDebtRequest{ + Pagination: pageReq, + } + + res, err := queryClient.PledgeDebtAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowPledgeDebt() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-pledge-debt [sp]", + Short: "shows a PledgeDebt", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argSp := args[0] + + params := &types.QueryGetPledgeDebtRequest{ + Sp: argSp, + } + + res, err := queryClient.PledgeDebt(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/node/client/cli/query_pledge_debt_test.go b/x/node/client/cli/query_pledge_debt_test.go new file mode 100644 index 00000000..d3f9d340 --- /dev/null +++ b/x/node/client/cli/query_pledge_debt_test.go @@ -0,0 +1,161 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/SaoNetwork/sao/testutil/network" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/node/client/cli" + "github.com/SaoNetwork/sao/x/node/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithPledgeDebtObjects(t *testing.T, n int) (*network.Network, []types.PledgeDebt) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + pledgeDebt := types.PledgeDebt{ + Sp: strconv.Itoa(i), + } + nullify.Fill(&pledgeDebt) + state.PledgeDebtList = append(state.PledgeDebtList, pledgeDebt) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.PledgeDebtList +} + +func TestShowPledgeDebt(t *testing.T) { + net, objs := networkWithPledgeDebtObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idSp string + + args []string + err error + obj types.PledgeDebt + }{ + { + desc: "found", + idSp: objs[0].Sp, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idSp: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idSp, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowPledgeDebt(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetPledgeDebtResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.PledgeDebt) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.PledgeDebt), + ) + } + }) + } +} + +func TestListPledgeDebt(t *testing.T) { + net, objs := networkWithPledgeDebtObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListPledgeDebt(), args) + require.NoError(t, err) + var resp types.QueryAllPledgeDebtResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.PledgeDebt), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.PledgeDebt), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListPledgeDebt(), args) + require.NoError(t, err) + var resp types.QueryAllPledgeDebtResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.PledgeDebt), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.PledgeDebt), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListPledgeDebt(), args) + require.NoError(t, err) + var resp types.QueryAllPledgeDebtResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.PledgeDebt), + ) + }) +} diff --git a/x/node/genesis.go b/x/node/genesis.go index f88ade04..16b1f096 100644 --- a/x/node/genesis.go +++ b/x/node/genesis.go @@ -12,6 +12,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.NodeList { k.SetNode(ctx, elem) } + // Set all the pledgeDebt + for _, elem := range genState.PledgeDebtList { + k.SetPledgeDebt(ctx, elem) + } for _, elem := range genState.PledgeList { k.SetPledge(ctx, elem) } @@ -32,6 +36,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.Pool = &pool } genesis.PledgeList = k.GetAllPledge(ctx) + genesis.PledgeDebtList = k.GetAllPledgeDebt(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/node/genesis_test.go b/x/node/genesis_test.go index 257060ef..a17fcf65 100644 --- a/x/node/genesis_test.go +++ b/x/node/genesis_test.go @@ -22,6 +22,14 @@ func TestGenesis(t *testing.T) { Creator: "1", }, }, + PledgeDebtList: []types.PledgeDebt{ + { + Sp: "0", + }, + { + Sp: "1", + }, + }, // this line is used by starport scaffolding # genesis/test/state } @@ -34,5 +42,6 @@ func TestGenesis(t *testing.T) { nullify.Fill(got) require.ElementsMatch(t, genesisState.NodeList, got.NodeList) + require.ElementsMatch(t, genesisState.PledgeDebtList, got.PledgeDebtList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/node/keeper/grpc_query_pledge_debt.go b/x/node/keeper/grpc_query_pledge_debt.go new file mode 100644 index 00000000..bd70dd9d --- /dev/null +++ b/x/node/keeper/grpc_query_pledge_debt.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + "github.com/SaoNetwork/sao/x/node/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) PledgeDebtAll(c context.Context, req *types.QueryAllPledgeDebtRequest) (*types.QueryAllPledgeDebtResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var pledgeDebts []types.PledgeDebt + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + pledgeDebtStore := prefix.NewStore(store, types.KeyPrefix(types.PledgeDebtKeyPrefix)) + + pageRes, err := query.Paginate(pledgeDebtStore, req.Pagination, func(key []byte, value []byte) error { + var pledgeDebt types.PledgeDebt + if err := k.cdc.Unmarshal(value, &pledgeDebt); err != nil { + return err + } + + pledgeDebts = append(pledgeDebts, pledgeDebt) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllPledgeDebtResponse{PledgeDebt: pledgeDebts, Pagination: pageRes}, nil +} + +func (k Keeper) PledgeDebt(c context.Context, req *types.QueryGetPledgeDebtRequest) (*types.QueryGetPledgeDebtResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetPledgeDebt( + ctx, + req.Sp, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetPledgeDebtResponse{PledgeDebt: val}, nil +} diff --git a/x/node/keeper/grpc_query_pledge_debt_test.go b/x/node/keeper/grpc_query_pledge_debt_test.go new file mode 100644 index 00000000..d82fd2a5 --- /dev/null +++ b/x/node/keeper/grpc_query_pledge_debt_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/SaoNetwork/sao/testutil/keeper" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/node/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestPledgeDebtQuerySingle(t *testing.T) { + keeper, ctx := keepertest.NodeKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPledgeDebt(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetPledgeDebtRequest + response *types.QueryGetPledgeDebtResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetPledgeDebtRequest{ + Sp: msgs[0].Sp, + }, + response: &types.QueryGetPledgeDebtResponse{PledgeDebt: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetPledgeDebtRequest{ + Sp: msgs[1].Sp, + }, + response: &types.QueryGetPledgeDebtResponse{PledgeDebt: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetPledgeDebtRequest{ + Sp: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.PledgeDebt(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestPledgeDebtQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.NodeKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNPledgeDebt(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPledgeDebtRequest { + return &types.QueryAllPledgeDebtRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.PledgeDebtAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.PledgeDebt), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.PledgeDebt), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.PledgeDebtAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.PledgeDebt), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.PledgeDebt), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.PledgeDebtAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.PledgeDebt), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.PledgeDebtAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/node/keeper/msg_server_claim_reward.go b/x/node/keeper/msg_server_claim_reward.go index f4598e54..5df3199c 100644 --- a/x/node/keeper/msg_server_claim_reward.go +++ b/x/node/keeper/msg_server_claim_reward.go @@ -3,6 +3,7 @@ package keeper import ( "context" + markettypes "github.com/SaoNetwork/sao/x/market/types" "github.com/SaoNetwork/sao/x/node/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -20,7 +21,7 @@ func (k msgServer) ClaimReward(goCtx context.Context, msg *types.MsgClaimReward) logger := k.Logger(ctx) - k.OrderRelease(ctx, msg.GetSigners()[0], nil) + k.ShardRelease(ctx, msg.GetSigners()[0], nil) pledge, _ = k.GetPledge(ctx, msg.Creator) @@ -38,22 +39,61 @@ func (k msgServer) ClaimReward(goCtx context.Context, msg *types.MsgClaimReward) pledge.Reward = remainReward - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{claimReward}) - - if err != nil { - return nil, err - } - logger.Debug("CoinTrace: claim reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", claimReward.String()) - - k.SetPledge(ctx, pledge) - // claim worker reward workerReward, err := k.market.Claim(ctx, claimReward.Denom, msg.Creator) if err != nil { return nil, err } - claimReward.Add(workerReward) + pledgeDebt, found := k.GetPledgeDebt(ctx, msg.Creator) + if found { + logger.Debug("CoinTrace: repay pledge debt", "blockReward", claimReward.String(), "orderReward", workerReward.String(), "debt", pledgeDebt.Debt.String()) + if pledgeDebt.Debt.IsLT(claimReward) { + finalClaim := claimReward.Sub(pledgeDebt.Debt) + logger.Debug("CoinTrace: claim reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", finalClaim.String()) + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{finalClaim}) + if err != nil { + return nil, err + } + k.RemovePledgeDebt(ctx, msg.Creator) + logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", workerReward.String()) + err = k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{workerReward}) + } else { + pledgeDebt.Debt = pledgeDebt.Debt.Sub(claimReward) + + if pledgeDebt.Debt.IsLT(workerReward) { + finalClaim := workerReward.Sub(pledgeDebt.Debt) + logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", finalClaim.String()) + err := k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{finalClaim}) + if err != nil { + return nil, err + } + k.RemovePledgeDebt(ctx, msg.Creator) + } else { + pledgeDebt.Debt = pledgeDebt.Debt.Sub(workerReward) + k.SetPledgeDebt(ctx, pledgeDebt) + } + } + } else { + logger.Debug("CoinTrace: claim reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", claimReward.String()) + if !claimReward.IsZero() { + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{claimReward}) + if err != nil { + return nil, err + } + } + if !workerReward.IsZero() { + logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", workerReward.String()) + err = k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{workerReward}) + if err != nil { + return nil, err + } + } + } + + k.SetPledge(ctx, pledge) + + claimReward = claimReward.Add(workerReward) return &types.MsgClaimRewardResponse{ ClaimedReward: claimReward.Amount.Uint64(), diff --git a/x/node/keeper/pledge_debt.go b/x/node/keeper/pledge_debt.go new file mode 100644 index 00000000..8aba088d --- /dev/null +++ b/x/node/keeper/pledge_debt.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "github.com/SaoNetwork/sao/x/node/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetPledgeDebt set a specific pledgeDebt in the store from its index +func (k Keeper) SetPledgeDebt(ctx sdk.Context, pledgeDebt types.PledgeDebt) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeDebtKeyPrefix)) + b := k.cdc.MustMarshal(&pledgeDebt) + store.Set(types.PledgeDebtKey( + pledgeDebt.Sp, + ), b) +} + +// GetPledgeDebt returns a pledgeDebt from its index +func (k Keeper) GetPledgeDebt( + ctx sdk.Context, + sp string, + +) (val types.PledgeDebt, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeDebtKeyPrefix)) + + b := store.Get(types.PledgeDebtKey( + sp, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemovePledgeDebt removes a pledgeDebt from the store +func (k Keeper) RemovePledgeDebt( + ctx sdk.Context, + sp string, + +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeDebtKeyPrefix)) + store.Delete(types.PledgeDebtKey( + sp, + )) +} + +// GetAllPledgeDebt returns all pledgeDebt +func (k Keeper) GetAllPledgeDebt(ctx sdk.Context) (list []types.PledgeDebt) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeDebtKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PledgeDebt + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/node/keeper/pledge_debt_test.go b/x/node/keeper/pledge_debt_test.go new file mode 100644 index 00000000..4f19e323 --- /dev/null +++ b/x/node/keeper/pledge_debt_test.go @@ -0,0 +1,63 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/SaoNetwork/sao/testutil/keeper" + "github.com/SaoNetwork/sao/testutil/nullify" + "github.com/SaoNetwork/sao/x/node/keeper" + "github.com/SaoNetwork/sao/x/node/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNPledgeDebt(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.PledgeDebt { + items := make([]types.PledgeDebt, n) + for i := range items { + items[i].Sp = strconv.Itoa(i) + + keeper.SetPledgeDebt(ctx, items[i]) + } + return items +} + +func TestPledgeDebtGet(t *testing.T) { + keeper, ctx := keepertest.NodeKeeper(t) + items := createNPledgeDebt(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetPledgeDebt(ctx, + item.Sp, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestPledgeDebtRemove(t *testing.T) { + keeper, ctx := keepertest.NodeKeeper(t) + items := createNPledgeDebt(keeper, ctx, 10) + for _, item := range items { + keeper.RemovePledgeDebt(ctx, + item.Sp, + ) + _, found := keeper.GetPledgeDebt(ctx, + item.Sp, + ) + require.False(t, found) + } +} + +func TestPledgeDebtGetAll(t *testing.T) { + keeper, ctx := keepertest.NodeKeeper(t) + items := createNPledgeDebt(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllPledgeDebt(ctx)), + ) +} diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 53fba215..3e739103 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -5,8 +5,6 @@ import ( ordertypes "github.com/SaoNetwork/sao/x/order/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) const ( @@ -18,14 +16,14 @@ const ( CirculatingDenominator = 10 ) -func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error { +func (k Keeper) ShardPledge(ctx sdk.Context, shard *ordertypes.Shard, unitPrice sdk.DecCoin) error { - pledge, foundPledge := k.GetPledge(ctx, sp.String()) + pledge, foundPledge := k.GetPledge(ctx, shard.Sp) denom := k.staking.BondDenom(ctx) if !foundPledge { pledge = types.Pledge{ - Creator: sp.String(), + Creator: shard.Sp, TotalStoragePledged: sdk.NewInt64Coin(denom, 0), Reward: sdk.NewInt64DecCoin(denom, 0), RewardDebt: sdk.NewInt64DecCoin(denom, 0), @@ -47,8 +45,8 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype if pledge.TotalStorage > 0 { pending := pool.AccRewardPerByte.Amount.MulInt64(pledge.TotalStorage).Sub(pledge.RewardDebt.Amount) logger.Debug("PledgeTrace: order pledge 1", - "sp", sp.String(), - "orderId", order.Id, + "sp", shard.Sp, + "orderId", shard.OrderId, "reward", pledge.Reward.String(), "accRewardPerByte", pool.AccRewardPerByte.String(), "totalStorage", pledge.TotalStorage, @@ -57,20 +55,16 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype pledge.Reward.Amount = pledge.Reward.Amount.Add(pending) } - shardPledge := sdk.NewInt64Coin(order.Amount.Denom, 0) + shardPledge := sdk.NewInt64Coin(denom, 0) - shard := k.order.GetOrderShardBySP(ctx, order, sp.String()) - if shard == nil { - return status.Errorf(codes.NotFound, "shard of %s not found", sp) - } logger.Debug("PoolTrace: order pledge", "totalStorage", pool.TotalStorage, "shardSize", shard.Size_) pool.TotalStorage += int64(shard.Size_) logger.Debug("PledgeTrace: order pledge 2", - "sp", sp.String(), - "orderId", order.Id, + "sp", shard.Sp, + "orderId", shard.OrderId, "totalStorage", pledge.TotalStorage, "shardSizeToAdd", shard.Size_) pledge.TotalStorage += int64(shard.Size_) @@ -89,7 +83,7 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype storageDecPledge.Amount.AddMut(projectionPeriodPledge) // 2. order price N%. collateral amount can be negotiated between client and SP in the future. - orderAmountPledge := k.StoreRewardPledge(shard.Duration, shard.Size_, order.UnitPrice) + orderAmountPledge := k.StoreRewardPledge(shard.Duration, shard.Size_, unitPrice) logger.Debug("pledge ", "part2", orderAmountPledge) storageDecPledge.Amount.AddMut(orderAmountPledge) @@ -97,14 +91,14 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype // pool, found := k.GetPool(ctx) // if found { // concensusPledge := sdk.NewDecFromInt( - // pool.TotalReward.Amount.MulRaw(int64(order.Shards[sp.String()].Size_ * CirculatingNumerator)). + // pool.TotalReward.Amount.MulRaw(int64(order.Shards[shard.Sp].Size_ * CirculatingNumerator)). // QuoRaw(CirculatingDenominator * pool.TotalStorage), // ) // logger.Debug("pledge part3: ", concensusPledge) // storageDecPledge.Amount.AddMut(concensusPledge) // } - logger.Debug("order pledge ", "amount", storageDecPledge, "pool", pool.TotalStorage, "reward_per_byte", rewardPerByte, "size", shard.Size_, "duration", order.Duration) + logger.Debug("order pledge ", "amount", storageDecPledge, "pool", pool.TotalStorage, "reward_per_byte", rewardPerByte, "size", shard.Size_, "duration", shard.Duration) var dec sdk.DecCoin shardPledge, dec = storageDecPledge.TruncateDecimal() if !dec.IsZero() { @@ -117,14 +111,15 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype pool.TotalPledged = pool.TotalPledged.Add(shardPledge) } - order_pledge_err := k.bank.SendCoinsFromAccountToModule(ctx, sp, types.ModuleName, coins) + var err error + err = k.bank.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(shard.Sp), types.ModuleName, coins) - if order_pledge_err != nil { - return order_pledge_err + if err != nil { + return err } logger.Debug("CoinTrace: order pledge", - "from", sp.String(), + "from", shard.Sp, "to", types.ModuleName, "amount", coins.String()) @@ -132,8 +127,8 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype newRewardDebt := pool.AccRewardPerByte.Amount.MulInt64(pledge.TotalStorage) logger.Debug("PledgeTrace: order pledge 3", - "sp", sp.String(), - "orderId", order.Id, + "sp", shard.Sp, + "orderId", shard.OrderId, "rewardDebt", pledge.RewardDebt.String(), "accRewardPerByte", pool.AccPledgePerByte.String(), "totalStorage", pledge.TotalStorage, @@ -148,7 +143,7 @@ func (k Keeper) OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertype return nil } -func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error { +func (k Keeper) ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertypes.Shard) error { logger := k.Logger(ctx) pledge, foundPledge := k.GetPledge(ctx, sp.String()) @@ -185,15 +180,32 @@ func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp shardPledge := shard.Pledge - coins = coins.Add(shardPledge) - logger.Debug("CoinTrace: order release", - "from", types.ModuleName, - "to", sp.String(), - "amount", coins.String()) - - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, coins) - if err != nil { - return err + pledgeDebt, found := k.GetPledgeDebt(ctx, shard.Sp) + if found { + if pledgeDebt.Debt.IsLT(shardPledge) { + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, sdk.Coins{shardPledge.Sub(pledgeDebt.Debt)}) + if err != nil { + return err + } + + k.RemovePledgeDebt(ctx, shard.Sp) + } else { + pledgeDebt.Debt = pledgeDebt.Debt.Sub(shardPledge) + + k.SetPledgeDebt(ctx, pledgeDebt) + } + } else { + + coins = coins.Add(shardPledge) + logger.Debug("CoinTrace: order release", + "from", types.ModuleName, + "to", sp.String(), + "amount", coins.String()) + + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, coins) + if err != nil { + return err + } } pledge.TotalStorage -= int64(shard.Size_) @@ -225,47 +237,6 @@ func (k Keeper) OrderRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp return nil } -func (k Keeper) OrderSlash(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error { - if order == nil { - return status.Errorf(codes.NotFound, "order %d not found", order.Id) - } - - pledge, foundPledge := k.GetPledge(ctx, sp.String()) - - if !foundPledge { - return sdkerrors.Wrap(types.ErrPledgeNotFound, "") - } - - pool, foundPool := k.GetPool(ctx) - - if !foundPool { - return sdkerrors.Wrap(types.ErrPoolNotFound, "") - } - - if pledge.TotalStorage > 0 { - pending := pool.AccRewardPerByte.Amount.MulInt64(pledge.TotalStorage).Sub(pledge.RewardDebt.Amount) - pledge.Reward.Amount = pledge.Reward.Amount.Add(pending) - pledge.RewardDebt.Amount = pool.AccPledgePerByte.Amount.MulInt64(pledge.TotalStorage) - } - - shard := k.order.GetOrderShardBySP(ctx, order, sp.String()) - if shard == nil { - return status.Errorf(codes.NotFound, "shard of %s not found", sp) - } - - shardPledge := shard.Pledge - - pledge.TotalStoragePledged = pledge.TotalStoragePledged.Sub(shardPledge) - - pledge.TotalStorage -= int64(shard.Size_) - - pool.TotalPledged = pool.TotalPledged.Sub(shardPledge) - - k.SetPledge(ctx, pledge) - - return nil -} - // //func (Keeper) OrderPricePledge(remainingDuration, duration uint64, amount sdk.Int, replica int32) sdk.Dec { // // 2. order price N%. collateral amount can be negotiated between client and SP in the future. diff --git a/x/node/types/genesis.go b/x/node/types/genesis.go index fe7e3cbe..19807638 100644 --- a/x/node/types/genesis.go +++ b/x/node/types/genesis.go @@ -20,8 +20,9 @@ func DefaultGenesis() *GenesisState { RewardedBlockCount: 0, } return &GenesisState{ - Pool: &pool, - NodeList: []Node{}, + Pool: &pool, + NodeList: []Node{}, + PledgeDebtList: []PledgeDebt{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -40,6 +41,16 @@ func (gs GenesisState) Validate() error { } nodeIndexMap[index] = struct{}{} } + // Check for duplicated index in pledgeDebt + pledgeDebtIndexMap := make(map[string]struct{}) + + for _, elem := range gs.PledgeDebtList { + index := string(PledgeDebtKey(elem.Sp)) + if _, ok := pledgeDebtIndexMap[index]; ok { + return fmt.Errorf("duplicated index for pledgeDebt") + } + pledgeDebtIndexMap[index] = struct{}{} + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/node/types/genesis.pb.go b/x/node/types/genesis.pb.go index 699dd8cc..fb32eeec 100644 --- a/x/node/types/genesis.pb.go +++ b/x/node/types/genesis.pb.go @@ -25,10 +25,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the node module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - Pool *Pool `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` - NodeList []Node `protobuf:"bytes,3,rep,name=nodeList,proto3" json:"nodeList"` - PledgeList []Pledge `protobuf:"bytes,4,rep,name=pledgeList,proto3" json:"pledgeList"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Pool *Pool `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` + NodeList []Node `protobuf:"bytes,3,rep,name=nodeList,proto3" json:"nodeList"` + PledgeList []Pledge `protobuf:"bytes,4,rep,name=pledgeList,proto3" json:"pledgeList"` + PledgeDebtList []PledgeDebt `protobuf:"bytes,5,rep,name=pledgeDebtList,proto3" json:"pledgeDebtList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -92,6 +93,13 @@ func (m *GenesisState) GetPledgeList() []Pledge { return nil } +func (m *GenesisState) GetPledgeDebtList() []PledgeDebt { + if m != nil { + return m.PledgeDebtList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "saonetwork.sao.node.GenesisState") } @@ -99,25 +107,27 @@ func init() { func init() { proto.RegisterFile("sao/node/genesis.proto", fileDescriptor_4f8106b05cd6903f) } var fileDescriptor_4f8106b05cd6903f = []byte{ - // 282 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x4e, 0xcc, 0xd7, - 0xcf, 0xcb, 0x4f, 0x49, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0x12, 0x2e, 0x4e, 0xcc, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, - 0x4e, 0xcc, 0xd7, 0x03, 0x29, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, - 0x10, 0xa5, 0x52, 0xa2, 0x70, 0x23, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x26, 0x48, 0x09, 0xc3, - 0x85, 0x41, 0x04, 0x86, 0x60, 0x41, 0x7e, 0x7e, 0x0e, 0xa6, 0x01, 0x39, 0xa9, 0x29, 0xe9, 0x50, - 0xb5, 0x4a, 0x3f, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x8e, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, - 0xe4, 0x62, 0x83, 0xd8, 0x20, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x91, - 0x7a, 0x01, 0x60, 0x25, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x35, 0x08, 0xe9, 0x72, - 0xb1, 0x80, 0x2c, 0x94, 0x60, 0x02, 0x6b, 0x94, 0xc4, 0xae, 0x31, 0x3f, 0x3f, 0x27, 0x08, 0xac, - 0x4c, 0xc8, 0x9a, 0x8b, 0x03, 0x24, 0xe4, 0x93, 0x59, 0x5c, 0x22, 0xc1, 0xac, 0xc0, 0x8c, 0x53, - 0x8b, 0x5f, 0x7e, 0x4a, 0x2a, 0xd4, 0x26, 0xb8, 0x06, 0x21, 0x47, 0x2e, 0x2e, 0x88, 0x3f, 0xc0, - 0xda, 0x59, 0xc0, 0xda, 0x71, 0x38, 0x15, 0xac, 0x0c, 0x6a, 0x00, 0x92, 0x26, 0x27, 0x87, 0x13, - 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, - 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x0f, 0x4e, 0xcc, 0xf7, 0x83, 0x18, 0xa9, 0x0f, 0x0a, 0xc1, 0x0a, - 0x48, 0x18, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xc3, 0xd0, 0x18, 0x10, 0x00, 0x00, - 0xff, 0xff, 0x15, 0xd4, 0x80, 0x05, 0xe0, 0x01, 0x00, 0x00, + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x3f, 0x4b, 0xc3, 0x40, + 0x18, 0xc6, 0x93, 0x36, 0x16, 0x39, 0xc5, 0xe1, 0xaa, 0x12, 0x23, 0x5c, 0x8b, 0x83, 0xb8, 0x78, + 0x01, 0x9d, 0xc4, 0x45, 0x8b, 0xe0, 0xa2, 0x45, 0xda, 0xcd, 0x45, 0x2e, 0xe6, 0x88, 0xc1, 0x34, + 0x6f, 0xc8, 0x9d, 0xa8, 0xdf, 0xc2, 0x6f, 0x65, 0xc7, 0x8e, 0x4e, 0x22, 0xc9, 0x17, 0x91, 0xfb, + 0x43, 0x14, 0xdb, 0xba, 0x94, 0xe6, 0xb9, 0xe7, 0xf7, 0xbb, 0xf7, 0x78, 0xd1, 0xb6, 0x60, 0x10, + 0xe6, 0x10, 0xf3, 0x30, 0xe1, 0x39, 0x17, 0xa9, 0xa0, 0x45, 0x09, 0x12, 0x70, 0x57, 0x30, 0xc8, + 0xb9, 0x7c, 0x86, 0xf2, 0x91, 0x0a, 0x06, 0x54, 0x55, 0x82, 0xcd, 0x04, 0x12, 0xd0, 0xe7, 0xa1, + 0xfa, 0x67, 0xaa, 0xc1, 0x56, 0xa3, 0x28, 0x58, 0xc9, 0x26, 0xd6, 0x10, 0x74, 0x9b, 0x58, 0xfd, + 0xcc, 0x85, 0x05, 0x40, 0x66, 0xc3, 0xe0, 0x27, 0xcc, 0x78, 0x9c, 0xf0, 0xbb, 0x98, 0x47, 0x72, + 0x5e, 0xae, 0xcf, 0x4c, 0xbc, 0xf7, 0xde, 0x42, 0xeb, 0x97, 0x66, 0xe0, 0xb1, 0x64, 0x92, 0xe3, + 0x13, 0xd4, 0x31, 0xb7, 0xfb, 0x6e, 0xdf, 0x3d, 0x58, 0x3b, 0xda, 0xa5, 0x0b, 0x1e, 0x40, 0x6f, + 0x74, 0x65, 0xe0, 0x4d, 0x3f, 0x7b, 0xce, 0xc8, 0x02, 0xf8, 0x10, 0x79, 0x6a, 0x18, 0xbf, 0xa5, + 0xc1, 0x9d, 0xc5, 0x20, 0x40, 0x36, 0xd2, 0x35, 0x7c, 0x8a, 0x56, 0x55, 0x74, 0x95, 0x0a, 0xe9, + 0xb7, 0xfb, 0xed, 0xa5, 0xc8, 0x10, 0x62, 0x6e, 0x6f, 0x6a, 0x00, 0x7c, 0x8e, 0x90, 0x79, 0x87, + 0xc6, 0x3d, 0x8d, 0x2f, 0x19, 0x55, 0xd7, 0xac, 0xe0, 0x17, 0x84, 0xaf, 0xd1, 0x86, 0xf9, 0xba, + 0xe0, 0x91, 0xd4, 0x9a, 0x15, 0xad, 0xe9, 0xfd, 0xa3, 0x51, 0x55, 0xab, 0xfa, 0x03, 0x0f, 0xce, + 0xa6, 0x15, 0x71, 0x67, 0x15, 0x71, 0xbf, 0x2a, 0xe2, 0xbe, 0xd5, 0xc4, 0x99, 0xd5, 0xc4, 0xf9, + 0xa8, 0x89, 0x73, 0xbb, 0x9f, 0xa4, 0xf2, 0xe1, 0x29, 0xa2, 0xf7, 0x30, 0x09, 0xc7, 0x0c, 0x86, + 0x46, 0x1d, 0xaa, 0x85, 0xbc, 0x98, 0x95, 0xc8, 0xd7, 0x82, 0x8b, 0xa8, 0xa3, 0x57, 0x72, 0xfc, + 0x1d, 0x00, 0x00, 0xff, 0xff, 0x59, 0x22, 0x2f, 0x10, 0x4b, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -140,6 +150,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PledgeDebtList) > 0 { + for iNdEx := len(m.PledgeDebtList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PledgeDebtList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if len(m.PledgeList) > 0 { for iNdEx := len(m.PledgeList) - 1; iNdEx >= 0; iNdEx-- { { @@ -228,6 +252,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PledgeDebtList) > 0 { + for _, e := range m.PledgeDebtList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -403,6 +433,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PledgeDebtList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PledgeDebtList = append(m.PledgeDebtList, PledgeDebt{}) + if err := m.PledgeDebtList[len(m.PledgeDebtList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/node/types/genesis_test.go b/x/node/types/genesis_test.go index cb30ceb5..19d89564 100644 --- a/x/node/types/genesis_test.go +++ b/x/node/types/genesis_test.go @@ -30,6 +30,14 @@ func TestGenesisState_Validate(t *testing.T) { Creator: "1", }, }, + PledgeDebtList: []types.PledgeDebt{ + { + Sp: "0", + }, + { + Sp: "1", + }, + }, // this line is used by starport scaffolding # types/genesis/validField }, valid: true, @@ -48,6 +56,20 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "duplicated pledgeDebt", + genState: &types.GenesisState{ + PledgeDebtList: []types.PledgeDebt{ + { + Sp: "0", + }, + { + Sp: "0", + }, + }, + }, + valid: false, + }, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/node/types/key_pledge_debt.go b/x/node/types/key_pledge_debt.go new file mode 100644 index 00000000..f002c25e --- /dev/null +++ b/x/node/types/key_pledge_debt.go @@ -0,0 +1,23 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // PledgeDebtKeyPrefix is the prefix to retrieve all PledgeDebt + PledgeDebtKeyPrefix = "PledgeDebt/value/" +) + +// PledgeDebtKey returns the store key to retrieve a PledgeDebt from the index fields +func PledgeDebtKey( + sp string, +) []byte { + var key []byte + + spBytes := []byte(sp) + key = append(key, spBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/node/types/pledge_debt.pb.go b/x/node/types/pledge_debt.pb.go new file mode 100644 index 00000000..c352b023 --- /dev/null +++ b/x/node/types/pledge_debt.pb.go @@ -0,0 +1,374 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/node/pledge_debt.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PledgeDebt struct { + Sp string `protobuf:"bytes,1,opt,name=sp,proto3" json:"sp,omitempty"` + Debt types.Coin `protobuf:"bytes,2,opt,name=debt,proto3" json:"debt"` +} + +func (m *PledgeDebt) Reset() { *m = PledgeDebt{} } +func (m *PledgeDebt) String() string { return proto.CompactTextString(m) } +func (*PledgeDebt) ProtoMessage() {} +func (*PledgeDebt) Descriptor() ([]byte, []int) { + return fileDescriptor_b7080da7c65ec51d, []int{0} +} +func (m *PledgeDebt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PledgeDebt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PledgeDebt.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PledgeDebt) XXX_Merge(src proto.Message) { + xxx_messageInfo_PledgeDebt.Merge(m, src) +} +func (m *PledgeDebt) XXX_Size() int { + return m.Size() +} +func (m *PledgeDebt) XXX_DiscardUnknown() { + xxx_messageInfo_PledgeDebt.DiscardUnknown(m) +} + +var xxx_messageInfo_PledgeDebt proto.InternalMessageInfo + +func (m *PledgeDebt) GetSp() string { + if m != nil { + return m.Sp + } + return "" +} + +func (m *PledgeDebt) GetDebt() types.Coin { + if m != nil { + return m.Debt + } + return types.Coin{} +} + +func init() { + proto.RegisterType((*PledgeDebt)(nil), "saonetwork.sao.node.PledgeDebt") +} + +func init() { proto.RegisterFile("sao/node/pledge_debt.proto", fileDescriptor_b7080da7c65ec51d) } + +var fileDescriptor_b7080da7c65ec51d = []byte{ + // 237 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x2c, 0x8f, 0xbf, 0x4e, 0xc3, 0x30, + 0x10, 0x87, 0xe3, 0xa8, 0x42, 0xc2, 0x48, 0x0c, 0x81, 0xa1, 0x64, 0x30, 0x15, 0x03, 0xea, 0xe4, + 0x53, 0xe9, 0x0b, 0xa0, 0xc2, 0x8c, 0xa0, 0x6c, 0x2c, 0xc8, 0x4e, 0x4e, 0x21, 0x82, 0xe6, 0xac, + 0x9e, 0xf9, 0xf7, 0x16, 0x3c, 0x56, 0xc7, 0x8c, 0x4c, 0x08, 0x25, 0x2f, 0x82, 0x6c, 0xb3, 0x59, + 0xfa, 0x7d, 0xfa, 0x7c, 0x9f, 0x2c, 0xd9, 0x10, 0x74, 0x54, 0x23, 0xb8, 0x17, 0xac, 0x1b, 0x7c, + 0xac, 0xd1, 0x7a, 0xed, 0xb6, 0xe4, 0xa9, 0x38, 0x62, 0x43, 0x1d, 0xfa, 0x77, 0xda, 0x3e, 0x6b, + 0x36, 0xa4, 0x03, 0x56, 0x1e, 0x37, 0xd4, 0x50, 0xdc, 0x21, 0xbc, 0x12, 0x5a, 0xaa, 0x8a, 0x78, + 0x43, 0x0c, 0xd6, 0x30, 0xc2, 0xdb, 0xc2, 0xa2, 0x37, 0x0b, 0xa8, 0xa8, 0xed, 0xd2, 0x7e, 0x76, + 0x27, 0xe5, 0x6d, 0xf4, 0x5f, 0xa3, 0xf5, 0xc5, 0xa1, 0xcc, 0xd9, 0x4d, 0xc5, 0x4c, 0xcc, 0xf7, + 0xd7, 0x39, 0xbb, 0x62, 0x29, 0x27, 0xe1, 0xdb, 0x69, 0x3e, 0x13, 0xf3, 0x83, 0x8b, 0x13, 0x9d, + 0x64, 0x3a, 0xc8, 0xf4, 0xbf, 0x4c, 0x5f, 0x51, 0xdb, 0xad, 0x26, 0xbb, 0x9f, 0xd3, 0x6c, 0x1d, + 0xe1, 0xd5, 0xe5, 0x6e, 0x50, 0xa2, 0x1f, 0x94, 0xf8, 0x1d, 0x94, 0xf8, 0x1a, 0x55, 0xd6, 0x8f, + 0x2a, 0xfb, 0x1e, 0x55, 0xf6, 0x70, 0xde, 0xb4, 0xfe, 0xe9, 0xd5, 0xea, 0x8a, 0x36, 0x70, 0x6f, + 0xe8, 0x26, 0x25, 0x40, 0x28, 0xfd, 0x48, 0xad, 0xfe, 0xd3, 0x21, 0xdb, 0xbd, 0x78, 0xdb, 0xf2, + 0x2f, 0x00, 0x00, 0xff, 0xff, 0xce, 0xde, 0xdf, 0x55, 0x04, 0x01, 0x00, 0x00, +} + +func (m *PledgeDebt) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PledgeDebt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PledgeDebt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Debt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPledgeDebt(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sp) > 0 { + i -= len(m.Sp) + copy(dAtA[i:], m.Sp) + i = encodeVarintPledgeDebt(dAtA, i, uint64(len(m.Sp))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPledgeDebt(dAtA []byte, offset int, v uint64) int { + offset -= sovPledgeDebt(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PledgeDebt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sp) + if l > 0 { + n += 1 + l + sovPledgeDebt(uint64(l)) + } + l = m.Debt.Size() + n += 1 + l + sovPledgeDebt(uint64(l)) + return n +} + +func sovPledgeDebt(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPledgeDebt(x uint64) (n int) { + return sovPledgeDebt(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PledgeDebt) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PledgeDebt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PledgeDebt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sp", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPledgeDebt + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPledgeDebt + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Debt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPledgeDebt + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPledgeDebt + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Debt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPledgeDebt(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPledgeDebt + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPledgeDebt(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPledgeDebt + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPledgeDebt + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPledgeDebt + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPledgeDebt + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPledgeDebt = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPledgeDebt = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPledgeDebt = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/node/types/query.pb.go b/x/node/types/query.pb.go index b2e6887b..313832c4 100644 --- a/x/node/types/query.pb.go +++ b/x/node/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -569,6 +570,190 @@ func (m *QueryAllPledgeResponse) GetPagination() *query.PageResponse { return nil } +type QueryGetPledgeDebtRequest struct { + Sp string `protobuf:"bytes,1,opt,name=sp,proto3" json:"sp,omitempty"` +} + +func (m *QueryGetPledgeDebtRequest) Reset() { *m = QueryGetPledgeDebtRequest{} } +func (m *QueryGetPledgeDebtRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetPledgeDebtRequest) ProtoMessage() {} +func (*QueryGetPledgeDebtRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_90d6cf38247b620b, []int{12} +} +func (m *QueryGetPledgeDebtRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPledgeDebtRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPledgeDebtRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPledgeDebtRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPledgeDebtRequest.Merge(m, src) +} +func (m *QueryGetPledgeDebtRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPledgeDebtRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPledgeDebtRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPledgeDebtRequest proto.InternalMessageInfo + +func (m *QueryGetPledgeDebtRequest) GetSp() string { + if m != nil { + return m.Sp + } + return "" +} + +type QueryGetPledgeDebtResponse struct { + PledgeDebt PledgeDebt `protobuf:"bytes,1,opt,name=pledgeDebt,proto3" json:"pledgeDebt"` +} + +func (m *QueryGetPledgeDebtResponse) Reset() { *m = QueryGetPledgeDebtResponse{} } +func (m *QueryGetPledgeDebtResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetPledgeDebtResponse) ProtoMessage() {} +func (*QueryGetPledgeDebtResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_90d6cf38247b620b, []int{13} +} +func (m *QueryGetPledgeDebtResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetPledgeDebtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetPledgeDebtResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetPledgeDebtResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetPledgeDebtResponse.Merge(m, src) +} +func (m *QueryGetPledgeDebtResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetPledgeDebtResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetPledgeDebtResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetPledgeDebtResponse proto.InternalMessageInfo + +func (m *QueryGetPledgeDebtResponse) GetPledgeDebt() PledgeDebt { + if m != nil { + return m.PledgeDebt + } + return PledgeDebt{} +} + +type QueryAllPledgeDebtRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPledgeDebtRequest) Reset() { *m = QueryAllPledgeDebtRequest{} } +func (m *QueryAllPledgeDebtRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllPledgeDebtRequest) ProtoMessage() {} +func (*QueryAllPledgeDebtRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_90d6cf38247b620b, []int{14} +} +func (m *QueryAllPledgeDebtRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPledgeDebtRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPledgeDebtRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPledgeDebtRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPledgeDebtRequest.Merge(m, src) +} +func (m *QueryAllPledgeDebtRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPledgeDebtRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPledgeDebtRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPledgeDebtRequest proto.InternalMessageInfo + +func (m *QueryAllPledgeDebtRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllPledgeDebtResponse struct { + PledgeDebt []PledgeDebt `protobuf:"bytes,1,rep,name=pledgeDebt,proto3" json:"pledgeDebt"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllPledgeDebtResponse) Reset() { *m = QueryAllPledgeDebtResponse{} } +func (m *QueryAllPledgeDebtResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllPledgeDebtResponse) ProtoMessage() {} +func (*QueryAllPledgeDebtResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_90d6cf38247b620b, []int{15} +} +func (m *QueryAllPledgeDebtResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllPledgeDebtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllPledgeDebtResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllPledgeDebtResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPledgeDebtResponse.Merge(m, src) +} +func (m *QueryAllPledgeDebtResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllPledgeDebtResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPledgeDebtResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllPledgeDebtResponse proto.InternalMessageInfo + +func (m *QueryAllPledgeDebtResponse) GetPledgeDebt() []PledgeDebt { + if m != nil { + return m.PledgeDebt + } + return nil +} + +func (m *QueryAllPledgeDebtResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "saonetwork.sao.node.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "saonetwork.sao.node.QueryParamsResponse") @@ -582,54 +767,67 @@ func init() { proto.RegisterType((*QueryGetPledgeResponse)(nil), "saonetwork.sao.node.QueryGetPledgeResponse") proto.RegisterType((*QueryAllPledgeRequest)(nil), "saonetwork.sao.node.QueryAllPledgeRequest") proto.RegisterType((*QueryAllPledgeResponse)(nil), "saonetwork.sao.node.QueryAllPledgeResponse") + proto.RegisterType((*QueryGetPledgeDebtRequest)(nil), "saonetwork.sao.node.QueryGetPledgeDebtRequest") + proto.RegisterType((*QueryGetPledgeDebtResponse)(nil), "saonetwork.sao.node.QueryGetPledgeDebtResponse") + proto.RegisterType((*QueryAllPledgeDebtRequest)(nil), "saonetwork.sao.node.QueryAllPledgeDebtRequest") + proto.RegisterType((*QueryAllPledgeDebtResponse)(nil), "saonetwork.sao.node.QueryAllPledgeDebtResponse") } func init() { proto.RegisterFile("sao/node/query.proto", fileDescriptor_90d6cf38247b620b) } var fileDescriptor_90d6cf38247b620b = []byte{ - // 667 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d, 0x6f, 0xd3, 0x4c, - 0x10, 0xc7, 0xb3, 0x6d, 0x9f, 0x54, 0xdd, 0x47, 0x5c, 0xb6, 0x69, 0xd5, 0xa6, 0x60, 0xca, 0x56, - 0x7d, 0xa1, 0x15, 0xb6, 0xda, 0x9e, 0xb8, 0x51, 0x0e, 0xf4, 0x80, 0x54, 0x85, 0xf4, 0xc6, 0x05, - 0x6d, 0x92, 0x95, 0x89, 0x70, 0x3c, 0xae, 0x77, 0x03, 0x54, 0x08, 0x04, 0x9c, 0xe0, 0x56, 0x09, - 0x8e, 0x7c, 0x10, 0x3e, 0x42, 0x8f, 0x95, 0xb8, 0x70, 0x42, 0x28, 0xe1, 0x83, 0xa0, 0x7d, 0x49, - 0x62, 0x27, 0x96, 0x1d, 0xa4, 0x5e, 0x2c, 0xef, 0x7a, 0x66, 0xfe, 0xbf, 0x9d, 0x99, 0x1d, 0xe3, - 0x8a, 0x60, 0xe0, 0x85, 0xd0, 0xe2, 0xde, 0x59, 0x97, 0xc7, 0xe7, 0x6e, 0x14, 0x83, 0x04, 0xb2, - 0x28, 0x18, 0x84, 0x5c, 0xbe, 0x82, 0xf8, 0x85, 0x2b, 0x18, 0xb8, 0xca, 0xa0, 0x5a, 0xf1, 0xc1, - 0x07, 0xfd, 0xdd, 0x53, 0x6f, 0xc6, 0xb4, 0x7a, 0xd3, 0x07, 0xf0, 0x03, 0xee, 0xb1, 0xa8, 0xed, - 0xb1, 0x30, 0x04, 0xc9, 0x64, 0x1b, 0x42, 0x61, 0xbf, 0xee, 0x36, 0x41, 0x74, 0x40, 0x78, 0x0d, - 0x26, 0xac, 0x82, 0xf7, 0x72, 0xbf, 0xc1, 0x25, 0xdb, 0xf7, 0x22, 0xe6, 0xb7, 0x43, 0x6d, 0x6c, - 0x6d, 0x97, 0x86, 0x28, 0x11, 0x8b, 0x59, 0x67, 0x10, 0x62, 0x71, 0xb8, 0xad, 0x1e, 0x13, 0x9b, - 0x11, 0x40, 0x30, 0x19, 0x20, 0xe0, 0x2d, 0xdf, 0xda, 0xd2, 0x0a, 0x26, 0x4f, 0x94, 0x72, 0x4d, - 0x47, 0xad, 0xf3, 0xb3, 0x2e, 0x17, 0x92, 0xd6, 0xf0, 0x62, 0x6a, 0x57, 0x44, 0x10, 0x0a, 0x4e, - 0xee, 0xe3, 0xb2, 0x51, 0x5f, 0x41, 0xeb, 0x68, 0xe7, 0xff, 0x83, 0x35, 0x37, 0x23, 0x15, 0xae, - 0x71, 0x7a, 0x38, 0x77, 0xf9, 0xeb, 0x76, 0xa9, 0x6e, 0x1d, 0xa8, 0x67, 0x23, 0x1e, 0x73, 0x79, - 0x02, 0x2d, 0x6e, 0x85, 0xc8, 0x0a, 0x9e, 0x6f, 0xc6, 0x9c, 0x49, 0x88, 0x75, 0xc8, 0x85, 0xfa, - 0x60, 0x49, 0x1f, 0xe3, 0x4a, 0xda, 0xc1, 0x32, 0x1c, 0xe2, 0x39, 0xa5, 0x62, 0x09, 0x56, 0x33, - 0x09, 0x94, 0x83, 0xd5, 0xd7, 0xc6, 0xb4, 0x6b, 0xd5, 0x8f, 0x82, 0x20, 0xa9, 0xfe, 0x08, 0xe3, - 0x51, 0xa2, 0x6d, 0xc4, 0x2d, 0xd7, 0x54, 0xc5, 0x55, 0x55, 0x71, 0x4d, 0xdd, 0x6d, 0x55, 0xdc, - 0x1a, 0xf3, 0x07, 0xbe, 0xf5, 0x84, 0x27, 0x59, 0xc6, 0x65, 0x21, 0x99, 0xec, 0x8a, 0x95, 0x99, - 0x75, 0xb4, 0x73, 0xa3, 0x6e, 0x57, 0xf4, 0x2b, 0xb2, 0x87, 0x18, 0xea, 0x4e, 0x1c, 0x62, 0x76, - 0xea, 0x43, 0x90, 0xe3, 0x14, 0xed, 0x8c, 0xa6, 0xdd, 0x2e, 0xa4, 0x35, 0x8a, 0x49, 0x5c, 0xba, - 0x34, 0xaa, 0x45, 0x0d, 0x20, 0x18, 0x14, 0x3d, 0x91, 0x71, 0xb3, 0x3d, 0x82, 0x55, 0xeb, 0xdc, - 0x8c, 0x2b, 0x83, 0x01, 0xac, 0x7a, 0xa7, 0xfb, 0x78, 0x69, 0x18, 0x4c, 0xf7, 0x5b, 0x71, 0xc5, - 0x4f, 0xf1, 0xf2, 0xb8, 0x4b, 0xa2, 0xef, 0xf4, 0x4e, 0x7e, 0xdf, 0x69, 0x93, 0x61, 0xdf, 0xe9, - 0x15, 0x7d, 0x66, 0x39, 0x8e, 0x82, 0x20, 0xcd, 0x71, 0x4d, 0xb5, 0xa7, 0xdf, 0x90, 0xc5, 0x4e, - 0x28, 0x64, 0x60, 0xcf, 0xfe, 0x13, 0xf6, 0xb5, 0xd5, 0xfa, 0xe0, 0x7b, 0x19, 0xff, 0xa7, 0xf1, - 0xc8, 0x7b, 0x84, 0xcb, 0xe6, 0x6a, 0x92, 0xed, 0x4c, 0x90, 0xc9, 0x39, 0x50, 0xdd, 0x29, 0x36, - 0x34, 0x9a, 0x74, 0xe3, 0xe3, 0x8f, 0x3f, 0x5f, 0x66, 0x6e, 0x91, 0x35, 0xef, 0x94, 0xc1, 0x89, - 0xf1, 0xf0, 0xc6, 0x66, 0x16, 0x79, 0x67, 0x3a, 0x89, 0xe4, 0x84, 0x4d, 0xf7, 0x64, 0xf5, 0xee, - 0x14, 0x96, 0x96, 0xe0, 0x8e, 0x26, 0x58, 0x23, 0xab, 0xd9, 0x04, 0x4a, 0xf7, 0x13, 0xc2, 0x73, - 0xea, 0x5a, 0x15, 0x00, 0x24, 0x46, 0x44, 0x01, 0x40, 0xf2, 0x52, 0xd3, 0x3d, 0x0d, 0xb0, 0x49, - 0x36, 0x32, 0x01, 0xf4, 0xe3, 0x8d, 0xed, 0xf5, 0xb7, 0xe4, 0x03, 0xc2, 0xf3, 0xca, 0xfb, 0x28, - 0xc8, 0x4d, 0x47, 0x7a, 0x60, 0xe5, 0xd1, 0x8c, 0x8d, 0x98, 0x82, 0x74, 0xe8, 0x81, 0x72, 0xa1, - 0x3a, 0xc2, 0xf4, 0xdb, 0x6e, 0x7e, 0x9e, 0x93, 0x37, 0xa7, 0xba, 0x37, 0x95, 0xad, 0xc5, 0xb8, - 0xa7, 0x31, 0xb6, 0xc9, 0x66, 0x76, 0x55, 0xb4, 0x71, 0x22, 0x2d, 0x9f, 0x11, 0x5e, 0x30, 0x11, - 0x54, 0x62, 0x76, 0x73, 0x8f, 0x3b, 0x35, 0xd5, 0xc4, 0xcd, 0x2c, 0xea, 0x56, 0x73, 0x23, 0x1f, - 0x5c, 0xf6, 0x1c, 0x74, 0xd5, 0x73, 0xd0, 0xef, 0x9e, 0x83, 0x2e, 0xfa, 0x4e, 0xe9, 0xaa, 0xef, - 0x94, 0x7e, 0xf6, 0x9d, 0xd2, 0xd3, 0x2d, 0xbf, 0x2d, 0x9f, 0x77, 0x1b, 0x6e, 0x13, 0x3a, 0xe3, - 0x01, 0x5e, 0x9b, 0x10, 0xf2, 0x3c, 0xe2, 0xa2, 0x51, 0xd6, 0xff, 0xd8, 0xc3, 0xbf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xae, 0x89, 0x46, 0x85, 0x48, 0x08, 0x00, 0x00, + // 805 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0x3b, 0x85, 0x5f, 0xf9, 0x31, 0x06, 0x0f, 0x43, 0x21, 0xb0, 0x68, 0xc1, 0x21, 0x40, + 0x85, 0xb8, 0x1b, 0xe0, 0xe4, 0x4d, 0x88, 0xca, 0xc1, 0x84, 0xd4, 0x72, 0xf3, 0x42, 0xa6, 0xed, + 0x64, 0x6d, 0x5c, 0x3a, 0x4b, 0x67, 0xab, 0x12, 0x82, 0x51, 0x4f, 0x7a, 0x23, 0xd1, 0x93, 0xe1, + 0x25, 0xf8, 0x42, 0x38, 0x92, 0x78, 0xf1, 0x64, 0x0c, 0xf8, 0x12, 0x7c, 0x01, 0x66, 0xfe, 0x6c, + 0x3b, 0xdb, 0xae, 0xbb, 0x8b, 0xe9, 0xa5, 0xd9, 0x79, 0xfa, 0xfc, 0xf9, 0x3c, 0xdf, 0x67, 0xfa, + 0x6c, 0x61, 0x91, 0x13, 0xe6, 0xb4, 0x58, 0x83, 0x3a, 0x87, 0x1d, 0xda, 0x3e, 0xb2, 0xfd, 0x36, + 0x0b, 0x18, 0x9a, 0xe4, 0x84, 0xb5, 0x68, 0xf0, 0x8a, 0xb5, 0x5f, 0xd8, 0x9c, 0x30, 0x5b, 0x38, + 0x58, 0xb7, 0x5c, 0xc6, 0x5c, 0x8f, 0x3a, 0xc4, 0x6f, 0x3a, 0xa4, 0xd5, 0x62, 0x01, 0x09, 0x9a, + 0xac, 0xc5, 0x55, 0x88, 0xb5, 0x5a, 0x67, 0xfc, 0x80, 0x71, 0xa7, 0x46, 0xb8, 0xce, 0xe5, 0xbc, + 0x5c, 0xaf, 0xd1, 0x80, 0xac, 0x3b, 0x3e, 0x71, 0x9b, 0x2d, 0xe9, 0xac, 0x7d, 0xa7, 0xba, 0x45, + 0x7d, 0xd2, 0x26, 0x07, 0x61, 0x8a, 0xc9, 0xae, 0x59, 0x7c, 0x0c, 0x18, 0x7d, 0xc6, 0xbc, 0xc1, + 0x04, 0x1e, 0x6d, 0xb8, 0xa1, 0xaf, 0xd5, 0x67, 0xde, 0x6f, 0xd0, 0x5a, 0xa0, 0xbf, 0x2b, 0x99, + 0x7c, 0x21, 0x59, 0x9d, 0x35, 0x43, 0xa6, 0xa2, 0xcb, 0x5c, 0x26, 0x1f, 0x1d, 0xf1, 0xa4, 0xac, + 0xb8, 0x08, 0xd1, 0x53, 0xd1, 0x4b, 0x45, 0x72, 0x56, 0xe9, 0x61, 0x87, 0xf2, 0x00, 0x57, 0xe0, + 0x64, 0xc4, 0xca, 0x7d, 0xd6, 0xe2, 0x14, 0xdd, 0x87, 0x05, 0xd5, 0xcf, 0x0c, 0x58, 0x00, 0xe5, + 0x1b, 0x1b, 0x73, 0x76, 0x8c, 0x8c, 0xb6, 0x0a, 0xda, 0x1e, 0x3d, 0xff, 0x31, 0x9f, 0xab, 0xea, + 0x00, 0xec, 0xe8, 0x8c, 0x3b, 0x34, 0xd8, 0x65, 0x0d, 0xaa, 0x0b, 0xa1, 0x19, 0x38, 0x56, 0x6f, + 0x53, 0x12, 0xb0, 0xb6, 0x4c, 0x39, 0x5e, 0x0d, 0x8f, 0xf8, 0x09, 0x2c, 0x46, 0x03, 0x34, 0xc3, + 0x26, 0x1c, 0x15, 0x55, 0x34, 0xc1, 0x6c, 0x2c, 0x81, 0x08, 0xd0, 0xf5, 0xa5, 0x33, 0xee, 0xe8, + 0xea, 0x5b, 0x9e, 0x67, 0x56, 0x7f, 0x0c, 0x61, 0x6f, 0x74, 0x3a, 0xe3, 0xb2, 0xad, 0x74, 0xb4, + 0x85, 0x8e, 0xb6, 0xba, 0x33, 0x5a, 0x4d, 0xbb, 0x42, 0xdc, 0x30, 0xb6, 0x6a, 0x44, 0xa2, 0x69, + 0x58, 0xe0, 0x01, 0x09, 0x3a, 0x7c, 0x26, 0xbf, 0x00, 0xca, 0x13, 0x55, 0x7d, 0xc2, 0x9f, 0x81, + 0x6e, 0xa2, 0x5b, 0x77, 0xa0, 0x89, 0x91, 0xcc, 0x4d, 0xa0, 0x9d, 0x08, 0x6d, 0x5e, 0xd2, 0xae, + 0xa4, 0xd2, 0xaa, 0x8a, 0x26, 0x2e, 0x9e, 0xea, 0xcd, 0xa2, 0xc2, 0x98, 0x17, 0x0e, 0xdd, 0x50, + 0x5c, 0x99, 0x7b, 0xb0, 0xe2, 0x9c, 0xa8, 0xb8, 0x70, 0x08, 0x61, 0xc5, 0x33, 0x5e, 0x87, 0x53, + 0xdd, 0x64, 0xf2, 0xaa, 0xa6, 0x4f, 0x7c, 0x0f, 0x4e, 0xf7, 0x87, 0x18, 0xf7, 0x4e, 0x5a, 0x92, + 0xef, 0x9d, 0x74, 0xe9, 0xde, 0x3b, 0x79, 0xc2, 0xfb, 0x9a, 0x63, 0xcb, 0xf3, 0xa2, 0x1c, 0x43, + 0x9a, 0x3d, 0x3e, 0x03, 0x1a, 0xdb, 0xa8, 0x10, 0x83, 0x3d, 0x72, 0x2d, 0xec, 0xe1, 0xcd, 0x7a, + 0x0d, 0xce, 0x46, 0x45, 0x7d, 0x48, 0x6b, 0x41, 0xa8, 0xc1, 0x4d, 0x98, 0xe7, 0xbe, 0x1e, 0x43, + 0x9e, 0xfb, 0xb8, 0x0e, 0xad, 0x38, 0x67, 0xdd, 0xce, 0x23, 0x08, 0xfd, 0xae, 0x55, 0x2b, 0x36, + 0x9f, 0xd0, 0x92, 0x70, 0xd3, 0x6d, 0x19, 0x81, 0xb8, 0xae, 0x89, 0xba, 0x7a, 0x99, 0x44, 0xc3, + 0x9a, 0xca, 0x57, 0xa0, 0x5b, 0xe9, 0xab, 0xf2, 0x97, 0x56, 0x46, 0xfe, 0xa9, 0x95, 0xa1, 0x4d, + 0x69, 0xe3, 0xf7, 0xff, 0xf0, 0x3f, 0x89, 0x8b, 0xde, 0x02, 0x58, 0x50, 0x0b, 0x14, 0xad, 0xc4, + 0x02, 0x0d, 0x6e, 0x6b, 0xab, 0x9c, 0xee, 0xa8, 0x6a, 0xe2, 0xc5, 0xf7, 0xdf, 0x7e, 0x7d, 0xca, + 0xdf, 0x46, 0x73, 0xce, 0x1e, 0x61, 0xbb, 0x2a, 0xc2, 0xe9, 0x7b, 0x57, 0xa1, 0x37, 0xea, 0xf7, + 0x8e, 0x12, 0xd2, 0x46, 0x37, 0x87, 0x75, 0x37, 0x83, 0xa7, 0x26, 0xb8, 0x23, 0x09, 0xe6, 0xd0, + 0x6c, 0x3c, 0x81, 0xa8, 0xfb, 0x01, 0xc0, 0x51, 0xb1, 0xfc, 0x52, 0x00, 0x8c, 0x45, 0x9e, 0x02, + 0x60, 0xae, 0x5e, 0xbc, 0x26, 0x01, 0x96, 0xd0, 0x62, 0x2c, 0x80, 0xfc, 0x38, 0xd6, 0x1b, 0xe9, + 0x04, 0xbd, 0x03, 0x70, 0x4c, 0x44, 0x6f, 0x79, 0x89, 0x72, 0x44, 0x5f, 0x2b, 0x49, 0x34, 0x7d, + 0x2f, 0x82, 0x14, 0x39, 0xe4, 0xda, 0x3f, 0x15, 0x37, 0x42, 0x6d, 0x85, 0xd5, 0x64, 0x9d, 0xcd, + 0xfd, 0x66, 0xad, 0x65, 0xf2, 0xd5, 0x18, 0xf7, 0x24, 0xc6, 0x0a, 0x5a, 0x8a, 0x9f, 0x8a, 0x74, + 0x36, 0x64, 0xf9, 0x08, 0xe0, 0xb8, 0xca, 0x20, 0x84, 0x59, 0x4d, 0x6c, 0x37, 0x33, 0xd5, 0xc0, + 0xfe, 0x4c, 0xbb, 0xad, 0x4a, 0x93, 0x33, 0x00, 0x61, 0xef, 0x47, 0x8a, 0xec, 0x0c, 0x6d, 0x1b, + 0x0b, 0xc7, 0x72, 0x32, 0xfb, 0x5f, 0x43, 0x2a, 0xf9, 0xb7, 0xcc, 0x39, 0xe6, 0xfe, 0x09, 0xfa, + 0x02, 0xe0, 0x44, 0x2f, 0x8b, 0x90, 0xcb, 0xce, 0x20, 0x41, 0x46, 0xc2, 0xd8, 0xe5, 0x86, 0xcb, + 0x92, 0x10, 0xa3, 0x85, 0x34, 0xc2, 0xed, 0x07, 0xe7, 0x97, 0x25, 0x70, 0x71, 0x59, 0x02, 0x3f, + 0x2f, 0x4b, 0xe0, 0xf4, 0xaa, 0x94, 0xbb, 0xb8, 0x2a, 0xe5, 0xbe, 0x5f, 0x95, 0x72, 0xcf, 0x96, + 0xdd, 0x66, 0xf0, 0xbc, 0x53, 0xb3, 0xeb, 0xec, 0xa0, 0x3f, 0xcb, 0x6b, 0x95, 0x27, 0x38, 0xf2, + 0x29, 0xaf, 0x15, 0xe4, 0xbf, 0xc8, 0xcd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x89, 0xab, + 0x91, 0x66, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -656,6 +854,10 @@ type QueryClient interface { Pledge(ctx context.Context, in *QueryGetPledgeRequest, opts ...grpc.CallOption) (*QueryGetPledgeResponse, error) // Queries a list of Pledge items. PledgeAll(ctx context.Context, in *QueryAllPledgeRequest, opts ...grpc.CallOption) (*QueryAllPledgeResponse, error) + // Queries a PledgeDebt by index. + PledgeDebt(ctx context.Context, in *QueryGetPledgeDebtRequest, opts ...grpc.CallOption) (*QueryGetPledgeDebtResponse, error) + // Queries a list of PledgeDebt items. + PledgeDebtAll(ctx context.Context, in *QueryAllPledgeDebtRequest, opts ...grpc.CallOption) (*QueryAllPledgeDebtResponse, error) } type queryClient struct { @@ -720,6 +922,24 @@ func (c *queryClient) PledgeAll(ctx context.Context, in *QueryAllPledgeRequest, return out, nil } +func (c *queryClient) PledgeDebt(ctx context.Context, in *QueryGetPledgeDebtRequest, opts ...grpc.CallOption) (*QueryGetPledgeDebtResponse, error) { + out := new(QueryGetPledgeDebtResponse) + err := c.cc.Invoke(ctx, "/saonetwork.sao.node.Query/PledgeDebt", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) PledgeDebtAll(ctx context.Context, in *QueryAllPledgeDebtRequest, opts ...grpc.CallOption) (*QueryAllPledgeDebtResponse, error) { + out := new(QueryAllPledgeDebtResponse) + err := c.cc.Invoke(ctx, "/saonetwork.sao.node.Query/PledgeDebtAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -734,6 +954,10 @@ type QueryServer interface { Pledge(context.Context, *QueryGetPledgeRequest) (*QueryGetPledgeResponse, error) // Queries a list of Pledge items. PledgeAll(context.Context, *QueryAllPledgeRequest) (*QueryAllPledgeResponse, error) + // Queries a PledgeDebt by index. + PledgeDebt(context.Context, *QueryGetPledgeDebtRequest) (*QueryGetPledgeDebtResponse, error) + // Queries a list of PledgeDebt items. + PledgeDebtAll(context.Context, *QueryAllPledgeDebtRequest) (*QueryAllPledgeDebtResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -758,6 +982,12 @@ func (*UnimplementedQueryServer) Pledge(ctx context.Context, req *QueryGetPledge func (*UnimplementedQueryServer) PledgeAll(ctx context.Context, req *QueryAllPledgeRequest) (*QueryAllPledgeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PledgeAll not implemented") } +func (*UnimplementedQueryServer) PledgeDebt(ctx context.Context, req *QueryGetPledgeDebtRequest) (*QueryGetPledgeDebtResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PledgeDebt not implemented") +} +func (*UnimplementedQueryServer) PledgeDebtAll(ctx context.Context, req *QueryAllPledgeDebtRequest) (*QueryAllPledgeDebtResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PledgeDebtAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -871,6 +1101,42 @@ func _Query_PledgeAll_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Query_PledgeDebt_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetPledgeDebtRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PledgeDebt(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/saonetwork.sao.node.Query/PledgeDebt", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PledgeDebt(ctx, req.(*QueryGetPledgeDebtRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_PledgeDebtAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllPledgeDebtRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PledgeDebtAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/saonetwork.sao.node.Query/PledgeDebtAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PledgeDebtAll(ctx, req.(*QueryAllPledgeDebtRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "saonetwork.sao.node.Query", HandlerType: (*QueryServer)(nil), @@ -899,6 +1165,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PledgeAll", Handler: _Query_PledgeAll_Handler, }, + { + MethodName: "PledgeDebt", + Handler: _Query_PledgeDebt_Handler, + }, + { + MethodName: "PledgeDebtAll", + Handler: _Query_PledgeDebtAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "sao/node/query.proto", @@ -1315,94 +1589,241 @@ func (m *QueryAllPledgeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetPledgeDebtRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *QueryGetPledgeDebtRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetNodeRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetPledgeDebtRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.Sp) > 0 { + i -= len(m.Sp) + copy(dAtA[i:], m.Sp) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Sp))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryGetNodeResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetPledgeDebtResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.Node.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil } -func (m *QueryAllNodeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Status != 0 { - n += 1 + sovQuery(uint64(m.Status)) - } - return n +func (m *QueryGetPledgeDebtResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllNodeResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetPledgeDebtResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Node) > 0 { - for _, e := range m.Node { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.PledgeDebt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAllPledgeDebtRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPledgeDebtRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPledgeDebtRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllPledgeDebtResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllPledgeDebtResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllPledgeDebtResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.PledgeDebt) > 0 { + for iNdEx := len(m.PledgeDebt) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PledgeDebt[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetNodeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetNodeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Node.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllNodeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + return n +} + +func (m *QueryAllNodeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Node) > 0 { + for _, e := range m.Node { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } func (m *QueryGetPoolRequest) Size() (n int) { @@ -1474,20 +1895,599 @@ func (m *QueryAllPledgeResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetPledgeDebtRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sp) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetPledgeDebtResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PledgeDebt.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllPledgeDebtRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllPledgeDebtResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PledgeDebt) > 0 { + for _, e := range m.PledgeDebt { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetNodeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetNodeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetNodeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetNodeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetNodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetNodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Node", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Node.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllNodeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllNodeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllNodeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllNodeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllNodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllNodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Node", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Node = append(m.Node, Node{}) + if err := m.Node[len(m.Node)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1510,10 +2510,10 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1537,7 +2537,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1560,15 +2560,15 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1595,7 +2595,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1620,7 +2620,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetNodeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetPledgeRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1643,10 +2643,10 @@ func (m *QueryGetNodeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetNodeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPledgeRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetNodeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPledgeRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1702,7 +2702,7 @@ func (m *QueryGetNodeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetNodeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetPledgeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1725,15 +2725,15 @@ func (m *QueryGetNodeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetNodeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPledgeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetNodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPledgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Node", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1760,7 +2760,7 @@ func (m *QueryGetNodeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Node.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Pledge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1785,7 +2785,7 @@ func (m *QueryGetNodeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllNodeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllPledgeRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1808,10 +2808,10 @@ func (m *QueryAllNodeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllNodeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPledgeRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllNodeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPledgeRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1850,25 +2850,6 @@ func (m *QueryAllNodeRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1890,7 +2871,7 @@ func (m *QueryAllNodeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllNodeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllPledgeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1913,15 +2894,15 @@ func (m *QueryAllNodeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllNodeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPledgeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllNodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPledgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Node", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1948,8 +2929,8 @@ func (m *QueryAllNodeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Node = append(m.Node, Node{}) - if err := m.Node[len(m.Node)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Pledge = append(m.Pledge, Pledge{}) + if err := m.Pledge[len(m.Pledge)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2010,140 +2991,7 @@ func (m *QueryAllNodeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPoolRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetPoolRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetPoolResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetPoolResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetPledgeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetPledgeDebtRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2166,15 +3014,15 @@ func (m *QueryGetPledgeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPledgeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPledgeDebtRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPledgeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPledgeDebtRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sp", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2202,7 +3050,7 @@ func (m *QueryGetPledgeRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Creator = string(dAtA[iNdEx:postIndex]) + m.Sp = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2225,7 +3073,7 @@ func (m *QueryGetPledgeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetPledgeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetPledgeDebtResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2248,15 +3096,15 @@ func (m *QueryGetPledgeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetPledgeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetPledgeDebtResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetPledgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetPledgeDebtResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PledgeDebt", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2283,7 +3131,7 @@ func (m *QueryGetPledgeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Pledge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PledgeDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2308,7 +3156,7 @@ func (m *QueryGetPledgeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPledgeRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllPledgeDebtRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2331,10 +3179,10 @@ func (m *QueryAllPledgeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPledgeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPledgeDebtRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPledgeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPledgeDebtRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2394,7 +3242,7 @@ func (m *QueryAllPledgeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllPledgeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllPledgeDebtResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2417,15 +3265,15 @@ func (m *QueryAllPledgeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPledgeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPledgeDebtResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPledgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPledgeDebtResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PledgeDebt", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2452,8 +3300,8 @@ func (m *QueryAllPledgeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Pledge = append(m.Pledge, Pledge{}) - if err := m.Pledge[len(m.Pledge)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PledgeDebt = append(m.PledgeDebt, PledgeDebt{}) + if err := m.PledgeDebt[len(m.PledgeDebt)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/node/types/query.pb.gw.go b/x/node/types/query.pb.gw.go index d2626f4d..2cea59bd 100644 --- a/x/node/types/query.pb.gw.go +++ b/x/node/types/query.pb.gw.go @@ -249,6 +249,96 @@ func local_request_Query_PledgeAll_0(ctx context.Context, marshaler runtime.Mars } +func request_Query_PledgeDebt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPledgeDebtRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["sp"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sp") + } + + protoReq.Sp, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sp", err) + } + + msg, err := client.PledgeDebt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PledgeDebt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetPledgeDebtRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["sp"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sp") + } + + protoReq.Sp, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sp", err) + } + + msg, err := server.PledgeDebt(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_PledgeDebtAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PledgeDebtAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPledgeDebtRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PledgeDebtAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PledgeDebtAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PledgeDebtAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPledgeDebtRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PledgeDebtAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PledgeDebtAll(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -393,6 +483,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PledgeDebt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PledgeDebt_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PledgeDebt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PledgeDebtAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PledgeDebtAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PledgeDebtAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -554,6 +690,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PledgeDebt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PledgeDebt_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PledgeDebt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_PledgeDebtAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PledgeDebtAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PledgeDebtAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -569,6 +745,10 @@ var ( pattern_Query_Pledge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"SaoNetwork", "sao", "node", "pledge", "creator"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_PledgeAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"SaoNetwork", "sao", "node", "pledge"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PledgeDebt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"SaoNetwork", "sao", "node", "pledge_debt", "sp"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PledgeDebtAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"SaoNetwork", "sao", "node", "pledge_debt"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -583,4 +763,8 @@ var ( forward_Query_Pledge_0 = runtime.ForwardResponseMessage forward_Query_PledgeAll_0 = runtime.ForwardResponseMessage + + forward_Query_PledgeDebt_0 = runtime.ForwardResponseMessage + + forward_Query_PledgeDebtAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/sao/keeper/expire_management.go b/x/sao/keeper/expire_management.go index fb215e11..4b059486 100644 --- a/x/sao/keeper/expire_management.go +++ b/x/sao/keeper/expire_management.go @@ -15,7 +15,7 @@ func (k Keeper) HandleExpiredShard(ctx sdk.Context, shardId uint64) { return } - k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) + k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) k.market.WorkerRelease(ctx, &order, &shard) k.order.RemoveShard(ctx, shardId) if len(order.Shards) == 1 { diff --git a/x/sao/keeper/msg_server_cancel.go b/x/sao/keeper/msg_server_cancel.go index 6ccf75a7..372b6ad0 100644 --- a/x/sao/keeper/msg_server_cancel.go +++ b/x/sao/keeper/msg_server_cancel.go @@ -66,7 +66,7 @@ func (k msgServer) Cancel(goCtx context.Context, msg *types.MsgCancel) (*types.M return nil, status.Errorf(codes.NotFound, "shard %d not found", id) } if shard.Status == ordertypes.ShardCompleted { - err := k.node.OrderRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) + err := k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) if err != nil { return nil, err } diff --git a/x/sao/keeper/msg_server_complete.go b/x/sao/keeper/msg_server_complete.go index dfa7f35a..b435d09e 100644 --- a/x/sao/keeper/msg_server_complete.go +++ b/x/sao/keeper/msg_server_complete.go @@ -120,7 +120,7 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ // shard migrate sp := sdk.MustAccAddressFromBech32(shard.From) oldShard := k.order.GetOrderShardBySP(ctx, &order, shard.From) - err := k.node.OrderRelease(ctx, sp, oldShard) + err := k.node.ShardRelease(ctx, sp, oldShard) if err != nil { return nil, err } @@ -152,7 +152,7 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ // shard = order.Shards[msg.Provider] - err = k.node.OrderPledge(ctx, sdk.MustAccAddressFromBech32(msg.Provider), &order) + err = k.node.ShardPledge(ctx, shard, order.UnitPrice) if err != nil { err = sdkerrors.Wrap(types.ErrorOrderPledgeFailed, err.Error()) return &types.MsgCompleteResponse{}, err diff --git a/x/sao/types/expected_keepers.go b/x/sao/types/expected_keepers.go index 3fe88b3f..bb6311e4 100644 --- a/x/sao/types/expected_keepers.go +++ b/x/sao/types/expected_keepers.go @@ -40,9 +40,9 @@ type NodeKeeper interface { RandomSP(ctx sdk.Context, count int, ignore []string) []nodetypes.Node - OrderPledge(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Order) error + ShardPledge(ctx sdk.Context, shard *ordertypes.Shard, unitPrice sdk.DecCoin) error - OrderRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Shard) error + ShardRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Shard) error } // EarnKeeper From bf69d44ac06448e6d15588fd07fe9cee8a9f7db5 Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Tue, 23 May 2023 15:36:51 +0800 Subject: [PATCH 6/8] feat: renew info (#52) --- CHANGELOG.md | 1 + proto/sao/model/metadata.proto | 17 +- proto/sao/order/renew_info.proto | 13 + proto/sao/order/shard.proto | 4 +- x/market/keeper/pool_management.go | 40 +- x/model/keeper/data_management.go | 95 +- x/model/keeper/migrations.go | 5 + x/model/migrations/v2/types/metadata.pb.go | 1090 ++++++++++++++++++++ x/model/migrations/v3/migrations.go | 67 ++ x/model/module.go | 5 +- x/model/types/metadata.pb.go | 162 ++- x/node/keeper/msg_server_claim_reward.go | 56 +- x/node/keeper/shard_pledge_management.go | 48 +- x/order/keeper/shard_management.go | 9 +- x/order/migrations/v3/migrations.go | 21 +- x/order/types/renew_info.pb.go | 395 +++++++ x/order/types/shard.pb.go | 130 ++- x/sao/keeper/expired_shard.go | 7 +- x/sao/keeper/msg_server_complete.go | 39 +- x/sao/keeper/msg_server_migrate.go | 2 +- x/sao/keeper/msg_server_store.go | 20 +- x/sao/keeper/msg_server_terminate.go | 23 +- x/sao/keeper/pledge.go | 63 -- x/sao/types/expected_keepers.go | 8 +- 24 files changed, 2032 insertions(+), 288 deletions(-) create mode 100644 proto/sao/order/renew_info.proto create mode 100644 x/model/migrations/v2/types/metadata.pb.go create mode 100644 x/model/migrations/v3/migrations.go create mode 100644 x/order/types/renew_info.pb.go delete mode 100644 x/sao/keeper/pledge.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b2a88202..b89f4ea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] ### Features +- pledge_debt, refactor node module funcs ([#51](https://github.com/SAONetwork/sao-consensus/issues/51)) - expired shard ([#49](https://github.com/SAONetwork/sao-consensus/issues/49)) - storage pledge baseline ([#48](https://github.com/SAONetwork/sao-consensus/issues/48)) diff --git a/proto/sao/model/metadata.proto b/proto/sao/model/metadata.proto index 7caaa9f4..d55e41e8 100644 --- a/proto/sao/model/metadata.proto +++ b/proto/sao/model/metadata.proto @@ -4,22 +4,23 @@ package saonetwork.sao.model; option go_package = "github.com/SaoNetwork/sao/x/model/types"; message Metadata { - string dataId = 1; - string owner = 2; - string alias = 3; + string dataId = 1; + string owner = 2; + string alias = 3; string groupId = 4; uint64 orderId = 5; - repeated string tags = 6; - string cid = 7; - repeated string commits = 8; - string extendInfo = 9; + repeated string tags = 6; + string cid = 7; + repeated string commits = 8; + string extendInfo = 9; bool update = 10; string commit = 11; string rule = 12; - uint64 duration = 13; + uint64 duration = 13; uint64 createdAt = 14; repeated string readonlyDids = 15; repeated string readwriteDids = 16; int32 status = 17; + repeated uint64 orders = 18; } diff --git a/proto/sao/order/renew_info.proto b/proto/sao/order/renew_info.proto new file mode 100644 index 00000000..7e2dfb42 --- /dev/null +++ b/proto/sao/order/renew_info.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package saonetwork.sao.order; + +option go_package = "github.com/SaoNetwork/sao/x/order/types"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +message RenewInfo { + + uint64 orderId = 1; + cosmos.base.v1beta1.Coin pledge = 2 [(gogoproto.nullable) = false]; + uint64 duration = 3; +} diff --git a/proto/sao/order/shard.proto b/proto/sao/order/shard.proto index 9419bd33..a3a85cd9 100644 --- a/proto/sao/order/shard.proto +++ b/proto/sao/order/shard.proto @@ -1,9 +1,10 @@ syntax = "proto3"; package saonetwork.sao.order; -import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/SaoNetwork/sao/x/order/types"; +import "sao/order/renew_info.proto"; message Shard { uint64 id = 1; @@ -16,4 +17,5 @@ message Shard { string sp = 8; uint64 duration = 9; uint64 createdAt = 10; + repeated RenewInfo renewInfos = 11 [(gogoproto.nullable) = false]; } diff --git a/x/market/keeper/pool_management.go b/x/market/keeper/pool_management.go index 6c150135..c70705e2 100644 --- a/x/market/keeper/pool_management.go +++ b/x/market/keeper/pool_management.go @@ -57,13 +57,13 @@ func (k Keeper) Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, err for _, id := range order.Shards { shard, found := k.order.GetShard(ctx, id) - if !found { + if !found || shard.OrderId > order.Id { continue } shardIncomePerBlock := order.UnitPrice.Amount.MulInt64(int64(shard.Size_)) - if shard.Status == ordertypes.ShardCompleted { + if shard.Status == ordertypes.ShardCompleted && shard.OrderId == order.Id { // refundDec += price * shardSize * (shardExpiredAt - currentHeight) refundDec = refundDec.Add(shardIncomePerBlock.MulInt64(int64(shard.CreatedAt+shard.Duration) - ctx.BlockHeight())) @@ -80,11 +80,14 @@ func (k Keeper) Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, err refundCoin, _ := sdk.NewDecCoinFromDec(amount.Denom, refundDec).TruncateDecimal() - err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) - if err != nil { - return sdk.Coin{}, err + if !refundCoin.IsZero() { + err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, ordertypes.ModuleName, sdk.Coins{refundCoin}) + if err != nil { + return sdk.Coin{}, err + } + + logger.Debug("CoinTrace: withdraw", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) } - logger.Debug("CoinTrace: withdraw", "from", types.ModuleName, "to", ordertypes.ModuleName, "amount", refundCoin.String()) return refundCoin, nil } @@ -118,15 +121,6 @@ func (k Keeper) Claim(ctx sdk.Context, denom string, sp string) (sdk.Coin, error rewardCoin := sdk.NewCoin(denom, worker.Reward.Amount.TruncateInt()) - spAcc := sdk.MustAccAddressFromBech32(sp) - - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, spAcc, sdk.Coins{rewardCoin}) - - if err != nil { - return empty, err - } - logger.Debug("CoinTrace: claim", "from", types.ModuleName, "to", spAcc.String(), "amount", rewardCoin.String()) - logger.Debug("WorkerTrace: claim 2", "Worker", workerName, "reward", worker.Reward.String(), @@ -141,17 +135,17 @@ func (k Keeper) Claim(ctx sdk.Context, denom string, sp string) (sdk.Coin, error return rewardCoin, nil } -func (k Keeper) Migrate(ctx sdk.Context, order ordertypes.Order, from string, to string) error { - fromShard := k.order.GetOrderShardBySP(ctx, &order, from) +func (k Keeper) Migrate(ctx sdk.Context, order ordertypes.Order, fromShard, toShard ordertypes.Shard) error { + log := k.Logger(ctx) + log.Debug("migrate", "order", order.Id, "from", fromShard.Id, "to", toShard.Id) // from sp worker settlement - err := k.WorkerRelease(ctx, &order, fromShard) + err := k.WorkerRelease(ctx, &order, &fromShard) if err != nil { return err } - toShard := k.order.GetOrderShardBySP(ctx, &order, to) // to sp worker begin work - err = k.WorkerAppend(ctx, &order, toShard) + err = k.WorkerAppend(ctx, &order, &toShard) if err != nil { return err } @@ -253,9 +247,9 @@ func (k Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *or } IncomePerBlock := order.UnitPrice.Amount.MulInt64(int64(shard.Size_)) + reward := IncomePerBlock.MulInt64(ctx.BlockHeight() - int64(shard.CreatedAt)) if worker.Storage > 0 { - reward := worker.IncomePerSecond.Amount.MulInt64(ctx.BlockHeight() - worker.LastRewardAt) - reward = reward.Add(IncomePerBlock.MulInt64(ctx.BlockHeight() - int64(shard.CreatedAt))) + reward = reward.Add(worker.IncomePerSecond.Amount.MulInt64(ctx.BlockHeight() - worker.LastRewardAt)) logger.Debug("WorkerTrace: deposit 1", "Worker", workerName, "orderId", order.Id, @@ -264,8 +258,8 @@ func (k Keeper) WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *or "lastRewardAt", worker.LastRewardAt, "currentHeight", ctx.BlockHeight(), "incomePerBlock", worker.IncomePerSecond.String()) - worker.Reward.Amount = worker.Reward.Amount.Add(reward) } + worker.Reward.Amount = worker.Reward.Amount.Add(reward) worker.LastRewardAt = ctx.BlockHeight() logger.Debug("WorkerTrace: deposit 2", diff --git a/x/model/keeper/data_management.go b/x/model/keeper/data_management.go index 4b3b2600..21d90ada 100644 --- a/x/model/keeper/data_management.go +++ b/x/model/keeper/data_management.go @@ -93,18 +93,38 @@ func (k Keeper) UpdateMeta(ctx sdk.Context, order ordertypes.Order) error { metadata.Commit = order.Commit metadata.Commits = append(metadata.Commits, Version(order.Commit, ctx.BlockHeight())) + metadata.Orders = append(metadata.Orders, order.Id) case 2: // force push, replace last commit - lastOrderId := metadata.OrderId + //lastOrderId := metadata.OrderId + lastCommit := CommitFromVersion(metadata.Commits[len(metadata.Commits)-1]) // old order settlement - lastOrder, foundLastOrder := k.order.GetOrder(ctx, lastOrderId) - if !foundLastOrder { - return status.Error(codes.NotFound, "last order not found") + shardSet := make(map[uint64]int) + for { + if len(metadata.Orders) == 0 { + break + } + lastOrder, foundLastOrder := k.order.GetOrder(ctx, metadata.Orders[len(metadata.Orders)-1]) + if !foundLastOrder { + return status.Error(codes.NotFound, "last order not found") + } + if lastOrder.Commit != lastCommit { + break + } + + for _, shardId := range lastOrder.Shards { + shardSet[shardId] = 1 + } + + err := k.TerminateOrder(ctx, lastOrder) + if err != nil { + return err + } + metadata.Orders = metadata.Orders[:len(metadata.Orders)-1] } - err := k.TerminateOrder(ctx, lastOrder) - if err != nil { - return err + for shardId, _ := range shardSet { + k.order.RemoveShard(ctx, shardId) } // remove old version @@ -114,19 +134,10 @@ func (k Keeper) UpdateMeta(ctx sdk.Context, order ordertypes.Order) error { } metadata.Commit = order.Commit metadata.Commits = append(metadata.Commits, Version(order.Commit, ctx.BlockHeight())) + metadata.Orders = append(metadata.Orders, order.Id) + k.ResetMetaDuration(ctx, &metadata) case 3: // renew - lastOrderId := metadata.OrderId - - // old order settlement - // TODO: sp may re-get (currentHeight - order.CreatedAt) rewards , resolve this problem - lastOrder, foundLastOrder := k.order.GetOrder(ctx, lastOrderId) - if !foundLastOrder { - return status.Error(codes.NotFound, "not found") - } - err := k.TerminateOrder(ctx, lastOrder) - if err != nil { - return err - } + metadata.Orders = append(metadata.Orders, order.Id) } metadata.OrderId = order.Id k.SetMetadata(ctx, metadata) @@ -144,11 +155,6 @@ func (k Keeper) UpdateMetaStatusAndCommit(ctx sdk.Context, order ordertypes.Orde return sdkerrors.Wrapf(types.ErrInvalidStatus, "unexpected meta: %s, status: %d", metadata.DataId, metadata.Status) } - /* - TODO: there can be multiple orders under the same metadata, but only one duration recorded. - so we cannot deal with the situation that order duration decreases when operation is 2. - Consider if we allow an alive metadata with no alive order and how to rollback expired - */ // calculate new duration oldExpired := metadata.CreatedAt + metadata.Duration newExpired := order.CreatedAt + order.Duration @@ -247,13 +253,12 @@ func (k Keeper) TerminateOrder(ctx sdk.Context, order ordertypes.Order) error { if !found { continue } - if shard.Status == ordertypes.ShardCompleted { + if shard.Status == ordertypes.ShardCompleted && shard.OrderId == order.Id { err := k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) if err != nil { return err } } - k.order.RemoveShard(ctx, id) } err = k.order.TerminateOrder(ctx, order.Id, refund) @@ -301,12 +306,48 @@ func (k Keeper) RollbackMeta(ctx sdk.Context, dataId string) { metadata.Status = types.MetaComplete metadata.Commit = CommitFromVersion(metadata.Commits[len(metadata.Commits)-1]) + k.ResetMetaDuration(ctx, &metadata) k.SetMetadata(ctx, metadata) return } -func (k Keeper) ExtendMetaDuration(ctx sdk.Context, meta types.Metadata, expiredAt uint64) { +func (k Keeper) ResetMetaDuration(ctx sdk.Context, meta *types.Metadata) { + orders := meta.Orders + + var expiredHeight uint64 = 0 + shardExpiredMap := make(map[uint64]uint64) + for _, orderId := range orders { + order, foundOrder := k.order.GetOrder(ctx, orderId) + if foundOrder { + for _, shardId := range order.Shards { + if shardExpiredMap[shardId] == 0 { + shard, foundShard := k.order.GetShard(ctx, shardId) + if foundShard { + shardExpiredMap[shardId] = shard.CreatedAt + shard.Duration + for _, renewInfo := range shard.RenewInfos { + shardExpiredMap[shardId] += renewInfo.Duration + } + if shardExpiredMap[shardId] > expiredHeight { + expiredHeight = shardExpiredMap[shardId] + } + } + } + } + } + } + + newDuration := expiredHeight - meta.CreatedAt + + if meta.Duration != newDuration { + k.removeDataExpireBlock(ctx, meta.DataId, meta.CreatedAt+meta.Duration) + meta.Duration = newDuration + k.setDataExpireBlock(ctx, meta.DataId, expiredHeight) + } +} + +func (k Keeper) ExtendMetaDuration(ctx sdk.Context, dataId string, expiredAt uint64) { + meta, _ := k.GetMetadata(ctx, dataId) newDuration := expiredAt - meta.CreatedAt if meta.Duration < newDuration { k.removeDataExpireBlock(ctx, meta.DataId, meta.CreatedAt+meta.Duration) diff --git a/x/model/keeper/migrations.go b/x/model/keeper/migrations.go index 68ab65d4..dcaabeab 100644 --- a/x/model/keeper/migrations.go +++ b/x/model/keeper/migrations.go @@ -2,6 +2,7 @@ package keeper import ( v2 "github.com/SaoNetwork/sao/x/model/migrations/v2" + v3 "github.com/SaoNetwork/sao/x/model/migrations/v3" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,3 +17,7 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.orderStoreKey, m.keeper.cdc, m.keeper.setDataExpireBlock) } + +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.orderStoreKey, m.keeper.cdc) +} diff --git a/x/model/migrations/v2/types/metadata.pb.go b/x/model/migrations/v2/types/metadata.pb.go new file mode 100644 index 00000000..e6e61554 --- /dev/null +++ b/x/model/migrations/v2/types/metadata.pb.go @@ -0,0 +1,1090 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/model/metadata.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Metadata struct { + DataId string `protobuf:"bytes,1,opt,name=dataId,proto3" json:"dataId,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Alias string `protobuf:"bytes,3,opt,name=alias,proto3" json:"alias,omitempty"` + GroupId string `protobuf:"bytes,4,opt,name=groupId,proto3" json:"groupId,omitempty"` + OrderId uint64 `protobuf:"varint,5,opt,name=orderId,proto3" json:"orderId,omitempty"` + Tags []string `protobuf:"bytes,6,rep,name=tags,proto3" json:"tags,omitempty"` + Cid string `protobuf:"bytes,7,opt,name=cid,proto3" json:"cid,omitempty"` + Commits []string `protobuf:"bytes,8,rep,name=commits,proto3" json:"commits,omitempty"` + ExtendInfo string `protobuf:"bytes,9,opt,name=extendInfo,proto3" json:"extendInfo,omitempty"` + Update bool `protobuf:"varint,10,opt,name=update,proto3" json:"update,omitempty"` + Commit string `protobuf:"bytes,11,opt,name=commit,proto3" json:"commit,omitempty"` + Rule string `protobuf:"bytes,12,opt,name=rule,proto3" json:"rule,omitempty"` + Duration uint64 `protobuf:"varint,13,opt,name=duration,proto3" json:"duration,omitempty"` + CreatedAt uint64 `protobuf:"varint,14,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + ReadonlyDids []string `protobuf:"bytes,15,rep,name=readonlyDids,proto3" json:"readonlyDids,omitempty"` + ReadwriteDids []string `protobuf:"bytes,16,rep,name=readwriteDids,proto3" json:"readwriteDids,omitempty"` + Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` +} + +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_0f86945b10149945, []int{0} +} +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return m.Size() +} +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo + +func (m *Metadata) GetDataId() string { + if m != nil { + return m.DataId + } + return "" +} + +func (m *Metadata) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Metadata) GetAlias() string { + if m != nil { + return m.Alias + } + return "" +} + +func (m *Metadata) GetGroupId() string { + if m != nil { + return m.GroupId + } + return "" +} + +func (m *Metadata) GetOrderId() uint64 { + if m != nil { + return m.OrderId + } + return 0 +} + +func (m *Metadata) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *Metadata) GetCid() string { + if m != nil { + return m.Cid + } + return "" +} + +func (m *Metadata) GetCommits() []string { + if m != nil { + return m.Commits + } + return nil +} + +func (m *Metadata) GetExtendInfo() string { + if m != nil { + return m.ExtendInfo + } + return "" +} + +func (m *Metadata) GetUpdate() bool { + if m != nil { + return m.Update + } + return false +} + +func (m *Metadata) GetCommit() string { + if m != nil { + return m.Commit + } + return "" +} + +func (m *Metadata) GetRule() string { + if m != nil { + return m.Rule + } + return "" +} + +func (m *Metadata) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *Metadata) GetCreatedAt() uint64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + +func (m *Metadata) GetReadonlyDids() []string { + if m != nil { + return m.ReadonlyDids + } + return nil +} + +func (m *Metadata) GetReadwriteDids() []string { + if m != nil { + return m.ReadwriteDids + } + return nil +} + +func (m *Metadata) GetStatus() int32 { + if m != nil { + return m.Status + } + return 0 +} + +func init() { + proto.RegisterType((*Metadata)(nil), "saonetwork.sao.model.V2Metadata") +} + +func init() { proto.RegisterFile("sao/model/metadata.proto", fileDescriptor_0f86945b10149945) } + +var fileDescriptor_0f86945b10149945 = []byte{ + // 380 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0xbf, 0x6e, 0xd4, 0x40, + 0x10, 0x87, 0x6f, 0xb9, 0x3f, 0xb1, 0x97, 0x04, 0xc2, 0x2a, 0x42, 0x23, 0x84, 0x2c, 0x2b, 0x42, + 0xc2, 0x95, 0x5d, 0xf0, 0x04, 0x41, 0x34, 0x2e, 0xa0, 0x30, 0x1d, 0xdd, 0xc6, 0xbb, 0x1c, 0x16, + 0xb6, 0xc7, 0xda, 0x1d, 0xeb, 0x92, 0xb7, 0xe0, 0x99, 0xa8, 0x28, 0x53, 0x52, 0xa2, 0xbb, 0x17, + 0x41, 0x3b, 0xf6, 0x41, 0xae, 0xf2, 0x7c, 0xdf, 0xfe, 0x76, 0x35, 0x23, 0x8f, 0x04, 0xaf, 0xb1, + 0xe8, 0xd0, 0xd8, 0xb6, 0xe8, 0x2c, 0x69, 0xa3, 0x49, 0xe7, 0x83, 0x43, 0x42, 0x75, 0xe5, 0x35, + 0xf6, 0x96, 0x76, 0xe8, 0xbe, 0xe7, 0x5e, 0x63, 0xce, 0xa1, 0xeb, 0x9f, 0x4b, 0x19, 0x7d, 0x9c, + 0x83, 0xea, 0xa5, 0xdc, 0x84, 0x6f, 0x69, 0x40, 0xa4, 0x22, 0x8b, 0xab, 0x99, 0xd4, 0x95, 0x5c, + 0xe3, 0xae, 0xb7, 0x0e, 0x9e, 0xb0, 0x9e, 0x20, 0x58, 0xdd, 0x36, 0xda, 0xc3, 0x72, 0xb2, 0x0c, + 0x0a, 0xe4, 0xd9, 0xd6, 0xe1, 0x38, 0x94, 0x06, 0x56, 0xec, 0x8f, 0x18, 0x4e, 0xd0, 0x19, 0xeb, + 0x4a, 0x03, 0xeb, 0x54, 0x64, 0xab, 0xea, 0x88, 0x4a, 0xc9, 0x15, 0xe9, 0xad, 0x87, 0x4d, 0xba, + 0xcc, 0xe2, 0x8a, 0x6b, 0x75, 0x29, 0x97, 0x75, 0x63, 0xe0, 0x8c, 0xdf, 0x08, 0x65, 0xb8, 0x5f, + 0x63, 0xd7, 0x35, 0xe4, 0x21, 0xe2, 0xe0, 0x11, 0x55, 0x22, 0xa5, 0xbd, 0x23, 0xdb, 0x9b, 0xb2, + 0xff, 0x8a, 0x10, 0xf3, 0x95, 0x47, 0x26, 0xcc, 0x35, 0x0e, 0x46, 0x93, 0x05, 0x99, 0x8a, 0x2c, + 0xaa, 0x66, 0x0a, 0x7e, 0x7a, 0x02, 0x9e, 0x4e, 0xf3, 0x4e, 0x14, 0xfa, 0x71, 0x63, 0x6b, 0xe1, + 0x9c, 0x2d, 0xd7, 0xea, 0x95, 0x8c, 0xcc, 0xe8, 0x34, 0x35, 0xd8, 0xc3, 0x05, 0xb7, 0xff, 0x8f, + 0xd5, 0x6b, 0x19, 0xd7, 0xce, 0x6a, 0xb2, 0xe6, 0x86, 0xe0, 0x19, 0x1f, 0xfe, 0x17, 0xea, 0x5a, + 0x9e, 0x3b, 0xab, 0x0d, 0xf6, 0xed, 0xfd, 0x87, 0xc6, 0x78, 0x78, 0xce, 0xcd, 0x9f, 0x38, 0xf5, + 0x46, 0x5e, 0x04, 0xde, 0xb9, 0x86, 0x2c, 0x87, 0x2e, 0x39, 0x74, 0x2a, 0x43, 0xbf, 0x9e, 0x34, + 0x8d, 0x1e, 0x5e, 0xa4, 0x22, 0x5b, 0x57, 0x33, 0xbd, 0xbf, 0xf9, 0xb5, 0x4f, 0xc4, 0xc3, 0x3e, + 0x11, 0x7f, 0xf6, 0x89, 0xf8, 0x71, 0x48, 0x16, 0x0f, 0x87, 0x64, 0xf1, 0xfb, 0x90, 0x2c, 0xbe, + 0xbc, 0xdd, 0x36, 0xf4, 0x6d, 0xbc, 0xcd, 0x6b, 0xec, 0x8a, 0xcf, 0x1a, 0x3f, 0x4d, 0xff, 0xbf, + 0x08, 0x4b, 0x72, 0x37, 0xaf, 0x09, 0xdd, 0x0f, 0xd6, 0xdf, 0x6e, 0x78, 0x49, 0xde, 0xfd, 0x0d, + 0x00, 0x00, 0xff, 0xff, 0xd0, 0xa6, 0xb7, 0xf9, 0x40, 0x02, 0x00, 0x00, +} + +func (m *Metadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Metadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if len(m.ReadwriteDids) > 0 { + for iNdEx := len(m.ReadwriteDids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ReadwriteDids[iNdEx]) + copy(dAtA[i:], m.ReadwriteDids[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.ReadwriteDids[iNdEx]))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + } + if len(m.ReadonlyDids) > 0 { + for iNdEx := len(m.ReadonlyDids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ReadonlyDids[iNdEx]) + copy(dAtA[i:], m.ReadonlyDids[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.ReadonlyDids[iNdEx]))) + i-- + dAtA[i] = 0x7a + } + } + if m.CreatedAt != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x70 + } + if m.Duration != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x68 + } + if len(m.Rule) > 0 { + i -= len(m.Rule) + copy(dAtA[i:], m.Rule) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Rule))) + i-- + dAtA[i] = 0x62 + } + if len(m.Commit) > 0 { + i -= len(m.Commit) + copy(dAtA[i:], m.Commit) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Commit))) + i-- + dAtA[i] = 0x5a + } + if m.Update { + i-- + if m.Update { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x50 + } + if len(m.ExtendInfo) > 0 { + i -= len(m.ExtendInfo) + copy(dAtA[i:], m.ExtendInfo) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.ExtendInfo))) + i-- + dAtA[i] = 0x4a + } + if len(m.Commits) > 0 { + for iNdEx := len(m.Commits) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Commits[iNdEx]) + copy(dAtA[i:], m.Commits[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Commits[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + if len(m.Cid) > 0 { + i -= len(m.Cid) + copy(dAtA[i:], m.Cid) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Cid))) + i-- + dAtA[i] = 0x3a + } + if len(m.Tags) > 0 { + for iNdEx := len(m.Tags) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Tags[iNdEx]) + copy(dAtA[i:], m.Tags[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Tags[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if m.OrderId != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.OrderId)) + i-- + dAtA[i] = 0x28 + } + if len(m.GroupId) > 0 { + i -= len(m.GroupId) + copy(dAtA[i:], m.GroupId) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.GroupId))) + i-- + dAtA[i] = 0x22 + } + if len(m.Alias) > 0 { + i -= len(m.Alias) + copy(dAtA[i:], m.Alias) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Alias))) + i-- + dAtA[i] = 0x1a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.DataId) > 0 { + i -= len(m.DataId) + copy(dAtA[i:], m.DataId) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.DataId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DataId) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Alias) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.GroupId) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.OrderId != 0 { + n += 1 + sovMetadata(uint64(m.OrderId)) + } + if len(m.Tags) > 0 { + for _, s := range m.Tags { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + l = len(m.Cid) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if len(m.Commits) > 0 { + for _, s := range m.Commits { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + l = len(m.ExtendInfo) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.Update { + n += 2 + } + l = len(m.Commit) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Rule) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovMetadata(uint64(m.Duration)) + } + if m.CreatedAt != 0 { + n += 1 + sovMetadata(uint64(m.CreatedAt)) + } + if len(m.ReadonlyDids) > 0 { + for _, s := range m.ReadonlyDids { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.ReadwriteDids) > 0 { + for _, s := range m.ReadwriteDids { + l = len(s) + n += 2 + l + sovMetadata(uint64(l)) + } + } + if m.Status != 0 { + n += 2 + sovMetadata(uint64(m.Status)) + } + return n +} + +func sovMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMetadata(x uint64) (n int) { + return sovMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Metadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DataId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DataId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Alias", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Alias = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GroupId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderId", wireType) + } + m.OrderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OrderId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tags", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tags = append(m.Tags, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commits", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commits = append(m.Commits, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtendInfo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtendInfo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Update", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Update = bool(v != 0) + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rule", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rule = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadonlyDids", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReadonlyDids = append(m.ReadonlyDids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadwriteDids", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReadwriteDids = append(m.ReadwriteDids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMetadata(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/model/migrations/v3/migrations.go b/x/model/migrations/v3/migrations.go new file mode 100644 index 00000000..83320731 --- /dev/null +++ b/x/model/migrations/v3/migrations.go @@ -0,0 +1,67 @@ +package v3 + +import ( + v2 "github.com/SaoNetwork/sao/x/model/migrations/v2/types" + "github.com/SaoNetwork/sao/x/model/types" + v2order "github.com/SaoNetwork/sao/x/order/migrations/v2/types" + ordertypes "github.com/SaoNetwork/sao/x/order/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, orderStoreKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + orderStore := prefix.NewStore(ctx.KVStore(orderStoreKey), types.KeyPrefix(ordertypes.OrderKey)) + orderIterator := sdk.KVStorePrefixIterator(orderStore, []byte{}) + defer orderIterator.Close() + + orderIdMap := make(map[string][]uint64) + for ; orderIterator.Valid(); orderIterator.Next() { + var val v2order.Order + cdc.MustUnmarshal(orderIterator.Value(), &val) + + if _, ok := orderIdMap[val.DataId]; !ok { + orderIdMap[val.DataId] = []uint64{val.Id} + } else { + orderIdMap[val.DataId] = append(orderIdMap[val.DataId], val.Id) + } + } + + store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.MetadataKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + key := iterator.Key() + + var val v2.Metadata + cdc.MustUnmarshal(iterator.Value(), &val) + + metadata := types.Metadata{ + DataId: val.DataId, + Owner: val.Owner, + Alias: val.Alias, + GroupId: val.GroupId, + OrderId: val.OrderId, + Tags: val.Tags, + Cid: val.Cid, + Commits: val.Commits, + ExtendInfo: val.ExtendInfo, + Update: val.Update, + Commit: val.Commit, + Rule: val.Rule, + Duration: val.Duration, + CreatedAt: val.CreatedAt, + ReadonlyDids: val.ReadonlyDids, + ReadwriteDids: val.ReadwriteDids, + Status: val.Status, + Orders: orderIdMap[val.DataId], + } + + newVal := cdc.MustMarshal(&metadata) + store.Set(key, newVal) + } + + return nil +} diff --git a/x/model/module.go b/x/model/module.go index 70e05c19..1d2f6b30 100644 --- a/x/model/module.go +++ b/x/model/module.go @@ -132,6 +132,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) } + if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate2to3); err != nil { + panic(fmt.Errorf("failed to migrate %s to vr: %w", types.ModuleName, err)) + } } @@ -156,7 +159,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/model/types/metadata.pb.go b/x/model/types/metadata.pb.go index 2b44f140..2aed463f 100644 --- a/x/model/types/metadata.pb.go +++ b/x/model/types/metadata.pb.go @@ -40,6 +40,7 @@ type Metadata struct { ReadonlyDids []string `protobuf:"bytes,15,rep,name=readonlyDids,proto3" json:"readonlyDids,omitempty"` ReadwriteDids []string `protobuf:"bytes,16,rep,name=readwriteDids,proto3" json:"readwriteDids,omitempty"` Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` + Orders []uint64 `protobuf:"varint,18,rep,packed,name=orders,proto3" json:"orders,omitempty"` } func (m *Metadata) Reset() { *m = Metadata{} } @@ -194,6 +195,13 @@ func (m *Metadata) GetStatus() int32 { return 0 } +func (m *Metadata) GetOrders() []uint64 { + if m != nil { + return m.Orders + } + return nil +} + func init() { proto.RegisterType((*Metadata)(nil), "saonetwork.sao.model.Metadata") } @@ -201,31 +209,32 @@ func init() { func init() { proto.RegisterFile("sao/model/metadata.proto", fileDescriptor_0f86945b10149945) } var fileDescriptor_0f86945b10149945 = []byte{ - // 380 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0xbf, 0x6e, 0xd4, 0x40, - 0x10, 0x87, 0x6f, 0xb9, 0x3f, 0xb1, 0x97, 0x04, 0xc2, 0x2a, 0x42, 0x23, 0x84, 0x2c, 0x2b, 0x42, - 0xc2, 0x95, 0x5d, 0xf0, 0x04, 0x41, 0x34, 0x2e, 0xa0, 0x30, 0x1d, 0xdd, 0xc6, 0xbb, 0x1c, 0x16, - 0xb6, 0xc7, 0xda, 0x1d, 0xeb, 0x92, 0xb7, 0xe0, 0x99, 0xa8, 0x28, 0x53, 0x52, 0xa2, 0xbb, 0x17, - 0x41, 0x3b, 0xf6, 0x41, 0xae, 0xf2, 0x7c, 0xdf, 0xfe, 0x76, 0x35, 0x23, 0x8f, 0x04, 0xaf, 0xb1, - 0xe8, 0xd0, 0xd8, 0xb6, 0xe8, 0x2c, 0x69, 0xa3, 0x49, 0xe7, 0x83, 0x43, 0x42, 0x75, 0xe5, 0x35, - 0xf6, 0x96, 0x76, 0xe8, 0xbe, 0xe7, 0x5e, 0x63, 0xce, 0xa1, 0xeb, 0x9f, 0x4b, 0x19, 0x7d, 0x9c, - 0x83, 0xea, 0xa5, 0xdc, 0x84, 0x6f, 0x69, 0x40, 0xa4, 0x22, 0x8b, 0xab, 0x99, 0xd4, 0x95, 0x5c, - 0xe3, 0xae, 0xb7, 0x0e, 0x9e, 0xb0, 0x9e, 0x20, 0x58, 0xdd, 0x36, 0xda, 0xc3, 0x72, 0xb2, 0x0c, - 0x0a, 0xe4, 0xd9, 0xd6, 0xe1, 0x38, 0x94, 0x06, 0x56, 0xec, 0x8f, 0x18, 0x4e, 0xd0, 0x19, 0xeb, - 0x4a, 0x03, 0xeb, 0x54, 0x64, 0xab, 0xea, 0x88, 0x4a, 0xc9, 0x15, 0xe9, 0xad, 0x87, 0x4d, 0xba, - 0xcc, 0xe2, 0x8a, 0x6b, 0x75, 0x29, 0x97, 0x75, 0x63, 0xe0, 0x8c, 0xdf, 0x08, 0x65, 0xb8, 0x5f, - 0x63, 0xd7, 0x35, 0xe4, 0x21, 0xe2, 0xe0, 0x11, 0x55, 0x22, 0xa5, 0xbd, 0x23, 0xdb, 0x9b, 0xb2, - 0xff, 0x8a, 0x10, 0xf3, 0x95, 0x47, 0x26, 0xcc, 0x35, 0x0e, 0x46, 0x93, 0x05, 0x99, 0x8a, 0x2c, - 0xaa, 0x66, 0x0a, 0x7e, 0x7a, 0x02, 0x9e, 0x4e, 0xf3, 0x4e, 0x14, 0xfa, 0x71, 0x63, 0x6b, 0xe1, - 0x9c, 0x2d, 0xd7, 0xea, 0x95, 0x8c, 0xcc, 0xe8, 0x34, 0x35, 0xd8, 0xc3, 0x05, 0xb7, 0xff, 0x8f, - 0xd5, 0x6b, 0x19, 0xd7, 0xce, 0x6a, 0xb2, 0xe6, 0x86, 0xe0, 0x19, 0x1f, 0xfe, 0x17, 0xea, 0x5a, - 0x9e, 0x3b, 0xab, 0x0d, 0xf6, 0xed, 0xfd, 0x87, 0xc6, 0x78, 0x78, 0xce, 0xcd, 0x9f, 0x38, 0xf5, - 0x46, 0x5e, 0x04, 0xde, 0xb9, 0x86, 0x2c, 0x87, 0x2e, 0x39, 0x74, 0x2a, 0x43, 0xbf, 0x9e, 0x34, - 0x8d, 0x1e, 0x5e, 0xa4, 0x22, 0x5b, 0x57, 0x33, 0xbd, 0xbf, 0xf9, 0xb5, 0x4f, 0xc4, 0xc3, 0x3e, - 0x11, 0x7f, 0xf6, 0x89, 0xf8, 0x71, 0x48, 0x16, 0x0f, 0x87, 0x64, 0xf1, 0xfb, 0x90, 0x2c, 0xbe, - 0xbc, 0xdd, 0x36, 0xf4, 0x6d, 0xbc, 0xcd, 0x6b, 0xec, 0x8a, 0xcf, 0x1a, 0x3f, 0x4d, 0xff, 0xbf, - 0x08, 0x4b, 0x72, 0x37, 0xaf, 0x09, 0xdd, 0x0f, 0xd6, 0xdf, 0x6e, 0x78, 0x49, 0xde, 0xfd, 0x0d, - 0x00, 0x00, 0xff, 0xff, 0xd0, 0xa6, 0xb7, 0xf9, 0x40, 0x02, 0x00, 0x00, + // 390 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x92, 0xc1, 0x6e, 0xd4, 0x30, + 0x10, 0x86, 0xd7, 0x64, 0x77, 0xbb, 0x31, 0x2d, 0x14, 0xab, 0x42, 0x23, 0x84, 0xa2, 0xa8, 0x42, + 0x22, 0xa7, 0xe4, 0xc0, 0x13, 0x14, 0x71, 0xc9, 0x01, 0x0e, 0xe1, 0xc6, 0xcd, 0x8d, 0xcd, 0x12, + 0x91, 0x64, 0x22, 0x7b, 0xa2, 0x6d, 0xdf, 0x82, 0xc7, 0xe2, 0xd8, 0x23, 0xe2, 0x84, 0x76, 0x5f, + 0x04, 0x79, 0x92, 0x85, 0xee, 0x29, 0xf3, 0x7d, 0xfe, 0x6d, 0xcd, 0x44, 0x23, 0xc1, 0x6b, 0x2c, + 0x3a, 0x34, 0xb6, 0x2d, 0x3a, 0x4b, 0xda, 0x68, 0xd2, 0xf9, 0xe0, 0x90, 0x50, 0x5d, 0x79, 0x8d, + 0xbd, 0xa5, 0x1d, 0xba, 0xef, 0xb9, 0xd7, 0x98, 0x73, 0xe8, 0xfa, 0x77, 0x24, 0x37, 0x1f, 0xe7, + 0xa0, 0x7a, 0x29, 0xd7, 0xe1, 0x5b, 0x1a, 0x10, 0xa9, 0xc8, 0xe2, 0x6a, 0x26, 0x75, 0x25, 0x57, + 0xb8, 0xeb, 0xad, 0x83, 0x27, 0xac, 0x27, 0x08, 0x56, 0xb7, 0x8d, 0xf6, 0x10, 0x4d, 0x96, 0x41, + 0x81, 0x3c, 0xdb, 0x3a, 0x1c, 0x87, 0xd2, 0xc0, 0x92, 0xfd, 0x11, 0xc3, 0x09, 0x3a, 0x63, 0x5d, + 0x69, 0x60, 0x95, 0x8a, 0x6c, 0x59, 0x1d, 0x51, 0x29, 0xb9, 0x24, 0xbd, 0xf5, 0xb0, 0x4e, 0xa3, + 0x2c, 0xae, 0xb8, 0x56, 0x97, 0x32, 0xaa, 0x1b, 0x03, 0x67, 0xfc, 0x46, 0x28, 0xc3, 0xfd, 0x1a, + 0xbb, 0xae, 0x21, 0x0f, 0x1b, 0x0e, 0x1e, 0x51, 0x25, 0x52, 0xda, 0x3b, 0xb2, 0xbd, 0x29, 0xfb, + 0xaf, 0x08, 0x31, 0x5f, 0x79, 0x64, 0xc2, 0x5c, 0xe3, 0x60, 0x34, 0x59, 0x90, 0xa9, 0xc8, 0x36, + 0xd5, 0x4c, 0xc1, 0x4f, 0x4f, 0xc0, 0xd3, 0x69, 0xde, 0x89, 0x42, 0x3f, 0x6e, 0x6c, 0x2d, 0x9c, + 0xb3, 0xe5, 0x5a, 0xbd, 0x92, 0x1b, 0x33, 0x3a, 0x4d, 0x0d, 0xf6, 0x70, 0xc1, 0xed, 0xff, 0x63, + 0xf5, 0x5a, 0xc6, 0xb5, 0xb3, 0x9a, 0xac, 0xb9, 0x21, 0x78, 0xc6, 0x87, 0xff, 0x85, 0xba, 0x96, + 0xe7, 0xce, 0x6a, 0x83, 0x7d, 0x7b, 0xff, 0xa1, 0x31, 0x1e, 0x9e, 0x73, 0xf3, 0x27, 0x4e, 0xbd, + 0x91, 0x17, 0x81, 0x77, 0xae, 0x21, 0xcb, 0xa1, 0x4b, 0x0e, 0x9d, 0xca, 0xd0, 0xaf, 0x27, 0x4d, + 0xa3, 0x87, 0x17, 0xa9, 0xc8, 0x56, 0xd5, 0x4c, 0xc1, 0xf3, 0xaf, 0xf4, 0xa0, 0xd2, 0x28, 0x5b, + 0x56, 0x33, 0xbd, 0xbf, 0xf9, 0xb9, 0x4f, 0xc4, 0xc3, 0x3e, 0x11, 0x7f, 0xf6, 0x89, 0xf8, 0x71, + 0x48, 0x16, 0x0f, 0x87, 0x64, 0xf1, 0xeb, 0x90, 0x2c, 0xbe, 0xbc, 0xdd, 0x36, 0xf4, 0x6d, 0xbc, + 0xcd, 0x6b, 0xec, 0x8a, 0xcf, 0x1a, 0x3f, 0x4d, 0x7b, 0x51, 0x84, 0xe5, 0xb9, 0x9b, 0xd7, 0x87, + 0xee, 0x07, 0xeb, 0x6f, 0xd7, 0xbc, 0x3c, 0xef, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x88, 0xba, + 0xa7, 0x93, 0x58, 0x02, 0x00, 0x00, } func (m *Metadata) Marshal() (dAtA []byte, err error) { @@ -248,6 +257,26 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Orders) > 0 { + dAtA2 := make([]byte, len(m.Orders)*10) + var j1 int + for _, num := range m.Orders { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintMetadata(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } if m.Status != 0 { i = encodeVarintMetadata(dAtA, i, uint64(m.Status)) i-- @@ -465,6 +494,13 @@ func (m *Metadata) Size() (n int) { if m.Status != 0 { n += 2 + sovMetadata(uint64(m.Status)) } + if len(m.Orders) > 0 { + l = 0 + for _, e := range m.Orders { + l += sovMetadata(uint64(e)) + } + n += 2 + sovMetadata(uint64(l)) + l + } return n } @@ -983,6 +1019,82 @@ func (m *Metadata) Unmarshal(dAtA []byte) error { break } } + case 18: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Orders = append(m.Orders, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Orders) == 0 { + m.Orders = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Orders = append(m.Orders, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Orders", wireType) + } default: iNdEx = preIndex skippy, err := skipMetadata(dAtA[iNdEx:]) diff --git a/x/node/keeper/msg_server_claim_reward.go b/x/node/keeper/msg_server_claim_reward.go index 5df3199c..26ac1c90 100644 --- a/x/node/keeper/msg_server_claim_reward.go +++ b/x/node/keeper/msg_server_claim_reward.go @@ -45,49 +45,21 @@ func (k msgServer) ClaimReward(goCtx context.Context, msg *types.MsgClaimReward) return nil, err } - pledgeDebt, found := k.GetPledgeDebt(ctx, msg.Creator) - if found { - logger.Debug("CoinTrace: repay pledge debt", "blockReward", claimReward.String(), "orderReward", workerReward.String(), "debt", pledgeDebt.Debt.String()) - if pledgeDebt.Debt.IsLT(claimReward) { - finalClaim := claimReward.Sub(pledgeDebt.Debt) - logger.Debug("CoinTrace: claim reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", finalClaim.String()) - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{finalClaim}) - if err != nil { - return nil, err - } - k.RemovePledgeDebt(ctx, msg.Creator) - logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", workerReward.String()) - err = k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{workerReward}) - } else { - pledgeDebt.Debt = pledgeDebt.Debt.Sub(claimReward) - - if pledgeDebt.Debt.IsLT(workerReward) { - finalClaim := workerReward.Sub(pledgeDebt.Debt) - logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", finalClaim.String()) - err := k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{finalClaim}) - if err != nil { - return nil, err - } - k.RemovePledgeDebt(ctx, msg.Creator) - } else { - pledgeDebt.Debt = pledgeDebt.Debt.Sub(workerReward) - k.SetPledgeDebt(ctx, pledgeDebt) - } - } - } else { - logger.Debug("CoinTrace: claim reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", claimReward.String()) - if !claimReward.IsZero() { - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{claimReward}) - if err != nil { - return nil, err - } + k.RepayPledgeDebt(ctx, msg.Creator, []*sdk.Coin{&claimReward, &workerReward}) + + if !claimReward.IsZero() { + logger.Debug("CoinTrace: block reward", "from", types.ModuleName, "to", msg.GetSigners()[0], "amount", claimReward.String()) + + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msg.GetSigners()[0], sdk.Coins{claimReward}) + if err != nil { + return nil, err } - if !workerReward.IsZero() { - logger.Debug("CoinTrace: claim", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", workerReward.String()) - err = k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{workerReward}) - if err != nil { - return nil, err - } + } + if !workerReward.IsZero() { + logger.Debug("CoinTrace: worker reward", "from", markettypes.ModuleName, "to", msg.GetSigners()[0], "amount", workerReward.String()) + err = k.bank.SendCoinsFromModuleToAccount(ctx, markettypes.ModuleName, msg.GetSigners()[0], sdk.Coins{workerReward}) + if err != nil { + return nil, err } } diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 3e739103..4446861e 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -169,8 +169,6 @@ func (k Keeper) ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp pledge.Reward.Amount = pledge.Reward.Amount.Add(pending) } - var coins sdk.Coins - if shard != nil { logger.Debug("PledgeTrace: order release 2", "sp", sp.String(), @@ -180,29 +178,15 @@ func (k Keeper) ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp shardPledge := shard.Pledge - pledgeDebt, found := k.GetPledgeDebt(ctx, shard.Sp) - if found { - if pledgeDebt.Debt.IsLT(shardPledge) { - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, sdk.Coins{shardPledge.Sub(pledgeDebt.Debt)}) - if err != nil { - return err - } - - k.RemovePledgeDebt(ctx, shard.Sp) - } else { - pledgeDebt.Debt = pledgeDebt.Debt.Sub(shardPledge) - - k.SetPledgeDebt(ctx, pledgeDebt) - } - } else { + k.RepayPledgeDebt(ctx, shard.Sp, []*sdk.Coin{&shardPledge}) - coins = coins.Add(shardPledge) + if !shardPledge.IsZero() { logger.Debug("CoinTrace: order release", "from", types.ModuleName, "to", sp.String(), - "amount", coins.String()) + "amount", shardPledge.String()) - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, coins) + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sp, sdk.Coins{shardPledge}) if err != nil { return err } @@ -210,7 +194,7 @@ func (k Keeper) ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp pledge.TotalStorage -= int64(shard.Size_) - pledge.TotalStoragePledged = pledge.TotalStoragePledged.Sub(shardPledge) + pledge.TotalStoragePledged = pledge.TotalStoragePledged.Sub(shard.Pledge) logger.Debug("PoolTrace: order release", "totalStorage", pool.TotalStorage, @@ -218,7 +202,7 @@ func (k Keeper) ShardRelease(ctx sdk.Context, sp sdk.AccAddress, shard *ordertyp pool.TotalStorage -= int64(shard.Size_) - pool.TotalPledged = pool.TotalPledged.Sub(shardPledge) + pool.TotalPledged = pool.TotalPledged.Sub(shard.Pledge) } newRewardDebt := pool.AccRewardPerByte.Amount.MulInt64(pledge.TotalStorage) @@ -272,3 +256,23 @@ func (Keeper) StoreRewardPledge(duration uint64, size uint64, rewardPerByte sdk. MulInt64(OrderAmountNumerator). QuoInt64(OrderAmountDenominator) } + +func (k Keeper) RepayPledgeDebt(ctx sdk.Context, sp string, rewards []*sdk.Coin) { + pledgeDebt, found := k.GetPledgeDebt(ctx, sp) + logger := k.Logger(ctx) + if found { + logger.Debug("CoinTrace: repay pledge debt", "rewards", rewards, "debt", pledgeDebt.Debt.String()) + + for _, reward := range rewards { + if reward.IsGTE(pledgeDebt.Debt) { + *reward = reward.Sub(pledgeDebt.Debt) + k.RemovePledgeDebt(ctx, sp) + return + } else { + pledgeDebt.Debt = pledgeDebt.Debt.Sub(*reward) + *reward = sdk.NewCoin(reward.Denom, sdk.NewInt(0)) + } + } + k.SetPledgeDebt(ctx, pledgeDebt) + } +} \ No newline at end of file diff --git a/x/order/keeper/shard_management.go b/x/order/keeper/shard_management.go index 673fee6b..f2d6818f 100644 --- a/x/order/keeper/shard_management.go +++ b/x/order/keeper/shard_management.go @@ -88,14 +88,14 @@ func (k Keeper) RenewShard(ctx sdk.Context, order *types.Order, sp string) error return nil } -func (k Keeper) MigrateShard(ctx sdk.Context, order *types.Order, from string, to string) *types.Shard { +func (k Keeper) MigrateShard(ctx sdk.Context, oldShard *types.Shard, order *types.Order, from string, to string) *types.Shard { shard := types.Shard{ OrderId: order.Id, Status: types.ShardWaiting, - Cid: order.Cid, + Cid: oldShard.Cid, From: from, - Size_: order.Size_, + Size_: oldShard.Size_, Sp: to, } @@ -103,11 +103,10 @@ func (k Keeper) MigrateShard(ctx sdk.Context, order *types.Order, from string, t ctx.EventManager().EmitEvent( sdk.NewEvent(types.NewShardEventType, - sdk.NewAttribute(types.EventOrderId, fmt.Sprintf("%d", order.Id)), + sdk.NewAttribute(types.EventOrderId, fmt.Sprintf("%d", oldShard.OrderId)), sdk.NewAttribute(types.OrderEventProvider, order.Provider), sdk.NewAttribute(types.ShardEventProvider, from), sdk.NewAttribute(types.EventCid, shard.Cid), - sdk.NewAttribute(types.EventOrderId, fmt.Sprintf("%d", order.Id)), sdk.NewAttribute(types.OrderEventOperation, fmt.Sprintf("%d", order.Operation)), ), ) diff --git a/x/order/migrations/v3/migrations.go b/x/order/migrations/v3/migrations.go index fdbd38fd..1c9d7ccb 100644 --- a/x/order/migrations/v3/migrations.go +++ b/x/order/migrations/v3/migrations.go @@ -58,16 +58,17 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar cdc.MustUnmarshal(val, &shard) newShard := types.Shard{ - Id: shard.Id, - OrderId: shard.OrderId, - Status: shard.Status, - Size_: shard.Size_, - Cid: shard.Cid, - Pledge: shard.Pledge, - From: shard.From, - Sp: shard.Sp, - Duration: order.Duration, - CreatedAt: order.CreatedAt, + Id: shard.Id, + OrderId: shard.OrderId, + Status: shard.Status, + Size_: shard.Size_, + Cid: shard.Cid, + Pledge: shard.Pledge, + From: shard.From, + Sp: shard.Sp, + Duration: order.Duration, + CreatedAt: order.CreatedAt, + RenewInfos: nil, } newVal := cdc.MustMarshal(&newShard) diff --git a/x/order/types/renew_info.pb.go b/x/order/types/renew_info.pb.go new file mode 100644 index 00000000..21d4d841 --- /dev/null +++ b/x/order/types/renew_info.pb.go @@ -0,0 +1,395 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sao/order/renew_info.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type RenewInfo struct { + OrderId uint64 `protobuf:"varint,1,opt,name=orderId,proto3" json:"orderId,omitempty"` + Pledge types.Coin `protobuf:"bytes,2,opt,name=pledge,proto3" json:"pledge"` + Duration uint64 `protobuf:"varint,3,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *RenewInfo) Reset() { *m = RenewInfo{} } +func (m *RenewInfo) String() string { return proto.CompactTextString(m) } +func (*RenewInfo) ProtoMessage() {} +func (*RenewInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_90fdb280e2671da1, []int{0} +} +func (m *RenewInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RenewInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RenewInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RenewInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RenewInfo.Merge(m, src) +} +func (m *RenewInfo) XXX_Size() int { + return m.Size() +} +func (m *RenewInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RenewInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RenewInfo proto.InternalMessageInfo + +func (m *RenewInfo) GetOrderId() uint64 { + if m != nil { + return m.OrderId + } + return 0 +} + +func (m *RenewInfo) GetPledge() types.Coin { + if m != nil { + return m.Pledge + } + return types.Coin{} +} + +func (m *RenewInfo) GetDuration() uint64 { + if m != nil { + return m.Duration + } + return 0 +} + +func init() { + proto.RegisterType((*RenewInfo)(nil), "saonetwork.sao.order.RenewInfo") +} + +func init() { proto.RegisterFile("sao/order/renew_info.proto", fileDescriptor_90fdb280e2671da1) } + +var fileDescriptor_90fdb280e2671da1 = []byte{ + // 258 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x18, 0x85, 0xe3, 0x7b, 0xab, 0x02, 0x66, 0x8b, 0x3a, 0x84, 0x0c, 0xa6, 0x62, 0xa1, 0x93, 0xad, + 0xc2, 0xc0, 0x4c, 0x99, 0xba, 0x30, 0x84, 0x8d, 0x05, 0x39, 0x89, 0x1b, 0x2c, 0xa8, 0x4f, 0x64, + 0xbb, 0x14, 0x78, 0x0a, 0x1e, 0xab, 0x63, 0x47, 0x26, 0x84, 0x92, 0x17, 0x41, 0x71, 0x02, 0xdb, + 0x7f, 0xf4, 0x7f, 0xfa, 0xa4, 0x73, 0x68, 0xea, 0x24, 0x04, 0x6c, 0xa9, 0xac, 0xb0, 0xca, 0xa8, + 0xed, 0x83, 0x36, 0x2b, 0xf0, 0xda, 0xc2, 0x23, 0x9e, 0x38, 0x09, 0xa3, 0xfc, 0x16, 0xf6, 0x89, + 0x3b, 0x09, 0x1e, 0xb0, 0x74, 0x52, 0xa1, 0x42, 0x00, 0x44, 0x77, 0xf5, 0x6c, 0xca, 0x0a, 0xb8, + 0x35, 0x9c, 0xc8, 0xa5, 0x53, 0xe2, 0x65, 0x9e, 0x2b, 0x2f, 0xe7, 0xa2, 0x80, 0x36, 0xfd, 0xff, + 0xec, 0x9d, 0x1e, 0x65, 0x9d, 0x7f, 0x69, 0x56, 0x88, 0x13, 0x7a, 0x10, 0x5c, 0xcb, 0x32, 0x21, + 0x53, 0x32, 0x1b, 0x65, 0xbf, 0x31, 0xbe, 0xa2, 0xe3, 0xfa, 0x59, 0x95, 0x95, 0x4a, 0xfe, 0x4d, + 0xc9, 0xec, 0xf8, 0xe2, 0x84, 0xf7, 0x5e, 0xde, 0x79, 0xf9, 0xe0, 0xe5, 0x37, 0xd0, 0x66, 0x31, + 0xda, 0x7d, 0x9d, 0x46, 0xd9, 0x80, 0xc7, 0x29, 0x3d, 0x2c, 0x37, 0x56, 0x7a, 0x0d, 0x93, 0xfc, + 0x0f, 0xce, 0xbf, 0xbc, 0xb8, 0xde, 0x35, 0x8c, 0xec, 0x1b, 0x46, 0xbe, 0x1b, 0x46, 0x3e, 0x5a, + 0x16, 0xed, 0x5b, 0x16, 0x7d, 0xb6, 0x2c, 0xba, 0x3f, 0xaf, 0xb4, 0x7f, 0xdc, 0xe4, 0xbc, 0xc0, + 0x5a, 0xdc, 0x49, 0xdc, 0xf6, 0x65, 0x45, 0xb7, 0xc9, 0xeb, 0xb0, 0x8a, 0x7f, 0xab, 0x95, 0xcb, + 0xc7, 0xa1, 0xc5, 0xe5, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x70, 0x7d, 0xfa, 0x2f, 0x01, + 0x00, 0x00, +} + +func (m *RenewInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RenewInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RenewInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Duration != 0 { + i = encodeVarintRenewInfo(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x18 + } + { + size, err := m.Pledge.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRenewInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.OrderId != 0 { + i = encodeVarintRenewInfo(dAtA, i, uint64(m.OrderId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintRenewInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovRenewInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RenewInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.OrderId != 0 { + n += 1 + sovRenewInfo(uint64(m.OrderId)) + } + l = m.Pledge.Size() + n += 1 + l + sovRenewInfo(uint64(l)) + if m.Duration != 0 { + n += 1 + sovRenewInfo(uint64(m.Duration)) + } + return n +} + +func sovRenewInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRenewInfo(x uint64) (n int) { + return sovRenewInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RenewInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RenewInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RenewInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderId", wireType) + } + m.OrderId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OrderId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pledge", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRenewInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRenewInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Pledge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipRenewInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRenewInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRenewInfo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRenewInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRenewInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRenewInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRenewInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRenewInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRenewInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRenewInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/order/types/shard.pb.go b/x/order/types/shard.pb.go index 299340c5..98750e1c 100644 --- a/x/order/types/shard.pb.go +++ b/x/order/types/shard.pb.go @@ -25,16 +25,17 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Shard struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - OrderId uint64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` - Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` - Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` - Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` - Pledge types.Coin `protobuf:"bytes,6,opt,name=pledge,proto3" json:"pledge"` - From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"` - Sp string `protobuf:"bytes,8,opt,name=sp,proto3" json:"sp,omitempty"` - Duration uint64 `protobuf:"varint,9,opt,name=duration,proto3" json:"duration,omitempty"` - CreatedAt uint64 `protobuf:"varint,10,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + OrderId uint64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` + Size_ uint64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + Cid string `protobuf:"bytes,5,opt,name=cid,proto3" json:"cid,omitempty"` + Pledge types.Coin `protobuf:"bytes,6,opt,name=pledge,proto3" json:"pledge"` + From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"` + Sp string `protobuf:"bytes,8,opt,name=sp,proto3" json:"sp,omitempty"` + Duration uint64 `protobuf:"varint,9,opt,name=duration,proto3" json:"duration,omitempty"` + CreatedAt uint64 `protobuf:"varint,10,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + RenewInfos []RenewInfo `protobuf:"bytes,11,rep,name=renewInfos,proto3" json:"renewInfos"` } func (m *Shard) Reset() { *m = Shard{} } @@ -140,6 +141,13 @@ func (m *Shard) GetCreatedAt() uint64 { return 0 } +func (m *Shard) GetRenewInfos() []RenewInfo { + if m != nil { + return m.RenewInfos + } + return nil +} + func init() { proto.RegisterType((*Shard)(nil), "saonetwork.sao.order.Shard") } @@ -147,29 +155,31 @@ func init() { func init() { proto.RegisterFile("sao/order/shard.proto", fileDescriptor_b050d2e483ae2036) } var fileDescriptor_b050d2e483ae2036 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0xbd, 0x6e, 0xdb, 0x30, - 0x14, 0x85, 0x45, 0x59, 0x96, 0x6d, 0x16, 0x28, 0x0a, 0xc2, 0x2d, 0x58, 0xa3, 0x50, 0x85, 0x2e, - 0xd5, 0x44, 0xc2, 0xed, 0x90, 0xd9, 0xce, 0x94, 0x25, 0x83, 0xbc, 0x65, 0xa3, 0x44, 0x46, 0x26, - 0x12, 0xeb, 0x0a, 0x24, 0x9d, 0xbf, 0x07, 0xc8, 0x9c, 0xc7, 0xf2, 0xe8, 0x31, 0x53, 0x10, 0xd8, - 0x2f, 0x12, 0x88, 0x52, 0x92, 0xed, 0xdc, 0xc3, 0xc3, 0x83, 0x0f, 0xf7, 0xe2, 0xef, 0x56, 0x00, - 0x07, 0x23, 0x95, 0xe1, 0x76, 0x2d, 0x8c, 0x64, 0x8d, 0x01, 0x07, 0x64, 0x6a, 0x05, 0xd4, 0xca, - 0xdd, 0x82, 0xb9, 0x62, 0x56, 0x00, 0xf3, 0x89, 0x59, 0x52, 0x82, 0xdd, 0x80, 0xe5, 0x85, 0xb0, - 0x8a, 0xdf, 0xcc, 0x0b, 0xe5, 0xc4, 0x9c, 0x97, 0xa0, 0xeb, 0xee, 0xd7, 0x6c, 0x5a, 0x41, 0x05, - 0x5e, 0xf2, 0x56, 0x75, 0xee, 0x9f, 0xc7, 0x10, 0x0f, 0x57, 0x6d, 0x37, 0xf9, 0x8a, 0x43, 0x2d, - 0x29, 0x4a, 0x51, 0x16, 0xe5, 0xa1, 0x96, 0x84, 0xe2, 0x91, 0x2f, 0x3e, 0x93, 0x34, 0xf4, 0xe6, - 0xfb, 0x48, 0x7e, 0xe0, 0xd8, 0x3a, 0xe1, 0xb6, 0x96, 0x0e, 0x52, 0x94, 0x0d, 0xf3, 0x7e, 0x22, - 0x04, 0x47, 0x56, 0x3f, 0x28, 0x1a, 0xf9, 0xb8, 0xd7, 0xe4, 0x1b, 0x1e, 0x94, 0x5a, 0xd2, 0x61, - 0x8a, 0xb2, 0x49, 0xde, 0x4a, 0x72, 0x82, 0xe3, 0xe6, 0x5a, 0xc9, 0x4a, 0xd1, 0x38, 0x45, 0xd9, - 0x97, 0x7f, 0x3f, 0x59, 0x07, 0xce, 0x5a, 0x70, 0xd6, 0x83, 0xb3, 0x53, 0xd0, 0xf5, 0x32, 0xda, - 0xbd, 0xfc, 0x0e, 0xf2, 0x3e, 0xde, 0xd6, 0x5f, 0x1a, 0xd8, 0xd0, 0x91, 0xef, 0xf2, 0xba, 0x85, - 0xb6, 0x0d, 0x1d, 0x7b, 0x27, 0xb4, 0x0d, 0x99, 0xe1, 0xb1, 0xdc, 0x1a, 0xe1, 0x34, 0xd4, 0x74, - 0xe2, 0x31, 0x3e, 0x66, 0xf2, 0x0b, 0x4f, 0x4a, 0xa3, 0x84, 0x53, 0x72, 0xe1, 0x28, 0xf6, 0x8f, - 0x9f, 0xc6, 0x72, 0xb1, 0x3b, 0x24, 0x68, 0x7f, 0x48, 0xd0, 0xeb, 0x21, 0x41, 0x4f, 0xc7, 0x24, - 0xd8, 0x1f, 0x93, 0xe0, 0xf9, 0x98, 0x04, 0x17, 0x7f, 0x2b, 0xed, 0xd6, 0xdb, 0x82, 0x95, 0xb0, - 0xe1, 0x2b, 0x01, 0xe7, 0xdd, 0xe6, 0x79, 0x7b, 0x9b, 0xbb, 0xfe, 0x3a, 0xee, 0xbe, 0x51, 0xb6, - 0x88, 0xfd, 0x4a, 0xff, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff, 0x85, 0x30, 0xb7, 0xef, 0xb7, 0x01, - 0x00, 0x00, + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0xbd, 0xae, 0xd3, 0x30, + 0x18, 0x8d, 0xd3, 0x34, 0xf7, 0xd6, 0x95, 0x10, 0xb2, 0x2e, 0xc8, 0x44, 0x28, 0x8d, 0x58, 0xc8, + 0x64, 0xab, 0x65, 0x60, 0x6e, 0x11, 0x43, 0x17, 0x86, 0x74, 0x63, 0x41, 0x4e, 0xec, 0xa6, 0x16, + 0x34, 0x5f, 0x64, 0xbb, 0x14, 0x78, 0x0a, 0x1e, 0xab, 0x0b, 0x52, 0x47, 0x26, 0x84, 0xda, 0x17, + 0x41, 0x71, 0x53, 0xca, 0xc0, 0x76, 0xbe, 0xe3, 0xf3, 0xfd, 0x1c, 0x1f, 0xfc, 0xc4, 0x0a, 0xe0, + 0x60, 0xa4, 0x32, 0xdc, 0x6e, 0x84, 0x91, 0xac, 0x35, 0xe0, 0x80, 0x3c, 0x58, 0x01, 0x8d, 0x72, + 0x7b, 0x30, 0x1f, 0x99, 0x15, 0xc0, 0xbc, 0x22, 0x49, 0x2b, 0xb0, 0x5b, 0xb0, 0xbc, 0x14, 0x56, + 0xf1, 0xcf, 0xd3, 0x52, 0x39, 0x31, 0xe5, 0x15, 0xe8, 0xe6, 0xd2, 0x95, 0x3c, 0xd4, 0x50, 0x83, + 0x87, 0xbc, 0x43, 0x3d, 0x9b, 0xdc, 0x56, 0x18, 0xd5, 0xa8, 0xfd, 0x07, 0xdd, 0xac, 0xfb, 0xb7, + 0x17, 0x3f, 0x42, 0x3c, 0x5c, 0x75, 0x7b, 0xc9, 0x23, 0x1c, 0x6a, 0x49, 0x51, 0x86, 0xf2, 0xa8, + 0x08, 0xb5, 0x24, 0x14, 0xdf, 0xf9, 0x9e, 0xa5, 0xa4, 0xa1, 0x27, 0xaf, 0x25, 0x79, 0x8a, 0x63, + 0xeb, 0x84, 0xdb, 0x59, 0x3a, 0xc8, 0x50, 0x3e, 0x2c, 0xfa, 0x8a, 0x10, 0x1c, 0x59, 0xfd, 0x4d, + 0xd1, 0xc8, 0xcb, 0x3d, 0x26, 0x8f, 0xf1, 0xa0, 0xd2, 0x92, 0x0e, 0x33, 0x94, 0x8f, 0x8a, 0x0e, + 0x92, 0xd7, 0x38, 0x6e, 0x3f, 0x29, 0x59, 0x2b, 0x1a, 0x67, 0x28, 0x1f, 0xcf, 0x9e, 0xb1, 0x8b, + 0x29, 0xd6, 0x99, 0x62, 0xbd, 0x29, 0xf6, 0x06, 0x74, 0xb3, 0x88, 0x0e, 0xbf, 0x26, 0x41, 0xd1, + 0xcb, 0xbb, 0xf1, 0x6b, 0x03, 0x5b, 0x7a, 0xe7, 0x67, 0x79, 0xdc, 0x1d, 0x6d, 0x5b, 0x7a, 0xef, + 0x99, 0xd0, 0xb6, 0x24, 0xc1, 0xf7, 0x72, 0x67, 0x84, 0xd3, 0xd0, 0xd0, 0x91, 0x3f, 0xe3, 0x6f, + 0x4d, 0x9e, 0xe3, 0x51, 0x65, 0x94, 0x70, 0x4a, 0xce, 0x1d, 0xc5, 0xfe, 0xf1, 0x46, 0x90, 0xb7, + 0x18, 0xfb, 0xcf, 0x59, 0x36, 0x6b, 0xb0, 0x74, 0x9c, 0x0d, 0xf2, 0xf1, 0x6c, 0xc2, 0xfe, 0x97, + 0x02, 0x2b, 0xae, 0xba, 0xfe, 0xc0, 0x7f, 0x1a, 0x17, 0xf3, 0xc3, 0x29, 0x45, 0xc7, 0x53, 0x8a, + 0x7e, 0x9f, 0x52, 0xf4, 0xfd, 0x9c, 0x06, 0xc7, 0x73, 0x1a, 0xfc, 0x3c, 0xa7, 0xc1, 0xfb, 0x97, + 0xb5, 0x76, 0x9b, 0x5d, 0xc9, 0x2a, 0xd8, 0xf2, 0x95, 0x80, 0x77, 0x97, 0xb1, 0xbc, 0xcb, 0xe6, + 0x4b, 0x9f, 0x8e, 0xfb, 0xda, 0x2a, 0x5b, 0xc6, 0x3e, 0x99, 0x57, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x43, 0x1b, 0x88, 0x2a, 0x1a, 0x02, 0x00, 0x00, } func (m *Shard) Marshal() (dAtA []byte, err error) { @@ -192,6 +202,20 @@ func (m *Shard) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.RenewInfos) > 0 { + for iNdEx := len(m.RenewInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RenewInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintShard(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } if m.CreatedAt != 0 { i = encodeVarintShard(dAtA, i, uint64(m.CreatedAt)) i-- @@ -305,6 +329,12 @@ func (m *Shard) Size() (n int) { if m.CreatedAt != 0 { n += 1 + sovShard(uint64(m.CreatedAt)) } + if len(m.RenewInfos) > 0 { + for _, e := range m.RenewInfos { + l = e.Size() + n += 1 + l + sovShard(uint64(l)) + } + } return n } @@ -586,6 +616,40 @@ func (m *Shard) Unmarshal(dAtA []byte) error { break } } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RenewInfos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShard + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShard + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthShard + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RenewInfos = append(m.RenewInfos, RenewInfo{}) + if err := m.RenewInfos[len(m.RenewInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipShard(dAtA[iNdEx:]) diff --git a/x/sao/keeper/expired_shard.go b/x/sao/keeper/expired_shard.go index 23d84188..279748cf 100644 --- a/x/sao/keeper/expired_shard.go +++ b/x/sao/keeper/expired_shard.go @@ -1,7 +1,6 @@ package keeper import ( - ordertypes "github.com/SaoNetwork/sao/x/order/types" "github.com/SaoNetwork/sao/x/sao/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -63,15 +62,15 @@ func (k Keeper) GetAllExpiredShard(ctx sdk.Context) (list []types.ExpiredShard) return } -func (k Keeper) SetExpiredShardBlock(ctx sdk.Context, shard ordertypes.Shard, expiredAt uint64) { +func (k Keeper) SetExpiredShardBlock(ctx sdk.Context, shardId uint64, expiredAt uint64) { expiredShard, found := k.GetExpiredShard(ctx, expiredAt) if found { - expiredShard.ShardList = append(expiredShard.ShardList, shard.Id) + expiredShard.ShardList = append(expiredShard.ShardList, shardId) } else { expiredShard = types.ExpiredShard{ Height: expiredAt, - ShardList: []uint64{shard.Id}, + ShardList: []uint64{shardId}, } } diff --git a/x/sao/keeper/msg_server_complete.go b/x/sao/keeper/msg_server_complete.go index b435d09e..e2a4c603 100644 --- a/x/sao/keeper/msg_server_complete.go +++ b/x/sao/keeper/msg_server_complete.go @@ -116,6 +116,8 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ return &types.MsgCompleteResponse{}, err } + orderInProgress := order + if shard.From != "" { // shard migrate sp := sdk.MustAccAddressFromBech32(shard.From) @@ -124,21 +126,41 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ if err != nil { return nil, err } - err = k.market.Migrate(ctx, order, shard.From, msg.Provider) - if err != nil { - return nil, err + orderList := []*ordertypes.Order{&order} + if oldShard.OrderId != order.Id { + // The order in progress is the one corresponding to the orderId field in oldShard, + // which is used to correctly calculate the next Migrate and ShardPledge + orderInProgress, _ = k.order.GetOrder(ctx, oldShard.OrderId) + orderList = append(orderList, &orderInProgress) } + shard.OrderId = oldShard.OrderId + shard.RenewInfos = oldShard.RenewInfos shard.CreatedAt = uint64(ctx.BlockHeight()) shard.Duration = oldShard.CreatedAt + oldShard.Duration - shard.CreatedAt - if oldShard != nil { - k.order.RemoveShard(ctx, oldShard.Id) + err = k.market.Migrate(ctx, orderInProgress, *oldShard, *shard) + if err != nil { + return nil, err + } + k.order.RemoveShard(ctx, oldShard.Id) + if len(oldShard.RenewInfos) > 1 { + for i := 0; i < len(oldShard.RenewInfos)-1; i++ { + order, _ := k.order.GetOrder(ctx, oldShard.RenewInfos[i].OrderId) + orderList = append(orderList, &order) + } + } + for i, order := range orderList { newShards := make([]uint64, 0) for _, id := range order.Shards { if id != oldShard.Id { newShards = append(newShards, id) } } + // first order has set new shard in shards in migrate + if i > 0 { + newShards = append(newShards, shard.Id) + } order.Shards = newShards + k.order.SetOrder(ctx, *order) } } else { shard.CreatedAt = uint64(ctx.BlockHeight()) @@ -147,12 +169,12 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ // active shard k.order.FulfillShard(ctx, shard, msg.Provider, msg.Cid) - k.order.SetShard(ctx, *shard) - k.SetExpiredShardBlock(ctx, *shard, shard.CreatedAt+shard.Duration) + k.SetExpiredShardBlock(ctx, shard.Id, shard.CreatedAt+shard.Duration) + k.model.ExtendMetaDuration(ctx, meta.DataId, shard.CreatedAt+shard.Duration) // shard = order.Shards[msg.Provider] - err = k.node.ShardPledge(ctx, shard, order.UnitPrice) + err = k.node.ShardPledge(ctx, shard, orderInProgress.UnitPrice) if err != nil { err = sdkerrors.Wrap(types.ErrorOrderPledgeFailed, err.Error()) return &types.MsgCompleteResponse{}, err @@ -209,7 +231,6 @@ func (k msgServer) Complete(goCtx context.Context, msg *types.MsgComplete) (*typ } } - k.model.ExtendMetaDuration(ctx, meta, shard.CreatedAt+shard.Duration) k.order.SetOrder(ctx, order) return &types.MsgCompleteResponse{}, err diff --git a/x/sao/keeper/msg_server_migrate.go b/x/sao/keeper/msg_server_migrate.go index a6ce8033..285b5758 100644 --- a/x/sao/keeper/msg_server_migrate.go +++ b/x/sao/keeper/msg_server_migrate.go @@ -80,7 +80,7 @@ func (k msgServer) Migrate(goCtx context.Context, msg *types.MsgMigrate) (*types sps := k.node.RandomSP(ctx, 1, ignoreList) - newShard := k.order.MigrateShard(ctx, &oldOrder, msg.Provider, sps[0].Creator) + newShard := k.order.MigrateShard(ctx, oldShard, &oldOrder, msg.Provider, sps[0].Creator) oldOrder.Shards = append(oldOrder.Shards, newShard.Id) diff --git a/x/sao/keeper/msg_server_store.go b/x/sao/keeper/msg_server_store.go index 424582ea..04ec9387 100644 --- a/x/sao/keeper/msg_server_store.go +++ b/x/sao/keeper/msg_server_store.go @@ -44,6 +44,10 @@ func (k msgServer) Store(goCtx context.Context, msg *types.MsgStore) (*types.Msg return nil, status.Errorf(codes.InvalidArgument, "invalid dataId") } + if proposal.Operation < 1 || proposal.Operation > 2 { + return nil, status.Errorf(codes.InvalidArgument, "invalid operation %d", proposal.Operation) + } + // check cid _, err = cid.Decode(proposal.Cid) if err != nil { @@ -54,7 +58,7 @@ func (k msgServer) Store(goCtx context.Context, msg *types.MsgStore) (*types.Msg // validate the permission for all update operations meta, isFound := k.Keeper.model.GetMetadata(ctx, proposal.DataId) if !isFound { - return nil, status.Errorf(codes.NotFound, "dataId Operation:%d not found", proposal.Operation) + return nil, status.Errorf(codes.NotFound, "metadata :%d not found", proposal.DataId) } isValid := meta.Owner == sigDid @@ -147,15 +151,21 @@ func (k msgServer) Store(goCtx context.Context, msg *types.MsgStore) (*types.Msg order.Size_ = 1 } + denom := k.staking.BondDenom(ctx) price := sdk.NewDecWithPrec(1, 6) + unitPrice := sdk.NewDecCoinFromDec(denom, price) + order.UnitPrice = unitPrice ownerAddress, err := k.did.GetCosmosPaymentAddress(ctx, proposal.Owner) if err != nil { return nil, err } - denom := k.staking.BondDenom(ctx) - amount, _ := sdk.NewDecCoinFromDec(denom, price.MulInt64(int64(order.Size_)).MulInt64(int64(order.Replica)).MulInt64(int64(order.Duration))).TruncateDecimal() + amount, dec := sdk.NewDecCoinFromDec(denom, price.MulInt64(int64(order.Size_)).MulInt64(int64(order.Replica)).MulInt64(int64(order.Duration))).TruncateDecimal() + if !dec.IsZero() { + amount = amount.AddAmount(sdk.NewInt(1)) + } + balance := k.bank.GetBalance(ctx, ownerAddress, denom) if balance.IsLT(amount) { @@ -269,7 +279,7 @@ func (k Keeper) GetSps(ctx sdk.Context, order ordertypes.Order, dataId string) ( if order.Replica <= 0 || int(order.Replica) > len(sps) { return nil, sdkerrors.Wrapf(types.ErrInvalidReplica, "replica should > 0 and <= %d", len(sps)) } - } else if order.Operation > 1 { + } else if order.Operation == 2 { if order.Replica <= 0 { return nil, sdkerrors.Wrapf(types.ErrInvalidReplica, "replica should > 0") } @@ -287,6 +297,8 @@ func (k Keeper) GetSps(ctx sdk.Context, order ordertypes.Order, dataId string) ( if int(order.Replica) > len(sps) { return nil, sdkerrors.Wrapf(types.ErrInvalidReplica, "replica should <= %d", len(sps)) } + } else { + return nil, sdkerrors.Wrapf(types.ErrorInvalidOperation, "unsupported operation %d", order.Operation) } return sps, nil } diff --git a/x/sao/keeper/msg_server_terminate.go b/x/sao/keeper/msg_server_terminate.go index bb346395..706a4e1c 100644 --- a/x/sao/keeper/msg_server_terminate.go +++ b/x/sao/keeper/msg_server_terminate.go @@ -66,19 +66,28 @@ func (k msgServer) Terminate(goCtx context.Context, msg *types.MsgTerminate) (*t } } - order, found := k.order.GetOrder(ctx, meta.OrderId) - if !found { - return nil, sdkerrors.Wrapf(types.ErrOrderNotFound, "order %d not found", meta.OrderId) - } + shardSet := make(map[uint64]int) + for _, orderId := range meta.Orders { + order, found := k.order.GetOrder(ctx, orderId) + if !found { + continue + } + + for _, shardId := range order.Shards { + shardSet[shardId] = 1 + } - if order.DataId != "" { - err := k.model.DeleteMeta(ctx, order.DataId) + err = k.model.TerminateOrder(ctx, order) if err != nil { return nil, err } } - err = k.model.TerminateOrder(ctx, order) + for shardId, _ := range shardSet { + k.order.RemoveShard(ctx, shardId) + } + + err = k.model.DeleteMeta(ctx, msg.Proposal.DataId) if err != nil { return nil, err } diff --git a/x/sao/keeper/pledge.go b/x/sao/keeper/pledge.go deleted file mode 100644 index ad942246..00000000 --- a/x/sao/keeper/pledge.go +++ /dev/null @@ -1,63 +0,0 @@ -package keeper - -import ( - "github.com/SaoNetwork/sao/x/node/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// SetPledge set a specific pledge in the store from its index -func (k Keeper) SetPledge(ctx sdk.Context, pledge types.Pledge) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeKeyPrefix)) - b := k.cdc.MustMarshal(&pledge) - store.Set(types.PledgeKey( - pledge.Creator, - ), b) -} - -// GetPledge returns a pledge from its index -func (k Keeper) GetPledge( - ctx sdk.Context, - creator string, - -) (val types.Pledge, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeKeyPrefix)) - - b := store.Get(types.PledgeKey( - creator, - )) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} - -// RemovePledge removes a pledge from the store -func (k Keeper) RemovePledge( - ctx sdk.Context, - creator string, - -) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeKeyPrefix)) - store.Delete(types.PledgeKey( - creator, - )) -} - -// GetAllPledge returns all pledge -func (k Keeper) GetAllPledge(ctx sdk.Context) (list []types.Pledge) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PledgeKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var val types.Pledge - k.cdc.MustUnmarshal(iterator.Value(), &val) - list = append(list, val) - } - - return -} diff --git a/x/sao/types/expected_keepers.go b/x/sao/types/expected_keepers.go index bb6311e4..ce858852 100644 --- a/x/sao/types/expected_keepers.go +++ b/x/sao/types/expected_keepers.go @@ -54,7 +54,7 @@ type EarnKeeper interface { type OrderKeeper interface { NewOrder(ctx sdk.Context, order *ordertypes.Order, sp []string) (uint64, error) GenerateShards(ctx sdk.Context, order *ordertypes.Order, sps []string) - MigrateShard(ctx sdk.Context, order *ordertypes.Order, from string, to string) *ordertypes.Shard + MigrateShard(ctx sdk.Context, oldShard *ordertypes.Shard, order *ordertypes.Order, from string, to string) *ordertypes.Shard GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) SetOrder(ctx sdk.Context, order ordertypes.Order) RemoveOrder(ctx sdk.Context, orderId uint64) @@ -86,7 +86,9 @@ type ModelKeeper interface { CancelOrder(ctx sdk.Context, orderId uint64) error - ExtendMetaDuration(ctx sdk.Context, meta modeltypes.Metadata, expiredAt uint64) + ResetMetaDuration(ctx sdk.Context, meta *modeltypes.Metadata) + + ExtendMetaDuration(ctx sdk.Context, dataId string, expiredAt uint64) } // DidKeeper @@ -101,6 +103,6 @@ type DidKeeper interface { type MarketKeeper interface { Deposit(ctx sdk.Context, order ordertypes.Order) error Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, error) - Migrate(ctx sdk.Context, order ordertypes.Order, from string, to string) error + Migrate(ctx sdk.Context, order ordertypes.Order, from, to ordertypes.Shard) error WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error } From 950f07a50936eb9d677cb6b2bfbb461df6ad1a2b Mon Sep 17 00:00:00 2001 From: SterlynLee <107973483+SterlynLee@users.noreply.github.com> Date: Wed, 24 May 2023 11:08:13 +0800 Subject: [PATCH 7/8] refactor: renew (#45) --- CHANGELOG.md | 2 + config.yml | 4 +- docs/static/openapi.yml | 258 +++++++++++++++++++++++ x/node/keeper/shard_pledge_management.go | 27 ++- x/node/types/expected_keepers.go | 1 + x/order/keeper/order_management.go | 34 ++- x/sao/keeper/expire_management.go | 19 +- x/sao/keeper/keeper.go | 25 +-- x/sao/keeper/msg_server_renew.go | 176 ++++++++++++---- x/sao/types/errors.go | 3 + x/sao/types/expected_keepers.go | 18 ++ 11 files changed, 504 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89f4ea8..0693b310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] ### Features +- renew info ([#52](https://github.com/SAONetwork/sao-consensus/issues/52)) - pledge_debt, refactor node module funcs ([#51](https://github.com/SAONetwork/sao-consensus/issues/51)) - expired shard ([#49](https://github.com/SAONetwork/sao-consensus/issues/49)) - storage pledge baseline ([#48](https://github.com/SAONetwork/sao-consensus/issues/48)) @@ -11,6 +12,7 @@ ### Code Refactoring - shard record storage duration ([#46](https://github.com/SAONetwork/sao-consensus/issues/46)) +- renew diff --git a/config.yml b/config.yml index f0f59394..dcb7a1b5 100644 --- a/config.yml +++ b/config.yml @@ -31,7 +31,9 @@ genesis: block_reward: amount: "6250000" denom: "sao" - baseline: "100000000000" + baseline: + amount: "100000000000" + denom: "sao" annual_percentage_yield : "1" staking: params: diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 03b04a26..fb81b650 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -44839,6 +44839,11 @@ paths: status: type: integer format: int32 + orders: + type: array + items: + type: string + format: uint64 pagination: type: object properties: @@ -45003,6 +45008,11 @@ paths: status: type: integer format: int32 + orders: + type: array + items: + type: string + format: uint64 orderId: type: string format: uint64 @@ -46411,6 +46421,33 @@ paths: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and + an amount. + + + NOTE: The amount field is an Int which + implements the custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 amount: type: object properties: @@ -46574,6 +46611,33 @@ paths: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 pagination: type: object properties: @@ -46731,6 +46795,33 @@ paths: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 default: description: An unexpected error response. schema: @@ -75368,6 +75459,11 @@ definitions: status: type: integer format: int32 + orders: + type: array + items: + type: string + format: uint64 saonetwork.sao.model.Model: type: object properties: @@ -75473,6 +75569,11 @@ definitions: status: type: integer format: int32 + orders: + type: array + items: + type: string + format: uint64 pagination: type: object properties: @@ -75602,6 +75703,11 @@ definitions: status: type: integer format: int32 + orders: + type: array + items: + type: string + format: uint64 orderId: type: string format: uint64 @@ -76402,6 +76508,32 @@ definitions: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 amount: type: object properties: @@ -76666,6 +76798,32 @@ definitions: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 pagination: type: object properties: @@ -76767,6 +76925,33 @@ definitions: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + duration: + type: string + format: uint64 amount: type: object properties: @@ -76858,6 +77043,32 @@ definitions: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + duration: + type: string + format: uint64 saonetwork.sao.order.QueryParamsResponse: type: object properties: @@ -76865,6 +77076,27 @@ definitions: description: params holds all the parameters of this module. type: object description: QueryParamsResponse is response type for the Query/Params RPC method. + saonetwork.sao.order.RenewInfo: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + duration: + type: string + format: uint64 saonetwork.sao.order.Shard: type: object properties: @@ -76904,6 +77136,32 @@ definitions: createdAt: type: string format: uint64 + renewInfos: + type: array + items: + type: object + properties: + orderId: + type: string + format: uint64 + pledge: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + duration: + type: string + format: uint64 saonetwork.sao.sao.ExpiredShard: type: object properties: diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 4446861e..0808e8ff 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -105,6 +105,12 @@ func (k Keeper) ShardPledge(ctx sdk.Context, shard *ordertypes.Shard, unitPrice shardPledge = shardPledge.AddAmount(sdk.NewInt(1)) } + for _, renewInfo := range shard.RenewInfos { + if shardPledge.IsLT(renewInfo.Pledge) { + shardPledge = renewInfo.Pledge + } + } + coins = coins.Add(shardPledge) pledge.TotalStoragePledged = pledge.TotalStoragePledged.Add(shardPledge) @@ -112,7 +118,26 @@ func (k Keeper) ShardPledge(ctx sdk.Context, shard *ordertypes.Shard, unitPrice } var err error - err = k.bank.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(shard.Sp), types.ModuleName, coins) + if len(shard.RenewInfos) != 0 { + balance := k.bank.GetBalance(ctx, sdk.MustAccAddressFromBech32(shard.Sp), denom) + if balance.IsGTE(shardPledge) { + err = k.bank.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(shard.Sp), types.ModuleName, coins) + } else { + err = k.bank.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(shard.Sp), types.ModuleName, sdk.Coins{balance}) + pledgeDebt, found := k.GetPledgeDebt(ctx, shard.Sp) + if found { + pledgeDebt.Debt = pledgeDebt.Debt.Add(shardPledge.Sub(balance)) + } else { + pledgeDebt = types.PledgeDebt{ + Sp: shard.Sp, + Debt: shardPledge.Sub(balance), + } + } + k.SetPledgeDebt(ctx, pledgeDebt) + } + } else { + err = k.bank.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(shard.Sp), types.ModuleName, coins) + } if err != nil { return err diff --git a/x/node/types/expected_keepers.go b/x/node/types/expected_keepers.go index 3a145517..ac718a11 100644 --- a/x/node/types/expected_keepers.go +++ b/x/node/types/expected_keepers.go @@ -31,6 +31,7 @@ type AccountKeeper interface { // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins // Methods imported from bank should be defined here SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error diff --git a/x/order/keeper/order_management.go b/x/order/keeper/order_management.go index f1d7d78f..aec63eac 100644 --- a/x/order/keeper/order_management.go +++ b/x/order/keeper/order_management.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + markettypes "github.com/SaoNetwork/sao/x/market/types" "github.com/SaoNetwork/sao/x/order/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,6 +49,31 @@ func (k Keeper) NewOrder(ctx sdk.Context, order *types.Order, sps []string) (uin return order.Id, nil } +func (k Keeper) RenewOrder(ctx sdk.Context, order *types.Order) (uint64, error) { + + paymentAcc, err := k.did.GetCosmosPaymentAddress(ctx, order.Owner) + if err != nil { + return 0, err + } + + logger := k.Logger(ctx) + + logger.Debug("try payment renew ", "payer", paymentAcc, "amount", order.Amount) + + err = k.bank.SendCoinsFromAccountToModule(ctx, paymentAcc, markettypes.ModuleName, sdk.Coins{order.Amount}) + if err != nil { + return 0, err + } + + logger.Debug("CoinTrace: renew order", "from", paymentAcc.String(), "to", markettypes.ModuleName, "amount", order.Amount.String()) + + order.Id = k.AppendOrder(ctx, *order) + + k.SetOrder(ctx, *order) + + return order.Id, nil +} + func (k Keeper) GenerateShards(ctx sdk.Context, order *types.Order, sps []string) { if len(sps) > 0 { @@ -85,9 +111,11 @@ func (k Keeper) TerminateOrder(ctx sdk.Context, orderId uint64, refundCoin sdk.C return err } - err = k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, paymentAcc, sdk.Coins{refundCoin}) - if err != nil { - return err + if !refundCoin.IsZero() { + err = k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, paymentAcc, sdk.Coins{refundCoin}) + if err != nil { + return err + } } logger := k.Logger(ctx) diff --git a/x/sao/keeper/expire_management.go b/x/sao/keeper/expire_management.go index 4b059486..a149da44 100644 --- a/x/sao/keeper/expire_management.go +++ b/x/sao/keeper/expire_management.go @@ -15,9 +15,24 @@ func (k Keeper) HandleExpiredShard(ctx sdk.Context, shardId uint64) { return } - k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) k.market.WorkerRelease(ctx, &order, &shard) - k.order.RemoveShard(ctx, shardId) + if len(shard.RenewInfos) == 0 { + k.node.ShardRelease(ctx, sdk.MustAccAddressFromBech32(shard.Sp), &shard) + k.order.RemoveShard(ctx, shardId) + } else { + nextOrderInfo := shard.RenewInfos[0] + + shard.RenewInfos = shard.RenewInfos[1:] + shard.OrderId = nextOrderInfo.OrderId + shard.CreatedAt = uint64(ctx.BlockHeight()) + shard.Duration = nextOrderInfo.Duration + k.SetExpiredShardBlock(ctx, shard.Id, shard.CreatedAt+shard.Duration) + k.order.SetShard(ctx, shard) + + newOrder, _ := k.order.GetOrder(ctx, shard.OrderId) + k.market.WorkerAppend(ctx, &newOrder, &shard) + } + if len(order.Shards) == 1 { if order.Shards[0] == shardId { k.order.RemoveOrder(ctx, order.Id) diff --git a/x/sao/keeper/keeper.go b/x/sao/keeper/keeper.go index 854314a8..be351404 100644 --- a/x/sao/keeper/keeper.go +++ b/x/sao/keeper/keeper.go @@ -52,18 +52,19 @@ func NewKeeper( } return &Keeper{ - auth: auth, - bank: bank, - node: node, - order: order, - model: model, - did: did, - market: market, - staking: staking, - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, + auth: auth, + bank: bank, + node: node, + order: order, + model: model, + did: did, + market: market, + staking: staking, + cdc: cdc, + storeKey: storeKey, + orderStoreKey: orderStoreKey, + memKey: memKey, + paramstore: ps, } } diff --git a/x/sao/keeper/msg_server_renew.go b/x/sao/keeper/msg_server_renew.go index c503a155..0b200107 100644 --- a/x/sao/keeper/msg_server_renew.go +++ b/x/sao/keeper/msg_server_renew.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + nodetypes "github.com/SaoNetwork/sao/x/node/types" ordertypes "github.com/SaoNetwork/sao/x/order/types" "github.com/SaoNetwork/sao/x/sao/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,6 +13,8 @@ import ( "google.golang.org/grpc/status" ) +const MaxRenewDuration uint64 = 60 * 60 * 24 * 365 * 2 + func (k msgServer) Renew(goCtx context.Context, msg *types.MsgRenew) (*types.MsgRenewResponse, error) { var sigDid string var err error @@ -44,17 +47,27 @@ func (k msgServer) Renew(goCtx context.Context, msg *types.MsgRenew) (*types.Msg return nil, sdkerrors.Wrapf(types.ErrorInvalidProvider, "msg.Creator: %s, msg.Provider: %s", msg.Creator, msg.Provider) } + if proposal.Duration > MaxRenewDuration { + return nil, sdkerrors.Wrapf(types.ErrorInvalidDuration, "renew duration: %d, max renew duration: %d", proposal.Duration, MaxRenewDuration) + } + resp := types.MsgRenewResponse{ Result: make([]*types.KV, 0), } - ownerAddress, err := k.did.GetCosmosPaymentAddress(ctx, sigDid) + pool, found := k.node.GetPool(ctx) + if !found { + return nil, sdkerrors.Wrapf(nodetypes.ErrPoolNotFound, "pool not found") + } + if err != nil { return nil, err } denom := k.staking.BondDenom(ctx) - balance := k.bank.GetBalance(ctx, ownerAddress, denom) + blockRewardPerByte := pool.RewardPerBlock.Amount.Quo(sdk.NewDec(pool.TotalStorage)) + +dataLoop: for _, dataId := range proposal.Data { metadata, found := k.Keeper.model.GetMetadata(ctx, dataId) if !found { @@ -76,9 +89,7 @@ func (k msgServer) Renew(goCtx context.Context, msg *types.MsgRenew) (*types.Msg continue } - sps := k.FindSPByDataId(ctx, dataId) - - oldOrder, found := k.order.GetOrder(ctx, metadata.OrderId) + order, found := k.order.GetOrder(ctx, metadata.OrderId) if !found { kv := &types.KV{ K: dataId, @@ -88,77 +99,154 @@ func (k msgServer) Renew(goCtx context.Context, msg *types.MsgRenew) (*types.Msg continue } - if oldOrder.Status != ordertypes.OrderCompleted { + if order.Status != ordertypes.OrderCompleted { + kv := &types.KV{ + K: dataId, + V: sdkerrors.Wrapf(types.ErrOrderNotFound, "FAILED: invalid order status: %d", metadata.Status).Error(), + } + resp.Result = append(resp.Result, kv) + continue + } + + duration := int64(order.Duration) + currentHeight := ctx.BlockHeight() + orderExpiredAt := int64(order.CreatedAt) + duration + + if orderExpiredAt < currentHeight { kv := &types.KV{ K: dataId, - V: sdkerrors.Wrapf(types.ErrOrderUnexpectedStatus, "FAILED: expected status %d, but get %d", ordertypes.OrderCompleted, oldOrder.Status).Error(), + V: sdkerrors.Wrapf(types.ErrorOrderExpired, "FAILED: metadata should have expired: order has expired at %d", orderExpiredAt).Error(), } resp.Result = append(resp.Result, kv) continue } - var order = ordertypes.Order{ + // TODO: use real-time unit price instead + orderUnitPrice := sdk.NewDecWithPrec(1, 6) + + replica := int32(len(order.Shards)) + amount, dec := sdk.NewDecCoinFromDec( + denom, + orderUnitPrice. + MulInt64(int64(replica)). + MulInt64(int64(order.Size_)). + MulInt64(int64(proposal.Duration))). + TruncateDecimal() + if !dec.IsZero() { + amount = amount.AddAmount(sdk.NewInt(1)) + } + newOrder := ordertypes.Order{ Creator: msg.Creator, - Owner: metadata.Owner, - Cid: oldOrder.Cid, - Timeout: oldOrder.Timeout, + Owner: order.Owner, + Provider: msg.Provider, + Cid: order.Cid, Duration: proposal.Duration, - Status: ordertypes.OrderDataReady, - Size_: oldOrder.Size_, - Replica: oldOrder.Replica, + Status: order.Status, + Replica: replica, + Shards: order.Shards, + Amount: amount, + Size_: order.Size_, Operation: 3, + CreatedAt: uint64(ctx.BlockHeight()), + Timeout: uint64(proposal.Timeout), + DataId: order.DataId, + Commit: order.Commit, + UnitPrice: sdk.NewDecCoinFromDec(denom, orderUnitPrice), } - price := sdk.NewDecWithPrec(1, 6) + var shards []ordertypes.Shard + for _, id := range order.Shards { + shard, found := k.order.GetShard(ctx, id) + if !found { + kv := &types.KV{ + K: dataId, + V: sdkerrors.Wrapf(types.ErrorNoPermission, "FAILED: shardId %s not found", id).Error(), + } + resp.Result = append(resp.Result, kv) + continue dataLoop + } + shards = append(shards, shard) + } - owner_address, err := k.did.GetCosmosPaymentAddress(ctx, order.Owner) + _, err := k.order.RenewOrder(ctx, &newOrder) if err != nil { kv := &types.KV{ K: dataId, - V: "FAILED: " + err.Error(), + V: err.Error(), } resp.Result = append(resp.Result, kv) continue } - amount, _ := sdk.NewDecCoinFromDec(denom, price.MulInt64(int64(order.Size_)).MulInt64(int64(order.Replica)).MulInt64(int64(order.Duration))).TruncateDecimal() + totalPledgeChange := sdk.NewInt(0) + var newExpiredAt uint64 = 0 + for _, shard := range shards { + spAcc := sdk.MustAccAddressFromBech32(shard.Sp) - logger := k.Logger(ctx) - logger.Debug("order amount", "amount", amount, "owner", owner_address, "balance", balance) + blockRewardPledge := k.node.BlockRewardPledge(proposal.Duration, shard.Size_, sdk.NewDecCoinFromDec(denom, blockRewardPerByte)) + storeRewardPledge := k.node.StoreRewardPledge(proposal.Duration, shard.Size_, newOrder.UnitPrice) - if balance.IsLT(amount) { - kv := &types.KV{ - K: dataId, - V: sdkerrors.Wrapf(types.ErrInsufficientCoin, "FAILED: insufficient coin: need %d", amount.Amount.Int64()).Error(), + newPledge, dec := sdk.NewDecCoinFromDec(denom, blockRewardPledge.Add(storeRewardPledge)).TruncateDecimal() + if !dec.IsZero() { + newPledge = newPledge.AddAmount(sdk.NewInt(1)) } - resp.Result = append(resp.Result, kv) - continue - } else { - balance = balance.Sub(amount) - } - order.Amount = amount - sps_addr := make([]string, 0) - for _, sp := range sps { - sps_addr = append(sps_addr, sp.String()) - } + if newPledge.Amount.GT(shard.Pledge.Amount) { + extraPledge := newPledge.Sub(shard.Pledge) + spBalance := k.bank.GetBalance(ctx, spAcc, denom) + if spBalance.IsGTE(extraPledge) { + k.bank.SendCoinsFromAccountToModule(ctx, spAcc, nodetypes.ModuleName, sdk.Coins{extraPledge}) + } else { + k.bank.SendCoinsFromAccountToModule(ctx, spAcc, nodetypes.ModuleName, sdk.Coins{spBalance}) + debt := extraPledge.Sub(spBalance) + pledgeDebt, found := k.node.GetPledgeDebt(ctx, shard.Sp) + if !found { + pledgeDebt = nodetypes.PledgeDebt{ + Sp: shard.Sp, + Debt: debt, + } + } else { + pledgeDebt.Debt = pledgeDebt.Debt.Add(debt) + } + k.node.SetPledgeDebt(ctx, pledgeDebt) + } + totalPledgeChange = totalPledgeChange.Add(extraPledge.Amount) - k.order.GenerateShards(ctx, &order, sps_addr) + shard.Pledge = newPledge - k.order.SetOrder(ctx, order) + pledge, _ := k.node.GetPledge(ctx, shard.Sp) + pledge.TotalStoragePledged = pledge.TotalStoragePledged.Add(extraPledge) + k.node.SetPledge(ctx, pledge) + } - newOrderId, err := k.order.NewOrder(ctx, &order, sps_addr) - if err != nil { - kv := &types.KV{ - K: dataId, - V: "FAILED: " + err.Error(), + renewInfo := ordertypes.RenewInfo{ + OrderId: newOrder.Id, + Pledge: newPledge, + Duration: proposal.Duration, } - resp.Result = append(resp.Result, kv) - continue + shard.RenewInfos = append(shard.RenewInfos, renewInfo) + shardExpiredAt := shard.CreatedAt + shard.Duration + for _, info := range shard.RenewInfos { + shardExpiredAt += info.Duration + } + if shardExpiredAt > newExpiredAt { + newExpiredAt = shardExpiredAt + } + + k.order.SetShard(ctx, shard) } + + k.model.ExtendMetaDuration(ctx, metadata.DataId, newExpiredAt) + k.model.UpdateMeta(ctx, newOrder) + + if !totalPledgeChange.IsZero() { + pool.TotalPledged.Amount = pool.TotalPledged.Amount.Add(totalPledgeChange) + k.node.SetPool(ctx, pool) + } + kv := &types.KV{ K: dataId, - V: fmt.Sprintf("SUCCESS: new orderId=%d", newOrderId), + V: fmt.Sprintf("SUCCESS: orderId=%d", newOrder.Id), } resp.Result = append(resp.Result, kv) } diff --git a/x/sao/types/errors.go b/x/sao/types/errors.go index f495b56a..96e87697 100644 --- a/x/sao/types/errors.go +++ b/x/sao/types/errors.go @@ -34,4 +34,7 @@ var ( ErrorInvalidShardSize = sdkerrors.Register(ModuleName, 2122, "invalid shard size") ErrorOrderPledgeFailed = sdkerrors.Register(ModuleName, 2123, "order pledge failed") ErrorInvalidOwner = sdkerrors.Register(ModuleName, 2124, "invalid owner") + ErrorInvalidDuration = sdkerrors.Register(ModuleName, 2125, "invalid duration") + ErrorOrderExpired = sdkerrors.Register(ModuleName, 2126, "order already expired") + ErrorInvalidExpiredAt = sdkerrors.Register(ModuleName, 2127, "invalid expired at") ) diff --git a/x/sao/types/expected_keepers.go b/x/sao/types/expected_keepers.go index ce858852..8ccfb949 100644 --- a/x/sao/types/expected_keepers.go +++ b/x/sao/types/expected_keepers.go @@ -43,6 +43,22 @@ type NodeKeeper interface { ShardPledge(ctx sdk.Context, shard *ordertypes.Shard, unitPrice sdk.DecCoin) error ShardRelease(ctx sdk.Context, sp sdk.AccAddress, order *ordertypes.Shard) error + + BlockRewardPledge(duration uint64, size uint64, rewardPerByte sdk.DecCoin) sdk.Dec + + StoreRewardPledge(duration uint64, size uint64, rewardPerByte sdk.DecCoin) sdk.Dec + + SetPledgeDebt(ctx sdk.Context, pledgeDebt nodetypes.PledgeDebt) + + GetPledgeDebt(ctx sdk.Context, sp string) (nodetypes.PledgeDebt, bool) + + GetPool(ctx sdk.Context) (val nodetypes.Pool, found bool) + + SetPool(ctx sdk.Context, pool nodetypes.Pool) + + GetPledge(ctx sdk.Context, sp string) (nodetypes.Pledge, bool) + + SetPledge(ctx sdk.Context, pledge nodetypes.Pledge) } // EarnKeeper @@ -53,6 +69,7 @@ type EarnKeeper interface { // OrderKeeper interface type OrderKeeper interface { NewOrder(ctx sdk.Context, order *ordertypes.Order, sp []string) (uint64, error) + RenewOrder(ctx sdk.Context, order *ordertypes.Order) (uint64, error) GenerateShards(ctx sdk.Context, order *ordertypes.Order, sps []string) MigrateShard(ctx sdk.Context, oldShard *ordertypes.Shard, order *ordertypes.Order, from string, to string) *ordertypes.Shard GetOrder(ctx sdk.Context, orderId uint64) (ordertypes.Order, bool) @@ -105,4 +122,5 @@ type MarketKeeper interface { Withdraw(ctx sdk.Context, order ordertypes.Order) (sdk.Coin, error) Migrate(ctx sdk.Context, order ordertypes.Order, from, to ordertypes.Shard) error WorkerRelease(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error + WorkerAppend(ctx sdk.Context, order *ordertypes.Order, shard *ordertypes.Shard) error } From 3a423e511c434a57205664dca471eb1eb38b6880 Mon Sep 17 00:00:00 2001 From: MattL <89444556+mattkb@users.noreply.github.com> Date: Tue, 30 May 2023 18:59:36 +0800 Subject: [PATCH 8/8] feat: add node params (#53) --- proto/sao/node/params.proto | 4 + x/node/abci.go | 4 +- x/node/keeper/params.go | 25 +++++ x/node/keeper/shard_pledge_management.go | 2 +- x/node/migrations/v3/migrations.go | 3 + x/node/types/params.go | 28 ++++++ x/node/types/params.pb.go | 113 +++++++++++++++++++---- 7 files changed, 156 insertions(+), 23 deletions(-) diff --git a/proto/sao/node/params.proto b/proto/sao/node/params.proto index de06ae7f..a9d1f6ac 100644 --- a/proto/sao/node/params.proto +++ b/proto/sao/node/params.proto @@ -15,4 +15,8 @@ message Params { cosmos.base.v1beta1.Coin baseline = 2 [(gogoproto.nullable) = false]; string annual_percentage_yield = 3; + + int64 halving_period = 4; + + int64 adjustment_period = 5; } diff --git a/x/node/abci.go b/x/node/abci.go index 72e0261a..3a311d18 100644 --- a/x/node/abci.go +++ b/x/node/abci.go @@ -54,7 +54,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { return } - reward := sdk.NewDecCoinFromCoin(pool.TotalPledged).Amount.Mul(apy).QuoInt64(16000000).TruncateInt() + reward := sdk.NewDecCoinFromCoin(pool.TotalPledged).Amount.Mul(apy).QuoInt64(params.HalvingPeriod / 2).TruncateInt() logger.Debug("baseline mint", "reward", reward) if reward.LT(rewardCoin.Amount) { rewardCoin = sdk.NewCoin(params.BlockReward.Denom, reward) @@ -72,7 +72,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { // reset reward accumulation every 2000 blocks - if ctx.BlockHeight()%100 == 0 { + if ctx.BlockHeight()%params.AdjustmentPeriod == 0 { pool.RewardPerBlock = pool.NextRewardPerBlock pool.NextRewardPerBlock = sdk.NewDecCoinFromCoin(rewardCoin) } diff --git a/x/node/keeper/params.go b/x/node/keeper/params.go index 98e47f6c..f2d3b8b6 100644 --- a/x/node/keeper/params.go +++ b/x/node/keeper/params.go @@ -8,10 +8,13 @@ import ( // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) types.Params { apy, _ := sdk.NewDecFromStr(k.AnnualPercentageYield(ctx)) + return types.NewParams( k.BlockReward(ctx), k.Baseline(ctx), apy, + k.HalvingPeriod(ctx), + k.AdjustmentPeriod(ctx), ) } @@ -35,3 +38,25 @@ func (k Keeper) AnnualPercentageYield(ctx sdk.Context) (res string) { k.paramstore.Get(ctx, types.KeyAPY, &res) return } + +func (k Keeper) HalvingPeriod(ctx sdk.Context) (res int64) { + k.paramstore.Get(ctx, types.KeyHalvingPeriod, &res) + return +} + +func (k Keeper) AdjustmentPeriod(ctx sdk.Context) (res int64) { + k.paramstore.Get(ctx, types.KeyAdjustmentPeriod, &res) + return +} + +func (k Keeper) SetAnnualPercentageYield(ctx sdk.Context, apy string) { + k.paramstore.Set(ctx, types.KeyAPY, &apy) +} + +func (k Keeper) SetHalvingPeriod(ctx sdk.Context, halving int64) { + k.paramstore.Set(ctx, types.KeyAPY, &halving) +} + +func (k Keeper) SetAdjustmentPeriod(ctx sdk.Context, adjustment int64) { + k.paramstore.Set(ctx, types.KeyAPY, &adjustment) +} diff --git a/x/node/keeper/shard_pledge_management.go b/x/node/keeper/shard_pledge_management.go index 0808e8ff..ab64c4cb 100644 --- a/x/node/keeper/shard_pledge_management.go +++ b/x/node/keeper/shard_pledge_management.go @@ -300,4 +300,4 @@ func (k Keeper) RepayPledgeDebt(ctx sdk.Context, sp string, rewards []*sdk.Coin) } k.SetPledgeDebt(ctx, pledgeDebt) } -} \ No newline at end of file +} diff --git a/x/node/migrations/v3/migrations.go b/x/node/migrations/v3/migrations.go index e866a9ad..72132dae 100644 --- a/x/node/migrations/v3/migrations.go +++ b/x/node/migrations/v3/migrations.go @@ -48,6 +48,9 @@ func UpdateNodeParams(ctx sdk.Context, paramStore *paramtypes.Subspace) error { blockReward = sdk.NewInt64Coin(blockReward.Denom, 6250000) paramStore.Set(ctx, types.KeyBlockReward, &blockReward) + paramStore.Set(ctx, types.KeyHalvingPeriod, int64(32000000)) + paramStore.Set(ctx, types.KeyAdjustmentPeriod, int64(2000)) + // set apy paramStore.Set(ctx, types.KeyAPY, "8.0") return nil diff --git a/x/node/types/params.go b/x/node/types/params.go index a47863a2..56e7b1bc 100644 --- a/x/node/types/params.go +++ b/x/node/types/params.go @@ -1,6 +1,8 @@ package types import ( + "errors" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" @@ -26,6 +28,16 @@ var ( DefaultAPY = sdk.NewDecWithPrec(50, 2) ) +var ( + KeyHalvingPeriod = []byte("HalvingPeriod") + DefaultHalvingPeriod = int64(32000000) +) + +var ( + KeyAdjustmentPeriod = []byte("AdjustmentPeriod") + DefaultAdjustmentPeriod = int64(2000) +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -36,11 +48,15 @@ func NewParams( blockReward sdk.Coin, baseline sdk.Coin, apy sdk.Dec, + halving int64, + adjustment int64, ) Params { return Params{ BlockReward: blockReward, Baseline: baseline, AnnualPercentageYield: apy.String(), + HalvingPeriod: halving, + AdjustmentPeriod: adjustment, } } @@ -50,6 +66,8 @@ func DefaultParams() Params { DefaultBlockReward, DefaultBaseline, DefaultAPY, + DefaultHalvingPeriod, + DefaultAdjustmentPeriod, ) } @@ -59,6 +77,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyBlockReward, &p.BlockReward, validateBlockReward), paramtypes.NewParamSetPair(KeyBaseLine, &p.Baseline, validateBaseline), paramtypes.NewParamSetPair(KeyAPY, &p.AnnualPercentageYield, validateAPY), + paramtypes.NewParamSetPair(KeyHalvingPeriod, &p.HalvingPeriod, validatePeriod), + paramtypes.NewParamSetPair(KeyAdjustmentPeriod, &p.AdjustmentPeriod, validatePeriod), } } @@ -98,6 +118,14 @@ func validateBaseline(v interface{}) error { return nil } +func validatePeriod(v interface{}) error { + p := v.(uint64) + if p > 10 { + return nil + } + return errors.New("invalid period") +} + // validateAPY validates the BlockReward param func validateAPY(v interface{}) error { _, err := sdk.NewDecFromStr(v.(string)) diff --git a/x/node/types/params.pb.go b/x/node/types/params.pb.go index e129ea80..507069ca 100644 --- a/x/node/types/params.pb.go +++ b/x/node/types/params.pb.go @@ -29,6 +29,8 @@ type Params struct { BlockReward types.Coin `protobuf:"bytes,1,opt,name=block_reward,json=blockReward,proto3" json:"block_reward"` Baseline types.Coin `protobuf:"bytes,2,opt,name=baseline,proto3" json:"baseline"` AnnualPercentageYield string `protobuf:"bytes,3,opt,name=annual_percentage_yield,json=annualPercentageYield,proto3" json:"annual_percentage_yield,omitempty"` + HalvingPeriod int64 `protobuf:"varint,4,opt,name=halving_period,json=halvingPeriod,proto3" json:"halving_period,omitempty"` + AdjustmentPeriod int64 `protobuf:"varint,5,opt,name=adjustment_period,json=adjustmentPeriod,proto3" json:"adjustment_period,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -84,6 +86,20 @@ func (m *Params) GetAnnualPercentageYield() string { return "" } +func (m *Params) GetHalvingPeriod() int64 { + if m != nil { + return m.HalvingPeriod + } + return 0 +} + +func (m *Params) GetAdjustmentPeriod() int64 { + if m != nil { + return m.AdjustmentPeriod + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "saonetwork.sao.node.Params") } @@ -91,26 +107,29 @@ func init() { func init() { proto.RegisterFile("sao/node/params.proto", fileDescriptor_c6a39a6c05c26f45) } var fileDescriptor_c6a39a6c05c26f45 = []byte{ - // 290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4e, 0xf3, 0x30, - 0x14, 0x46, 0xe3, 0xff, 0xaf, 0x2a, 0x48, 0x99, 0x02, 0x15, 0xa5, 0x83, 0x5b, 0x31, 0xa0, 0x4e, - 0xb6, 0x0a, 0x12, 0x03, 0x2c, 0xa8, 0xec, 0xa8, 0x0a, 0x13, 0x2c, 0xd1, 0x4d, 0x62, 0x85, 0xa8, - 0x89, 0x6f, 0x64, 0xbb, 0x94, 0xbe, 0x05, 0x23, 0x23, 0x6f, 0x43, 0xc7, 0x8e, 0x4c, 0x08, 0x25, - 0x2f, 0x82, 0x1c, 0xa3, 0xce, 0x6c, 0x57, 0x3a, 0xf7, 0x3b, 0xc3, 0xf1, 0xfb, 0x1a, 0x90, 0x4b, - 0x4c, 0x05, 0xaf, 0x40, 0x41, 0xa9, 0x59, 0xa5, 0xd0, 0x60, 0x70, 0xa8, 0x01, 0xa5, 0x30, 0x2b, - 0x54, 0x0b, 0xa6, 0x01, 0x99, 0xfd, 0x18, 0x1e, 0x65, 0x98, 0x61, 0xcb, 0xb9, 0xbd, 0xdc, 0xeb, - 0x90, 0x26, 0xa8, 0x4b, 0xd4, 0x3c, 0x06, 0x2d, 0xf8, 0xf3, 0x34, 0x16, 0x06, 0xa6, 0x3c, 0xc1, - 0x5c, 0x3a, 0x7e, 0xfa, 0x41, 0xfc, 0xee, 0xbc, 0x75, 0x07, 0x33, 0xff, 0x20, 0x2e, 0x30, 0x59, - 0x44, 0x4a, 0xac, 0x40, 0xa5, 0x03, 0x32, 0x26, 0x93, 0xde, 0xf9, 0x09, 0x73, 0x06, 0x66, 0x0d, - 0xec, 0xd7, 0xc0, 0x6e, 0x31, 0x97, 0xb3, 0xce, 0xe6, 0x6b, 0xe4, 0x85, 0xbd, 0x76, 0x14, 0xb6, - 0x9b, 0xe0, 0xda, 0xdf, 0xb3, 0x7f, 0x45, 0x2e, 0xc5, 0xe0, 0xdf, 0xdf, 0xf6, 0xbb, 0x41, 0x70, - 0xe9, 0x1f, 0x83, 0x94, 0x4b, 0x28, 0xa2, 0x4a, 0xa8, 0x44, 0x48, 0x03, 0x99, 0x88, 0xd6, 0xb9, - 0x28, 0xd2, 0xc1, 0xff, 0x31, 0x99, 0xec, 0x87, 0x7d, 0x87, 0xe7, 0x3b, 0xfa, 0x60, 0xe1, 0x55, - 0xe7, 0xed, 0x7d, 0xe4, 0xcd, 0x6e, 0x36, 0x35, 0x25, 0xdb, 0x9a, 0x92, 0xef, 0x9a, 0x92, 0xd7, - 0x86, 0x7a, 0xdb, 0x86, 0x7a, 0x9f, 0x0d, 0xf5, 0x1e, 0xcf, 0xb2, 0xdc, 0x3c, 0x2d, 0x63, 0x96, - 0x60, 0xc9, 0xef, 0x01, 0xef, 0x5c, 0x39, 0x6e, 0xdb, 0xbe, 0xb8, 0xba, 0x66, 0x5d, 0x09, 0x1d, - 0x77, 0xdb, 0x24, 0x17, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x04, 0x5e, 0x99, 0x71, 0x76, 0x01, - 0x00, 0x00, + // 337 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x4f, 0xc2, 0x40, + 0x18, 0x86, 0x5b, 0x40, 0xa2, 0x45, 0x8d, 0x56, 0x89, 0x95, 0xa1, 0x10, 0x13, 0x0d, 0x89, 0xc9, + 0x5d, 0xd0, 0xc4, 0x41, 0x17, 0x83, 0xbb, 0x21, 0x75, 0xd2, 0x85, 0x7c, 0x6d, 0x2f, 0xa5, 0xd2, + 0xde, 0xd7, 0xf4, 0x0e, 0x90, 0x7f, 0xe1, 0x68, 0xe2, 0xe2, 0xcf, 0x61, 0x64, 0x74, 0x32, 0x06, + 0xfe, 0x88, 0xe9, 0x1d, 0xe2, 0xea, 0x76, 0xf9, 0x9e, 0xe7, 0x7d, 0x87, 0x7b, 0xad, 0xba, 0x00, + 0xa4, 0x1c, 0x43, 0x46, 0x33, 0xc8, 0x21, 0x15, 0x24, 0xcb, 0x51, 0xa2, 0x7d, 0x20, 0x00, 0x39, + 0x93, 0x13, 0xcc, 0x87, 0x44, 0x00, 0x92, 0xc2, 0x68, 0x1c, 0x46, 0x18, 0xa1, 0xe2, 0xb4, 0x78, + 0x69, 0xb5, 0xe1, 0x06, 0x28, 0x52, 0x14, 0xd4, 0x07, 0xc1, 0xe8, 0xb8, 0xe3, 0x33, 0x09, 0x1d, + 0x1a, 0x60, 0xcc, 0x35, 0x3f, 0x79, 0x2f, 0x59, 0xd5, 0x9e, 0xea, 0xb6, 0xbb, 0xd6, 0xb6, 0x9f, + 0x60, 0x30, 0xec, 0xe7, 0x6c, 0x02, 0x79, 0xe8, 0x98, 0x2d, 0xb3, 0x5d, 0xbb, 0x38, 0x26, 0xba, + 0x81, 0x14, 0x0d, 0x64, 0xd5, 0x40, 0xee, 0x30, 0xe6, 0xdd, 0xca, 0xec, 0xab, 0x69, 0x78, 0x35, + 0x15, 0xf2, 0x54, 0xc6, 0xbe, 0xb1, 0x36, 0x0b, 0x2f, 0x89, 0x39, 0x73, 0x4a, 0xff, 0xcb, 0xaf, + 0x03, 0xf6, 0x95, 0x75, 0x04, 0x9c, 0x8f, 0x20, 0xe9, 0x67, 0x2c, 0x0f, 0x18, 0x97, 0x10, 0xb1, + 0xfe, 0x34, 0x66, 0x49, 0xe8, 0x94, 0x5b, 0x66, 0x7b, 0xcb, 0xab, 0x6b, 0xdc, 0x5b, 0xd3, 0xc7, + 0x02, 0xda, 0xa7, 0xd6, 0xee, 0x00, 0x92, 0x71, 0xcc, 0xa3, 0x22, 0x18, 0x63, 0xe8, 0x54, 0x5a, + 0x66, 0xbb, 0xec, 0xed, 0xac, 0xae, 0x3d, 0x75, 0xb4, 0xcf, 0xad, 0x7d, 0x08, 0x9f, 0x47, 0x42, + 0xa6, 0x8c, 0xcb, 0x5f, 0x73, 0x43, 0x99, 0x7b, 0x7f, 0x40, 0xcb, 0xd7, 0x95, 0xb7, 0x8f, 0xa6, + 0xd1, 0xbd, 0x9d, 0x2d, 0x5c, 0x73, 0xbe, 0x70, 0xcd, 0xef, 0x85, 0x6b, 0xbe, 0x2e, 0x5d, 0x63, + 0xbe, 0x74, 0x8d, 0xcf, 0xa5, 0x6b, 0x3c, 0x9d, 0x45, 0xb1, 0x1c, 0x8c, 0x7c, 0x12, 0x60, 0x4a, + 0x1f, 0x00, 0xef, 0xf5, 0x1a, 0xb4, 0xd8, 0xeb, 0x45, 0x2f, 0x26, 0xa7, 0x19, 0x13, 0x7e, 0x55, + 0x7d, 0xf3, 0xe5, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x7d, 0xdb, 0xf8, 0xca, 0x01, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -133,6 +152,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.AdjustmentPeriod != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.AdjustmentPeriod)) + i-- + dAtA[i] = 0x28 + } + if m.HalvingPeriod != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.HalvingPeriod)) + i-- + dAtA[i] = 0x20 + } if len(m.AnnualPercentageYield) > 0 { i -= len(m.AnnualPercentageYield) copy(dAtA[i:], m.AnnualPercentageYield) @@ -188,6 +217,12 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + if m.HalvingPeriod != 0 { + n += 1 + sovParams(uint64(m.HalvingPeriod)) + } + if m.AdjustmentPeriod != 0 { + n += 1 + sovParams(uint64(m.AdjustmentPeriod)) + } return n } @@ -324,6 +359,44 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.AnnualPercentageYield = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HalvingPeriod", wireType) + } + m.HalvingPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HalvingPeriod |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AdjustmentPeriod", wireType) + } + m.AdjustmentPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AdjustmentPeriod |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])