Skip to content

Commit

Permalink
Merge pull request #41 from ODIN-PROTOCOL/feature/add-cosmwasm
Browse files Browse the repository at this point in the history
Feature/add cosmwasm
  • Loading branch information
Satchitananda authored Jul 25, 2024
2 parents 52110ae + e6176ba commit 40e6025
Show file tree
Hide file tree
Showing 21 changed files with 751 additions and 249 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.ci
file: ./Dockerfile.static
push: true
tags: odinprotocol/core:${{ env.GITHUB_REF_SLUG }}

- name: Build and push docker container latest
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.ci
file: ./Dockerfile.static
push: true
tags: odinprotocol/core:latest

Expand Down
15 changes: 11 additions & 4 deletions Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ WORKDIR /chain
COPY . /chain

RUN go mod download
RUN GO_OWASM_VERSION=$(go list -m github.com/odin-protocol/go-owasm | cut -d ' ' -f 2) && \
wget https://github.com/odin-protocol/go-owasm/releases/download/$GO_OWASM_VERSION/libgo_owasm_muslc.x86_64.a -O /lib/libgo_owasm_muslc.x86_64.a
RUN sha256sum /lib/libgo_owasm_muslc.x86_64.a | grep 52b43f1d1ee7f93eba2316b0dd0ba5bd8eefbf93b11bc7b44447b91a694dc74e
#RUN GO_OWASM_VERSION=$(go list -m github.com/odin-protocol/go-owasm | cut -d ' ' -f 2) && \
# wget https://github.com/odin-protocol/go-owasm/releases/download/$GO_OWASM_VERSION/libgo_owasm_muslc.x86_64.a -O /lib/libgo_owasm_muslc.x86_64.a
#RUN sha256sum /lib/libgo_owasm_muslc.x86_64.a | grep b4ebce01c2c742c32ba0312793ea3936e4738c50362a631a47b1e42bff878e5d

# Copy the library you want to the final location that will be found by the linker flag `-lgo_owasm_muslc`
RUN cp /lib/libgo_owasm_muslc.x86_64.a /lib/libgo_owasm_muslc.a
#RUN cp /lib/libgo_owasm_muslc.x86_64.a /lib/libgo_owasm_muslc.a

ADD https://github.com/ODIN-PROTOCOL/wasmvm/releases/download/v2.0.18/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/ODIN-PROTOCOL/wasmvm/releases/download/v2.0.18/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
#RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 860ba8d7ee4c89c1b0dc3abd4b3658d07ddf5531d2de970cada0699689cc1e33
#RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 85de2ab3c40236935dbd023c9211130d49c5464494c4b9b09ea33e27a2d6bf87

# force it to use static lib (from above) not standard libgo_owasm.so file
RUN LEDGER_ENABLED=true BUILD_TAGS=muslc LINK_STATICALLY=true make install \
&& echo "Ensuring binary is statically linked ..." \
&& (file /go/bin/odind | grep "statically linked")

#RUN go test ./...

# --------------------------------------------------------
FROM alpine:3.16

Expand Down
35 changes: 19 additions & 16 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package odin

import (
corestoretypes "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
circuitante "cosmossdk.io/x/circuit/ante"
oraclekeeper "github.com/ODIN-PROTOCOL/odin-core/x/oracle/keeper"
wasmkeeper "github.com/ODIN-PROTOCOL/wasmd/x/wasm/keeper"
wasmtypes "github.com/ODIN-PROTOCOL/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -16,13 +19,13 @@ import (
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions
OracleKeeper *oraclekeeper.Keeper
IBCKeeper *ibckeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
CircuitKeeper circuitante.CircuitBreaker
//WasmKeeper *wasmkeeper.Keeper
//WasmConfig *wasmtypes.WasmConfig
//TXCounterStoreKey storetypes.StoreKey
OracleKeeper *oraclekeeper.Keeper
IBCKeeper *ibckeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
CircuitKeeper circuitante.CircuitBreaker
WasmKeeper *wasmkeeper.Keeper
WasmConfig *wasmtypes.WasmConfig
TXCounterStoreKey corestoretypes.KVStoreService
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
Expand All @@ -44,12 +47,12 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.StakingKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "Staking keeper is required for AnteHandler")
}
//if options.WasmConfig == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
//}
//if options.TXCounterStoreKey == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
//}
if options.WasmConfig == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
}
if options.TXCounterStoreKey == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
if sigGasConsumer == nil {
Expand All @@ -59,9 +62,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first(),
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
//wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
//wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
//wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
Loading

0 comments on commit 40e6025

Please sign in to comment.