Skip to content

Paginated datastore-key ABIs (AS path, exploratory) - #361

Merged
peterjah merged 3 commits into
mainfrom
5284-paginated-ds-keys
Sep 28, 2026
Merged

peterjah merged 3 commits into
mainfrom
5284-paginated-ds-keys

Conversation

@bilboquet

@bilboquet bilboquet commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Exploratory implementation for massalabs/massa#5284 (part (a) of massalabs/massa#5241).

Adds get_keys_paginated / get_keys_for_paginated to the Interface trait (prefix filter, exclusive start_after cursor, mandatory count), the matching assembly_script_get_keys_paginated[_for] host functions, gas cost entries (provisional values mirrored from the existing key ABIs — real calibration is tracked massa-side), and unit tests for the pagination param mapping.

Deliberately out of scope here: wasmv1. GetDsKeysRequest lives in massa-proto-rs, so paginating wasmv1 would pull a third repo into this change — that keep-or-cut decision is tracked on massalabs/massa#5284.

Draft until the massa-side integration and review feedback settle the shape (in particular whether part (c) metering needs the scanned-key count to cross this same trait boundary, to avoid a second migration).

##UPDATE
Adds paginated AssemblyScript datastore-key ABIs, activated with massa MIP-0002.

  • assembly_script_get_keys_paginated and assembly_script_get_keys_for_paginated take an optional prefix, an exclusive start_key cursor, and a mandatory count in 1..=500 (MAX_DATASTORE_KEYS_PAGE).
  • The imports are registered only when the host reports an execution version at or above PAGINATED_DS_KEYS_EXECUTION_VERSION, an alias of the MIP-0002 wasmv1-disable version. Before that, or if the host cannot report a version, the imports are absent, so instantiation fails the same way as on a node that does not have them.
  • Each call costs a flat 190000 gas. That covers the worst page the cap allows: 500 keys of 255 bytes (117k + 500 × 255 × 0.55 ≈ 187k).
    The existing get_keys / get_keys_for imports stay registered. The wasmv1 datastore-key ABI is unchanged.

Comment thread src/as_execution/context.rs Outdated
@Leo-Besancon
Leo-Besancon self-requested a review September 24, 2026 13:59

@Leo-Besancon Leo-Besancon left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (not approving as I still think everyone's input is needed. Not entirely sure this would be needed, but if we want it it seems a nice implementation.

Note that it would be good to explicitely test the MIP gate on the test network once this is merged (it's harder to review the behaviour than massa repo only breaking changes IMO).

Add get_keys_paginated / get_keys_for_paginated to the Interface trait
(prefix filter, exclusive start_after cursor, mandatory count), with
matching assembly_script_get_keys_paginated[_for] host functions, gas
cost entries (provisional, mirrored) and unit tests for the pagination
param mapping.

Exploratory work for massalabs/massa#5284 (wasmv1 intentionally out:
its request type lives in massa-proto-rs, a third repo).
Only resolve the new assembly_script_get_keys_paginated[_for] imports
when the host reports an execution component version at or past
PAGINATED_DS_KEYS_EXECUTION_VERSION (MIP-0002 massa-side), so an updated
node rejects the imports before activation exactly like a non-updated
node. Unknown versions fail closed.
@peterjah
peterjah force-pushed the 5284-paginated-ds-keys branch from 8c4e6ed to d5f8223 Compare September 28, 2026 10:18
@peterjah
peterjah marked this pull request as ready for review September 28, 2026 10:20

@Leo-Besancon Leo-Besancon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some inline comments, otherwise LGTM!

Comment thread src/types.rs
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Leo-Besancon
Leo-Besancon previously approved these changes Sep 28, 2026

@Leo-Besancon Leo-Besancon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a nit, but not blocking: approving.

Comment thread src/types.rs Outdated
@peterjah
peterjah enabled auto-merge September 28, 2026 13:52
@peterjah
peterjah added this pull request to the merge queue Sep 28, 2026
Merged via the queue into main with commit 409b0ef Sep 28, 2026
11 checks passed
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.

3 participants