-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6de8ed8
commit 1156e57
Showing
15 changed files
with
316 additions
and
1,117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# docker build . -t cosmoscontracts/comdex:latest | ||
# docker run --rm -it cosmoscontracts/comdex:latest /bin/sh | ||
FROM golang:1.20-alpine AS go-builder | ||
|
||
# this comes from standard alpine nightly file | ||
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile | ||
# with some changes to support our toolchain, etc | ||
SHELL ["/bin/sh", "-ecuxo", "pipefail"] | ||
# we probably want to default to latest and error | ||
# since this is predominantly for dev use | ||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache ca-certificates build-base git | ||
# NOTE: add these to run with LEDGER_ENABLED=true | ||
# RUN apk add libusb-dev linux-headers | ||
|
||
WORKDIR /code | ||
COPY . /code/ | ||
|
||
# See https://github.com/CosmWasm/wasmvm/releases | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a | ||
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 9ecb037336bd56076573dc18c26631a9d2099a7f2b40dc04b6cae31ffb4c8f9a | ||
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 6e4de7ba9bad4ae9679c7f9ecf7e283dd0160e71567c6a7be6ae47c81ebe7f32 | ||
|
||
# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` | ||
RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a | ||
|
||
# force it to use static lib (from above) not standard libgo_cosmwasm.so file | ||
# then log output of file /code/bin/comdex | ||
# then ensure static linking | ||
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build \ | ||
&& file /code/bin/comdex \ | ||
&& echo "Ensuring binary is statically linked ..." \ | ||
&& (file /code/bin/comdex | grep "statically linked") | ||
|
||
# -------------------------------------------------------- | ||
FROM alpine:3.16 | ||
|
||
COPY --from=go-builder /code/bin/comdex /usr/bin/comdex | ||
|
||
COPY docker/* /opt/ | ||
RUN chmod +x /opt/*.sh | ||
|
||
WORKDIR /opt | ||
|
||
# rest server | ||
EXPOSE 1317 | ||
# tendermint p2p | ||
EXPOSE 26656 | ||
# tendermint rpc | ||
EXPOSE 26657 | ||
|
||
CMD ["/usr/bin/comdex", "version"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
version: "3" | ||
services: | ||
node: | ||
build: | ||
context: . | ||
args: | ||
- arch=${ARCH:-x86_64} | ||
command: ./setup_and_run.sh comdex1pkkayn066msg6kn33wnl5srhdt3tnu2v9jjqu0 | ||
ports: | ||
- 1317:1317 # rest | ||
- 26656:26656 # p2p | ||
- 26657:26657 # rpc | ||
environment: | ||
- GAS_LIMIT=${GAS_LIMIT:-10000000} | ||
- STAKE_TOKEN=${STAKE_TOKEN:-ucmdx} | ||
- TIMEOUT_COMMIT=${TIMEOUT_COMMIT:-5s} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
if test -n "$1"; then | ||
# need -R not -r to copy hidden files | ||
cp -R "$1/.comdex" /root | ||
fi | ||
|
||
mkdir -p /root/log | ||
comdex start --rpc.laddr tcp://0.0.0.0:26657 --trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
./setup_comdex.sh "$@" | ||
./run_comdex.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/sh | ||
#set -o errexit -o nounset -o pipefail | ||
|
||
PASSWORD=${PASSWORD:-1234567890} | ||
STAKE=${STAKE_TOKEN:-ustake} | ||
FEE=${FEE_TOKEN:-ucosm} | ||
CHAIN_ID=${CHAIN_ID:-testing} | ||
MONIKER=${MONIKER:-node001} | ||
KEYRING="--keyring-backend test" | ||
TIMEOUT_COMMIT=${TIMEOUT_COMMIT:-5s} | ||
BLOCK_GAS_LIMIT=${GAS_LIMIT:-10000000} # should mirror mainnet | ||
|
||
echo "Configured Block Gas Limit: $BLOCK_GAS_LIMIT" | ||
|
||
# check the genesis file | ||
GENESIS_FILE="$HOME"/.comdex/config/genesis.json | ||
GENESIS_FILE="$HOME"/.comdex/config/genesis.json | ||
if [ -f "$GENESIS_FILE" ]; then | ||
echo "$GENESIS_FILE exists..." | ||
else | ||
echo "$GENESIS_FILE does not exist. Generating..." | ||
|
||
comdex init --chain-id "$CHAIN_ID" "$MONIKER" | ||
comdex add-ica-config | ||
# staking/governance token is hardcoded in config, change this | ||
sed -i "s/\"stake\"/\"$STAKE\"/" "$GENESIS_FILE" | ||
# this is essential for sub-1s block times (or header times go crazy) | ||
sed -i 's/"time_iota_ms": "1000"/"time_iota_ms": "10"/' "$GENESIS_FILE" | ||
# change gas limit to mainnet value | ||
sed -i 's/"max_gas": "-1"/"max_gas": "'"$BLOCK_GAS_LIMIT"'"/' "$GENESIS_FILE" | ||
# change default keyring-backend to test | ||
sed -i 's/keyring-backend = "os"/keyring-backend = "test"/' "$HOME"/.comdex/config/client.toml | ||
fi | ||
|
||
APP_TOML_CONFIG="$HOME"/.comdex/config/app.toml | ||
APP_TOML_CONFIG_NEW="$HOME"/.comdex/config/app_new.toml | ||
CONFIG_TOML_CONFIG="$HOME"/.comdex/config/config.toml | ||
if [ -n "$UNSAFE_CORS" ]; then | ||
echo "Unsafe CORS set... updating app.toml and config.toml" | ||
# sorry about this bit, but toml is rubbish for structural editing | ||
sed -n '1h;1!H;${g;s/# Enable defines if the API server should be enabled.\nenable = false/enable = true/;p;}' "$APP_TOML_CONFIG" > "$APP_TOML_CONFIG_NEW" | ||
mv "$APP_TOML_CONFIG_NEW" "$APP_TOML_CONFIG" | ||
# ...and breathe | ||
sed -i "s/enabled-unsafe-cors = false/enabled-unsafe-cors = true/" "$APP_TOML_CONFIG" | ||
sed -i "s/cors_allowed_origins = \[\]/cors_allowed_origins = \[\"\*\"\]/" "$CONFIG_TOML_CONFIG" | ||
fi | ||
|
||
# speed up block times for testing environments | ||
sed -i "s/timeout_commit = \"5s\"/timeout_commit = \"$TIMEOUT_COMMIT\"/" "$CONFIG_TOML_CONFIG" | ||
|
||
# are we running for the first time? | ||
if ! comdex keys show validator $KEYRING; then | ||
(echo "$PASSWORD"; echo "$PASSWORD") | comdex keys add validator $KEYRING | ||
|
||
# hardcode the validator account for this instance | ||
echo "$PASSWORD" | comdex add-genesis-account validator "1000000000$STAKE,1000000000$FEE" $KEYRING | ||
|
||
# (optionally) add a few more genesis accounts | ||
for addr in "$@"; do | ||
echo $addr | ||
comdex add-genesis-account "$addr" "1000000000$STAKE,1000000000$FEE" | ||
done | ||
|
||
# submit a genesis validator tx | ||
## Workraround for https://github.com/cosmos/cosmos-sdk/issues/8251 | ||
(echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | comdex gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" --amount="250000000$STAKE" $KEYRING | ||
## should be: | ||
# (echo "$PASSWORD"; echo "$PASSWORD"; echo "$PASSWORD") | comdex gentx validator "250000000$STAKE" --chain-id="$CHAIN_ID" | ||
comdex collect-gentxs | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TEST_ADDR=comdex1pkkayn066msg6kn33wnl5srhdt3tnu2v9jjqu0 | ||
TEST_MNEMONIC="wage thunder live sense resemble foil apple course spin horse glass mansion midnight laundry acoustic rhythm loan scale talent push green direct brick please" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.