anvil-zksync icon indicating copy to clipboard operation
anvil-zksync copied to clipboard

Implement STEP Event for zkEVM Similar to EVM's Operation Tracking

Open mpopovac-txfusion opened this issue 2 years ago • 1 comments

🌟 Feature Request

📝 Description

To enhance the zkEVM's tracking capabilities, I'd like to propose the addition of a STEP event similar to the EVM. The STEP event would monitor each operation executed in the EVM during the execution of a smart contract.

Attributes

account:

  • Type: Account
  • Description: Represents the state of the account currently executing the operation.

address:

  • Type: Address {buf: Buffer(20)}
  • Description: The address of the account currently executing the operation.

codeAddress:

  • Type: Address {buf: Buffer(20)}
  • Description: The address where the code being executed resides.

depth:

  • Type: Integer
  • Description: Indicates the current call depth.

eei:

  • Type: Object (EEI)
  • Description: Represents the Ethereum Environment Interface used by the executing contract.

gasLeft:

  • Type: BigInt
  • Description: The remaining gas for the current contract execution.

gasRefund:

  • Type: BigInt
  • Description: Amount of gas that will be refunded at the end of the transaction.

memory:

  • Type: Buffer
  • Description: The current state of the EVM's memory.

memoryWordCount:

  • Type: BigInt
  • Description: The size of memory in words.

opcode:

  • Type: Object {name: String, fee: Integer, dynamicFee: BigInt, isAsync: Boolean}
  • Description: Denotes the current operation code being executed.

pc:

  • Type: Integer
  • Description: The program counter pointing to the position in the bytecode of the current operation.

returnStack:

  • Type: List of BigInt
  • Description: A separate stack used for specific operations.

stack:

  • Type: List of BigInt
  • Description: Represents the current state of the stack in the EVM, where intermediate values are stored during contract execution.

🤔 Rationale

Implementing the STEP event in zkEVM would provide granular insights into contract execution, allowing developers to better understand, debug, and optimize their contracts. This feature would be in line with the transparency and observability standards set by the traditional EVM.

🖼️ Mockups/Examples

account:Account address:Address {buf: Buffer(20)} codeAddress:Address {buf: Buffer(20)} depth:0 eei: EEI gasLeft:1099511509902n gasRefund:0n memory:Buffer(8192) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, %E2%80%A6] memoryWordCount:3n opcode:{name: 'MLOAD', fee: 3, dynamicFee: 3n, isAsync: false} pc:21 returnStack:(0) [] stack:(1) [64n] 0:64n

📋 Additional Context

Ensuring compatibility and similarity with the EVM's STEP event would facilitate smoother migration for developers familiar with the EVM. Moreover, it would further bridge the gap between zkEVM and EVM, providing a consistent development experience.

mpopovac-txfusion avatar Oct 17 '23 13:10 mpopovac-txfusion

Currently not planned or properly spec'd. Will leave open until discussed internally on whether we intend to include in next 2025 plan.

dutterbutter avatar Jan 30 '25 23:01 dutterbutter