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

Compress public functions in json artifact, but still deploy uncompressed #11150

Open
fcarreiro opened this issue Jan 10, 2025 · 2 comments · May be fixed by #11193
Open

Compress public functions in json artifact, but still deploy uncompressed #11150

fcarreiro opened this issue Jan 10, 2025 · 2 comments · May be fixed by #11193
Assignees
Labels
C-avm Component: AVM related tickets (aka public VM) T-optimisation Type: Optimisation. Making something faster / cheaper / smaller

Comments

@fcarreiro
Copy link
Contributor

fcarreiro commented Jan 10, 2025

See https://aztecprotocol.slack.com/archives/C0183F0V42V/p1736508632678059?thread_ts=1735850380.203639&cid=C0183F0V42V .

Compressing is easy, uncompressing on every usage of this data is more complicated. In particular, don't forget to update the public bytecode diff util.

Reference for self: #8623

@fcarreiro fcarreiro added C-avm Component: AVM related tickets (aka public VM) T-optimisation Type: Optimisation. Making something faster / cheaper / smaller labels Jan 10, 2025
@fcarreiro fcarreiro self-assigned this Jan 10, 2025
@fcarreiro
Copy link
Contributor Author

Not as easy as I thought. There's no single place that loads an artifact as a TS structure and there are several other complications. How I think things work

  • The artifact is loaded via a schema which does decode the base64 for the functions (both noir and public, there's no distinction)
  • The functions' bytecode is kept as is and eventually passed to noir or the avm. Therefore, Noir's bytecode stays compressed, noir/bb decompress it. For the AVM, we don't want to add decompression logic to it, so that will not work.
  • Even if it did, there's another complication, there are free functions to compute things like a contract class id, etc, that will use whatever bytecode is in the class. If we kept public bytecode compressed, the hash will be wrong (you actually want the hash of the uncompressed bytecode since that's what gets deployed)

@spalladino, do you think it would be possible to add decompression via the schema, only for public functions? Would this make sense to achieve what I want? Any pointers?

@spalladino
Copy link
Collaborator

Every JSON artifact goes through the loadContractArtifact function before being used in ts code. In there, you got a generateFunctionArtifact that is used to tweak each function in the artifact. You could check there if the fn is public, and deal with the bytecode as you see fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-avm Component: AVM related tickets (aka public VM) T-optimisation Type: Optimisation. Making something faster / cheaper / smaller
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants