SV-app add CalculateRewardsTrigger and ProcessRewardsTrigger#5552
SV-app add CalculateRewardsTrigger and ProcessRewardsTrigger#5552dfordivam wants to merge 37 commits into
Conversation
meiersi-da
left a comment
There was a problem hiding this comment.
Nice work! Thanks a lot! Great to see of this coming together @dfordivam and @adetokunbo 👏
@adetokunbo : note that I gave quite a few pointers wrt the usage of triggers, task outcomes, and retries. Please have a look, as you are going to work on a trigger as well this week.
In general, when implementing a trigger it's always worth to check its logging behavior carefully and think about whether these logs are "right" for the work the trigger is doing. Filtering to the trigger name in lnav gets that job done quite well.
| .transformWith { | ||
| case Failure(ex) => | ||
| Future.failed( | ||
| new RuntimeException("Failed to connect to scan for root hash lookup", ex) |
There was a problem hiding this comment.
This will likely be noisy in production. Scan can be down. Best is probably to just let the errors bubble up and be handled by our retry infrastructure.
Also: it seems that you are creating a fresh scan connection per task. Is this what's done in other parts of the codebase as well?
There was a problem hiding this comment.
Ok, fixed this by returning None, The scan connection situation is a bit complicated actually as we will not be able to likely make use of existing abstractions being used in sv-app. My idea is to remove this ephemeral connection later when BFT support is added, such that both are provided through a well designed abstraction. So I have just added a TODO for now.
There was a problem hiding this comment.
Replaced fresh scan connection with a long lived one, as discussed yesterday.
| acsStoreId, | ||
| domainMigrationId, | ||
| splice.amulet.rewardaccountingv2.ProcessRewardsV2.COMPANION, | ||
| orderLimit = sql"""order by reward_round limit ${sqlLimit(limit)}""", |
There was a problem hiding this comment.
Do we have an index that would make this sorting efficient? If not, do we need this sorting here?
There might be many coupons in prod, and we wouldn't want this query to become a problem.
There was a problem hiding this comment.
I have replaced this with 'mining_round' which has index. And in some ways 'mining_round' is more appropriate for the CalculateRewardsV2 and ProcessRewardsV2. Also bumped the store version in this PR, as I forgot to do that in the earlier PR where I added the ingestion. (#4724)
| // Bootstrapping a network with mintingVersion set to trafficBasedAppRewards | ||
| // is in principle not supported, as the round 0 will never have | ||
| // activity totals/root-hash calculated, and its CalculateRewardsV2 cannot be processed. | ||
| // So the only way to handle this in test is via direct archive. |
There was a problem hiding this comment.
This is actually a problem when we reset TestNet the next time.
What can we do so that we don't need to skip these first five rounds? I'd have expected anyways that we only need to skip Round 0, due to our requirement for there to be activity for the round one lower.
We can probably use a similar approach as done here:
i.e., if no app activity metadata record exists at all and we are the first SV, then we insert it with the initialRound and recordTime = unixEpochStart.
There was a problem hiding this comment.
And it's also a problem for all our tests once we make traffic-based app rewards the default.
There was a problem hiding this comment.
Ok, I have added a TODO linking to #5624
81d901c to
4d8c9e6
Compare
eba9097 to
b2641fb
Compare
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Mostly a patch reapply of earlier commit done on main Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
Signed-off-by: Divam <dfordivam@gmail.com>
17a4114 to
c62d886
Compare
Signed-off-by: Divam <dfordivam@gmail.com>
|
@meiersi-da This PR is now ready for another review. All comments have been addressed, and/or TODOs added. |
meiersi-da
left a comment
There was a problem hiding this comment.
Nice work! Thanks a lot!
| case None => | ||
| throw Status.FAILED_PRECONDITION | ||
| .withDescription( | ||
| s"waiting for scan to compute root hash for CalculateRewardsV2 round $round, will retry" |
There was a problem hiding this comment.
| s"waiting for scan to compute root hash for CalculateRewardsV2 round $round, will retry" | |
| s"Scan has not yet computed the root hash for CalculateRewardsV2 round $round." |
That's the precondition that is actually violated.
| taskOutcome <- queryResult match { | ||
| case QueryResult(_, Some(_)) => | ||
| Future.successful( | ||
| TaskSuccess( |
There was a problem hiding this comment.
| TaskSuccess( | |
| TaskNoop( |
| damlBatch = convertBatch(batch) | ||
| choiceArg = new ProcessRewardsV2_ProcessBatch( | ||
| damlBatch, | ||
| new DamlSet(java.util.Collections.emptyMap()), |
There was a problem hiding this comment.
To check the vetting state.
Fixes: #4844
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./lsu_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