Skip to content

Commit

Permalink
fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Mar 6, 2024
1 parent 6add3b2 commit 8ca4e2e
Show file tree
Hide file tree
Showing 35 changed files with 1,501 additions and 4,226 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
WASM_DIR: ./wasmchain
MOVE_DIR: ./movechain

jobs:
golangci:
env:
Expand Down
137 changes: 137 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,145 @@
#!/usr/bin/make -f

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
DOCKER := $(shell which docker)
CONTRACTS_DIR = ./x/evm/contracts

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')

export GO111MODULE = on

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
build_tags += gcc
endif
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
build_tags += rocksdb
endif
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
build_tags += boltdb
endif

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=minitia \
-X github.com/cosmos/cosmos-sdk/version.AppName=mminitiad \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb
endif
# handle rocksdb
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
$(info ################################################################)
$(info To use rocksdb, you need to install rocksdb first)
$(info Please follow this guide https://github.com/rockset/rocksdb-cloud/blob/master/INSTALL.md)
$(info ################################################################)
CGO_ENABLED=1
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
endif
# handle boltdb
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb
endif

ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

# The below include contains the tools and runsim targets.
include contrib/devtools/Makefile

all: tools install lint test

build: go.sum
ifeq ($(OS),Windows_NT)
exit 1
else
go build -mod=readonly $(BUILD_FLAGS) -o build/minitiad ./cmd/minitiad
endif

build-linux:
mkdir -p $(BUILDDIR)
docker build --no-cache --tag initia/minievm ./
docker create --name temp initia/minievm:latest
docker cp temp:/usr/local/bin/minievm $(BUILDDIR)/
docker rm temp

install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/minitiad

update-swagger-docs: statik
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m
@if [ -n "$(git status --porcelain)" ]; then \
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
exit 1;\
else \
echo "\033[92mSwagger docs are in sync\033[0m";\
fi

.PHONY: build build-linux install update-swagger-docs

###############################################################################
### Protobuf ###
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# miniwasm
# minievm

optimistic rollup consumer chain with evm.
17 changes: 14 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -339,15 +340,14 @@ func NewMinitiaApp(
)
app.AccountKeeper = &accountKeeper

bankKeeper := bankkeeper.NewBaseKeeper(
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
app.AccountKeeper,
app.ModuleAccountAddrs(),
authorityAddr,
logger,
)
app.BankKeeper = &bankKeeper

communityPoolKeeper := appkeepers.NewCommunityPoolKeeper(app.BankKeeper, authtypes.FeeCollectorName)

Expand Down Expand Up @@ -617,7 +617,7 @@ func NewMinitiaApp(
app.IBCKeeper.SetRouter(ibcRouter)

//////////////////////////////
// WasmKeeper Configuration //
// EVMKeeper Configuration //
//////////////////////////////
evmConfig := evmconfig.GetConfig(appOpts)

Expand Down Expand Up @@ -1120,3 +1120,14 @@ func (app *MinitiaApp) ChainID() string { // TODO: remove this method once chain
field := reflect.ValueOf(app.BaseApp).Elem().FieldByName("chainID")
return field.String()
}

// allow 20 and 32 bytes address
func VerifyAddressLen() func(addr []byte) error {
return func(addr []byte) error {
addrLen := len(addr)
if addrLen != 32 && addrLen != 20 {
return sdkerrors.ErrInvalidAddress
}
return nil
}
}
5 changes: 2 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ import (
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/x/upgrade"
"github.com/cosmos/cosmos-sdk/testutil/mock"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/consensus"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/ibc-go/modules/capability"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

"cosmossdk.io/x/upgrade"
"github.com/cosmos/cosmos-sdk/x/bank"

ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
Expand Down
5 changes: 4 additions & 1 deletion app/hook/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hook
import (
"context"
"encoding/json"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand All @@ -21,7 +22,9 @@ func NewEVMBridgeHook(evmKeeper *evmkeeper.Keeper) EVMBridgeHook {

func (mbh EVMBridgeHook) Hook(ctx context.Context, sender sdk.AccAddress, msgBytes []byte) error {
msg := evmtypes.MsgCall{}
err := json.Unmarshal(msgBytes, &msg)
decoder := json.NewDecoder(strings.NewReader(string(msgBytes)))
decoder.DisallowUnknownFields()
err := decoder.Decode(&msg)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions app/ibc-middleware/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func isIcs20Packet(packet channeltypes.Packet) (isIcs20 bool, ics20data transfer
return true, data
}

func validateAndParseMemo(memo, receiver string) (isWasmRouted bool, msg evmtypes.MsgCall, err error) {
isWasmRouted, metadata := jsonStringHasKey(memo, "evm")
if !isWasmRouted {
func validateAndParseMemo(memo, receiver string) (isEVMRouted bool, msg evmtypes.MsgCall, err error) {
isEVMRouted, metadata := jsonStringHasKey(memo, "evm")
if !isEVMRouted {
return
}

Expand Down
18 changes: 9 additions & 9 deletions app/ibc-middleware/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ import (
func Test_validateAndParseMemo(t *testing.T) {
memo := `
{
"wasm" : {
"evm" : {
"sender": "init_addr",
"contract_addr": "contract_addr",
"input": {}
"input": ""
}
}`
isWasmRouted, msg, err := validateAndParseMemo(memo, "contract_addr")
require.True(t, isWasmRouted)
isEVMRouted, msg, err := validateAndParseMemo(memo, "contract_addr")
require.True(t, isEVMRouted)
require.NoError(t, err)
require.Equal(t, evmtypes.MsgCall{
Sender: "init_addr",
ContractAddr: "contract_addr",
Input: []byte("{}"),
Input: []byte(""),
}, msg)

// invalid receiver
isWasmRouted, _, err = validateAndParseMemo(memo, "invalid_addr")
require.True(t, isWasmRouted)
isEVMRouted, _, err = validateAndParseMemo(memo, "invalid_addr")
require.True(t, isEVMRouted)
require.Error(t, err)

isWasmRouted, _, err = validateAndParseMemo("hihi", "invalid_addr")
require.False(t, isWasmRouted)
isEVMRouted, _, err = validateAndParseMemo("hihi", "invalid_addr")
require.False(t, isEVMRouted)
require.NoError(t, err)
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion client/statik/statik.go → client/docs/statik/statik.go

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8ca4e2e

Please sign in to comment.