TL;DR:
This project deploys raw EVM probe contracts and verifies through real transactions whether TLOAD, TSTORE, MCOPY, CLZ, BLOBHASH, and BLOBBASEFEE actually execute on a target node. It also includes a zk_gas_spec scenario suite in a "deploy contract + trigger via tx" form.
src/OpcodeProbes.sol: probe runtimes, deployer, and verifiersrc/ZkGasTxCases.sol: on-chain trigger case contract forzk_gas_spectest/OpcodeVerifier.t.sol: local regression teststest/ZkGasTxCases.t.sol: local regression tests for the on-chain trigger casesscript/VerifyOpcodes.s.sol: broadcast script for real RPC validationscript/RunZkGasTxCases.s.sol: zk gas trigger script for real RPC validation
forge test --offline -vvThe local config in this repository currently enables:
TLOAD/TSTORE,MCOPY,CLZ,BLOBHASH, andBLOBBASEFEE
--offline is used to avoid a Foundry crash in this environment when it attempts online signature decoding. This does not affect the project’s local tests themselves.
To run only the zk gas trigger case tests:
forge test --offline --match-path test/ZkGasTxCases.t.sol -vvPrepare:
export RPC_URL=https://your-node
export PRIVATE_KEY=0x...Then run:
forge script script/VerifyOpcodes.s.sol:VerifyOpcodesScript \
--rpc-url "$RPC_URL" \
--broadcast \
-vvvvTo execute the zk_gas_spec "deploy contract + tx trigger" cases:
forge script script/RunZkGasTxCases.s.sol:RunZkGasTxCasesScript \
--rpc-url "$RPC_URL" \
--broadcast \
-vvvvThe opcode verification script sends real transactions in this order:
- Deploy
OpcodeDeployer - Deploy
OpcodeVerifier - Deploy the
TLOAD/TSTORE,MCOPY,CLZ,BLOBHASH, andBLOBBASEFEEprobes - Send real invocation transactions through
OpcodeVerifier
Each verification emits:
ProbeResult(string opcode, address probe, bool success, bytes raw)
Interpretation:
TLOAD_TSTORE:success = trueand decodedrawequals the written value means supportedMCOPY:success = trueandrawequals the input byte string means supportedCLZ:success = trueand returns the leading-zero count means supportedBLOBHASH:success = trueand returns zero for index0outside blob-tx context means the opcode executed correctlyBLOBBASEFEE:success = trueand returns a non-zero value means the opcode executed correctly
You can inspect the transaction hash from the script output, then run:
cast receipt <TX_HASH> --rpc-url "$RPC_URL"Or inspect the ProbeResult event in a block explorer.
You can also test BLOBHASH and BLOBBASEFEE directly with eth_call state override.
BLOBHASH(0):
curl -sS "$RPC_URL" \
-H 'content-type: application/json' \
--data '{
"jsonrpc":"2.0",
"id":1,
"method":"eth_call",
"params":[
{"to":"0x000000000000000000000000000000000000dEaD"},
"latest",
{
"0x000000000000000000000000000000000000dEaD":{
"code":"0x5f35495f5260205ff3"
}
}
]
}'Expected success result outside blob-tx context:
0x0000000000000000000000000000000000000000000000000000000000000000
BLOBBASEFEE:
curl -sS "$RPC_URL" \
-H 'content-type: application/json' \
--data '{
"jsonrpc":"2.0",
"id":1,
"method":"eth_call",
"params":[
{"to":"0x000000000000000000000000000000000000dEaD"},
"latest",
{
"0x000000000000000000000000000000000000dEaD":{
"code":"0x4a5f5260205ff3"
}
}
]
}'Expected success result:
- a 32-byte non-zero integer if the opcode is supported
- an execution error such as
invalid opcodeif it is not supported
RunZkGasTxCases.s.sol deploys a ZkGasTxHarness and then sends real transactions to trigger these scenarios one by one:
TLOAD/TSTOREMCOPYCALLSTATICCALLDELEGATECALLCALLCODEidentityprecompilemodexpprecompileCREATECREATE2
Each entrypoint emits:
event CaseExecuted(string caseId, bool success, bytes data, address related);Where:
caseIdis the scenario namedatais the ABI-encoded resultrelatedis the target address or the newly created child contract address
This script does not depend on a fixed network name. It only depends on configuration values:
export RPC_URL=https://your-endpoint
export PRIVATE_KEY=0x...