-
Notifications
You must be signed in to change notification settings - Fork 686
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 State
object
#236
Comments
@hwwhww I was thinking you (or someone on the sharding team) would be a good fit for implementing this since you'll have a better idea of what's needs to be built on top of it. Otherwise, I'm happy to take this on. |
@pipermerriam |
WorklogIn py-evm/tests/json-fixtures/test_virtual_machine.py Lines 112 to 113 in 288e65b
But these two function were moved from
|
With the idea that the
Thoughts? Not sure if I missed something. I'm open to alternate solutions. |
@pipermerriam Your solution works well and clean! I apply it by replacing HomesteadStateForTesting = HomesteadState.configure(
name='HomesteadStateForTesting',
apply_message=apply_message_for_testing,
apply_create_message=apply_create_message_for_testing,
get_ancestor_hash=get_block_hash_for_testing,
)
HomesteadVMForTesting = HomesteadVM.configure(
name='HomesteadVMForTesting',
_state_class=HomesteadStateForTesting,
) Thank you so much. |
close via #247 |
What is wrong?
Currently, the
VM
class is part of the constructor for theComputation
object. Here are the places where it is currently used.Giving computation direct access to the
VM
is problematic for a number of reasons.How can it be fixed
To fix this, lets create a new
State
object. Similar to how theTransaction
class is specified for eachVM
, theState
object should be similarly overrideable.VM.get_state_class()
VM.get_state()
VM.state
(this could be a convenienceproperty
that just delegates toVM.get_state()
.The
State
object will need the following things.coinbase/timestamp/block_number/difficulty/gas_limit
.StateDB
The
State
object will also need the following APIs available to it.VM.apply_message
VM.apply_create_message
I think the best way to accomplish this is to relocate the following APIs to live directly on the
State
object itself, removing them from theVM
object.VM.apply_message
VM.apply_create_message
VM.apply_computation
Note that
VM.apply_computation
needs access toVM.get_opcode_fn()
andVM.precompiles
. This indicates we'll need to supply theState
object with a way to get at this data. The simplest solution that comes to mind is to add them as extra arguments:The text was updated successfully, but these errors were encountered: