Skip to main content
PhEVM executes assertion bytecode for the Assertion Enforcer. It extends the EVM with state snapshots and transaction inspection.

Purpose

PhEVM checks assertions against transaction state changes. See Execution Model for triggers and snapshots.

Key Capabilities

State Access

PhEVM can access blockchain state at multiple points during transaction execution:
  • Pre-transaction state: The blockchain state before the transaction executes
  • Post-transaction state: The blockchain state after the transaction executes
  • Pre-call state: State before a specific internal call within the transaction
  • Post-call state: State after a specific internal call within the transaction
Assertions can compare values across these execution points.

Cheatcodes

PhEVM implements special precompiles called cheatcodes that provide capabilities beyond standard EVM operations:
  • Snapshot reads: loadStateAt with explicit ForkId values for pre-transaction, post-transaction, pre-call, and post-call state
  • Call introspection: Access to call inputs, call traces, and execution context
  • State change tracking: Monitor storage slot modifications during execution
  • Log access: Retrieve transaction logs for enforcement
These cheatcodes are exposed through the credible-std library and documented in the Cheatcodes Reference.

Off-Chain Execution

PhEVM runs offchain with these execution properties:
  • Higher gas limits: Assertions can perform complex computations that would be prohibitively expensive on-chain
  • Off-chain assertion gas: Assertion execution does not consume Ethereum block gas. Credible-block markers and on-chain guard checks have separate gas costs.
  • Parallel execution: Multiple assertions can execute simultaneously

How It Works

PhEVM receives state snapshots and cached assertion bytecode. It executes matching assertion functions and reports their results. An assertion revert marks the candidate as invalid. See Assertion Enforcer for the enforcement process.