provider

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// SchedulerMetadataOfferAllowedCreatorsKey is the metadata key holding a comma-separated list
	// of accounts allowed to rent machines from the offer. When absent or empty, anyone can rent
	// a machine.
	SchedulerMetadataOfferAllowedCreatorsKey = SchedulerMetadataOfferKey + ".allowed_creators"

	// SchedulerMetadataOfferAllowedArtifactsPrefix is the prefix of the metadata keys holding a
	// comma-separated list of allowed SHA256 artifact hashes. The artifact kind is the suffix
	// following the prefix (e.g. `net.oasis.scheduler.offer.allowed_artifacts.firmware`). When a
	// key for a kind is absent, any artifact of that kind is allowed.
	SchedulerMetadataOfferAllowedArtifactsPrefix = SchedulerMetadataOfferKey + ".allowed_artifacts."

	// SchedulerMetadataOfferPrivateKey is the metadata key hinting that the offer should be hidden
	// from public offer listings.
	SchedulerMetadataOfferPrivateKey = SchedulerMetadataOfferKey + ".private"

	// SchedulerMetadataValueTrue is the metadata value that enables a boolean flag such as
	// SchedulerMetadataOfferPrivateKey.
	SchedulerMetadataValueTrue = "1"
)
View Source
const (
	TermKeyHour  = "hourly"
	TermKeyMonth = "monthly"
	TermKeyYear  = "yearly"
)
View Source
const DescriptionMetadataKey = "net.oasis.description"

DescriptionMetadataKey is the metadata key for longer offer-specific description such as intended applications.

View Source
const NoteMetadataKey = "net.oasis.note"

NoteMetadataKey is the metadata key for offer-specific one-line notification such as a discount or a warning.

View Source
const SchedulerMetadataOfferKey = schedulerMetadataPrefix + "offer"

SchedulerMetadataOfferKey is the metadata key used for the offer name.

Variables

View Source
var ArtifactKinds = []string{"firmware", "kernel", "initrd", "stage2"}

ArtifactKinds are the artifact kinds recognized by the scheduler in AllowedArtifacts.

View Source
var DefaultRoflServices = map[string]RoflServices{
	config.DefaultNetworks.All["testnet"].ParaTimes.All["sapphire"].ID: {
		Scheduler: "rofl1qrqw99h0f7az3hwt2cl7yeew3wtz0fxunu7luyfg",
		Provider:  "oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz",
	},
	config.DefaultNetworks.All["mainnet"].ParaTimes.All["sapphire"].ID: {
		Scheduler: "rofl1qr95suussttd2g9ehu3zcpgx8ewtwgayyuzsl0x2",
		Provider:  "oasis1qzc8pldvm8vm3duvdrj63wgvkw34y9ucfcxzetqr",
	},
}

DefaultRoflServices contains default built-in ROFL services for all supported networks/ParaTimes.

View Source
var ManifestFileNames = []string{
	"rofl-provider.yaml",
	"rofl-provider.yml",
}

ManifestFileNames are the manifest file names that are tried when loading the manifest.

Functions

func IsOfferPrivate added in v0.20.0

func IsOfferPrivate(offer *roflmarket.Offer) bool

IsOfferPrivate returns true iff the given on-chain offer is marked as private and should thus be hidden from public offer listings.

func ManifestExists

func ManifestExists() bool

ManifestExists checks whether a manifest file exist. No attempt is made to load, parse or validate any of the found manifest files.

func OfferAllowedCreators added in v0.20.0

func OfferAllowedCreators(offer *roflmarket.Offer) []string

OfferAllowedCreators returns the accounts allowed to rent machines from the given on-chain offer. When the returned list is empty, anyone can rent a machine.

Types

type AddressResolver added in v0.20.0

type AddressResolver func(nameOrAddress string) (types.Address, error)

AddressResolver resolves an account name or address into the corresponding account address.

type EVMContractPayment added in v0.16.0

type EVMContractPayment struct {
	// Address is hex-encoded address without leading 0x.
	Address string `json:"address"`

	// Data is arbitrary Base-64 encoded payment information.
	Data string `json:"data"`
}

EVMContractPayment is payment configuration for EVM contract-based payments.

type GPUResource

type GPUResource struct {
	// Model is the optional GPU model.
	Model string `yaml:"model,omitempty" json:"model,omitempty"`
	// Count is the number of GPUs requested.
	Count uint8 `yaml:"count" json:"count"`
}

GPUResource is the offered GPU resource.

func (*GPUResource) Validate

func (g *GPUResource) Validate() error

Validate validates the GPU resource.

type Manifest

type Manifest struct {
	// Name is the optional name of the provider.
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	// Homepage is the optional homepage URL of the provider.
	Homepage string `yaml:"homepage,omitempty" json:"homepage,omitempty"`
	// Description is the optional description of the provider.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`

	// Network is the identifier of the network to deploy to.
	Network string `yaml:"network" json:"network"`
	// ParaTime is the identifier of the paratime to deploy to.
	ParaTime string `yaml:"paratime" json:"paratime"`
	// Provider is the identifier of the provider account.
	Provider string `yaml:"provider,omitempty" json:"provider,omitempty"`

	// Nodes are the public keys of nodes authorized to act on behalf of provider.
	Nodes []signature.PublicKey `yaml:"nodes" json:"nodes"`
	// ScheduperApp is the authorized scheduper app for this provider.
	SchedulerApp rofl.AppID `yaml:"scheduler_app" json:"scheduler_app"`
	// PaymentAddress is the payment address.
	PaymentAddress string `yaml:"payment_address" json:"payment_address"`
	// Offers is a list of offers available from this provider.
	Offers []*Offer `yaml:"offers,omitempty" json:"offers,omitempty"`
	// Metadata is arbitrary metadata (key-value pairs) assigned by the provider.
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

Manifest is the manifest describing a provider.

func LoadManifest

func LoadManifest() (*Manifest, error)

LoadManifest attempts to find and load the ROFL app manifest from a local file.

func (*Manifest) GetMetadata

func (m *Manifest) GetMetadata() map[string]string

GetMetadata derives metadata from the attributes defined in the manifest and combines it with the specified metadata.

func (*Manifest) Save

func (m *Manifest) Save() error

Save serializes the manifest and writes it to the file returned by `SourceFileName`, overwriting any previous manifest.

If no previous source filename is available, a default one is set.

func (*Manifest) SourceFileName

func (m *Manifest) SourceFileName() string

SourceFileName returns the filename of the manifest file from which the manifest was loaded or an empty string in case the filename is not available.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate validates the provider manifest.

type NativePayment added in v0.16.0

type NativePayment struct {
	// Denomination is the native token denomination.
	Denomination string `yaml:"denomination,omitempty" json:"denomination,omitempty"`

	// Terms are payment terms in form of Term => amount in decimal.
	Terms map[string]string `yaml:"terms" json:"terms"`
}

NativePayment is payment configuration for native tokens.

type Offer

type Offer struct {
	// ID is the unique offer identifier used by the scheduler.
	ID string `yaml:"id" json:"id"`
	// Note contains one-line notification such as a discount or a warning.
	Note string `yaml:"note" json:"note"`
	// Description contains longer offer-specific description such as intended applications.
	Description string `yaml:"description" json:"description"`
	// Resources are the offered resources.
	Resources Resources `yaml:"resources" json:"resources"`
	// Payment is the payment for this offer.
	Payment Payment `yaml:"payment" json:"payment"`
	// Capacity is the amount of available instances. Setting this to zero will disallow
	// provisioning of new instances for this offer. Each accepted instance will automatically
	// decrement capacity.
	Capacity uint64 `yaml:"capacity" json:"capacity"`
	// AllowedCreators is the list of accounts (names or addresses) allowed to rent machines from
	// this offer. When empty, anyone can rent a machine.
	AllowedCreators []string `yaml:"allowed_creators,omitempty" json:"allowed_creators,omitempty"`
	// AllowedArtifacts is the map of artifact kind to the list of allowed SHA256 hashes of that
	// artifact. When a kind is not present, any artifact of that kind is allowed.
	AllowedArtifacts map[string][]string `yaml:"allowed_artifacts,omitempty" json:"allowed_artifacts,omitempty"`
	// Private hides the offer from public offer listings. Note that this is only a listing hint
	// and does not restrict who may rent the offer, use AllowedCreators for that.
	Private bool `yaml:"private,omitempty" json:"private,omitempty"`
	// Metadata is arbitrary metadata (key-value pairs) assigned by the provider.
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}

Offer is a provider's offer.

func (*Offer) AsDescriptor

func (o *Offer) AsDescriptor(pt *config.ParaTime, resolve AddressResolver) (*roflmarket.Offer, error)

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Offer) GetMetadata

func (o *Offer) GetMetadata(resolve AddressResolver) (map[string]string, error)

GetMetadata derives metadata from the attributes defined in the offer and combines it with the specified metadata.

The given resolver is used to resolve the accounts in AllowedCreators. Any metadata explicitly specified in Metadata takes precedence over the derived one.

func (*Offer) Validate

func (o *Offer) Validate() error

Validate validates the offer.

type Payment

type Payment struct {
	// Native contains native payment terms.
	Native *NativePayment `yaml:"native,omitempty" json:"native,omitempty"`

	// EvmContract contains payment terms defined in a smart contract.
	EvmContract *EVMContractPayment `yaml:"evm,omitempty" json:"evm,omitempty"`
}

Payment is payment configuration for an offer.

func (*Payment) AsDescriptor

func (p *Payment) AsDescriptor(pt *config.ParaTime) (*roflmarket.Payment, error)

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Payment) Validate

func (p *Payment) Validate() error

Validate validates the payment configuration.

type Resources

type Resources struct {
	// TEE is the type of TEE hardware.
	TEE string `yaml:"tee" json:"tee"`
	// Memory is the amount of memory in megabytes.
	Memory uint64 `yaml:"memory" json:"memory"`
	// CPUCount is the amount of vCPUs.
	CPUCount uint16 `yaml:"cpus" json:"cpus"`
	// Storage is the amount of storage ine megabytes.
	Storage uint64 `yaml:"storage" json:"storage"`
	// GPU is the optional GPU resource.
	GPU *GPUResource `yaml:"gpu,omitempty" json:"gpu,omitempty"`
}

Resources are describe the offered resources.

func (*Resources) AsDescriptor

func (r *Resources) AsDescriptor() *roflmarket.Resources

AsDescriptor returns the configuration as an on-chain descriptor.

func (*Resources) Validate

func (r *Resources) Validate() error

Validate validates the resources.

type RoflServices added in v0.13.4

type RoflServices struct {
	// Scheduler is a ROFL app ID of the preferred scheduler app.
	Scheduler string

	// Provider is the address of the preferred provider.
	Provider string
}

RoflServices contains per network/ParaTime default ROFL services.

Jump to

Keyboard shortcuts

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