Skip to content

Commit

Permalink
support custom max wasm size
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitys7 committed Apr 21, 2024
1 parent f53b8f2 commit 0b45283
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,26 @@ export DENOM="urax"
export MONIKER="$ROLLAPP_CHAIN_ID-sequencer"
```

if you want to change the max wasm size:
And initialize the rollapp:

```shell
export MAX_WASM_SIZE=YOUR_MAX_WASM_SIZE
sh scripts/init.sh
```

And initialize the rollapp:
You can find out in <https://github.com/CosmWasm/wasmd#compile-time-parameters> that:

There are a few variables was allow blockchains to customize at compile time. If you build your own chain and import x/wasm, you can adjust a few items via module parameters, but a few others did not fit in that, as they need to be used by stateless ValidateBasic(). Thus, we made them as flags and set them in start.go so that they can be overridden on your custom chain.

```shell
sh scripts/init.sh
rollappd start --max-label-size 64 --max-wasm-size 2048000 --max-wasm-proposal-size 2048000
```

Those flags are optional, the default value was set as:

```go
wasmtypes.MaxLabelSize = 128
wasmtypes.MaxWasmSize = 819200
wasmtypes.MaxProposalWasmSize = 3145728
```

### Download cw20-ics20 smartcontract
Expand Down
8 changes: 0 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -285,13 +284,6 @@ func NewRollapp(
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)

if maxSize := os.Getenv("MAX_WASM_SIZE"); maxSize != "" {
// https://github.com/CosmWasm/wasmd#compile-time-parameters
val, _ := strconv.ParseInt(maxSize, 10, 32)
wasmtypes.MaxWasmSize = int(val)
wasmtypes.MaxProposalWasmSize = int(val)
}

// load state streaming if enabled
if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil {
panic("failed to load state streaming services: " + err.Error())
Expand Down
14 changes: 14 additions & 0 deletions rollappd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/dymensionxyz/dymension-rdk/utils"
rdklogger "github.com/dymensionxyz/dymension-rdk/utils/logger"
dymintconf "github.com/dymensionxyz/dymint/config"
Expand Down Expand Up @@ -62,6 +63,11 @@ const (
FlagDisableIAVLFastNode = "iavl-disable-fastnode"
FlagIAVLLazyLoading = "iavl-lazy-loading"

// wasm max bytes flags
FlagMaxLabelSize = "max-label-size"
FlagMaxWasmSize = "max-wasm-size"
FlagMaxProposalWasmSize = "max-proposal-wasm-size"

// state sync-related flags
FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval"
FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent"
Expand Down Expand Up @@ -178,6 +184,10 @@ which accepts a path for the resulting pprof file.
cmd.Flags().Uint(FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks")
cmd.Flags().Uint64(FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks")

cmd.Flags().Int(FlagMaxLabelSize, 128, "Maximum wasm label size")
cmd.Flags().Int(FlagMaxWasmSize, 819200, "Maximum wasm size")
cmd.Flags().Int(FlagMaxProposalWasmSize, 3145728, "Maximum wasm proposal size")

cmd.Flags().Bool(FlagAPIEnable, false, "Define if the API server should be enabled")
cmd.Flags().Bool(FlagAPISwagger, false, "Define if swagger documentation should automatically be registered (Note: the API must also be enabled)")
cmd.Flags().String(FlagAPIAddress, serverconfig.DefaultAPIAddress, "the API server address to listen on")
Expand Down Expand Up @@ -213,6 +223,10 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, nodeConfig *d
}
defer db.Close()

wasmtypes.MaxLabelSize = ctx.Viper.GetInt(FlagMaxLabelSize)
wasmtypes.MaxWasmSize = ctx.Viper.GetInt(FlagMaxWasmSize)
wasmtypes.MaxProposalWasmSize = ctx.Viper.GetInt(FlagMaxProposalWasmSize)

traceWriterFile := ctx.Viper.GetString(flagTraceStore)
traceWriter, err := utils.OpenTraceWriter(traceWriterFile)
if err != nil {
Expand Down

0 comments on commit 0b45283

Please sign in to comment.