From 3d6864e90a02f6e1c7b9752ebecb509be3329aa0 Mon Sep 17 00:00:00 2001 From: Sergey Nazarov Date: Tue, 22 Oct 2024 14:37:03 +0300 Subject: [PATCH] DAO Rewards (#25) --- docker/services/waves-node.yml | 2 +- local-network/all-images-build.sh | 2 +- .../configs/wavesnode/genesis-template.conf | 67 +++++++++++-------- local-network/configs/wavesnode/waves.conf | 21 ------ local-network/configs/wavesnode/wavesnode.yml | 2 +- local-network/consensus_client-image-build.sh | 2 +- local-network/deploy/Dockerfile | 10 +-- local-network/deploy/deploy.py | 5 +- local-network/deploy/local/__init__.py | 0 local-network/deploy/pyproject.toml | 6 +- local-network/docker-compose.yml | 18 ++++- local-network/genesis-update.sh | 23 +------ local-network/restart.sh | 1 - src/test/resources/main.ride | 65 +++++++++++++----- .../units/BaseIntegrationTestSuite.scala | 7 +- src/test/scala/units/TestSettings.scala | 6 +- .../HasConsensusLayerDappTxHelpers.scala | 6 +- 17 files changed, 130 insertions(+), 113 deletions(-) delete mode 100644 local-network/deploy/local/__init__.py diff --git a/docker/services/waves-node.yml b/docker/services/waves-node.yml index a1921bf5..970c4aae 100644 --- a/docker/services/waves-node.yml +++ b/docker/services/waves-node.yml @@ -1,7 +1,7 @@ services: waves-node: container_name: waves-node - image: ghcr.io/unitsnetwork/consensus-client:${WAVES_NODE_TAG:-${NETWORK}} + image: consensus-client:local stop_grace_period: 5m ports: - "6869:6869" diff --git a/local-network/all-images-build.sh b/local-network/all-images-build.sh index d709b081..1fe4b1af 100755 --- a/local-network/all-images-build.sh +++ b/local-network/all-images-build.sh @@ -13,6 +13,6 @@ echo "Update deploy image" docker compose build deploy --no-cache echo "Update test image" -docker compose build test +docker compose build tests echo "Done." diff --git a/local-network/configs/wavesnode/genesis-template.conf b/local-network/configs/wavesnode/genesis-template.conf index 27f07fdb..20c172c9 100644 --- a/local-network/configs/wavesnode/genesis-template.conf +++ b/local-network/configs/wavesnode/genesis-template.conf @@ -9,48 +9,57 @@ genesis-generator { # the sum of shares should be <= initial-balance distributions = [ # CL miner on wavesnode-1 - # Seed text: devnet-1 - # Nonce: 0 - # Seed: HnyGuCEnV1A - # Private account key: DwPvPGEp3LPg5gVRz7Pqd8mHa6dWK9dXtP4XDmKTz6ga - # Public account key: Atej9hrXKQS6cLjuhjEnKyF5boyYGSp5VBZvfcmF9FqY - # Address: 3FNraPMYcfuGREcxorNSEBHgNLjmYtaHy9e + # Seed text: devnet-1 + # Nonce: 0 + # Seed: HnyGuCEnV1A + # Private key: DwPvPGEp3LPg5gVRz7Pqd8mHa6dWK9dXtP4XDmKTz6ga + # Public key: Atej9hrXKQS6cLjuhjEnKyF5boyYGSp5VBZvfcmF9FqY + # Address: 3FNraPMYcfuGREcxorNSEBHgNLjmYtaHy9e { seed-text = "devnet-1", nonce = 0, amount = 998036000000000 } # Chain contract on wavesnode-1 - # Seed text: devnet-1 - # Nonce: 2 - # Seed: HnyGuCEnV1A - # Private account key: 7TzN4c2XgvSN28gEbvW5wmUecfa4SrPRLXjgr5DRfQMG - # Public account key: 5yxSxDhB2ZL5agYnU6WRtEqPg3T3FfUY3zouKrMpnTX6 + # Seed text: devnet-1 + # Nonce: 2 + # Seed: HnyGuCEnV1A + # Private key: 7TzN4c2XgvSN28gEbvW5wmUecfa4SrPRLXjgr5DRfQMG + # Public key: 5yxSxDhB2ZL5agYnU6WRtEqPg3T3FfUY3zouKrMpnTX6 # Address: 3FdaanzgX4roVgHevhq8L8q42E7EZL9XTQr { seed-text = "devnet-1", nonce = 2, amount = 20000000000 } + # DAO Address + # Seed text: devnet dao 1 + # Nonce: 0 + # Seed: 2ttKSSq2o7VU6kFwN + # Private key: EXC4wafzVus3tmesKEouuewZHGNzEG5qxNHMN66XAiG4 + # Public key: 7S2iCGvRcx3bJA3y8R9k6sJdVATg3ss8r4RuW1S8VriA + # Address: 3FYp54DX9Np9uouxBtnnCFPYWzz7K3kvSD2 + { seed-text = "devnet dao 1", nonce = 0, amount = 100000000 } + # CL miner on wavesnode-2 - # Seed text: devnet-2 - # Nonce: 0 - # Seed: HnyGuCEnV1B - # Private account key: F17jrRWmrR7en6eY6ptvnUTNqc9W8RSP34hpX7bNhbht - # Public account key: FuibB1rJ1uHVvvY6FNmhLqnbvQBNtziWbh7zh5c1CQCG - # Address: 3FSrRN8X7cDsLyYTScS8Yf8KSwZgJBwf1jU + # Seed text: devnet-2 + # Nonce: 0 + # Seed: HnyGuCEnV1B + # Private key: F17jrRWmrR7en6eY6ptvnUTNqc9W8RSP34hpX7bNhbht + # Public key: FuibB1rJ1uHVvvY6FNmhLqnbvQBNtziWbh7zh5c1CQCG + # Address: 3FSrRN8X7cDsLyYTScS8Yf8KSwZgJBwf1jU { seed-text = "devnet-2", nonce = 0, amount = 998036000000000 } # Additional addresses - # Seed text: devnet-0 - # Nonce: 0 - # Seed: HnyGuCEnV19 - # Private account key: 8aYKVCJVYfcSQeSH1kM4D2e4Fcj5cAQzMh8uZ5hW2tB9 - # Public account key: GRKksNikCNXYT7HqxCnqzjP5pf4NctgtTnmCvCMDEhAT - # Address: 3Ffcu52v7ETMAFhNAqQvHsv4JuQjEVP9q6E + # Seed text: devnet-0 + # Nonce: 0 + # Seed: HnyGuCEnV19 + # Private key: 8aYKVCJVYfcSQeSH1kM4D2e4Fcj5cAQzMh8uZ5hW2tB9 + # Public key: GRKksNikCNXYT7HqxCnqzjP5pf4NctgtTnmCvCMDEhAT + # Address: 3Ffcu52v7ETMAFhNAqQvHsv4JuQjEVP9q6E { seed-text = "devnet-0", nonce = 0, amount = 2305842994213693951 } - # Seed text: devnet-0 - # Nonce: 1 - # Seed: HnyGuCEnV19 - # Private account key: 5tE8jwZ3B4eLTvdz7LqEBMcmspoqXD9nPCEfcZgh2BeV - # Public account key: BArfnBGQ9gkNHC2EftXf42uJuBioSffZiJoyYCTtwxof - # Address: 3FQFFWxMCDmyZhkRzKA7QiAZL4RKMhJvFnu + # Seed text: devnet-0 + # Nonce: 1 + # Seed: HnyGuCEnV19 + # Private key: 5tE8jwZ3B4eLTvdz7LqEBMcmspoqXD9nPCEfcZgh2BeV + # Public key: BArfnBGQ9gkNHC2EftXf42uJuBioSffZiJoyYCTtwxof + # Address: 3FQFFWxMCDmyZhkRzKA7QiAZL4RKMhJvFnu { seed-text = "devnet-0", nonce = 1, amount = 2305842994213693952 } ] } diff --git a/local-network/configs/wavesnode/waves.conf b/local-network/configs/wavesnode/waves.conf index b7d38280..6473e406 100644 --- a/local-network/configs/wavesnode/waves.conf +++ b/local-network/configs/wavesnode/waves.conf @@ -1,7 +1,5 @@ # Waves node settings waves { - directory = /var/lib/waves - db.directory = /var/lib/waves/data db.store-state-hashes = true # Blockchain settings @@ -13,16 +11,6 @@ waves { feature-check-blocks-period = 1 blocks-for-feature-activation = 1 min-asset-info-update-interval = 7 - generation-balance-depth-from-50-to-1000-after-height = 0 - last-time-based-fork-parameter = 1492128000000 - reset-effective-balances-at-height = 4650 - block-version-3-after-height = 0 - max-complexity-in-block = 10000000000 - double-features-periods-after-height = 1000000000 - max-transaction-time-back-offset = 120m - max-transaction-time-forward-offset = 90m - lease-expiration = 1000000 - min-block-time = 12000ms delay-delta = 3 @@ -68,7 +56,6 @@ waves { miner { enable = yes micro-block-interval = 200ms - max-transactions-in-key-block = 0 max-transactions-in-micro-block = 500 min-micro-block-age = 0ms quorum = 0 @@ -97,9 +84,6 @@ waves { enable-peers-exchange = no enable-blacklisting = no - max-inbound-connections = 70 - max-outbound-connections = 70 - traffic-logger { # Codes of transmitted messages to ignore. See MessageSpec.messageCode ignore-tx-messages = [] # BlockMessageSpec, TransactionsMessageSpec @@ -143,8 +127,6 @@ waves { # Hash of API key string api-key-hash = "2etchmPPsitn9VMShPjACKjWZ1M2sZLG7tsZqj9qEaRx" # hashSecure of "testapi" - api-key-different-host = yes - evaluate-script-complexity-limit = 52000 minimum-peers = 0 } @@ -166,6 +148,3 @@ waves { password = "" } } - -kamon.enable = no -metrics.enable = no diff --git a/local-network/configs/wavesnode/wavesnode.yml b/local-network/configs/wavesnode/wavesnode.yml index 8d7c9a2d..d7974394 100644 --- a/local-network/configs/wavesnode/wavesnode.yml +++ b/local-network/configs/wavesnode/wavesnode.yml @@ -1,6 +1,6 @@ services: wavesnode: - image: unitsnetwork/consensus-client:main + image: ghcr.io/unitsnetwork/consensus-client:testnet pull_policy: never environment: JAVA_OPTS: -Dlogback.file.level=TRACE diff --git a/local-network/consensus_client-image-build.sh b/local-network/consensus_client-image-build.sh index 4603e4d1..6b52f2db 100755 --- a/local-network/consensus_client-image-build.sh +++ b/local-network/consensus_client-image-build.sh @@ -4,4 +4,4 @@ DIR="$(cd "$(dirname "$0")" && pwd)" cd "${DIR}/.." || exit sbt -J-Xmx4G -J-Xss4m -Dfile.encoding=UTF-8 -Dsbt.supershell=false buildTarballsForDocker -docker build -t unitsnetwork/consensus-client:main docker +docker build -t consensus-client:local docker diff --git a/local-network/deploy/Dockerfile b/local-network/deploy/Dockerfile index e4207f93..5e27b6a7 100644 --- a/local-network/deploy/Dockerfile +++ b/local-network/deploy/Dockerfile @@ -1,15 +1,7 @@ -FROM python:3.12-slim - -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl \ - git \ - gcc \ - libc6-dev \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +FROM python:3.9 WORKDIR /usr/src/app -COPY local/__init__.py ./local/ COPY pyproject.toml ./ RUN pip install --no-cache-dir --editable . diff --git a/local-network/deploy/deploy.py b/local-network/deploy/deploy.py index ac26cb23..4e10f9b6 100644 --- a/local-network/deploy/deploy.py +++ b/local-network/deploy/deploy.py @@ -43,7 +43,10 @@ log.info(f"Genesis block hash: {el_genesis_block_hash}") - r = network.cl_chain_contract.setup(el_genesis_block_hash) + r = network.cl_chain_contract.setup( + el_genesis_block_hash, + daoAddress = '3FYp54DX9Np9uouxBtnnCFPYWzz7K3kvSD2' + ) waves.force_success(log, r, "Can not setup the chain contract") cl_token = network.cl_chain_contract.getToken() diff --git a/local-network/deploy/local/__init__.py b/local-network/deploy/local/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/local-network/deploy/pyproject.toml b/local-network/deploy/pyproject.toml index c59c87de..01fdf4f2 100644 --- a/local-network/deploy/pyproject.toml +++ b/local-network/deploy/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=75.0", "wheel"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] @@ -8,10 +8,10 @@ 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", + "units-network @ git+https://github.com/UnitsNetwork/examples.git@dao-rewards", ] readme = "README.md" -requires-python = ">=3.12" +requires-python = ">=3.9" license = { text = "MIT License" } keywords = ["units network", "blockchain", "waves"] diff --git a/local-network/docker-compose.yml b/local-network/docker-compose.yml index 052a337f..deeca46d 100644 --- a/local-network/docker-compose.yml +++ b/local-network/docker-compose.yml @@ -36,7 +36,7 @@ services: extends: file: ./configs/wavesnode/wavesnode.yml service: wavesnode - image: unitsnetwork/consensus-client:${WAVES_NODE_1_TAG:-main} + image: ${WAVES_NODE_IMAGE_1:-${WAVES_NODE_IMAGE:-consensus-client:local}} ports: - "127.0.0.1:16869:6869" environment: @@ -47,6 +47,8 @@ services: depends_on: ec-1: condition: service_healthy + update-genesis: + condition: service_completed_successfully wavesnode-2: container_name: wavesnode-2 @@ -54,7 +56,7 @@ services: extends: file: ./configs/wavesnode/wavesnode.yml service: wavesnode - image: unitsnetwork/consensus-client:${WAVES_NODE_2_TAG:-main} + image: ${WAVES_NODE_IMAGE_2:-${WAVES_NODE_IMAGE:-consensus-client:local}} ports: - "127.0.0.1:26869:6869" environment: @@ -65,6 +67,18 @@ services: depends_on: ec-2: 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} + volumes: + - ./configs/wavesnode:/tmp/configs + command: + - gengen + - /tmp/configs/genesis-template.conf + - /tmp/configs/genesis.conf deploy: container_name: deploy diff --git a/local-network/genesis-update.sh b/local-network/genesis-update.sh index abcc8fd6..159433bc 100755 --- a/local-network/genesis-update.sh +++ b/local-network/genesis-update.sh @@ -1,24 +1,3 @@ #!/usr/bin/env bash -DIR="$(cd "$(dirname "$0")" && pwd)" -cd "${DIR}" || exit - -CACHE_DIR=".cache" -JAR_FILE="waves.jar" -URL="https://github.com/wavesplatform/Waves/releases/download/v1.5.6/waves-all-1.5.6.jar" - -mkdir -p "$CACHE_DIR" - -if [ ! -f "$CACHE_DIR/$JAR_FILE" ]; then - echo "Downloading $JAR_FILE..." - curl -L -o "$CACHE_DIR/$JAR_FILE" "$URL" - echo "Download completed." -else - echo "$JAR_FILE already exists in $CACHE_DIR." -fi - -java -cp "${DIR}/.cache/waves.jar" com.wavesplatform.GenesisBlockGenerator \ - "${DIR}/configs/wavesnode/genesis-template.conf" \ - "${DIR}/configs/wavesnode/genesis.conf" > /dev/null - -echo "Genesis config updated" +docker compose up --no-deps update-genesis diff --git a/local-network/restart.sh b/local-network/restart.sh index 9e1766b3..fadc52bc 100755 --- a/local-network/restart.sh +++ b/local-network/restart.sh @@ -21,6 +21,5 @@ cp ../src/test/resources/main.ride ./deploy/setup/waves/ export COMPOSE_PROFILES="${COMPOSE_PROFILES:-}" echo "Compose profiles are: ${COMPOSE_PROFILES}" -./genesis-update.sh docker compose up -d docker compose logs deploy tests -f diff --git a/src/test/resources/main.ride b/src/test/resources/main.ride index bc9d9f43..1f5456e3 100644 --- a/src/test/resources/main.ride +++ b/src/test/resources/main.ride @@ -16,6 +16,8 @@ let MAX_CL_TO_EL_TRANSFERS = 16 # 1024 symbols let zeroesStr = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +let offsets_100 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::".split_4C("") + let allMinersKey = "allMiners" let mainChainIdKey = "mainChainId" let lastChainIdKey = "lastChainId" @@ -26,6 +28,8 @@ let finalizedBlockKey = "finalizedBlock" let tokenIdKey = "tokenId" let elBridgeAddressKey = "elBridgeAddress" let nativeTransfersCountKey = "nativeTransfersCount" +let daoAddressKey = "daoAddress" +let daoRewardKey = "daoReward" func pad(i: Int) = { let s = i.toString() @@ -185,14 +189,13 @@ let (computedGenerator, computedTotalBalance) = { let (mclbIgnored1, mainChainEpoch) = blockMeta(mainChainLastBlock) -func calculateFinalizedBlockHash(curMiner: Address, curPrevEpoch: Int, curLastBlockHash: String) = { - let offsets_100 = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::".split_4C("") +func calculateFinalizedBlockHashAndEpoch(curMiner: Address, curPrevEpoch: Int, curLastBlockHash: String) = { let halfBalance = computedTotalBalance / 2 func step(prev: (Int, String|Unit, Int, List[Address]), next: String) = { - let (thisEpoch, maybeSafeEpoch, totalBalance, prevMiners) = prev - match maybeSafeEpoch { + let (thisEpoch, maybeFinalizedBlockHash, totalBalance, prevMiners) = prev + match maybeFinalizedBlockHash { case _: Unit => let (miner, prevEpoch, lastBlockHash) = if (thisEpoch == height) then (curMiner, curPrevEpoch, curLastBlockHash) @@ -211,12 +214,11 @@ func calculateFinalizedBlockHash(curMiner: Address, curPrevEpoch: Int, curLastBl } } - let (fallbackEpoch, finalizedBlockHashOpt) = FOLD<100>(offsets_100, (height, unit, 0, []), step) - match finalizedBlockHashOpt { + let (finalizedEpoch, finalizedBlockHashOpt) = FOLD<100>(offsets_100, (height, unit, 0, []), step) + (match finalizedBlockHashOpt { case finalizedBlockHash: String => finalizedBlockHash - case _ => - epochMeta(fallbackEpoch).value()._3 - } + case _ => epochMeta(finalizedEpoch).value()._3 + }, finalizedEpoch) } func supportingBalance(chainId: Int) = { @@ -231,8 +233,8 @@ func supportingBalance(chainId: Int) = { } } let allGenerators = getStringValue(supportersKey(chainId)).split_4C(SEP) - let (balance, _g) = FOLD<100>(allGenerators, (0, []), addBalance) - balance + let res = FOLD<100>(allGenerators, (0, []), addBalance) + res._1 } func isContractSetup() = { @@ -318,11 +320,37 @@ func validateBlockHash(hexStr: String) = { } func getUpdateFinalizedBlockAction(caller: Address, newBlockHashHex: String, prevEpoch: Int) = { - let curFinalizedBlockHeight = blockMeta(getStringValue(finalizedBlockKey))._1 - let newFinalizedBlockHash = calculateFinalizedBlockHash(caller, prevEpoch, newBlockHashHex) - if (newFinalizedBlockHash == newBlockHashHex || blockMeta(newFinalizedBlockHash)._1 > curFinalizedBlockHeight) + let curFinalizedBlockMeta = blockMeta(getStringValue(finalizedBlockKey)) + let (newFinalizedBlockHash, newFinalizedEpoch) = calculateFinalizedBlockHashAndEpoch(caller, prevEpoch, newBlockHashHex) + + let rewardActions = match getString(daoAddressKey) { + case addr: String => + if newFinalizedEpoch == curFinalizedBlockMeta._2 then [] else { + func countNonEmptyEpochs(acc: (Int, Int), next: String) = + if acc._1 == curFinalizedBlockMeta._2 then acc + else match epochMeta(acc._1) { + case m: (Address, Int, String) => (m._2, acc._2 + 1) + case _ => acc + } + + let startFromEpoch = if newFinalizedEpoch == height then prevEpoch else epochMeta(newFinalizedEpoch).valueOrErrorMessage("no prev epoch for start")._2 + let daoRewards = FOLD<100>(offsets_100, (startFromEpoch, 1), countNonEmptyEpochs) + let reissueAmount = daoRewards._2 * getIntegerValue(daoRewardKey) + let tokenId = getStringValue(tokenIdKey).fromBase58String() + [ + Reissue(tokenId, reissueAmount, true), + ScriptTransfer(Address(addr.fromBase58String()), reissueAmount, tokenId) + ] + } + + case _ => [] + } + + rewardActions ++ ( + if (newFinalizedBlockHash == newBlockHashHex || blockMeta(newFinalizedBlockHash)._1 > curFinalizedBlockMeta._1) then [StringEntry(finalizedBlockKey, newFinalizedBlockHash)] else [] + ) } @Callable(i) @@ -648,7 +676,7 @@ func withdraw(blockHashHex: String, merkleProof: List[ByteVector], transferIndex # genesisBlockHashHex without 0x @Callable(i) -func setup(genesisBlockHashHex: String, minerRewardInGwei: Int) = { +func setup(genesisBlockHashHex: String, minerRewardInGwei: Int, daoAddress: String, daoReward: Int) = { if (isContractSetup()) then throw("The contract has been already set up") else if (minerRewardInGwei < 0) then throw("The miner reward must be nonnegative") else { @@ -672,6 +700,11 @@ func setup(genesisBlockHashHex: String, minerRewardInGwei: Int) = { -1 # lastC2ETransferIndex ) + let daoEntries = if daoAddress == "" then [] else [ + StringEntry(daoAddressKey, Address(daoAddress.fromBase58String()).toString()), + IntegerEntry(daoRewardKey, if daoReward > 0 then daoReward else throw("invalid DAO reward amount")) + ] + [ genesisBlockMeta, StringEntry(chainFirstBlockIdKey(0), genesisBlockHashHex), @@ -682,6 +715,6 @@ func setup(genesisBlockHashHex: String, minerRewardInGwei: Int) = { issue, StringEntry(tokenIdKey, tokenId.toBase58String()), StringEntry(elBridgeAddressKey, "0x0000000000000000000000000000000000006a7e") - ] + ] ++ daoEntries } } diff --git a/src/test/scala/units/BaseIntegrationTestSuite.scala b/src/test/scala/units/BaseIntegrationTestSuite.scala index c94b4e42..e6f07542 100644 --- a/src/test/scala/units/BaseIntegrationTestSuite.scala +++ b/src/test/scala/units/BaseIntegrationTestSuite.scala @@ -37,7 +37,12 @@ trait BaseIntegrationTestSuite val txs = List( d.chainContract.setScript(), - d.chainContract.setup(d.ecGenesisBlock, elMinerDefaultReward.amount.longValue()) + d.chainContract.setup( + d.ecGenesisBlock, + elMinerDefaultReward.amount.longValue(), + defaultSettings.daoRewardAccount.map(_.toAddress), + defaultSettings.daoRewardAmount + ) ) ++ settings.initialMiners.map { x => d.chainContract.join(x.account, x.elRewardAddress) } diff --git a/src/test/scala/units/TestSettings.scala b/src/test/scala/units/TestSettings.scala index e5b5117e..80e3ef52 100644 --- a/src/test/scala/units/TestSettings.scala +++ b/src/test/scala/units/TestSettings.scala @@ -1,7 +1,7 @@ package units import com.typesafe.config.ConfigFactory -import com.wavesplatform.account.SeedKeyPair +import com.wavesplatform.account.{KeyPair, SeedKeyPair} import com.wavesplatform.db.WithState.AddrWithBalance import com.wavesplatform.settings.WavesSettings import com.wavesplatform.test.{DomainPresets, NumericExt} @@ -12,7 +12,9 @@ import units.eth.EthAddress case class TestSettings( wavesSettings: WavesSettings = Waves.Default, initialMiners: List[ElMinerSettings] = Nil, - additionalBalances: List[AddrWithBalance] = Nil + additionalBalances: List[AddrWithBalance] = Nil, + daoRewardAccount: Option[KeyPair] = None, + daoRewardAmount: Long = 0 ) { def finalAdditionalBalances: List[AddrWithBalance] = additionalBalances ++ initialMiners.collect { case x if !additionalBalances.exists(_.address == x.address) => AddrWithBalance(x.address, x.wavesBalance) } diff --git a/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala b/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala index 6fa062dc..df79ac99 100644 --- a/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala +++ b/src/test/scala/units/client/contract/HasConsensusLayerDappTxHelpers.scala @@ -23,12 +23,14 @@ trait HasConsensusLayerDappTxHelpers { object chainContract { def setScript(): SetScriptTransaction = TxHelpers.setScript(chainContractAccount, CompiledChainContract.script, fee = setScriptFee) - def setup(genesisBlock: L2BlockLike, elMinerReward: Long): InvokeScriptTransaction = TxHelpers.invoke( + def setup(genesisBlock: L2BlockLike, elMinerReward: Long, daoAddress: Option[Address], daoReward: Long): InvokeScriptTransaction = TxHelpers.invoke( dApp = chainContractAddress, func = "setup".some, args = List( Terms.CONST_STRING(genesisBlock.hash.drop(2)).explicitGet(), - Terms.CONST_LONG(elMinerReward) + Terms.CONST_LONG(elMinerReward), + Terms.CONST_STRING(daoAddress.fold("")(_.toString)).explicitGet(), + Terms.CONST_LONG(daoReward) ), fee = setupFee )