-
-
Notifications
You must be signed in to change notification settings - Fork 131
Description
What is your idea? Provide a use case.
Script costs execution are an important aspect of writing contracts on cardano.
In every validator script I've been working on, one of the phases was to optimise costs.
Currently tests already report on their costs, but, afaik, there is no way to assert against them.
Once optimised for resources consumption, it should be possible to ensure that further code modifications, won't unexpectedly blow up resources used during execution. This is even more relevant when migrating from a version to another of aiken. Even for aiken development itsels.
Something like rust attributes could work very nicely as adding assertion within the test could alter cpu/memory used.
Example:
#resources[eq{mem: 493718, cpu: 145378658}]
test marshal_for_connection_end_cost() {
let bytes =
marshal_for_connection_end(
ConnectionEnd(
#"0001",
[Version(#"0101", [#"0201", #"0202"])],
UNINITIALIZED,
new_counterparty(#"0301", #"0401", MerklePrefix(#"0501")),
10,
),
)
bytes == #"0a020001120c0a0201011202020112020202220e0a020301120204011a040a020501280a"
}
In the example the attribute requires resources to be equal to some specific memory and cpu. It could be nice to have to have option to chose between exact values or less than values.
Why is it a good idea?
Coz it allows devs to set strong budget constraints for execution costs of specific part of the code, and prevent changes to the code to blow up costs unexpectedly.
What is the current alternative and why is it not good enough?
Check costs in test reports breakdown and compare with previous ones.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status