Skip to content

Commit

Permalink
feat: upgrades + audit fixes (#97)
Browse files Browse the repository at this point in the history
* prepare upgrade

* delete cosmwasm address validation

* fix amino

* delete delegation-related functions

* bump kvdexer/submodules/tx

* bump ibc-go pfm

* update swagger

* remove pull request from docker workflow trigger

* return error ack when the packet is wasm routed but has error at decoding

* pass image version at docker build

* fix docker file to set version

* bump initia to latest

* add missed docker env

---------

Co-authored-by: sh-cha <[email protected]>
Co-authored-by: Geoff Lee <[email protected]>
  • Loading branch information
3 people authored Mar 5, 2025
1 parent a1c4a60 commit dd08703
Show file tree
Hide file tree
Showing 21 changed files with 487 additions and 700 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ on:
- "**.go"
- "go.mod"
- "go.sum"
pull_request:
branches:
- "main"
paths:
- "**.go"
- "go.mod"
- "go.sum"

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -64,3 +57,5 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha
env:
VERSION: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/li
RUN cp /lib/libwasmvm_muslc.`uname -m`.a /lib/libwasmvm_muslc.a

# force it to use static lib (from above) not standard libwasmvm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS="-linkmode=external -extldflags \"-L/code/mimalloc/build -lmimalloc -Wl,-z,muldefs -static\"" make build
RUN VERSION=${VERSION} LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS="-linkmode=external -extldflags \"-L/code/mimalloc/build -lmimalloc -Wl,-z,muldefs -static\"" make build

FROM alpine:3.18

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt install -y vim
WORKDIR /code
COPY . /code/

RUN LEDGER_ENABLED=false make build
RUN VERSION=${VERSION} LEDGER_ENABLED=false make build

RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm/v2@v*/internal/api/libwasmvm.`uname -m`.so /lib/libwasmvm.so

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ endif
build-linux:
mkdir -p $(BUILDDIR)
docker build --no-cache --tag initia/minimwasm ./
docker create --name temp initia/minimwasm:latest
docker create --name temp initia/minimwasm:latest --env VERSION=$(VERSION)
docker cp temp:/usr/local/bin/minitiad $(BUILDDIR)/
docker rm temp

build-linux-with-shared-library:
mkdir -p $(BUILDDIR)
docker build --tag initia/miniwasm-shared ./ -f ./shared.Dockerfile
docker create --name temp initia/miniwasm-shared:latest
docker create --name temp initia/miniwasm-shared:latest --env VERSION=$(VERSION)
docker cp temp:/usr/local/bin/minitiad $(BUILDDIR)/
docker cp temp:/lib/libwasmvm.so $(BUILDDIR)/
docker rm temp
Expand Down
131 changes: 66 additions & 65 deletions api/miniwasm/tokenfactory/v1/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ import (

// local imports
"github.com/initia-labs/miniwasm/app/keepers"
"github.com/skip-mev/block-sdk/v2/block"
blockservice "github.com/skip-mev/block-sdk/v2/block/service"

// kvindexer
kvindexermodule "github.com/initia-labs/kvindexer/x/kvindexer"
Expand Down Expand Up @@ -493,6 +495,9 @@ func (app *MinitiaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.AP
// Register node gRPC service for grpc-gateway.
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register the Block SDK mempool API routes.
blockservice.RegisterGRPCGatewayRoutes(apiSvr.ClientCtx, apiSvr.GRPCGatewayRouter)

// Register grpc-gateway routes for all modules.
app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

Expand Down Expand Up @@ -520,6 +525,14 @@ func (app *MinitiaApp) RegisterTxService(clientCtx client.Context) {
app.BaseApp.GRPCQueryRouter(), clientCtx,
app.Simulate, app.interfaceRegistry,
)

// Register the Block SDK mempool transaction service.
mempool, ok := app.Mempool().(block.Mempool)
if !ok {
panic("mempool is not a block.Mempool")
}

blockservice.RegisterMempoolService(app.GRPCQueryRouter(), mempool)
}

// RegisterTendermintService implements the Application.RegisterTendermintService method.
Expand Down
1 change: 1 addition & 0 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (genState GenesisState) ConfigureMinGasPrices(cdc codec.JSONCodec) GenesisS
var opChildGenState opchildtypes.GenesisState
cdc.MustUnmarshalJSON(genState[opchildtypes.ModuleName], &opChildGenState)
opChildGenState.Params.MinGasPrices = nil
opChildGenState.Params.HookMaxGas = 3_000_000
genState[opchildtypes.ModuleName] = cdc.MustMarshalJSON(&opChildGenState)

return genState
Expand Down
4 changes: 2 additions & 2 deletions app/ibc-hooks/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (h WasmHooks) onRecvIcs20Packet(
data transfertypes.FungibleTokenPacketData,
) ibcexported.Acknowledgement {
isWasmRouted, hookData, err := validateAndParseMemo(data.GetMemo())
if !isWasmRouted || hookData.Message == nil {
if !isWasmRouted || (err == nil && hookData.Message == nil) {
return im.App.OnRecvPacket(ctx, packet, relayer)
} else if err != nil {
return newEmitErrorAcknowledgement(err)
Expand Down Expand Up @@ -91,7 +91,7 @@ func (h WasmHooks) onRecvIcs721Packet(
data nfttransfertypes.NonFungibleTokenPacketData,
) ibcexported.Acknowledgement {
isWasmRouted, hookData, err := validateAndParseMemo(data.GetMemo())
if !isWasmRouted || hookData.Message == nil {
if !isWasmRouted || (err == nil && hookData.Message == nil) {
return im.App.OnRecvPacket(ctx, packet, relayer)
} else if err != nil {
return newEmitErrorAcknowledgement(err)
Expand Down
2 changes: 0 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ func NewAppKeeper(
appKeepers.keys[packetforwardtypes.StoreKey],
appKeepers.TransferKeeper,
appKeepers.IBCKeeper.ChannelKeeper,
communityPoolKeeper,
appKeepers.BankKeeper,
// ics4wrapper: transfer -> packet forward -> rate limit
rateLimitKeeper,
Expand All @@ -410,7 +409,6 @@ func NewAppKeeper(
appKeepers.PacketForwardKeeper,
0,
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

// create the rate limit keeper
Expand Down
4 changes: 2 additions & 2 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
)

const upgradeName = "0.6.4"
const upgradeName = "0.7.1"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *MinitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) {
Expand All @@ -32,7 +32,7 @@ func (app *MinitiaApp) RegisterUpgradeHandlers(cfg module.Configurator) {
}
}

return vm, nil
return app.ModuleManager.RunMigrations(ctx, cfg, vm)
},
)
}
11 changes: 11 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@
"Params": "MarketMapParams"
}
}
},
{
"url": "./tmp-swagger-gen/sdk/auction/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "AuctionParams"
}
}
},
{
"url": "./tmp-swagger-gen/sdk/mempool/v1/query.swagger.json"
}
]
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit dd08703

Please sign in to comment.