diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 5ca6c3d8..09a4fbbe 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -2,6 +2,13 @@ name: Check PR on: pull_request: +concurrency: + group: check-pr-${{ github.ref }} + cancel-in-progress: true + +permissions: + checks: write + jobs: check-pr: name: Check PR @@ -46,7 +53,15 @@ jobs: - name: Run tests run: | forge --version - sbt --batch "scalafmtCheck;test;docker;consensus-client-it/test" + sbt --no-colors --color=never --batch "scalafmtCheck;test;docker;consensus-client-it/test" + env: + RUN_ID: ${{ github.head_ref }}-${{ github.run_number }}-${{ github.run_attempt }} + - uses: scacap/action-surefire-report@5609ce4db72c09db044803b344a8968fd1f315da + if: always() + with: + report_paths: '**/target/test-reports/*.xml' + create_check: false + check_name: 'Check PR' - name: Archive logs uses: actions/upload-artifact@v4 if: always() diff --git a/consensus-client-it/src/test/scala/units/BaseDockerTestSuite.scala b/consensus-client-it/src/test/scala/units/BaseDockerTestSuite.scala index 210afad1..7bf0d3eb 100644 --- a/consensus-client-it/src/test/scala/units/BaseDockerTestSuite.scala +++ b/consensus-client-it/src/test/scala/units/BaseDockerTestSuite.scala @@ -6,9 +6,11 @@ import com.wavesplatform.common.state.ByteStr import com.wavesplatform.common.utils.EitherExt2.explicitGet import com.wavesplatform.utils.ScorexLogging import monix.execution.atomic.AtomicBoolean +import org.scalactic.source.Position import org.scalatest.freespec.AnyFreeSpec import org.scalatest.matchers.should.Matchers import org.scalatest.{BeforeAndAfterAll, EitherValues, OptionValues} +import org.web3j.protocol.core.DefaultBlockParameterName import sttp.client3.{HttpClientSyncBackend, Identity, SttpBackend} import units.client.HttpChainContractClient import units.client.contract.HasConsensusLayerDappTxHelpers @@ -16,7 +18,7 @@ import units.client.engine.model.BlockNumber import units.docker.* import units.docker.WavesNodeContainer.generateWavesGenesisConfig import units.el.{NativeBridgeClient, StandardBridgeClient} -import units.eth.Gwei +import units.eth.{EthAddress, Gwei} import units.test.{CustomMatchers, IntegrationTestEventually, TestEnvironment} import scala.sys.process.{Process, ProcessLogger} @@ -115,6 +117,10 @@ trait BaseDockerTestSuite waves1.api.waitForHeight(epoch1Number) } + private def waitForContract(address: EthAddress)(implicit pos: Position): Unit = eventually { + ec1.web3j.ethGetCode(address.toString, DefaultBlockParameterName.LATEST).send().getCode shouldNot be("0x") + } + protected def deploySolidityContracts(): Unit = { step("Deploy contracts on EL") Process( @@ -122,6 +128,10 @@ trait BaseDockerTestSuite TestEnvironment.ContractsDir, "CHAIN_ID" -> EcContainer.ChainId.toString ).!(ProcessLogger(out => log.info(out), err => log.error(err))) + + waitForContract(StandardBridgeAddress) + waitForContract(WWavesAddress) + waitForContract(TErc20Address) } override protected def step(text: String): Unit = { diff --git a/docker/README.md b/docker/README.md index bb8ae979..40d554d3 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,24 +6,27 @@ Units Network node consists of Waves blockchain node, Consensus Client extension * Generate JWT secret and execution client keys by running `./gen-keys.sh`. This script requires `openssl`. * Optional: get waves node [state](https://docs.waves.tech/en/waves-node/options-for-getting-actual-blockchain/state-downloading-and-applying) and place it inside the `./data/waves` directory. * Optional: get execution client state. -* To run op-geth on Linux, you need to manually create data & log directories and set appropriate permissions: -``` -install -d -o 1000 -g 1000 data/op-geth logs/op-geth + +## Configuring the nodes + +Create `./local.env` file with the base58-encoded [seed and password](https://docs.waves.tech/en/waves-node/how-to-work-with-node-wallet) and declared addresses for both Waves and Unit Zero nodes: +```shell +WAVES_WALLET_SEED= +WAVES_WALLET_PASSWORD= +WAVES_DECLARED_ADDRESS=1.2.3.4:6868 +UNITS_DECLARED_ADDRESS=1.2.3.4:6865 ``` +This wallet seed will be used for mining both waves and ethereum blocks, so make sure it's the correct one. Also make sure these declared addresses have distinct ports, otherwise your node will be banned from the network! -## Configuring Waves Node -* Create `./secrets.env` file with the base58-encoded [seed and password](https://docs.waves.tech/en/waves-node/how-to-work-with-node-wallet): - ``` - WAVES_WALLET_SEED= - WAVES_WALLET_PASSWORD= - ``` - This wallet seed will be used for mining both waves and ethereum blocks, so make sure it's the correct one. -* Specify the proper declared addresses in the environment file (`testnet.env` for testnet, etc.). Make sure these declared addresses have distinct ports, otherwise your node will be banned from the network! +You can also override Consensus Client image tag by adding `UNITS_IMAGE_TAG` variable to `./local.env`: +```shell +UNITS_IMAGE_TAG=snapshot +``` ## Launching Running, stopping and updating in testnet: -``` +```shell docker compose --env-file=testnet.env up -d docker compose --env-file=testnet.env down docker compose --env-file=testnet.env pull diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1a6c7b5f..0b1ed4dc 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -20,14 +20,16 @@ services: waves-node: container_name: waves-node - image: ghcr.io/unitsnetwork/consensus-client:${WAVES_NODE_TAG:-${NETWORK:-snapshot}} + image: ghcr.io/unitsnetwork/consensus-client:${UNITS_IMAGE_TAG:-$NETWORK} stop_grace_period: 5m pull_policy: always restart: unless-stopped environment: - JAVA_OPTS: $JAVA_OPTS -Dwaves.blockchain.type=$NETWORK -Dlogback.file.level=TRACE - WAVES_WALLET_PASSWORD: $WAVES_WALLET_PASSWORD - WAVES_WALLET_SEED: $WAVES_WALLET_SEED + JAVA_OPTS: ${JAVA_OPTS:-} -Dwaves.blockchain.type=${NETWORK:?NETWORK must be set} -Dlogback.file.level=TRACE + UNITS_CHAIN_CONTRACT: + UNITS_KNOWN_PEERS: + env_file: + - local.env ports: - 127.0.0.1:6869:6869 - 6868:6868 @@ -35,6 +37,6 @@ services: volumes: - ./data/secrets:/etc/secrets:ro - ./data/waves:/var/lib/waves/data - - ./waves-${NETWORK}.conf:/etc/waves/waves.conf:ro + - ./waves.conf:/etc/waves/waves.conf:ro - ./logback.xml:/etc/waves/logback.xml - ./logs/waves:/var/log/waves diff --git a/docker/mainnet.env b/docker/mainnet.env new file mode 100644 index 00000000..6a420bcb --- /dev/null +++ b/docker/mainnet.env @@ -0,0 +1,5 @@ +NETWORK=mainnet +NETWORKID=88811 +GASLIMIT=10000000 +UNITS_CHAIN_CONTRACT=3PKgN8rfmvF7hK7RWJbpvkh59e1pQkUzero +UNITS_KNOWN_PEERS=peers.unit0.dev diff --git a/docker/peers-stagenet.toml b/docker/peers-stagenet.toml new file mode 100644 index 00000000..61a064c3 --- /dev/null +++ b/docker/peers-stagenet.toml @@ -0,0 +1,8 @@ +[Node.P2P] +BootstrapNodes = [ + "enode://15865b888af15bf576ac4c3026856c6f75845e8b4702e4480124e358f7bf09e847ae6c97c86573330e6ab9d12751f5cd1fdbe61f78aee5d204a3af16811477ec@116.202.97.123:30303" +] +BootstrapNodesV5 = [] +StaticNodes = [ + "enode://15865b888af15bf576ac4c3026856c6f75845e8b4702e4480124e358f7bf09e847ae6c97c86573330e6ab9d12751f5cd1fdbe61f78aee5d204a3af16811477ec@116.202.97.123:30303" +] diff --git a/docker/services/op-geth.yml b/docker/services/op-geth.yml index 4323eb89..2f9daa5d 100644 --- a/docker/services/op-geth.yml +++ b/docker/services/op-geth.yml @@ -1,7 +1,7 @@ services: op-geth: container_name: op-geth - image: ghcr.io/unitsnetwork/op-geth:v1.101503.1-simulate-fixes + image: ghcr.io/unitsnetwork/op-geth:v1.101603.0-1 stop_grace_period: 5m entrypoint: /bin/sh -c environment: diff --git a/docker/stagenet.env b/docker/stagenet.env new file mode 100644 index 00000000..b580e685 --- /dev/null +++ b/docker/stagenet.env @@ -0,0 +1,5 @@ +NETWORK=stagenet +NETWORKID=88819 +GASLIMIT=10000000 +UNITS_CHAIN_CONTRACT=3MjDHGn2ZbeXYj7YQ5ALArv5R2Vy914Phf7 +UNITS_KNOWN_PEERS=peers-stagenet.unit0.dev:6865 diff --git a/docker/testnet.env b/docker/testnet.env index 9f87e61c..126e8367 100644 --- a/docker/testnet.env +++ b/docker/testnet.env @@ -1,6 +1,5 @@ NETWORK=testnet NETWORKID=88817 GASLIMIT=10000000 -WAVES_KNOWN_PEERS=[testnet-l2-htz-hel1-1.wavesnodes.com:6865] -#WAVES_DECLARED_ADDRESS=1.2.3.4:6868 -#UNITS_DECLARED_ADDRESS=1.2.3.4:6865 +UNITS_CHAIN_CONTRACT=3Msx4Aq69zWUKy4d1wyKnQ4ofzEDAfv5Ngf +UNITS_KNOWN_PEERS=peers-testnet.unit0.dev diff --git a/docker/waves-testnet.conf b/docker/waves-testnet.conf deleted file mode 100644 index 62d5e0f6..00000000 --- a/docker/waves-testnet.conf +++ /dev/null @@ -1,44 +0,0 @@ -waves { - extensions = [ - units.ConsensusClient - ] - - wallet { - seed = ${WAVES_WALLET_SEED} - password = ${WAVES_WALLET_PASSWORD} - } - - network { - bind-address = "0.0.0.0" - port = 6868 - declared-address = ${?WAVES_DECLARED_ADDRESS} - } - - rest-api { - enable = yes - bind-address = "0.0.0.0" - port = 6869 - api-key-hash = ${?WAVES_API_KEY_HASH} - } -} - -units { - chains = [ - { - chain-contract = 3Msx4Aq69zWUKy4d1wyKnQ4ofzEDAfv5Ngf - execution-client-address = "http://op-geth:8551" - jwt-secret-file = /etc/secrets/jwtsecret - - network { - port = 6865 - declared-address = ${?UNITS_DECLARED_ADDRESS} - known-peers = [ - "testnet-l2-htz-hel1-1.wavesnodes.com:6865" - "testnet-l2-htz-hel1-2.wavesnodes.com:6865" - "testnet-htz-nbg1-1.wavesnodes.com:6865" - ] - } - mining-enable = no - } - ] -} diff --git a/docker/waves-mainnet.conf b/docker/waves.conf similarity index 83% rename from docker/waves-mainnet.conf rename to docker/waves.conf index 86542518..d58953bf 100644 --- a/docker/waves-mainnet.conf +++ b/docker/waves.conf @@ -25,16 +25,15 @@ waves { units { chains = [ { - chain-contract = 3PKgN8rfmvF7hK7RWJbpvkh59e1pQkUzero + chain-contract = ${UNITS_CHAIN_CONTRACT} execution-client-address = "http://op-geth:8551" jwt-secret-file = /etc/secrets/jwtsecret network { port = 6865 declared-address = ${?UNITS_DECLARED_ADDRESS} - known-peers = ${WAVES_KNOWN_PEERS} + known-peers = [${UNITS_KNOWN_PEERS}] } - mining-enable = no } ] }