eval_on_snapshot

Function eval_on_snapshot 

Source
pub fn eval_on_snapshot<DB>(
    context: Arc<EngineContext<DB>>,
    expr: &str,
    snapshot_id: usize,
) -> Result<DynSolValue>
where DB: Database + DatabaseCommit + DatabaseRef + Clone + Send + Sync + 'static, <CacheDB<DB> as Database>::Error: Clone + Send + Sync, <DB as Database>::Error: Clone + Send + Sync,
Expand description

Evaluate a Solidity expression string within the context of a specific debug snapshot.

This is a convenience function that creates an EDB-configured expression evaluator and evaluates the given expression against the specified snapshot.

§Arguments

  • context - The EDB engine context containing snapshots and trace data
  • expr - The expression string to evaluate (e.g., “balances[msg.sender]”)
  • snapshot_id - The ID of the debug snapshot to evaluate against

§Returns

The result of the expression evaluation as a DynSolValue

§Errors

Returns an error if:

  • The expression cannot be parsed
  • The snapshot ID is invalid
  • The expression evaluation fails (e.g., variable not found, function call fails)

§Examples

// Evaluate a balance check
let result = eval_on_snapshot(context, "balances[msg.sender] > 1000", snapshot_id)?;

// Evaluate a function call
let supply = eval_on_snapshot(context, "totalSupply()", snapshot_id)?;

// Evaluate blockchain context
let is_recent = eval_on_snapshot(context, "block.timestamp - lastUpdate < 3600", snapshot_id)?;