From a8fb4ed8f3b9b76d58365433f78827d5e57681c0 Mon Sep 17 00:00:00 2001 From: Tuna Date: Tue, 10 Apr 2018 11:05:53 +0700 Subject: [PATCH] add block reward to clique config --- cmd/puppeth/wizard_genesis.go | 5 +++++ consensus/clique/clique.go | 6 ++++-- params/config.go | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index f255ef6e65..799384985a 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -66,11 +66,16 @@ func (w *wizard) makeGenesis() { genesis.Config.Clique = ¶ms.CliqueConfig{ Period: 15, Epoch: 30000, + Reward: 0, } fmt.Println() fmt.Println("How many seconds should blocks take? (default = 15)") genesis.Config.Clique.Period = uint64(w.readDefaultInt(15)) + fmt.Println() + fmt.Println("How many Ethers should be rewarded to signer? (default = 0)") + genesis.Config.Clique.Reward = uint64(w.readDefaultInt(0)) + // We also need the initial list of signers fmt.Println() fmt.Println("Which accounts are allowed to seal? (mandatory at least one)") diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 63812845a7..2aa4648552 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -571,8 +571,10 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro // rewards given, and returns the final block. func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { // set block reward - blockReward := big.NewInt(5e+18) - reward := new(big.Int).Set(blockReward) + // FIXME: unit Ether could be too plump + chainReward := new(big.Int).SetUint64(chain.Config().Clique.Reward * params.Ether) + + reward := new(big.Int).Set(chainReward) state.AddBalance(header.Coinbase, reward) // No block rewards in PoA, so the state remains as is and uncles are dropped diff --git a/params/config.go b/params/config.go index dc02c7ca37..868ed1ff84 100644 --- a/params/config.go +++ b/params/config.go @@ -135,6 +135,7 @@ func (c *EthashConfig) String() string { type CliqueConfig struct { Period uint64 `json:"period"` // Number of seconds between blocks to enforce Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint + Reward uint64 `json:"reward"` // Block reward - unit Ether } // String implements the stringer interface, returning the consensus engine details.