[go: up one dir, main page]

SCORU/Node: better abstraction for node_ctxt mutable fields

The node context is implemented as a record with two mutable fields:

type 'a t = {
  ...
  mutable lcc : lcc;
  mutable lpc : Sc_rollup.Commitment.t option;
}

This leads to two issues:

  1. These fields can be mutated even for a [Read] t`, which should be read-only.
  2. When a copy of an 'a t is created, mutations of these fields in the original won't be reflected in the copy. This can be an issue when using the type casting function readonly, which will create a copy.

The second issue was a problem for !7715 (merged), as it would force the publisher worker to keep a Node_cotntext.rw in its state rather than a Node_context.ro, even if it never writes to it (but it should react to changes by other components).

Edited by Antonio Locascio