-
Notifications
You must be signed in to change notification settings - Fork 657
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
Conversation
645437d
to
e222a3f
Compare
e418a0f
to
663726d
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
evm/vm/computation.py
Outdated
@@ -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()) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c2238d5
to
3177cd7
Compare
3889ec8
to
9d124f8
Compare
evm/utils/transactions.py
Outdated
else: | ||
return (v - 35) // 2 | ||
return (v - EIP155_CHAIN_ID_OFFSET) // 2 |
There was a problem hiding this comment.
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?
evm/utils/transactions.py
Outdated
@@ -79,16 +40,39 @@ def extract_signature_v(v): | |||
return 27 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]
700097f
to
948e6b6
Compare
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