Skip to content

Commit

Permalink
feat(x/market): implement resource offer in bid
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Nov 1, 2023
1 parent 7fe0bae commit 21fd3c4
Show file tree
Hide file tree
Showing 52 changed files with 499 additions and 206 deletions.
2 changes: 1 addition & 1 deletion app/app_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
deploymenttypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
escrowtypes "github.com/akash-network/akash-api/go/node/escrow/v1beta3"
inflationtypes "github.com/akash-network/akash-api/go/node/inflation/v1beta3"
markettypes "github.com/akash-network/akash-api/go/node/market/v1beta3"
markettypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
providertypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
taketypes "github.com/akash-network/akash-api/go/node/take/v1beta3"

Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
ctypes "github.com/akash-network/akash-api/go/node/cert/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"

Expand Down
136 changes: 68 additions & 68 deletions client/mocks/query_client.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/akash/cmd/testnetify/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3"
dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
etypes "github.com/akash-network/akash-api/go/node/escrow/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/x/audit"
"github.com/akash-network/node/x/cert"
Expand Down
2 changes: 1 addition & 1 deletion events/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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"
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
"github.com/akash-network/akash-api/go/sdkutil"

Expand Down
2 changes: 1 addition & 1 deletion events/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"

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"
"github.com/akash-network/akash-api/go/sdkutil"

Expand Down
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/akash-network/node
go 1.21

require (
github.com/akash-network/akash-api v0.0.27
github.com/akash-network/akash-api v0.0.30
github.com/blang/semver/v4 v4.0.0
github.com/boz/go-lifecycle v0.1.1
github.com/cosmos/cosmos-sdk v0.45.16
Expand Down Expand Up @@ -37,8 +37,8 @@ require (
)

retract (
v0.22.1
v0.26.0
v0.22.1
)

replace (
Expand Down Expand Up @@ -123,7 +123,6 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
Expand Down Expand Up @@ -194,11 +193,11 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.23.4 // indirect
k8s.io/apimachinery v0.23.4 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
k8s.io/api v0.26.1 // indirect
k8s.io/apimachinery v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
nhooyr.io/websocket v1.8.6 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
70 changes: 16 additions & 54 deletions go.sum

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"skipped": false,
"from_binary": "v0.24.2",
"from_version": "v0.24.0"
},
"v0.28.0": {
"skipped": false,
"from_binary": "v0.26.1",
"from_version": "v0.26.0"
}
}
}
8 changes: 8 additions & 0 deletions tests/upgrade/upgrade-v0.28.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"migrations": {
"market": {
"from": "3",
"to": "4"
}
}
}
2 changes: 1 addition & 1 deletion testutil/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"

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"
"github.com/akash-network/akash-api/go/sdkutil"
)
Expand Down
2 changes: 1 addition & 1 deletion testutil/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"

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"
)

func Keyring(t testing.TB) keyring.Keyring {
Expand Down
4 changes: 1 addition & 3 deletions testutil/state/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (

dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
etypes "github.com/akash-network/akash-api/go/node/escrow/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"

"github.com/akash-network/node/app"
Expand Down
9 changes: 8 additions & 1 deletion upgrades/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| escrow | 2 |
| agov | 1 |
| inflation | 1 |
| market | 3 |
| market | 4 |
| provider | 2 |
| astaking | 1 |
| take | 1 |
Expand Down Expand Up @@ -43,6 +43,13 @@ Goal of the upgrade here
Add new upgrades after this line based on the template above
-----

##### v0.28.0

1. Add resource offer for the bid, allowing providers to show details on the resources they offer, when order has wildcard resources, for example GPU.

- Migrations
- market `3 -> 4`

##### v0.26.0

1. Enforce **Minimum Validators commission** using onchain parameter. Default value is set to 5%. This is carry-over from v0.24.0 upgrade, as this change was dry-run
Expand Down
14 changes: 14 additions & 0 deletions upgrades/software/v0.28.0/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Package v0_28_0
// nolint revive
package v0_28_0

import (
mv1beta4 "github.com/akash-network/akash-api/go/node/market/v1beta4"

utypes "github.com/akash-network/node/upgrades/types"
)

func init() {
utypes.RegisterUpgrade(UpgradeName, initUpgrade)
utypes.RegisterMigration(mv1beta4.ModuleName, 3, newMarketMigration)
}
48 changes: 48 additions & 0 deletions upgrades/software/v0.28.0/market.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Package v0_28_0
// nolint revive
package v0_28_0

import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkmodule "github.com/cosmos/cosmos-sdk/types/module"

mv1beta3 "github.com/akash-network/akash-api/go/node/market/v1beta3"
mmigrate "github.com/akash-network/akash-api/go/node/market/v1beta4/migrate"

utypes "github.com/akash-network/node/upgrades/types"
)

type marketMigrations struct {
utypes.Migrator
}

func newMarketMigration(m utypes.Migrator) utypes.Migration {
return marketMigrations{Migrator: m}
}

func (m marketMigrations) GetHandler() sdkmodule.MigrationHandler {
return m.handler
}

// handler migrates deployment from version 2 to 3.
func (m marketMigrations) handler(ctx sdk.Context) error {
store := ctx.KVStore(m.StoreKey())

err := utypes.MigrateValue(store, m.Codec(), mv1beta3.BidPrefix(), migrateBid)

if err != nil {
return err
}

Check warning on line 36 in upgrades/software/v0.28.0/market.go

View check run for this annotation

Codecov / codecov/patch

upgrades/software/v0.28.0/market.go#L29-L36

Added lines #L29 - L36 were not covered by tests

return nil

Check warning on line 38 in upgrades/software/v0.28.0/market.go

View check run for this annotation

Codecov / codecov/patch

upgrades/software/v0.28.0/market.go#L38

Added line #L38 was not covered by tests
}

func migrateBid(fromBz []byte, cdc codec.BinaryCodec) codec.ProtoMarshaler {
var oldObject mv1beta3.Bid
cdc.MustUnmarshal(fromBz, &oldObject)

to := mmigrate.BidFromV1beta3(oldObject)

return &to

Check warning on line 47 in upgrades/software/v0.28.0/market.go

View check run for this annotation

Codecov / codecov/patch

upgrades/software/v0.28.0/market.go#L41-L47

Added lines #L41 - L47 were not covered by tests
}
54 changes: 54 additions & 0 deletions upgrades/software/v0.28.0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Package v0_28_0
// nolint revive
package v0_28_0

import (
"fmt"

"github.com/tendermint/tendermint/libs/log"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/authz"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

apptypes "github.com/akash-network/node/app/types"
utypes "github.com/akash-network/node/upgrades/types"
)

const (
UpgradeName = "v0.28.0"
)

type upgrade struct {
*apptypes.App
log log.Logger
}

var _ utypes.IUpgrade = (*upgrade)(nil)

func initUpgrade(log log.Logger, app *apptypes.App) (utypes.IUpgrade, error) {
up := &upgrade{
App: app,
log: log.With("module", fmt.Sprintf("upgrade/%s", UpgradeName)),
}

return up, nil
}

func (up *upgrade) StoreLoader() *storetypes.StoreUpgrades {
return &storetypes.StoreUpgrades{}
}

func (up *upgrade) UpgradeHandler() upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return up.MM.RunMigrations(ctx, up.Configurator, fromVM)
}

Check warning on line 47 in upgrades/software/v0.28.0/upgrade.go

View check run for this annotation

Codecov / codecov/patch

upgrades/software/v0.28.0/upgrade.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}

type grantBackup struct {
granter sdk.AccAddress
grantee sdk.AccAddress
grant authz.Grant
}
2 changes: 2 additions & 0 deletions upgrades/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package upgrades

import (
// nolint: revive
_ "github.com/akash-network/node/upgrades/software/v0.28.0"
// nolint: revive
_ "github.com/akash-network/node/upgrades/software/v0.26.0"
// nolint: revive
Expand Down
2 changes: 1 addition & 1 deletion x/deployment/handler/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
types "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
etypes "github.com/akash-network/akash-api/go/node/escrow/v1beta3"

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

// MarketKeeper Interface includes market methods
Expand Down
2 changes: 1 addition & 1 deletion x/escrow/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
deploymentTypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
types "github.com/akash-network/akash-api/go/node/escrow/v1beta3"

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

netutil "github.com/akash-network/node/util/network"
"github.com/akash-network/node/x/deployment/client/cli"
Expand Down
2 changes: 1 addition & 1 deletion x/market/alias.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package market

import (
types "github.com/akash-network/akash-api/go/node/market/v1beta3"
types "github.com/akash-network/akash-api/go/node/market/v1beta4"

"github.com/akash-network/node/x/market/keeper"
)
Expand Down
2 changes: 1 addition & 1 deletion x/market/client/cli/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

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

func cmdGetBids() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion x/market/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

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

"github.com/akash-network/node/testutil"
Expand Down
2 changes: 1 addition & 1 deletion x/market/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"

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

dcli "github.com/akash-network/node/x/deployment/client/cli"
)
Expand Down
Loading

0 comments on commit 21fd3c4

Please sign in to comment.