Closed ltfschoen closed 6 years ago
In ll. 138+, https://github.com/ethereum/sharding/blob/384ccbfd62bbf7e766fb5e66279448adba16effa/sharding/state_transition.py#L138, we have:
def finalize(state, coinbase):
"""Apply rewards and commit
(refer to ethereum.pow.consensus.finalize)
"""
delta = int(state.config['COLLATOR_REWARD'])
state.delta_balance(coinbase, delta)
I think the doc is a bit misleading:
At the end, there is an additional step, finalizing the collation (to give the collator the reward, which is
COLLATOR_REWARD
ETH). This requires asking the network for a Merkle branch for the collator's account. When the network replies with this, the post-state root after applying the reward, as well as the fees, can be calculated. The collator can then package up the collation, of the form (header, txs, witness), where the witness is the union of the witnesses of all the transactions and the branch for the collator's account.
Note that it doesn't actually say that the reward is applied, just that the post-state root after applying the reward, as well as the fees, can be calculated.
The old spec is deprecated.
In the Sharding Specification in paragraph of Line 276 it states "At the end, there is an additional step, finalizing the collation (to give the collator the reward...", then then explains the additional step. It says that after the network replies it will "apply the reward" to the collator, and then says that "The collator can then package up the collation, ...".
Why are we applying the reward before instead of after the collator has finished packaging up the collation?