22 releases (major breaking)

19.0.1 Sep 26, 2024
19.0.0 Jul 18, 2024
17.0.0 Jun 21, 2024
16.0.0 May 23, 2024
0.1.0-dev.2 Jul 27, 2023

#9 in #removed

Download history 22/week @ 2024-09-16 134/week @ 2024-09-23 55/week @ 2024-09-30 18/week @ 2024-10-07 2/week @ 2024-10-14 10/week @ 2024-10-28 30/week @ 2024-11-04 22/week @ 2024-11-11 94/week @ 2024-11-18 43/week @ 2024-11-25 63/week @ 2024-12-02 109/week @ 2024-12-09

313 downloads per month
Used in polkadot-sdk

GPL-3.0-or-later…

1MB
19K SLoC

Substrate statement store implementation.

License: GPL-3.0-or-later WITH Classpath-exception-2.0

Release

Polkadot SDK stable2409


lib.rs:

Disk-backed statement store.

This module contains an implementation of sp_statement_store::StatementStore which is backed by a database.

Constraint management.

Each time a new statement is inserted into the store, it is first validated with the runtime Validation function computes global_priority, 'max_count' and max_size for a statement. The following constraints are then checked:

  • For a given account id, there may be at most max_count statements with max_size total data size. To satisfy this, statements for this account ID are removed from the store starting with the lowest priority until a constraint is satisfied.
  • There may not be more than MAX_TOTAL_STATEMENTS total statements with MAX_TOTAL_SIZE size. To satisfy this, statements are removed from the store starting with the lowest global_priority until a constraint is satisfied.

When a new statement is inserted that would not satisfy constraints in the first place, no statements are deleted and Ignored result is returned. The order in which statements with the same priority are deleted is unspecified.

Statement expiration.

Each time a statement is removed from the store (Either evicted by higher priority statement or explicitly with the remove function) the statement is marked as expired. Expired statements can't be added to the store for Options::purge_after_sec seconds. This is to prevent old statements from being propagated on the network.

Dependencies

~68MB
~1M SLoC