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

add consideration of static vs (static + dynamic) cost accounting #28

Closed
emergent-reasons opened this issue Sep 7, 2024 · 3 comments
Closed

Comments

@emergent-reasons
Copy link
Contributor

The combo of static + dynamic cost accounting is powerful, but from an initial perspective, it's not obvious and in fact looks like a rookie mistake of "You're going to have to execute this thing (even partially) to do this. It should be done statically to avoid incurring VM costs."

I think it would be a good addition to explicitly mention that purely static analysis is considered and discarded as an option because it forces either limiting (overly conservative) or dangerous (overly loose) heuristics where both of these are a problem AND the cost of dynamic validation is very low in any case.

If that would be something you consider adding, I'll try to come up with a minimal way to include it.

@A60AB5450353F40E
Copy link
Contributor

Obvious downside of static cost evaluation: you'd have to have a fixed price for opcodes no matter the size of inputs to them.
Then OP_CAT concatenating 1 + 1 byte would cost the same as OP_CAT concatenating 5k and 5k bytes - and you'd be forced to budget it as if it's always doing the most expensive operation, so it would severely limit smaller uses for no reason.

@bitjson
Copy link
Owner

bitjson commented Sep 25, 2024

Thank you @emergent-reasons for opening the issue! Note for future readers, there's more discussion on BCR, and a succinct description is now in rationale: https://github.com/bitjson/bch-vm-limits/blob/master/rationale.md#use-of-explicitly-defined-density-limits

@bitjson bitjson closed this as completed Sep 25, 2024
@emergent-reasons
Copy link
Contributor Author

Appreciate you adding that.

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

No branches or pull requests

3 participants