Skip to content

Commit

Permalink
chore: sync charts, remove registry job
Browse files Browse the repository at this point in the history
register the provider directly with the cli command
add new manifest examples.(note it might take a while before upscaling,
might add more vcpus to the vm)

aand minor refactor and bug fixes around the registry and deployment of
contracts in the qemu test
  • Loading branch information
revoltez committed Mar 18, 2024
1 parent 454c2cc commit 9a1fffa
Show file tree
Hide file tree
Showing 24 changed files with 442 additions and 228 deletions.
2 changes: 1 addition & 1 deletion cmd/tpodserver/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var registerCmd = &cobra.Command{

tx, err := registry.RegisterProvider(providerAuth, cid.String())
if err != nil {
return err
return fmt.Errorf("Could not register Provider: %v", err)
}

prices, err := resource.GetTablesPrices(pricingTables)
Expand Down
11 changes: 11 additions & 0 deletions cmd/trustedpods/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func fetchAndFilterProviders(ipfs *rpc.HttpApi, ethClient *ethclient.Client) (pu
return nil, err
}

if len(tables) == 0 {
return nil, fmt.Errorf("Marketplace is empty! are you sure you are connected to the right contract?")
}

filter, err := getRegistryTableFilter()
if err != nil {
return nil, err
Expand All @@ -55,6 +59,11 @@ func fetchAndFilterProviders(ipfs *rpc.HttpApi, ethClient *ethclient.Client) (pu
return nil, fmt.Errorf("no table found by filter")
}

err = PrintTableInfo(filteredTables, ethClient, registryContract)
if err != nil {
return nil, err
}

availableProviders, err := publisher.GetProviderHostInfos(ipfs, ethClient, registryContract, filteredTables)
if err != nil {
return nil, err
Expand All @@ -65,6 +74,8 @@ func fetchAndFilterProviders(ipfs *rpc.HttpApi, ethClient *ethclient.Client) (pu
return nil, err
}

PrintProvidersInfo(availableProviders)

return availableProviders, nil
}

Expand Down
72 changes: 42 additions & 30 deletions cmd/trustedpods/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/comrade-coop/apocryph/pkg/publisher"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -66,31 +67,12 @@ var getTablesCmd = &cobra.Command{
}

filteredTables := publisher.FilterPricingTables(tables, filter)
table := tablewriter.NewWriter(os.Stdout)

table.SetHeader([]string{"Id", "CPU", "RAM", "STORAGE", "BANDWIDTH EGRESS", "BANDWIDTH INGRESS", "CPU MODEL", "TEE TECHNOLOGY", "Providers"})
for _, t := range filteredTables {
subscribers, err := publisher.GetPricingTableSubscribers(ethClient, registryContract, t.Id)
if err != nil {
return err
}
// if table has no subscribers skip printing it
if len(subscribers) == 0 {
continue
}
var subs string = ""
for _, subscriber := range subscribers {
subs = subs + subscriber.String() + "\n"
}
row := []string{t.Id.String(), t.CpuPrice.String(), t.RamPrice.String(),
t.StoragePrice.String(), t.BandwidthEgressPrice.String(),
t.BandwidthIngressPrice.String(), t.Cpumodel, t.TeeType, subs}
table.Append(row)
}
if len(filteredTables) == 0 {
return fmt.Errorf("no table found by given filter")
}
table.Render()

PrintTableInfo(filteredTables, ethClient, registryContract)

allProviders, err := publisher.GetProviderHostInfos(ipfs, ethClient, registryContract, filteredTables)
if err != nil {
Expand All @@ -104,20 +86,50 @@ var getTablesCmd = &cobra.Command{
return fmt.Errorf("could not find providers with the given filter")
}

infoTable := tablewriter.NewWriter(os.Stdout)
infoTable.SetHeader([]string{"Id", "Regions", "Addresses"})
for id, info := range filteredInfos {
row := []string{id.Hex(), formatRegions(info.Regions), strings.Join(info.Multiaddrs, "\n")}
infoTable.Append(row)
}
infoTable.SetRowLine(true)
fmt.Printf("\nProviders:\n")
infoTable.Render()
PrintProvidersInfo(filteredInfos)

return nil
},
}

func PrintProvidersInfo(filteredInfos publisher.ProviderHostInfoList) {
infoTable := tablewriter.NewWriter(os.Stdout)
infoTable.SetHeader([]string{"Id", "Regions", "Addresses"})
for id, info := range filteredInfos {
row := []string{id.Hex(), formatRegions(info.Regions), strings.Join(info.Multiaddrs, "\n")}
infoTable.Append(row)
}
infoTable.SetRowLine(true)
fmt.Printf("Providers:\n")
infoTable.Render()
}

func PrintTableInfo(filteredTables publisher.PricingTableList, ethClient *ethclient.Client, registryContract common.Address) error {
table := tablewriter.NewWriter(os.Stdout)

table.SetHeader([]string{"Id", "CPU", "RAM", "STORAGE", "BANDWIDTH EGRESS", "BANDWIDTH INGRESS", "CPU MODEL", "TEE TECHNOLOGY", "Providers"})
for _, t := range filteredTables {
subscribers, err := publisher.GetPricingTableSubscribers(ethClient, registryContract, t.Id)
if err != nil {
return err
}
// if table has no subscribers skip printing it
if len(subscribers) == 0 {
continue
}
var subs string = ""
for _, subscriber := range subscribers {
subs = subs + subscriber.String() + "\n"
}
row := []string{t.Id.String(), t.CpuPrice.String(), t.RamPrice.String(),
t.StoragePrice.String(), t.BandwidthEgressPrice.String(),
t.BandwidthIngressPrice.String(), t.Cpumodel, t.TeeType, subs}
table.Append(row)
}
table.Render()
return nil
}

func formatRegions(regions []*pb.HostInfo_Region) string {
result := ""
for _, region := range regions {
Expand Down
149 changes: 121 additions & 28 deletions pkg/abi/IERC20.abi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a1fffa

Please sign in to comment.