Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache participations for spent outputs #1953

Conversation

Thoralf-M
Copy link
Member

Description of change

Cache participations for spent outputs and don't request outputs duplicated when not necessary

Links to any relevant issues

Fixes #1866

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How the change has been tested

cli wallet, the caching can be seen in the logs from calling participation-overview twice
0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000 was spent, then cached and the second time not requested anymore, returned participation overview is still the same

2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview]
2023-03-14 10:31:55 (UTC) iota_wallet::storage::participation        DEBUG get_cached_participation
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] restored_spent_cached_outputs_len: 2
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] requesting 2 outputs for event 0xfb52886a80b081f3a1d4ea948870d54de406a5084603a159a93510fb9c24be91
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_client_for_event]
2023-03-14 10:31:55 (UTC) iota_wallet::storage::participation        DEBUG get_participation_events
2023-03-14 10:31:55 (UTC) iota_client::node_manager::http_client     DEBUG GET: 0 ms for 200 OK http://localhost:14265/api/participation/v1/outputs/0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000
2023-03-14 10:31:55 (UTC) iota_client::node_manager::http_client     DEBUG GET: 0 ms for 200 OK http://localhost:14265/api/participation/v1/outputs/0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] requesting 2 outputs for event 0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_client_for_event]
2023-03-14 10:31:55 (UTC) iota_wallet::storage::participation        DEBUG get_participation_events
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] skip requesting already known 0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000 for event 0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] skip requesting already known 0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000 for event 0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f
2023-03-14 10:31:55 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] new spent_cached_outputs: 3
2023-03-14 10:31:55 (UTC) iota_wallet::storage::participation        DEBUG set_cached_participation
2023-03-14 10:31:55 (UTC) wallet::command::account                   INFO  Participation overview: AccountParticipationOverview { participations: {ParticipationEventId(0xfb52886a80b081f3a1d4ea948870d54de406a5084603a159a93510fb9c24be91): {OutputId(0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000): TrackedParticipation { block_id: BlockId(0x6f65789c523d662cc07e0d488c9a0c5e4dd7f7d19bb028b2839b4e79518b5821), amount: 1000000, start_milestone_index: 279, end_milestone_index: 428, answers: Some([1]) }, OutputId(0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000): TrackedParticipation { block_id: BlockId(0x2d34ace0bbbdd358cf3828c09bc0cd2e058581aa4ddc8fc70090a9e0f9232fb1), amount: 1000000, start_milestone_index: 428, end_milestone_index: 0, answers: Some([2]) }, OutputId(0xf4a2203393cc900051522d3909ec3257e08b50b9ada5716682697f7a641bac550000): TrackedParticipation { block_id: BlockId(0x75fac9456b4bcb2885b43b32ed4332c633ad33f32a66501265e84c237db8d686), amount: 1000000, start_milestone_index: 201, end_milestone_index: 279, answers: Some([1]) }}, ParticipationEventId(0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f): {OutputId(0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000): TrackedParticipation { block_id: BlockId(0x6f65789c523d662cc07e0d488c9a0c5e4dd7f7d19bb028b2839b4e79518b5821), amount: 1000000, start_milestone_index: 279, end_milestone_index: 428, answers: Some([2]) }, OutputId(0x32f2603504517e5efd03bbabc6349c589948b404db8cf8d7ba1e2ddedf301c9b0000): TrackedParticipation { block_id: BlockId(0xa10535a2573f538b3877a3b811bcd63e4eba544cac99358d5b62ce417aa91d61), amount: 1000000, start_milestone_index: 149, end_milestone_index: 201, answers: Some([1]) }, OutputId(0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000): TrackedParticipation { block_id: BlockId(0x2d34ace0bbbdd358cf3828c09bc0cd2e058581aa4ddc8fc70090a9e0f9232fb1), amount: 1000000, start_milestone_index: 428, end_milestone_index: 0, answers: Some([2]) }, OutputId(0xf4a2203393cc900051522d3909ec3257e08b50b9ada5716682697f7a641bac550000): TrackedParticipation { block_id: BlockId(0x75fac9456b4bcb2885b43b32ed4332c633ad33f32a66501265e84c237db8d686), amount: 1000000, start_milestone_index: 201, end_milestone_index: 279, answers: Some([1]) }}} }


2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview]
2023-03-14 10:32:19 (UTC) iota_wallet::storage::participation        DEBUG get_cached_participation
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] restored_spent_cached_outputs_len: 3
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] requesting 1 outputs for event 0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_client_for_event]
2023-03-14 10:32:19 (UTC) iota_wallet::storage::participation        DEBUG get_participation_events
2023-03-14 10:32:19 (UTC) iota_client::node_manager::http_client     DEBUG GET: 0 ms for 200 OK http://localhost:14265/api/participation/v1/outputs/0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] requesting 1 outputs for event 0xfb52886a80b081f3a1d4ea948870d54de406a5084603a159a93510fb9c24be91
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_client_for_event]
2023-03-14 10:32:19 (UTC) iota_wallet::storage::participation        DEBUG get_participation_events
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] skip requesting already known 0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000 for event 0xfb52886a80b081f3a1d4ea948870d54de406a5084603a159a93510fb9c24be91
2023-03-14 10:32:19 (UTC) iota_wallet::account::operations::participation DEBUG [get_participation_overview] new spent_cached_outputs: 3
2023-03-14 10:32:19 (UTC) wallet::command::account                   INFO  Participation overview: AccountParticipationOverview { participations: {ParticipationEventId(0xfb52886a80b081f3a1d4ea948870d54de406a5084603a159a93510fb9c24be91): {OutputId(0xf4a2203393cc900051522d3909ec3257e08b50b9ada5716682697f7a641bac550000): TrackedParticipation { block_id: BlockId(0x75fac9456b4bcb2885b43b32ed4332c633ad33f32a66501265e84c237db8d686), amount: 1000000, start_milestone_index: 201, end_milestone_index: 279, answers: Some([1]) }, OutputId(0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000): TrackedParticipation { block_id: BlockId(0x6f65789c523d662cc07e0d488c9a0c5e4dd7f7d19bb028b2839b4e79518b5821), amount: 1000000, start_milestone_index: 279, end_milestone_index: 428, answers: Some([1]) }, OutputId(0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000): TrackedParticipation { block_id: BlockId(0x2d34ace0bbbdd358cf3828c09bc0cd2e058581aa4ddc8fc70090a9e0f9232fb1), amount: 1000000, start_milestone_index: 428, end_milestone_index: 0, answers: Some([2]) }}, ParticipationEventId(0xadcad4c0703e0e1099eda402c49584bd390238518c31c89f3dea9f8aca850b1f): {OutputId(0x32f2603504517e5efd03bbabc6349c589948b404db8cf8d7ba1e2ddedf301c9b0000): TrackedParticipation { block_id: BlockId(0xa10535a2573f538b3877a3b811bcd63e4eba544cac99358d5b62ce417aa91d61), amount: 1000000, start_milestone_index: 149, end_milestone_index: 201, answers: Some([1]) }, OutputId(0x14afa29c052f440a2b6366d0235101299c9a750d2ca73ae493a05baa98700f310000): TrackedParticipation { block_id: BlockId(0x2d34ace0bbbdd358cf3828c09bc0cd2e058581aa4ddc8fc70090a9e0f9232fb1), amount: 1000000, start_milestone_index: 428, end_milestone_index: 0, answers: Some([2]) }, OutputId(0x52d6cb454169a206be0acf209ad148ae35a5341b500d584567775d4f61dd98a40000): TrackedParticipation { block_id: BlockId(0x6f65789c523d662cc07e0d488c9a0c5e4dd7f7d19bb028b2839b4e79518b5821), amount: 1000000, start_milestone_index: 279, end_milestone_index: 428, answers: Some([2]) }, OutputId(0xf4a2203393cc900051522d3909ec3257e08b50b9ada5716682697f7a641bac550000): TrackedParticipation { block_id: BlockId(0x75fac9456b4bcb2885b43b32ed4332c633ad33f32a66501265e84c237db8d686), amount: 1000000, start_milestone_index: 201, end_milestone_index: 279, answers: Some([1]) }}} }

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

kwek20
kwek20 previously approved these changes Mar 14, 2023
@thibault-martinez thibault-martinez merged commit 5cf2702 into iotaledger:develop Mar 15, 2023
@Thoralf-M Thoralf-M deleted the participation-spent-outputs-cache branch March 15, 2023 19:22
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.

Cache participation data for spent outputs
3 participants