Custom Ordering Rules

Define deterministic ordering rules beyond FIFO.

Fairseq defaults to FIFO ordering, but you can define custom policies that better match your protocol. All rules must be deterministic and auditable.

Built-in rules

FIFO (default)

RUST
let config = Config {
    ordering_rule: OrderingRule::Fifo,
    ..Default::default()
};

Priority fee

RUST
let config = Config {
    ordering_rule: OrderingRule::PriorityFee,
    ..Default::default()
};

Custom rule example

RUST
let config = Config {
    ordering_rule: OrderingRule::Custom(Box::new(|a, b| {
        // Example: prioritize highest fee, then fallback to timestamp.
        a.fee.cmp(&b.fee).then(a.timestamp.cmp(&b.timestamp))
    })),
    ..Default::default()
};

Best practices

  • Version your rules and store a policy ID in proof metadata.
  • Keep rule inputs minimal to simplify audits.
  • Reuse the same ordering implementation across prover/verifier environments.

Common pitfalls

  • Non-deterministic inputs (wall clock variance, randomness).
  • Hidden tie-breakers that are not captured in metadata.

Tip

If your ordering policy is sensitive, prefer a self-hosted prover so policy inputs never leave your infrastructure.

Was this page helpful? /
Back to docs