Skip to content

Public Sequencer: Add SV End Point to List All ValidatorPermissions where the sponser is the calling SV. #5702

Merged
pasindutennage-da merged 11 commits into
pasindutennage-da/public-sequencer-feature-branchfrom
pasindutennage-da/fix/5665
Jun 4, 2026
Merged

Public Sequencer: Add SV End Point to List All ValidatorPermissions where the sponser is the calling SV. #5702
pasindutennage-da merged 11 commits into
pasindutennage-da/public-sequencer-feature-branchfrom
pasindutennage-da/fix/5665

Conversation

@pasindutennage-da
Copy link
Copy Markdown
Contributor

Fix #5665

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
@pasindutennage-da pasindutennage-da marked this pull request as draft May 27, 2026 15:33
Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
@pasindutennage-da pasindutennage-da marked this pull request as ready for review May 27, 2026 21:58
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
@@ -0,0 +1,5 @@
-- Add index for sv_party to the dso_acs_store.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Prior to index

EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE template_id_qualified_name LIKE '%ValidatorPermission%' 
  AND sv_party = 'PAR::sv1::12345';
                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on dso_acs_store  (cost=0.00..10.90 rows=1 width=1225) (actual time=0.020..0.020 rows=0 loops=1)
   Filter: ((template_id_qualified_name ~~ '%ValidatorPermission%'::text) AND (sv_party = 'PAR::sv1::12345'::text))
   Rows Removed by Filter: 14
 Planning Time: 1.217 ms
 Execution Time: 0.030 ms
(5 rows)

After Index

splice_apps=# EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE template_id_qualified_name LIKE '%ValidatorPermission%' 
  AND sv_party = 'PAR::sv1::12345';
                                                                  QUERY PLAN                                                                  
----------------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.14..12.54 rows=1 width=2756) (actual time=0.006..0.007 rows=0 loops=1)
   Index Cond: (sv_party = 'PAR::sv1::12345'::text)
   Filter: (template_id_qualified_name ~~ '%ValidatorPermission%'::text)
 Planning Time: 1.628 ms
 Execution Time: 0.038 ms
(5 rows)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's not the query we're actually running, that one also includes store id, migration and package name and does not use the LIKE filter. Query plans are quite subtle. You really need to make sure you test the one that you use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@moritzkiefer-da

EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE store_id = 2 
  AND migration_id = 0 
  AND package_name = 'splice-amulet' 
  AND template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission' 
  AND sv_party = 'digital-asset-2-f1623917::122s';
Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.14..8.16 rows=1 width=2743) (actual time=0.075..0.096 rows=3 loops=1)
   Index Cond: ((store_id = 2) AND (migration_id = 0) AND (package_name = 'splice-amulet'::text) AND (template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission'::text) AND (sv_party = 'digital-asset-2-f1623917::12200a6dde6a5b4ab4a2f6e8c1e98b736c404f9775b810fed9f620a6e07134d6c11a'::text))
 Planning Time: 2.629 ms
 Execution Time: 0.125 ms
(4 rows)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's the query without pagination, what if you paginate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@moritzkiefer-da

No curser

EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE store_id = 2 
  AND migration_id = 0 
  AND package_name = 'splice-amulet' 
  AND template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission' 
  AND sv_party = 'digital-asset-2-f1623917::122s'
ORDER BY event_number DESC 
LIMIT 101;
Limit  (cost=6.99..7.00 rows=1 width=2755) (actual time=0.039..0.039 rows=0 loops=1)
   ->  Sort  (cost=6.99..7.00 rows=1 width=2755) (actual time=0.038..0.039 rows=0 loops=1)
         Sort Key: event_number DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.14..6.98 rows=1 width=2755) (actual time=0.020..0.020 rows=0 loops=1)
               Index Cond: ((store_id = 2) AND (migration_id = 0) AND (package_name = 'splice-amulet'::text) AND (template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission'::text) AND (sv_party = 'digital-asset-2-f1623917::122s'::text))

With cursor

EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE store_id = 2 
  AND migration_id = 0 
  AND package_name = 'splice-amulet' 
  AND template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission' 
  AND sv_party = 'digital-asset-2-f1623917::122s'
  AND event_number < 850
ORDER BY event_number DESC 
LIMIT 101;
Limit  (cost=7.00..7.00 rows=1 width=2755) (actual time=0.028..0.028 rows=0 loops=1)
   ->  Sort  (cost=7.00..7.00 rows=1 width=2755) (actual time=0.027..0.027 rows=0 loops=1)
         Sort Key: event_number DESC
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.14..6.99 rows=1 width=2755) (actual time=0.012..0.012 rows=0 loops=1)
               Index Cond: ((store_id = 2) AND (migration_id = 0) AND (package_name = 'splice-amulet'::text) AND (template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission'::text) AND (sv_party = 'digital-asset-2-f1623917::122s'::text))
               Filter: (event_number < 850)

Conclusion

Both approaches use indexed scanning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both approaches use indexed scanning.

Sadly SQL query plans are more complex than that. They do use an index. But if you look at it more closely the index cond does not include the event_number and this is just a filter. This essentially means you still have to do a seq scan through everything matching your index cond.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@moritzkiefer-da Thank you. Apologies for missing that. I updated the index and please see the new plans below, which use only index.

No cursor

EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE store_id = 2 
  AND migration_id = 0 
  AND package_name = 'splice-amulet' 
  AND template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission' 
  AND sv_party = 'digital-asset-2-f1623917::122s'
ORDER BY event_number DESC 
LIMIT 101;

Limit  (cost=0.27..6.68 rows=1 width=2533) (actual time=0.038..0.038 rows=0 loops=1)
   ->  Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.27..6.68 rows=1 width=2533) (actual time=0.037..0.037 rows=0 loops=1)
         Index Cond: ((store_id = 2) AND (migration_id = 0) AND (package_name = 'splice-amulet'::text) AND (template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission'::text) AND (sv_party = 'digital-asset-2-f1623917::122s'::text))
 Planning Time: 1.609 ms
 Execution Time: 0.062 ms
(5 rows)

With cursor


EXPLAIN ANALYZE 
SELECT * FROM dso_acs_store 
WHERE store_id = 2 
  AND migration_id = 0 
  AND package_name = 'splice-amulet' 
  AND template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission' 
  AND sv_party = 'digital-asset-2-f1623917::122s'
  AND event_number < 850
ORDER BY event_number DESC 
LIMIT 101;

Limit  (cost=0.27..6.68 rows=1 width=2533) (actual time=0.010..0.011 rows=0 loops=1)
   ->  Index Scan using dso_acs_store_sv_party_idx on dso_acs_store  (cost=0.27..6.68 rows=1 width=2533) (actual time=0.010..0.010 rows=0 loops=1)
         Index Cond: ((store_id = 2) AND (migration_id = 0) AND (package_name = 'splice-amulet'::text) AND (template_id_qualified_name = 'Splice.ValidatorPermission:ValidatorPermission'::text) AND (sv_party = 'digital-asset-2-f1623917::122s'::text) AND (event_number < 850))
 Planning Time: 0.248 ms
 Execution Time: 0.023 ms
(5 rows)

@@ -0,0 +1,5 @@
-- Add index for sv_party to the dso_acs_store.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's not the query we're actually running, that one also includes store id, migration and package name and does not use the LIKE filter. Query plans are quite subtle. You really need to make sure you test the one that you use.

Comment thread apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/SvApp.scala Outdated
Comment thread apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/SvApp.scala Outdated
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
@pasindutennage-da pasindutennage-da changed the title Public Sequencer: Add SV End Point to List All ParticipantSynchronizerPermissions where the sponser is the calling SV. Public Sequencer: Add SV End Point to List All ValidatorPermissions where the sponser is the calling SV. Jun 3, 2026
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
Copy link
Copy Markdown
Contributor

@moritzkiefer-da moritzkiefer-da left a comment

Choose a reason for hiding this comment

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

thanks

@pasindutennage-da pasindutennage-da merged commit 53886e5 into pasindutennage-da/public-sequencer-feature-branch Jun 4, 2026
65 of 67 checks passed
@pasindutennage-da pasindutennage-da deleted the pasindutennage-da/fix/5665 branch June 4, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants