Skip to content

Conversation

@AndreiEres
Copy link
Contributor

@AndreiEres AndreiEres commented Nov 25, 2025

Description

Internal submittion result type changed to keep more information, which should be useful for RPC clients.

Application-level errors moved from JSON-RPC transport errors into the result type for statement_submit RPC method to help clients distinguish between submission outcomes instead of parsing error strings.

Runtime API wasn't changed.

Integration

Breaking Change - statement_submit now returns StatementSubmitResult enum instead of ().

Review Notes

Submission outcomes now return as Ok(result) with status field. Only infrastructure failures (database errors, decode errors) remain as JSON-RPC errors.

NetworkPriority removed as we never used it, reputation changes adjusted.

@carlosala
Copy link
Contributor

Wayyyy better than before, thank you for the effort! 😉

Copy link
Contributor

@carlosala carlosala left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@carlosala
Copy link
Contributor

Probably the next step is to rethink the whole API, reducing the surface and providing clear endpoints 👍🏻

@AndreiEres
Copy link
Contributor Author

AndreiEres commented Nov 27, 2025

I looked at all cases where we use SubmitResult (internal, not RPC types). I think we could be more user-friendly by showing what exactly happened and helping users decide how to fix the problem. Then we can adjust RPC types according to that.

Current SubmitResult

  • New(NetworkPriority)
    • Successfully validated and stored
      • ISSUE: it has NetworkPriority but we never set anything except High
  • Known
    • Statement already exists
  • KnownExpired
    • Statement exists but expired, can't happen during submission over RPC
  • SubmitResult::Ignored
    • Encoded size > MAX_STATEMENT_SIZE
    • Data size > validation.max_size
    • Priority ≤ existing channel message priority
    • Priority too low, can't evict enough messages (account limits)
    • Store full (exceeds max_total_size or max_total_statements)
  • SubmitResult::Bad
    • No statement proof
    • Bad statement proof
  • InternalError(Error)
    • Validation internal error
    • Database commit failed

Proposed SubmitResult

enum SubmitResult {
	New,                       // Submitted
	Known,                     // Already exists
	KnownExpired,              // Already exists but expired, never appears in RPC
	Invalid(InvalidReason),    // Statement is invalid
	Rejected(RejectionReason), // Statement rejected, try again with different parameters
	InternalError(Error),      // Internal error
}

enum InvalidReason {
	NoProof,
	BadProof,
	EncodingTooLarge { submitted_size: usize, max_size: usize },
}

enum RejectionReason {
	DataTooLarge { submitted_size: usize, available_size: usize },
	ChannelPriorityTooLow { submitted_priority: u32, min_priority: u32 },
	AccountFull { submitted_priority: u32, min_priority: u32 },
	StoreFull { submitted_priority: u32, min_priority: u32 },
}

@AndreiEres
Copy link
Contributor Author

/cmd prdoc --audience node_dev --bump major

@AndreiEres AndreiEres added the T0-node This PR/Issue is related to the topic “node”. label Nov 28, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/19767808692
Failed job name: test-linux-stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants