Skip to content

Commit

Permalink
State verifier is merged into rehearsal
Browse files Browse the repository at this point in the history
  • Loading branch information
deniszagumennov committed Dec 13, 2024
2 parents 315864a + 4a57aac commit 801baa5
Show file tree
Hide file tree
Showing 38 changed files with 2,718 additions and 120 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ARG GIT_COMMIT
ARG BUILD_TAGS
ARG ENABLED_PROPOSALS

ENV GOTOOLCHAIN go1.22.6
ENV GOTOOLCHAIN go1.22.9

RUN apk add --no-cache \
ca-certificates \
Expand Down
15 changes: 14 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
"path/filepath"
"time"

v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2"
dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types"
stateverifier "github.com/neutron-org/neutron/v5/x/state-verifier"
svkeeper "github.com/neutron-org/neutron/v5/x/state-verifier/keeper"
stateverifiertypes "github.com/neutron-org/neutron/v5/x/state-verifier/types"

"github.com/skip-mev/feemarket/x/feemarket"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
Expand Down Expand Up @@ -228,6 +232,7 @@ const (
var (
Upgrades = []upgrades.Upgrade{
v500.Upgrade,
v502.Upgrade,
}

// DefaultNodeHome default home directories for the application daemon
Expand Down Expand Up @@ -392,6 +397,8 @@ type App struct {
InterchainTxsKeeper interchaintxskeeper.Keeper
ContractManagerKeeper contractmanagermodulekeeper.Keeper

StateVerifierKeeper *svkeeper.Keeper

ConsensusParamsKeeper consensusparamkeeper.Keeper

WasmKeeper wasmkeeper.Keeper
Expand Down Expand Up @@ -487,7 +494,7 @@ func New(
interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasmtypes.StoreKey, feetypes.StoreKey,
feeburnertypes.StoreKey, adminmoduletypes.StoreKey, ccvconsumertypes.StoreKey, tokenfactorytypes.StoreKey, pfmtypes.StoreKey,
crontypes.StoreKey, ibcratelimittypes.ModuleName, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, dextypes.StoreKey, auctiontypes.StoreKey,
oracletypes.StoreKey, marketmaptypes.StoreKey, feemarkettypes.StoreKey, dynamicfeestypes.StoreKey, globalfeetypes.StoreKey,
oracletypes.StoreKey, marketmaptypes.StoreKey, feemarkettypes.StoreKey, dynamicfeestypes.StoreKey, globalfeetypes.StoreKey, stateverifiertypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, dextypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, feetypes.MemStoreKey)
Expand Down Expand Up @@ -651,6 +658,8 @@ func New(

app.GlobalFeeKeeper = globalfeekeeper.NewKeeper(appCodec, keys[globalfeetypes.StoreKey], authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String())

app.StateVerifierKeeper = svkeeper.NewKeeper(appCodec, keys[stateverifiertypes.StoreKey], runtime.ProvideCometInfoService(), runtime.ProvideHeaderInfoService(nil), authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String())

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), &app.ConsumerKeeper, app.SlashingKeeper,
Expand Down Expand Up @@ -929,6 +938,7 @@ func New(
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
// always be last to make sure that it checks for all invariants and not only part of them
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
stateverifier.NewAppModule(appCodec, app.StateVerifierKeeper),
)

app.mm.SetOrderPreBlockers(
Expand Down Expand Up @@ -974,6 +984,7 @@ func New(
feemarkettypes.ModuleName,
dextypes.ModuleName,
consensusparamtypes.ModuleName,
stateverifiertypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -1011,6 +1022,7 @@ func New(
feemarkettypes.ModuleName,
dextypes.ModuleName,
consensusparamtypes.ModuleName,
stateverifiertypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -1054,6 +1066,7 @@ func New(
dextypes.ModuleName,
dynamicfeestypes.ModuleName,
consensusparamtypes.ModuleName,
stateverifiertypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v5.0.2/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v502

import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.2"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
35 changes: 35 additions & 0 deletions app/upgrades/v5.0.2/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v502

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}
37 changes: 37 additions & 0 deletions app/upgrades/v5.0.2/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package v502_test

import (
"testing"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2"
"github.com/neutron-org/neutron/v5/testutil"
)

type UpgradeTestSuite struct {
testutil.IBCConnectionTestSuite
}

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

func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()

upgrade := upgradetypes.Plan{
Name: v502.UpgradeName,
Info: "some text here",
Height: 100,
}
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))
}
46 changes: 46 additions & 0 deletions docs/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19635,6 +19635,11 @@ definitions:
type: array
type: object
type: object
neutron.state_verifier.v1.QueryVerifyStateValuesResponse:
properties:
valid:
type: boolean
type: object
osmosis.tokenfactory.Params:
description: Params defines the parameters for the tokenfactory module.
properties:
Expand Down Expand Up @@ -45443,6 +45448,47 @@ paths:
type: object
tags:
- Query
/neutron/state-verifier/verify_state_values:
get:
operationId: VerifyStateValues
parameters:
- format: uint64
in: query
name: height
required: false
type: string
responses:
'200':
description: A successful response.
schema:
properties:
valid:
type: boolean
type: object
default:
description: An unexpected error response.
schema:
properties:
code:
format: int32
type: integer
details:
items:
properties:
type_url:
type: string
value:
format: byte
type: string
type: object
type: array
error:
type: string
message:
type: string
type: object
tags:
- Query
/osmosis/tokenfactory/v1beta1/denoms/factory/{creator}/{subdenom}/authority_metadata:
get:
operationId: DenomAuthorityMetadata
Expand Down
Loading

0 comments on commit 801baa5

Please sign in to comment.