From b7138e7f0e162b2d8c21323e68c2cb2c64debf7f Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Thu, 16 Feb 2023 10:15:49 +0200 Subject: [PATCH 1/2] in update contract check reward tokens are either preserved or voted by ballot boxes; make reward token id and amount optional in ballot box; --- eip-0023/contracts/update_contract.es | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eip-0023/contracts/update_contract.es b/eip-0023/contracts/update_contract.es index cbc49736..846e7ce8 100644 --- a/eip-0023/contracts/update_contract.es +++ b/eip-0023/contracts/update_contract.es @@ -5,8 +5,8 @@ // R4 the pub key of voter [GroupElement] (not used here) // R5 the creation height of this box [Int] // R6 the value voted for [Coll[Byte]] (hash of the new pool box script) - // R7 the reward token id in new box - // R8 the number of reward tokens in new box + // R7 the reward token id in new box (optional, if not present then reward token is preserved) + // R8 the number of reward tokens in new box (optional, if not present then reward token is preserved)) val poolNFT = fromBase64("RytLYlBlU2hWbVlxM3Q2dzl6JEMmRilKQE1jUWZUalc=") // TODO replace with actual @@ -39,12 +39,18 @@ updateBoxOut.creationInfo._1 > SELF.creationInfo._1 && ! (updateBoxOut.R4[Any].isDefined) + val rewardTokenPreserved = poolIn.tokens(1)._1 == rewardTokenId && // check reward token id is preserved + poolIn.tokens(1)._2 == rewardAmt // check reward token amt is preserved + def isValidBallot(b:Box) = if (b.tokens.size > 0) { + val validRewardToken = if (b.R7[Coll[Byte]].isDefined && b.R8[Long].isDefined) { + b.R7[Coll[Byte]].get == rewardTokenId && // check rewardTokenId voted for + b.R8[Long].get == rewardAmt // check rewardTokenAmt voted for + } else rewardTokenPreserved b.tokens(0)._1 == ballotTokenId && b.R5[Int].get == SELF.creationInfo._1 && // ensure vote corresponds to this box by checking creation height b.R6[Coll[Byte]].get == poolOutHash && // check proposition voted for - b.R7[Coll[Byte]].get == rewardTokenId && // check rewardTokenId voted for - b.R8[Long].get == rewardAmt // check rewardTokenAmt voted for + validRewardToken } else false val ballotBoxes = INPUTS.filter(isValidBallot) From f67124bb5c7ddb883d2e337c6cd44eb4306630aa Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Mon, 27 Feb 2023 11:08:45 +0200 Subject: [PATCH 2/2] update update contract hash according to changes in https://github.com/ergoplatform/eips/pull/89 --- eip-0023/eip-0023.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eip-0023/eip-0023.md b/eip-0023/eip-0023.md index 91320032..fd20b666 100644 --- a/eip-0023/eip-0023.md +++ b/eip-0023/eip-0023.md @@ -143,7 +143,7 @@ Before going into the transactions in the protocol, we first present the contrac - [Refresh Contract](contracts/refresh_contract.es) `cs5c5QEirstI4ZlTyrbTjlPwWYHRW+QsedtpyOSBnH4=` - [Oracle Contract](contracts/oracle_contract.es) `fhOYLO3s+NJCqTQDWUz0E+ffy2T1VG7ZnhSFs0RP948=` - [Ballot Contract](contracts/ballot_contract.es) `2DnK+72bh+TxviNk8XfuYzLKtuF5jnqUJOzimt30NvI=` -- [Update Contract](contracts/update_contract.es) `3aIVTP5tRgCZHxaT3ZFw3XubRV5DJi0rKeo9bKVHlVw=` +- [Update Contract](contracts/update_contract.es) `pQ7Dgjq1pUyISroP+RWEDf+kVNYAWjeFHzW+cpImhsQ=` Use this Scastie playground to calculate the above hashes - [https://scastie.scala-lang.org/hnTEm2lJQPG1wRYCqPz8LQ](https://scastie.scala-lang.org/hnTEm2lJQPG1wRYCqPz8LQ) ## Transactions