Skip to content

Commit

Permalink
Merge pull request #1 from kjessec/pr/kjessec/36
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
beer-1 authored May 3, 2024
2 parents 8fb6e25 + 0c8a75b commit ac585e9
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 69 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# miniwasm
# MiniWasm

miniwasm is an optimistic rollup consumer chain powered by wasmvm. It is a framework designed to simplify the process of bootstrapping an L2 network. The main advantage of using miniwasm is that you can leverage the OPinit stack for enhanced security and utilize all the initia ecosystem tooling from day one, without the need to prepare a validator group or build your own ecosystem tools.
MiniWasm is an optimistic rollup consumer chain powered by WasmVM, designed to simplify the process of bootstrapping an L2 network. The main advantage of using MiniWasm is that the users can leverage the OPinit stack for enhanced security and utilize all the Initia ecosystem tooling from day one, without the need to prepare a validator group or build the users' own ecosystem tools.

## Prerequisites

- Go v1.22.2+

## Getting Started

To get started with L2, please visit the documentation.
To get started with L2, please visit the [documentation](https://initia.gitbook.io/initia-docs-v2/).

## Features

- Optimistic rollup consumer chain powered by wasmvm.
- Simplified network bootstrapping process.
- No need to prepare a validator group or build your own ecosystem tools.
- Enhanced security through the OPinit stack.
- Access to all initia ecosystem tools from day one.
- Powered by WasmVM, MiniWasm acts as an optimistic rollup consumer chain.
- Simplifies the network bootstrapping process, making it faster and more efficient.
- Eliminates the need for setting up a validator group or creating custom ecosystem tools.
- Integrates seamlessly with the OPinit stack, enhancing security.
- Provides immediate access to the full suite of Initia ecosystem tools right from the start.


## Contributing

Expand Down
20 changes: 17 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
Expand Down Expand Up @@ -972,9 +973,22 @@ func NewMinitiaApp(
}
err = msgservice.ValidateProtoAnnotations(protoFiles)
if err != nil {
// Once we switch to using protoreflect-based antehandlers, we might
// want to panic here instead of logging a warning.
fmt.Fprintln(os.Stderr, err.Error())
errMsg := ""

// ignore injective proto annotations comes from github.com/cosoms/relayer
for _, s := range strings.Split(err.Error(), "\n") {
if strings.Contains(s, "injective") {
continue
}

errMsg += s + "\n"
}

if errMsg != "" {
// Once we switch to using protoreflect-based antehandlers, we might
// want to panic here instead of logging a warning.
fmt.Fprintln(os.Stderr, errMsg)
}
}

// must be before Loading version
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41293,7 +41293,7 @@ paths:
- Query
/indexer/version:
get:
summary: Version queries all the collections of an account
summary: Version queries all the versions of the submodules
operationId: Versions
responses:
'200':
Expand Down Expand Up @@ -41340,6 +41340,7 @@ paths:
- Query
/indexer/vmtype:
get:
summary: VMType queries the type of the Minitia's VM
operationId: VMType
responses:
'200':
Expand Down Expand Up @@ -41488,7 +41489,7 @@ paths:
type: string
title: >-
Proposer represents the proposer of a block: for
minitia, its the L2 operator
minitia, it is the L2 operator
title: Block represents a indexed block in a blockchain
pagination:
description: pagination defines the pagination in the response.
Expand Down Expand Up @@ -41660,9 +41661,9 @@ paths:
type: string
title: >-
Proposer represents the proposer of a block: for minitia,
its the L2 operator
it is the L2 operator
title: Block represents a indexed block in a blockchain
description: BlockResponse defines the response for the Blocks RPC.
description: BlockResponse defines the response for the Block RPC.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -42203,7 +42204,7 @@ paths:
- Query
/indexer/tx/v1/txs/by_account/{account}:
get:
summary: TxsByAccount queries all the collections of given account
summary: TxsByAccount queries all transactions of given account
operationId: TxsByAccount
responses:
'200':
Expand Down Expand Up @@ -42716,7 +42717,7 @@ paths:
- Query
/indexer/tx/v1/txs/by_height/{height}:
get:
summary: TxsByHeight queries all the collections of given height
summary: TxsByHeight queries all transactions of given height
operationId: TxsByHeight
responses:
'200':
Expand Down Expand Up @@ -44216,7 +44217,7 @@ paths:
- Query
/indexer/pair/v1/pairs:
get:
summary: Pairs queries all the collections of an account
summary: Pairs queries all the pairs of L1 and L2
operationId: Pairs
responses:
'200':
Expand Down Expand Up @@ -70460,7 +70461,7 @@ definitions:
operator_address:
type: string
title: >-
Proposer represents the proposer of a block: for minitia, its the L2
Proposer represents the proposer of a block: for minitia, it is the L2
operator
title: Block represents a indexed block in a blockchain
indexer.block.v1.BlockResponse:
Expand Down Expand Up @@ -70523,10 +70524,10 @@ definitions:
operator_address:
type: string
title: >-
Proposer represents the proposer of a block: for minitia, its the
L2 operator
Proposer represents the proposer of a block: for minitia, it is
the L2 operator
title: Block represents a indexed block in a blockchain
description: BlockResponse defines the response for the Blocks RPC.
description: BlockResponse defines the response for the Block RPC.
indexer.block.v1.BlocksResponse:
type: object
properties:
Expand Down Expand Up @@ -70589,7 +70590,7 @@ definitions:
operator_address:
type: string
title: >-
Proposer represents the proposer of a block: for minitia, its
Proposer represents the proposer of a block: for minitia, it is
the L2 operator
title: Block represents a indexed block in a blockchain
pagination:
Expand Down Expand Up @@ -70627,7 +70628,7 @@ definitions:
operator_address:
type: string
title: >-
Proposer represents the proposer of a block: for minitia, its the L2
Proposer represents the proposer of a block: for minitia, it is the L2
operator
indexer.tx.v1.QueryTxResponse:
type: object
Expand Down
7 changes: 4 additions & 3 deletions cmd/minitiad/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"encoding/json"
"os"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -12,7 +14,6 @@ import (
minitiaapp "github.com/initia-labs/miniwasm/app"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"os"
)

// DefaultLaunchStepFactories is a list of default launch step factories.
Expand Down Expand Up @@ -50,9 +51,9 @@ var DefaultLaunchStepFactories = []launchtools.LauncherStepFuncFactory[launchtoo
steps.StopApp,
}

func LaunchCommand(ac appCreator, enc params.EncodingConfig, mbm module.BasicManager) *cobra.Command {
func LaunchCommand(ac *appCreator, enc params.EncodingConfig, mbm module.BasicManager) *cobra.Command {
return launchtools.LaunchCmd(
ac.newApp,
ac,
func(denom string) map[string]json.RawMessage {
return minitiaapp.NewDefaultGenesisState(enc.Codec, mbm, denom)
},
Expand Down
50 changes: 33 additions & 17 deletions cmd/minitiad/root.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package main

import (
"context"
"errors"
"io"
"os"
"path"

tmcli "github.com/cometbft/cometbft/libs/cli"
"golang.org/x/sync/errgroup"

"github.com/prometheus/client_golang/prometheus"

Expand Down Expand Up @@ -63,7 +65,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
sdkConfig.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
sdkConfig.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
sdkConfig.SetAddressVerifier(wasmtypes.VerifyAddressLen())
//sdkConfig.Seal()

// seal moved to post setup
// sdkConfig.Seal()

encodingConfig := minitiaapp.MakeEncodingConfig()
basicManager := minitiaapp.BasicManager()
Expand Down Expand Up @@ -145,17 +149,23 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, basicManager module.BasicManager) {
a := appCreator{encodingConfig}
a := &appCreator{}

rootCmd.AddCommand(
InitCmd(basicManager, minitiaapp.DefaultNodeHome),
debug.Cmd(),
confixcmd.ConfigCommand(),
pruning.Cmd(a.newApp, minitiaapp.DefaultNodeHome),
snapshot.Cmd(a.newApp),
pruning.Cmd(a.AppCreator(), minitiaapp.DefaultNodeHome),
snapshot.Cmd(a.AppCreator()),
)

server.AddCommands(rootCmd, minitiaapp.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags)
server.AddCommandsWithStartCmdOptions(rootCmd, minitiaapp.DefaultNodeHome, a.AppCreator(), a.appExport, server.StartCmdOptions{
AddFlags: addModuleInitFlags,
PostSetup: func(svrCtx *server.Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error {
sdk.GetConfig().Seal()
return nil
},
})
wasmcli.ExtendUnsafeResetAllCmd(rootCmd)

// add keybase, auxiliary RPC, query, and tx child commands
Expand Down Expand Up @@ -244,24 +254,30 @@ func txCommand() *cobra.Command {
}

type appCreator struct {
encodingConfig params.EncodingConfig
app servertypes.Application
}

// newApp is an AppCreator
func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts)
func (a *appCreator) AppCreator() servertypes.AppCreator {
return func(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts)

var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}

var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
return minitiaapp.NewMinitiaApp(
logger, db, traceStore, true,
wasmOpts,
appOpts,
baseappOptions...,
)
}
}

return minitiaapp.NewMinitiaApp(
logger, db, traceStore, true,
wasmOpts,
appOpts,
baseappOptions...,
)
func (a *appCreator) App() servertypes.Application {
return a.app
}

func (a appCreator) appExport(
Expand Down
17 changes: 5 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.3
github.com/initia-labs/OPinit v0.2.6
github.com/initia-labs/OPinit v0.2.7
github.com/initia-labs/initia v0.2.7
github.com/initia-labs/kvindexer v0.1.2
github.com/initia-labs/kvindexer v0.1.3
github.com/initia-labs/kvindexer/submodules/block v0.1.0
github.com/initia-labs/kvindexer/submodules/tx v0.1.0
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.1
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.2
github.com/initia-labs/kvindexer/submodules/wasm-pair v0.1.0
github.com/noble-assets/forwarding v0.0.0-20240416085758-ed8e9efaf69a
github.com/pkg/errors v0.9.1
Expand All @@ -51,13 +51,12 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
golang.org/x/sync v0.7.0
google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.0
)

require github.com/initia-labs/minimove v0.2.8

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
Expand All @@ -71,8 +70,6 @@ require (
github.com/99designs/keyring v1.2.2 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/IGLOU-EU/go-wildcard v1.0.3 // indirect
github.com/aptos-labs/serde-reflection/serde-generate/runtime/golang v0.0.0-20231213012317-73b6bbf74833 // indirect
github.com/avast/retry-go/v4 v4.5.1 // indirect
github.com/aws/aws-sdk-go v1.44.312 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -168,9 +165,6 @@ require (
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/initia-labs/OPinit/api v0.2.6 // indirect
github.com/initia-labs/kvindexer/submodules/move-nft v0.1.1 // indirect
github.com/initia-labs/kvindexer/submodules/move-pair v0.1.0 // indirect
github.com/initia-labs/movevm v0.2.7 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/jsternberg/zap-logfmt v1.3.0 // indirect
Expand Down Expand Up @@ -232,7 +226,6 @@ require (
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down Expand Up @@ -271,7 +264,7 @@ replace (
// initia custom
replace (
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240425025334-db711cb7c25d
github.com/cosmos/cosmos-sdk => github.com/initia-labs/cosmos-sdk v0.0.0-20240425031032-6bc18cf6e67d
github.com/cosmos/cosmos-sdk => github.com/initia-labs/cosmos-sdk v0.0.0-20240502043911-a4bdb8e06769
github.com/cosmos/iavl => github.com/initia-labs/iavl v0.0.0-20240415085037-7e81233cdd9e
github.com/cosmos/ibc-go/v8 => github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c
github.com/skip-mev/slinky => github.com/initia-labs/slinky v0.0.0-20240418051646-d45167cc66b1
Expand Down
Loading

0 comments on commit ac585e9

Please sign in to comment.