Skip to content

[ETCM-44] Treasury block reward distribution #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 29, 2020

Conversation

ntallar
Copy link

@ntallar ntallar commented Sep 23, 2020

Description

Adapts block reward distribution to the treasury

Proposed Solution

Follows the specification described in this section:

  • If treasury contract wasn't deployed or was selfdestroyed: follow ETC rules, 100% reward for block to miner
  • If treasury contract was deployed but the miner opted-out: 80% reward for block to miner
  • If treasury contract was deployed and miner opted-in: 80% reward for block to miner, 20% reward for treasury

Testing

Testing on mainnet

  • Mantis should still remain compatible with ETC mainnet and mordor

Testing on private network

  1. Start up a node
  • Gas limit on mainnet genesis isn't enough for the txs being sent below, a value of 0x1388000000 worked for me
  • It requires an account with funds so you should create one and add it to the genesis file
  • Requires configuration of private network: mocked mining on, fast sync off, pruning off, etc
  1. Deploy a contract with a function that calls selfdestroy, simpler one that can be used is:
pragma solidity ^0.5.0;

contract MockTreasury {
    function shutdown() public {
        // All funds from the contract are burned
        selfdestruct(address(0));
    }
}
  1. Restart the node after:
  • Configuring the deployed contract address as the treasury address
  • Setting the ECIP1098 block number activation to a more feasible one
  1. Mine enough blocks to surpass the ECIP1098 activation block
  • Block reward distribution should behave as spec'ed, both before and after the activation of ECIP1098
  1. Call function to selfdestroy the contract, mine further blocks and check that block reward distribution behaves as before ECIP1098 activation

Pending

  • Test on mainnet
  • Add useful endpoints examples to insomnia

@ntallar ntallar added BREAKS CONFIG Affects the default configuration BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate labels Sep 23, 2020
@ntallar ntallar force-pushed the etcm-44-ecip1098-block-reward branch 2 times, most recently from 38cbba7 to ea15d31 Compare September 24, 2020 17:36
@ntallar ntallar force-pushed the etcm-44-ecip1098-block-reward branch from ea15d31 to 787810f Compare September 24, 2020 17:52
@ntallar ntallar marked this pull request as ready for review September 24, 2020 18:05
@ntallar ntallar requested review from mirkoAlic and removed request for kapke September 28, 2020 12:02

val blockchainConfig = Config.blockchains.blockchainConfig
val syncConfig = SyncConfig(Config.config)
class BlockRewardSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyChecks with MockFactory {

"Reward Calculation" should "pay to the miner if no ommers included" in new TestSetup {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"it"?

…for implicit BlockRewardCalculatorWithFullReward
@ntallar ntallar requested a review from mirkoAlic September 28, 2020 17:24
Copy link
Contributor

@mirkoAlic mirkoAlic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@@ -45,26 +46,47 @@ class BlockPreparator(
* @return
*/
private[ledger] def payBlockReward(block: Block, worldStateProxy: InMemoryWorldStateProxy): InMemoryWorldStateProxy = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor comment: I would update scaladoc, to reflect all the changes and maybe mention treasury spec.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did! I'm not sure whether to mention the spec or not as it's not public yet. I think the description I added should be a good enough description without having to refer to it

@ntallar ntallar merged commit 02fc7f6 into develop Sep 29, 2020
@ntallar ntallar deleted the etcm-44-ecip1098-block-reward branch September 29, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKS CONFIG Affects the default configuration BREAKS PROTOCOL Affects Node2Node interactions in a way that makes them not interoperate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants