Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze committed Mar 13, 2024
1 parent 6d86876 commit 2396e5b
Show file tree
Hide file tree
Showing 17 changed files with 1,003 additions and 130 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
# This Dockerfile performs a multi-stage build. BUILDER_IMAGE is the image used
# to compile the celestia-appd binary. RUNTIME_IMAGE is the image that will be
# returned with the final celestia-appd binary.
Expand All @@ -6,6 +7,11 @@
# considerably smaller because it doesn't need to have Golang installed.
ARG BUILDER_IMAGE=docker.io/golang:1.22.1-alpine3.18
ARG RUNTIME_IMAGE=docker.io/alpine:3.19.1
=======
# stage 1 Generate celestia-appd Binary
FROM --platform=$BUILDPLATFORM docker.io/golang:1.22.1-alpine3.18 as builder

>>>>>>> 65c100c9 (chore: cleanup)
ARG TARGETOS
ARG TARGETARCH

Expand Down
4 changes: 2 additions & 2 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewAnteHandler(
ante.NewConsumeGasForTxSizeDecorator(accountKeeper),
// Ensure the feepayer (fee granter or first signer) has enough funds to pay for the tx.
// Side effect: deducts fees from the fee payer. Sets the tx priority in context.
NewMinGasDecorator(accountKeeper, bankKeeper, feegrantKeeper, minFeeParams),
NewDeductFeeDecoratorWrapper(accountKeeper, bankKeeper, feegrantKeeper, minFeeParams),
// Set public keys in the context for fee-payer and all signers.
// Contract: must be called before all signature verification decorators.
ante.NewSetPubKeyDecorator(accountKeeper),
Expand Down Expand Up @@ -74,7 +74,7 @@ func NewAnteHandler(

var DefaultSigVerificationGasConsumer = ante.DefaultSigVerificationGasConsumer

func NewMinGasDecorator(accountKeeper ante.AccountKeeper, bankKeeper authtypes.BankKeeper, feegrantKeeper ante.FeegrantKeeper, minFeeParam params.Subspace) ante.DeductFeeDecorator {
func NewDeductFeeDecoratorWrapper(accountKeeper ante.AccountKeeper, bankKeeper authtypes.BankKeeper, feegrantKeeper ante.FeegrantKeeper, minFeeParam params.Subspace) ante.DeductFeeDecorator {
return ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper, NewTxFeeChecker(minFeeParam))
}

Expand Down
2 changes: 1 addition & 1 deletion app/ante/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func CheckTxFeeWithGlobalMinGasPrices(ctx sdk.Context, tx sdk.Tx, minFeeParams p
if ctx.IsCheckTx() {
defaultMinGasPriceDec, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.DefaultMinGasPrice))
if err != nil {
return nil, 0, errors.Wrapf(err, "invalid defaultMinGasPrice: %f", defaultMinGasPriceDec)
return nil, 0, errors.Wrapf(err, "invalid defaultMinGasPrice: %f", defaultMinGasPriceDec)
}

err = CheckTxFeeWithMinGasPrices(fee, gas, defaultMinGasPriceDec, "insufficient validator minimum fee")
Expand Down
12 changes: 6 additions & 6 deletions app/ante/min_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
minfeetypes "github.com/celestiaorg/celestia-app/x/minfee"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
version "github.com/tendermint/tendermint/proto/tendermint/version"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/store"
// tmdb "github.com/tendermint/tm-db"
testutil "github.com/celestiaorg/celestia-app/test/util"
tmdb "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -107,13 +107,13 @@ func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) {

storeKey := sdk.NewKVStoreKey(paramtypes.StoreKey)
tStoreKey := storetypes.NewTransientStoreKey(paramtypes.TStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(tStoreKey, storetypes.StoreTypeTransient, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)

Expand All @@ -122,15 +122,15 @@ func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) {
App: tc.appVersion,
},
}, false, nil)

paramsSubspace := paramtypes.NewSubspace(cdc,
testutil.MakeTestCodec(),
storeKey,
tStoreKey,
"GlobalMinGasPrice",
)

// Register the parameter in the subspace
// Register the parameter in the subspace
minfeetypes.RegisterMinFeeParamTable(paramsSubspace)

// Set a mock value for the MinGasPrice
Expand Down
45 changes: 39 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"io"

"github.com/celestiaorg/celestia-app/app/module"
Expand Down Expand Up @@ -392,6 +393,10 @@ func New(
module.NewVersionedModule(blob.NewAppModule(appCodec, app.BlobKeeper), v1.Version, v2.Version),
module.NewVersionedModule(blobstream.NewAppModule(appCodec, app.BlobstreamKeeper), v1.Version, v2.Version),
module.NewVersionedModule(upgrade.NewAppModule(app.UpgradeKeeper), v2.Version, v2.Version),
<<<<<<< HEAD
=======
module.NewVersionedModule(minfee.NewAppModule(app.ParamsKeeper), v1.Version, v2.Version),
>>>>>>> 65c100c9 (chore: cleanup)
)
if err != nil {
panic(err)
Expand Down Expand Up @@ -422,8 +427,11 @@ func New(
authz.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
minfee.ModuleName,
)

fmt.Println(app.mm.ModuleNames(1))

app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
Expand All @@ -445,6 +453,7 @@ func New(
authz.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
minfee.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -473,19 +482,21 @@ func New(
paramstypes.ModuleName,
authz.ModuleName,
upgradetypes.ModuleName,
minfee.ModuleName,
)

app.QueryRouter().AddRoute(proof.TxInclusionQueryPath, proof.QueryTxInclusionProof)
app.QueryRouter().AddRoute(proof.ShareInclusionQueryPath, proof.QueryShareInclusionProof)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
minfee.RegisterMinFeeParamTable(app.GetSubspace(minfee.ModuleName))
app.configurator.RegisterMigration("minfee", v2.Version, func(ctx sdk.Context) error {
subspace := app.GetSubspace(minfee.ModuleName)
subspace.Set(ctx, minfee.KeyGlobalMinGasPrice, minfee.DefaultGlobalMinGasPrice)
return nil
})
// minfee.RegisterMinFeeParamTable(app.GetSubspace(minfee.ModuleName))
// app.configurator.RegisterMigration(minfee.ModuleName, v2.Version, func(ctx sdk.Context) error {
// // fmt.Println("Migrating minfee")
// subspace := app.GetSubspace(minfee.ModuleName)
// subspace.Set(ctx, minfee.KeyGlobalMinGasPrice, minfee.DefaultGlobalMinGasPrice)
// return nil
// })

app.mm.RegisterServices(app.configurator)

Expand Down Expand Up @@ -531,6 +542,10 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
res := app.mm.EndBlock(ctx, req)
// NOTE: this is a specific feature for upgrading from v1 to v2. It will be deprecated in v3
<<<<<<< HEAD
=======
fmt.Println("CALLED HERE")
>>>>>>> 65c100c9 (chore: cleanup)
if app.UpgradeKeeper.ShouldUpgradeToV2(req.Height) && app.AppVersion(ctx) == v1.Version {
if err := app.Upgrade(ctx, v2.Version); err != nil {
panic(err)
Expand All @@ -540,6 +555,10 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
// Version changes must be increasing. Downgrades are not permitted
if version > app.AppVersion(ctx) {
if err := app.Upgrade(ctx, version); err != nil {
<<<<<<< HEAD
=======

>>>>>>> 65c100c9 (chore: cleanup)
panic(err)
}
}
Expand All @@ -549,6 +568,12 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo

func (app *App) Upgrade(ctx sdk.Context, version uint64) error {
app.SetAppVersion(ctx, version)
<<<<<<< HEAD
=======
fmt.Println(app.mm.ModuleNames(version), "APP MM")
fmt.Print(app.AppVersion(ctx), "APP VERSION CTX")
fmt.Println(version, "VERSION")
>>>>>>> 65c100c9 (chore: cleanup)
return app.mm.RunMigrations(ctx, app.configurator, app.AppVersion(ctx), version)
}

Expand All @@ -563,6 +588,14 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
if req.ConsensusParams == nil || req.ConsensusParams.Version == nil {
panic("no consensus params set")
}
<<<<<<< HEAD
=======

// subspace := app.GetSubspace(minfee.ModuleName)
// subspace.Set(ctx, minfee.KeyGlobalMinGasPrice, minfee.DefaultGlobalMinGasPrice)
// fmt.Println("APP MM", app.mm)
fmt.Println(app.mm.ModuleNames(req.ConsensusParams.Version.AppVersion), "MODULES AT INITGENESIS")
>>>>>>> 65c100c9 (chore: cleanup)
return app.mm.InitGenesis(ctx, app.appCodec, genesisState, req.ConsensusParams.Version.AppVersion)
}

Expand Down
38 changes: 38 additions & 0 deletions app/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func NewManager(modules ...VersionedModule) (*Manager, error) {
}
}

<<<<<<< HEAD
m := &Manager{
=======
return &Manager{
>>>>>>> 65c100c9 (chore: cleanup)
versionedModules: moduleMap,
allModules: allModules,
firstVersion: firstVersion,
Expand All @@ -85,8 +89,12 @@ func NewManager(modules ...VersionedModule) (*Manager, error) {
OrderExportGenesis: modulesStr,
OrderBeginBlockers: modulesStr,
OrderEndBlockers: modulesStr,
<<<<<<< HEAD
}
return m, m.checkUpgradeSchedule()
=======
}, nil
>>>>>>> 65c100c9 (chore: cleanup)
}

// SetOrderInitGenesis sets the order of init genesis calls
Expand Down Expand Up @@ -214,12 +222,22 @@ type VersionMap map[string]uint64
// RunMigrations performs in-place store migrations for all modules. This
// function MUST be called when the state machine changes appVersion
func (m Manager) RunMigrations(ctx sdk.Context, cfg sdkmodule.Configurator, fromVersion, toVersion uint64) error {
<<<<<<< HEAD
=======
fmt.Println("FROM VERSION", fromVersion)
fmt.Println("TO VERSION", toVersion)
fromVersion = 1
>>>>>>> 65c100c9 (chore: cleanup)
c, ok := cfg.(configurator)
if !ok {
return sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", configurator{}, cfg)
}
modules := m.OrderMigrations
if modules == nil {
<<<<<<< HEAD
=======
fmt.Println("MODULES ARE NIL")
>>>>>>> 65c100c9 (chore: cleanup)
modules = DefaultMigrationsOrder(m.ModuleNames(toVersion))
}
currentVersionModules, exists := m.versionedModules[fromVersion]
Expand All @@ -232,11 +250,19 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg sdkmodule.Configurator, from
}

for _, moduleName := range modules {
<<<<<<< HEAD
currentModule, currentModuleExists := currentVersionModules[moduleName]
=======
fmt.Println(moduleName, "module name")
_, currentModuleExists := currentVersionModules[moduleName]
fmt.Println(currentVersionModules[moduleName].Name(), "current version modules !!!!!!")
fmt.Println(nextVersionModules[moduleName].Name(), "next version modules !!!!!!")
>>>>>>> 65c100c9 (chore: cleanup)
nextModule, nextModuleExists := nextVersionModules[moduleName]

// if the module exists for both upgrades
if currentModuleExists && nextModuleExists {
<<<<<<< HEAD
// by using consensus version instead of app version we support the SDK's legacy method
// of migrating modules which were made of several versions and consisted of a mapping of
// app version to module version. Now, using go.mod, each module will have only a single
Expand All @@ -245,10 +271,19 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg sdkmodule.Configurator, from
fromModuleVersion := currentModule.ConsensusVersion()
toModuleVersion := nextModule.ConsensusVersion()
err := c.runModuleMigrations(ctx, moduleName, fromModuleVersion, toModuleVersion)
=======
fmt.Println("MODULE EXISTS FOR BOTH UPGRADES")
fmt.Println(currentModuleExists)
err := c.runModuleMigrations(ctx, moduleName, fromVersion, toVersion)
>>>>>>> 65c100c9 (chore: cleanup)
if err != nil {
return err
}
} else if !currentModuleExists && nextModuleExists {
<<<<<<< HEAD
=======
fmt.Println("CONFIRMING THAT DID NOT MAKE IT HERE")
>>>>>>> 65c100c9 (chore: cleanup)
ctx.Logger().Info(fmt.Sprintf("adding a new module: %s", moduleName))
moduleValUpdates := nextModule.InitGenesis(ctx, c.cdc, nextModule.DefaultGenesis(c.cdc))
// The module manager assumes only one module will update the
Expand Down Expand Up @@ -346,6 +381,7 @@ func (m *Manager) SupportedVersions() []uint64 {
return output
}

<<<<<<< HEAD
// checkUgradeSchedule performs a dry run of all the upgrades in all versions and asserts that the consensus version
// for a module domain i.e. auth, always increments for each module that uses the auth domain name
func (m *Manager) checkUpgradeSchedule() error {
Expand All @@ -370,6 +406,8 @@ func (m *Manager) checkUpgradeSchedule() error {
return nil
}

=======
>>>>>>> 65c100c9 (chore: cleanup)
// DefaultMigrationsOrder returns a default migrations order: ascending alphabetical by module name,
// except x/auth which will run last, see:
// https://github.com/cosmos/cosmos-sdk/issues/10591
Expand Down
3 changes: 3 additions & 0 deletions app/module/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func TestManager_EndBlock(t *testing.T) {
mockAppModule2.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{{}})
require.Panics(t, func() { mm.EndBlock(ctx, req) })
}
<<<<<<< HEAD

func TestManager_UpgradeSchedule(t *testing.T) {
mockCtrl := gomock.NewController(t)
Expand All @@ -218,3 +219,5 @@ func TestManager_UpgradeSchedule(t *testing.T) {
)
require.Error(t, err)
}
=======
>>>>>>> 65c100c9 (chore: cleanup)
26 changes: 6 additions & 20 deletions app/test/std_sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import (
"testing"
"time"

// "encoding/json"
"fmt"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/pkg/user"
"github.com/celestiaorg/celestia-app/test/util/blobfactory"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/celestiaorg/celestia-app/x/minfee"
// v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2"
upgrade "github.com/celestiaorg/celestia-app/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -22,14 +27,13 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
oldgov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
// params "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
params "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
// "fmt"
)

func TestStandardSDKIntegrationTestSuite(t *testing.T) {
Expand Down Expand Up @@ -86,24 +90,6 @@ func (s *StandardSDKIntegrationTestSuite) getValidatorAccount() sdk.ValAddress {
return sdk.ValAddress(address)
}

// func (s *StandardSDKIntegrationTestSuite) TestDefaultGlobalMinFee() {
// fmt.Println("HELLOOOOOO")
// // setup grpc query client and retrieve parameter and assert that it matches the default
// client := params.NewQueryClient(s.cctx.GRPCClient)
// fmt.Println(client, "client")
// res, err := client.Params(s.cctx.GoContext(), &params.QueryParamsRequest{
// Subspace: "minfee",
// })
// if err != nil {
// s.T().Fatal(err)
// }

// fmt.Println(res.Param, "res.Param")

// assert.Equal(s.T(), "0.002000000000000000", res.Param)

// }

func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
t := s.T()
type test struct {
Expand Down
Loading

0 comments on commit 2396e5b

Please sign in to comment.