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

simulate: resource population #6015

Open
wants to merge 57 commits into
base: master
Choose a base branch
from

Conversation

joe-p
Copy link
Contributor

@joe-p joe-p commented Jun 5, 2024

Summary

When a user calls simulate with UnnamedResources enabled, simulate should suggest to the user how they can populate the resource arrays in their transactions to properly send the transaction group to the network.

Test Plan

  • Test ResourcePopulator works with simple local (not group sharing) resources
  • Test ResourcePopulator with group sharing
  • Test ResourcePopulator resource limit detection with group sharing (ie. it is able to find the correct transaction to put a resource in)
  • Test Simulate with ResourcePopulator functionality
  • Test /simulate endpoint with ResourcePopulator functionality
  • Write smaller tests for better ledger/simulation/resources.go coverage

@joe-p joe-p changed the title Feat/populate_resources resource population Jun 5, 2024
@joe-p joe-p force-pushed the feat/populate_resources branch from 466fd50 to 5ba0a9a Compare June 5, 2024 23:06
@joe-p joe-p changed the title resource population simulate: resource population Jun 5, 2024
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 88.72549% with 46 lines in your changes missing coverage. Please review.

Project coverage is 51.97%. Comparing base (8fce49c) to head (b7bda2e).
Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
daemon/algod/api/server/v2/utils.go 0.00% 29 Missing ⚠️
ledger/simulation/resources.go 96.45% 8 Missing and 5 partials ⚠️
ledger/simulation/simulator.go 66.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6015      +/-   ##
==========================================
+ Coverage   51.79%   51.97%   +0.18%     
==========================================
  Files         644      644              
  Lines       86511    86919     +408     
==========================================
+ Hits        44805    45175     +370     
- Misses      38834    38870      +36     
- Partials     2872     2874       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joe-p joe-p marked this pull request as ready for review January 31, 2025 12:03
@joe-p
Copy link
Contributor Author

joe-p commented Jan 31, 2025

I believe all comments have been addressed at this point and test coverage is near 100%. The only problem is I'm still occasionally getting database table is locked when running tests locally. So far it's only happened with TestPopulatorWithGlobalResources. I tried just running this test and disabling parallel testing but I'm still seeing the same error occasionally. I believe this is just a problem with the test harness so not sure if it should be considered a blocker or not. I'd be interested to know if others can replicate.

@joe-p
Copy link
Contributor Author

joe-p commented Feb 19, 2025

As I was working on SDK support and testing for full coverage of the API I realized I didn't have a test with full coverage of the API here. I found a bug that seems to be related to extra-resource-arrays. I will write a test for proper coverage of the API and then mark as ready for review once ready

Fixed in 791df53. See body for details

This was initially missed because the e2e test did not use the extra
resource arrays and coverage was easy to overlook because we don't
actually get handler coverage info for e2e tests (because they are e2e
and the test itself goes through libgoal)
@joe-p joe-p marked this pull request as ready for review February 20, 2025 13:05
@joe-p
Copy link
Contributor Author

joe-p commented Feb 20, 2025

The failing CI was from the non-deterministic behavior of the population algorithm. Turns out the table is locked message was correlated but not causal.

From the body of fd2c8dc:

The initial reason for desiring this was because of the non-deterministic behavior of maps made testing difficult. When thinking about it more, I realized that having deterministic population will also improve the developer experience since the same txn group will always get back the same populated resources. This change, however, does expose a potential problem inherit to resource population: order matters. As seen in the modified test, the determinstic order results in an extra resource in the extra resource array. In the future steps could be taken to try to improve the efficiency, but unless we go over every permutation of resource ordering there will always be cases where algorithmic population will not result in the most efficient resource packing.

The inital reason for desiring this was because of the non-deterministic
behavior of maps made testing difficult. When thinking about it more, I
realized that having deterministic population will also improve the
developer experience since the same txn group will always get back the
same populated resources. This change, however, does expose a potential
problem inherit to resource population: order matters. As seen in the
modified test, the determinstic order results in an extra resource in
the extra resource array. In the future steps could be taken to try to
improve the efficiency, but unless we go over every permutation of
resource ordering there will always be cases where algorithmic
population will not result in the most efficient resource packing.
@algorandskiy
Copy link
Contributor

Relevant issue #5616

algorandskiy
algorandskiy previously approved these changes Feb 27, 2025
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

LGTM, some minor suggestions/questions.

@algorandskiy
Copy link
Contributor

@joe-p could you fix the reviewdog and respond to the review?

@joe-p
Copy link
Contributor Author

joe-p commented Mar 8, 2025

CI is failing due to an unrelated test: TestP2PEnableGossipService_BothDisable

Re-triggered test run passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants