Skip to content

Precompiling doesn't always reduce costs #380

Open
@Darkneew

Description

@Darkneew

The function compile has been made to reduce the cost of computations on-chain, and thus the cost of computations in convex coins.
For programs using convex API, precompiling the code is therefore something that should always be done.
Which is why it seems essential that the compile function never increase the cost of computations.

However, it can in a lot of cases, and in every "simple" cases. Compiling off-chain then running it on-chain will make the reader read the command again, and read even more than if it wasn't compiled.
As an exemple, running

(+ 1 2)

costs 1210 coins.
However, compiling it gives

(#50/+ 1 2)

(50 being my address), and running it costs 1930 coins.
Running it with an eval costs even more (3950) as the reader and compiler must now understand the eval too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information or discussion is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions