diff --git a/.github/workflows/lava.yml b/.github/workflows/lava.yml index 2300704a09..e5effeb59e 100644 --- a/.github/workflows/lava.yml +++ b/.github/workflows/lava.yml @@ -384,6 +384,7 @@ jobs: permissions: contents: write packages: write + id-token: write needs: [test-consensus, test-protocol] runs-on: ubuntu-latest strategy: diff --git a/README.md b/README.md index 2703e2a779..89e59964cb 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,11 @@ Lava is built using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) whic **Note**: Requires [Go 1.20.5](https://golang.org/dl/) +### Running Lava + +The best way to start working with lava is to use docker, for additional reading go to: +[Running via compose](docker/README.md) + ### Installing development dependencies before running the scripts make sure you have go installed and added to $PATH, you can validate by running `which go` diff --git a/cmd/lavad/Dockerfile b/cmd/lavad/Dockerfile index 39efa9dbcd..7e4bfb69cc 100644 --- a/cmd/lavad/Dockerfile +++ b/cmd/lavad/Dockerfile @@ -21,6 +21,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ COPY . . +ARG GIT_VERSION +ARG GIT_COMMIT + RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ GOWORK=off go build \ @@ -50,6 +53,7 @@ EXPOSE 1317 EXPOSE 8080 # grpc EXPOSE 9090 +EXPOSE 9091 # tendermint p2p EXPOSE 26656 # tendermint rpc diff --git a/cmd/lavap/Dockerfile b/cmd/lavap/Dockerfile index 2df889dd10..3e87af4c9b 100644 --- a/cmd/lavap/Dockerfile +++ b/cmd/lavap/Dockerfile @@ -21,6 +21,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ COPY . . +ARG GIT_VERSION +ARG GIT_COMMIT + RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ GOWORK=off go build \ @@ -50,6 +53,7 @@ EXPOSE 1317 EXPOSE 8080 # grpc EXPOSE 9090 +EXPOSE 9091 # tendermint p2p EXPOSE 26656 # tendermint rpc diff --git a/docker/README.md b/docker/README.md index faba5bca55..ad16255dec 100644 --- a/docker/README.md +++ b/docker/README.md @@ -51,47 +51,38 @@ runtime"). The default settings are usually suitable for all deployments. docker-compose --profile node --env-file env -f docker-compose.yml down ``` -**Run Lava Portal / Provider** - -This section is outdated and is temporarily removed. - - +## Running node using state-sync with docker-compose + +From the root path run: +```sh +docker compose -f docker/docker-compose.state-sync.yml up -d +``` + +To test the setup run: +```sh +curl -X POST -H "Content-Type: application/json" localhost:26657 --data '{"jsonrpc": "2.0", "id": 1, "method": "status", "params": []}' +``` +and expect to see the lastest block. + +You can run change the version of `lavad` using the `LAVAD_VERSION` var: +```sh +LAVAD_VERSION=v2.0.1 docker compose -f docker/docker-compose.state-sync.yml up -d +``` + +### Full configuration options: +|Name |Description +|----------------|------------------------------- +|LAVAD_VERSION | The Lavad version to use +|CHAIN_ID | The chain id +|KEYRING_BACKEND | The keyring backend +|MONIKER | The moniker for the `init` command +|STATE_SYNC_RPC_1| The RPC node to sync on +|GENESIS_ADDRESS | The `genesis.json` URL +|ADDRBOOK_ADDRESS| The `addrbook.json` URL +|NUM_BLOCKS | The number of blocks to sync on from behind the latest block + + +To clean the lava node setup including volumes run: +```sh +docker compose -f docker/docker-compose.state-sync.yml down -v +``` \ No newline at end of file diff --git a/docker/docker-compose.state-sync.yml b/docker/docker-compose.state-sync.yml new file mode 100644 index 0000000000..491ee546f9 --- /dev/null +++ b/docker/docker-compose.state-sync.yml @@ -0,0 +1,85 @@ + +services: + + lava-node-init: + # Update with the most recent supported version of lavad + image: ghcr.io/lavanet/lava/lavad:${LAVAD_VERSION:-v2.0.0} + environment: + - CHAIN_ID=${CHAIN_ID:-lava-testnet-2} + - KEYRING_BACKEND=${KEYRING_BACKEND:-test} + - MONIKER=${MONIKER:-DOCKER_COMPOSE_MONIKER} + command: > + config chain-id $$CHAIN_ID && \ + lavad config keyring-backend $$KEYRING_BACKEND && \ + lavad init $$MONIKER --chain-id $$CHAIN_ID + volumes: + - lava_data:/lava + networks: + - lava_network + + lava-node-config: + image: ghcr.io/tomwright/dasel:v2.7.0 + entrypoint: ["sh", "-c"] + # Example variables for kjnodes nodes + environment: + - STATE_SYNC_RPC_1=${STATE_SYNC_RPC_1:-https://lava-testnet.rpc.kjnodes.com:443} + - GENESIS_ADDRESS=${GENESIS_ADDRESS:-https://snapshots.kjnodes.com/lava-testnet/genesis.json} + - ADDRBOOK_ADDRESS=${ADDRBOOK_ADDRESS:-https://snapshots.kjnodes.com/lava-testnet/addrbook.json} + - NUM_BLOCKS=${NUM_BLOCKS:-1500} + command: > + " + apt-get -y update && apt-get install -y jq curl && + curl -Ls $$GENESIS_ADDRESS > /lava/.lava/config/genesis.json && + curl -Ls $$ADDRBOOK_ADDRESS > /lava/.lava/config/addrbook.json && + dasel put -f /lava/.lava/config/app.toml -t string -v 0ulava 'minimum-gas-prices' && + dasel put -f /lava/.lava/config/app.toml -t string -v custom 'pruning' && + dasel put -f /lava/.lava/config/app.toml -t string -v 100 'pruning-keep-recent' && + dasel put -f /lava/.lava/config/app.toml -t string -v 0 'pruning-keep-every' && + dasel put -f /lava/.lava/config/app.toml -t string -v 19 'pruning-interval' && + dasel put -f /lava/.lava/config/app.toml -t string -v true 'api.enable' && + + LATEST_HEIGHT=$(curl -s $$STATE_SYNC_RPC_1/block | jq -r .result.block.header.height) && + SYNC_BLOCK_HEIGHT=$(($$LATEST_HEIGHT - $$NUM_BLOCKS)) && + SYNC_BLOCK_HASH=$(curl -s "$$STATE_SYNC_RPC_1/block?height=$$SYNC_BLOCK_HEIGHT" | jq -r .result.block_id.hash) && + + dasel put -f /lava/.lava/config/config.toml -t string -v true 'statesync.enable' && + dasel put -f /lava/.lava/config/config.toml -t string -v \"$$STATE_SYNC_RPC_1,$$STATE_SYNC_RPC_1\" 'statesync.rpc_servers' && + dasel put -f /lava/.lava/config/config.toml -t string -v \"$$SYNC_BLOCK_HEIGHT\" 'statesync.trust_height' && + dasel put -f /lava/.lava/config/config.toml -t string -v \"$$SYNC_BLOCK_HASH\" 'statesync.trust_hash' && + dasel put -f /lava/.lava/config/config.toml -t string -v \"tcp://0.0.0.0:26657\" 'rpc.laddr' + " + volumes: + - lava_data:/lava + networks: + - lava_network + depends_on: + lava-node-init: + condition: service_completed_successfully + + lava-node: + # Update with the most recent supported version of lavad + image: ghcr.io/lavanet/lava/lavad:${LAVAD_VERSION:-v2.0.0} + container_name: lava-node + command: ["start"] + ports: + - '${LAVA_NODE_PORT_API:-1317}:1317' + - '${LAVA_NODE_PORT_GRPC:-9090}:9090' + - '${LAVA_NODE_PORT_GRPC_WEB:-9091}:9091' + - '${LAVA_NODE_PORT_P2P:-26656}:26656' + - '${LAVA_NODE_PORT_RPC:-26657}:26657' + volumes: + - lava_data:/lava + networks: + - lava_network + restart: always + depends_on: + lava-node-init: + condition: service_completed_successfully + lava-node-config: + condition: service_completed_successfully + +volumes: + lava_data: + +networks: + lava_network: \ No newline at end of file