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

[WIP] Proxy Direct #111

Closed
wants to merge 1 commit into from
Closed

[WIP] Proxy Direct #111

wants to merge 1 commit into from

Conversation

hayesgm
Copy link
Contributor

@hayesgm hayesgm commented Dec 2, 2023

This patch is an attempt at making the proxy even more slimmed down (by ignoring the niceties of the Solidity delegatecall contract) but otherwise keeping things in Solidity. We also are working on compiler settings to remove metadata, etc, to make the contract even smaller. Note: for observation, I've also added the optimized yul output.

Note: forge is quite a bit broken when you want to deviate from the norm for different Solidity files, so to build this, I suggest solc --optimize --optimize-runs 1 --no-cbor-metadata --bin-runtime src-proxy/ProxyDirect.sol

This patch is an attempt at making the proxy even more slimmed down (by ignoring the niceties of the Solidity `delegatecall` contract) but otherwise keeping things in Solidity. We also are working on compiler settings to remove metadata, etc, to make the contract even smaller. Note: for observation, I've also added the optimized yul output.
@kevincheng96
Copy link
Collaborator

LGTM on the Solidity part 👍

Comment on lines +36 to +40
if succ {
return(0, retSz)
}

revert(0, retSz)
Copy link
Contributor

@cwang25 cwang25 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the return data is 0?
Seems OZ's approach check the return data.
like: https://github.com/compound-finance/quark/pull/108/files

 switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two code blocks are equivalent right? If succ == 0, revert

Copy link
Contributor

@cwang25 cwang25 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah that's right.
just saw oz explicitly mentioning checking zero, but works the same as bool.

Comment on lines +6 to +9
address public immutable signer;

/// @notice Address of the executor contract, if any, empowered to direct-execute unsigned operations for this wallet
address public immutable executor;
Copy link
Contributor

@cwang25 cwang25 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong.
When proxy delegate call, the immutable reads will reads the value from implementations immutable instead of proxy's ? (I think I ran into that issues before when integrating proxy into test suites)
So I assume this route, will also require changes to implementation contract to have special getter?

or in here we won't have this kind of issue 🤔 ? (something special in assembly?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the implementation contract will read the value from the proxy using a call. The proxy has built-in, public getters for these immutables.

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.

4 participants