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

How is costing determined? #4375

Open
kozross opened this issue Feb 3, 2022 · 6 comments
Open

How is costing determined? #4375

kozross opened this issue Feb 3, 2022 · 6 comments
Labels
enhancement Low priority Doesn't require immediate attention status: triaged

Comments

@kozross
Copy link
Contributor

kozross commented Feb 3, 2022

Describe the feature you'd like

This relates to #4233, specifically this comment here. Clearly the mempty costing is a default, and probably not accurate for the SECP256k1 builtin required by the issue. However, I'm not sure how costing is determined, or what needs to be done to determine it. Is this documented anywhere? If yes, it'd be good to have it more visible; if not, what is the process of costing?

Describe alternatives you've considered

Currently, you can define all costs as mempty, but this is clearly not accurate, as operations can have very different costs.

@michaelpj
Copy link
Contributor

I think for the time being we're assuming that the Plutus team will handle determining costing functions. In the future we'd like to encourage contributors to do it, but it's a bit tricky. If you're willing and have time to contribute to this you could probably help by extending the benchmarks here to include the new builtin.

Ultimately it's empirical: make some benchmarks, run the function in question with arguments of varying sizes and see what costing function fits. You can omit parts of the domain that cause errors (relevant for signature verification as that means we only care about appropriately-shaped inputs).

cc @kwxm

@kwxm
Copy link
Contributor

kwxm commented Feb 4, 2022

When the SECP256k1 PR is merged I can work out what the cost model should be. A problem is that to come up with coefficients for costing functions we have to run some benchmarks on a reference machine that's reserved for that purpose, so it's not easy for external contributors to generate the required data. Costing functions also have to be carefully audited before deployment to make sure that the claimed cost of a builtin is accurate in order to avoid scripts which run for much longer than the cost model would have you believe.

We will produce a document about this in due course, but other things are currently taking priority.

@effectfully
Copy link
Contributor

We will produce a document about this in due course, but other things are currently taking priority.

@kwxm is there such a document now? Is it accurate regarding what needs to be done in order to determine costing? Is it complete?

@kwxm
Copy link
Contributor

kwxm commented Jan 31, 2023

We will produce a document about this in due course, but other things are currently taking priority.

@kwxm is there such a document now? Is it accurate regarding what needs to be done in order to determine costing? Is it complete?

Unfortunately not. We have an internal document that's rather outdated and needs to be updated and tidied up for general consumption. That's another thing that's in the backlog. There's a placeholder in the Plutus Core specification, and it might be worth putting a high-level description of the costing process in there as a stopgap so that people can get some idea of how things work.

@effectfully
Copy link
Contributor

OK, it sounds like this is not being considered high priority at the moment. I'm therefore adding the respective label.

@effectfully effectfully added Low priority Doesn't require immediate attention status: triaged and removed status: needs triage GH issues that requires triage labels Feb 1, 2023
@effectfully
Copy link
Contributor

@kwxm do we now have more docs on costing? Maybe even enough to close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Low priority Doesn't require immediate attention status: triaged
Projects
None yet
Development

No branches or pull requests

4 participants