diff --git a/consensus-client-it/src/test/scala/units/docker/BesuContainer.scala b/consensus-client-it/src/test/scala/units/docker/BesuContainer.scala index 61022170..fd2b08c9 100644 --- a/consensus-client-it/src/test/scala/units/docker/BesuContainer.scala +++ b/consensus-client-it/src/test/scala/units/docker/BesuContainer.scala @@ -18,12 +18,12 @@ class BesuContainer(network: NetworkImpl, number: Int, ip: String)(implicit http protected override val container = new GenericContainer(DockerImages.BesuExecutionClient) .withNetwork(network) .withExposedPorts(RpcPort, EnginePort) + .withEnv("NODE_NUMBER", s"$number") .withEnv("LOG4J_CONFIGURATION_FILE", "/config/log4j2.xml") .withEnv("ROOT_LOG_FILE_LEVEL", "TRACE") - .withFileSystemBind(s"$ConfigsDir/ec-common/genesis.json", "/genesis.json", BindMode.READ_ONLY) + .withFileSystemBind(s"$ConfigsDir/ec-common", "/etc/secrets", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/besu", "/config", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/besu/run-besu.sh", "/tmp/run.sh", BindMode.READ_ONLY) - .withFileSystemBind(s"$ConfigsDir/ec-common/p2p-key-$number.hex", "/etc/secrets/p2p-key", BindMode.READ_ONLY) .withFileSystemBind(s"$logFile", "/opt/besu/logs/besu.log", BindMode.READ_WRITE) .withCreateContainerCmdModifier { cmd => cmd diff --git a/consensus-client-it/src/test/scala/units/docker/GethContainer.scala b/consensus-client-it/src/test/scala/units/docker/GethContainer.scala index 88735ee8..0029e715 100644 --- a/consensus-client-it/src/test/scala/units/docker/GethContainer.scala +++ b/consensus-client-it/src/test/scala/units/docker/GethContainer.scala @@ -21,10 +21,9 @@ class GethContainer(network: NetworkImpl, number: Int, ip: String)(implicit http protected override val container = new GenericContainer(DockerImages.GethExecutionClient) .withNetwork(network) .withExposedPorts(RpcPort, EnginePort) - .withFileSystemBind(s"$ConfigsDir/ec-common/genesis.json", "/tmp/genesis.json", BindMode.READ_ONLY) + .withEnv("NODE_NUMBER", s"$number") + .withFileSystemBind(s"$ConfigsDir/ec-common", "/etc/secrets", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/geth/run-geth.sh", "/tmp/run.sh", BindMode.READ_ONLY) - .withFileSystemBind(s"$ConfigsDir/ec-common/p2p-key-$number.hex", "/etc/secrets/p2p-key", BindMode.READ_ONLY) - .withFileSystemBind(s"$ConfigsDir/ec-common/jwt-secret-$number.hex", "/etc/secrets/jwtsecret", BindMode.READ_ONLY) .withFileSystemBind(s"$logFile", "/root/logs/log", BindMode.READ_WRITE) .withCreateContainerCmdModifier { cmd => cmd diff --git a/local-network/README.md b/local-network/README.md index 8095dd44..e8c07370 100644 --- a/local-network/README.md +++ b/local-network/README.md @@ -10,18 +10,25 @@ You have to build consensus client. Run [./consensus_client-image-build.sh](./consensus_client-image-build.sh) +## How to add additional nodes + +1. Uncomment in [./docker-compose.yml](./docker-compose.yml) +2. Optionally: Enable EL mining for these nodes in [./deploy/local/network.py](./deploy/local/network.py) (see the CL + section). + ## How to start - Run `./all-images-build.sh` after pulling the repository, so docker compose will pull new external images and rebuild the `deploy` image. - Available docker compose contexts: - - BlockScout services: `bs` - - Tests in the end `tests` -- Run [./restart.sh](./restart.sh) - - With selected contexts, for example, `COMPOSE_PROFILES=bs,tests ./restart.sh` - - Or without any context: `./restart.sh` + - BlockScout services: `bs` + - Tests in the end `tests` +- Run [./restart.sh](./restart.sh) + - With selected contexts, for example, `COMPOSE_PROFILES=bs,tests ./restart.sh` + - Or without any context: `./restart.sh` + +To retry failed: -To retry failed: - deploy - run `./deploy-run.sh`. - tests - run `./tests-run.sh`. @@ -39,12 +46,18 @@ See [./deploy](./deploy/). * Node HTTP API Key: `testapi` * CL accounts: see [genesis-template.conf](configs/wavesnode/genesis-template.conf) * EL mining reward accounts: - * Reward account for **Miner 1** (`wavesnode-1`, `besu-1`): + * Reward account for **Miner 1** (`wavesnode-1`, `ec-1`): * Address: `0x7dBcf9c6C3583b76669100f9BE3CaF6d722bc9f9` * Private key: `16962bb06858ec2e4f252b01391196a5e3699329ff0ce1cc185c213a3844b1cf` - * Reward account for **Miner 2** (`wavesnode-2`, `besu-2`): + * Reward account for **Miner 2** (`wavesnode-2`, `ec-2`): * Address: `0xcF0b9E13FDd593f4Ca26D36aFCaA44dd3FDCCbeD` * Private key: `ab49fee4fc326ecbc7abc7f2e5870bf1f86076eb0979c524e20c843f2a73f647` + * Reward account for **Miner 3** (`wavesnode-3`, `ec-3`): + * Address: `0xf1FE6d7bfebead68A8C06cCcee97B61d7DAA0338` + * Private key: `40151189dda26e893252542f1e628f469871f8770bc9cbe3d095419541a01bd0` + * Reward account for **Miner 4** (`wavesnode-4`, `ec-4`): + * Address: `0x10eDdE5dc07eF63E6bb7018758e6fcB5320d8cAa` + * Private key: `716aacab2cb83b57ce399f0d4e625e7a7ab242d3ee1b29858b0866e146be6086` * To see all information, run `npx tsx common-settings-show.ts` from [./deploy](./deploy/) directory. * Ethereum addresses and private keys for `besu` nodes in [config](configs/ec-common/genesis.json): * `fe3b557e8fb62b89f4916b721be55ceb828dbd73`: `8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63` @@ -96,7 +109,7 @@ For example, we will deploy a `HelloWorld`: 3. Press "Clear activity tab data" button. 2. If you want to deploy a contract via Explorer ("Contracts" tab), make sure you've chosen not a nightly version and it matches [bridge.sol](./deploy/setup/el/bridge.sol). - + # Useful links ## Besu configuration diff --git a/local-network/configs/besu/besu.conf b/local-network/configs/besu/besu.conf index 65846933..1958b04c 100644 --- a/local-network/configs/besu/besu.conf +++ b/local-network/configs/besu/besu.conf @@ -1,8 +1,8 @@ +# See https://besu.hyperledger.org/public-networks/reference/cli/options # /opt/besu belongs to besu user: https://github.com/hyperledger/besu/blob/main/docker/openjdk-17/Dockerfile # so it is the only writable path data-path = "/opt/besu/data" -genesis-file = "/genesis.json" -node-private-key-file = "/etc/secrets/p2p-key" +genesis-file = "/etc/secrets/genesis.json" sync-mode = "FULL" host-allowlist = ["*"] diff --git a/local-network/configs/besu/besu.yml b/local-network/configs/besu/besu.yml index e683f057..5d822ccc 100644 --- a/local-network/configs/besu/besu.yml +++ b/local-network/configs/besu/besu.yml @@ -2,7 +2,7 @@ services: besu: image: hyperledger/besu:latest volumes: - - ../ec-common/genesis.json:/genesis.json:ro + - ../ec-common/:/etc/secrets/:ro - .:/config:ro - ./run-besu.sh:/tmp/run.sh:ro env_file: diff --git a/local-network/configs/besu/run-besu.sh b/local-network/configs/besu/run-besu.sh index 36c69169..289c89d2 100755 --- a/local-network/configs/besu/run-besu.sh +++ b/local-network/configs/besu/run-besu.sh @@ -9,4 +9,5 @@ EOF # --p2p-host="ec-1" # Doesn't work: https://github.com/hyperledger/besu/issues/4380 besu \ --config-file=/config/besu.conf \ - --p2p-host=${IP} + --p2p-host=${IP} \ + --node-private-key-file="/etc/secrets/p2p-key-${NODE_NUMBER}.hex" diff --git a/local-network/configs/ec-common/p2p-key-bootnode.hex b/local-network/configs/ec-common/p2p-key-bootnode.hex deleted file mode 100644 index cf2d9f0e..00000000 --- a/local-network/configs/ec-common/p2p-key-bootnode.hex +++ /dev/null @@ -1 +0,0 @@ -dc51ae50601364b0d9354bad516acd16261447f89bde416399fa4ae5f2cbe8ab \ No newline at end of file diff --git a/local-network/configs/geth/geth.yml b/local-network/configs/geth/geth.yml index 7f4fe47c..2bf0afb0 100644 --- a/local-network/configs/geth/geth.yml +++ b/local-network/configs/geth/geth.yml @@ -4,7 +4,7 @@ services: stop_grace_period: 10s entrypoint: /tmp/run.sh volumes: - - ../ec-common/genesis.json:/tmp/genesis.json:ro + - ../ec-common/:/etc/secrets/:ro - ./run-geth.sh:/tmp/run.sh:ro env_file: - ../ec-common/peers.env diff --git a/local-network/configs/geth/run-geth.sh b/local-network/configs/geth/run-geth.sh index b608afd0..d9b758b9 100755 --- a/local-network/configs/geth/run-geth.sh +++ b/local-network/configs/geth/run-geth.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh if [ ! -d /root/.ethereum/geth ] ; then - geth init /tmp/genesis.json 2>&1 | tee /root/logs/init.log + geth init /etc/secrets/genesis.json 2>&1 | tee /root/logs/init.log fi IP_RAW=$(ip -4 addr show dev eth0 | awk '/inet / {print $2}') @@ -29,8 +29,8 @@ geth \ --ws.origins=* \ --authrpc.addr=0.0.0.0 \ --authrpc.vhosts=* \ - --authrpc.jwtsecret=/etc/secrets/jwtsecret \ - --nodekey=/etc/secrets/p2p-key \ + --authrpc.jwtsecret="/etc/secrets/jwt-secret-${NODE_NUMBER}.hex" \ + --nodekey="/etc/secrets/p2p-key-${NODE_NUMBER}.hex" \ --nat="extip:${IP}" \ --netrestrict="${NETWORK}/${PREFIX}" \ --bootnodes="${BESU_BOOTNODES}" \ diff --git a/local-network/configs/wavesnode/genesis-template.conf b/local-network/configs/wavesnode/genesis-template.conf index d0c505d0..e5b415d9 100644 --- a/local-network/configs/wavesnode/genesis-template.conf +++ b/local-network/configs/wavesnode/genesis-template.conf @@ -35,6 +35,24 @@ genesis-generator { # Address: 3FSrRN8X7cDsLyYTScS8Yf8KSwZgJBwf1jU { seed-text = "devnet-2", nonce = 0, amount = 800900102030000 } + # Miner on wavesnode-3 + # Seed text: devnet-3 + # Nonce: 0 + # Seed: HnyGuCEnV1C + # Private key: 6xx38JtyDrCBUox2HZ1F6qPZYcFHnfkYQzHRvs3wyRfH + # Public key: 4rfG6p3Ep2dUr4QqWtJwDvy3ySumMejgTE5sdJLzB756 + # Address: 3Fkh3dNmLS6NQtVbHcrADegwLo9DviBL5Ro + { seed-text = "devnet-3", nonce = 0, amount = 700050007000500 } + + # Miner on wavesnode-4 + # Seed text: devnet-4 + # Nonce: 0 + # Seed: HnyGuCEnV1D + # Private key: 26mAQWx1hKjDgiJHLpgGJnp8GWp23ueHjqy3vDJtCtTz + # Public key: CxeyqUAbsfCWHhQfrTq7g7t7PengjQpDejG5cd7i4Pqa + # Address: 3FXMRA1tPsn8LApkqVEQJgzsVdMBrnnd8vp + { seed-text = "devnet-4", nonce = 0, amount = 600100102030000 } + # Additional addresses # Seed text: devnet rich diff --git a/local-network/deploy/local/network.py b/local-network/deploy/local/network.py index 68723222..e647c410 100644 --- a/local-network/deploy/local/network.py +++ b/local-network/deploy/local/network.py @@ -60,6 +60,24 @@ def cl_miners(self) -> List[Miner]: "0xcf0b9e13fdd593f4ca26d36afcaa44dd3fdccbed" ), ), + # Miner( + # account=pw.Address( + # seed="devnet-3", + # nonce=0, + # ), + # el_reward_address_hex=HexStr( + # "0xf1FE6d7bfebead68A8C06cCcee97B61d7DAA0338" + # ), + # ), + # Miner( + # account=pw.Address( + # seed="devnet-4", + # nonce=0, + # ), + # el_reward_address_hex=HexStr( + # "0x10eDdE5dc07eF63E6bb7018758e6fcB5320d8cAa" + # ), + # ), ] @cached_property diff --git a/local-network/deploy/pyproject.toml b/local-network/deploy/pyproject.toml index 01fdf4f2..bb16f36d 100644 --- a/local-network/deploy/pyproject.toml +++ b/local-network/deploy/pyproject.toml @@ -8,7 +8,7 @@ version = "0.1" description = "Scripts and tests for a locally deployed Unit network" dependencies = [ "solc-select", - "units-network @ git+https://github.com/UnitsNetwork/examples.git@dao-rewards", + "units-network @ git+https://github.com/UnitsNetwork/examples.git", ] readme = "README.md" requires-python = ">=3.9" diff --git a/local-network/docker-compose.yml b/local-network/docker-compose.yml index ca880fbe..ba364053 100644 --- a/local-network/docker-compose.yml +++ b/local-network/docker-compose.yml @@ -8,27 +8,60 @@ services: extends: file: ./configs/besu/besu.yml service: besu + environment: + NODE_NUMBER: 1 ports: - "127.0.0.1:18551:8551" # Engine port - doesn't have all APIs - "127.0.0.1:18545:8545" # RPC port, for Metamask e.g. - "127.0.0.1:18546:8546" # WebSocket volumes: - - ./configs/ec-common/p2p-key-1.hex:/etc/secrets/p2p-key:ro - ./logs/ec-1:/opt/besu/logs ec-2: container_name: ec-2 hostname: ec-2 extends: - file: ./configs/geth/geth.yml - service: geth + file: ./configs/besu/besu.yml + service: besu ports: - - "127.0.0.1:28551:8551" # Engine port - - "127.0.0.1:28545:8545" # RPC port + - "127.0.0.1:28551:8551" + - "127.0.0.1:28545:8545" + - "127.0.0.1:28546:8546" + environment: + NODE_NUMBER: 2 volumes: - - ./configs/ec-common/p2p-key-2.hex:/etc/secrets/p2p-key:ro - - ./configs/ec-common/jwt-secret-2.hex:/etc/secrets/jwtsecret:ro - - ./logs/ec-2:/root/logs + - ./logs/ec-2:/opt/besu/logs + + # Make sure, you have enough RAM to run additional nodes + # ec-3: + # container_name: ec-3 + # hostname: ec-3 + # extends: + # file: ./configs/besu/besu.yml + # service: besu + # environment: + # NODE_NUMBER: 3 + # ports: + # - "127.0.0.1:38551:8551" + # - "127.0.0.1:38545:8545" + # - "127.0.0.1:38546:8546" + # volumes: + # - ./logs/ec-3:/opt/besu/logs + + # Geth is not recommended for now, because of rollback issue + # ec-4: + # container_name: ec-4 + # hostname: ec-4 + # extends: + # file: ./configs/geth/geth.yml + # service: geth + # environment: + # NODE_NUMBER: 4 + # ports: + # - "127.0.0.1:48551:8551" + # - "127.0.0.1:48545:8545" + # volumes: + # - ./logs/ec-4:/root/logs wavesnode-1: container_name: wavesnode-1 @@ -70,6 +103,48 @@ services: update-genesis: condition: service_completed_successfully + # wavesnode-3: + # container_name: wavesnode-3 + # hostname: wavesnode-3 + # extends: + # file: ./configs/wavesnode/wavesnode.yml + # service: wavesnode + # image: ${WAVES_NODE_IMAGE_3:-${WAVES_NODE_IMAGE:-consensus-client:local}} + # ports: + # - "127.0.0.1:36869:6869" + # environment: + # NODE_NUMBER: 3 + # WAVES_WALLET_SEED: HnyGuCEnV1C # devnet-3, addr: 3Fkh3dNmLS6NQtVbHcrADegwLo9DviBL5Ro + # JAVA_OPTS: -Dwaves.miner.enable=no + # volumes: + # - ./logs/wavesnode-3:/var/log/waves + # depends_on: + # ec-3: + # condition: service_healthy + # update-genesis: + # condition: service_completed_successfully + + # wavesnode-4: + # container_name: wavesnode-4 + # hostname: wavesnode-4 + # extends: + # file: ./configs/wavesnode/wavesnode.yml + # service: wavesnode + # image: ${WAVES_NODE_IMAGE_4:-${WAVES_NODE_IMAGE:-consensus-client:local}} + # ports: + # - "127.0.0.1:46869:6869" + # environment: + # NODE_NUMBER: 4 + # WAVES_WALLET_SEED: HnyGuCEnV1D # devnet-4, addr: 3FXMRA1tPsn8LApkqVEQJgzsVdMBrnnd8vp + # JAVA_OPTS: -Dwaves.miner.enable=no + # volumes: + # - ./logs/wavesnode-4:/var/log/waves + # depends_on: + # ec-3: + # condition: service_healthy + # update-genesis: + # condition: service_completed_successfully + update-genesis: container_name: update-genesis image: ${WAVES_NODE_IMAGE:-ghcr.io/wavesplatform/waves:test-gengen} diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 28544b41..630935a7 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -12,6 +12,9 @@ units { known-peers = [] file = null } + + # Optional: + # jwt-secret-file = "/path/to/jwt/secret" } chains = [ @@ -27,6 +30,8 @@ units { # "5.6.7.8:6865" # ] # } + # # Optional: + # # jwt-secret-file = "/path/to/jwt/secret" # } ] }