Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bid attributes #162

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _run/common-kube.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ kube-prepare-image-akash: RELEASE_DOCKER_IMAGE=ghcr.io/akash-network/node
kube-prepare-image-akash:
ifneq ($(SKIP_BUILD), true)
ifeq ($(AKASH_BUILD_LOCAL_IMAGE), true)
$(AP_ROOT)/script/tools.sh build-akash $(AKASHD_LOCAL_PATH)
$(AP_ROOT)/script/tools.sh build-akash-docker $(AKASHD_LOCAL_PATH)
else
docker pull $(AKASH_DOCKER_IMAGE)
endif
Expand Down
7 changes: 4 additions & 3 deletions balance_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
tmrpc "github.com/tendermint/tendermint/rpc/core/types"

dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
"github.com/akash-network/node/client"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

aclient "github.com/akash-network/node/client"

"github.com/akash-network/node/pubsub"
netutil "github.com/akash-network/node/util/network"
"github.com/akash-network/node/util/runner"
Expand Down Expand Up @@ -68,7 +69,7 @@ type leaseCheckResponse struct {

func newBalanceChecker(ctx context.Context,
bqc btypes.QueryClient,
aqc client.QueryClient,
aqc aclient.QueryClient,
accAddr sdk.AccAddress,
clientSession session.Session,
bus pubsub.Bus,
Expand Down
9 changes: 5 additions & 4 deletions bidengine/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/pubsub"
metricsutils "github.com/akash-network/node/util/metrics"
"github.com/akash-network/node/util/runner"
Expand Down Expand Up @@ -337,8 +337,7 @@ loop:
o.log.Info("requesting reservation")
// Begin reserving resources from cluster.
clusterch = runner.Do(metricsutils.ObserveRunner(func() runner.Result {
v := runner.NewResult(o.cluster.Reserve(o.orderID, group))
return v
return runner.NewResult(o.cluster.Reserve(o.orderID, group))
}, reservationDuration))

case result := <-clusterch:
Expand Down Expand Up @@ -400,8 +399,10 @@ loop:

o.log.Debug("submitting fulfillment", "price", price)

offer := mtypes.ResourceOfferFromRU(reservation.GetAllocatedResources())

// Begin submitting fulfillment
msg = mtypes.NewMsgCreateBid(o.orderID, o.session.Provider().Address(), price, o.cfg.Deposit)
msg = mtypes.NewMsgCreateBid(o.orderID, o.session.Provider().Address(), price, o.cfg.Deposit, offer)
bidch = runner.Do(func() runner.Result {
return runner.NewResult(nil, o.session.Client().Tx().Broadcast(ctx, msg))
})
Expand Down
31 changes: 19 additions & 12 deletions bidengine/order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

audittypes "github.com/akash-network/akash-api/go/node/audit/v1beta3"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
atypes "github.com/akash-network/akash-api/go/node/types/v1beta3"
broadcastmocks "github.com/akash-network/node/client/broadcaster/mocks"
Expand All @@ -42,8 +42,8 @@ type orderTestScaffold struct {
queryClient *clientmocks.QueryClient
client *clientmocks.Client
txClient *broadcastmocks.Client
cluster *clustermocks.Cluster

cluster *clustermocks.Cluster
broadcasts chan sdk.Msg
reserveCallNotify chan int
}
Expand Down Expand Up @@ -98,23 +98,24 @@ func makeMocks(s *orderTestScaffold) {
queryClientMock.On("Orders", mock.Anything, mock.Anything).Return(&mtypes.QueryOrdersResponse{}, nil)
queryClientMock.On("Provider", mock.Anything, mock.Anything).Return(&ptypes.QueryProviderResponse{}, nil)

txClientMock := &broadcastmocks.Client{}
txMocks := &broadcastmocks.Client{}
s.broadcasts = make(chan sdk.Msg, 1)
txClientMock.On("Broadcast", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
txMocks.On("Broadcast", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
s.broadcasts <- args.Get(1).(sdk.Msg)
}).Return(nil)

clientMock := &clientmocks.Client{}
clientMock.On("Query").Return(queryClientMock)
clientMock.On("Tx").Return(txClientMock)
clientMocks := &clientmocks.Client{}
clientMocks.On("Query").Return(queryClientMock)
clientMocks.On("Tx").Return(txMocks)

s.client = clientMock
s.client = clientMocks
s.queryClient = queryClientMock
s.txClient = txClientMock
s.txClient = txMocks

mockReservation := &clustermocks.Reservation{}
mockReservation.On("OrderID").Return(s.orderID)
mockReservation.On("Resources").Return(groupResult.Group)
mockReservation.On("GetAllocatedResources").Return(groupResult.Group.GroupSpec.Resources)

s.cluster = &clustermocks.Cluster{}
s.reserveCallNotify = make(chan int, 1)
Expand All @@ -128,7 +129,7 @@ func makeMocks(s *orderTestScaffold) {

type nullProviderAttrSignatureService struct{}

func (nullProviderAttrSignatureService) GetAuditorAttributeSignatures(auditor string) ([]audittypes.Provider, error) {
func (nullProviderAttrSignatureService) GetAuditorAttributeSignatures(_ string) ([]audittypes.Provider, error) {
return nil, nil // Return no attributes & no error
}

Expand All @@ -138,7 +139,14 @@ func (nullProviderAttrSignatureService) GetAttributes() (atypes.Attributes, erro

const testBidCreatedAt = 1234556789

func makeOrderForTest(t *testing.T, checkForExistingBid bool, bidState mtypes.Bid_State, pricing BidPricingStrategy, callerConfig *Config, sessionHeight int64) (*order, orderTestScaffold, <-chan int) {
func makeOrderForTest(
t *testing.T,
checkForExistingBid bool,
bidState mtypes.Bid_State,
pricing BidPricingStrategy,
callerConfig *Config,
sessionHeight int64,
) (*order, orderTestScaffold, <-chan int) {
if pricing == nil {
pricing = testBidPricingStrategy(1)
require.NotNil(t, pricing)
Expand Down Expand Up @@ -399,7 +407,6 @@ func Test_BidOrderAndThenLeaseCreated(t *testing.T) {
}

func Test_BidOrderAndThenLeaseCreatedForDifferentDeployment(t *testing.T) {

order, scaffold, _ := makeOrderForTest(t, false, mtypes.BidStateInvalid, nil, nil, testBidCreatedAt)

// Wait for first broadcast
Expand Down
15 changes: 10 additions & 5 deletions bidengine/provider_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3"

ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3"

clientmocks "github.com/akash-network/node/client/mocks"
"github.com/akash-network/node/pubsub"
"github.com/akash-network/node/testutil"

"github.com/akash-network/provider/session"

atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3"
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3"
)

type providerAttributesTestScaffold struct {
Expand All @@ -31,7 +32,11 @@ type providerAttributesTestScaffold struct {
providerAddr sdk.AccAddress
}

func setupProviderAttributesTestScaffold(t *testing.T, ttl time.Duration, clientFactory func(scaffold *providerAttributesTestScaffold) *clientmocks.QueryClient) *providerAttributesTestScaffold {
func setupProviderAttributesTestScaffold(
t *testing.T,
ttl time.Duration,
clientFactory func(scaffold *providerAttributesTestScaffold,
) *clientmocks.QueryClient) *providerAttributesTestScaffold {
retval := &providerAttributesTestScaffold{
auditorAddr: testutil.AccAddress(t),
providerAddr: testutil.AccAddress(t),
Expand Down
2 changes: 1 addition & 1 deletion bidengine/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

sdkquery "github.com/cosmos/cosmos-sdk/types/query"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/pubsub"
mquery "github.com/akash-network/node/x/market/query"

Expand Down
2 changes: 1 addition & 1 deletion client/broadcaster/serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
ttypes "github.com/tendermint/tendermint/types"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
abroadcaster "github.com/akash-network/node/client/broadcaster"
)

Expand Down
2 changes: 1 addition & 1 deletion cluster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

mani "github.com/akash-network/akash-api/go/manifest/v2beta2"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/akash-api/go/node/types/unit"
types "github.com/akash-network/akash-api/go/node/types/v1beta3"
"github.com/akash-network/node/sdl"
Expand Down
2 changes: 1 addition & 1 deletion cluster/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/pkg/errors"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

clustertypes "github.com/akash-network/provider/cluster/types/v1beta3"
)
Expand Down
2 changes: 1 addition & 1 deletion cluster/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/tendermint/tendermint/libs/log"

dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
atypes "github.com/akash-network/akash-api/go/node/types/v1beta3"

"github.com/akash-network/node/pubsub"
Expand Down
2 changes: 1 addition & 1 deletion cluster/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

manifest "github.com/akash-network/akash-api/go/manifest/v2beta2"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/akash-api/go/node/types/unit"
types "github.com/akash-network/akash-api/go/node/types/v1beta3"
"github.com/akash-network/node/pubsub"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/tendermint/tendermint/libs/log"

mani "github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

ctypes "github.com/akash-network/provider/cluster/types/v1beta3"
clusterUtil "github.com/akash-network/provider/cluster/util"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"k8s.io/apimachinery/pkg/selection"
"k8s.io/client-go/kubernetes"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster/kube/builder"
)
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

mapi "github.com/akash-network/akash-api/go/manifest/v2beta2"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/sdl"
metricsutils "github.com/akash-network/node/util/metrics"

Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/client-go/tools/remotecommand"
executil "k8s.io/client-go/util/exec"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster"
"github.com/akash-network/provider/cluster/kube/builder"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
kubefake "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/rest"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/sdl"
"github.com/akash-network/node/testutil"

Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client_hostname_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

sdktypes "github.com/cosmos/cosmos-sdk/types"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster/kube/builder"
ctypes "github.com/akash-network/provider/cluster/types/v1beta3"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/pager"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
metricsutils "github.com/akash-network/node/util/metrics"

"github.com/akash-network/provider/cluster/kube/builder"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"k8s.io/client-go/rest"

manifest "github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
types "github.com/akash-network/akash-api/go/node/types/v1beta3"
"github.com/akash-network/node/testutil"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strconv"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster/kube/builder"
)
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/cluster_ip_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
sdktypes "github.com/cosmos/cosmos-sdk/types"

manifest "github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster/kube/builder"
kubeclienterrors "github.com/akash-network/provider/cluster/kube/errors"
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"

mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/sdl"
"github.com/akash-network/node/testutil"

Expand Down
6 changes: 5 additions & 1 deletion cluster/kube/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/akash-api/go/node/types/unit"
atypes "github.com/akash-network/akash-api/go/node/types/v1beta3"
"github.com/akash-network/node/testutil"
Expand Down Expand Up @@ -47,6 +47,10 @@ func (r *testReservation) SetAllocatedResources(val dtypes.ResourceUnits) {
r.adjustedResources = val
}

func (r *testReservation) GetAllocatedResources() dtypes.ResourceUnits {
return r.adjustedResources
}

func (r *testReservation) Allocated() bool {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/kube/metallb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/client-go/util/flowcontrol"

manifest "github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/provider/cluster/kube/builder"
"github.com/akash-network/provider/cluster/kube/clientcommon"
Expand Down
2 changes: 1 addition & 1 deletion cluster/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"

mani "github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
"github.com/akash-network/node/pubsub"

kubeclienterrors "github.com/akash-network/provider/cluster/kube/errors"
Expand Down
2 changes: 1 addition & 1 deletion cluster/manager_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/akash-network/akash-api/go/manifest/v2beta2"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
logger "github.com/tendermint/tendermint/libs/log"
)

Expand Down
Loading