keeper

package
v0.1.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HealthAttestationPrefix is the prefix for health attestation storage
	HealthAttestationPrefix = "health/"

	// Health status constants
	HealthStatusUnknown  int32 = 0
	HealthStatusHealthy  int32 = 1
	HealthStatusDegraded int32 = 2
	HealthStatusFailed   int32 = 3
)
View Source
const (
	// LowEscrowThreshold defines the minimum blocks remaining before escrow is considered low
	LowEscrowThreshold int64 = 100 // ~8 minutes at 5 second blocks
)
View Source
const (
	// ManifestRefPrefix is the prefix for manifest reference storage
	ManifestRefPrefix = "manifest_ref/"
)

Variables

This section is empty.

Functions

func HealthStatusToString

func HealthStatusToString(status int32) string

HealthStatusToString converts health status to string

func ParseHealthStatus

func ParseHealthStatus(s string) int32

ParseHealthStatus converts a string to health status

Types

type EscrowInfo

type EscrowInfo struct {
	Owner           string
	DSeq            uint64
	Balance         string
	Transferred     string
	Settled         string
	State           string
	IsLow           bool
	BlocksRemaining int64
}

EscrowInfo contains deployment escrow information

type EscrowKeeper

type EscrowKeeper interface {
	GetAccount(ctx sdk.Context, id escrowid.Account) (etypes.Account, error)
	GetPayment(ctx sdk.Context, id escrowid.Payment) (etypes.Payment, error)
	AccountClose(ctx sdk.Context, id escrowid.Account) error
	PaymentClose(ctx sdk.Context, id escrowid.Payment) error
}

type HealthAttestationData

type HealthAttestationData struct {
	LeaseID     mv1.LeaseID
	Provider    string
	Status      int32
	BlockHeight int64
	Timestamp   int64
	Message     string
}

HealthAttestationData is the stored health attestation data

type HealthAttestationMsg

type HealthAttestationMsg struct {
	LeaseID   mv1.LeaseID
	Provider  string
	Status    int32 // 0=unknown, 1=healthy, 2=degraded, 3=failed
	Timestamp int64
	Message   string
}

HealthAttestationMsg is the input for submitting health attestations

type HealthAttestationWithFreshness

type HealthAttestationWithFreshness struct {
	Attestation    HealthAttestationData
	Found          bool
	IsFresh        bool
	AttestationAge int64
	CurrentBlock   int64
	IsHealthy      bool
}

HealthAttestationWithFreshness contains attestation data plus computed freshness

type IKeeper

type IKeeper interface {
	NewQuerier() Querier
	Codec() codec.BinaryCodec
	StoreKey() storetypes.StoreKey
	CreateOrder(ctx sdk.Context, gid dtypes.GroupID, spec dtypesBeta.GroupSpec) (types.Order, error)
	CreateBid(ctx sdk.Context, id mv1.BidID, price sdk.DecCoin, roffer types.ResourcesOffer) (types.Bid, error)
	CreateLease(ctx sdk.Context, bid types.Bid) error
	OnOrderMatched(ctx sdk.Context, order types.Order)
	OnBidMatched(ctx sdk.Context, bid types.Bid)
	OnBidLost(ctx sdk.Context, bid types.Bid)
	OnBidClosed(ctx sdk.Context, bid types.Bid) error
	OnOrderClosed(ctx sdk.Context, order types.Order) error
	OnLeaseClosed(ctx sdk.Context, lease mv1.Lease, state mv1.Lease_State, reason mv1.LeaseClosedReason) error
	OnGroupClosed(ctx sdk.Context, id dtypes.GroupID) error
	GetOrder(ctx sdk.Context, id mv1.OrderID) (types.Order, bool)
	GetBid(ctx sdk.Context, id mv1.BidID) (types.Bid, bool)
	GetLease(ctx sdk.Context, id mv1.LeaseID) (mv1.Lease, bool)
	LeaseForOrder(ctx sdk.Context, bs types.Bid_State, oid mv1.OrderID) (mv1.Lease, bool)
	WithOrders(ctx sdk.Context, fn func(types.Order) bool)
	WithBids(ctx sdk.Context, fn func(types.Bid) bool)
	WithBidsForOrder(ctx sdk.Context, id mv1.OrderID, state types.Bid_State, fn func(types.Bid) bool)
	WithLeases(ctx sdk.Context, fn func(mv1.Lease) bool)
	WithOrdersForGroup(ctx sdk.Context, id dtypes.GroupID, state types.Order_State, fn func(types.Order) bool)
	BidCountForOrder(ctx sdk.Context, id mv1.OrderID) uint32
	GetParams(ctx sdk.Context) (params types.Params)
	SetParams(ctx sdk.Context, params types.Params) error
	GetAuthority() string
	// Health attestation methods
	SubmitHealthAttestation(ctx sdk.Context, msg *HealthAttestationMsg) error
	GetHealthAttestation(ctx sdk.Context, leaseID mv1.LeaseID) (HealthAttestationData, bool)
	IsLeaseHealthy(ctx sdk.Context, leaseID mv1.LeaseID, healthThreshold int64) bool
	// Manifest reference methods
	SetManifestRef(ctx sdk.Context, owner string, dseq uint64, hash []byte, sdl string) error
	GetManifestRef(ctx sdk.Context, owner string, dseq uint64) (ManifestRef, bool)
	HasManifestRef(ctx sdk.Context, owner string, dseq uint64) bool
	// Escrow methods
	GetDeploymentEscrow(ctx sdk.Context, owner string, dseq uint64) (EscrowInfo, bool)
}

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, skey storetypes.StoreKey, ekeeper EscrowKeeper, authority string) IKeeper

NewKeeper creates and returns an instance for Market keeper

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the market store

func (Keeper) BidCountForOrder

func (k Keeper) BidCountForOrder(ctx sdk.Context, id mv1.OrderID) uint32

func (Keeper) Codec

func (k Keeper) Codec() codec.BinaryCodec

Codec returns keeper codec

func (Keeper) CreateBid

func (k Keeper) CreateBid(ctx sdk.Context, id mv1.BidID, price sdk.DecCoin, roffer types.ResourcesOffer) (types.Bid, error)

CreateBid creates a bid for a order with given orderID, price for bid and provider

func (Keeper) CreateLease

func (k Keeper) CreateLease(ctx sdk.Context, bid types.Bid) error

CreateLease creates lease for bid with given bidID. Should only be called by the EndBlock handler or unit tests.

func (Keeper) CreateOrder

func (k Keeper) CreateOrder(ctx sdk.Context, gid dtypes.GroupID, spec dtypesBeta.GroupSpec) (types.Order, error)

CreateOrder creates a new order with given group id and specifications. It returns created order

func (Keeper) DeleteManifestRef

func (k Keeper) DeleteManifestRef(ctx sdk.Context, owner string, dseq uint64)

DeleteManifestRef removes the manifest reference for a deployment

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/mint module's authority.

func (Keeper) GetBid

func (k Keeper) GetBid(ctx sdk.Context, id mv1.BidID) (types.Bid, bool)

GetBid returns bid with given bidID from market store

func (Keeper) GetDeploymentEscrow

func (k Keeper) GetDeploymentEscrow(ctx sdk.Context, owner string, dseq uint64) (EscrowInfo, bool)

GetDeploymentEscrow returns escrow information for a deployment It looks up the active lease for the deployment and queries the escrow account

func (Keeper) GetDeploymentEscrowForLease

func (k Keeper) GetDeploymentEscrowForLease(ctx sdk.Context, leaseID mv1.LeaseID) (EscrowInfo, bool)

GetDeploymentEscrowForLease returns escrow info for a specific lease

func (Keeper) GetHealthAttestation

func (k Keeper) GetHealthAttestation(ctx sdk.Context, leaseID mv1.LeaseID) (HealthAttestationData, bool)

GetHealthAttestation retrieves the latest health attestation for a lease

func (Keeper) GetHealthAttestationWithFreshness

func (k Keeper) GetHealthAttestationWithFreshness(ctx sdk.Context, leaseID mv1.LeaseID, healthThreshold int64) HealthAttestationWithFreshness

GetHealthAttestationWithFreshness returns attestation with computed freshness metadata

func (Keeper) GetHealthAttestationsForOwner

func (k Keeper) GetHealthAttestationsForOwner(ctx sdk.Context, owner string) []HealthAttestationData

GetHealthAttestationsForOwner retrieves all health attestations for a deployment owner

func (Keeper) GetLease

func (k Keeper) GetLease(ctx sdk.Context, id mv1.LeaseID) (mv1.Lease, bool)

GetLease returns lease with given leaseID from market store

func (Keeper) GetManifestRef

func (k Keeper) GetManifestRef(ctx sdk.Context, owner string, dseq uint64) (ManifestRef, bool)

GetManifestRef retrieves the manifest reference for a deployment

func (Keeper) GetOrder

func (k Keeper) GetOrder(ctx sdk.Context, id mv1.OrderID) (types.Order, bool)

GetOrder returns order with given orderID from market store

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (p types.Params)

GetParams returns the current x/market module parameters.

func (Keeper) GetUnhealthyLeases

func (k Keeper) GetUnhealthyLeases(ctx sdk.Context, owner string, healthThreshold int64) []mv1.LeaseID

GetUnhealthyLeases returns all leases that have exceeded the health threshold

func (Keeper) HasManifestRef

func (k Keeper) HasManifestRef(ctx sdk.Context, owner string, dseq uint64) bool

HasManifestRef checks if a manifest reference exists

func (Keeper) IsLeaseHealthy

func (k Keeper) IsLeaseHealthy(ctx sdk.Context, leaseID mv1.LeaseID, healthThreshold int64) bool

IsLeaseHealthy checks if a lease is healthy based on its latest attestation

func (Keeper) LeaseForOrder

func (k Keeper) LeaseForOrder(ctx sdk.Context, bs types.Bid_State, oid mv1.OrderID) (mv1.Lease, bool)

LeaseForOrder returns lease for order with given ID and lease found status

func (Keeper) NewQuerier

func (k Keeper) NewQuerier() Querier

func (Keeper) OnBidClosed

func (k Keeper) OnBidClosed(ctx sdk.Context, bid types.Bid) error

OnBidClosed updates bid state to closed

func (Keeper) OnBidLost

func (k Keeper) OnBidLost(ctx sdk.Context, bid types.Bid)

OnBidLost updates bid state to bid lost

func (Keeper) OnBidMatched

func (k Keeper) OnBidMatched(ctx sdk.Context, bid types.Bid)

OnBidMatched updates bid state to matched

func (Keeper) OnGroupClosed

func (k Keeper) OnGroupClosed(ctx sdk.Context, id dtypes.GroupID) error

OnGroupClosed updates state of all orders, bids and leases in group to closed

func (Keeper) OnLeaseClosed

func (k Keeper) OnLeaseClosed(ctx sdk.Context, lease mv1.Lease, state mv1.Lease_State, reason mv1.LeaseClosedReason) error

OnLeaseClosed updates lease state to closed

func (Keeper) OnOrderClosed

func (k Keeper) OnOrderClosed(ctx sdk.Context, order types.Order) error

OnOrderClosed updates order state to closed

func (Keeper) OnOrderMatched

func (k Keeper) OnOrderMatched(ctx sdk.Context, order types.Order)

OnOrderMatched updates order state to matched

func (Keeper) SetManifestRef

func (k Keeper) SetManifestRef(ctx sdk.Context, owner string, dseq uint64, hash []byte, sdl string) error

SetManifestRef stores a manifest reference for a deployment

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error

SetParams sets the x/market module parameters.

func (Keeper) StoreKey

func (k Keeper) StoreKey() storetypes.StoreKey

StoreKey returns store key

func (Keeper) SubmitHealthAttestation

func (k Keeper) SubmitHealthAttestation(ctx sdk.Context, msg *HealthAttestationMsg) error

SubmitHealthAttestation stores a health attestation for a lease

func (Keeper) WithBids

func (k Keeper) WithBids(ctx sdk.Context, fn func(types.Bid) bool)

WithBids iterates all bids in market

func (Keeper) WithBidsForOrder

func (k Keeper) WithBidsForOrder(ctx sdk.Context, id mv1.OrderID, state types.Bid_State, fn func(types.Bid) bool)

WithBidsForOrder iterates all bids of an order in market with given OrderID

func (Keeper) WithLeases

func (k Keeper) WithLeases(ctx sdk.Context, fn func(mv1.Lease) bool)

WithLeases iterates all leases in market

func (Keeper) WithOrders

func (k Keeper) WithOrders(ctx sdk.Context, fn func(types.Order) bool)

WithOrders iterates all orders in market

func (Keeper) WithOrdersForGroup

func (k Keeper) WithOrdersForGroup(ctx sdk.Context, id dtypes.GroupID, state types.Order_State, fn func(types.Order) bool)

WithOrdersForGroup iterates all orders of a group in market with given GroupID

type ManifestRef

type ManifestRef struct {
	Owner     string `json:"owner"`
	DSeq      uint64 `json:"dseq"`
	Hash      []byte `json:"hash"`       // SHA256 hash of manifest bytes
	HashHex   string `json:"hash_hex"`   // Hex-encoded hash for easy lookup
	Version   uint32 `json:"version"`    // Schema version
	SDL       string `json:"sdl"`        // Original SDL (optional, for debugging)
	CreatedAt int64  `json:"created_at"` // Block height when created
	UpdatedAt int64  `json:"updated_at"` // Block height when last updated
}

ManifestRef contains metadata about a manifest stored off-chain

type Querier

type Querier struct {
	Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func (Querier) Bid

Bid returns bid details based on BidID

func (Querier) Bids

Bids returns bids based on filters

func (Querier) Lease

Lease returns lease details based on LeaseID

func (Querier) Leases

Leases returns leases based on filters

func (Querier) Order

Order returns order details based on OrderID

func (Querier) Orders

Orders returns orders based on filters

func (Querier) Params

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL