-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat(tests): Add Tests for STOP Opcode and Blob Data Handling in Shard Blob Transactions for EIP-4844 #977
Conversation
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.
Thanks for the PR @jcqln2! I appreciate your ambition in tackling a complex task like testing an opcode within a blob transaction!
While your test test_stop_opcode_with_transaction
fills correctly and passes when executed against clients, it seems that it's not testing the opcode execution as intended. The reason is that the bytecode provided in the calldata (tx.data
) isn't executed when sent to an EOA address. In Ethereum, only contract accounts execute code upon receiving a transaction.
In your current implementation, the transaction sends calldata to an EOA (to="0x000000000000000000000000000000000000dead"
), but EOAs do not execute code. Although a contract creation transaction would execute the initcode that is set as part of tx.data
, as per the EIP-4844 specification, type 3 transactions (blob transactions) cannot be contract creation transactions (where to=None
). This means we need an alternative approach to test opcode execution within a blob transaction.
Here are a couple of paths you might explore:
-
To align the test with your original intention: Deploy a contract with the desired bytecode in the pre-state allocation. Then, send a transaction to this contract's address to trigger code execution. You can refer to this example where a contract is deployed and interacted with:
execution-spec-tests/tests/istanbul/eip1344_chainid/test_chainid.py
Lines 28 to 37 in 8539345
contract_address = pre.deploy_contract(Op.SSTORE(1, Op.CHAINID) + Op.STOP) sender = pre.fund_eoa() tx = Transaction( ty=0x0, chain_id=0x01, to=contract_address, gas_limit=100000000, gas_price=10, sender=sender, -
Alternatively, modify the test to focus on a specific behavior that is permissible within the constraints of EIP-4844.
If time permits, to verify what the EVM is executing during the test, you can use Geth's evm
tool.
Here's how you can use it:
-
Install/download geth (note geth is no longer a prerequisite for filling - this is an old version of the docs): https://ethereum.github.io/execution-spec-tests/v3.0.0/getting_started/quick_start/
-
Fill the test using Geth's evm t8n command instead of EELS to get execution traces:
fill tests/cancun/eip4844_blobs/eip4844_stopblob.py --evm-bin=~/bin/go-ethereum/bin/evm --traces --evm-dump-dir=/tmp/debug
-
Inspect the trace file to see if the EVM executed any code. If the EVM didn't use any gas, it indicates no execution took place (
/tmp/debug/cancun__eip4844_blobs__eip4844_stopblob__test_stop_opcode_with_transaction/fork_Cancun_blockchain_test/0/trace-0-0xce0288fdff9e0b7b3ec1bb8663b645d651da5a54df6941403dc1cc604267db2d.jsonl
).
Alternatively, you can use consume
to execute the test against Geth's evm blocktest command:
consume direct --input=fixtures/blockchain_tests/cancun/eip4844_blobs/eip4844_stopblob/ --evm-bin=~/bin/go-ethereum/bin/evm -k blockchain_test -v
Edit: Instead of consume
, it's easier to run evm blocktest directly:
evm --json --debug --verbosity 100 blocktest fixtures/blockchain_tests/cancun/eip4844_blobs/eip4844_stopblob/stop_opcode_with_transaction.json
@jcqln2 - just so you don't miss it, I made a small edit above. |
Thanks for the feedback, I'll try to modify and commit changes today by my midday (EST) |
As I mentioned in DMs, feel free to take as much time as you like/can afford 👍 |
Closing in favor of #982. |
🗒️ Description
This test covers:
🔗 Related Issues