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

Implement EIP 1234 #1303

Merged
merged 2 commits into from
Sep 22, 2018
Merged

Implement EIP 1234 #1303

merged 2 commits into from
Sep 22, 2018

Conversation

cburgdorf
Copy link
Contributor

@cburgdorf cburgdorf commented Sep 18, 2018

What was wrong?

We need to implement EIP1234

How was it fixed?

Refactored Byzantium implementation to be more reusable for Constantinople. Left a comment inline for an alternative implementation idea.

Cute Animal Picture

put a cute animal picture link inside the parentheses

@cburgdorf cburgdorf force-pushed the christoph/feat/1234 branch 9 times, most recently from ee980b5 to 6a9723e Compare September 18, 2018 13:31
Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

Just noting that I think you'll need to also implement get_uncle_reward as well (but I'm not 100% sure about this)

@cburgdorf
Copy link
Contributor Author

Just noting that I think you'll need to also implement get_uncle_reward as well (but I'm not 100% sure about this)

You are right. Should be fixed now. I'll make an inline comment to get feedback on an alternative implementation idea.

@@ -80,9 +92,3 @@ def validate_receipt(cls, receipt: Receipt) -> None:
@staticmethod
def get_block_reward():
return EIP649_BLOCK_REWARD

@staticmethod
def get_uncle_reward(block_number, uncle):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could make this a @classmethod and then access the block reward on cls.block_reward which would allow us drop any uncle reward refinement in ConstantinopleVM. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Conceptually I'm fine with that but I think it goes against the direction we're trying to go with composition > inheritance. I like the mechanism you've got in place now with the curried re-usable utilities so if you're happy with that I say keep it (and maybe backport it to the ByzantiumVM)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, I like it as-is, too. I kind of like the idea of pushing the get_uncle_reward(...) definition as far back as possible, so that even the import carries semantic meaning, like:

from eth.vm.forks.frontier import get_uncle_reward

Would mean that the uncle mechanism has stayed the same since frontier, with only the block reward changing in: get_uncle_reward = staticmethod(get_uncle_reward(EIP649_BLOCK_REWARD)).

(I don't remember when/if the uncle mechanism changed, but the general concept stands.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SGTM 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I like it as-is, too. I kind of like the idea of pushing the get_uncle_reward(...) definition as far back as possible

It was last changed in byzantium so I think it is already pushed as far back as possible.

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

Going to request two test cases, ideally using something like the eth.tools.fixtures.builder if possible.

  • Simple empty block mining which validates the miner is paid the correct amount
  • Empty block with uncle which validates the miner and uncle miner are paid correctly.

@cburgdorf
Copy link
Contributor Author

@pipermerriam I was leaving out tests because I thought we'll have plenty of shared ethereum/tests that will cover that. Will add some independent tests as well.

@pipermerriam
Copy link
Member

I was leaving out tests because I thought we'll have plenty of shared ethereum/tests that will cover that.

I figured as much. If it proves too big an issue to write them I could be convinced to leave them out but I think it's a good practice for us to start. I know of a few things that I fully expected would be covered by ethereum/tests but aren't so getting better at writing our own (and subsequently being able to contribute them back upstream) would be a big win.

@cburgdorf
Copy link
Contributor Author

I think it's a good practice for us to start. I know of a few things that I fully expected would be covered by ethereum/tests but aren't so getting better at writing our own (and subsequently being able to contribute them back upstream) would be a big win.

Totally agree to that. We can leave this PR open a bit longer if we aren't in a rush. I first want to finish up #1309 if possible.

@cburgdorf
Copy link
Contributor Author

cburgdorf commented Sep 21, 2018

I added one test that involves regular blocks, a fork, included uncle and then ensures the balances of miner 1 and miner 2 match what we expect. I think that should cut it, no?

Ps.: These chain builder tools are heaven! ☁️ ✨

Copy link
Contributor

@carver carver left a comment

Choose a reason for hiding this comment

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

I think that should cut it, no?

Yeah, given that we can expect some more tests to come in after we update the fixtures. If we ignore those tests, then some conspicuously absent tests are:

  • calculating uncle/nephew reward when the uncle is on a different VM (like: uncle in frontier at 0, nephew in constantinople at 1)
  • uncles that are 2 -> 8 layers back
  • validating that uncles > 8 back are invalid

(I'm saying the last two without having reviewed the uncles section of the YP recently, so probably have some detail wrong)

@cburgdorf
Copy link
Contributor Author

Interesting test cases! I'll create a good first starter issue for someone to grab to add expand the reward tests to cover these cases.

@cburgdorf cburgdorf merged commit 0cc5d59 into ethereum:master Sep 22, 2018
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.

3 participants