> loading_
# EIP-8175 Exploration: Capabilities & fee_auth
# ================================================
# NOTE: EIP-8175 is in draft. These opcodes and mechanisms are NOT live on mainnet.
# This walkthrough is conceptual, based on the current EIP spec, to help you
# reason about the proposed changes.
# --- 1. Understanding the Capabilities Model for CALL ---
# In the current EVM, a CALL is permissionless — the callee can do anything
# its code allows. EIP-8175 introduces a capabilities bitfield that restricts
# what the callee frame is allowed to do.
# Conceptual pseudocode for a capability-restricted CALL:
#
# capabilities = CAP_SEND_VALUE | CAP_CREATE # allow value transfer + CREATE
# capabilities &= ~CAP_DELEGATECALL # disallow DELEGATECALL in child frame
#
# CALL_WITH_CAP(gas, target, value, in_offset, in_size, out_offset, out_size, capabilities)
#
# If the callee attempts a DELEGATECALL, the EVM would revert that sub-frame
# automatically. This is enforced at the protocol level, not in Solidity.
# --- 2. New Opcodes ---
# EIP-8175 introduces new opcodes to query and enforce capabilities:
#
# GETCAP -> pushes the current frame's capability bitfield onto the stack
# REQUIRECAP(cap) -> reverts if the current frame lacks the specified capability
#
# Example: A contract that refuses to execute without CREATE permission:
#
# // Hypothetical Solidity inline assembly (future compiler support needed)
# assembly {
# let caps := getcap() // new opcode
# let hasCreate := and(caps, 0x04) // CAP_CREATE = bit 2 (illustrative)
# if iszero(hasCreate) {
# revert(0, 0) // bail if we can't CREATE
# }
# }
# --- 3. The fee_auth Mechanism ---
# fee_auth allows an EOA or contract to sign an authorization granting another
# address the right to pay gas fees on its behalf.
#
# Conceptual flow:
#
# Step A: User signs a fee_auth message off-chain:
# fee_auth_payload = {
# authorizer: "0xUserAddress",
# sponsor: "0xSponsorAddress",
# max_fee: 1000000, # max gas units authorized
# nonce: 42,
# expiry: 1744070400 # Unix timestamp
# }
# signature = sign(fee_auth_payload, user_private_key)
#
# Step B: Sponsor submits a transaction that includes the fee_auth:
# tx = {
# to: target_contract,
# data: calldata,
# fee_auth: (fee_auth_payload, signature) # new transaction field
# }
# # The protocol debits gas from sponsor, but msg.sender in the EVM
# # reflects the authorizer (0xUserAddress), not the sponsor.
# --- 4. What to Watch For ---
# - Compiler support: Solidity/Vyper will need updates for new opcodes
# - Tooling: Hardhat, Foundry, and Revm will need to implement the new opcodes
# in their EVM interpreters for local testing
# - Security: Capability restrictions change the trust model of composed calls;
# audit frameworks will need updated threat models
#
# Track the EIP: https://github.com/ethereum/EIPs (search for EIP-8175)
# Track the reference implementation in Revm by rakita