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

Add transaction_context object to Computation #327

Merged
merged 7 commits into from
Feb 8, 2018

Conversation

lrettig
Copy link
Contributor

@lrettig lrettig commented Jan 29, 2018

Creating a PR to track this work in progress. From #262.

@lrettig lrettig changed the title Add transaction_context object to Computation (WIP) Add transaction_context object to Computation Jan 29, 2018
execution.
"""
_gas_price = None
_origin = None
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the @property versions of these. Should be good just using them directly as properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason for why we protect fields of ExecutionContext is that we want to make sure the fields only be assigned in __init__ and won't be changed in other places.
But I'm not sure what's the use cases of TransactionContext.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pipermerriam originally said:

This would be an object that we treat as immutable

So it should be the same, no?

Copy link
Member

Choose a reason for hiding this comment

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

@hwwhww @property methods don't actually provide any protection from mutation unless you create a setter which throws. I'd be good with doing that but it should probably be done with our own decorator that automatically creates the setter function. Something like a new decorator:

@immutable_property
def something(self):
    ...

Copy link
Contributor

Choose a reason for hiding this comment

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

@pipermerriam
So sorry for that I just realized I missed and haven't seen this comment(#273 (comment)) 15 days ago! Agree with you about using explicit @read_only_property or @immutable_property decorator.

Copy link
Member

Choose a reason for hiding this comment

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

No big deal. Easy enough for us to make that cleanup now (mind opening an issue for it?)

@lrettig I'm fine with leaving current @property methods in place and cleaning them up with a stand-alone PR with the @immutable_property/read_only_property decorator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, thanks for the clarification

@pipermerriam pipermerriam mentioned this pull request Jan 31, 2018
1 task
@lrettig lrettig force-pushed the transaction-context branch 2 times, most recently from 48eddcb to aebe522 Compare February 7, 2018 01:59
Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.
Create from instance rather than specific class in execute_transaction.
Pass transaction context object into get_computation.
Update a couple of opcodes and a util method that rely on origin and
gas_price
Updates a bunch of tests, adds one new test. These tests are all
passing.
Bugfix: transaction_context cannot be instantiated without an origin.
Use the transaction.sender when instantiating.
Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
@lrettig lrettig force-pushed the transaction-context branch from aebe522 to 5602f72 Compare February 8, 2018 07:39
@@ -295,6 +302,8 @@ def test_state_fixtures(fixture, fixture_vm_class):
computation, _ = vm.apply_transaction(transaction)
except ValidationError as err:
transaction_error = err
LOGGER.warn("Got transaction error:")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pipermerriam This is a little messy, not sure if this is how logging should happen inside tests, but this made my life much easier when running tests as these errors were being swallowed silently. Let me know if this is okay.

I also want to understand: can a transaction raise a TransactionError but the test still pass? Are there tests which expect an error?

Copy link
Member

Choose a reason for hiding this comment

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

There is no TransactionError in py-evm that I know of so I'm not entirely sure what you're referring to here.

In the case of this section of code, yes, transactions can error and the tests still pass because some of the tests are designed to throw errors, testing invalid transactions do not succeed to execute in the EVM.

@pipermerriam pipermerriam merged commit 403c17f into ethereum:master Feb 8, 2018
@lrettig
Copy link
Contributor Author

lrettig commented Feb 9, 2018 via email

lrettig added a commit to lrettig/py-evm that referenced this pull request Feb 9, 2018
Rebase and update to work with ethereum#327 changes. Adds code_address to allow
execution of arbitrary code in the context of an existing contract per
ethereum#306 (comment).
lrettig added a commit to lrettig/py-evm that referenced this pull request Feb 11, 2018
Rebase and update to work with ethereum#327 changes. Adds code_address to allow
execution of arbitrary code in the context of an existing contract per
ethereum#306 (comment).
pipermerriam pushed a commit that referenced this pull request Feb 15, 2018
* Minimal proof of concept for exec bytecode

Construct a message and pass it through apply_computation

* Add missing origin param

* Add transaction_context

Rebase and update to work with #327 changes. Adds code_address to allow
execution of arbitrary code in the context of an existing contract per
#306 (comment).

* Allow code_address to be None

* Bugfix: pass tx_context to apply_computation

* Parametrize the computation_getter

Per @pipermerriam's suggestion
lrettig added a commit to lrettig/py-evm that referenced this pull request Feb 15, 2018
Ports over the changes made to master in ethereum#327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
hwwhww pushed a commit to hwwhww/py-evm that referenced this pull request Feb 18, 2018
Ports over the changes made to master in ethereum#327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
hwwhww pushed a commit to hwwhww/py-evm that referenced this pull request Feb 22, 2018
Ports over the changes made to master in ethereum#327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
hwwhww pushed a commit to hwwhww/py-evm that referenced this pull request Feb 23, 2018
Ports over the changes made to master in ethereum#327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
hwwhww pushed a commit to hwwhww/py-evm that referenced this pull request Mar 2, 2018
Ports over the changes made to master in ethereum#327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
hwwhww pushed a commit that referenced this pull request Mar 2, 2018
Ports over the changes made to master in #327.

Creates a BaseTransactionContext class and a child
FrontierTransactionContext class.
Removes properties which remain constant (gas_price, origin) from
Message and move them to the new TransactionContext class.
Generate a TransactionContext inside execute_transaction and attach it
to the Computation object. Pass this down into child Computations.
Begin reworking code which reads the (now-removed)
Message.{origin,gas_price}.

Update tests.

Errors from blockchain fixtures were being swallowed silently. Output
these along with a full stack trace to make debugging easier.
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.

3 participants