Setup hooks between laconic modules (#9)

- Implement auction and bond module hooks in registry module
- Code cleanup

Reviewed-on: deep-stack/laconic2d#9
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Prathamesh Musale 2024-02-28 04:34:58 +00:00 committed by ashwin
parent ba7a127d7f
commit c79b7bea7d
33 changed files with 495 additions and 2683 deletions

View File

@ -7169,7 +7169,7 @@ type QueryAuctionRequest struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Auction ID
// Auction id
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
@ -7243,7 +7243,7 @@ type QueryBidRequest struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
// Bidder address
Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"`
@ -7326,7 +7326,7 @@ type QueryBidsRequest struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
}

View File

@ -3371,7 +3371,7 @@ type MsgCommitBid struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
// Commit Hash
CommitHash string `protobuf:"bytes,2,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"`
@ -3463,7 +3463,7 @@ type MsgRevealBid struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
// Commit Hash
Reveal string `protobuf:"bytes,2,opt,name=reveal,proto3" json:"reveal,omitempty"`

File diff suppressed because it is too large Load Diff

View File

@ -76,8 +76,8 @@ type LaconicApp struct {
ConsensusParamsKeeper consensuskeeper.Keeper
// laconic keepers
AuctionKeeper auctionkeeper.Keeper
BondKeeper bondkeeper.Keeper
AuctionKeeper *auctionkeeper.Keeper // (Use * as per ProvideModule implementation)
BondKeeper *bondkeeper.Keeper
RegistryKeeper registrykeeper.Keeper
// RegistryRecordKeeper registrykeeper.RecordKeeper

2
go.mod
View File

@ -37,6 +37,7 @@ require (
github.com/ipld/go-ipld-prime v0.21.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
@ -169,7 +170,6 @@ require (
go.etcd.io/bbolt v1.3.8 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.15.0 // indirect

View File

@ -77,7 +77,7 @@ message QueryAuctionsResponse {
// AuctionRequest is the format for querying a specific auction
message QueryAuctionRequest {
// Auction ID
// Auction id
string id = 1;
}
@ -89,7 +89,7 @@ message QueryAuctionResponse {
// BidRequest is the format for querying a specific bid in an auction
message QueryBidRequest {
// Auction ID
// Auction id
string auction_id = 1;
// Bidder address
string bidder = 2;
@ -103,7 +103,7 @@ message QueryBidResponse {
// BidsRequest is the format for querying all bids in an auction
message QueryBidsRequest {
// Auction ID
// Auction id
string auction_id = 1;
}

View File

@ -85,7 +85,7 @@ message MsgCommitBid {
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "signer";
// Auction ID
// Auction id
string auction_id = 1 [(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""];
// Commit Hash
@ -109,7 +109,7 @@ message MsgRevealBid {
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "signer";
// Auction ID
// Auction id
string auction_id = 1 [(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""];
// Commit Hash

View File

@ -131,22 +131,6 @@ message Signature {
string pub_key = 2 [(gogoproto.moretags) = "json:\"pub_key\" yaml:\"pub_key\""];
}
// BlockChangeSet
message BlockChangeSet {
int64 height = 1;
repeated string records = 2;
repeated string auctions = 3;
repeated AuctionBidInfo auction_bids = 4 [(gogoproto.moretags) = "json:\"auction_bids\" yaml:\"auction_bids\""];
repeated string authorities = 5;
repeated string names = 6;
}
// AuctionBidInfo
message AuctionBidInfo {
string auction_id = 1 [(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""];
string bidder_address = 2 [(gogoproto.moretags) = "json:\"bidder_address\" yaml:\"bidder_address\""];
}
// ExpiryQueue: record / authority expiry queue type
// id: expiry time
// value: array of ids (record cids / authority names)

View File

@ -3,6 +3,7 @@
rm -r ~/.laconic2d || true
LACONIC2D_BIN=$(which laconic2d)
# configure laconic2d
$LACONIC2D_BIN config set config log_level "*:error,p2p:info,state:info,auction:info,bond:info,registry:info" --skip-validate
$LACONIC2D_BIN config set client chain-id demo
$LACONIC2D_BIN config set client keyring-backend test
$LACONIC2D_BIN keys add alice

View File

@ -11,7 +11,7 @@ const (
AttributeKeyRevealFee = "reveal-fee"
AttributeKeyMinimumBid = "minimum-bid"
AttributeKeySigner = "signer"
AttributeKeyAuctionID = "auction-id"
AttributeKeyAuctionId = "auction-id"
AttributeKeyCommitHash = "commit-hash"
AttributeKeyReveal = "reveal"

View File

@ -0,0 +1,21 @@
package auction
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// AuctionUsageKeeper keep track of auction usage in other modules.
// Used to, for example, prevent deletion of a auction that's in use.
type AuctionUsageKeeper interface {
ModuleName() string
UsesAuction(ctx sdk.Context, auctionId string) bool
OnAuctionWinnerSelected(ctx sdk.Context, auctionId string)
}
// AuctionHooksWrapper is a wrapper for modules to inject AuctionUsageKeeper using depinject.
// Reference: https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#resolving-circular-dependencies
type AuctionHooksWrapper struct{ AuctionUsageKeeper }
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AuctionHooksWrapper) IsOnePerModuleType() {}

View File

@ -11,6 +11,7 @@ import (
"cosmossdk.io/collections/indexes"
storetypes "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -62,8 +63,6 @@ func newBidsIndexes(sb *collections.SchemaBuilder) BidsIndexes {
}
}
// TODO: Add required methods
type Keeper struct {
// Codecs
cdc codec.BinaryCodec
@ -73,7 +72,7 @@ type Keeper struct {
bankKeeper bank.Keeper
// Track auction usage in other cosmos-sdk modules (more like a usage tracker).
// usageKeepers []types.AuctionUsageKeeper
usageKeepers []auctiontypes.AuctionUsageKeeper
// state management
Schema collections.Schema
@ -88,7 +87,7 @@ func NewKeeper(
storeService storetypes.KVStoreService,
accountKeeper auth.AccountKeeper,
bankKeeper bank.Keeper,
) Keeper {
) *Keeper {
sb := collections.NewSchemaBuilder(storeService)
k := Keeper{
cdc: cdc,
@ -97,7 +96,7 @@ func NewKeeper(
Params: collections.NewItem(sb, auctiontypes.ParamsPrefix, "params", codec.CollValue[auctiontypes.Params](cdc)),
Auctions: collections.NewIndexedMap(sb, auctiontypes.AuctionsPrefix, "auctions", collections.StringKey, codec.CollValue[auctiontypes.Auction](cdc), newAuctionIndexes(sb)),
Bids: collections.NewIndexedMap(sb, auctiontypes.BidsPrefix, "bids", collections.PairKeyCodec(collections.StringKey, collections.StringKey), codec.CollValue[auctiontypes.Bid](cdc), newBidsIndexes(sb)),
// usageKeepers: usageKeepers,
usageKeepers: nil,
}
schema, err := sb.Build()
@ -107,22 +106,29 @@ func NewKeeper(
k.Schema = schema
return k
return &k
}
// func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) {
// k.usageKeepers = usageKeepers
// }
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return logger(ctx)
}
func logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", auctiontypes.ModuleName)
}
func (k *Keeper) SetUsageKeepers(usageKeepers []auctiontypes.AuctionUsageKeeper) {
if k.usageKeepers != nil {
panic("cannot set auction hooks twice")
}
k.usageKeepers = usageKeepers
}
// SaveAuction - saves a auction to the store.
func (k Keeper) SaveAuction(ctx sdk.Context, auction *auctiontypes.Auction) error {
return k.Auctions.Set(ctx, auction.Id, *auction)
// // Notify interested parties.
// for _, keeper := range k.usageKeepers {
// keeper.OnAuction(ctx, auction.Id)
// }
// return nil
}
// DeleteAuction - deletes the auction.
@ -154,12 +160,6 @@ func (k Keeper) HasAuction(ctx sdk.Context, id string) (bool, error) {
func (k Keeper) SaveBid(ctx sdk.Context, bid *auctiontypes.Bid) error {
key := collections.Join(bid.AuctionId, bid.BidderAddress)
return k.Bids.Set(ctx, key, *bid)
// // Notify interested parties.
// for _, keeper := range k.usageKeepers {
// keeper.OnAuctionBid(ctx, bid.AuctionId, bid.BidderAddress)
// }
// return nil
}
func (k Keeper) DeleteBid(ctx sdk.Context, bid auctiontypes.Bid) error {
@ -191,7 +191,6 @@ func (k Keeper) GetBid(ctx sdk.Context, id string, bidder string) (auctiontypes.
func (k Keeper) GetBids(ctx sdk.Context, id string) ([]*auctiontypes.Bid, error) {
var bids []*auctiontypes.Bid
// TODO: Optimize using return by value?
err := k.Bids.Walk(ctx, collections.NewPrefixedPairRange[string, string](id), func(key collections.Pair[string, string], value auctiontypes.Bid) (stop bool, err error) {
bids = append(bids, &value)
return false, nil
@ -463,13 +462,13 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.")
}
chainID, err := wnsUtils.GetAttributeAsString(reveal, "chainId")
if err != nil || chainID != ctx.ChainID() {
chainId, err := wnsUtils.GetAttributeAsString(reveal, "chainId")
if err != nil || chainId != ctx.ChainID() {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.")
}
auctionID, err := wnsUtils.GetAttributeAsString(reveal, "auctionId")
if err != nil || auctionID != msg.AuctionId {
auctionId, err := wnsUtils.GetAttributeAsString(reveal, "auctionId")
if err != nil || auctionId != msg.AuctionId {
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.")
}
@ -557,7 +556,7 @@ func (k Keeper) processAuctionPhases(ctx sdk.Context) error {
return err
}
ctx.Logger().Info(fmt.Sprintf("Moved auction %s to reveal phase.", auction.Id))
k.Logger(ctx).Info(fmt.Sprintf("Moved auction %s to reveal phase.", auction.Id))
}
// Reveal -> Expired state.
@ -567,7 +566,7 @@ func (k Keeper) processAuctionPhases(ctx sdk.Context) error {
return err
}
ctx.Logger().Info(fmt.Sprintf("Moved auction %s to expired state.", auction.Id))
k.Logger(ctx).Info(fmt.Sprintf("Moved auction %s to expired state.", auction.Id))
}
// If auction has expired, pick a winner from revealed bids.
@ -592,7 +591,7 @@ func (k Keeper) deleteCompletedAuctions(ctx sdk.Context) error {
}
for _, auction := range auctions {
ctx.Logger().Info(fmt.Sprintf("Deleting completed auction %s after timeout.", auction.Id))
k.Logger(ctx).Info(fmt.Sprintf("Deleting completed auction %s after timeout.", auction.Id))
if err := k.DeleteAuction(ctx, *auction); err != nil {
return err
}
@ -602,7 +601,7 @@ func (k Keeper) deleteCompletedAuctions(ctx sdk.Context) error {
}
func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction) error {
ctx.Logger().Info(fmt.Sprintf("Picking auction %s winner.", auction.Id))
k.Logger(ctx).Info(fmt.Sprintf("Picking auction %s winner.", auction.Id))
var highestBid *auctiontypes.Bid
var secondHighestBid *auctiontypes.Bid
@ -613,38 +612,38 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
}
for _, bid := range bids {
ctx.Logger().Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
// Only consider revealed bids.
if bid.Status != auctiontypes.BidStatusRevealed {
ctx.Logger().Info(fmt.Sprintf("Ignoring unrevealed bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Ignoring unrevealed bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
continue
}
// Init highest bid.
if highestBid == nil {
highestBid = bid
ctx.Logger().Info(fmt.Sprintf("Initializing 1st bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Initializing 1st bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
continue
}
//nolint: all
if highestBid.BidAmount.IsLT(bid.BidAmount) {
ctx.Logger().Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
secondHighestBid = highestBid
highestBid = bid
ctx.Logger().Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String()))
ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Updated 1st bid %s %s", highestBid.BidderAddress, highestBid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
} else if secondHighestBid == nil || secondHighestBid.BidAmount.IsLT(bid.BidAmount) {
ctx.Logger().Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("New 2nd highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
secondHighestBid = bid
ctx.Logger().Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Updated 2nd bid %s %s", secondHighestBid.BidderAddress, secondHighestBid.BidAmount.String()))
} else {
ctx.Logger().Info(fmt.Sprintf("Ignoring bid as it doesn't affect 1st/2nd price %s %s", bid.BidderAddress, bid.BidAmount.String()))
k.Logger(ctx).Info(fmt.Sprintf("Ignoring bid as it doesn't affect 1st/2nd price %s %s", bid.BidderAddress, bid.BidAmount.String()))
}
}
@ -660,11 +659,11 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
if secondHighestBid != nil {
auction.WinningPrice = secondHighestBid.BidAmount
}
ctx.Logger().Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddress))
ctx.Logger().Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBid.String()))
ctx.Logger().Info(fmt.Sprintf("Auction %s winner price %s.", auction.Id, auction.WinningPrice.String()))
k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner %s.", auction.Id, auction.WinnerAddress))
k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner bid %s.", auction.Id, auction.WinningBid.String()))
k.Logger(ctx).Info(fmt.Sprintf("Auction %s winner price %s.", auction.Id, auction.WinningPrice.String()))
} else {
ctx.Logger().Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id))
k.Logger(ctx).Info(fmt.Sprintf("Auction %s has no valid revealed bids (no winner).", auction.Id))
}
if err := k.SaveAuction(ctx, auction); err != nil {
@ -674,7 +673,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
for _, bid := range bids {
bidderAddress, err := sdk.AccAddressFromBech32(bid.BidderAddress)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
k.Logger(ctx).Error(fmt.Sprintf("Invalid bidderAddress address. %v", err))
panic("Invalid bidder address.")
}
@ -682,7 +681,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
// Send reveal fee back to bidders that've revealed the bid.
sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidderAddress, sdk.NewCoins(bid.RevealFee))
if sdkErr != nil {
ctx.Logger().Error(fmt.Sprintf("Auction error returning reveal fee: %v", sdkErr))
k.Logger(ctx).Error(fmt.Sprintf("Auction error returning reveal fee: %v", sdkErr))
panic(sdkErr)
}
}
@ -690,7 +689,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
// Send back locked bid amount to all bidders.
sdkErr := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidderAddress, sdk.NewCoins(bid.BidAmount))
if sdkErr != nil {
ctx.Logger().Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErr))
k.Logger(ctx).Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErr))
panic(sdkErr)
}
}
@ -699,39 +698,38 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction
if auction.WinnerAddress != "" {
winnerAddress, err := sdk.AccAddressFromBech32(auction.WinnerAddress)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("Invalid winner address. %v", err))
k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err))
panic("Invalid winner address.")
}
// Take 2nd price from winner.
sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, winnerAddress, auctiontypes.ModuleName, sdk.NewCoins(auction.WinningPrice))
if sdkErr != nil {
ctx.Logger().Error(fmt.Sprintf("Auction error taking funds from winner: %v", sdkErr))
k.Logger(ctx).Error(fmt.Sprintf("Auction error taking funds from winner: %v", sdkErr))
panic(sdkErr)
}
// Burn anything over the min. bid amount.
amountToBurn := auction.WinningPrice.Sub(auction.MinimumBid)
if amountToBurn.IsNegative() {
ctx.Logger().Error("Auction coins to burn cannot be negative.")
k.Logger(ctx).Error("Auction coins to burn cannot be negative.")
panic("Auction coins to burn cannot be negative.")
}
// Use auction burn module account instead of actually burning coins to better keep track of supply.
sdkErr = k.bankKeeper.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, auctiontypes.AuctionBurnModuleAccountName, sdk.NewCoins(amountToBurn))
if sdkErr != nil {
ctx.Logger().Error(fmt.Sprintf("Auction error burning coins: %v", sdkErr))
k.Logger(ctx).Error(fmt.Sprintf("Auction error burning coins: %v", sdkErr))
panic(sdkErr)
}
}
// TODO
// Notify other modules (hook).
// ctx.Logger().Info(fmt.Sprintf("Auction %s notifying %d modules.", auction.Id, len(k.usageKeepers)))
// for _, keeper := range k.usageKeepers {
// ctx.Logger().Info(fmt.Sprintf("Auction %s notifying module %s.", auction.Id, keeper.ModuleName()))
// keeper.OnAuctionWinnerSelected(ctx, auction.Id)
// }
k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying %d modules.", auction.Id, len(k.usageKeepers)))
for _, keeper := range k.usageKeepers {
k.Logger(ctx).Info(fmt.Sprintf("Auction %s notifying module %s.", auction.Id, keeper.ModuleName()))
keeper.OnAuctionWinnerSelected(ctx, auction.Id)
}
return nil
}

View File

@ -10,11 +10,11 @@ import (
var _ auctiontypes.MsgServer = msgServer{}
type msgServer struct {
k Keeper
k *Keeper
}
// NewMsgServerImpl returns an implementation of the module MsgServer interface.
func NewMsgServerImpl(keeper Keeper) auctiontypes.MsgServer {
func NewMsgServerImpl(keeper *Keeper) auctiontypes.MsgServer {
return &msgServer{k: keeper}
}
@ -67,7 +67,7 @@ func (ms msgServer) CommitBid(c context.Context, msg *auctiontypes.MsgCommitBid)
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
auctiontypes.EventTypeCommitBid,
sdk.NewAttribute(auctiontypes.AttributeKeyAuctionID, msg.AuctionId),
sdk.NewAttribute(auctiontypes.AttributeKeyAuctionId, msg.AuctionId),
sdk.NewAttribute(auctiontypes.AttributeKeyCommitHash, msg.CommitHash),
),
sdk.NewEvent(
@ -98,7 +98,7 @@ func (ms msgServer) RevealBid(c context.Context, msg *auctiontypes.MsgRevealBid)
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
auctiontypes.EventTypeRevealBid,
sdk.NewAttribute(auctiontypes.AttributeKeyAuctionID, msg.AuctionId),
sdk.NewAttribute(auctiontypes.AttributeKeyAuctionId, msg.AuctionId),
sdk.NewAttribute(auctiontypes.AttributeKeyReveal, msg.Reveal),
),
sdk.NewEvent(

View File

@ -13,11 +13,11 @@ import (
var _ auctiontypes.QueryServer = queryServer{}
type queryServer struct {
k Keeper
k *Keeper
}
// NewQueryServerImpl returns an implementation of the module QueryServer.
func NewQueryServerImpl(k Keeper) auctiontypes.QueryServer {
func NewQueryServerImpl(k *Keeper) auctiontypes.QueryServer {
return queryServer{k}
}

View File

@ -9,7 +9,7 @@ import (
)
// EndBlocker is called every block
func EndBlocker(ctx context.Context, k keeper.Keeper) error {
func EndBlocker(ctx context.Context, k *keeper.Keeper) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
return k.EndBlockerProcessAuctions(sdkCtx)

View File

@ -4,12 +4,14 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"golang.org/x/exp/maps"
"github.com/cosmos/cosmos-sdk/codec"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
modulev1 "git.vdb.to/cerc-io/laconic2d/api/cerc/auction/module/v1"
"git.vdb.to/cerc-io/laconic2d/x/auction"
"git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
)
@ -25,6 +27,7 @@ func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
appmodule.Invoke(InvokeSetAuctionHooks),
)
}
@ -41,7 +44,11 @@ type ModuleInputs struct {
type ModuleOutputs struct {
depinject.Out
Keeper keeper.Keeper
// Use * as required by InvokeSetAuctionHooks
// https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#invoker-invocation-details
// https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#regular-golang-types
Keeper *keeper.Keeper
Module appmodule.AppModule
}
@ -51,3 +58,25 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
return ModuleOutputs{Module: m, Keeper: k}
}
func InvokeSetAuctionHooks(
config *modulev1.Module,
keeper *keeper.Keeper,
auctionHooks map[string]auction.AuctionHooksWrapper,
) error {
// all arguments to invokers are optional
if keeper == nil || config == nil {
return nil
}
var usageKeepers []auction.AuctionUsageKeeper
for _, modName := range maps.Keys(auctionHooks) {
hook := auctionHooks[modName]
usageKeepers = append(usageKeepers, hook)
}
keeper.SetUsageKeepers(usageKeepers)
return nil
}

View File

@ -20,8 +20,6 @@ import (
"git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
)
// TODO: Port remaining AppModule methods
var (
_ module.AppModuleBasic = AppModule{}
_ appmodule.AppModule = AppModule{}
@ -36,11 +34,11 @@ const ConsensusVersion = 1
type AppModule struct {
cdc codec.Codec
keeper keeper.Keeper
keeper *keeper.Keeper
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule {
return AppModule{
cdc: cdc,
keeper: keeper,

View File

@ -25,9 +25,9 @@ func NewMsgCreateAuction(params Params, signer sdk.AccAddress) MsgCreateAuction
}
// NewMsgCommitBid is the constructor function for MsgCommitBid.
func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
func NewMsgCommitBid(auctionId string, commitHash string, signer sdk.AccAddress) MsgCommitBid {
return MsgCommitBid{
AuctionId: auctionID,
AuctionId: auctionId,
CommitHash: commitHash,
Signer: signer.String(),
}

View File

@ -217,7 +217,7 @@ func (m *QueryAuctionsResponse) GetPagination() *query.PageRequest {
// AuctionRequest is the format for querying a specific auction
type QueryAuctionRequest struct {
// Auction ID
// Auction id
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
@ -309,7 +309,7 @@ func (m *QueryAuctionResponse) GetAuction() *Auction {
// BidRequest is the format for querying a specific bid in an auction
type QueryBidRequest struct {
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
// Bidder address
Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"`
@ -410,7 +410,7 @@ func (m *QueryBidResponse) GetBid() *Bid {
// BidsRequest is the format for querying all bids in an auction
type QueryBidsRequest struct {
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"`
}

View File

@ -125,7 +125,7 @@ var xxx_messageInfo_MsgCreateAuctionResponse proto.InternalMessageInfo
// CommitBid defines the message to commit a bid
type MsgCommitBid struct {
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" json:"auction_id" yaml:"auction_id"`
// Commit Hash
CommitHash string `protobuf:"bytes,2,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty" json:"commit_hash" yaml:"commit_hash"`
@ -207,7 +207,7 @@ var xxx_messageInfo_MsgCommitBidResponse proto.InternalMessageInfo
// RevealBid defines the message to reveal a bid
type MsgRevealBid struct {
// Auction ID
// Auction id
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" json:"auction_id" yaml:"auction_id"`
// Commit Hash
Reveal string `protobuf:"bytes,2,opt,name=reveal,proto3" json:"reveal,omitempty" json:"reveal" yaml:"reveal"`

View File

@ -29,14 +29,14 @@ const (
BidStatusRevealed = "reveal"
)
// AuctionId simplifies generation of auction IDs.
// AuctionId simplifies generation of auction ids.
type AuctionId struct {
Address sdk.Address
AccNum uint64
Sequence uint64
}
// Generate creates the auction ID.
// Generate creates the auction id.
func (auctionId AuctionId) Generate() string {
hasher := sha256.New()
str := fmt.Sprintf("%s:%d:%d", auctionId.Address.String(), auctionId.AccNum, auctionId.Sequence)

19
x/bond/expected_keeper.go Normal file
View File

@ -0,0 +1,19 @@
package bond
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// BondUsageKeeper keep track of bond usage in other modules.
// Used to, for example, prevent deletion of a bond that's in use.
type BondUsageKeeper interface {
ModuleName() string
UsesBond(ctx sdk.Context, bondId string) bool
}
// BondHooksWrapper is a wrapper for modules to inject BondUsageKeeper using depinject.
// Reference: https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#resolving-circular-dependencies
type BondHooksWrapper struct{ BondUsageKeeper }
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (BondHooksWrapper) IsOnePerModuleType() {}

View File

@ -49,7 +49,7 @@ type Keeper struct {
bankKeeper bank.Keeper
// Track bond usage in other cosmos-sdk modules (more like a usage tracker).
// usageKeepers []types.BondUsageKeeper
usageKeepers []bondtypes.BondUsageKeeper
// State management
Schema collections.Schema
@ -63,8 +63,7 @@ func NewKeeper(
storeService store.KVStoreService,
accountKeeper auth.AccountKeeper,
bankKeeper bank.Keeper,
// usageKeepers []types.BondUsageKeeper,
) Keeper {
) *Keeper {
sb := collections.NewSchemaBuilder(storeService)
k := Keeper{
cdc: cdc,
@ -72,7 +71,7 @@ func NewKeeper(
bankKeeper: bankKeeper,
Params: collections.NewItem(sb, bondtypes.ParamsPrefix, "params", codec.CollValue[bondtypes.Params](cdc)),
Bonds: collections.NewIndexedMap(sb, bondtypes.BondsPrefix, "bonds", collections.StringKey, codec.CollValue[bondtypes.Bond](cdc), newBondIndexes(sb)),
// usageKeepers: usageKeepers,
usageKeepers: nil,
}
schema, err := sb.Build()
@ -82,7 +81,15 @@ func NewKeeper(
k.Schema = schema
return k
return &k
}
func (k *Keeper) SetUsageKeepers(usageKeepers []bondtypes.BondUsageKeeper) {
if k.usageKeepers != nil {
panic("cannot set bond hooks twice")
}
k.usageKeepers = usageKeepers
}
// BondId simplifies generation of bond Ids.
@ -318,13 +325,12 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.")
}
// TODO
// Check if bond is used in other modules.
// for _, usageKeeper := range k.usageKeepers {
// if usageKeeper.UsesBond(ctx, id) {
// return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName()))
// }
// }
for _, usageKeeper := range k.usageKeepers {
if usageKeeper.UsesBond(ctx, id) {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName()))
}
}
// Move funds from the bond into the account.
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, bondtypes.ModuleName, ownerAddress, bond.Balance)

View File

@ -11,11 +11,11 @@ import (
var _ bond.MsgServer = msgServer{}
type msgServer struct {
k Keeper
k *Keeper
}
// NewMsgServerImpl returns an implementation of the module MsgServer interface.
func NewMsgServerImpl(keeper Keeper) bond.MsgServer {
func NewMsgServerImpl(keeper *Keeper) bond.MsgServer {
return &msgServer{k: keeper}
}

View File

@ -13,11 +13,11 @@ import (
var _ bondtypes.QueryServer = queryServer{}
type queryServer struct {
k Keeper
k *Keeper
}
// NewQueryServerImpl returns an implementation of the module QueryServer.
func NewQueryServerImpl(k Keeper) bondtypes.QueryServer {
func NewQueryServerImpl(k *Keeper) bondtypes.QueryServer {
return queryServer{k}
}

View File

@ -4,12 +4,14 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"golang.org/x/exp/maps"
"github.com/cosmos/cosmos-sdk/codec"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
modulev1 "git.vdb.to/cerc-io/laconic2d/api/cerc/bond/module/v1"
"git.vdb.to/cerc-io/laconic2d/x/bond"
"git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
)
@ -25,6 +27,7 @@ func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
appmodule.Invoke(InvokeSetBondHooks),
)
}
@ -41,7 +44,7 @@ type ModuleInputs struct {
type ModuleOutputs struct {
depinject.Out
Keeper keeper.Keeper
Keeper *keeper.Keeper
Module appmodule.AppModule
}
@ -51,3 +54,25 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
return ModuleOutputs{Module: m, Keeper: k}
}
func InvokeSetBondHooks(
config *modulev1.Module,
keeper *keeper.Keeper,
bondHooks map[string]bond.BondHooksWrapper,
) error {
// all arguments to invokers are optional
if keeper == nil || config == nil {
return nil
}
var usageKeepers []bond.BondUsageKeeper
for _, modName := range maps.Keys(bondHooks) {
hook := bondHooks[modName]
usageKeepers = append(usageKeepers, hook)
}
keeper.SetUsageKeepers(usageKeepers)
return nil
}

View File

@ -18,8 +18,6 @@ import (
"git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
)
// TODO: Port remaining AppModule methods
var (
_ module.AppModuleBasic = AppModule{}
_ appmodule.AppModule = AppModule{}
@ -33,11 +31,11 @@ const ConsensusVersion = 1
type AppModule struct {
cdc codec.Codec
keeper keeper.Keeper
keeper *keeper.Keeper
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule {
return AppModule{
cdc: cdc,
keeper: keeper,

View File

@ -43,12 +43,6 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error
if err := k.insertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime); err != nil {
return err
}
// TODO
// Note: Bond genesis runs first, so bonds will already be present.
// if authority.Entry.BondId != "" {
// k.AddBondToAuthorityIndexEntry(ctx, authority.Entry.BondId, authority.Name)
// }
}
}

View File

@ -11,6 +11,7 @@ import (
"cosmossdk.io/collections/indexes"
storetypes "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -28,8 +29,6 @@ import (
"git.vdb.to/cerc-io/laconic2d/x/registry/helpers"
)
// TODO: Add required methods
type RecordsIndexes struct {
BondId *indexes.Multi[string, string, registrytypes.Record]
}
@ -50,16 +49,24 @@ func newRecordIndexes(sb *collections.SchemaBuilder) RecordsIndexes {
}
}
// TODO
type AuthoritiesIndexes struct {
AuctionId *indexes.Multi[string, string, registrytypes.NameAuthority]
}
func (b AuthoritiesIndexes) IndexesList() []collections.Index[string, registrytypes.NameAuthority] {
return []collections.Index[string, registrytypes.NameAuthority]{}
func (a AuthoritiesIndexes) IndexesList() []collections.Index[string, registrytypes.NameAuthority] {
return []collections.Index[string, registrytypes.NameAuthority]{a.AuctionId}
}
func newAuthorityIndexes(sb *collections.SchemaBuilder) AuthoritiesIndexes {
return AuthoritiesIndexes{}
return AuthoritiesIndexes{
AuctionId: indexes.NewMulti(
sb, registrytypes.AuthoritiesByAuctionIdIndexPrefix, "authorities_by_auction_id",
collections.StringKey, collections.StringKey,
func(name string, v registrytypes.NameAuthority) (string, error) {
return v.AuctionId, nil
},
),
}
}
type NameRecordsIndexes struct {
@ -87,9 +94,8 @@ type Keeper struct {
accountKeeper auth.AccountKeeper
bankKeeper bank.Keeper
recordKeeper RecordKeeper
bondKeeper bondkeeper.Keeper
auctionKeeper auctionkeeper.Keeper
bondKeeper *bondkeeper.Keeper
auctionKeeper *auctionkeeper.Keeper
// state management
Schema collections.Schema
@ -107,16 +113,14 @@ func NewKeeper(
storeService storetypes.KVStoreService,
accountKeeper auth.AccountKeeper,
bankKeeper bank.Keeper,
recordKeeper RecordKeeper,
bondKeeper bondkeeper.Keeper,
auctionKeeper auctionkeeper.Keeper,
bondKeeper *bondkeeper.Keeper,
auctionKeeper *auctionkeeper.Keeper,
) Keeper {
sb := collections.NewSchemaBuilder(storeService)
k := Keeper{
cdc: cdc,
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
recordKeeper: recordKeeper,
bondKeeper: bondKeeper,
auctionKeeper: auctionKeeper,
Params: collections.NewItem(sb, registrytypes.ParamsPrefix, "params", codec.CollValue[registrytypes.Params](cdc)),
@ -155,6 +159,15 @@ func NewKeeper(
return k
}
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return logger(ctx)
}
func logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", registrytypes.ModuleName)
}
// HasRecord - checks if a record by the given id exists.
func (k Keeper) HasRecord(ctx sdk.Context, id string) (bool, error) {
has, err := k.Records.Has(ctx, id)
@ -230,9 +243,6 @@ func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*registrytyp
// PutRecord - saves a record to the store.
func (k Keeper) SaveRecord(ctx sdk.Context, record registrytypes.Record) error {
return k.Records.Set(ctx, record.Id, record)
// TODO
// k.updateBlockChangeSetForRecord(ctx, record.Id)
}
// ProcessSetRecord creates a record.
@ -274,7 +284,7 @@ func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*reg
// Sort owners list.
sort.Strings(record.Owners)
sdkErr := k.processRecord(ctx, &record, false)
sdkErr := k.processRecord(ctx, &record)
if sdkErr != nil {
return nil, sdkErr
}
@ -282,7 +292,7 @@ func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*reg
return &record, nil
}
func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRecord, isRenewal bool) error {
func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRecord) error {
params, err := k.GetParams(ctx)
if err != nil {
return err
@ -420,7 +430,6 @@ func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalan
// ProcessRecordExpiryQueue tries to renew expiring records (by collecting rent) else marks them as deleted.
func (k Keeper) ProcessRecordExpiryQueue(ctx sdk.Context) error {
// TODO: process expired records
cids, err := k.getAllExpiredRecords(ctx, ctx.BlockHeader().Time)
if err != nil {
return err

View File

@ -132,16 +132,7 @@ func (k Keeper) SaveNameRecord(ctx sdk.Context, crn string, id string) error {
Height: uint64(ctx.BlockHeight()),
}
// TODO: Check if index gets updated on entry updates
if err := k.NameRecords.Set(ctx, crn, nameRecord); err != nil {
return err
}
// TODO
// Update changeSet for name.
// k.updateBlockChangeSetForName(ctx, crn)
return nil
return k.NameRecords.Set(ctx, crn, nameRecord)
}
// SetName creates a CRN -> Record ID mapping.
@ -169,9 +160,6 @@ func (k Keeper) SetName(ctx sdk.Context, msg registrytypes.MsgSetName) error {
// SaveNameAuthority creates the NameAuthority record.
func (k Keeper) SaveNameAuthority(ctx sdk.Context, name string, authority *registrytypes.NameAuthority) error {
return k.Authorities.Set(ctx, name, *authority)
// TODO
// updateBlockChangeSetForNameAuthority(ctx, codec, store, name)
}
// ReserveAuthority reserves a name authority.
@ -282,12 +270,9 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
// If auctions are enabled, clear out owner fields. They will be set after a winner is picked.
authority.OwnerAddress = ""
authority.OwnerPublicKey = ""
// Reset bond ID if required.
if authority.BondId != "" || len(authority.BondId) != 0 {
// TODO
// k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
authority.BondId = ""
}
authority.BondId = ""
params := auctiontypes.Params{
CommitsDuration: moduleParams.AuthorityAuctionCommitsDuration,
@ -305,10 +290,6 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
return sdkErr
}
// TODO
// Create auction ID -> authority name index.
// k.AddAuctionToAuthorityMapping(ctx, auction.Id, name)
authority.Status = registrytypes.AuthorityUnderAuction
authority.AuctionId = auction.Id
authority.ExpiryTime = auction.RevealsEndTime.Add(moduleParams.AuthorityGracePeriod)
@ -362,22 +343,12 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor
return nil
}
// TODO
// Remove old bond ID mapping, if any.
// if authority.BondId != "" {
// k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
// }
// Update bond id and save name authority in store.
authority.BondId = bond.Id
if err = k.SaveNameAuthority(ctx, name, &authority); err != nil {
return err
}
// TODO
// Add new bond ID mapping.
// k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
return nil
}
@ -546,8 +517,7 @@ func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) error {
return err
}
// TODO: Setup logger
// k.Logger(ctx).Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
k.Logger(ctx).Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
return nil
}
@ -620,7 +590,7 @@ func (k Keeper) deleteAuthorityExpiryQueue(ctx sdk.Context, name string, authori
// tryTakeAuthorityRent tries to take rent from the authority bond.
func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority registrytypes.NameAuthority) error {
// k.Logger(ctx).Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
k.Logger(ctx).Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
params, err := k.GetParams(ctx)
if err != nil {
@ -636,7 +606,8 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg
return err
}
// k.Logger(ctx).Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
k.Logger(ctx).Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
return k.deleteAuthorityExpiryQueue(ctx, name, authority)
}
@ -653,7 +624,8 @@ func (k Keeper) tryTakeAuthorityRent(ctx sdk.Context, name string, authority reg
// Save authority.
authority.Status = registrytypes.AuthorityActive
// k.Logger(ctx).Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
k.Logger(ctx).Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
return k.SaveNameAuthority(ctx, name, &authority)
}

View File

@ -1,24 +1,137 @@
package keeper
import (
"errors"
"fmt"
"time"
"cosmossdk.io/collections"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
bondtypes "git.vdb.to/cerc-io/laconic2d/x/bond"
registrytypes "git.vdb.to/cerc-io/laconic2d/x/registry"
)
// TODO: Add methods
// Record keeper implements the bond usage keeper interface.
var (
_ auctiontypes.AuctionUsageKeeper = RecordKeeper{}
_ bondtypes.BondUsageKeeper = RecordKeeper{}
)
// RecordKeeper exposes the bare minimal read-only API for other modules.
type RecordKeeper struct {
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
auctionKeeper auctionkeeper.Keeper
// storeKey storetypes.StoreKey // Unexposed key to access store from sdk.Context
k *Keeper
auctionKeeper *auctionkeeper.Keeper
}
// NewRecordKeeper creates new instances of the registry RecordKeeper
func NewRecordKeeper(cdc codec.BinaryCodec, k *Keeper, auctionKeeper *auctionkeeper.Keeper) RecordKeeper {
return RecordKeeper{
cdc: cdc,
k: k,
auctionKeeper: auctionKeeper,
}
}
// ModuleName returns the module name.
func (rk RecordKeeper) ModuleName() string {
return registrytypes.ModuleName
}
func (rk RecordKeeper) UsesAuction(ctx sdk.Context, auctionId string) bool {
iter, err := rk.k.Authorities.Indexes.AuctionId.MatchExact(ctx, auctionId)
if err != nil {
panic(err)
}
return iter.Valid()
}
func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string) {
// Update authority status based on auction status/winner.
iter, err := rk.k.Authorities.Indexes.AuctionId.MatchExact(ctx, auctionId)
if err != nil && !errors.Is(err, collections.ErrNotFound) {
panic(err)
}
names, err := iter.PrimaryKeys()
if err != nil {
panic(err)
}
if len(names) == 0 {
// We don't know about this auction, ignore.
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionId))
return
}
// Take the first one as an auction (non-empty) will map to only one name
// MultiIndex being used as there can be multiple entries with empty auction id ("")
name := names[0]
if has, err := rk.k.HasNameAuthority(ctx, name); !has {
if err != nil {
panic(err)
}
// We don't know about this authority, ignore.
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionId))
return
}
authority, err := rk.k.GetNameAuthority(ctx, name)
if err != nil {
panic(err)
}
auctionObj, err := rk.auctionKeeper.GetAuctionById(ctx, auctionId)
if err != nil {
panic(err)
}
if auctionObj.Status == auctiontypes.AuctionStatusCompleted {
if auctionObj.WinnerAddress != "" {
// Mark authority owner and change status to active.
authority.OwnerAddress = auctionObj.WinnerAddress
authority.Status = registrytypes.AuthorityActive
// Reset bond id if required, as owner has changed.
authority.BondId = ""
// Update height for updated/changed authority (owner).
// Can be used to check if names are older than the authority itself (stale names).
authority.Height = uint64(ctx.BlockHeight())
logger(ctx).Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
} else {
// Mark as expired.
authority.Status = registrytypes.AuthorityExpired
logger(ctx).Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
}
// Forget about this auction now, we no longer need it.
authority.AuctionId = ""
if err = rk.k.SaveNameAuthority(ctx, name, &authority); err != nil {
panic(err)
}
} else {
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
}
}
// UsesBond returns true if the bond has associated records.
func (rk RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool {
iter, err := rk.k.Records.Indexes.BondId.MatchExact(ctx, bondId)
if err != nil {
panic(err)
}
return iter.Valid()
}
// RenewRecord renews a record.
@ -46,7 +159,7 @@ func (k Keeper) RenewRecord(ctx sdk.Context, msg registrytypes.MsgRenewRecord) e
}
readableRecord := record.ToReadableRecord()
return k.processRecord(ctx, &readableRecord, true)
return k.processRecord(ctx, &readableRecord)
}
// AssociateBond associates a record with a bond.

View File

@ -10,7 +10,9 @@ import (
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
modulev1 "git.vdb.to/cerc-io/laconic2d/api/cerc/registry/module/v1"
"git.vdb.to/cerc-io/laconic2d/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
"git.vdb.to/cerc-io/laconic2d/x/bond"
bondkeeper "git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
"git.vdb.to/cerc-io/laconic2d/x/registry/keeper"
)
@ -39,8 +41,8 @@ type ModuleInputs struct {
AccountKeeper auth.AccountKeeper
BankKeeper bank.Keeper
BondKeeper bondkeeper.Keeper
AuctionKeeper auctionkeeper.Keeper
BondKeeper *bondkeeper.Keeper
AuctionKeeper *auctionkeeper.Keeper
}
type ModuleOutputs struct {
@ -48,6 +50,9 @@ type ModuleOutputs struct {
Keeper keeper.Keeper
Module appmodule.AppModule
AuctionHooks auction.AuctionHooksWrapper
BondHooks bond.BondHooksWrapper
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
@ -56,11 +61,16 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
in.StoreService,
in.AccountKeeper,
in.BankKeeper,
keeper.RecordKeeper{},
in.BondKeeper,
in.AuctionKeeper,
)
m := NewAppModule(in.Cdc, k)
return ModuleOutputs{Module: m, Keeper: k}
recordKeeper := keeper.NewRecordKeeper(in.Cdc, &k, in.AuctionKeeper)
return ModuleOutputs{
Module: m, Keeper: k,
AuctionHooks: auction.AuctionHooksWrapper{AuctionUsageKeeper: recordKeeper},
BondHooks: bond.BondHooksWrapper{BondUsageKeeper: recordKeeper},
}
}

View File

@ -624,144 +624,6 @@ func (m *Signature) GetPubKey() string {
return ""
}
// BlockChangeSet
type BlockChangeSet struct {
Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
Records []string `protobuf:"bytes,2,rep,name=records,proto3" json:"records,omitempty"`
Auctions []string `protobuf:"bytes,3,rep,name=auctions,proto3" json:"auctions,omitempty"`
AuctionBids []*AuctionBidInfo `protobuf:"bytes,4,rep,name=auction_bids,json=auctionBids,proto3" json:"auction_bids,omitempty" json:"auction_bids" yaml:"auction_bids"`
Authorities []string `protobuf:"bytes,5,rep,name=authorities,proto3" json:"authorities,omitempty"`
Names []string `protobuf:"bytes,6,rep,name=names,proto3" json:"names,omitempty"`
}
func (m *BlockChangeSet) Reset() { *m = BlockChangeSet{} }
func (m *BlockChangeSet) String() string { return proto.CompactTextString(m) }
func (*BlockChangeSet) ProtoMessage() {}
func (*BlockChangeSet) Descriptor() ([]byte, []int) {
return fileDescriptor_d792f2373089b5b9, []int{8}
}
func (m *BlockChangeSet) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *BlockChangeSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_BlockChangeSet.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 *BlockChangeSet) XXX_Merge(src proto.Message) {
xxx_messageInfo_BlockChangeSet.Merge(m, src)
}
func (m *BlockChangeSet) XXX_Size() int {
return m.Size()
}
func (m *BlockChangeSet) XXX_DiscardUnknown() {
xxx_messageInfo_BlockChangeSet.DiscardUnknown(m)
}
var xxx_messageInfo_BlockChangeSet proto.InternalMessageInfo
func (m *BlockChangeSet) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
func (m *BlockChangeSet) GetRecords() []string {
if m != nil {
return m.Records
}
return nil
}
func (m *BlockChangeSet) GetAuctions() []string {
if m != nil {
return m.Auctions
}
return nil
}
func (m *BlockChangeSet) GetAuctionBids() []*AuctionBidInfo {
if m != nil {
return m.AuctionBids
}
return nil
}
func (m *BlockChangeSet) GetAuthorities() []string {
if m != nil {
return m.Authorities
}
return nil
}
func (m *BlockChangeSet) GetNames() []string {
if m != nil {
return m.Names
}
return nil
}
// AuctionBidInfo
type AuctionBidInfo struct {
AuctionId string `protobuf:"bytes,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty" json:"auction_id" yaml:"auction_id"`
BidderAddress string `protobuf:"bytes,2,opt,name=bidder_address,json=bidderAddress,proto3" json:"bidder_address,omitempty" json:"bidder_address" yaml:"bidder_address"`
}
func (m *AuctionBidInfo) Reset() { *m = AuctionBidInfo{} }
func (m *AuctionBidInfo) String() string { return proto.CompactTextString(m) }
func (*AuctionBidInfo) ProtoMessage() {}
func (*AuctionBidInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_d792f2373089b5b9, []int{9}
}
func (m *AuctionBidInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *AuctionBidInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_AuctionBidInfo.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 *AuctionBidInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_AuctionBidInfo.Merge(m, src)
}
func (m *AuctionBidInfo) XXX_Size() int {
return m.Size()
}
func (m *AuctionBidInfo) XXX_DiscardUnknown() {
xxx_messageInfo_AuctionBidInfo.DiscardUnknown(m)
}
var xxx_messageInfo_AuctionBidInfo proto.InternalMessageInfo
func (m *AuctionBidInfo) GetAuctionId() string {
if m != nil {
return m.AuctionId
}
return ""
}
func (m *AuctionBidInfo) GetBidderAddress() string {
if m != nil {
return m.BidderAddress
}
return ""
}
// ExpiryQueue: record / authority expiry queue type
// id: expiry time
// value: array of ids (record cids / authority names)
@ -774,7 +636,7 @@ func (m *ExpiryQueue) Reset() { *m = ExpiryQueue{} }
func (m *ExpiryQueue) String() string { return proto.CompactTextString(m) }
func (*ExpiryQueue) ProtoMessage() {}
func (*ExpiryQueue) Descriptor() ([]byte, []int) {
return fileDescriptor_d792f2373089b5b9, []int{10}
return fileDescriptor_d792f2373089b5b9, []int{8}
}
func (m *ExpiryQueue) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -826,101 +688,90 @@ func init() {
proto.RegisterType((*NameRecord)(nil), "cerc.registry.v1.NameRecord")
proto.RegisterType((*NameRecordEntry)(nil), "cerc.registry.v1.NameRecordEntry")
proto.RegisterType((*Signature)(nil), "cerc.registry.v1.Signature")
proto.RegisterType((*BlockChangeSet)(nil), "cerc.registry.v1.BlockChangeSet")
proto.RegisterType((*AuctionBidInfo)(nil), "cerc.registry.v1.AuctionBidInfo")
proto.RegisterType((*ExpiryQueue)(nil), "cerc.registry.v1.ExpiryQueue")
}
func init() { proto.RegisterFile("cerc/registry/v1/registry.proto", fileDescriptor_d792f2373089b5b9) }
var fileDescriptor_d792f2373089b5b9 = []byte{
// 1365 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4f, 0x6f, 0x1b, 0x45,
0x14, 0xcf, 0xc6, 0x89, 0x13, 0x3f, 0x37, 0xa1, 0x1a, 0xd2, 0xd6, 0x09, 0xad, 0x37, 0x35, 0x42,
0x69, 0x55, 0xd5, 0xab, 0x34, 0x42, 0x55, 0x5b, 0x71, 0xc8, 0x86, 0x34, 0x0a, 0x15, 0xd0, 0x4e,
0x2a, 0x0e, 0x20, 0x64, 0xed, 0x9f, 0xa9, 0x33, 0xd4, 0xbb, 0x6b, 0xed, 0xce, 0x9a, 0xfa, 0x88,
0xc4, 0x01, 0x6e, 0x3d, 0xf6, 0xc0, 0x37, 0xe0, 0x00, 0xdf, 0x82, 0x1e, 0x7b, 0xe4, 0x82, 0x41,
0x8d, 0xc4, 0x07, 0xf0, 0x27, 0x40, 0xf3, 0x67, 0xff, 0xda, 0xae, 0x81, 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x01, 0xac, 0x1c, 0xf3, 0xa5, 0x79, 0x1e, 0x92, 0x90,
0x8c, 0x91, 0x5d, 0x87, 0xc5, 0x81, 0xd1, 0x0b, 0x09, 0x97, 0xa2, 0x86, 0x85, 0xd1, 0x3e, 0x7c,
0x73, 0xd5, 0x50, 0xde, 0x5e, 0x35, 0x94, 0xbf, 0xae, 0x1a, 0xca, 0xe5, 0x75, 0x63, 0xee, 0xed,
0x75, 0x63, 0xee, 0xf7, 0xeb, 0xc6, 0xdc, 0x57, 0x3b, 0x5d, 0xca, 0xb4, 0x81, 0x6d, 0x6a, 0xcc,
0xd3, 0x63, 0xd5, 0xf6, 0xa8, 0xa7, 0xf7, 0x0c, 0xcb, 0x73, 0xa9, 0xb5, 0x6f, 0xeb, 0xaf, 0xd2,
0xbf, 0x38, 0xb3, 0xca, 0xfb, 0xea, 0xe0, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd2, 0xef, 0x57,
0x0f, 0xe9, 0x0d, 0x00, 0x00,
}
func (m *Params) Marshal() (dAtA []byte, err error) {
@ -1415,121 +1266,6 @@ func (m *Signature) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *BlockChangeSet) 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 *BlockChangeSet) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *BlockChangeSet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Names) > 0 {
for iNdEx := len(m.Names) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Names[iNdEx])
copy(dAtA[i:], m.Names[iNdEx])
i = encodeVarintRegistry(dAtA, i, uint64(len(m.Names[iNdEx])))
i--
dAtA[i] = 0x32
}
}
if len(m.Authorities) > 0 {
for iNdEx := len(m.Authorities) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Authorities[iNdEx])
copy(dAtA[i:], m.Authorities[iNdEx])
i = encodeVarintRegistry(dAtA, i, uint64(len(m.Authorities[iNdEx])))
i--
dAtA[i] = 0x2a
}
}
if len(m.AuctionBids) > 0 {
for iNdEx := len(m.AuctionBids) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.AuctionBids[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintRegistry(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
}
if len(m.Auctions) > 0 {
for iNdEx := len(m.Auctions) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Auctions[iNdEx])
copy(dAtA[i:], m.Auctions[iNdEx])
i = encodeVarintRegistry(dAtA, i, uint64(len(m.Auctions[iNdEx])))
i--
dAtA[i] = 0x1a
}
}
if len(m.Records) > 0 {
for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Records[iNdEx])
copy(dAtA[i:], m.Records[iNdEx])
i = encodeVarintRegistry(dAtA, i, uint64(len(m.Records[iNdEx])))
i--
dAtA[i] = 0x12
}
}
if m.Height != 0 {
i = encodeVarintRegistry(dAtA, i, uint64(m.Height))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *AuctionBidInfo) 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 *AuctionBidInfo) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *AuctionBidInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.BidderAddress) > 0 {
i -= len(m.BidderAddress)
copy(dAtA[i:], m.BidderAddress)
i = encodeVarintRegistry(dAtA, i, uint64(len(m.BidderAddress)))
i--
dAtA[i] = 0x12
}
if len(m.AuctionId) > 0 {
i -= len(m.AuctionId)
copy(dAtA[i:], m.AuctionId)
i = encodeVarintRegistry(dAtA, i, uint64(len(m.AuctionId)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *ExpiryQueue) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -1780,65 +1516,6 @@ func (m *Signature) Size() (n int) {
return n
}
func (m *BlockChangeSet) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Height != 0 {
n += 1 + sovRegistry(uint64(m.Height))
}
if len(m.Records) > 0 {
for _, s := range m.Records {
l = len(s)
n += 1 + l + sovRegistry(uint64(l))
}
}
if len(m.Auctions) > 0 {
for _, s := range m.Auctions {
l = len(s)
n += 1 + l + sovRegistry(uint64(l))
}
}
if len(m.AuctionBids) > 0 {
for _, e := range m.AuctionBids {
l = e.Size()
n += 1 + l + sovRegistry(uint64(l))
}
}
if len(m.Authorities) > 0 {
for _, s := range m.Authorities {
l = len(s)
n += 1 + l + sovRegistry(uint64(l))
}
}
if len(m.Names) > 0 {
for _, s := range m.Names {
l = len(s)
n += 1 + l + sovRegistry(uint64(l))
}
}
return n
}
func (m *AuctionBidInfo) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.AuctionId)
if l > 0 {
n += 1 + l + sovRegistry(uint64(l))
}
l = len(m.BidderAddress)
if l > 0 {
n += 1 + l + sovRegistry(uint64(l))
}
return n
}
func (m *ExpiryQueue) Size() (n int) {
if m == nil {
return 0
@ -3425,351 +3102,6 @@ func (m *Signature) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *BlockChangeSet) 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 ErrIntOverflowRegistry
}
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: BlockChangeSet: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: BlockChangeSet: 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 ErrIntOverflowRegistry
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Height |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Records = append(m.Records, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Auctions", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Auctions = append(m.Auctions, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AuctionBids", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthRegistry
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AuctionBids = append(m.AuctionBids, &AuctionBidInfo{})
if err := m.AuctionBids[len(m.AuctionBids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Authorities", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Authorities = append(m.Authorities, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Names", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Names = append(m.Names, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipRegistry(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthRegistry
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *AuctionBidInfo) 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 ErrIntOverflowRegistry
}
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: AuctionBidInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: AuctionBidInfo: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AuctionId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BidderAddress", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRegistry
}
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 ErrInvalidLengthRegistry
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthRegistry
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.BidderAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipRegistry(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthRegistry
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ExpiryQueue) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0