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

Reduce size and cost of AccessTokenConsumer #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

d1ll0n
Copy link

@d1ll0n d1ll0n commented Feb 27, 2024

Replaces all of the code for verifying access tokens in the consumer contract with a single consumeAccessToken library function which extracts the access token and signature from the call context. Also changes the solc version to 0.8.24 and enables viaIR.

The main improvement here is in getting rid of solc's handling of encoding, which is highly inefficient. It also avoids allocating any memory during this process, which will have significant savings for any inheriting contracts that use a lot of memory, as the current version allocates 742 bytes of memory permanently, making contracts automatically be past the point of linear memory costs.

With these changes, here is the gas and code size diff for the MockConsumer contract - it reduces the size by ~60% and the gas by ~3-4%:
image

Here is the diff if the solc version is kept at 0.8.13 and viaIR is kept disabled - most of the gas savings remain intact but codesize is only reduced ~30%:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant