Submission validation pipeline (Step 2) #3

Closed
justinmoon wants to merge 9 commits from demo/step-2 into master
justinmoon commented 2025-09-22 05:23:27 +12:00 (Migrated from github.com)

Summary

  • Introduces the submission validation pipeline to the server as a focused, test-covered module. This enforces that a client completes HELLO/HELLO ACK before submitting, and that submitted records are structurally and cryptographically valid per mosaic-core.

What’s included

  • New module: src/validation.rs
    • validate_submission(&Message, &ClientData) -> Result<OwnedRecord, SubmissionValidationError>
    • Maps validation failures to unified ResultCode values:
      • HandshakeNotComplete, WrongMessageType -> INVALID
      • RecordTooLong -> TOO_LARGE; other record verification errors -> INVALID
  • Public export in src/lib.rs for handler integration in a later step.
  • Unit tests covering the validation rules (handshake prerequisite; wrong type; corrupted record invalidation; oversize mapping).
  • Cargo updates to wire in mosaic-core locally during development and ensure tests run.

Spec alignment

  • Record verification: mosaic-spec/docs/record.md (§Validation).
  • Submission and result codes: mosaic-spec/docs/messages.md (§Submission, §Result Codes).
  • Handshake prerequisite is enforced implicitly by requiring negotiated state in ClientData before accepting submissions (Hello/Hello Ack wire format already validated in mosaic-core).

Out of scope (deliberate)

  • Storage/duplicate detection and wiring the store into the handler will come in a later step.
  • Handler changes for Submission are not included here; this keeps the PR small and focused.

Notes

  • Redundant HELLO behavior and incompatible-version Closing details are tracked outside this PR and do not impact the validation module.
Summary - Introduces the submission validation pipeline to the server as a focused, test-covered module. This enforces that a client completes HELLO/HELLO ACK before submitting, and that submitted records are structurally and cryptographically valid per mosaic-core. What’s included - New module: src/validation.rs - validate_submission(&Message, &ClientData) -> Result<OwnedRecord, SubmissionValidationError> - Maps validation failures to unified ResultCode values: - HandshakeNotComplete, WrongMessageType -> INVALID - RecordTooLong -> TOO_LARGE; other record verification errors -> INVALID - Public export in src/lib.rs for handler integration in a later step. - Unit tests covering the validation rules (handshake prerequisite; wrong type; corrupted record invalidation; oversize mapping). - Cargo updates to wire in mosaic-core locally during development and ensure tests run. Spec alignment - Record verification: mosaic-spec/docs/record.md (§Validation). - Submission and result codes: mosaic-spec/docs/messages.md (§Submission, §Result Codes). - Handshake prerequisite is enforced implicitly by requiring negotiated state in ClientData before accepting submissions (Hello/Hello Ack wire format already validated in mosaic-core). Out of scope (deliberate) - Storage/duplicate detection and wiring the store into the handler will come in a later step. - Handler changes for Submission are not included here; this keeps the PR small and focused. Notes - Redundant HELLO behavior and incompatible-version Closing details are tracked outside this PR and do not impact the validation module.
justinmoon commented 2025-09-22 05:25:00 +12:00 (Migrated from github.com)

oops i meant to work against my local fork for a while ...

oops i meant to work against my local fork for a while ...

Pull request closed

Sign in to join this conversation.
No description provided.