Skip to content

Commit

Permalink
Merge pull request #166 from lavanet/CNS-45-add-query-to-support-prot…
Browse files Browse the repository at this point in the history
…ocol

CNS-45 add query to support protocol
  • Loading branch information
Yaroms authored Dec 25, 2022
2 parents 2536fc6 + 75b9076 commit 9e4b3b8
Show file tree
Hide file tree
Showing 20 changed files with 795 additions and 152 deletions.
14 changes: 14 additions & 0 deletions app/upgrades/v0.2.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package vx

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/lavanet/lava/app/upgrades"
)

const UpgradeName = "vx"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName, // upgrade name defined few lines above
CreateUpgradeHandler: CreateUpgradeHandler, // create CreateUpgradeHandler in upgrades.go below
StoreUpgrades: store.StoreUpgrades{}, // StoreUpgrades has 3 fields: Added/Renamed/Deleted any module that fits these description should be added in the way below
}
47 changes: 47 additions & 0 deletions app/upgrades/v0.2.0/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//go:build ignore

package vx_test

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
keepertest "github.com/lavanet/lava/testutil/keeper"
v020 "github.com/lavanet/lava/x/spec/migrations/v0.2.0"
"github.com/stretchr/testify/suite"
)

type UpgradeTestSuite struct {
suite.Suite

ctx sdk.Context
app cosmoscmd.App
}

func (suite *UpgradeTestSuite) SetupTestApp() {
suite.app, suite.ctx = app.TestSetup()
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

func (suite *UpgradeTestSuite) TestBody() {
suite.SetupTestApp() // setup test app
suite.T().Log("test")
}

func (suite *UpgradeTestSuite) TestAddingBlockLastUpdated() {
_, keepers, ctx := keepertest.InitAllKeepers(suite.T())
sdkctx := sdk.UnwrapSDKContext(ctx)
suite.T().Log("TestAddingBlockLastUpdated")

migrator := v020.NewMigrator(keepers.Spec)
migrator.MigrateToV020(sdkctx)

allSpec := keepers.Spec.GetAllSpec(sdk.UnwrapSDKContext(ctx))
for _, spec := range allSpec {
suite.Require().Equal(0, spec.BlockLastUpdated)
}
}
31 changes: 31 additions & 0 deletions app/upgrades/v0.2.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package vx

import (
"log"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/lavanet/lava/app/keepers"
"github.com/lavanet/lava/app/upgrades"
v020 "github.com/lavanet/lava/x/spec/migrations/v0.2.0"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
bpm upgrades.BaseAppParamManager,
keepers *keepers.LavaKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
log.Println("########################")
log.Println("# STARTING UPGRADE #")
log.Println("########################")

// delete all existing conflicts
migrator := v020.NewMigrator(keepers.SpecKeeper)
migrator.MigrateToV020(ctx)

return mm.RunMigrations(ctx, configurator, vm)
}
}
35 changes: 33 additions & 2 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30390,6 +30390,15 @@ paths:
type: string
moniker:
type: string
currentEpoch:
type: string
format: uint64
timeLeftToNextPairing:
type: string
format: uint64
specLastUpdatedBlock:
type: string
format: uint64
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -31360,6 +31369,9 @@ paths:
allowed_block_lag_for_qos_sync:
type: string
format: int64
block_last_updated:
type: string
format: uint64
pagination:
type: object
properties:
Expand Down Expand Up @@ -31606,6 +31618,9 @@ paths:
allowed_block_lag_for_qos_sync:
type: string
format: int64
block_last_updated:
type: string
format: uint64
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -53354,8 +53369,6 @@ definitions:
CacheMisses:
type: string
format: uint64
lavanet.lava.pairing.Empty:
type: object
lavanet.lava.pairing.EpochPayments:
type: object
properties:
Expand Down Expand Up @@ -53749,6 +53762,15 @@ definitions:
type: string
moniker:
type: string
currentEpoch:
type: string
format: uint64
timeLeftToNextPairing:
type: string
format: uint64
specLastUpdatedBlock:
type: string
format: uint64
lavanet.lava.pairing.QueryGetProviderPaymentStorageResponse:
type: object
properties:
Expand Down Expand Up @@ -54190,6 +54212,9 @@ definitions:
allowed_block_lag_for_qos_sync:
type: string
format: int64
block_last_updated:
type: string
format: uint64
pagination:
type: object
properties:
Expand Down Expand Up @@ -54349,6 +54374,9 @@ definitions:
allowed_block_lag_for_qos_sync:
type: string
format: int64
block_last_updated:
type: string
format: uint64
lavanet.lava.spec.QueryParamsResponse:
type: object
properties:
Expand Down Expand Up @@ -54624,6 +54652,9 @@ definitions:
allowed_block_lag_for_qos_sync:
type: string
format: int64
block_last_updated:
type: string
format: uint64
lavanet.lava.spec.SpecCategory:
type: object
properties:
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.23
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -197,11 +197,11 @@ require (
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
golang.org/x/net v0.2.0
golang.org/x/net v0.3.0
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1646,8 +1646,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk=
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1784,14 +1784,14 @@ golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1801,8 +1801,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1976,8 +1976,8 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 h1:a2S6M0+660BgMNl++4JPlcAO/CjkqYItDEZwkoDQK7c=
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70=
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
3 changes: 3 additions & 0 deletions proto/pairing/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ message QueryGetPairingRequest {

message QueryGetPairingResponse {
repeated lavanet.lava.epochstorage.StakeEntry providers = 1 [(gogoproto.nullable) = false];
uint64 currentEpoch = 2;
uint64 timeLeftToNextPairing = 3;
uint64 specLastUpdatedBlock = 4;
}

message QueryVerifyPairingRequest {
Expand Down
1 change: 1 addition & 0 deletions proto/spec/spec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ message Spec {
uint32 blocks_in_finalization_proof = 8;
int64 average_block_time =9;
int64 allowed_block_lag_for_qos_sync = 10;
uint64 block_last_updated = 11;
}
Loading

0 comments on commit 9e4b3b8

Please sign in to comment.