Skip to content
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

Block reward validation #1093

Merged
merged 6 commits into from
May 15, 2019

Conversation

Nizametdinov
Copy link
Member

Fixes #777.

Extracted from #1081 because it contains important changes to coinbase validation which can be easily overlooked.

This PR implements the following rules for coinbase transactions:

  1. The output amount minus the input amount must not be bigger than the block reward plus fees.
  2. The output amount minus the input amount must not be smaller than the block reward. It allows proposers to burn fees. I did it this way because many functional tests generate coinbase transactions without taking into account fees.
  3. Non-reward output amount (sum of all outputs except the first one) must not be bigger than the input amount.

Note that the first output (which is subject to coinbase maturity) can be bigger than the block reward plus fees, i.e. the reward and the stake can be sent to one output. It might useful for proposers who do not want to increase the number of their coins.

@scravy
Copy link
Member

scravy commented May 10, 2019

Concept ACK, reviewing in greater detail

}

// TODO UNIT-E: make the check stricter: if (output_amount - input_amount < total_reward)
if (output_amount - input_amount < total_reward - fees) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This check allows proposers to burn fees.

@Nizametdinov Nizametdinov requested a review from Ruteri May 14, 2019 12:09
Copy link
Member

@Ruteri Ruteri left a comment

Choose a reason for hiding this comment

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

utACK 5651db0

@scravy
Copy link
Member

scravy commented May 14, 2019

utACK 5651db0

Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Signed-off-by: Azat Nizametdinov <[email protected]>
Copy link
Member

@dsaveliev dsaveliev left a comment

Choose a reason for hiding this comment

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

utACK 1a7c4f8

Copy link
Member

@Gnappuraz Gnappuraz left a comment

Choose a reason for hiding this comment

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

utACK 5c5e03e

Copy link
Member

@frolosofsky frolosofsky left a comment

Choose a reason for hiding this comment

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

utACK

@Nizametdinov Nizametdinov merged commit 1deff14 into dtr-org:master May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coinbase with just one output fails for the wrong reason
6 participants