diff --git a/build.sbt b/build.sbt index f521ea84..4f1ad945 100644 --- a/build.sbt +++ b/build.sbt @@ -13,8 +13,8 @@ name := "consensus-client" maintainer := "Units Network Team" resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal) libraryDependencies ++= Seq( - "com.wavesplatform" % "node-testkit" % "1.5.7-3964-SNAPSHOT" % "test", - "com.wavesplatform" % "node" % "1.5.7-3964-SNAPSHOT" % "provided", + "com.wavesplatform" % "node-testkit" % "1.5.8-SNAPSHOT" % "test", + "com.wavesplatform" % "node" % "1.5.8-SNAPSHOT" % "provided", "com.softwaremill.sttp.client3" % "core_2.13" % "3.9.8", "com.softwaremill.sttp.client3" %% "play-json" % "3.9.8", "com.github.jwt-scala" %% "jwt-play-json" % "10.0.1" diff --git a/docker/README.md b/docker/README.md index a274f9c8..3ff4c9b5 100644 --- a/docker/README.md +++ b/docker/README.md @@ -3,9 +3,13 @@ Units Network node consists of Waves blockchain node, Consensus Client extension ## Prerequisites * Install [Docker Compose](https://docs.docker.com/compose/install/). -* Generate JWT secret and execution client keys by running `./gen-keys.sh`. This script requires `openssl` and `xxd`. +* 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 besu on Linux, you need to manually create data & log directories and set appropriate permissions: +``` +install -d -o 1000 -g 1000 data/besu logs/besu +``` ## 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): @@ -17,19 +21,17 @@ Units Network node consists of Waves blockchain node, Consensus Client extension * 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! ## Launching -To run besu on Linux, you need to manually create data & log directories and set appropriate permissions: -``` -install -d -o 1000 -g 1000 data/besu logs/besu -``` +There are two profiles in the compose file: `besu` and `geth`, each starting a respective execution client. You can choose which one to run by specifying either `--profile besu` or `--profile geth` on the command line. + Running, stopping and updating with besu in testnet: ``` -docker compose --env-file=testnet.env up -d -docker compose --env-file=testnet.env down -docker compose --env-file=testnet.env pull +docker compose --profile besu --env-file=testnet.env up -d +docker compose --profile besu --env-file=testnet.env down +docker compose --profile besu --env-file=testnet.env pull ``` Running, stopping and updating with geth in testnet: ``` -docker compose -f docker-compose-geth.yml --env-file=testnet.env up -d -docker compose -f docker-compose-geth.yml --env-file=testnet.env down -docker compose -f docker-compose-geth.yml --env-file=testnet.env pull +docker compose --profile geth --env-file=testnet.env up -d +docker compose --profile geth --env-file=testnet.env down +docker compose --profile geth --env-file=testnet.env pull ``` diff --git a/docker/docker-compose-geth.yml b/docker/docker-compose-geth.yml deleted file mode 100644 index 767ddf80..00000000 --- a/docker/docker-compose-geth.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - geth: - extends: - file: ./services/geth.yml - service: geth - waves-node: - extends: - file: ./services/waves-node.yml - service: waves-node - environment: - EXECUTION_CLIENT: geth diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index eebb3c26..61e2af5b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,11 +1,28 @@ services: besu: + profiles: [besu] + hostname: execution-client extends: file: ./services/besu.yml service: besu + + geth-init: + profiles: [geth] + extends: + file: ./services/geth.yml + service: geth-init + + geth: + profiles: [geth] + hostname: execution-client + extends: + file: ./services/geth.yml + service: geth + depends_on: + geth-init: + condition: service_completed_successfully + waves-node: extends: file: ./services/waves-node.yml service: waves-node - environment: - EXECUTION_CLIENT: besu diff --git a/docker/gen-keys.sh b/docker/gen-keys.sh index c9aa23dd..328a2ae3 100755 --- a/docker/gen-keys.sh +++ b/docker/gen-keys.sh @@ -1,4 +1,4 @@ #!/bin/sh mkdir -p data/secrets -openssl rand 32 | xxd -p -c 32 > data/secrets/p2p-key -openssl rand 32 | xxd -p -c 32 > data/secrets/jwtsecret +openssl rand -hex 32 | tr -d "\n" > data/secrets/p2p-key +openssl rand -hex 32 | tr -d "\n" > data/secrets/jwtsecret diff --git a/docker/services/besu.yml b/docker/services/besu.yml index e9444a8c..bc75690f 100644 --- a/docker/services/besu.yml +++ b/docker/services/besu.yml @@ -11,7 +11,6 @@ services: - --rpc-http-api=ETH,NET,WEB3,TXPOOL,TRACE - --rpc-http-cors-origins=all - --rpc-ws-enabled - - --discovery-dns-url=enrtree://AIRIZFFZSCSIVHXTKA44WYZQJMR75FLTGWJ5TUNEW5IP7QKZDLBRK@${NETWORK}-nodes.unit0.dev - --discovery-enabled=true - --engine-rpc-enabled - --engine-jwt-secret=/etc/secrets/jwtsecret @@ -31,6 +30,5 @@ services: ports: - '30303:30303/tcp' - '30303:30303/udp' - - '8545:8545' environment: - LOG4J_CONFIGURATION_FILE=/etc/besu/log4j2.xml diff --git a/docker/services/geth.yml b/docker/services/geth.yml index d31ec651..f64288de 100644 --- a/docker/services/geth.yml +++ b/docker/services/geth.yml @@ -1,4 +1,12 @@ services: + geth-init: + container_name: geth-init + image: ethereum/client-go:stable + entrypoint: /tmp/init-geth.sh + volumes: + - ../genesis-${NETWORK}.json:/tmp/genesis.json + - ../data/geth:/root/.ethereum + - ../init-geth.sh:/tmp/init-geth.sh geth: container_name: geth image: ethereum/client-go:stable diff --git a/docker/testnet.env b/docker/testnet.env index be67a404..52b00a8d 100644 --- a/docker/testnet.env +++ b/docker/testnet.env @@ -1,5 +1,5 @@ NETWORK=testnet NETWORK_ID=88817 -WAVES_NODE_TAG=L2-test -WAVES_DECLARED_ADDRESS=1.2.3.4:6868 -UNITS_DECLARED_ADDRESS=1.2.3.4:6865 +WAVES_NODE_TAG=testnet +#WAVES_DECLARED_ADDRESS=1.2.3.4:6868 +#UNITS_DECLARED_ADDRESS=1.2.3.4:6865 diff --git a/docker/waves-testnet.conf b/docker/waves-testnet.conf index c1640323..9450cb72 100644 --- a/docker/waves-testnet.conf +++ b/docker/waves-testnet.conf @@ -22,14 +22,15 @@ waves { } l2 { - chain-contract = 3MsqKJ6o1ABE37676cHHBxJRs6huYTt72ch - execution-client-address = "http://${EXECUTION_CLIENT}:8551" + chain-contract = 3Msx4Aq69zWUKy4d1wyKnQ4ofzEDAfv5Ngf + execution-client-address = "http://execution-client: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" ] diff --git a/local-network/deploy/src/waves-txs.ts b/local-network/deploy/src/waves-txs.ts index b2b3c6cf..8e861c79 100644 --- a/local-network/deploy/src/waves-txs.ts +++ b/local-network/deploy/src/waves-txs.ts @@ -54,9 +54,8 @@ export const ccMinerJoin1 = wt.invokeScript( args: [ { // Reward address - type: "binary", - // 0x7dbcf9c6c3583b76669100f9be3caf6d722bc9f9 - value: "base64:fbz5xsNYO3ZmkQD5vjyvbXIryfk=" + type: "string", + value: "0x7dbcf9c6c3583b76669100f9be3caf6d722bc9f9" } ] } @@ -74,9 +73,8 @@ export const ccMinerJoin2 = wt.invokeScript( args: [ { // Reward address - type: "binary", - // 0xcf0b9e13fdd593f4ca26d36afcaa44dd3fdccbed - value: "base64:zwueE/3Vk/TKJtNq/KpE3T/cy+0=" + type: "string", + value: "0xcf0b9e13fdd593f4ca26d36afcaa44dd3fdccbed" } ] } @@ -131,4 +129,3 @@ export function mkE2CTransfer(senderPrivateKey: string, blockHash: string, merkl { privateKey: senderPrivateKey } ) } - diff --git a/src/test/resources/main.ride b/src/test/resources/main.ride index 32f63c8b..bc9d9f43 100644 --- a/src/test/resources/main.ride +++ b/src/test/resources/main.ride @@ -487,7 +487,7 @@ func appendBlock( } @Callable(i) -func join(rewardAddress: ByteVector) = { +func join(rewardAddressHex: String) = { # EL miner must sign a Network block by own private key func ensureNotOverrideOtherMinerPk(elAddressHex: String) = { match getBinary(minerPkKey(elAddressHex)) { @@ -500,6 +500,9 @@ func join(rewardAddress: ByteVector) = { } } + let parts = rewardAddressHex.split("0x") + let rewardAddress = parts[parts.size() - 1].fromBase16String() + if (!isContractSetup()) then throw("The contract has not yet set up") else if (i.originCaller.wavesBalance().generating < MIN_BALANCE) then @@ -513,8 +516,8 @@ func join(rewardAddress: ByteVector) = { then [] else { let newMiner = i.originCaller.toString() - let rewardAddressHex = rewardAddress.toBase16String() - strict check = ensureNotOverrideOtherMinerPk(rewardAddressHex) + let lowercaseRewardAddress = rewardAddress.toBase16String() + strict check = ensureNotOverrideOtherMinerPk(lowercaseRewardAddress) let newMiners = if (allMiners.size() == 0) @@ -531,8 +534,8 @@ func join(rewardAddress: ByteVector) = { } [ StringEntry(allMinersKey, newMiners), - StringEntry(minerRewardAddressKey(newMiner), "0x" + rewardAddressHex), - BinaryEntry(minerPkKey(rewardAddressHex), i.originCallerPublicKey) + StringEntry(minerRewardAddressKey(newMiner), "0x" + lowercaseRewardAddress), + BinaryEntry(minerPkKey(lowercaseRewardAddress), i.originCallerPublicKey) ] ++ deletePrevRewardAddressPk } } diff --git a/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala b/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala index 5a225953..56cde48b 100644 --- a/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala +++ b/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala @@ -13,7 +13,6 @@ import units.client.CommonBlockData import units.client.contract.HasConsensusLayerDappTxHelpers.* import units.client.contract.HasConsensusLayerDappTxHelpers.defaultFees.chainContract.* import units.eth.{EthAddress, EthereumConstants} -import units.util.HexBytesConverter trait HasConsensusLayerDappTxHelpers { def currentHitSource: ByteStr @@ -38,7 +37,7 @@ trait HasConsensusLayerDappTxHelpers { invoker = minerAccount, dApp = chainContractAddress, func = "join".some, - args = List(Terms.CONST_BYTESTR(ByteStr(HexBytesConverter.toBytes(elRewardAddress.hexNoPrefix))).explicitGet()), + args = List(Terms.CONST_STRING(elRewardAddress.hexNoPrefix).explicitGet()), fee = joinFee )