-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add a test-only mechanism for metering most of the relevant resources per-invocation #1482
Conversation
… per-invocation. This is an opt-in feature that will reset the budget and take a storage snapshot for every 'logical' invocation (such as `call` or a lifecycle operation). Then when the invocation is done we use the snapshot and current budget to produce the estimate for the resources consumed by the invocation (budget-related, IO-related and rent bumps). This also provides a rough estimation for the respective fee breakdown given a fee config.
65881b2
to
36ad558
Compare
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.
Will the idea be in the SDK to call budget.reset()
before each top-level invocation? That sounds like a great idea.
I think we should move to that approach env wide, except for types that are in memory and storage, treat everything else like a reset. One thing we need to start doing that for is logs. Right now you can output diagnostic logs for many invocations, which is quite confusing. In short, yeah, this approach of resetting 👍🏻, and it should just be mandated in the SDK and always happen.
If someone needs to test calls together they can always wrap their calls in a single .as_contract
.
SDK just needs to enable invocation metering, env will take care of the resets.
Yeah, we're getting this automatically by clearing the events. I'm resetting the budget, footprint, and events. I think that should be everything, but we can reset more if necessary.
Good point, this actually hasn't been covered by the metering scope. |
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.
Nice work!
What
This is an opt-in feature that will reset the budget and take a storage snapshot for every 'logical' invocation (such as
call
or a lifecycle operation). Then when the invocation is done we use the snapshot and current budget to produce the estimate for the resources consumed by the invocation (budget-related, IO-related and rent bumps).This also provides a rough estimation for the respective fee breakdown given a fee config.
Why
Make unit tests more useful for rough performance evaluation. This is the initial env-side implementation for stellar/rs-soroban-sdk#1319
Known limitations
Some of the resources are tricky to model. Specifically, this omits:
These shouldn't be too significant though and are likely better addressed via e2e runs (like simulation or some
e2e_invoke
-based mechanism)