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

Spurious dragon fork rules: WIP #109

Merged
merged 4 commits into from
Oct 19, 2017
Merged

Spurious dragon fork rules: WIP #109

merged 4 commits into from
Oct 19, 2017

Conversation

pipermerriam
Copy link
Member

@pipermerriam pipermerriam commented Sep 30, 2017

fixes: #101

What was wrong?

No support for the Spurious Dragon hard fork.

How was it fixed?

Using the EIP's as a reference as well as pyethereum and goethereum, implemented the various fork rules under evm.vm.forks.spurious_dragon.SpuriousDragonVM

https://blog.ethereum.org/2016/11/18/hard-fork-no-4-spurious-dragon/

Cute Animal Picture

marmots-carrot_2265882k

@pipermerriam pipermerriam force-pushed the piper/spurious-dragon branch from 645437d to e222a3f Compare October 2, 2017 22:14
@pipermerriam pipermerriam force-pushed the piper/spurious-dragon branch 3 times, most recently from e418a0f to 663726d Compare October 18, 2017 19:23
@pipermerriam pipermerriam requested a review from gsalgado October 18, 2017 20:09
Copy link
Collaborator

@gsalgado gsalgado left a comment

Choose a reason for hiding this comment

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

Great stuff! A few questions/suggestions but nothing major


for beneficiary in sorted(set(computation.accounts_to_delete.values())):
if computation.error and computation.is_origin_computation:
# Special case to account for geth+parity bug
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe include a link to the bug?



class SpuriousDragonUnsignedTransaction(HomesteadUnsignedTransaction):
def as_signed_transaction(self, private_key, chain_id=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

ISTM that this method is never called with a chain_id argument. Can we get rid of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can but we'll need to re-add it later when we implement the RPC API that performs transaction signing since we'll want to produce replay resistant transactions. Would you prefer we remove it until then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep it, then

if chain_id is None:
v, r, s = create_transaction_signature(self, private_key)
else:
v, r, s = create_eip155_transaction_signature(self, private_key)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we do get rid of that argument, this function also becomes unnecessary, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'm inclined to keep it. This does however expose that this code path isn't covered since it's missing the chain_id argument. adding a test.

transaction_class = SpuriousDragonTransaction
fields = [
('header', BlockHeader),
('transactions', CountableList(SpuriousDragonTransaction)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should you use transaction_class here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow I didn't know you could do this... 👍


if computation.error:
vm.revert(snapshot)
return computation
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't really need this early return here, but if you want to keep it, it'd be nice to do the sprinkle a few more in the else block below, mainly for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you're visually missing an indentation level. Agreed that this code block is difficult to read. Just not sure what to do about it right now (I took the liberty of removing the if vm.logger conditionals since all of our VM's have a logger.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, I thought the other return computation was not inside the else block

@@ -24,7 +27,7 @@ def _apply_homestead_create_message(vm, message):
computation = vm.apply_message(message)

if computation.error:
vm.commit(snapshot)
vm.revert(snapshot)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks suspicious. Why was it needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out it doesn't matter if it commits or reverts. I'm removing the line entirely.

@@ -200,6 +191,15 @@ def add_log_entry(self, account, topics, data):
#
# Getters
#
def get_accounts_for_deletion(self):
if self.error:
return tuple(dict().items())
Copy link
Collaborator

Choose a reason for hiding this comment

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

return () instead?

homestead_start_block is None
)
if no_declared_blocks:
yield (0, SpuriousDragonTesterVM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're going to have to change this every time we implement rules for a new fork, right? Is there any way we could keep a list of existing forks (in order) and always pick the last one here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I've been punting on writing a generic algorithm for this. Soon.

@pipermerriam pipermerriam force-pushed the piper/spurious-dragon branch from c2238d5 to 3177cd7 Compare October 19, 2017 15:03
@pipermerriam pipermerriam force-pushed the piper/spurious-dragon branch from 3889ec8 to 9d124f8 Compare October 19, 2017 15:35
else:
return (v - 35) // 2
return (v - EIP155_CHAIN_ID_OFFSET) // 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now you return the same value in both cases. I don't think that's what you intended?

@@ -79,16 +40,39 @@ def extract_signature_v(v):
return 27
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/27/V_OFFSET?

elif request.param == 'Homestead':
return HomesteadTransaction
elif request.param == 'SpuriousDragon':
return SpuriousDragonTransaction
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use the classes in the params list? params=[FrontierTransaction, HomesteadTransaction, SpuriousDragonTransaction]

@pipermerriam pipermerriam force-pushed the piper/spurious-dragon branch from 700097f to 948e6b6 Compare October 19, 2017 15:53
@pipermerriam pipermerriam merged commit 4fa0f23 into master Oct 19, 2017
@pipermerriam pipermerriam deleted the piper/spurious-dragon branch October 19, 2017 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Spurious Dragon hard fork
2 participants