Refactor Environment#1131
Conversation
There are parallels between how the regular block gas is handled and how the blob gas is handled. This commit refactors blob gas canculation to bring them in line with block gas
Create the BlockEnvironment and TransactionEnvironment dataclasses BlockEnvironment holds data that is chain or block scoped TransactionEnvironment holds data that is transaction scoped Message holds data that is specific to a message call
petertdavies
left a comment
There was a problem hiding this comment.
This is really good! I think you missed some cleanup in your test refactoring, but otherwise I am happy to approve.
The tests from execution_spec_tests should now be a part of EEST
SamWilsn
left a comment
There was a problem hiding this comment.
Part one of two hundred and three.
| Items containing contract creation or message call specific data. | ||
| """ | ||
| accessed_addresses = set() | ||
| accessed_addresses.add(caller) |
There was a problem hiding this comment.
Wow, the old code here was pretty misleading.
| gas: Uint | ||
| access_list_addresses: Set[Address] | ||
| access_list_storage_keys: Set[Tuple[Address, Bytes32]] | ||
| tx_index: Uint |
There was a problem hiding this comment.
Would this be more descriptive (and still accurate)?
| tx_index: Uint | |
| index_in_block: Uint |
There was a problem hiding this comment.
Not sure how index_in_block fits in with system transactions processing since there isn't an actual transaction in the block.
There was a problem hiding this comment.
Ah, interesting. So system transactions have an index, but do not appear in the list of txs in the block?
There was a problem hiding this comment.
Actually on second thought, we should set the index to None for the system transactions and rename to index_in_block for actual transactions. This is only used in the context of tracing where the index and hash is used as an identifier for the generated trace. I will update this name.
* refactor blob gas logic There are parallels between how the regular block gas is handled and how the blob gas is handled. This commit refactors blob gas canculation to bring them in line with block gas * create BlockEnvironment and TransactionEnvironment Create the BlockEnvironment and TransactionEnvironment dataclasses BlockEnvironment holds data that is chain or block scoped TransactionEnvironment holds data that is transaction scoped Message holds data that is specific to a message call * refactor validate_header * update t8n * update evm tracing * backport changes to cancun * port to shanghai * port changes to paris * port to london * port berlin * port istanbul * port constantinople * port byzantium * port spurious_dragon * port older forks * fix t8n receipts * update testing * process_withdrawals update * fixes for doc * remove execution_spec_tests entry The tests from execution_spec_tests should now be a part of EEST * use default_factory in BlockOutput * minor fixes 1 * define current_block_number in block_hash opcode * rename tx_index to index_in_block * fix vm test runs
* refactor blob gas logic There are parallels between how the regular block gas is handled and how the blob gas is handled. This commit refactors blob gas canculation to bring them in line with block gas * create BlockEnvironment and TransactionEnvironment Create the BlockEnvironment and TransactionEnvironment dataclasses BlockEnvironment holds data that is chain or block scoped TransactionEnvironment holds data that is transaction scoped Message holds data that is specific to a message call * refactor validate_header * update t8n * update evm tracing * backport changes to cancun * port to shanghai * port changes to paris * port to london * port berlin * port istanbul * port constantinople * port byzantium * port spurious_dragon * port older forks * fix t8n receipts * update testing * process_withdrawals update * fixes for doc * remove execution_spec_tests entry The tests from execution_spec_tests should now be a part of EEST * use default_factory in BlockOutput * minor fixes 1 * define current_block_number in block_hash opcode * rename tx_index to index_in_block * fix vm test runs
* refactor blob gas logic There are parallels between how the regular block gas is handled and how the blob gas is handled. This commit refactors blob gas canculation to bring them in line with block gas * create BlockEnvironment and TransactionEnvironment Create the BlockEnvironment and TransactionEnvironment dataclasses BlockEnvironment holds data that is chain or block scoped TransactionEnvironment holds data that is transaction scoped Message holds data that is specific to a message call * refactor validate_header * update t8n * update evm tracing * backport changes to cancun * port to shanghai * port changes to paris * port to london * port berlin * port istanbul * port constantinople * port byzantium * port spurious_dragon * port older forks * fix t8n receipts * update testing * process_withdrawals update * fixes for doc * remove execution_spec_tests entry The tests from execution_spec_tests should now be a part of EEST * use default_factory in BlockOutput * minor fixes 1 * define current_block_number in block_hash opcode * rename tx_index to index_in_block * fix vm test runs
* export chain_id in fixtureConfig * adjust unit tests * Update src/pytest_plugins/consume/hive_simulators/conftest.py * fix * fix: Make fixture readers backwards compatible --------- Co-authored-by: Mario Vega <marioevz@gmail.com>
(closes #1130 )
(closes #1115 )
(closes #799)
(closes #993 )
What was wrong?
The Environment data class has some transaction scope attributes like sender, origin and a few others. Ideally, this data class should only have block scope attributes and the transaction scope attributes should be moved to a different data class.
This refactor has a few really nice benefits including
Clear and logical separation between the scopes
Simplifying the signature of a lot of functions including the apply_body function (We can now pass just a single
block_envparameter instead of a large number of individual attributes that might change with hard forks)Simplification of the code in t8n
Simplification of system transaction processing code
How was it fixed?
BlockEnvironment,TransactionEnvironmentandBlockOutputdataclassesEESTtest fixtures as well asethereum/testsfixtures