Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Xion integration #15

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ prepare-contracts:

.PHONY: build-images
build-images:
$(MAKE) -C ./tests/e2e/chains/tendermint image
$(MAKE) -C ./tests/e2e/chains/xion image
$(MAKE) -C ./tests/e2e/chains/bsc build

.PHONY: e2e-test
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/cases/tm2bsc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ RLY_BIN ?= ../../../../bin/yrly
network:
sleep 10
$(MAKE) -C ../../chains/bsc bootstrap
$(MAKE) -C ../../chains/tendermint network
$(MAKE) -C ../../chains/xion network
$(MAKE) -C ../../chains/bsc network
sleep 30
$(MAKE) -C ../../chains/bsc deploy extract-abi

.PHONY: network-down
network-down:
$(MAKE) -C ../../chains/tendermint network-down
$(MAKE) -C ../../chains/xion network-down
$(MAKE) -C ../../chains/bsc network-down

.PHONY: setup
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cases/tm2bsc/configs/templates/ibc-0.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"key": "testkey",
"chain_id": "ibc0",
"rpc_addr": "http://localhost:26657",
"account_prefix": "cosmos",
"account_prefix": "xion",
"gas_adjustment": 1.5,
"gas_prices": "0.025stake",
"average_block_time_msec": 1000,
Expand Down
43 changes: 43 additions & 0 deletions tests/e2e/cases/tm2bsc/configs/templates/ibc-0.json.tpl.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"chain": {
"@type": "/relayer.chains.tendermint.config.ChainConfig",
"key": "testkey",
"chain_id": "ibc0",
"rpc_addr": "http://localhost:26657",
"account_prefix": "cosmos",
"gas_adjustment": 1.5,
"gas_prices": "0.025stake",
"average_block_time_msec": 1000,
"max_retry_for_commit": 5
},
"prover": {
"@type": "/relayer.provers.lcp.config.ProverConfig",
"origin_prover": {
"@type": "/relayer.chains.tendermint.config.ProverConfig",
"trusting_period": "336h",
"refresh_threshold_rate": {
"numerator": 2,
"denominator": 3
}
},
"lcp_service_address": "localhost:50051",
"mrenclave": $MRENCLAVE,
"allowed_quote_statuses": ["GROUP_OUT_OF_DATE","SW_HARDENING_NEEDED"],
"allowed_advisory_ids": ["INTEL-SA-00219","INTEL-SA-00289","INTEL-SA-00334","INTEL-SA-00477","INTEL-SA-00614","INTEL-SA-00615","INTEL-SA-00617", "INTEL-SA-00828"],
"key_expiration": 604800,
"elc_client_id": "07-tendermint-1",
"message_aggregation": true,
"is_debug_enclave": true,
"operators": [
"0xcb96F8d6C2d543102184d679D7829b39434E4EEc"
],
"operator_signer": {
"@type": "/relayer.provers.lcp.signers.raw.SignerConfig",
"private_key": "0x99b107441d0bce8e5b0078450f10f309910d8c0a2cc91671bd6cc1a284809642"
},
"operators_eip712_evm_chain_params": {
"chain_id": 9999,
"verifying_contract_address": $LC_ADDRESS
}
}
}
2 changes: 1 addition & 1 deletion tests/e2e/cases/tm2bsc/scripts/fixture
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ mkdir -p ${FIXTURES_DIR}/tendermint/ibc0
set -x

## copy tendermint's node mnemonic from node container
${DOCKER} cp tendermint-chain:/root/data/ibc0/key_seed.json ${FIXTURES_DIR}/tendermint/ibc0/key_seed.json
${DOCKER} cp xion-chain:/root/data/ibc0/key_seed.json ${FIXTURES_DIR}/tendermint/ibc0/key_seed.json
90 changes: 90 additions & 0 deletions tests/e2e/chains/xion/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
ARG GO_VERSION="1.23.2"
ARG ALPINE_VERSION="3.20"

# --------------------------------------------------------
# Builder
# --------------------------------------------------------

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder

# Always set by buildkit
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETOS
ARG XIOND_BINARY

# needed in makefile
ARG COMMIT
ARG VERSION

# Consume Args to env
ENV COMMIT=${COMMIT} \
VERSION=${VERSION} \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
XIOND_BINARY=${XIOND_BINARY}

# Install dependencies
RUN set -eux; \
apk add --no-cache \
build-base \
ca-certificates \
linux-headers \
binutils-gold \
git \
jq \
bash

# Set the workdir
COPY . /root/
WORKDIR /root

# Download go dependencies
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/pkg/mod \
set -eux; \
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0; \
go mod download

# Cosmwasm - Download correct libwasmvm version
RUN set -eux; \
WASMVM_REPO="github.com/CosmWasm/wasmvm"; \
WASMVM_MOD_VERSION="$(grep ${WASMVM_REPO} go.mod | cut -d ' ' -f 1)"; \
WASMVM_VERSION="$(go list -m ${WASMVM_MOD_VERSION} | cut -d ' ' -f 2)"; \
[ ${TARGETPLATFORM} = "linux/amd64" ] && LIBWASM="libwasmvm_muslc.x86_64.a"; \
[ ${TARGETPLATFORM} = "linux/arm64" ] && LIBWASM="libwasmvm_muslc.aarch64.a"; \
[ ${TARGETOS} = "darwin" ] && LIBWASM="libwasmvmstatic_darwin.a"; \
[ -z "$LIBWASM" ] && echo "Arch ${TARGETARCH} not recognized" && exit 1; \
wget "https://${WASMVM_REPO}/releases/download/${WASMVM_VERSION}/${LIBWASM}" -O "/lib/${LIBWASM}"; \
# verify checksum
EXPECTED=$(wget -q "https://${WASMVM_REPO}/releases/download/${WASMVM_VERSION}/checksums.txt" -O- | grep "${LIBWASM}" | awk '{print $1}'); \
sha256sum "/lib/${LIBWASM}" | grep "${EXPECTED}"; \
cp /lib/${LIBWASM} /lib/libwasmvm_muslc.a;

# Build xiond binary
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/pkg/mod \
if [ -e "${XIOND_BINARY:-}" ]; then \
cp "${XIOND_BINARY}" /go/bin/xiond; \
else \
export CGO_ENABLED=1 LINK_STATICALLY=true BUILD_TAGS=muslc; \
make test-version; \
make install; \
fi

WORKDIR /root/app

ARG CHAINID
ARG CHAINDIR=/root/data
ARG RPCPORT=26657
ARG P2PPORT=26656
ARG PROFPORT=6060
ARG GRPCPORT=9090

RUN bash tm-chain xiond $CHAINID $CHAINDIR $RPCPORT $P2PPORT $PROFPORT $GRPCPORT

ENV CHAINID=$CHAINID 
ENV CHAINDIR=$CHAINDIR
EXPOSE $RPCPORT $P2PPORT $PROFPORT $GRPCPORT
ENTRYPOINT ["./entrypoint.sh"]
126 changes: 126 additions & 0 deletions tests/e2e/chains/xion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/usr/bin/make -f

VERSION ?= $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT ?= $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
# docker
DOCKER ?= $(shell which docker)
DOCKER_BUILD ?= $(DOCKER) build --rm --no-cache --pull

# 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 ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags += customcert
build_tags := $(strip $(build_tags))

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

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=xion \
-X github.com/cosmos/cosmos-sdk/version.AppName=xiond \
-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)"

ifeq ($(WITH_CLEVELDB),yes)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath

all: install lint test

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

build: guard-VERSION guard-COMMIT
ifeq ($(OS),Windows_NT)
$(error wasmd server not supported. Use "make build-windows-client" for client)
exit 1
else
go build -mod=readonly $(BUILD_FLAGS) -o build/xiond ./cmd/xiond
endif

################################################################################
### Docker ###
################################################################################

.PHONY: image
image:
$(DOCKER_BUILD) --build-arg CHAINID=ibc0 --tag xion-chain --no-cache .

.PHONY: network
network:
$(DOCKER) compose up -d

.PHONY: network-down
network-down:
$(DOCKER) compose down --volumes --remove-orphans

################################################################################
### Protobuf ###
################################################################################
protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
HTTPS_GIT := https://github.com/burnt-labs/xion.git

proto-all: proto-format proto-lint proto-gen format

proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@$(protoImage) sh 'scripts/protoc-swagger-gen.sh'

proto-format:
@echo "Formatting Protobuf files"
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
test test-all test-build test-cover test-unit test-race \
test-sim-import-export build-windows-client \
Loading
Loading