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

Expose invocation metering in the SDK. #1411

Merged
merged 15 commits into from
Dec 18, 2024
Merged

Conversation

dmkozh
Copy link
Contributor

@dmkozh dmkozh commented Dec 12, 2024

What

Expose invocation metering in the SDK.

Why

Improving testing UX.

#1319

Known limitations

N/A

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

💯 This is so needed and awesome to see getting added to the SDK.

I have some thoughts just about the API and how we integrate it. Lmk what you think, and we can DM / chat too to do a little more realtime.

soroban-sdk/src/env.rs Outdated Show resolved Hide resolved
soroban-sdk/src/env.rs Outdated Show resolved Hide resolved
@dmkozh dmkozh force-pushed the resource_metering branch 4 times, most recently from c249cb6 to 4939279 Compare December 13, 2024 18:38
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻 Love the level of docs we're adding around these functions.

soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
soroban-sdk/src/lib.rs Outdated Show resolved Hide resolved
soroban-sdk/test_wasms/README.md Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

See the suggestion inline about how to deal with set_config.

soroban-sdk/src/lib.rs Outdated Show resolved Hide resolved
soroban-sdk/src/cost_estimate.rs Outdated Show resolved Hide resolved
@dmkozh
Copy link
Contributor Author

dmkozh commented Dec 17, 2024

If set_config is called with turning the value off, when the value is already turned on (should be an easy comparison), panic with an informative message saying that once it is enabled it cannot be disabled.

That makes sense and I've tried to sketch this. But this doesn't pass the semver check, as we're adding a new pub field to a struct, so initialization will be broken. So I'm even more in favor of enabling this by default.

@leighmcculloch
Copy link
Member

leighmcculloch commented Dec 17, 2024

this doesn't pass the semver check, as we're adding a new pub field to a struct

Darn, I forgot about this when I created this struct. In v23 we should change the struct into private fields with functions to modify the state. I created an issue to do that here:

So I'm even more in favor of enabling this by default.

👍🏻. We can plan to retroactively introduce a EnvTestConfig flag in v23 too if needed. If folks need to turn it off before then, we can introduce an env var too. I had considered adding an env var for the other env test config item too.

@dmkozh
Copy link
Contributor Author

dmkozh commented Dec 17, 2024

Based on the previous discussion I've enabled this by default, PTAL.

One caveat that I forgot about is that besides budget we also reset all the events between the calls. This makes sense in general and may actually highlight issues people might have had (if an event was expected to happen after a wrong contract call).

@leighmcculloch
Copy link
Member

I think it's reasonable to treat that like a bug fix. The way it works today is too unspecific as to when events occur.

@dmkozh dmkozh enabled auto-merge December 18, 2024 00:00
@dmkozh dmkozh added this pull request to the merge queue Dec 18, 2024
Merged via the queue into stellar:main with commit e03fca0 Dec 18, 2024
17 checks passed
@dmkozh dmkozh deleted the resource_metering branch December 18, 2024 01:00
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.

3 participants