Rollup Node: Propagate current mutable state in execution

What

This MR introduces context propagation across consecutive block evaluations in the rollup node daemon. Instead of checking out a fresh context from the store for each new block, the daemon keeps track of the current context in a mutable reference and reuses it when the predecessor's context is already available and valid.

Closes TZX-51.

Why

Currently the rollup node checks out the context from Irmin for every block it processes, even though consecutive blocks share the same predecessor context that was just committed. This is wasteful, particularly for the RISC-V PVM where state copies are expensive. By propagating the mutable context across blocks, we avoid redundant checkouts and lay the groundwork for keeping the evaluated PVM state readily available (e.g. for serving RPCs on the head block without re-reading it from disk).

How

A new context_state record is added to Node_context, carrying the current context, the block it corresponds to, and a status flag (Valid or Dirty). The daemon holds a mutable reference to this record in its internal state. When processing a new block, context_of_block first checks whether the reference already holds a valid context for the requested block hash and returns it directly if so, falling back to a checkout from the store otherwise. The lifecycle is managed with two helpers: start_block_evaluation marks the context as Dirty at the beginning of processing, and finish_block_evaluation marks it as Valid after the commit, so that the next block can safely reuse it.

Edited by Alain Mebsout

Merge request reports

Loading