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

applying cosmos sdk v0.47.x with related upstream codes #125

Merged
merged 31 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ea5e443
feat: apply cosmos sdk v0.47.x
yoosah Mar 15, 2024
746fe42
fix: remove evmos dependency
yoosah Mar 15, 2024
a2e8c0f
fix: fix test function
yoosah Mar 15, 2024
b029f20
feat: refactor packet forward middleware and more
yoosah Mar 11, 2024
e86e7af
chore: align formatting
yoosah Mar 18, 2024
86fdadf
feat: bump cosmos sdk version
yoosah Mar 18, 2024
e4ab96a
feat: apply cosmwasm v0.45.0
yoosah Mar 19, 2024
069b9e6
chore: slightly refactor app.go and ante.go
yoosah Mar 20, 2024
98bda09
chore: refactor export.go
yoosah Mar 22, 2024
5bb2433
chore: update go version for workflow
yoosah Mar 25, 2024
9af0705
feat: bump wasmvm version to v1.5.1
yoosah Mar 25, 2024
a5c5a09
fix: add user id for workflow
yoosah Mar 25, 2024
426077c
chore: go-ethereum v1.10.26-xpla
JoowonYun Mar 19, 2024
cfebbe5
chore: cosmos-sdk v0.47.10-xpla
JoowonYun Mar 22, 2024
be1c7ca
refactor: app-cosmos ledger(xpla)
JoowonYun Mar 22, 2024
7717944
test: use test input StakingHandler
yoosah Mar 27, 2024
3d6b735
fix: revert v1_4 upgrade
yoosah Mar 27, 2024
8a634eb
feat: refactor upgrade handler
yoosah Mar 28, 2024
9a81de1
feat: apply v1_5 upgrade handler
yoosah Apr 1, 2024
01730b7
fix: update pfm version
yoosah Apr 1, 2024
630b1ac
fix: follow up staking module
JoowonYun Apr 2, 2024
994d91c
fix: remove redundant code
yoosah Apr 3, 2024
46d14a9
fix: chain id EIP155 number
yoosah Apr 3, 2024
23ec238
chore: add error check for RegisterGRPCGatewayRoutes
yoosah Apr 3, 2024
0182553
fix: remove deprecated param
yoosah Apr 3, 2024
d5c14e4
fix: slightly refactor integration test
yoosah Apr 3, 2024
9220cbf
feat: apply ethermint v0.23.0-xpla-rc2
yoosah Apr 3, 2024
546ccbc
feat: apply ethermint v0.23.0-xpla-rc3
yoosah Apr 4, 2024
9910b1b
feat: apply cosmos-sdk v0.47.10-xpla-rc0
JoowonYun Apr 5, 2024
18fab6c
chore: deprecated params module (#128)
JoowonYun Apr 11, 2024
248c222
feat: update go.mod
yoosah Apr 11, 2024
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: 2 additions & 0 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type HandlerOptions struct {

BypassMinFeeMsgTypes []string
TxCounterStoreKey storetypes.StoreKey
WasmKeeper *wasmkeeper.Keeper
WasmConfig wasmTypes.WasmConfig
}

Expand Down Expand Up @@ -141,6 +142,7 @@ func newCosmosAnteHandler(opts HandlerOptions) sdk.AnteHandler {
authante.NewSetUpContextDecorator(), // second decorator. SetUpContext must be called before other decorators
wasmkeeper.NewLimitSimulationGasDecorator(opts.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(opts.TxCounterStoreKey),
wasmkeeper.NewGasRegisterDecorator(opts.WasmKeeper.GetGasRegister()),
NewMinGasPriceDecorator(opts.FeeMarketKeeper, opts.EvmKeeper, opts.BypassMinFeeMsgTypes),
authante.NewValidateBasicDecorator(),
authante.NewTxTimeoutHeightDecorator(),
Expand Down
42 changes: 2 additions & 40 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"

"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
Expand Down Expand Up @@ -67,45 +65,10 @@ var (
)

var (
// If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals.
// If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals.
ProposalsEnabled = "true"
// If set to non-empty string it must be comma-separated list of values that are all a subset
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

// TODO: after test, take this values from appOpts
evmMaxGasWanted uint64 = 500000 //ethermintconfig.DefaultMaxTxGasWanted
)

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
// produce a list of enabled proposals to pass into wasmd app.
func GetEnabledProposals() []wasm.ProposalType {
if EnableSpecificProposals == "" {
if ProposalsEnabled == "true" {
return wasm.EnableAllProposals
}
return wasm.DisableAllProposals
}
chunks := strings.Split(EnableSpecificProposals, ",")
proposals, err := wasm.ConvertToProposals(chunks)
if err != nil {
panic(err)
}
return proposals
}

// GetWasmOpts build wasm options
func GetWasmOpts(appOpts servertypes.AppOptions) []wasm.Option {
var wasmOpts []wasm.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}

return wasmOpts
}

// XplaApp extends an ABCI application, but with most of its parameters exported.
// They are exported for convenience in creating helper functions, as object
// capabilities aren't needed for testing.
Expand Down Expand Up @@ -146,9 +109,8 @@ func NewXplaApp(
homePath string,
invCheckPeriod uint,
encodingConfig xplaappparams.EncodingConfig,
enabledProposals []wasm.ProposalType,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
wasmOpts []wasmkeeper.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *XplaApp {
appCodec := encodingConfig.Codec
Expand Down Expand Up @@ -182,7 +144,6 @@ func NewXplaApp(
skipUpgradeHeights,
homePath,
invCheckPeriod,
enabledProposals,
logger,
appOpts,
wasmOpts,
Expand Down Expand Up @@ -254,6 +215,7 @@ func NewXplaApp(

BypassMinFeeMsgTypes: cast.ToStringSlice(appOpts.Get(xplaappparams.BypassMinFeeMsgTypesKey)),
TxCounterStoreKey: app.GetKey(wasm.StoreKey),
WasmKeeper: &app.WasmKeeper,
WasmConfig: wasmConfig,
},
)
Expand Down
7 changes: 3 additions & 4 deletions app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"testing"
"time"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/cosmos/ibc-go/v7/testing/mock"
"github.com/stretchr/testify/require"

"github.com/xpladev/xpla/app"
xplaapp "github.com/xpladev/xpla/app"
)

Expand Down Expand Up @@ -126,9 +126,8 @@ func setup(chainId string) (*xplaapp.XplaApp, xplaapp.GenesisState) {
xplaapp.DefaultNodeHome,
5,
encCdc,
app.GetEnabledProposals(),
EmptyAppOptions{},
[]wasm.Option{},
[]wasmkeeper.Option{},
baseapp.SetChainID(chainId),
)
return app, xplaapp.NewDefaultGenesisState()
Expand Down
16 changes: 5 additions & 11 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ func NewAppKeeper(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
enabledProposals []wasm.ProposalType,
logger log.Logger,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
wasmOpts []wasmkeeper.Option,
) AppKeepers {
appKeepers := AppKeepers{}

Expand Down Expand Up @@ -193,7 +192,7 @@ func NewAppKeeper(
appKeepers.ScopedICAControllerKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
appKeepers.scopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
appKeepers.scopedWasmKeeper = appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)

// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule`
Expand Down Expand Up @@ -340,7 +339,7 @@ func NewAppKeeper(
wasmOpts = append(wasmOpts, querierOpts)
appKeepers.WasmKeeper = wasm.NewKeeper(
appCodec,
appKeepers.keys[wasm.StoreKey],
appKeepers.keys[wasmtypes.StoreKey],
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.StakingKeeper,
Expand Down Expand Up @@ -369,11 +368,6 @@ func NewAppKeeper(
AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&appKeepers.Erc20Keeper)).
AddRoute(volunteertypes.RouterKey, volunteerkeeper.NewVolunteerValidatorProposalHandler(appKeepers.VolunteerKeeper))

// register wasm gov proposal types
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(appKeepers.WasmKeeper, enabledProposals))
}

govKeeper := govkeeper.NewKeeper(
appCodec,
appKeepers.keys[govtypes.StoreKey],
Expand Down Expand Up @@ -515,7 +509,7 @@ func NewAppKeeper(
// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(wasm.ModuleName, wasmStack).
AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack)

Expand Down Expand Up @@ -566,7 +560,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(pfmroutertypes.ModuleName).WithKeyTable(pfmroutertypes.ParamKeyTable())
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(wasm.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())
paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())
paramsKeeper.Subspace(erc20types.ModuleName)
Expand Down
8 changes: 4 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var maccPerms = map[string][]string{
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
erc20types.ModuleName: {authtypes.Minter, authtypes.Burner},
rewardtypes.ModuleName: nil,
Expand Down Expand Up @@ -212,7 +212,7 @@ func orderBeginBlockers() []string {
icatypes.ModuleName,
pfmroutertypes.ModuleName,
ibcfeetypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
feemarkettypes.ModuleName,
evmtypes.ModuleName,
erc20types.ModuleName,
Expand Down Expand Up @@ -245,7 +245,7 @@ func orderEndBlockers() []string {
icatypes.ModuleName,
pfmroutertypes.ModuleName,
ibcfeetypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
erc20types.ModuleName,
Expand Down Expand Up @@ -283,7 +283,7 @@ func orderInitBlockers() []string {
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
wasm.ModuleName,
wasmtypes.ModuleName,
erc20types.ModuleName,
rewardtypes.ModuleName,
volunteertypes.ModuleName,
Expand Down
7 changes: 2 additions & 5 deletions cmd/xplad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

dbm "github.com/cometbft/cometbft-db"
Expand Down Expand Up @@ -275,7 +274,7 @@ func (ac appCreator) newApp(
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
)

var wasmOpts []wasm.Option
var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}
Expand All @@ -302,7 +301,6 @@ func (ac appCreator) newApp(
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
ac.encCfg,
xpla.GetEnabledProposals(),
appOpts,
wasmOpts,
baseapp.SetPruning(pruningOpts),
Expand Down Expand Up @@ -340,7 +338,7 @@ func (ac appCreator) appExport(
if height == -1 {
loadLatest = true
}
var emptyWasmOpts []wasm.Option
var emptyWasmOpts []wasmkeeper.Option

xplaApp := xpla.NewXplaApp(
logger,
Expand All @@ -351,7 +349,6 @@ func (ac appCreator) appExport(
homePath,
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
ac.encCfg,
xpla.GetEnabledProposals(),
appOpts,
emptyWasmOpts,
)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cosmossdk.io/api v0.3.1
cosmossdk.io/errors v1.0.1
cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d
github.com/CosmWasm/wasmd v0.40.2
github.com/CosmWasm/wasmd v0.45.0
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
Expand Down Expand Up @@ -47,7 +47,7 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmvm v1.2.4 // indirect
github.com/CosmWasm/wasmvm v1.5.0 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CosmWasm/wasmd v0.40.2 h1:GSDHIaeJI7fcDF5mkzSXQI5IZLtvpNq5t3TjJ9bDpPw=
github.com/CosmWasm/wasmd v0.40.2/go.mod h1:vqI238yb4D6aNuigS8mCqTyyCV9HN5eBEZARKRoK3ts=
github.com/CosmWasm/wasmvm v1.2.4 h1:6OfeZuEcEH/9iqwrg2pkeVtDCkMoj9U6PpKtcrCyVrQ=
github.com/CosmWasm/wasmvm v1.2.4/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI=
github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944=
github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw=
github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
Expand Down
Loading