Skip to content

Commit

Permalink
Merge branch 'lavanet:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelLLC authored Jun 4, 2024
2 parents 745646e + 17c497d commit 58d258c
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lava.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ jobs:
permissions:
contents: write
packages: write
id-token: write
needs: [test-consensus, test-protocol]
runs-on: ubuntu-latest
strategy:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions cmd/lavad/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -50,6 +53,7 @@ EXPOSE 1317
EXPOSE 8080
# grpc
EXPOSE 9090
EXPOSE 9091
# tendermint p2p
EXPOSE 26656
# tendermint rpc
Expand Down
4 changes: 4 additions & 0 deletions cmd/lavap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -50,6 +53,7 @@ EXPOSE 1317
EXPOSE 8080
# grpc
EXPOSE 9090
EXPOSE 9091
# tendermint p2p
EXPOSE 26656
# tendermint rpc
Expand Down
79 changes: 35 additions & 44 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!--
1. Create a lava user and fund it.
```
export LAVA_HOME='.lava'
export LAVA_USER='my-user'
# create a new user, and then show its address
build/lavad keys add $LAVA_USER --home $LAVA_HOME --keyring-backend test
build/lavad keys list --home $LAVA_HOME --keyring-backend test list
LAVA_ADDR=$(lavad keys show "${LAVA_USER}" --home $LAVA_HOME --keyring-backend test | \
grep address | awk '{print $2}')
# fund the new user: see https://docs.lavanet.xyz/faucet
# verify the user has funds
build/lavad query bank balances $LAVA_ADDR --home $LAVA_HOME --denom ulava \
--node http://public-rpc.lavanet.xyz:80/rpc/
```
2. Review the settings in `docker/env`. Fill in all the mandatory values
for the 'portal' / 'provider' role.
3. Use the following the commands to create/start/stop/destroy the node (for
'provider' replace the role 'portal' with 'provider'):
```
# operate in docker/ directory:
cd docker/
# to start the portal/provider:
docker-compose --profile portal --env-file env -f docker-compose.yml up
# to stop/start the portal/provider:
docker-compose --profile portal --env-file env -f docker-compose.yml stop
docker-compose --profile portal --env-file env -f docker-compose.yml start
# to destroy the portal/provider:
docker-compose --profile portal --env-file env -f docker-compose.yml down
```
-->
## 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
```
85 changes: 85 additions & 0 deletions docker/docker-compose.state-sync.yml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 58d258c

Please sign in to comment.