From 61fe74ca3b6db4a17bf22947e9d5b5bff68f1772 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Tue, 5 Sep 2023 20:00:22 +0800 Subject: [PATCH] build cleanup docker ignore dockerfile cleanup clean up init script forward LOGLEVEL --- .dockerignore | 7 +- .github/CODEOWNERS | 5 -- Dockerfile | 12 ++-- Makefile | 4 +- init.sh | 103 +++++++++++++++-------------- tests/sdk_tests/docker-compose.yml | 3 +- 6 files changed, 69 insertions(+), 65 deletions(-) delete mode 100644 .github/CODEOWNERS diff --git a/.dockerignore b/.dockerignore index dacc6297..c004e5dd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,9 @@ localnet-setup # build -build \ No newline at end of file +build + +**/node_modules + +Dockerfile +init.sh \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index f03d6586..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# CODEOWNERS: https://help.github.com/articles/about-codeowners/ - -# Primary (global) repo maintainers - - * @evmos/core-engineering diff --git a/Dockerfile b/Dockerfile index e6ddee8c..c848960e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,11 @@ FROM golang:alpine AS build-env -# Set up dependencies -ENV PACKAGES git build-base +# Install dependencies +RUN apk add --update git build-base linux-headers # Set working directory for the build WORKDIR /go/src/github.com/cerc-io/laconicd -# Install dependencies -RUN apk add --update $PACKAGES -RUN apk add linux-headers - # Add source files COPY . . @@ -21,10 +17,10 @@ FROM alpine:3.17.0 # Install ca-certificates RUN apk add --update ca-certificates jq curl -WORKDIR / # Copy over binaries from the build-env COPY --from=build-env /go/src/github.com/cerc-io/laconicd/build/laconicd /usr/bin/laconicd +WORKDIR / # Run laconicd by default -CMD ["laconicd"] +ENTRYPOINT ["laconicd"] diff --git a/Makefile b/Makefile index c487280a..be895c3c 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ ifeq ($(ENABLE_ROCKSDB),true) BUILD_TAGS += rocksdb_build test_tags += rocksdb_build else - $(warning RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true) + $(info RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true) endif # DB backend selection @@ -145,7 +145,7 @@ docker-build: # update old container docker rm laconicd || true # create a new container from the latest image - docker create --name laconic -t -i cerc-io/laconicd:latest laconicd + docker create --name laconic -t -i ${DOCKER_IMAGE}:${DOCKER_TAG} laconicd # move the binaries to the ./build directory mkdir -p ./build/ docker cp laconic:/usr/bin/laconicd ./build/ diff --git a/init.sh b/init.sh index adcb8b74..93d91770 100755 --- a/init.sh +++ b/init.sh @@ -5,19 +5,20 @@ CHAINID="laconic_9000-1" MONIKER="localtestnet" KEYRING="test" KEYALGO="eth_secp256k1" -LOGLEVEL="info" +LOGLEVEL="${LOGLEVEL:-info}" # trace evm TRACE="--trace" # TRACE="" # validate dependencies are installed -command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; } +command -v jq > /dev/null 2>&1 || { + echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/" + exit 1 +} # remove existing daemon and client rm -rf ~/.laconic* -make install - laconicd config keyring-backend $KEYRING laconicd config chain-id $CHAINID @@ -27,71 +28,70 @@ laconicd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO # Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer) laconicd init $MONIKER --chain-id $CHAINID +update_genesis() { + jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json && + mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json +} + # Change parameter token denominations to aphoton -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json +update_genesis '.app_state["staking"]["params"]["bond_denom"]="aphoton"' +update_genesis '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' +update_genesis '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' +update_genesis '.app_state["mint"]["params"]["mint_denom"]="aphoton"' # Custom modules -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json -cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json +update_genesis '.app_state["registry"]["params"]["record_rent"]["denom"]="aphoton"' +update_genesis '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"' +update_genesis '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"' +update_genesis '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"' +update_genesis '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"' if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then echo "Setting timers for expiry tests." - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json + update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"' + update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"' + update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' fi if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then echo "Enabling auction and setting timers." - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_enabled"]=true' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="300s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json - cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json + update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true' + update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' + update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"' + update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"' + update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"' fi # increase block time (?) -cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="1000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json +update_genesis '.consensus_params["block"]["time_iota_ms"]="1000"' # Set gas limit in genesis -cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json +update_genesis '.consensus_params["block"]["max_gas"]="10000000"' # disable produce empty block if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml - else - sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml + sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml +else + sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml fi -if [[ $1 == "pending" ]]; then +if [[ "$1" == "pending" ]]; then + alias sed-i="sed -i" if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml - sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml - else - sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml - sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml + alias sed-i="sed -i ''" fi + sed-i \ + -e 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' \ + -e 's/timeout_propose = "3s"/timeout_propose = "30s"/g' \ + -e 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' \ + -e 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' \ + -e 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' \ + -e 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' \ + -e 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' \ + -e 's/timeout_commit = "5s"/timeout_commit = "150s"/g' \ + -e 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' \ + $HOME/.laconicd/config/config.toml fi # Allocate genesis accounts (cosmos formatted addresses) @@ -106,9 +106,16 @@ laconicd collect-gentxs # Run this to ensure everything worked and that the genesis file is setup correctly laconicd validate-genesis -if [[ $1 == "pending" ]]; then +if [[ "$1" == "pending" ]]; then echo "pending mode is on, please wait for the first block committed." fi # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground +laconicd start \ + --pruning=nothing \ + --evm.tracer=json $TRACE \ + --log_level $LOGLEVEL \ + --minimum-gas-prices=0.0001aphoton \ + --json-rpc.api eth,txpool,personal,net,debug,web3,miner \ + --api.enable \ + --gql-server --gql-playground diff --git a/tests/sdk_tests/docker-compose.yml b/tests/sdk_tests/docker-compose.yml index 7a65e3e1..b0788f9e 100644 --- a/tests/sdk_tests/docker-compose.yml +++ b/tests/sdk_tests/docker-compose.yml @@ -2,10 +2,11 @@ services: laconicd: restart: unless-stopped image: cerc/laconicd:local-test - command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] + entrypoint: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] environment: - TEST_AUCTION_ENABLED - TEST_REGISTRY_EXPIRY + - LOGLEVEL volumes: - ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh healthcheck: