Skip to content

refactor(worker): remove AsmState umbrella, persist AnchorState directly - #3

Open
vladb-ai wants to merge 2 commits into
mainfrom
refactor/remove-asm-state
Open

refactor(worker): remove AsmState umbrella, persist AnchorState directly#3
vladb-ai wants to merge 2 commits into
mainfrom
refactor/remove-asm-state

Conversation

@vladb-ai

@vladb-ai vladb-ai commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Replicated from alpenlabs#174

Description

AsmState bundled an AnchorState with the STF's log entries, but the anchor-state DB only ever persisted the AnchorState — the logs live in the manifest store. Every read re-joined the two back into an AsmState. That re-join existed to feed the Moho worker, which now reads logs from the manifest store directly (get_anchor_logs), so the umbrella no longer serves any production path; it only backed the RPC status (via a dead logs() helper) and two integration tests.

This removes the type: the worker and runner store and thread AnchorState directly, and the tests that need logs read them from the recorded manifest (block-keyed, so it stays correct across reorgs) rather than a state-carried copy.

Note: AsmWorkerStatus.cur_state (returned by the RPC get_status) changes shape — it is now an AnchorState rather than an AsmState wrapping {state, logs}. Nothing in this repo read those status logs.

Type of Change

  • Refactor

Notes to Reviewers

Stacked on alpenlabs#169 (it uses the typed WorkerError variants), so this PR is based on refactor/worker-typed-errors and should merge after it. Rebase onto main once alpenlabs#169 lands.

The re-join it removes was added to fix a real bug (a re-committed anchor silently dropping a block's export entries, desyncing the persisted MohoState); that path is now covered by the Moho worker reading logs from the manifest store directly, so the invariant is preserved.

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

prajwolrg and others added 2 commits July 2, 2026 15:21
AsmState bundled an AnchorState with the STF's log entries, but the anchor
state DB only ever persisted the AnchorState — the logs live in the manifest
store. Every read re-joined the two back into an AsmState. That re-join
existed to feed the Moho worker, which now reads logs from the manifest store
directly (get_anchor_logs), so the umbrella no longer serves any production
path; it only backed the RPC status and two integration tests.

Store and thread AnchorState throughout the worker and runner, and have the
tests that need logs read them from the recorded manifest (block-keyed, so it
stays correct across reorgs) rather than a state-carried copy.
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🔒 AI Security Review

No security issues found.

This PR is a pure mechanical refactor: it removes the AsmState wrapper (AnchorState + STF log entries) and threads AnchorState directly through the worker, runner, and storage layers. Callers that previously got logs via the re-joined AsmState now read them straight from the manifest store, keyed by block (Moho worker's pre-existing get_anchor_logs, and the test harness's new get_logs_at).

Reviewed for the standard categories (injection, auth/access control, crypto/secrets, memory/integer safety, unsafe error handling, DoS) — none apply here:

  • No new trust boundaries or untrusted-input parsing is introduced; all changed code is internal worker/storage/test plumbing.
  • No unsafe, no new arithmetic, no crypto or credential handling touched.
  • The crash-safety ordering in apply_block (crates/worker/src/service.rs) is preserved: manifest + aux data are still persisted before the anchor-state commit point, and every write remains an idempotent, block-keyed overwrite — the PR doesn't change this contract, only the type being written.
  • The invariant this refactor references (a prior bug where a re-committed anchor silently dropped a block's export entries because reads re-joined the anchor state with empty logs) can't regress here: production log consumption already goes through the Moho worker's get_anchor_logs, which reads the manifest store directly rather than through the removed re-join path, and that function is untouched by this diff.
  • The one behavioral surface change — AsmWorkerStatus.cur_state (RPC get_status) now returns AnchorState instead of AsmState { state, logs } — is a shape change, not a security regression; the PR description notes nothing in this repo consumed the status logs.

No findings to report.

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.

2 participants