Skip to content

feat: EntityStore#23989

Open
mverzilli wants to merge 5 commits into
martin/richer-ephemeral-and-transient-array-apisfrom
martin/entity-store
Open

feat: EntityStore#23989
mverzilli wants to merge 5 commits into
martin/richer-ephemeral-and-transient-array-apisfrom
martin/entity-store

Conversation

@mverzilli

Copy link
Copy Markdown
Contributor

A new store in PXE DB. It's designed to provide generic, persistent, reorg resilient storage to contract developers.

It stores write-only Entities, and each Entity stores 0..N write-only Facts.

An entity is an opaque body with a type, a unique id, isolated to a contract address and scope.
A fact has an opaque body, a type, and belongs to an entity.

Both can be retractable or non-retractable. They are retractable when they are associated to an origin block. They are non-retractable when they are not associated to an origin block.

A retractable entity is transparently made unavailable by PXE when its origin block drops out of the chain. In that case all its facts (retractable or not), are gone with it.

A retractable fact is transparently removed from an entity by PXE when its origin block drops out of the chain. Sibling facts (non-retractable or retractable on a different origin block) remain untouched.

Entities can (and should) be terminated at some point in their lifecycle, to avoid unbounded storage and processing.

Stores immutable facts about entities keyed by (contract, scope, entity
type, entity id), with per-job staged writes flushed atomically on
commit. Facts and entities carry an optional block anchor: anchored
(retractable) records are deleted when their block is pruned, while
unanchored ones survive reorgs as external inputs.

Wired into openPxeStores with schema backwards-compatibility coverage.
The block synchronizer rolls the entity store back alongside the note
and private event stores when the chain is pruned: entities and facts
anchored to orphaned blocks are deleted, unanchored ones survive.
EntityStore is registered with the job coordinator so staged facts
flush atomically with the other stores on job commit.
Rewrite the chain-pruned entity store test in neutral terms (no
offchain-message vocabulary) and extend it to cover entity-level
retraction: a retractable entity anchored on the abandoned fork is
deleted wholesale including its unanchored fact, while a
non-retractable entity survives losing only its anchored fact.
'Anchor' is already taken by the PXE anchor block concept; the block a
retractable entity or fact is tied to is now its 'origin block'
(FactAnchor -> OriginBlock, anchor -> originBlock). No serialization
change: the buffer layout carries no field names, so the stored format
and compatibility snapshots are untouched.
stored_fact.ts held both record classes. Give each its own file
(stored_fact.ts, stored_entity.ts) with a matching test file, and move
the shared primitives they both depend on -- the OriginBlock type, the
EntityCoords type, and the scope/entity key derivation -- into a new
entity_keys.ts so neither class file imports the other. factRowKeyOf
stays with StoredFact as it is fact-specific.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant