Skip to content

Commit

Permalink
Add Token Factory and upgrade IBC to 7.4.0 (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
froch authored Apr 16, 2024
2 parents a9bb0f5 + 8f15878 commit cb185b4
Show file tree
Hide file tree
Showing 26 changed files with 938 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aws-ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: xion-release
target: release
4 changes: 2 additions & 2 deletions .github/workflows/docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: xion-release
target: release

build-dev:
name: Build Dev Image
Expand Down Expand Up @@ -90,4 +90,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: xion-dev
target: dev
2 changes: 1 addition & 1 deletion .github/workflows/docker-scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: xion-release
target: release

- name: Run Docker Scout
uses: docker/scout-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --timeout 10m
args: --timeout=10m --tests=false
61 changes: 61 additions & 0 deletions .github/workflows/heighliner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Heighliner Build

on:
push:
branches:
- main
tags:
- '*'
pull_request:
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
heighliner:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest

steps:

- name: checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: container-login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for docker using shell
id: shell_meta
run: |
SHA=$(git rev-parse --short HEAD)
echo "SHA=$SHA" >> $GITHUB_ENV
echo "::set-output name=sha::sha-$SHA"
- name: Build Heighliner image
id: heighliner
uses: burnt-labs/[email protected]
with:
local: true
tag: ${{ steps.shell_meta.outputs.sha }}
chain: xion
github-organization: burnt-labs
github-repo: xion
dockerfile: cosmos
build-target: make install
binaries: '["/go/bin/xiond"]'
build-env: '["BUILD_TAGS=muslc"]'

- name: Push Heighliner image
run: |
docker tag ${{ steps.heighliner.outputs.tag }} ghcr.io/burnt-labs/xion/${{ steps.heighliner.outputs.tag }}
docker push ghcr.io/burnt-labs/xion/${{ steps.heighliner.outputs.tag }}
80 changes: 36 additions & 44 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
FROM golang:1.21-alpine3.18 AS go-builder
ARG arch=x86_64
# syntax=docker/dockerfile:1

ENV WASMVM_VERSION=v1.5.2
ENV WASMVM_CHECKSUM_AARCH64=e78b224c15964817a3b75a40e59882b4d0e06fd055b39514d61646689cef8c6e
ENV WASMVM_CHECKSUM_x86_64=e660a38efb2930b34ee6f6b0bb12730adccb040b6ab701b8f82f34453a426ae7
# --------------------------------------------------------
# Builder
# --------------------------------------------------------

RUN set -euxo pipefail \
&& apk add --no-cache \
ca-certificates \
FROM golang:1.21-alpine3.18 AS builder

RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers \
git

# NOTE: add these to run with LEDGER_ENABLED=true
# RUN apk add libusb-dev linux-headers

WORKDIR /code
COPY go.mod /code/
COPY go.sum /code/
RUN go mod download

COPY ./.git /code/.git
COPY ./app /code/app
COPY ./cmd /code/cmd
COPY ./contrib /code/contrib
COPY ./proto /code/proto
COPY ./x /code/x
COPY ./wasmbindings /code/wasmbindings
COPY Makefile /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep ${WASMVM_CHECKSUM_AARCH64}
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ${WASMVM_CHECKSUM_x86_64}

# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
RUN cp -vf /lib/libwasmvm_muslc.${arch}.a /lib/libwasmvm_muslc.a

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN set -eux \
&& make test-version \
&& LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build

RUN echo "Ensuring binary is statically linked ..." \
&& (file /code/build/xiond | grep "statically linked")
# Download go dependencies
WORKDIR /xion
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1)

# Build xiond binary
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
make test-version \
&& LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build

# --------------------------------------------------------
# Runner
# --------------------------------------------------------

FROM alpine:3.19.1 AS xion-base
COPY --from=go-builder /code/build/xiond /usr/bin/xiond
COPY --from=builder /xion/build/xiond /usr/bin/xiond

# api
EXPOSE 1317
Expand All @@ -72,15 +64,15 @@ RUN set -euxo pipefail \
tini

# --------------------------------------------------------
FROM xion-base AS xion-dev
FROM xion-base AS dev

COPY ./docker/entrypoint.sh /home/xiond/entrypoint.sh
WORKDIR /home/xiond/

CMD ["/home/xiond/entrypoint.sh"]

# --------------------------------------------------------
FROM xion-base as xion-release
FROM xion-base AS release

RUN set -euxo pipefail \
&& addgroup -S xiond \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ test-integration-xion-token-factory: compile_integration_tests
test-integration-min:
@XION_IMAGE=$(XION_IMAGE) cd integration_tests && go test -v -run TestXionMinimumFeeDefault -mod=readonly -tags='ledger test_ledger_mock' ./...

test-integration-mig:
@XION_IMAGE=$(XION_IMAGE) cd integration_tests && go test -v -run TestAbstractAccountMigration -mod=readonly -tags='ledger test_ledger_mock' ./...

test-integration-web-auth-n-abstract-account: compile_integration_tests
@XION_IMAGE=$(XION_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run WebAuthNAbstractAccount

test-integration-upgrade:
@XION_IMAGE=$(XION_IMAGE) cd integration_tests && go test -v -run TestXionUpgradeIBC -mod=readonly -tags='ledger test_ledger_mock' ./...

test-integration-xion-mig: compile_integration_tests
@XION_IMAGE=$(XION_IMAGE) ./integration_tests/integration_tests.test -test.failfast -test.v -test.run TestAbstractAccountMigration

test-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...

Expand Down
26 changes: 16 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,6 @@ func NewWasmApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.XionKeeper = xionkeeper.NewKeeper(
appCodec,
keys[xiontypes.StoreKey],
app.GetSubspace(xiontypes.ModuleName),
app.BankKeeper,
app.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String())

// Configure the hooks keeper
hooksKeeper := ibchookskeeper.NewKeeper(
keys[ibchookstypes.StoreKey],
Expand Down Expand Up @@ -742,6 +734,20 @@ func NewWasmApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)
app.Ics20WasmHooks.ContractKeeper = &app.WasmKeeper

app.XionKeeper = xionkeeper.NewKeeper(
appCodec,
keys[xiontypes.StoreKey],
app.GetSubspace(xiontypes.ModuleName),
app.BankKeeper,
app.AccountKeeper,
app.ContractKeeper,
app.WasmKeeper,
app.AbstractAccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String())

// Set legacy router for backwards compatibility with gov v1beta1
app.GovKeeper.SetLegacyRouter(govRouter)

Expand Down Expand Up @@ -821,11 +827,11 @@ func NewWasmApp(
nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
xion.NewAppModule(app.XionKeeper),
jwk.NewAppModule(appCodec, app.JwkKeeper, app.GetSubspace(jwktypes.ModuleName)),
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
aa.NewAppModule(app.AbstractAccountKeeper),
xion.NewAppModule(app.XionKeeper),
ibc.NewAppModule(app.IBCKeeper),
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
Expand All @@ -851,7 +857,6 @@ func NewWasmApp(
vestingtypes.ModuleName, consensusparamtypes.ModuleName,
tokenfactorytypes.ModuleName,
globalfee.ModuleName,
xiontypes.ModuleName,
jwktypes.ModuleName,
// additional non simd modules
ibctransfertypes.ModuleName,
Expand All @@ -861,6 +866,7 @@ func NewWasmApp(
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
aatypes.ModuleName,
xiontypes.ModuleName,
ibchookstypes.ModuleName,
packetforwardtypes.ModuleName,
)
Expand Down
8 changes: 1 addition & 7 deletions app/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

/*
const NewDenomCreationGasConsume uint64 = 2_000_000
var DenomCreationFee = sdk.NewCoins(sdk.NewInt64Coin(`uxion`, 50_000_000))
*/

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand All @@ -24,7 +18,7 @@ func CreateUpgradeHandler(
return vm, err
}

ctx.Logger().Info("Upgrade complete")
ctx.Logger().Info("Upgrade v6 complete")
return vm, err
}
}
13 changes: 4 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,25 @@ version: "3.9"
services:

testnet:
image: burnt/xion:develop
build:
context: .
dockerfile: Dockerfile
target: xion-dev
target: dev
platform: linux/amd64
volumes:
- testnet-data:/xion/
ports:
- "1317:1317"
- "26656:26656"
- "26657:26657"

release:
image: burnt/xion:release
build:
context: .
dockerfile: Dockerfile
target: xion-release
target: release
platform: linux/amd64
volumes:
- testnet-data:/xion/data
ports:
- "1317:1317"
- "26656:26656"
- "26657:26657"

volumes:
testnet-data:
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/iavl v0.20.1 // indirect
github.com/cosmos/ibc-go/v7 v7.3.1
github.com/cosmos/ibc-go/v7 v7.4.0
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/dvsekhvalnov/jose2go v1.6.0
Expand All @@ -20,7 +20,6 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.16.0
github.com/rakyll/statik v0.1.7 // indirect
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5 // indirect
Expand Down Expand Up @@ -57,13 +56,11 @@ require (
)

require (
github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 // indirect
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/skip-mev/pob v1.0.4 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
Expand Down Expand Up @@ -218,6 +215,9 @@ require (

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

github.com/CosmWasm/wasmd => github.com/burnt-labs/wasmd v0.45.1-0.20240312170141-3dfd94af17a8

github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 => github.com/burnt-labs/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3-0.20240308232808-736bd51c54ad
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
// See: https://github.com/cosmos/cosmos-sdk/issues/13134
Expand Down
Loading

0 comments on commit cb185b4

Please sign in to comment.