Skip to content

feat: use fact origin block state in offchain reception - #24292

Merged
mverzilli merged 185 commits into
merge-train/fairies-v5from
martin/f-762-fact-origin-block-state-in-offchain-receive
Jul 2, 2026
Merged

feat: use fact origin block state in offchain reception#24292
mverzilli merged 185 commits into
merge-train/fairies-v5from
martin/f-762-fact-origin-block-state-in-offchain-receive

Conversation

@mverzilli

@mverzilli mverzilli commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Tightens up the offchain reception state machine by using block finality to terminate a processed reception

Closes F-762

mverzilli added 30 commits June 10, 2026 08:31
Adds empty(), map, filter, any, all, find and read_as to EphemeralArray
(spun off from #23928) and mirrors them on TransientArray.
Both types are now aliases of a single OracleArray<T, Oracle> generic,
parameterized by an ArrayOracle backend trait whose impls wrap the
existing #[oracle] declarations. Foreign-call names and the TS-side
services are untouched; monomorphization emits the same calls as before.

empty_at stays ephemeral-only via a specialized impl. Test suites are
byte-for-byte unchanged. Expansion snapshots regenerated: nargo expand
now prints the resolved OracleArray paths.
Each behavior check is written once in oracle_array/test_helpers.nr,
generic over the ArrayOracle backend; the ephemeral and transient test
modules keep one named #[test] wrapper per behavior so counts, names
and CI filters are unchanged. Backend-specific tests (empty_at,
store/load/delete) stay with their backend.
Moves empty_at from the ephemeral-only impl into the shared OracleArray
impl, making it available on TransientArray as well. Its doc notes that
for cross-frame backends it wipes data other frames may have written.
The empty_at test moves to the shared suite and runs on both backends.
Generic store/load/delete cores live in oracle_array; ephemeral and
transient expose them via thin module-level wrappers, so both backends
now have identical public surfaces (alias + oracle marker +
store/load/delete). The store/load test bodies move to the shared
suite; each backend keeps a store_and_load smoke test through its own
wrappers. Also fixes the stale test_helpers doc that still described
empty_at and store/load as backend-specific.
Backend test modules no longer list one wrapper per shared check.
Annotating a test module with ephemeral_oracle_array_tests /
transient_oracle_array_tests reflects over test_helpers and emits one
#[test] per unconstrained check with that backend's oracle swapped in,
so new checks automatically run against every backend and the suites
cannot drift. should_fail_with messages come from a single manifest in
test_helpers; an unregistered failing check fails loudly rather than
silently. Generated test names match the previous hand-written ones.
Replaces the two per-backend attribute functions with one
oracle_array_tests(module, oracle) attribute that takes the backend's
oracle as a quoted path at the annotation site.
The module name collided with crate::ephemeral, which owns the
EphemeralArray type. Name the oracle module after what it holds --
the #[oracle(...)] declarations -- so the array module keeps the
plain ephemeral name and the two are unambiguous at use sites.
The module name collided with crate::transient, which owns the
TransientArray type. Name the oracle module after what it holds --
the #[oracle(...)] declarations -- so the array module keeps the
plain transient name and the two are unambiguous at use sites.
OracleArray and ArrayOracle were near-anagrams, forcing readers to
disambiguate which was the struct and which the backend trait. Keep
ArrayOracle (it names the set of oracles that implement an array) and
rename the struct to UnconstrainedArray, after the property every
backend shares: its operations are unconstrained foreign calls into
PXE-side storage, so the data is host-provided and must be verified
before being trusted in constrained code. The oracle_array module,
the ArrayOracle trait, and the Oracle type parameter are unchanged.
Follows the struct rename: the module and its test macro were still
named after the old OracleArray struct. Rename the module directory to
unconstrained_array and the oracle_array_tests macro to
unconstrained_array_tests so the module mirrors the type it houses. The
ArrayOracle trait and the store/load/delete helpers keep their names.
…y rename

UnconstrainedArray is longer than the old OracleArray, so several doc
lines that referenced the type (or its method links) tipped past the
120-column limit. nargo fmt breaks an over-long comment line by pushing
only the trailing word onto a new line, which left mid-paragraph orphans
like '/// not' and '/// the'. Rejoin those words and rewrap the affected
paragraphs at natural points, keeping every line within 120 columns.
…ntOracles

Each of these names a set of oracle operations -- the full backend an
array needs (ArrayOracles) and the concrete ephemeral/transient bundles
that implement it -- so the plural reads truer and matches the
ephemeral_oracles/transient_oracles module names. The singular Oracle
remains as the type parameter: one backend slot filled by one bundle.
The explanatory paragraph on the ArrayOracles trait was dropped during
the previous pluralize commit (a formatter re-stage race on the shared
working tree); the rename itself only swapped the identifier. Restore
the paragraph verbatim. nargo fmt run directly keeps it intact.
…suleArray

for_each iterated in reverse so the callback could remove the current
element without shifting unvisited ones, but nothing in production uses
that capability and backward iteration is surprising both relative to
general intuition and to the sibling methods (map/filter/find), which
all read elements in order.

Iterate forward instead, document that structural mutation from inside
the callback is unsupported, and drop the tests that existed solely to
exercise remove-during-iteration. The order test now asserts the exact
forward visit order.

Linear: F-729
The manual index loop in get_pending_partial_notes_completion_logs
existed only because for_each had arbitrary iteration order. Now that
for_each visits elements in order, the loop can use it directly while
preserving the index alignment between the request array and the
partial note array.

Linear: F-729
@mverzilli
mverzilli requested a review from nventuro as a code owner June 25, 2026 11:21
Adding the OriginState / RetractableFactOrigin symbols and the Fact.origin_block
field perturbs nargo expand's unsorted hashmap iteration order, so the token and
amm expanded snapshots re-emit identical interface functions in a new order
(noir-lang/noir#12933). Order-only drift: sorted added/removed line multisets are
byte-identical (token 51/51, amm 8/8), no body or selector changed.
Round-2 PR feedback on the PXE fact origin-state classifier:
- OriginState -> OriginBlockState
- annotateFact -> toFactWithOriginState
- AnnotatedFact -> FactWithOriginState
- AnnotatedFactCollection -> FactCollectionWithOriginState
- cappedTipBlockNumbers -> anchoredTipBlockNumbers
- shorten the OriginBlockState and RetractableFactOrigin doc comments

Names only on the TS side; the wire format is positional, so the Noir
OriginState wrapper is unaffected.
Completes the origin-state rename across the wire:
- Noir crate::facts::OriginState -> OriginBlockState (matches the TS enum)
- TS classifyOriginState -> classifyOriginBlockState (symmetry with the type)

Names only; the wire format is positional, so serialization is unchanged
(Noir round-trip and TXE finalized/pending tests pass).
The oracle major bump (30->31, cc6adab) changed the standard contracts'
bytecode, but pinned-standard-contracts.tar.gz still held the v30 artifacts.
build() extracts those from the tarball and skips recompiling them, so they
stayed at v30 and PXE (v31) rejected them during private execution, failing
e2e_gov_proposal at SchnorrInitializerlessAccount.entrypoint.

Re-pinned the standard contracts at v31 and regenerated the canonical
addresses/class IDs to a fixpoint (converged in 3 passes): the version
constant is compiled into every contract, so each standard contract's class
id and deterministic address shift. Updates:
- pinned-standard-contracts.tar.gz (standard contracts now v31)
- standard_addresses.nr (aztec-nr + aztec_sublib)
- standard_contract_data.ts (addresses, class ids, bytecode hashes)
The read-side RETRACTABLE_FACT_ORIGIN mapping now returns blockState, so the
strict toEqual in utility_execution.test.ts failed on the extra key. Pin the
anchor above the origin block so the origin classifies deterministically as
finalized, then assert the full read-side origin including
blockState: OriginBlockState.Finalized.
…762-fact-origin-block-state-in-offchain-receive
@AztecBot

AztecBot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/62ab486d0d844e2a�62ab486d0d844e2a8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/multi-node/slashing/broadcasted_invalid_block_proposal_slash.test.ts (145s) (code: 0) group:e2e-p2p-epoch-flakes

The merged oracle registry's named signature matches fairies-v5 (interface
hash 2a441f29), and no official release carried the intermediate v30.1 or the
v31.0 bump, so there is no released artifact to break. Keep MAJOR=30, MINOR=0
across the three version copies (PXE, aztec-nr, aztec_sublib) and rely on the
recomputed interface hash.
…762-fact-origin-block-state-in-offchain-receive
Base automatically changed from martin/annotate-fact-origin-block-state to merge-train/fairies-v5 July 2, 2026 09:16
@mverzilli
mverzilli enabled auto-merge (squash) July 2, 2026 09:25
@mverzilli
mverzilli merged commit 579be59 into merge-train/fairies-v5 Jul 2, 2026
28 checks passed
@mverzilli
mverzilli deleted the martin/f-762-fact-origin-block-state-in-offchain-receive branch July 2, 2026 10:31
github-merge-queue Bot pushed a commit that referenced this pull request Jul 2, 2026
BEGIN_COMMIT_OVERRIDE
feat: use fact origin block state in offchain reception (#24292)
END_COMMIT_OVERRIDE
rangozd pushed a commit to rangozd/aztec-packages that referenced this pull request Aug 5, 2026
BEGIN_COMMIT_OVERRIDE
feat: use fact origin block state in offchain reception (AztecProtocol#24292)
END_COMMIT_OVERRIDE
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