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

VIP: @delegate decorator #4207

Open
charles-cooper opened this issue Aug 9, 2024 · 0 comments
Open

VIP: @delegate decorator #4207

charles-cooper opened this issue Aug 9, 2024 · 0 comments

Comments

@charles-cooper
Copy link
Member

Simple Summary

add a @delegate decorator which automatically moves code into external contracts

Motivation

because of the EIP-170 codesize limit, developers often end up splitting logical contracts into multiple physical contracts, delegatecalling into them as necessary. we could abstract this away by providing a @delegate decorator, which specifies for the given function to be inserted into an external contract, and then delegatecalling into the external contract.

Specification

add a @delegate decorator, which is only valid on @external functions. during contract initialization, the auxiliary contract is also created and saved in the main contract's bytecode. in the selector table, if the function is called, the calldata is forwarded to the auxiliary contract using delegatecall.

depending on how many delegate'd functions there are, multiple external contracts can be created, thus not requiring any given logical contract to be required to be split over multiple files.

Copyright

Copyright and related rights waived via CC0

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

No branches or pull requests

2 participants
@charles-cooper and others