p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
140 stars 86 forks source link

Clarify & strengthen spec around read-write symmetry & canonical encodings #406

Open verios-google opened 1 year ago

verios-google commented 1 year ago

While reading the P4 runtime specification to understand the property of read-write symmetry and the use of canonical encodings, it felt like the specification could be clarified and strengthened around these topics. Specifically, the following concerns were identified and solutions proposed:

Concern 0: Clarify that read-write symmetry excludes read-only property,in other words, it applies only to writable properties. Introduce the notion of read-only vs writable properties. An example of a read-only property is counters. Concern 1: Read-write symmetry is not strictly required today; would be nice if it was. Concern 2: Without imposing additional constraints on the client, we cannot ensure canonical forms & read-write symmetry at the same time. Need to decide which one to prefer or be willing to make a breaking change.

Straw-man Proposal: Server guarantees read-write symmetry, regardless of whether writes were in canonical representation or not. Proposal 1: Assuming last write/update was in canonical form, server guarantees that read will be in canonical form (and hence read-write symmetry) for a writable property; otherwise all bets are off (with respect to canonicity & read-write symmetry)    -Weakest approach    -Harder to express    -Not a breaking change Proposal 2: Servers must unconditionally use canonical encodings. Similar to proposal 1, read-write symmetry is achieved when clients write/update in canonical form.    -Stronger approach    -Easier to express    -Not a breaking change (although more likely for servers to be non-compliant) Proposal 3: Clients and servers must both unconditionally use canonical encodings therefore always ensuring read-write symmetry. Servers return an error message when receiving non-canonical messages from clients.    -Strongest approach    -Easiest to express    -Breaking change

chrispsommers commented 1 year ago

@verios-google Hi, any update/progress?