Skip to content

Cleanup: delete unreachable legacy State-based transition machinery (looser validation, no live caller) #449

@cryptskii

Description

@cryptskii

Summary

Two state-transition paths coexist: the canonical per-device DeviceState::advance /
advance_relationship path, and an older State-based path (transition::apply_transition,
RelationshipManager::execute_relationship_transition, BilateralTransactionManager::execute_bilateral_transaction).
The older relationship.rs apply_transition performs no signature, balance, or token-consistency checks.

Severity: Low (cleanup). The older transition-execution machinery is not reachable from any live
SDK/JNI/bridge/Android/frontend code
— it is wired only into a SDK example and integration tests. Production
uses only the free helpers compute_smt_key / initial_chain_tip_from_device_ids from that module. Per repo
zero-legacy policy this is dead protocol-bearing code that should be removed before someone wires it into a live
path (which would jump it to High).

Evidence (dsm_client/deterministic_state_machine/)

  • Canonical path: dsm/src/core/state_machine/mod.rs:163 (prepare_advance_relationship), :216
    (commit_advance); dsm/src/types/device_state.rs:457 (DeviceState::advance, enforces token consistency
    with checked_add/checked_sub).
  • Older path (looser): dsm/src/core/state_machine/relationship.rs:657 (apply_transition — clones state, swaps
    op/entropy, rehashes; no op-level validation); :538 (execute_relationship_transition);
    dsm/src/core/state_machine/transition.rs:774 (apply_transition), :881 (create_next_state);
    dsm/src/core/bilateral_transaction_manager.rs:874 (execute_bilateral_transaction).
  • Reachability — older execution path is dead in prod: execute_bilateral_transaction callers are only the
    #[cfg(test)] module (bilateral_transaction_manager.rs:1814,1865), the SDK example
    dsm_sdk/examples/bilateral_transaction_example.rs:313,326, and integration tests
    dsm/tests/bilateral_transaction_integration_tests.rs. Live SDK uses prepare_advance_relationship +
    commit_advance (dsm_sdk/src/sdk/core_sdk.rs:856/933/1233,
    dsm_sdk/src/bluetooth/bilateral_ble_handler.rs:4876-4880).
  • Note: create_next_state is now fail-closed on incoming unilateral transfers (transition.rs:907-924, the
    Issue core/state_machine: relationship keys still use Base32 text and unilateral receive can skip local signature verification #194 fix), so that specific looseness is already addressed; the genuine remaining looseness is the
    relationship.rs apply_transition helper.

Fix (cleanup, delete legacy)

  1. Delete BilateralTransactionManager::execute_bilateral_transaction / exec_offline / exec_online /
    execute_transition_bytes, keeping only the live free functions (compute_smt_key,
    initial_chain_tip_from_device_ids, SMT-replace/anchor helpers).
  2. Delete BilateralStateManager::execute_transition_bytes, RelationshipManager::execute_relationship_transition,
    and relationship.rs's local apply_transition (:657).
  3. Delete transition::apply_transition/create_next_state once their tests are removed (verify still-live
    exports are untouched).
  4. Rewrite the SDK example + integration tests against the canonical prepare_advance_relationship/commit_advance API.
  5. If full deletion is too large for one change, gate the entire older module behind #[cfg(test)] / a non-default
    feature so no shippable build can reach it.

Affected files

  • dsm_client/deterministic_state_machine/dsm/src/core/state_machine/{mod.rs,transition.rs,relationship.rs,bilateral.rs}
  • dsm_client/deterministic_state_machine/dsm/src/core/bilateral_transaction_manager.rs
  • dsm_client/deterministic_state_machine/dsm_sdk/examples/bilateral_transaction_example.rs
  • dsm_client/deterministic_state_machine/dsm/tests/bilateral_transaction_integration_tests.rs

Metadata

Metadata

Assignees

Labels

cleanupDead code and housekeepingpriority:lowLow priority / nice-to-haverefactorCode refactoringrustPull requests that update rust code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions