-
Notifications
You must be signed in to change notification settings - Fork 493
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
base: master
Are you sure you want to change the base?
Conversation
466fd50
to
5ba0a9a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6015 +/- ##
==========================================
+ Coverage 51.79% 51.97% +0.17%
==========================================
Files 644 644
Lines 86511 86922 +411
==========================================
+ Hits 44805 45174 +369
- Misses 38834 38873 +39
- Partials 2872 2875 +3 ☔ View full report in Codecov by Sentry. |
exmpty box ref is expected because the box size is 1025
After having this on the backburner for awhile I've come back to working on this and discovered why I was slow to make progress once I started to implement the endpoint. I was making two mistakes
Now with 41d63dd all tests are passing, although I am experiencing an intermittent issue with database tables being locked when testing, which is seemingly causing a tracked app to be missing
Here is a gist showing the full output with 2/10 runs failing because of the above: https://gist.github.com/joe-p/860cf28908a99db2f58c5010cb378894 I have not yet tried to reproduce on the e2e tests, but I was running them extensively last week and never saw this issue. Once this issue is resolved the only remaining work is to make some smaller unit tests to test the "bad" cases and make sure things fail gracefully. |
as per the comment, these checks should never be needed due to the logic in eval context, but felt safer to add just in case
previously non appls weren't properly added to the populator, meaning their fields were not accounted for when checking for availability. This is actually probably fine since these sorts of duplicates should be prevented by the logic in evalcontext, but as mentioned in previous commits it feels safer to check here just in case
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 |
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)
The failing CI was from the non-deterministic behavior of the population algorithm. Turns out the 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. |
5657d49
to
06549f5
Compare
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.
a49a709
to
fd2c8dc
Compare
Relevant issue #5616 |
There was a problem hiding this 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.
@@ -4302,6 +4339,13 @@ | |||
}, | |||
"unnamed-resources-accessed": { | |||
"$ref": "#/definitions/SimulateUnnamedResourcesAccessed" | |||
}, | |||
"extra-resource-arrays": { | |||
"description": "Present if populate-resource-arrays is true in the request and additional tranactions are needed to name all the accessed resources.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Present if populate-resource-arrays is true in the request and additional tranactions are needed to name all the accessed resources.", | |
"description": "Present if populate-resource-arrays is true in the request and additional transactions are needed to name all the accessed resources.", |
func convertPopulatedResourceArrays(populatedResources simulation.PopulatedResourceArrays) *model.ResourceArrays { | ||
// Convert the resources to the model structs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func convertPopulatedResourceArrays(populatedResources simulation.PopulatedResourceArrays) *model.ResourceArrays { | |
// Convert the resources to the model structs | |
// convertPopulatedResourceArrays converts the resources to the model structs | |
func convertPopulatedResourceArrays(populatedResources simulation.PopulatedResourceArrays) *model.ResourceArrays { |
maxAssets int | ||
} | ||
|
||
func (r *txnResources) getTotalRefs() int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider: add a test with reflection/ast checking all arrays from txnResources
are listed in getTotalRefs
summation. Or a random test with reflection populating all arrays and checking getTotalRefs
resultant value - that one might be shorter/easier.
if i >= p.groupSize && len(pop.Accounts)+len(pop.Assets)+len(pop.Apps)+len(pop.Boxes) == 0 { | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you explain this condition? It appears checks existence of extra resources?
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
/simulate
endpoint with ResourcePopulator functionalityledger/simulation/resources.go
coverage