Repository navigation
Conversation
Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Nothing prunes the dedicated synchronizer's sequencer, so its journal already has every interval. Read both ends of each requested interval from it instead of storing totals, which drops the store, the migration and the trigger. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
A page is 100 intervals, so a request makes at most 101 sequencer reads. The response says where the next page starts until it reaches the requested end. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The interval length is now a config field, 10 minutes by default, so the LSU test can shorten it and see the interval that spans the upgrade end. It checks that interval is read from both sequencers. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Paymasters rely on 10-minute intervals, so only tests should change it. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The reads already stop at the first refusal, so checking the app clock first only saved one call per request. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
…affic-report-v2 Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
`auth` is now required, so the image reads the audience and JWKS URL from env vars that the chart sets from `auth.audience` and `auth.jwksUrl`. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
| synchronize = Some(NonNegativeDuration.ofSeconds(60)), | ||
| ) | ||
|
|
||
| clue("the interval that is not over is Undetermined") { |
There was a problem hiding this comment.
I'm not sure I like this UX. Can't we just reject a request that includes an interval that's not over? We don't need real-time data here, just forcing the user query a few minutes back seems fine.
There was a problem hiding this comment.
done, the call now fails with a 400 that says which range to ask for instead, and the per-interval status is gone
Instead of a status per interval, the request fails with a 400 that says which range to ask for instead. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The route setup moves into `SyncOperatorApp.routes`, so a unit test covers the app's own wiring: the auth the integration test checked, and the 400 for a range the sequencer can't serve. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The check used `Map.empty` in place of the successor's reading before the upgrade; it now reads the successor there. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Without a server there is no request timeout, so the directive warned and failed checkErrors. The app now wraps `SyncOperatorApp.routes` in the error handler, and the test uses only its exceptions directive. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
| /** The first interval that starts after the sequencer's pruning lower bound. Pruning keeps only | ||
| * each member's latest journal row up to that bound, so readings at or before it are wrong. | ||
| * Canton prunes the journal before it moves the bound, so a request at the edge of the retention | ||
| * period can still race a prune and report a wrong total. |
There was a problem hiding this comment.
Can't we query firstReadable again after we create the report, and confirm that at that time it hasn't been invalidated yet? That way, we risk only a false-negative if you're querying close to the pruning window, which seems better than risking reporting wrong numbers.
There was a problem hiding this comment.
good call, changed it.
it reads the pruning bound again after the page and rejects if it moved past the start.
| } | ||
|
|
||
| val acrossStart = trafficReport.alignDown(upgradeTime) | ||
| val acrossEnd = acrossStart.plus(trafficReport.intervalLength) |
There was a problem hiding this comment.
Isn't there a small flakiness risk here if the upgradeTime falls exactly on the end of the interval? Might be safer to just always add 2xintervalLength?
There was a problem hiding this comment.
Ah, but then alignDown is exactly upgradeTime.. So I think it's fine.
|
|
||
| def notOver(start: CantonTimestamp, end: CantonTimestamp): String = | ||
| s"The interval [$start, $end) is not over yet, or the sequencer has not sequenced past its " + | ||
| s"end. Request a range that ends at or before $start." |
There was a problem hiding this comment.
| s"end. Request a range that ends at or before $start." | |
| s"end. Request a range that ends at or before $start (or wait for long enough after $end and retry)" |
Canton prunes the traffic journal before it moves the pruning bound, so a prune during a read could change the readings without the first check noticing. The reader now checks the bound again afterwards and rejects the range if it moved past the start. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Besides asking for an earlier range, the caller can wait until the sequencer is past the interval and retry. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
| eventually(timeUntilSuccess = 1.minute) { | ||
| trafficStates(end) | ||
| } | ||
| reportedInterval(last) |
There was a problem hiding this comment.
Nit: I think you can also do here
eventuallySucceeds {
reportedInterval(last)
}
There was a problem hiding this comment.
done in 97dadce, here and in the LSU test
|
|
||
| /** The first interval that starts after the sequencer's pruning lower bound. Pruning keeps only | ||
| * each member's latest journal row up to that bound, so readings at or before it are wrong. | ||
| * Canton prunes the journal before it moves the bound, so the reader checks the bound again |
There was a problem hiding this comment.
the reader checks the bound again
I find it confusing that this comment is here while the implementation is in a completely different file.
There was a problem hiding this comment.
moved it next to the re-check in the reader, 9d7572f
| * after reading. Only a read that falls entirely between the prune and the move can still | ||
| * report a wrong total. |
There was a problem hiding this comment.
Only a read that falls entirely between the prune and the move can still report a wrong total.
I don't understand what this means. If we still have a case where we return wrong numbers, we should try to fix that. The endpoint should either succeed and be correct, or fail if it cannot guarantee correctness.
There was a problem hiding this comment.
okay will need to add sync app owned pruning in another PR
There was a problem hiding this comment.
canton deletes the traffic journal before it moves the bound, and a pruned reading looks like a participant that hasn't used traffic yet, so nothing on the read side can tell. the fix on our side is for the app to own sequencer pruning and never read while it prunes, made a PR for it #115.
After going through the rest again to see if anything was missed. I also fixed two cases here that could return wrong numbers:
-the successor's pruning bound wasn't checked for readings after the upgrade (f891fea), and
- a participant leaving mid-interval was silently dropped, now that interval is rejected (154d6ac).
There was a problem hiding this comment.
a participant leaving
Hmmm... I don't think this can happen. Topology is append-only, so I don't think there is such a thing as "participant left". Can you reproduce it beyond a unit test?
In fact, I hope you're wrong and this is not possible, otherwise we're risking not being able to report traffic whenever a participant takes a certain action, which is bad. If this is the case, we need to escalate this to Canton team, so that their traffic state continues being reported forever (which, again, I suspect/hope is actually already the case right now).
…encer Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Readings after the upgrade come from the successor, so its bound has to be checked too. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The reading at the end no longer lists it, so its traffic up to when it left can't be read. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
The successor takes over each member's counter with its original timestamp, so reading both ends from it matches whenever nothing was consumed between the interval's start and the upgrade. Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Signed-off-by: Sebastian Lindner <33971232+salindne@users.noreply.github.com>
Refs ChainSafe/canton-extending-mainnet#152
Replaces #103, which carried #101's history from before the squash.
Summary:
GET /v0/traffic-reportreturns the traffic charged to participants per 10-minute interval, summed across participants as #87 asks, 100 intervals per page. For each interval it reads every member's consumed traffic from the sequencer'sGetLsuTrafficControlStateat the start and end. If the sequencer can't serve an interval (not over yet, pruned, or before the upgrade to it), the call fails with a 400 that says which range to ask for instead. It needs a JWT, soauthis a new required config field, and the image and Helm chart pass it through.A successor sequencer takes over the counters at an upgrade but not their history, so readings up to the announced upgrade time come from the current sequencer and later ones from the successor.
GetLsuTrafficControlStatewith a timestamp is documented for disaster recovery; is a page of up to 101 calls per request OK? One call took 6 to 30 ms locally.