Skip to content

Conversation

murisi
Copy link
Collaborator

@murisi murisi commented Jul 25, 2025

Describe your changes

Querying the conversion state becomes more difficult as nodes progress to higher and higher epochs. For instance, on a mainnet clone running on accelerated epochs, client queries for conversions always timeout (even after modifying timeout_broadcast_tx_commit) when the node goes beyond a certain MASP epoch. This happens because the conversion state grows linearly with the MASP epoch counter. This PR attempts to address this problem by making the conversions RPC endpoint require that clients specify the MASP epoch they want conversions from. This implies two things: first the size of the response from the conversions RPC endpoint should now be constant (equal to the number of tokens in the shielded rewards program), and second a client requiring all conversions now has to do a separate query for each MASP epoch.

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes
  • If this PR requires changes to the docs or specs, a corresponding PR is opened in the namada-docs repo
    • Relevant PR if applies:
  • If this PR affects services such as namada-indexer or namada-masp-indexer, a corresponding PR is opened in that repo
    • Relevant PR if applies:

@github-actions github-actions bot added the breaking:api public API breaking change label Jul 25, 2025
@murisi murisi force-pushed the murisi/filter-conversions-query branch from add089e to e377e7f Compare July 25, 2025 11:54
@murisi murisi added do-not-merge Do not merge for now MASP testing and removed testing labels Jul 25, 2025
@brentstone
Copy link
Collaborator

@murisi - it was mentioned to me from @Fraccaman that we desire this work. Is this mergeable (I see the label that might suggest otherwise). Does it need review?

@murisi
Copy link
Collaborator Author

murisi commented Sep 16, 2025

@murisi - it was mentioned to me from @Fraccaman that we desire this work. Is this mergeable (I see the label that might suggest otherwise). Does it need review?

@brentstone It's been a while since I've looked at this. I believe this PR did help when the mainnet clone's epochs got very high. I probably put the do-not-merge tag because these changes are not purely client-side; they change an RPC function. So there could be client-node version/compatibility issues arising. Yes, it needs a review and some testing to ensure that the PR is compatible with the latest releases of Namada, and that it has no adverse effects (due to having lots of smaller queries). The PR might also need to be touched up with a changelog entry.

@brentstone
Copy link
Collaborator

@batconjurer would you mind peeking at this?

@batconjurer batconjurer force-pushed the murisi/filter-conversions-query branch from e377e7f to b46504b Compare September 17, 2025 08:56
@batconjurer batconjurer self-requested a review September 17, 2025 09:02
@batconjurer
Copy link
Collaborator

This looks good to me. In the future, it would also be possible to speed up the server side processing by keying the conversions by epoch since right now the server still needs to do a linear scan over the whole conversion state. That is a much more invasive change though.

Copy link
Contributor

mergify bot commented Sep 17, 2025

🧪 CI Insights

Here's what we observed from your CI run for 882fbbd.

🟢 All jobs passed!

But CI Insights is watching 👀

@brentstone brentstone added this to the Next Release milestone Sep 18, 2025
Copy link
Collaborator

@sug0 sug0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can optimize conversion queries. right now, we need to wait for the full round-trip time of the conversions at a specific masp epoch. say we had 100 masp epochs to go through, and the RTT was 100 ms. we would need to wait 10 seconds for each query to be resolved. with 100 concurrent requests, ideally we would complete all queries in 100 ms. of course in practice they'll be slower, but there should be a major speed-up from launching these queries concurrently.

Comment on lines 2153 to 2159
for epoch in MaspEpoch::iter_bounds_inclusive(from, to) {
conversions.append(
&mut rpc::query_conversions(context.client(), &epoch)
.await
.expect("Conversions should be defined"),
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no reason why we cannot run these queries concurrently (e.g. with this). the Stream can be collected into a BTreeMap (see StreamExt::collect)

Copy link
Collaborator

@grarco grarco Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've attempted this in 0d1074c even though I had to fold the maps instead of collect because of the limitations of the Extend trait on maps. Should we also add an extra argument to the query command to allow the user to specify the from epoch to avoid querying from 0 all the times?

@grarco grarco force-pushed the murisi/filter-conversions-query branch from 46ea724 to 0d1074c Compare October 7, 2025 16:15
@grarco
Copy link
Collaborator

grarco commented Oct 7, 2025

Force-pushed to rebase on main

@grarco grarco force-pushed the murisi/filter-conversions-query branch from 0d1074c to 70bc3df Compare October 7, 2025 16:53
@sug0
Copy link
Collaborator

sug0 commented Oct 8, 2025

lgtm, just a small question

@sug0 sug0 self-requested a review October 8, 2025 08:46
@tzemanovic tzemanovic removed the do-not-merge Do not merge for now label Oct 8, 2025
@tzemanovic tzemanovic added merge Ready to merge - mergifyio bot will add the PR to merge queue when all checks pass backport-201.0 Backport to app 201.0 maintenance branch labels Oct 8, 2025
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mergify mergify bot added the queued label Oct 8, 2025
mergify bot added a commit that referenced this pull request Oct 8, 2025
@mergify mergify bot merged commit 1ce25a0 into main Oct 8, 2025
27 checks passed
@mergify mergify bot deleted the murisi/filter-conversions-query branch October 8, 2025 10:35
@mergify mergify bot removed the queued label Oct 8, 2025
mergify bot added a commit that referenced this pull request Oct 8, 2025
The MASP conversions query now requires a MASP epoch to be specified. (backport #4776)
@tzemanovic tzemanovic added the backport-libs-0.251 Backport libraries to 0.251 maintenance branch label Oct 9, 2025
@tzemanovic tzemanovic restored the murisi/filter-conversions-query branch October 9, 2025 09:07
mergify bot added a commit that referenced this pull request Oct 9, 2025
…pr-4776

The MASP conversions query now requires a MASP epoch to be specified. (backport #4776)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-201.0 Backport to app 201.0 maintenance branch backport-libs-0.251 Backport libraries to 0.251 maintenance branch breaking:api public API breaking change MASP merge Ready to merge - mergifyio bot will add the PR to merge queue when all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants