Skip to content

Allow nested RevertableDeltas #247

@preston-evans98

Description

@preston-evans98

Background

A working_set can be set into revertable mode. In this mode, any writes which occur after the call working_set.to_revertable() and before workin_set.commit() may be undone by calling revert. We use this function to revert individual transactions if - for example - they run out of gas. However, we currently use a single working_set for an entire slot, not just a single batch - and since the working_set only supports one layer of revertable writes, we can't revert batches if the sequencer is discovered to be malicious. To fix the issue, we need to allow at least two layers of revertable state - a tx level delta, and a batch level delta.

Ideas

One way to approach this would be to create a new NestedRevertableDelta struct:

pub struct StackedRevertableDelta<S: Storage> {
    /// The inner (batch-level) revertable delta
    inner: RevertableDelta<S>,
    /// A cache containing the most recent values written. Reads are first checked
    /// against this map, and if the key is not present, the underlying Delta is checked.
    writes: HashMap<CacheKey, Option<CacheValue>>,
}

A second approach would be to use type-level programming to express that Revertable Deltas may be nested, but all layers of nesting must be stripped away (by reverting or committing them) before returning from the apply blob function.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions