From 59e015a1e3c0d7b13b9c7a0403afac7d21ea4271 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Tue, 21 Dec 2021 02:02:23 +0300 Subject: [PATCH 01/19] initial version of emission EIP --- eip-0027.md | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 eip-0027.md diff --git a/eip-0027.md b/eip-0027.md new file mode 100644 index 00000000..94eef51b --- /dev/null +++ b/eip-0027.md @@ -0,0 +1,148 @@ +Emission Retargeting Soft-Fork +=============================== + +* Author: kushti +* Status: Proposed +* Created: 17-Dec-2021 +* Last edited: 20-Dec-2020 +* License: CC0 +* Forking: Soft Fork + + +Motivation +---------- + +Long-term security of the Ergo protocol, including crypto-economic security, always has high priority. + One of the hottest topic in this field is (in)stability of cryptocurrency protocols without the block + reward (see e.g. [1] for details). + +It was planned during the launch of the Ergo network that after end of emission miners will be rewarded with +transaction fees and also storage rent. However, it is hard to estimate yet how successfully will storage rent replace +emission. + +Thus it was proposed on the ErgoForum informally (in [2] and [3]) to prolong emission (with preserving total supply) +via a soft-fork([4]). This EIP is concluding previous discussions and provides details on emission soft-fork +design and implementation. + +Updated Emission Schedule +------------------------- + +Starting from block #699,393 (first block of 684th epoch), new emission rules applied on top of rules described in the +Ergo Whitepaper. + +Before end of the current emission (before block 2,080,800): + +* if block reward is not less than 15 ERG, send 12 ERG from it to the reemission contract +* otherwise, block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract + +After end of the current emission (from block 2,080,800): + +* pay 3 ERG each block from re-emission contract + +General Design +-------------- + +Emission in Ergo is done via a contract locking funds existing since before genesis block. Changing emission then in +an elegant way is tricky. + +This EIP is proposing to use existing contract in combination with checks done in the core protocol which are mandatory +only for mining nodes. Non-updated nodes will successfully validate blocks which are valid for the new nodes (both +checking and not checking new rules) after soft-fork activation. + +This EIP offers following procedure for that: + +* inject two new tokens into emission contract. First token is a singleton one issued to mark emission box. Second token +is reemission token, it will go to mining reward blocks and amount of reemission tokens in mining rewards box shows how +many ERG should miner send to re-emission contract when spending the box. Any miner can do injection. + +* new kind of contract, Re-emission Contract is paying 3 ERG each block after end of emission + +* new consensus-level checks are verifying that a proper amount of re-emission token is going from the emission box to +a miner rewards box, and also that during spending a box which is not emission box but contains re-emission tokens, +the tokens are being burnt and the same amount of nanoERG is locked by the reemission contract. +The checks can be switched off via a soft-fork. + + + +Reemission Contract +------------------- + +```scala + // output of the reemission contract + val reemissionOut = ByIndex(Outputs, IntConstant(0)) + + // output to pay miner + val minerOut = ByIndex(Outputs, IntConstant(1)) + + // miner's output must have script which is time-locking reward for miner's pubkey + // box height must be the same as block height + val correctMinerOutput = AND( + EQ(ExtractScriptBytes(minerOut), expectedMinerOutScriptBytesVal(monetarySettings.minerRewardDelay, MinerPubkey)), + EQ(Height, boxCreationHeight(minerOut)) + ) + + // reemission output's height must be the same as block height + val heightCorrect = EQ(boxCreationHeight(reemissionOut), Height) + + // reemission output's height is greater than reemission input + val heightIncreased = GT(Height, boxCreationHeight(Self)) + + // check that height is greater than end of emission (>= 2,080,800 for the mainnet) + val afterEmission = GE(Height, IntConstant(emissionPeriod)) + + // reemission contract must be preserved + val sameScriptRule = EQ(ExtractScriptBytes(Self), ExtractScriptBytes(reemissionOut)) + + // miner's reward + val coinsToIssue = monetarySettings.oneEpochReduction // 3 ERG + val correctCoinsIssued = EQ(coinsToIssue, Minus(ExtractAmount(Self), ExtractAmount(reemissionOut))) + + val sponsored = AND( + GT(ExtractAmount(reemissionOut)), + EQ(SizeOf(Outputs), 1) + ) + + AND( + sameScriptRule, + heightCorrect, + OR( + sponsored, + AND( + correctMinerOutput, + afterEmission, + heightIncreased, + correctCoinsIssued + ) + ) + ) +``` + +Voting for the Soft-Fork +------------------------ + +TODO: + + +Testnet Data +------------ + +Emission contract NFT id: *not set yet* + +Re-emission token id: *not set yet* + + +Mainnet Data +------------ + +Emission contract NFT id: *not set yet* + +Re-emission token id: *not set yet* + + +References +---------- + +1. Carlsten, Miles, et al. "On the instability of bitcoin without the block reward." Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. 2016. +2. Ergo Emission: details, retargeting via a soft-fork. https://www.ergoforum.org/t/ergo-emission-details-retargeting-via-a-soft-fork/2778 +3. Emission Soft-Fork Proposal. https://www.ergoforum.org/t/emission-soft-fork-proposal/2996/27 +4. Zindros, Dionysis. "Soft Power: Upgrading Chain Macroeconomic Policy Through Soft Forks." International Conference on Financial Cryptography and Data Security. 2021. From e0ea8b13e46f34d4cdc0cab347777836ac4f42d6 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Tue, 21 Dec 2021 23:33:17 +0300 Subject: [PATCH 02/19] minor fixes in sponsored path and text --- eip-0027.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 94eef51b..dafa1ea0 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -33,23 +33,23 @@ Ergo Whitepaper. Before end of the current emission (before block 2,080,800): * if block reward is not less than 15 ERG, send 12 ERG from it to the reemission contract -* otherwise, block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract +* otherwise, if block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract After end of the current emission (from block 2,080,800): -* pay 3 ERG each block from re-emission contract +* pay 3 ERG each block from the re-emission contract General Design -------------- -Emission in Ergo is done via a contract locking funds existing since before genesis block. Changing emission then in +Emission in Ergo is done via a contract which is locking funds existing since before genesis block. Changing emission then in an elegant way is tricky. This EIP is proposing to use existing contract in combination with checks done in the core protocol which are mandatory only for mining nodes. Non-updated nodes will successfully validate blocks which are valid for the new nodes (both checking and not checking new rules) after soft-fork activation. -This EIP offers following procedure for that: +This EIP offers the following procedure for that: * inject two new tokens into emission contract. First token is a singleton one issued to mark emission box. Second token is reemission token, it will go to mining reward blocks and amount of reemission tokens in mining rewards box shows how @@ -97,9 +97,11 @@ Reemission Contract val coinsToIssue = monetarySettings.oneEpochReduction // 3 ERG val correctCoinsIssued = EQ(coinsToIssue, Minus(ExtractAmount(Self), ExtractAmount(reemissionOut))) + // when reemission contract box got merged with other boxes val sponsored = AND( - GT(ExtractAmount(reemissionOut)), - EQ(SizeOf(Outputs), 1) + GT(ExtractAmount(reemissionOut), ExtractAmount(Self)), + LE(ExtractAmount(ByIndex(Outputs, IntConstant(1))), LongConstant(10000000)), // 0.01 ERG + EQ(SizeOf(Outputs), 2) ) AND( @@ -139,6 +141,7 @@ Emission contract NFT id: *not set yet* Re-emission token id: *not set yet* + References ---------- From 40b509f48e2e070953aee30e75430830daf702de Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Tue, 21 Dec 2021 23:36:08 +0300 Subject: [PATCH 03/19] reemission nft todo --- eip-0027.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eip-0027.md b/eip-0027.md index dafa1ea0..3c5df240 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -68,6 +68,8 @@ Reemission Contract ------------------- ```scala + // todo: check reemission contract NFT id + // output of the reemission contract val reemissionOut = ByIndex(Outputs, IntConstant(0)) From 03cebd171ef99b06572f5b6dd884be147c9f5467 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Wed, 9 Mar 2022 22:36:03 +0300 Subject: [PATCH 04/19] eip27 update --- eip-0027.md | 135 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 35 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 3c5df240..63a209d1 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -1,5 +1,5 @@ -Emission Retargeting Soft-Fork -=============================== +Emission Retargeting Soft-Fork Proposal +======================================== * Author: kushti * Status: Proposed @@ -12,12 +12,12 @@ Emission Retargeting Soft-Fork Motivation ---------- -Long-term security of the Ergo protocol, including crypto-economic security, always has high priority. - One of the hottest topic in this field is (in)stability of cryptocurrency protocols without the block - reward (see e.g. [1] for details). +Long-term security of the Ergo protocol, including crypto-economic security, is always of highest priority. + One of the hottest topic in this field is (in)stability of cryptocurrency protocols without stable block + rewards coming from emission (see e.g. [1] for details). It was planned during the launch of the Ergo network that after end of emission miners will be rewarded with -transaction fees and also storage rent. However, it is hard to estimate yet how successfully will storage rent replace +transaction fees and also with storage rent. However, it is hard to estimate yet how successfully will storage rent replace emission. Thus it was proposed on the ErgoForum informally (in [2] and [3]) to prolong emission (with preserving total supply) @@ -27,35 +27,47 @@ design and implementation. Updated Emission Schedule ------------------------- -Starting from block #699,393 (first block of 684th epoch), new emission rules applied on top of rules described in the +Starting from block #XXX,XXX (first block of 684th epoch), new emission rules applied on top of rules described in the Ergo Whitepaper. Before end of the current emission (before block 2,080,800): * if block reward is not less than 15 ERG, send 12 ERG from it to the reemission contract -* otherwise, if block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract +* otherwise, block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract After end of the current emission (from block 2,080,800): -* pay 3 ERG each block from the re-emission contract +* pay 3 ERG each block from the re-emission contract, + +where the re-emission contract is working like emission one, but does not have emission curve encoded, only flat payment. + + +Updated Emission Details +------------------------ + + General Design -------------- -Emission in Ergo is done via a contract which is locking funds existing since before genesis block. Changing emission then in +Emission in Ergo is done via a contract, which is existing since before genesis block. Changing emission then in an elegant way is tricky. This EIP is proposing to use existing contract in combination with checks done in the core protocol which are mandatory only for mining nodes. Non-updated nodes will successfully validate blocks which are valid for the new nodes (both -checking and not checking new rules) after soft-fork activation. +checking and not checking new rules) after activation of the new rules. Thus this change is soft-fork. + +This EIP offers following procedure for that: -This EIP offers the following procedure for that: +* inject two new tokens into emission contract. First token is a singleton one issued to mark emission box (could be used +for tracking emission box efficiently) . Second token is reemission token, it will go to mining reward boxes, and +amount of reemission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract +when spending the box. Any miner can do the injection. The injection will happen on activation height. -* inject two new tokens into emission contract. First token is a singleton one issued to mark emission box. Second token -is reemission token, it will go to mining reward blocks and amount of reemission tokens in mining rewards box shows how -many ERG should miner send to re-emission contract when spending the box. Any miner can do injection. +* a new kind of contract, the re-emission Contract is paying 3 ERG each block after end of emission -* new kind of contract, Re-emission Contract is paying 3 ERG each block after end of emission +* a new kind of contract, pay-to-reemission contract. Miners enforced to pay to this proxy contract. The contract is +similar to existing fee contract, but with no time-lock. * new consensus-level checks are verifying that a proper amount of re-emission token is going from the emission box to a miner rewards box, and also that during spending a box which is not emission box but contains re-emission tokens, @@ -64,12 +76,24 @@ The checks can be switched off via a soft-fork. -Reemission Contract +Contracts ------------------- +**Reemission contract**: + ```scala - // todo: check reemission contract NFT id - + // output of the reemission contract + val reemissionOut = ByIndex(Outputs, IntConstant(0)) + + // output to pay miner + val minerOut = ByIndex(Outputs, IntConstant(1)) + + val rOutTokens = OptionGet(ExtractRegisterAs(reemissionOut, R2)(SCollection(STuple(SCollection(SByte), SLong)))) + + val firstTokenId = SelectField(ByIndex(rOutTokens, IntConstant(0)), 0.toByte) + + val correctNftId = EQ(firstTokenId, ByteArrayConstant(reemissionNftId)) + // output of the reemission contract val reemissionOut = ByIndex(Outputs, IntConstant(0)) @@ -101,38 +125,78 @@ Reemission Contract // when reemission contract box got merged with other boxes val sponsored = AND( - GT(ExtractAmount(reemissionOut), ExtractAmount(Self)), - LE(ExtractAmount(ByIndex(Outputs, IntConstant(1))), LongConstant(10000000)), // 0.01 ERG - EQ(SizeOf(Outputs), 2) + GT(ExtractAmount(reemissionOut), ExtractAmount(Self)), + LE(ExtractAmount(ByIndex(Outputs, IntConstant(1))), LongConstant(10000000)), // 0.01 ERG + EQ(SizeOf(Outputs), 2) ) AND( - sameScriptRule, - heightCorrect, - OR( - sponsored, - AND( - correctMinerOutput, - afterEmission, - heightIncreased, - correctCoinsIssued + correctNftId, + sameScriptRule, + heightCorrect, + OR( + sponsored, + AND( + correctMinerOutput, + afterEmission, + heightIncreased, + correctCoinsIssued + ) ) - ) ) ``` +**Pay-to-Reemission contract**: + +```scala + val reemissionOut = ByIndex(Outputs, IntConstant(0)) + + val rOutTokens = OptionGet(ExtractRegisterAs(reemissionOut, R2)(SCollection(STuple(SCollection(SByte), SLong)))) + + val firstTokenId = SelectField(ByIndex(rOutTokens, IntConstant(0)), 0.toByte) + + EQ(firstTokenId, ByteArrayConstant(reemissionNftId)) +``` + Voting for the Soft-Fork ------------------------ TODO: +Activation Details +------------------ + +On emission height, emission NFT and reemission tokens to be injected into the emission contract by spending +a box we are calling injection box. + +The injection box is protected by the script + +``` +{ + INPUTS(0).value > 30000000L * 1000000000L && + SELF.id == INPUTS(1).id +} +``` + +so spendable by anyone who can spend 30M ERG at least provided in the first input. + +API Methods Changed +------------------- + +* /emission/at +* /wallet/balances +* /wallet/balances/withUnconfirmed Testnet Data ------------ -Emission contract NFT id: *not set yet* +Emission contract NFT id: **00594148f3b4205ec8d33f9f664b1baae20252df3592c8dbff5e9bdc30c77c44** -Re-emission token id: *not set yet* +Re-emission token id: **004b1528123ef62ce2bbb7036ad2dd553e6a64252f86746a706729fa253b24cd** + +Reemission contract NFT id: **001b81ceed43f4328754e368fc6a34c367ab8e00d1272be33c565bf247ad5748** + +Activation height: **** Mainnet Data @@ -142,6 +206,7 @@ Emission contract NFT id: *not set yet* Re-emission token id: *not set yet* +Reemission contract NFT id: *not set yet* References @@ -150,4 +215,4 @@ References 1. Carlsten, Miles, et al. "On the instability of bitcoin without the block reward." Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. 2016. 2. Ergo Emission: details, retargeting via a soft-fork. https://www.ergoforum.org/t/ergo-emission-details-retargeting-via-a-soft-fork/2778 3. Emission Soft-Fork Proposal. https://www.ergoforum.org/t/emission-soft-fork-proposal/2996/27 -4. Zindros, Dionysis. "Soft Power: Upgrading Chain Macroeconomic Policy Through Soft Forks." International Conference on Financial Cryptography and Data Security. 2021. +4. Zindros, Dionysis. "Soft Power: Upgrading Chain Macroeconomic Policy Through Soft Forks." International Conference on Financial Cryptography and Data Security. 2021. \ No newline at end of file From b6ce6f31a05b2ea925569b6ae653259c580c30b5 Mon Sep 17 00:00:00 2001 From: Alex Chepurnoy Date: Wed, 9 Mar 2022 22:38:15 +0300 Subject: [PATCH 05/19] epoch unset --- eip-0027.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eip-0027.md b/eip-0027.md index 63a209d1..cd510417 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -27,7 +27,7 @@ design and implementation. Updated Emission Schedule ------------------------- -Starting from block #XXX,XXX (first block of 684th epoch), new emission rules applied on top of rules described in the +Starting from block #XXX,XXX (first block of XXXth epoch), new emission rules applied on top of rules described in the Ergo Whitepaper. Before end of the current emission (before block 2,080,800): From 2079c33dfa0e9398a00cc97a2cc59d71e8476e5b Mon Sep 17 00:00:00 2001 From: kushti Date: Fri, 22 Apr 2022 15:06:38 +0300 Subject: [PATCH 06/19] text update with activation vote details etc --- eip-0027.md | 84 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index cd510417..9d74d443 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -4,7 +4,7 @@ Emission Retargeting Soft-Fork Proposal * Author: kushti * Status: Proposed * Created: 17-Dec-2021 -* Last edited: 20-Dec-2020 +* Last edited: 18-Apr-2022 * License: CC0 * Forking: Soft Fork @@ -12,13 +12,13 @@ Emission Retargeting Soft-Fork Proposal Motivation ---------- -Long-term security of the Ergo protocol, including crypto-economic security, is always of highest priority. - One of the hottest topic in this field is (in)stability of cryptocurrency protocols without stable block - rewards coming from emission (see e.g. [1] for details). +Long-term security of the Ergo protocol, including its crypto-economic security, is always of highest priority for the community +and core developers. One of the hottest research topic in this field is possible (in)stability of cryptocurrency protocols without stable +block rewards coming from emission (see e.g. [1] for details). -It was planned during the launch of the Ergo network that after end of emission miners will be rewarded with -transaction fees and also with storage rent. However, it is hard to estimate yet how successfully will storage rent replace -emission. +It was planned during the launch of the Ergo network that after the end of emission miners will be rewarded with +transaction fees and also with storage rent (unique for Ergo source of mining income). However, it is hard to estimate yet how successfully +will storage rent replace emission. Thus it was proposed on the ErgoForum informally (in [2] and [3]) to prolong emission (with preserving total supply) via a soft-fork([4]). This EIP is concluding previous discussions and provides details on emission soft-fork @@ -27,61 +27,64 @@ design and implementation. Updated Emission Schedule ------------------------- -Starting from block #XXX,XXX (first block of XXXth epoch), new emission rules applied on top of rules described in the +Starting from block #777,216 (first block of 759th voting epoch), new emission rules applied on top of rules described in the Ergo Whitepaper. -Before end of the current emission (before block 2,080,800): +Before the end of the current emission (block #2,080,800): * if block reward is not less than 15 ERG, send 12 ERG from it to the reemission contract * otherwise, block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract -After end of the current emission (from block 2,080,800): +After end of the current emission (starting from block 2,080,800): * pay 3 ERG each block from the re-emission contract, -where the re-emission contract is working like emission one, but does not have emission curve encoded, only flat payment. +where the re-emission contract is working like emission one, but does not have emission curve encoded, only flat payout. Updated Emission Details ------------------------ - +With the updated emission schedule from above, re-emission (with 3 ERG re-emission reward per block) would be enough for +4,566,336 blocks (approx. 17.38 years). General Design -------------- -Emission in Ergo is done via a contract, which is existing since before genesis block. Changing emission then in -an elegant way is tricky. +Emission in Ergo is done via a contract, which is existing since before genesis block (pre-genesis state). Changing +emission then in an elegant way is tricky. This EIP is proposing to use existing contract in combination with checks done in the core protocol which are mandatory -only for mining nodes. Non-updated nodes will successfully validate blocks which are valid for the new nodes (both -checking and not checking new rules) after activation of the new rules. Thus this change is soft-fork. +only for mining nodes. Non-updated nodes will successfully validate all transactions which are valid for the new nodes (both +checking and not checking new rules), after activation of the new rules. Thus this change is soft-fork. This EIP offers following procedure for that: * inject two new tokens into emission contract. First token is a singleton one issued to mark emission box (could be used -for tracking emission box efficiently) . Second token is reemission token, it will go to mining reward boxes, and +for tracking emission box efficiently also). Second token is reemission token, it will go to mining reward boxes, and amount of reemission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract -when spending the box. Any miner can do the injection. The injection will happen on activation height. +when spending the box. Any miner can do the injection. The injection happens on activation height. -* a new kind of contract, the re-emission Contract is paying 3 ERG each block after end of emission +* a new kind of contract, the re-emission contract is paying 3 ERG each block after end of emission -* a new kind of contract, pay-to-reemission contract. Miners enforced to pay to this proxy contract. The contract is -similar to existing fee contract, but with no time-lock. +* a new kind of contract, pay-to-reemission contract, which is a proxy contract before the re-emission contract. +Miners enforced to pay to this proxy contract. The contract is similar to existing fee contract, but with no time-lock. * new consensus-level checks are verifying that a proper amount of re-emission token is going from the emission box to -a miner rewards box, and also that during spending a box which is not emission box but contains re-emission tokens, -the tokens are being burnt and the same amount of nanoERG is locked by the reemission contract. -The checks can be switched off via a soft-fork. - - +a miner rewards box, and also that during spending a box which is not emission box but contains re-emission tokens +(miner rewards box), the tokens are being burnt and the same amount of nanoERG is locked by the reemission contract. +The checks can be switched off via a soft-fork (via voting on disabling rule #123). Contracts ------------------- -**Reemission contract**: +**Re-emission contract**: this contract pays 3 ERG per block starting from block #2,080,800 . Also this contracts allows +for merging with other boxes, merging transaction must have only two otuputs, first output is for re-emission contract, +second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) ```scala + val reemissionRewardPerBlock = monetarySettings.oneEpochReduction // 3 ERG + // output of the reemission contract val reemissionOut = ByIndex(Outputs, IntConstant(0)) @@ -120,8 +123,7 @@ Contracts val sameScriptRule = EQ(ExtractScriptBytes(Self), ExtractScriptBytes(reemissionOut)) // miner's reward - val coinsToIssue = monetarySettings.oneEpochReduction // 3 ERG - val correctCoinsIssued = EQ(coinsToIssue, Minus(ExtractAmount(Self), ExtractAmount(reemissionOut))) + val correctCoinsIssued = EQ(reemissionRewardPerBlock, Minus(ExtractAmount(Self), ExtractAmount(reemissionOut))) // when reemission contract box got merged with other boxes val sponsored = AND( @@ -146,7 +148,7 @@ Contracts ) ``` -**Pay-to-Reemission contract**: +**Pay-to-Reemission contract**: ensures that a box protected with the contract can be spent to re-emission contract only. ```scala val reemissionOut = ByIndex(Outputs, IntConstant(0)) @@ -161,7 +163,18 @@ Contracts Voting for the Soft-Fork ------------------------ -TODO: +To vote for the soft-fork on the mainnet (similar testnet voting already done), a solo miner or a pool needs to add +following setting to the config +``` +ergo { + voting { + 8 = 1000 + } +} +``` + +When a voting epoch with *90+%* support (blocks with a vote for increasing parameter #8, which holds transaction +output cost) will take place before activation height, EIP-27 locks in and will be activated on activation height. Activation Details ------------------ @@ -178,12 +191,14 @@ The injection box is protected by the script } ``` -so spendable by anyone who can spend 30M ERG at least provided in the first input. +so spendable by anyone who can spend 30M ERG at least provided in the first input (presumable, only emission box can +have so many ERGs). API Methods Changed ------------------- * /emission/at +* /emission/scripts * /wallet/balances * /wallet/balances/withUnconfirmed @@ -196,7 +211,9 @@ Re-emission token id: **004b1528123ef62ce2bbb7036ad2dd553e6a64252f86746a706729fa Reemission contract NFT id: **001b81ceed43f4328754e368fc6a34c367ab8e00d1272be33c565bf247ad5748** -Activation height: **** +Activation height: **188001** + +Re-emission start height: **186400** Mainnet Data @@ -208,6 +225,7 @@ Re-emission token id: *not set yet* Reemission contract NFT id: *not set yet* +Activation height: *not set yet* References ---------- From dcc77f7da3fb0f8c1542a0dea51cdff975413db4 Mon Sep 17 00:00:00 2001 From: kushti Date: Fri, 22 Apr 2022 15:22:22 +0300 Subject: [PATCH 07/19] wallet support section --- eip-0027.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eip-0027.md b/eip-0027.md index 9d74d443..c88dd7f7 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -202,6 +202,22 @@ API Methods Changed * /wallet/balances * /wallet/balances/withUnconfirmed +Wallet Support +-------------- + +To have wallet accounting re-emission tokens, e.g. doing payments correctly in the presence of re-emission tokens, +the following flag must be set: + +``` +ergo { + wallet { + checkEIP27 = true + } +} +``` + +This flag if off by default for the sake of performance. + Testnet Data ------------ From 745d7829fbc008aa1d303f4c33e059a7e92c9d04 Mon Sep 17 00:00:00 2001 From: kushti Date: Mon, 2 May 2022 23:26:53 +0300 Subject: [PATCH 08/19] eip27 finalized --- eip-0027.md | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index c88dd7f7..453b9ff1 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -1,4 +1,4 @@ -Emission Retargeting Soft-Fork Proposal +Emission Retargeting Soft-Fork Proposal ======================================== * Author: kushti @@ -27,7 +27,7 @@ design and implementation. Updated Emission Schedule ------------------------- -Starting from block #777,216 (first block of 759th voting epoch), new emission rules applied on top of rules described in the +Starting from block #777,217 (first block of 759th voting epoch), new emission rules applied on top of rules described in the Ergo Whitepaper. Before the end of the current emission (block #2,080,800): @@ -135,10 +135,10 @@ second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) AND( correctNftId, sameScriptRule, - heightCorrect, OR( sponsored, AND( + heightCorrect, correctMinerOutput, afterEmission, heightIncreased, @@ -173,8 +173,8 @@ ergo { } ``` -When a voting epoch with *90+%* support (blocks with a vote for increasing parameter #8, which holds transaction -output cost) will take place before activation height, EIP-27 locks in and will be activated on activation height. +When a voting epoch with at least 888 out of 1024 blocks support (blocks with a vote for increasing parameter #8, which holds transaction +output cost) will take place before activation height, EIP-27 locks in and will be activated at activation height. Activation Details ------------------ @@ -235,13 +235,39 @@ Re-emission start height: **186400** Mainnet Data ------------ -Emission contract NFT id: *not set yet* +Emission contract NFT id: *20fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a51* -Re-emission token id: *not set yet* +(issued in tx # a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c , + https://explorer.ergoplatform.com/en/transactions/a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c , + block 738,624) + +Re-emission token id: *d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a* -Reemission contract NFT id: *not set yet* +(issued in tx # ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3, + https://explorer.ergoplatform.com/en/transactions/ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3 , + block 738,694) -Activation height: *not set yet* +Reemission contract NFT id: *d3feeffa87f2df63a7a15b4905e618ae3ce4c69a7975f171bd314d0b877927b8* + +(issued in tx # f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c , + https://explorer.ergoplatform.com/en/transactions/f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c , + block 738,628) + +Activation height: *777,217* + +( + Injection box P2S address is *9puEV3pP1bNdFi17ScAWzHqGaZPAopM15fFz2FiotY1zdd1XBT9Kba* , + created in tx # fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7 , + https://explorer.ergoplatform.com/en/transactions/fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7 , + output # 997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a , + + use utxo/byIdBinary/997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a request in node API to get + injection box bytes : + ```{ + "boxId": "997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a", + "bytes": "80a8d6b9071003040005808098f4e9b5ca6a0402d1ed91c1b2a4730000730193c5a7c5b2a47302008f9e2d0220fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a5101d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a808088fccdbcc32300fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f700" + }``` +) References ---------- From 185dc92438087cebc9e0d009bd7ae5dd67eb912f Mon Sep 17 00:00:00 2001 From: M Glasgow Date: Wed, 4 May 2022 11:38:19 +0100 Subject: [PATCH 09/19] proposed text fixes --- eip-0027.md | 162 +++++++++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 92 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 453b9ff1..741af031 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -12,75 +12,62 @@ Emission Retargeting Soft-Fork Proposal Motivation ---------- -Long-term security of the Ergo protocol, including its crypto-economic security, is always of highest priority for the community -and core developers. One of the hottest research topic in this field is possible (in)stability of cryptocurrency protocols without stable -block rewards coming from emission (see e.g. [1] for details). +The long-term security of the Ergo protocol, including its crypto-economic security, is always of the highest priority for the community and core developers. One of the hottest research topics in this field is the possible (in)stability of cryptocurrency protocols without stable block rewards coming from emissions.[[1]](#references) -It was planned during the launch of the Ergo network that after the end of emission miners will be rewarded with -transaction fees and also with storage rent (unique for Ergo source of mining income). However, it is hard to estimate yet how successfully -will storage rent replace emission. +During the launch of the Ergo network, it was planned that after the end of emission, miners would be rewarded with transaction fees and storage rent (unique for Ergo source of mining income). However, it is difficult to estimate how sufficient or consistently storage rent will replace emissions. -Thus it was proposed on the ErgoForum informally (in [2] and [3]) to prolong emission (with preserving total supply) -via a soft-fork([4]). This EIP is concluding previous discussions and provides details on emission soft-fork -design and implementation. +Thus, it was proposed on the ErgoForum informally (in [[2]](#references) and [[3]](#references)) to prolong emission (while preserving the total supply) via a soft-fork([4](#references)). This EIP concludes previous discussions and provides further details on the proposed emission soft-fork design and implementation. Updated Emission Schedule ------------------------- -Starting from block #777,217 (first block of 759th voting epoch), new emission rules applied on top of rules described in the -Ergo Whitepaper. +Starting from block **#777,217** (the first block of the 759th voting epoch), the new emission rules described in this EIP will be applied on top of the rules described in the Ergo Whitepaper. Before the end of the current emission (block #2,080,800): -* if block reward is not less than 15 ERG, send 12 ERG from it to the reemission contract -* otherwise, block reward R is less than 15 ERG, send R - 3 ERG from it to the reemission contract +* If the block reward **R > 15 ERG**, send **12 ERG** to the re-emission contract. +* otherwise, if **R < 15 ERG**, send **R - 3 ERG** to the re-emission contract -After end of the current emission (starting from block 2,080,800): +After the end of the current emission (starting from block #2,080,800), the re-emission contract works like the existing emission contract but does not have the emission curve encoded, only a flat payout. -* pay 3 ERG each block from the re-emission contract, - -where the re-emission contract is working like emission one, but does not have emission curve encoded, only flat payout. +* Pay **3 ERG each block** from the re-emission contract. Updated Emission Details ------------------------ -With the updated emission schedule from above, re-emission (with 3 ERG re-emission reward per block) would be enough for -4,566,336 blocks (approx. 17.38 years). +With the updated emission schedule described above, re-emission (with 3 ERG re-emission rewards per block) would be enough for 4,566,336 blocks (approx. 17.38 years). General Design -------------- -Emission in Ergo is done via a contract, which is existing since before genesis block (pre-genesis state). Changing -emission then in an elegant way is tricky. +Ergo's emissions are controlled via a smart contract which has existed since before the genesis block (pre-genesis state). + +This EIP proposes using the existing contract in combination with checks performed in the core protocol, which are only mandatory for mining nodes. Non-updated nodes will continue to successfully validate all transactions valid for the new nodes (both checking and not checking the new rules) after activation, making this change a **soft-fork**. + +This EIP offers the following procedure for achieving this: -This EIP is proposing to use existing contract in combination with checks done in the core protocol which are mandatory -only for mining nodes. Non-updated nodes will successfully validate all transactions which are valid for the new nodes (both -checking and not checking new rules), after activation of the new rules. Thus this change is soft-fork. +* Inject two new tokens into the emission contract. + * The first token is a *singleton* issued to mark the emission box (It could also be used to track the emission box efficiently). + * The second token is the re-emission token, which will go into mining reward boxes. + +* The amount of re-emission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract when spending the box. Any miner can do the injection, which happens on activation height. -This EIP offers following procedure for that: +We introduce two new contracts which are described in greater detail below. +* The **re-emission contract** pays 3 ERG for each block after the end of emission. -* inject two new tokens into emission contract. First token is a singleton one issued to mark emission box (could be used -for tracking emission box efficiently also). Second token is reemission token, it will go to mining reward boxes, and -amount of reemission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract -when spending the box. Any miner can do the injection. The injection happens on activation height. +* The **pay-to-reemission** contract, is a proxy contract active before the re-emission contract. -* a new kind of contract, the re-emission contract is paying 3 ERG each block after end of emission +Miners are enforced to pay to this proxy contract. The contract is similar to the existing fee contract but with no time lock. -* a new kind of contract, pay-to-reemission contract, which is a proxy contract before the re-emission contract. -Miners enforced to pay to this proxy contract. The contract is similar to existing fee contract, but with no time-lock. +* We create new consensus-level checks that verify that the proper amount of re-emission tokens are going from the emission box to a miner rewards box, and also that during spending a box which is not an emission box but contains re-emission tokens (miner rewards box), the tokens are being burnt, and the same amount of nanoERG is locked by the re-emission contract. -* new consensus-level checks are verifying that a proper amount of re-emission token is going from the emission box to -a miner rewards box, and also that during spending a box which is not emission box but contains re-emission tokens -(miner rewards box), the tokens are being burnt and the same amount of nanoERG is locked by the reemission contract. The checks can be switched off via a soft-fork (via voting on disabling rule #123). Contracts ------------------- -**Re-emission contract**: this contract pays 3 ERG per block starting from block #2,080,800 . Also this contracts allows -for merging with other boxes, merging transaction must have only two otuputs, first output is for re-emission contract, -second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) +**Re-emission contract**: This contract pays 3 ERG per block starting from block #2,080,800 . Also, this contract allows for merging with other boxes; the merging transaction must have only two outputs; the first output is for the re-emission contract, the second one is to pay a mining fee (its value can be 0.01 ERG at most) ```scala val reemissionRewardPerBlock = monetarySettings.oneEpochReduction // 3 ERG @@ -103,7 +90,7 @@ second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) // output to pay miner val minerOut = ByIndex(Outputs, IntConstant(1)) - // miner's output must have script which is time-locking reward for miner's pubkey + // miner's output must have a script which is the time-locking reward for the miner's pubkey // box height must be the same as block height val correctMinerOutput = AND( EQ(ExtractScriptBytes(minerOut), expectedMinerOutScriptBytesVal(monetarySettings.minerRewardDelay, MinerPubkey)), @@ -148,7 +135,7 @@ second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) ) ``` -**Pay-to-Reemission contract**: ensures that a box protected with the contract can be spent to re-emission contract only. +**Pay-to-Reemission contract**: Ensures that a box protected with the contract can only be spent by the re-emission contract. ```scala val reemissionOut = ByIndex(Outputs, IntConstant(0)) @@ -163,9 +150,9 @@ second one is to pay mining fee supposedly (its value can be 0.01 ERG at most) Voting for the Soft-Fork ------------------------ -To vote for the soft-fork on the mainnet (similar testnet voting already done), a solo miner or a pool needs to add -following setting to the config -``` +To vote for the soft-fork on the mainnet (similar testnet voting already done), a solo miner or a pool needs to add the following to their configuration file. + +```conf ergo { voting { 8 = 1000 @@ -173,16 +160,14 @@ ergo { } ``` -When a voting epoch with at least 888 out of 1024 blocks support (blocks with a vote for increasing parameter #8, which holds transaction -output cost) will take place before activation height, EIP-27 locks in and will be activated at activation height. +When a voting epoch with at least 888/1024 blocks indicates they support the proposal (by their vote for increasing parameter #8, which holds transaction output cost) is achieved, EIP-27 locks in and will be activated at the given activation height. Activation Details ------------------ -On emission height, emission NFT and reemission tokens to be injected into the emission contract by spending -a box we are calling injection box. +On emission height, emission NFT and re-emission tokens are injected into the emission contract by spending a box we call the **injection box**. -The injection box is protected by the script +The script protects the injection box. ``` { @@ -191,24 +176,22 @@ The injection box is protected by the script } ``` -so spendable by anyone who can spend 30M ERG at least provided in the first input (presumable, only emission box can -have so many ERGs). +This is spendable by providing 30M ERG in the first input (Only the emission box has so many ERGs). API Methods Changed ------------------- -* /emission/at -* /emission/scripts -* /wallet/balances -* /wallet/balances/withUnconfirmed +* `/emission/at` +* `/emission/scripts` +* `/wallet/balances` +* `/wallet/balances/withUnconfirmed` Wallet Support -------------- -To have wallet accounting re-emission tokens, e.g. doing payments correctly in the presence of re-emission tokens, -the following flag must be set: +To have a wallet accounting for re-emission tokens, e.g. making payments correctly in the presence of re-emission tokens, the following flag must be set: -``` +```conf ergo { wallet { checkEIP27 = true @@ -216,63 +199,58 @@ ergo { } ``` -This flag if off by default for the sake of performance. +This flag is `false` by default for the sake of performance. Testnet Data ------------ -Emission contract NFT id: **00594148f3b4205ec8d33f9f664b1baae20252df3592c8dbff5e9bdc30c77c44** +Emission contract NFT id: `00594148f3b4205ec8d33f9f664b1baae20252df3592c8dbff5e9bdc30c77c44` -Re-emission token id: **004b1528123ef62ce2bbb7036ad2dd553e6a64252f86746a706729fa253b24cd** +Re-emission token id: `004b1528123ef62ce2bbb7036ad2dd553e6a64252f86746a706729fa253b24cd` -Reemission contract NFT id: **001b81ceed43f4328754e368fc6a34c367ab8e00d1272be33c565bf247ad5748** +Reemission contract NFT id: `001b81ceed43f4328754e368fc6a34c367ab8e00d1272be33c565bf247ad5748` -Activation height: **188001** +Activation height: `188001` -Re-emission start height: **186400** +Re-emission start height: `186400` Mainnet Data ------------ -Emission contract NFT id: *20fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a51* +- Emission contract NFT id: `20fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a51` + - Issued in tx #[a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c](https://explorer.ergoplatform.com/en/transactions/a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c) + - Block 738,624 + +- Re-emission token id: `d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a` + - Issued in tx # [ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3](https://explorer.ergoplatform.com/en/transactions/ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3) + - block 738,694 -(issued in tx # a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c , - https://explorer.ergoplatform.com/en/transactions/a1cbc9e14999cc7620c9d952cb06f5f6a70a2c39bb7d3c8ff5311f825eca244c , - block 738,624) +- Reemission contract NFT id: `d3feeffa87f2df63a7a15b4905e618ae3ce4c69a7975f171bd314d0b877927b8` + - Issued in tx #[f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c](https://explorer.ergoplatform.com/en/transactions/f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c) + - block 738,628) -Re-emission token id: *d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a* +Activation height: `777,217` -(issued in tx # ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3, - https://explorer.ergoplatform.com/en/transactions/ff340e380559a5a1ba870f27367a50a1829a4a573e1a738ec764456ec47620e3 , - block 738,694) -Reemission contract NFT id: *d3feeffa87f2df63a7a15b4905e618ae3ce4c69a7975f171bd314d0b877927b8* - -(issued in tx # f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c , - https://explorer.ergoplatform.com/en/transactions/f06762711a3f33d3a479962e730a742f640105c6c5bb4e0a3e5a9405de700b4c , - block 738,628) +- Injection box P2S address is `9puEV3pP1bNdFi17ScAWzHqGaZPAopM15fFz2FiotY1zdd1XBT9Kba` + - created in tx # [fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7](https://explorer.ergoplatform.com/en/transactions/fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7) + - output `997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a` -Activation height: *777,217* - -( - Injection box P2S address is *9puEV3pP1bNdFi17ScAWzHqGaZPAopM15fFz2FiotY1zdd1XBT9Kba* , - created in tx # fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7 , - https://explorer.ergoplatform.com/en/transactions/fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f7 , - output # 997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a , + use `utxo/byIdBinary/997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a` request in node API to get injection box bytes: - use utxo/byIdBinary/997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a request in node API to get - injection box bytes : - ```{ + ```conf + { "boxId": "997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a", "bytes": "80a8d6b9071003040005808098f4e9b5ca6a0402d1ed91c1b2a4730000730193c5a7c5b2a47302008f9e2d0220fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a5101d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a808088fccdbcc32300fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f700" - }``` -) + } +``` + References ---------- -1. Carlsten, Miles, et al. "On the instability of bitcoin without the block reward." Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. 2016. -2. Ergo Emission: details, retargeting via a soft-fork. https://www.ergoforum.org/t/ergo-emission-details-retargeting-via-a-soft-fork/2778 -3. Emission Soft-Fork Proposal. https://www.ergoforum.org/t/emission-soft-fork-proposal/2996/27 -4. Zindros, Dionysis. "Soft Power: Upgrading Chain Macroeconomic Policy Through Soft Forks." International Conference on Financial Cryptography and Data Security. 2021. \ No newline at end of file +1. [Carlsten, Miles, et al. **"On the instability of bitcoin without the block reward."** Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. 2016.](https://www.cs.princeton.edu/~arvindn/publications/mining_CCS.pdf) +2. [Ergo Emission: **details, retargeting via a soft-fork.**](https://www.ergoforum.org/t/ergo-emission-details-retargeting-via-a-soft-fork/2778) +3. [Emission Soft-Fork Proposal.](https://www.ergoforum.org/t/emission-soft-fork-proposal/2996/27) +4. [Zindros, Dionysis. **"Soft Power: Upgrading Chain Macroeconomic Policy Through Soft Forks."** International Conference on Financial Cryptography and Data Security. 2021.](https://eprint.iacr.org/2021/577.pdf) \ No newline at end of file From ec8d833b05cc28955c508c15fa8a831ef9234952 Mon Sep 17 00:00:00 2001 From: M Glasgow Date: Wed, 4 May 2022 12:00:11 +0100 Subject: [PATCH 10/19] fix --- eip-0027.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eip-0027.md b/eip-0027.md index 741af031..0a0d73d3 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -25,7 +25,7 @@ Starting from block **#777,217** (the first block of the 759th voting epoch), th Before the end of the current emission (block #2,080,800): -* If the block reward **R > 15 ERG**, send **12 ERG** to the re-emission contract. +* If the block reward **R >= 15 ERG**, send **12 ERG** to the re-emission contract. * otherwise, if **R < 15 ERG**, send **R - 3 ERG** to the re-emission contract After the end of the current emission (starting from block #2,080,800), the re-emission contract works like the existing emission contract but does not have the emission curve encoded, only a flat payout. From cd01cf39148101998e9e61b8f93fd62bef8308e0 Mon Sep 17 00:00:00 2001 From: kushti Date: Mon, 30 May 2022 18:29:49 +0300 Subject: [PATCH 11/19] duplicates removed and renaming in ReemissionContract --- eip-0027.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 0a0d73d3..030d7786 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -72,12 +72,6 @@ Contracts ```scala val reemissionRewardPerBlock = monetarySettings.oneEpochReduction // 3 ERG - // output of the reemission contract - val reemissionOut = ByIndex(Outputs, IntConstant(0)) - - // output to pay miner - val minerOut = ByIndex(Outputs, IntConstant(1)) - val rOutTokens = OptionGet(ExtractRegisterAs(reemissionOut, R2)(SCollection(STuple(SCollection(SByte), SLong)))) val firstTokenId = SelectField(ByIndex(rOutTokens, IntConstant(0)), 0.toByte) @@ -113,7 +107,7 @@ Contracts val correctCoinsIssued = EQ(reemissionRewardPerBlock, Minus(ExtractAmount(Self), ExtractAmount(reemissionOut))) // when reemission contract box got merged with other boxes - val sponsored = AND( + val merging = AND( GT(ExtractAmount(reemissionOut), ExtractAmount(Self)), LE(ExtractAmount(ByIndex(Outputs, IntConstant(1))), LongConstant(10000000)), // 0.01 ERG EQ(SizeOf(Outputs), 2) @@ -123,7 +117,7 @@ Contracts correctNftId, sameScriptRule, OR( - sponsored, + merging, AND( heightCorrect, correctMinerOutput, From 39a0ebc571ac82de546bfe6e41228134eb399d1c Mon Sep 17 00:00:00 2001 From: kushti Date: Mon, 30 May 2022 19:08:41 +0300 Subject: [PATCH 12/19] a note on paying to re-emission contract --- eip-0027.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eip-0027.md b/eip-0027.md index 030d7786..7ae3d8a6 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -60,7 +60,11 @@ We introduce two new contracts which are described in greater detail below. Miners are enforced to pay to this proxy contract. The contract is similar to the existing fee contract but with no time lock. -* We create new consensus-level checks that verify that the proper amount of re-emission tokens are going from the emission box to a miner rewards box, and also that during spending a box which is not an emission box but contains re-emission tokens (miner rewards box), the tokens are being burnt, and the same amount of nanoERG is locked by the re-emission contract. +* We create new consensus-level checks that verify that the proper amount of re-emission tokens are going from +the emission box to a miner rewards box, and also that during spending a box which +is not an emission box but contains re-emission tokens (miner rewards box), the tokens are being burnt, +and the same amount of nanoERG is locked by the re-emission contract (via a proxy pay-to-reemission contract, + ERGs locked by such a contract could be paid to reemission contract box (its NFT) only). The checks can be switched off via a soft-fork (via voting on disabling rule #123). From b576925076128d957618657fa15898e00ebcc20d Mon Sep 17 00:00:00 2001 From: kushti Date: Mon, 30 May 2022 20:28:15 +0300 Subject: [PATCH 13/19] contracts intro --- eip-0027.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eip-0027.md b/eip-0027.md index 7ae3d8a6..58117586 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -71,6 +71,15 @@ The checks can be switched off via a soft-fork (via voting on disabling rule #12 Contracts ------------------- +Contracts along with new consensus-level checks define re-emission tokens flow, and re-emission <-> ERG token swap +rules. They are as follows: + +* at the activation height re-emission tokens being injected into emission box (consensus-level check) +* starting from activation height, a miner must inject certain amount of re-emission tokens into its reward box (consensus-level check) +* when a box with re-emission tokens (so a reward box) being spent, re-emission tokens must be burnt, and corresponding amount of ERG must be sent to pay-to-reemission contract (consensus-level check) +* peridically, pay-to-re-emission boxes being merging with re-emission contract box (contract-level check) +* from re-emission contract box, ERGs could be withdrawn starting from re-emission start height, 3 ERG per block (contract-level check) + **Re-emission contract**: This contract pays 3 ERG per block starting from block #2,080,800 . Also, this contract allows for merging with other boxes; the merging transaction must have only two outputs; the first output is for the re-emission contract, the second one is to pay a mining fee (its value can be 0.01 ERG at most) ```scala From a15f3bf33b54de5bdf32abcac0141ff1a540f170 Mon Sep 17 00:00:00 2001 From: M Glasgow Date: Tue, 31 May 2022 19:53:30 +0100 Subject: [PATCH 14/19] text fixes --- eip-0027.md | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 58117586..75929234 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -12,9 +12,9 @@ Emission Retargeting Soft-Fork Proposal Motivation ---------- -The long-term security of the Ergo protocol, including its crypto-economic security, is always of the highest priority for the community and core developers. One of the hottest research topics in this field is the possible (in)stability of cryptocurrency protocols without stable block rewards coming from emissions.[[1]](#references) +The long-term security of the Ergo protocol, including its crypto-economic security, is always of the highest priority for the community and core developers. One of the hottest research topics in this field is the possible (in)stability of cryptocurrency protocols after their stable block rewards from emissions comes to an end.[[1]](#references) -During the launch of the Ergo network, it was planned that after the end of emission, miners would be rewarded with transaction fees and storage rent (unique for Ergo source of mining income). However, it is difficult to estimate how sufficient or consistently storage rent will replace emissions. +During the launch of the Ergo network, it was planned that after the end of emission, miners would be rewarded with transaction fees and storage rent (a unique source of mining income). However, it is difficult to estimate how sufficient or consistently storage rent will replace emissions. Thus, it was proposed on the ErgoForum informally (in [[2]](#references) and [[3]](#references)) to prolong emission (while preserving the total supply) via a soft-fork([4](#references)). This EIP concludes previous discussions and provides further details on the proposed emission soft-fork design and implementation. @@ -28,7 +28,7 @@ Before the end of the current emission (block #2,080,800): * If the block reward **R >= 15 ERG**, send **12 ERG** to the re-emission contract. * otherwise, if **R < 15 ERG**, send **R - 3 ERG** to the re-emission contract -After the end of the current emission (starting from block #2,080,800), the re-emission contract works like the existing emission contract but does not have the emission curve encoded, only a flat payout. +After the end of the current emission (starting from block #2,080,800), the re-emission contract works like the existing emission contract. However, it does not have the emission curve encoded, only a flat payout. * Pay **3 ERG each block** from the re-emission contract. @@ -36,7 +36,7 @@ After the end of the current emission (starting from block #2,080,800), the re-e Updated Emission Details ------------------------ -With the updated emission schedule described above, re-emission (with 3 ERG re-emission rewards per block) would be enough for 4,566,336 blocks (approx. 17.38 years). +With the updated emission schedule described above, re-emission (with 3 ERG re-emission rewards per block) would be enough for 4,566,336 blocks (~17.38 years). General Design -------------- @@ -53,34 +53,34 @@ This EIP offers the following procedure for achieving this: * The amount of re-emission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract when spending the box. Any miner can do the injection, which happens on activation height. -We introduce two new contracts which are described in greater detail below. +We introduce two new contracts, which are described in greater detail below. * The **re-emission contract** pays 3 ERG for each block after the end of emission. -* The **pay-to-reemission** contract, is a proxy contract active before the re-emission contract. +* The **pay-to-reemission** contract is a proxy contract active before the re-emission contract. -Miners are enforced to pay to this proxy contract. The contract is similar to the existing fee contract but with no time lock. +Miners are forced to pay this proxy contract. The contract is similar to the existing fee contract but with no time lock. * We create new consensus-level checks that verify that the proper amount of re-emission tokens are going from the emission box to a miner rewards box, and also that during spending a box which -is not an emission box but contains re-emission tokens (miner rewards box), the tokens are being burnt, +is not an emission box but contains re-emission tokens (miner rewards box); the tokens are being burnt, and the same amount of nanoERG is locked by the re-emission contract (via a proxy pay-to-reemission contract, - ERGs locked by such a contract could be paid to reemission contract box (its NFT) only). + ERGs locked by such a contract could be paid to the reemission contract box (its NFT) only). -The checks can be switched off via a soft-fork (via voting on disabling rule #123). +The checks can be switched off via a soft-fork (via a vote on disabling rule #123). Contracts ------------------- -Contracts along with new consensus-level checks define re-emission tokens flow, and re-emission <-> ERG token swap +Contracts and new consensus-level checks define re-emission tokens flow and re-emission <-> ERG token swap rules. They are as follows: -* at the activation height re-emission tokens being injected into emission box (consensus-level check) -* starting from activation height, a miner must inject certain amount of re-emission tokens into its reward box (consensus-level check) -* when a box with re-emission tokens (so a reward box) being spent, re-emission tokens must be burnt, and corresponding amount of ERG must be sent to pay-to-reemission contract (consensus-level check) -* peridically, pay-to-re-emission boxes being merging with re-emission contract box (contract-level check) -* from re-emission contract box, ERGs could be withdrawn starting from re-emission start height, 3 ERG per block (contract-level check) +* At the activation height, re-emission tokens are injected into the emission box (consensus-level check) +* Starting from activation height, a miner must inject a certain amount of re-emission tokens into its reward box (consensus-level check) +* When a box with re-emission tokens (so a reward box) is spent, re-emission tokens must be burnt, and a corresponding amount of ERG must be sent to the pay-to-reemission contract (consensus-level check) +* Periodically, pay-to-re-emission boxes being merged with re-emission contract box (contract-level check) +* From the re-emission contract box, ERGs can be withdrawn starting from the re-emission start height, 3 ERG per block (contract-level check) -**Re-emission contract**: This contract pays 3 ERG per block starting from block #2,080,800 . Also, this contract allows for merging with other boxes; the merging transaction must have only two outputs; the first output is for the re-emission contract, the second one is to pay a mining fee (its value can be 0.01 ERG at most) +**Re-emission contract**: This contract pays 3 ERG per block starting from block #2,080,800 . Also, this contract allows for merging with other boxes; the merging transaction must have only two outputs; the first output is for the re-emission contract, and the second one is to pay a mining fee (its value can be 0.01 ERG at most) ```scala val reemissionRewardPerBlock = monetarySettings.oneEpochReduction // 3 ERG @@ -157,7 +157,7 @@ rules. They are as follows: Voting for the Soft-Fork ------------------------ -To vote for the soft-fork on the mainnet (similar testnet voting already done), a solo miner or a pool needs to add the following to their configuration file. +A solo miner or a pool needs to add the following to their configuration file to vote for the soft-fork on the mainnet (similar to the testnet voting already performed). ```conf ergo { @@ -167,14 +167,14 @@ ergo { } ``` -When a voting epoch with at least 888/1024 blocks indicates they support the proposal (by their vote for increasing parameter #8, which holds transaction output cost) is achieved, EIP-27 locks in and will be activated at the given activation height. +EIP-27 is 'locked in' when a voting epoch with at least 888 out of 1024 blocks indicates they support the proposal by their vote for increasing parameter #8, which holds transaction output cost. It will then be activated at the given activation height. Activation Details ------------------ -On emission height, emission NFT and re-emission tokens are injected into the emission contract by spending a box we call the **injection box**. +On emission height, emission NFT and re-emission tokens are injected into the emission contract by spending the **injection box**. -The script protects the injection box. +The following script protects the injection box. ``` { @@ -183,7 +183,7 @@ The script protects the injection box. } ``` -This is spendable by providing 30M ERG in the first input (Only the emission box has so many ERGs). +This is spendable by providing 30M ERG in the first input (Only the emission box has this amount of ERG). API Methods Changed ------------------- @@ -195,8 +195,7 @@ API Methods Changed Wallet Support -------------- - -To have a wallet accounting for re-emission tokens, e.g. making payments correctly in the presence of re-emission tokens, the following flag must be set: +So that the wallet can account for the presence of the re-emission tokens and make payments correctly, the following flag must be set: ```conf ergo { From e87d52418a5c5a4956980350810d2d62850e5d23 Mon Sep 17 00:00:00 2001 From: M Glasgow Date: Tue, 31 May 2022 20:02:52 +0100 Subject: [PATCH 15/19] more text fixes --- eip-0027.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index 75929234..d19e3c52 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -12,9 +12,9 @@ Emission Retargeting Soft-Fork Proposal Motivation ---------- -The long-term security of the Ergo protocol, including its crypto-economic security, is always of the highest priority for the community and core developers. One of the hottest research topics in this field is the possible (in)stability of cryptocurrency protocols after their stable block rewards from emissions comes to an end.[[1]](#references) +The long-term security of the Ergo protocol, including its crypto-economic security, is always of the highest priority for the community and core developers. One of the hottest research topics in this field is the possible (in)stability of cryptocurrency protocols after their stable block rewards from emissions come to an end.[[1]](#references) -During the launch of the Ergo network, it was planned that after the end of emission, miners would be rewarded with transaction fees and storage rent (a unique source of mining income). However, it is difficult to estimate how sufficient or consistently storage rent will replace emissions. +During the launch of the Ergo network, it was planned that miners would be rewarded with transaction fees and storage rent (a unique source of mining income) after the end of emission. However, it is difficult to estimate how sufficient or consistently storage rent will replace emissions. Thus, it was proposed on the ErgoForum informally (in [[2]](#references) and [[3]](#references)) to prolong emission (while preserving the total supply) via a soft-fork([4](#references)). This EIP concludes previous discussions and provides further details on the proposed emission soft-fork design and implementation. @@ -48,23 +48,23 @@ This EIP proposes using the existing contract in combination with checks perform This EIP offers the following procedure for achieving this: * Inject two new tokens into the emission contract. - * The first token is a *singleton* issued to mark the emission box (It could also be used to track the emission box efficiently). + * The first token is a *singleton* issued to mark the emission box (It can also be used to track the emission box efficiently). * The second token is the re-emission token, which will go into mining reward boxes. * The amount of re-emission tokens in a mining rewards box shows how many ERG a miner should send to the re-emission contract when spending the box. Any miner can do the injection, which happens on activation height. We introduce two new contracts, which are described in greater detail below. -* The **re-emission contract** pays 3 ERG for each block after the end of emission. +* The **re-emission contract** pays 3 ERG for each block after the end of emission. * The **pay-to-reemission** contract is a proxy contract active before the re-emission contract. Miners are forced to pay this proxy contract. The contract is similar to the existing fee contract but with no time lock. -* We create new consensus-level checks that verify that the proper amount of re-emission tokens are going from -the emission box to a miner rewards box, and also that during spending a box which -is not an emission box but contains re-emission tokens (miner rewards box); the tokens are being burnt, -and the same amount of nanoERG is locked by the re-emission contract (via a proxy pay-to-reemission contract, - ERGs locked by such a contract could be paid to the reemission contract box (its NFT) only). +We create new consensus-level checks that verify that the proper amount of re-emission tokens goes from the emission box to a miner rewards box. + +Furthermore, we ensure that when spending a box that is not an emission box (but contains re-emission tokens - the miner rewards box), the tokens are burnt, and the same amount of nanoERG is locked by the re-emission contract. + +We achieve this via a proxy pay-to-reemission contract. The ERG locked by such a contract can only be paid to the reemission contract box (its NFT) The checks can be switched off via a soft-fork (via a vote on disabling rule #123). @@ -75,9 +75,9 @@ Contracts and new consensus-level checks define re-emission tokens flow and re-e rules. They are as follows: * At the activation height, re-emission tokens are injected into the emission box (consensus-level check) -* Starting from activation height, a miner must inject a certain amount of re-emission tokens into its reward box (consensus-level check) +* Starting from the given activation height, a miner must inject a certain amount of re-emission tokens into its reward box (consensus-level check) * When a box with re-emission tokens (so a reward box) is spent, re-emission tokens must be burnt, and a corresponding amount of ERG must be sent to the pay-to-reemission contract (consensus-level check) -* Periodically, pay-to-re-emission boxes being merged with re-emission contract box (contract-level check) +* Periodically, pay-to-re-emission boxes are merged with the re-emission contract box (contract-level check) * From the re-emission contract box, ERGs can be withdrawn starting from the re-emission start height, 3 ERG per block (contract-level check) **Re-emission contract**: This contract pays 3 ERG per block starting from block #2,080,800 . Also, this contract allows for merging with other boxes; the merging transaction must have only two outputs; the first output is for the re-emission contract, and the second one is to pay a mining fee (its value can be 0.01 ERG at most) From 48e9952b17747fc3e944b5971a22940170c0a000 Mon Sep 17 00:00:00 2001 From: M Glasgow Date: Tue, 31 May 2022 20:06:03 +0100 Subject: [PATCH 16/19] scalahubs text suggestions --- eip-0027.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eip-0027.md b/eip-0027.md index d19e3c52..53a147ab 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -62,11 +62,9 @@ Miners are forced to pay this proxy contract. The contract is similar to the exi We create new consensus-level checks that verify that the proper amount of re-emission tokens goes from the emission box to a miner rewards box. -Furthermore, we ensure that when spending a box that is not an emission box (but contains re-emission tokens - the miner rewards box), the tokens are burnt, and the same amount of nanoERG is locked by the re-emission contract. +Furthermore, we ensure that when spending a box that is *not an emission box but contains re-emission tokens* (the miner rewards box), the tokens are burnt, and the same amount of nanoERG is locked in a box with the pay-to-reemission contract (aka the proxy contract). -We achieve this via a proxy pay-to-reemission contract. The ERG locked by such a contract can only be paid to the reemission contract box (its NFT) - -The checks can be switched off via a soft-fork (via a vote on disabling rule #123). +These checks can be switched off via a soft-fork (via a vote on disabling rule #123). Contracts ------------------- From 0bc5229b9d3d9e3e147ddc885b3d020530edcad8 Mon Sep 17 00:00:00 2001 From: kushti Date: Sun, 5 Jun 2022 02:20:57 +0300 Subject: [PATCH 17/19] node settings section --- eip-0027.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/eip-0027.md b/eip-0027.md index 53a147ab..3b01d09e 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -205,6 +205,36 @@ ergo { This flag is `false` by default for the sake of performance. +Node Settings +------------- + +* It is mandatory for mining nodes to check EIP-27 rules, for that, use the following setting +```conf +ergo { + chain { + reemission { + checkReemissionRules = true + } + } +} +``` + +This option is off by default (so `= false`) in the mainnet for performance's sake. However, starting from version 4.0.31, +the node is not starting if `mining = true` and `checkReemissionRules = false` + +* If a node wallet may have re-emission tokens (i.e. the node is mining or has the same wallet secret as a +mining node to do payouts), the following setting is needed to handle re-emission tokens (and pay to +pay-to-reemission contract) properly: +```conf +ergo { + wallet { + checkEIP27 = true + } +} +``` + +This option is off by default (so `= false`) for performance's sake. + Testnet Data ------------ @@ -248,6 +278,8 @@ Activation height: `777,217` "boxId": "997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a", "bytes": "80a8d6b9071003040005808098f4e9b5ca6a0402d1ed91c1b2a4730000730193c5a7c5b2a47302008f9e2d0220fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a5101d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a808088fccdbcc32300fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f700" } + +- Re-emission contract box with reemission contract NFT created in tx # [70fc909f363294aa3f8863a8de4d87462e5f843f458292fd2267fbcef3073971](https://explorer.ergoplatform.com/en/transactions/70fc909f363294aa3f8863a8de4d87462e5f843f458292fd2267fbcef3073971) ``` From f23bb2caac10237aa08019bff48c8c48fd3bea39 Mon Sep 17 00:00:00 2001 From: kushti Date: Sun, 5 Jun 2022 02:22:33 +0300 Subject: [PATCH 18/19] adding eip-27 to readme --- README.md | 1 + eip-0027.md | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bab35b9f..6692555d 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ Please check out existing EIPs, such as [EIP-1](eip-0001.md), to understand the | [EIP-0022](eip-0022.md) | Auction Contract | | [EIP-0024](eip-0024.md) | Artwork contract | | [EIP-0025](eip-0025.md) | Payment Request URI | +| [EIP-0027](eip-0025.md) | Emission Retargeting Soft-Fork | diff --git a/eip-0027.md b/eip-0027.md index 3b01d09e..311943e7 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -1,10 +1,10 @@ -Emission Retargeting Soft-Fork Proposal -======================================== +Emission Retargeting Soft-Fork +=============================== * Author: kushti -* Status: Proposed +* Status: Implemented * Created: 17-Dec-2021 -* Last edited: 18-Apr-2022 +* Last edited: 4-Jun-2022 * License: CC0 * Forking: Soft Fork From 3606911bdc45f2138c9354f03514797283362b95 Mon Sep 17 00:00:00 2001 From: kushti Date: Sun, 5 Jun 2022 02:23:48 +0300 Subject: [PATCH 19/19] reemission contract box tx fix --- eip-0027.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eip-0027.md b/eip-0027.md index 311943e7..d3980060 100644 --- a/eip-0027.md +++ b/eip-0027.md @@ -278,9 +278,9 @@ Activation height: `777,217` "boxId": "997369af025fa60dab11d11f94bd5492dbb8731ea3a31154a0388e329f7edf4a", "bytes": "80a8d6b9071003040005808098f4e9b5ca6a0402d1ed91c1b2a4730000730193c5a7c5b2a47302008f9e2d0220fa2bf23962cdf51b07722d6237c0c7b8a44f78856c0f7ec308dc1ef1a92a5101d9a2cc8a09abfaed87afacfbb7daee79a6b26f10c6613fc13d3f3953e5521d1a808088fccdbcc32300fca71b8b95f6ad14ce600a126c8842334d40d35f8754176c4cda2c95219f19f700" } +``` - Re-emission contract box with reemission contract NFT created in tx # [70fc909f363294aa3f8863a8de4d87462e5f843f458292fd2267fbcef3073971](https://explorer.ergoplatform.com/en/transactions/70fc909f363294aa3f8863a8de4d87462e5f843f458292fd2267fbcef3073971) -``` References