From 61f3eb7d4466800ab5f055a909188c43bd0955a8 Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Thu, 12 Sep 2024 16:14:02 +0400 Subject: [PATCH] local-network: a common config for Waves nodes --- local-network/README.md | 6 ++-- .../configs/wavesnode/{common => }/.gitignore | 0 .../configs/wavesnode/common/logback.xml | 15 ---------- .../{common => }/genesis-template.conf | 0 local-network/configs/wavesnode/logback.xml | 5 ++++ local-network/configs/wavesnode/waves-1.conf | 3 -- local-network/configs/wavesnode/waves-2.conf | 7 ----- .../{common/waves-common.conf => waves.conf} | 9 ++++-- local-network/docker-compose.yml | 15 ++++------ local-network/genesis-update.sh | 4 +-- .../ChainContractSnapshotClient.scala | 29 ------------------- 11 files changed, 22 insertions(+), 71 deletions(-) rename local-network/configs/wavesnode/{common => }/.gitignore (100%) delete mode 100644 local-network/configs/wavesnode/common/logback.xml rename local-network/configs/wavesnode/{common => }/genesis-template.conf (100%) create mode 100644 local-network/configs/wavesnode/logback.xml delete mode 100644 local-network/configs/wavesnode/waves-1.conf delete mode 100644 local-network/configs/wavesnode/waves-2.conf rename local-network/configs/wavesnode/{common/waves-common.conf => waves.conf} (95%) delete mode 100644 src/main/scala/units/client/contract/ChainContractSnapshotClient.scala diff --git a/local-network/README.md b/local-network/README.md index c87e3a29..9e8ef30a 100644 --- a/local-network/README.md +++ b/local-network/README.md @@ -29,7 +29,7 @@ See [./deploy](./deploy/). # Keys * Node HTTP API Key: `testapi` -* CL accounts (see [genesis-template.conf](./configs/wavesnode/common/genesis-template.conf) for more information): +* CL accounts (see [genesis-template.conf](configs/wavesnode/genesis-template.conf) for more information): * Node wallet seed: * wavesnode-1: `devnet-1` * wavesnode-2: `devnet-2` @@ -100,5 +100,5 @@ See [Besu configuration](configs/besu/). ## How to change Waves initial miners or time between blocks -1. Update [genesis-template.conf](./configs/wavesnode/common/genesis-template.conf). -2. [genesis.conf](./configs/wavesnode/common/genesis.conf) will be updated in [restart.sh](./restart.sh). +1. Update [genesis-template.conf](configs/wavesnode/genesis-template.conf). +2. [genesis.conf](configs/wavesnode/genesis.conf) will be updated in [restart.sh](./restart.sh). diff --git a/local-network/configs/wavesnode/common/.gitignore b/local-network/configs/wavesnode/.gitignore similarity index 100% rename from local-network/configs/wavesnode/common/.gitignore rename to local-network/configs/wavesnode/.gitignore diff --git a/local-network/configs/wavesnode/common/logback.xml b/local-network/configs/wavesnode/common/logback.xml deleted file mode 100644 index d2c6282e..00000000 --- a/local-network/configs/wavesnode/common/logback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - /var/log/waves/ChainContractSnapshotClient.log - - ${default.pattern} - - - - - - - diff --git a/local-network/configs/wavesnode/common/genesis-template.conf b/local-network/configs/wavesnode/genesis-template.conf similarity index 100% rename from local-network/configs/wavesnode/common/genesis-template.conf rename to local-network/configs/wavesnode/genesis-template.conf diff --git a/local-network/configs/wavesnode/logback.xml b/local-network/configs/wavesnode/logback.xml new file mode 100644 index 00000000..6d094c09 --- /dev/null +++ b/local-network/configs/wavesnode/logback.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/local-network/configs/wavesnode/waves-1.conf b/local-network/configs/wavesnode/waves-1.conf deleted file mode 100644 index d997e641..00000000 --- a/local-network/configs/wavesnode/waves-1.conf +++ /dev/null @@ -1,3 +0,0 @@ -include "common/waves-common.conf" - -waves.wallet.seed = HnyGuCEnV1A # devnet-1 , addr: 3FNraPMYcfuGREcxorNSEBHgNLjmYtaHy9e diff --git a/local-network/configs/wavesnode/waves-2.conf b/local-network/configs/wavesnode/waves-2.conf deleted file mode 100644 index db29bc7d..00000000 --- a/local-network/configs/wavesnode/waves-2.conf +++ /dev/null @@ -1,7 +0,0 @@ -include "common/waves-common.conf" - -waves { - wallet.seed = HnyGuCEnV1B # devnet-2 , addr: 3FSrRN8X7cDsLyYTScS8Yf8KSwZgJBwf1jU - - l2.jwt-secret-file = /etc/secrets/jwtsecret -} diff --git a/local-network/configs/wavesnode/common/waves-common.conf b/local-network/configs/wavesnode/waves.conf similarity index 95% rename from local-network/configs/wavesnode/common/waves-common.conf rename to local-network/configs/wavesnode/waves.conf index 90015443..1c4d6042 100644 --- a/local-network/configs/wavesnode/common/waves-common.conf +++ b/local-network/configs/wavesnode/waves.conf @@ -113,7 +113,9 @@ waves { l2 { chain-contract = "3FdaanzgX4roVgHevhq8L8q42E7EZL9XTQr" - execution-client-address = "http://"${EXECUTION_CLIENT}":8551" + execution-client-address = "http://ec-"${NODE_NUMBER}":8551" + jwt-secret-file = /etc/secrets/jwtsecret + network { bind-address = "0.0.0.0" port = 6865 @@ -159,7 +161,10 @@ waves { units.ConsensusClient ] - wallet.password = "" + wallet { + seed = ${WAVES_WALLET_SEED} + password = "" + } } kamon.enable = no diff --git a/local-network/docker-compose.yml b/local-network/docker-compose.yml index 86b12367..06d85b41 100644 --- a/local-network/docker-compose.yml +++ b/local-network/docker-compose.yml @@ -39,14 +39,12 @@ services: - "127.0.0.1:16869:6869" environment: - WAVES_HEAP_SIZE=2g - - JAVA_OPTS=-Dwaves.config.directory=/etc/waves -Dlogback.file.level=TRACE - NODE_NUMBER=1 - - EXECUTION_CLIENT=ec-1 + - WAVES_WALLET_SEED=HnyGuCEnV1A # devnet-1, addr: 3FNraPMYcfuGREcxorNSEBHgNLjmYtaHy9e volumes: + - ./configs/wavesnode:/etc/waves:ro + - ./configs/ec-common/jwtsecret-1.hex:/etc/secrets/jwtsecret:ro - ./logs/wavesnode-1:/var/log/waves - - ./configs/wavesnode/common:/etc/waves/common:ro - - ./configs/wavesnode/common/logback.xml:/etc/waves/logback.xml:ro - - ./configs/wavesnode/waves-1.conf:/etc/waves/waves.conf:ro depends_on: ec-1: condition: service_healthy @@ -60,13 +58,10 @@ services: - "127.0.0.1:26869:6869" environment: - WAVES_HEAP_SIZE=2g - - JAVA_OPTS=-Dwaves.config.directory=/etc/waves -Dlogback.file.level=TRACE - NODE_NUMBER=2 - - EXECUTION_CLIENT=ec-2 + - WAVES_WALLET_SEED=HnyGuCEnV1B # devnet-2, addr: 3FSrRN8X7cDsLyYTScS8Yf8KSwZgJBwf1jU volumes: - - ./configs/wavesnode/common:/etc/waves/common:ro - - ./configs/wavesnode/common/logback.xml:/etc/waves/logback.xml:ro - - ./configs/wavesnode/waves-2.conf:/etc/waves/waves.conf:ro + - ./configs/wavesnode:/etc/waves:ro - ./configs/ec-common/jwtsecret-2.hex:/etc/secrets/jwtsecret:ro - ./logs/wavesnode-2:/var/log/waves depends_on: diff --git a/local-network/genesis-update.sh b/local-network/genesis-update.sh index 25872f6e..abcc8fd6 100755 --- a/local-network/genesis-update.sh +++ b/local-network/genesis-update.sh @@ -18,7 +18,7 @@ else fi java -cp "${DIR}/.cache/waves.jar" com.wavesplatform.GenesisBlockGenerator \ - "${DIR}/configs/wavesnode/common/genesis-template.conf" \ - "${DIR}/configs/wavesnode/common/genesis.conf" > /dev/null + "${DIR}/configs/wavesnode/genesis-template.conf" \ + "${DIR}/configs/wavesnode/genesis.conf" > /dev/null echo "Genesis config updated" diff --git a/src/main/scala/units/client/contract/ChainContractSnapshotClient.scala b/src/main/scala/units/client/contract/ChainContractSnapshotClient.scala deleted file mode 100644 index be643b3a..00000000 --- a/src/main/scala/units/client/contract/ChainContractSnapshotClient.scala +++ /dev/null @@ -1,29 +0,0 @@ -package units.client.contract - -import cats.kernel.Monoid -import com.wavesplatform.account.Address -import com.wavesplatform.api.http.StateSnapshotJson -import com.wavesplatform.state.{DataEntry, NewTransactionInfo, StateSnapshot, TxMeta} -import com.wavesplatform.transaction.smart.InvokeScriptTransaction -import com.wavesplatform.utils.ScorexLogging -import play.api.libs.json.Json - -class ChainContractSnapshotClient(val contract: Address, snapshot: StateSnapshot) extends ChainContractClient with ScorexLogging { - - private val totalSnapshot: StateSnapshot = - Monoid[StateSnapshot].combineAll(snapshot +: snapshot.transactions.values.toSeq.map(_.snapshot)) - - def logDataChanges(): Unit = if (totalSnapshot.accountData.nonEmpty) { - snapshot.transactions.foreach { - case (id, txInfo @ NewTransactionInfo(tx: InvokeScriptTransaction, txSnapshot, _, TxMeta.Status.Succeeded, _)) - if tx.dApp == contract && txSnapshot.accountData.nonEmpty => // Don't resolve a possible alias, because it is only for logs - val dataJson = Json.toJson(StateSnapshotJson.fromSnapshot(txSnapshot, txInfo.status).accountData) - log.trace(s"[$id] Data changes: $dataJson") - - case _ => - } - } - - override def extractData(key: String): Option[DataEntry[?]] = - totalSnapshot.accountData.get(contract).flatMap(_.get(key)) -}