CIP 0104: Traffic Weighted App Rewards: Serve App Activity Records and Traffic Summarys from /v0/events#4154
Conversation
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Co-authored-by: Divam <681060+dfordivam@users.noreply.github.com> Signed-off-by: Timothy Emiola <adetokunbo@users.noreply.github.com>
Co-authored-by: Divam <681060+dfordivam@users.noreply.github.com> Signed-off-by: Timothy Emiola <adetokunbo@users.noreply.github.com>
Co-authored-by: Divam <681060+dfordivam@users.noreply.github.com> Signed-off-by: Timothy Emiola <adetokunbo@users.noreply.github.com>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Co-authored-by: Divam <681060+dfordivam@users.noreply.github.com> Signed-off-by: Timothy Emiola <adetokunbo@users.noreply.github.com>
dfordivam
left a comment
There was a problem hiding this comment.
we possibly also need to add two "enable" flags in request, and disable serving these by default with events
apps/scan/src/main/openapi/scan.yaml
Outdated
| description: | | ||
| Computed app activity record derived from verdicts and traffic summaries. | ||
| Each record represents the traffic-weighted activity of featured app providers at a given record_time, | ||
| and is derived from a computation involving the verdict and traffic summary data. |
There was a problem hiding this comment.
We could mention CIP-0104 here
There was a problem hiding this comment.
Possible, but at the moment it does not look like a CIP number is mentioned in any other open API descriptions, so this would be the first
apps/scan/src/main/openapi/scan.yaml
Outdated
| - total_traffic_cost | ||
| - envelope_traffic_costs | ||
| properties: | ||
| sequencing_time: |
There was a problem hiding this comment.
Not sure if we really need to include this
There was a problem hiding this comment.
Neither am I. @meiersi-da should we replicate fields like sequencing time, and in the activity record record time that can be obtained from the verdict ?
There was a problem hiding this comment.
I think sequencing_time is special. It serves as the primary key for the events themselves. The right place might be to serve it on the EventHistoryItem itself.
That said: I'm not sure. It really depends on the access patterns that we want to make easily possible. Let's have a quick chat in our sync meeting.
| .map(toUpdateV2) | ||
| val verdictEncoded = verdictWithViewsO.map { case (v, views) => | ||
| ScanHttpEncodings.encodeVerdict(v, views) | ||
| items <- Future.traverse(events) { case (verdictWithViewsO, updateO) => |
There was a problem hiding this comment.
How about doing a batch read of activity records?
Given that the activity records are also being provided by the ScanEventStore, modifying the getEvents may be better?
apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/db/DbScanVerdictStore.scala
Show resolved
Hide resolved
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
These have been added. |
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
| If an event pertains to a contract reassignment, there will be no verdict data. | ||
| If an event pertains to a wholly private transaction, there will only be verdict data. | ||
| If an event pertains to a transaction that is partially private, it may also bear verdict information for the private portions. | ||
| When both fields are present, the transaction and verdict have the same `update_id` and `record_time`. |
There was a problem hiding this comment.
Update this comment as well wrt traffic summaries and activity records.
meiersi-da
left a comment
There was a problem hiding this comment.
Thanks. Did a quick review of the API parts only as prep for our meeting.
apps/scan/src/main/openapi/scan.yaml
Outdated
| items: | ||
| type: integer | ||
| format: int32 | ||
| EventHistoryAppActivityRecord: |
There was a problem hiding this comment.
| EventHistoryAppActivityRecord: | |
| EventHistoryAppActivityRecords: |
apps/scan/src/main/openapi/scan.yaml
Outdated
| properties: | ||
| record_time: | ||
| description: | | ||
| The record_time (= sequencing_time) of the verdict/traffic summary. |
There was a problem hiding this comment.
Yeah, OK. This hints very much at pushing the sequencing_time of the confirmation request to the top-level.
There was a problem hiding this comment.
Fixed, as discussed in the meeting
apps/scan/src/main/openapi/scan.yaml
Outdated
| format: int64 | ||
| entries: | ||
| description: | | ||
| App activity entries, one per featured app provider. |
There was a problem hiding this comment.
| App activity entries, one per featured app provider. | |
| App activity entries, one per app provider. |
we'll want this API to also work when we start to support unfeatured app providers: https://github.com/canton-foundation/cips/blob/main/cip-0104/cip-0104.md#rewards-for-unfeatured-apps
There was a problem hiding this comment.
Done, and in 2 other locations in the change.
apps/scan/src/main/openapi/scan.yaml
Outdated
| Computed app activity record derived from verdicts and traffic summaries. | ||
| Each record represents the traffic-weighted activity of featured app providers at a given record_time, | ||
| and is derived from a computation involving the verdict and traffic summary data. |
There was a problem hiding this comment.
| Computed app activity record derived from verdicts and traffic summaries. | |
| Each record represents the traffic-weighted activity of featured app providers at a given record_time, | |
| and is derived from a computation involving the verdict and traffic summary data. | |
| App activity record compted from verdicts and traffic summaries | |
| as per [CIP-104](https://github.com/canton-foundation/cips/blob/main/cip-0104/cip-0104.md). |
Minimize specificity to make the API hold up when we evolve rewards further. Referring to CIP-104 seems fine though, as we can just replace it with a reference to the new CIP that changes it.
Co-authored-by: Simon Meier <simon@digitalasset.com> Signed-off-by: Timothy Emiola <adetokunbo@users.noreply.github.com>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
|
@meiersi-da PTAL, the outstanding comments should all be addressed, and I also removed duplicate fields as discussed earlier |
meiersi-da
left a comment
There was a problem hiding this comment.
Thanks. Looks good. Looking forward to seeing this code pass an integration test.
apps/scan/src/main/openapi/scan.yaml
Outdated
| If an event pertains to a wholly private transaction, there will only be verdict data. | ||
| If an event pertains to a transaction that is partially private, it may also bear verdict information for the private portions. | ||
| When both fields are present, the transaction and verdict have the same `update_id` and `record_time`. | ||
| A traffic summary is present when sequencer traffic cost data is available for the verdict's confirmation request. |
There was a problem hiding this comment.
| A traffic summary is present when sequencer traffic cost data is available for the verdict's confirmation request. | |
| **Experimental**: for networks where the SVs enable activity record | |
| computation, a traffic summary and app activity record are present when | |
| a verdict is present. | |
| This support is experimental while the preview phase of CIP-104 | |
| is running. |
There was a problem hiding this comment.
I know we internally have a finer grained configuration. I'd not communicate this as the intention is to enable both of them at all times, but we might disable one of them in case of problems. No need for users to care about the exceptional circumstance.
apps/scan/src/main/openapi/scan.yaml
Outdated
| An app activity record is present when the verdict is successful and involves app providers. | ||
| When present, both the traffic summary and app activity record correspond to the verdict's record_time. |
There was a problem hiding this comment.
| An app activity record is present when the verdict is successful and involves app providers. | |
| When present, both the traffic summary and app activity record correspond to the verdict's record_time. |
apps/scan/src/main/openapi/scan.yaml
Outdated
| **EXPERIMENTAL**: This property is experimental and subject to change. Data may be incomplete or missing. | ||
| $ref: "#/components/schemas/EventHistoryTrafficSummary" | ||
| nullable: true | ||
| app_activity_record: |
There was a problem hiding this comment.
| app_activity_record: | |
| app_activity_records: |
apps/scan/src/main/openapi/scan.yaml
Outdated
| properties: | ||
| round_number: | ||
| description: | | ||
| The round number assigned to the activity record. |
There was a problem hiding this comment.
| The round number assigned to the activity record. | |
| The round number assigned to the activity records. |
apps/scan/src/main/openapi/scan.yaml
Outdated
| as per [CIP-104](https://github.com/canton-foundation/cips/blob/main/cip-0104/cip-0104.md). | ||
| required: | ||
| - round_number | ||
| - entries |
There was a problem hiding this comment.
| - entries | |
| - records |
There was a problem hiding this comment.
here and in related names
reason for using record is whitepaper, page 12 scoping an activity record to a single app
apps/scan/src/main/openapi/scan.yaml
Outdated
| type: array | ||
| items: | ||
| $ref: "#/components/schemas/AppActivityEntry" | ||
| AppActivityEntry: |
There was a problem hiding this comment.
| AppActivityEntry: | |
| AppActivityRecord: |
apps/scan/src/main/openapi/scan.yaml
Outdated
| AppActivityEntry: | ||
| type: object | ||
| description: | | ||
| A single app provider's activity weight. |
There was a problem hiding this comment.
| A single app provider's activity weight. | |
| Activity record for an app. |
| )(implicit tc: TraceContext): Future[Map[CantonTimestamp, AppActivityRecordT]] = { | ||
| if (recordTimes.isEmpty) Future.successful(Map.empty) | ||
| else { | ||
| val inClause = sqlCommaSeparated(recordTimes.map(rt => sql"$rt")) |
There was a problem hiding this comment.
@rautenrieth-da : what is our guidance of using in-clauses with many parameters, vs using ANY(array)? AFAIR, the latter has lower query parsing overhead, and better planner cache hits...
There was a problem hiding this comment.
Fixed. I updated this to ANY(array) via the inClause function. Details in f61dbcd
There was a problem hiding this comment.
Thanks! Using the inClause() helper is definitely the right thing to do here.
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
- needed to add an implicit for setting arrays of timestamps to AcsJdbcTypes Signed-off-by: Tim Emiola <adetokunbo@emio.la>
f61dbcd to
d0879d7
Compare
Follows-up from #4037
N.B. #4037 is not yet merged, so this contains all it's commits. It will be submitted before this one is, in the meantime please review the latest commits on this PR
Pull Request Checklist
Cluster Testing
/cluster_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./hdm_teston this PR to request it, and ping someone with access to the DA-internal system to approve it.PR Guidelines
Fixes #n, and mention issues worked on using#nMerge Guidelines