Skip to content

Commit

Permalink
Merge pull request #22 from UptickNetwork/dev-0.2.16
Browse files Browse the repository at this point in the history
a safe version without wasm moudle
  • Loading branch information
YangChuantongStarry committed Jan 11, 2024
2 parents fe6d3b7 + a797f68 commit 51ce894
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 236 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,6 @@ else
# mkdir -p localnet-setup
@$(MAKE) localnet-build

# if ! [ -f localnet-setup/node0/$(UPTICK_BINARY)/config/genesis.json ]; \
# then \
# docker run --rm -v $(CURDIR)/localnet-setup:/uptick:Z xuxinai2002/node:v0.1 "export LD_LIBRARY_PATH=/wasm && ./uptickd testnet init-files --v 4 -o /uptick --keyring-backend=test --starting-ip-address 192.167.10.2"; \
# fi
#
# docker-compose up -d
endif

Expand Down
3 changes: 0 additions & 3 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (

ethante "github.com/evmos/ethermint/app/ante"
evmtypes "github.com/evmos/ethermint/x/evm/types"

wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
)

// HandlerOptions defines the list of module keepers required to run the Evmos
Expand All @@ -31,7 +29,6 @@ type HandlerOptions struct {
SignModeHandler authsigning.SignModeHandler
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
Cdc codec.BinaryCodec
MaxTxGasWanted uint64
TxFeeChecker ante.TxFeeChecker
Expand Down
164 changes: 14 additions & 150 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/nft"

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

"io"
"net/http"
"os"
Expand Down Expand Up @@ -175,14 +172,6 @@ func init() {
const (
// Name defines the application binary name
Name = "uptickd"

// ProposalsEnabled 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"
// EnableSpecificProposals 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 = ""
)

var (
Expand Down Expand Up @@ -244,7 +233,6 @@ var (
nftmodule.AppModuleBasic{},
nfttransfer.AppModuleBasic{},

wasm.AppModuleBasic{},
ica.AppModuleBasic{},

consensus.AppModuleBasic{},
Expand All @@ -266,9 +254,8 @@ var (

nfttypes.ModuleName: nil,
// nft.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
icatypes.ModuleName: nil,
nft.ModuleName: nil,
icatypes.ModuleName: nil,
nft.ModuleName: nil,
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -345,15 +332,6 @@ type Uptick struct {
Erc721Keeper erc721keeper.Keeper

NFTKeeper nftkeeper.Keeper

//Add ICS721 for nft ibc transfer
// ICS721Keeper ibcnfttransferkeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration
wasmKeeper wasm.Keeper
wasmPermissionedKeeper wasmkeeper.PermissionedKeeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper

// simulation manager
sm *module.SimulationManager
tpsCounter *tpsCounter
Expand All @@ -370,7 +348,6 @@ func NewUptick(
invCheckPeriod uint,
encodingConfig simappparams.EncodingConfig,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *Uptick {

Expand Down Expand Up @@ -419,7 +396,6 @@ func NewUptick(
// nfttypes.StoreKey,
ibcnfttransfertypes.StoreKey,
icahosttypes.StoreKey,
wasmtypes.StoreKey,
consensusparamtypes.StoreKey,
crisistypes.StoreKey,
)
Expand Down Expand Up @@ -456,7 +432,6 @@ func NewUptick(
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)

scopedNFTTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibcnfttransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule`
app.CapabilityKeeper.Seal()
Expand Down Expand Up @@ -695,38 +670,6 @@ func NewUptick(
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition
wasmDir := filepath.Join(homePath, "data")

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
panic("error while reading wasm config: " + err.Error())
}

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate"
app.wasmKeeper = wasmkeeper.NewKeeper(
appCodec,
keys[wasmtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
nil,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
app.TransferKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
supportedFeatures,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
wasmOpts...,
)

ibcnfttransferModule := nfttransfer.NewAppModule(app.IBCNFTTransferKeeper)
nftTransferIBCModule := nfttransfer.NewIBCModule(app.IBCNFTTransferKeeper)
ercTransferStack := erc721.NewIBCMiddleware(app.Erc721Keeper, nftTransferIBCModule)
Expand All @@ -736,7 +679,6 @@ func NewUptick(
ibcRouter := porttypes.NewRouter()

ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(wasmtypes.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)).
AddRoute(ibcnfttransfertypes.ModuleName, ercTransferStack).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)

Expand Down Expand Up @@ -792,9 +734,6 @@ func NewUptick(

ibcnfttransferModule,
icaModule,
// this line is used by starport scaffolding # stargate/app/appModule
// wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -832,7 +771,6 @@ func NewUptick(

ibcnfttransfertypes.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
consensusparamtypes.ModuleName,
)

Expand Down Expand Up @@ -864,7 +802,6 @@ func NewUptick(
nfttypes.ModuleName,
ibcnfttransfertypes.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
consensusparamtypes.ModuleName,
)

Expand Down Expand Up @@ -906,7 +843,6 @@ func NewUptick(
nfttypes.ModuleName,
ibcnfttransfertypes.ModuleName,
icatypes.ModuleName,
wasmtypes.ModuleName,
consensusparamtypes.ModuleName,
)

Expand Down Expand Up @@ -941,7 +877,6 @@ func NewUptick(
feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)),

//nftmodule.NewAppModule(app.appCodec, app.CollectionKeeper, app.AccountKeeper, app.BankKeeper),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper),
ibcnfttransferModule,
)
Expand All @@ -959,17 +894,15 @@ func NewUptick(

maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))
options := ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
IBCKeeper: app.IBCKeeper,
TxCounterStoreKey: keys[wasm.StoreKey],
WasmConfig: wasmConfig,
FeeMarketKeeper: app.FeeMarketKeeper,
EvmKeeper: app.EvmKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: SigVerificationGasConsumer,
MaxTxGasWanted: maxGasWanted,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
IBCKeeper: app.IBCKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
EvmKeeper: app.EvmKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: SigVerificationGasConsumer,
MaxTxGasWanted: maxGasWanted,
}

if err := options.Validate(); err != nil {
Expand All @@ -980,15 +913,6 @@ func NewUptick(
app.SetEndBlocker(app.EndBlocker)
app.registerUpgradeHandlers()

if manager := app.SnapshotManager(); manager != nil {
err = manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.wasmKeeper),
)
if err != nil {
panic("failed to register snapshot extension: " + err.Error())
}
}

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
Expand All @@ -1010,7 +934,6 @@ func NewUptick(

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.scopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper

// Finally start the tpsCounter.
Expand Down Expand Up @@ -1259,9 +1182,6 @@ func initParamsKeeper(
paramsKeeper.Subspace(erc721types.ModuleName).WithKeyTable(erc721types.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())

// paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())
// paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmParamsKeyTable())
paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmParamsKeyTable())
paramsKeeper.Subspace(ibcnfttransfertypes.ModuleName)

return paramsKeeper
Expand All @@ -1283,13 +1203,6 @@ func (app *Uptick) registerUpgradeHandlers() {
panic(fmt.Errorf("failed to FeeMarketKeeper SetParams "))
}

wasmParams := app.wasmKeeper.GetParams(ctx)
wasmParams.CodeUploadAccess.Permission = wasmtypes.AccessTypeEverybody
wasmParams.InstantiateDefaultPermission = wasmtypes.AccessTypeEverybody
if err := app.wasmKeeper.SetParams(ctx, wasmParams); err != nil {
panic(fmt.Errorf("failed to wasmKeeper SetParams "))
}

return app.mm.RunMigrations(ctx, app.configurator, vm)
})

Expand All @@ -1310,7 +1223,8 @@ func (app *Uptick) registerUpgradeHandlers() {
case upgradeVersion:
// add revenue module for testnet (v7 -> v8)
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{crisistypes.ModuleName, consensusparamtypes.ModuleName, ibcnfttransfertypes.ModuleName},
Added: []string{crisistypes.ModuleName, consensusparamtypes.ModuleName, ibcnfttransfertypes.ModuleName},
Deleted: []string{"wasm"},
}
}

Expand All @@ -1337,53 +1251,3 @@ func (app *Uptick) BlockedModuleAccountAddrs() map[string]bool {

return modAccAddrs
}

// Deprecated.
func wasmParamsKeyTable() paramstypes.KeyTable {

var addrees []string
return paramstypes.NewKeyTable(
paramstypes.NewParamSetPair(
wasmtypes.ParamStoreKeyUploadAccess, wasmtypes.AccessConfig{
Permission: wasmtypes.AccessTypeEverybody,
Addresses: addrees,
}, validateAccessConfig,
),
paramstypes.NewParamSetPair(
wasmtypes.ParamStoreKeyInstantiateAccess, wasmtypes.AccessTypeEverybody, validateAccessType,
),
)
}

func validateAccessConfig(i interface{}) error {
v, ok := i.(wasmtypes.AccessConfig)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return v.ValidateBasic()
}

func validateAccessType(i interface{}) error {
a, ok := i.(wasmtypes.AccessType)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if a == wasmtypes.AccessTypeUnspecified {
return fmt.Errorf("ErrEmpty: %T", i)
// errorsmod.Wrap(ErrEmpty, "type")
}
for _, v := range wasmtypes.AllAccessTypes {
if v == a {
return nil
}
}
return fmt.Errorf("unknown type: %q", a)
}

//// ParamSetPairs returns the parameter set pairs.
//func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
// return paramtypes.ParamSetPairs{
// paramtypes.NewParamSetPair(ParamStoreKeyUploadAccess, &p.CodeUploadAccess, validateAccessConfig),
// paramtypes.NewParamSetPair(ParamStoreKeyInstantiateAccess, &p.InstantiateDefaultPermission, validateAccessType),
// }
//}
52 changes: 0 additions & 52 deletions app/wasm_config.go

This file was deleted.

Loading

0 comments on commit 51ce894

Please sign in to comment.