-
Notifications
You must be signed in to change notification settings - Fork 307
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
feat: drop unused public functions from contract artifact #11101
Conversation
**however, we do test some functions via public_dispatch so this is negotiable. |
Perhaps we can move this to whichever service is storing all of the contract artifacts and serving them to users when requested? I'm not sure if this is done "intelligently" so that only the relevant functions are transmitted or whether users get the full json object thrown at them. I'm not sure who's responsible for building that service though.
All the relevant debug information should be in the debug info attached to |
What's the problem that you are trying to solve? :) if it's raw artifact size, this PR makes sense. I didn't understand very well what you mention about transferring functions, that seems to point to some other serving problem? Let me briefly discuss with @dbanks12 about these changes. I see two options forward |
If having access to the underlying functions are useful for the AVM team then I'm all in favour of keeping them. The existence of these functions in the artifact after transpilation isn't a problem for me. My concern is whether or not the aztec nodes filter out these functions when it comes time for a user to download it. Bytecode sizes of contracts are consistently raised as a problem and while I'm not up to date on how contract artifacts are ingested by the aztec node and made available for download, I'm just wanting to check that we're not asking users to download a number of functions which are irrelevant. If aztec nodes strip out these functions so they don't store/serve them, then this PR can be closed. |
IDK what Zac means in that thread by bandwidth/downloading contracts. AFAIK the only thing that will be deployed is |
Yes, that's the expected flow. They need to at least download the ABI and bytcode for the private functions they're interacting with. We expect that dapps will bundle these artifacts, so the app frontend would provide these artifacts to the user's connected PXE. Alternatively, we can have some kind of public off-chain repository that stores source and artifact given an address, but that should not be a requirement. |
Ok so IIUC the most likely scenario is that the whole artifacts will be served somehow. There's another option that I was thinking: add an option to the transpiler Alternatively, make this a default and have WDYT? |
The only risk I see with the above is that (1) we might forget and regard the artifact we see as bigger than it actually is, (2) if WE(/automation) deploy something, we should remember to transpile with |
@TomAFrench @nventuro Are we sure we don't expect any testing problems if we strip these functions? For example a #test written in the contract, or running a TXE test, or running an AztecJS test. I'd expect at least the latter to fail if the functions are not there and only "public_dispatch" is there? |
I don't think we do any special handling of publci fns, we interact with them via the simulator, and we try to keep our flows as similar as the actual thing whenever possible. As far as we know David was the last person to touch that, so if things are fine on his end then we should be good to go. |
Ok but how does |
|
Hmm ok but can you remind me then how the interaction w/the simulator works? Because the simulator can only work with AVM bytecode, and |
@fcarreiro This is the main reason why At this point, TXE behaves much like an e2e does, just much, much faster |
Ok I see, it eventually calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think everything would work ok if
- The default is to strip
- Add a --no-strip-functions to avoid it
- Modify the repo's bootstrap or whatever part that transpiles to add --no-strip-functions when transpiling avm_test_contract and avm_initializer_test_contract
I just saw @Thunkar 's app where the Token artifact is selected and a list of private AND public functions appear, which you can call. How is this supposed to work if only |
We'd need to keep the ABI (but remove the bytecode) for all functions but |
Yeah my point all along, that's not what this PR is doing. Then we'd have to keep the function but remove (presumably) bytecode, debug symbols, what else? Partial hydration is error prone. For example, if #11193 went in, then partial artifacts would start failing on load, because the very reasonable assumption of a non-empty (compressed in that case) bytecode would be broken. The same might happen with debug symbols since they are decompressed as well (but maybe just on access). |
Maybe @TomAFrench @nventuro @spalladino @Thunkar we should have a more general discussion about this during the offsite. Keeping the functions that are not deployed for the sake of their ABI (with or without bytecode etc) might be unavoidable but leaks some knowledge to the user of the artifact: e.g., you shouldn't use the bytecode, nor the debug symbols, and you can call them but always using the aztec-nr convention [via public_dispatch] etc). |
Sounds good. Do you want to add an item to the spreadsheet? |
I'm not sure if this is done later in the pipeline but there's no reason for aztec to track any functions other than
public_dispatch
so we can drop these to reduce the size of the artifact.