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

♻️ Refactor VyperDeployer to Allow the Configuration of the Target EVM Version #161

Merged
merged 7 commits into from
Sep 15, 2023

Conversation

zobront
Copy link
Contributor

@zobront zobront commented Sep 13, 2023

Edit by @pcaversaccio: We refactor the VyperDeployer to allow the configuration of the EVM version. The VyperDeployer contract now offers two overloaded deployContract functions that allow the configuration of the target EVM version.


Original text by @zobront:
If snekmate is installed with forge install pcaversaccio/snekmate in a fresh forge repo, tests will fail because the VyperDeployer's call to create in the assembly block will not properly deploy the contract.

To fix, user just needs to ensure that evm_version = 'shanghai' in their foundry.toml file.

This PR simply adds a warning to the README to make them aware of this.


🐶 Cute Animal Picture

image

@pcaversaccio pcaversaccio changed the title nit: evm version warning for forge install 🥢Add evm_version Warning for forge install in README Sep 13, 2023
@pcaversaccio pcaversaccio self-assigned this Sep 13, 2023
@pcaversaccio pcaversaccio added the documentation 📖 Improvements or additions to documentation label Sep 13, 2023
@pcaversaccio pcaversaccio added this to the 0.0.3 milestone Sep 13, 2023
@pcaversaccio
Copy link
Owner

pcaversaccio commented Sep 13, 2023

@zobront thanks a lot for this PR. To clarify: the VyperDeployer works as intended, but since version 0.3.8, Vyper defaults to shanghai and since the default evm_version from Foundry is paris, it will revert. Actually, you can adjust the VyperDeployer like that to make it work:

string[] memory cmds = new string[](4);
cmds[0] = "vyper";
cmds[1] = string.concat(path, fileName, ".vy");
cmds[2] = "--evm-version";
cmds[3] = "paris";

Maybe I can adjust the VyperDeployer accordingly and dismiss the warning in the README which might be more confusing. What do you think? So it would look like:

    function deployContract(
        string memory path,
        string memory fileName
        string memory evmVersion
    ) public returns (address) {
        // Create a list of strings with the commands necessary
        // to compile Vyper contracts.
        string[] memory cmds = new string[](4);
        cmds[0] = "vyper";
        cmds[1] = string.concat(path, fileName, ".vy");
        cmds[2] = "--evm-version";
        cmds[3] = evmVersion
}

@zobront
Copy link
Contributor Author

zobront commented Sep 14, 2023

@pcaversaccio Of course, makes sense that it's due to the Vyper version defaulting to Shanghai.

I like your solution a lot, but wouldn't want to burden everyone who uses deployContract() with entering an EVM version.

I assume you're thinking of adding this as a separate function, so that if they include an EVM version then it'll be included, but otherwise will use the existing function? If that's the case, I think that's a great solution and can update the PR to reflect that change.

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio pcaversaccio added the refactor/cleanup ♻️ Code refactorings and cleanups label Sep 14, 2023
@pcaversaccio pcaversaccio changed the title 🥢Add evm_version Warning for forge install in README ♻️ Refactor VyperDeployer to Allow the Configuration of the Target EVM Version Sep 14, 2023
pcaversaccio and others added 2 commits September 14, 2023 20:47
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio
Copy link
Owner

@pcaversaccio Of course, makes sense that it's due to the Vyper version defaulting to Shanghai.

I like your solution a lot, but wouldn't want to burden everyone who uses deployContract() with entering an EVM version.

I assume you're thinking of adding this as a separate function, so that if they include an EVM version then it'll be included, but otherwise will use the existing function? If that's the case, I think that's a great solution and can update the PR to reflect that change.

I pushed my changes into this PR. I simply use an overloading strategy to provide this convenience. Lmk if you agree with this approach.

pcaversaccio
pcaversaccio previously approved these changes Sep 14, 2023
@zobront
Copy link
Contributor Author

zobront commented Sep 14, 2023

Looks great to me, love the solution 🔥

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
Copy link
Owner

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

Did some final cleanups (removed unnecessary return statements as we use named returns and used calldata instead of memory for the function arguments). Will merged once the CI passed.

@pcaversaccio pcaversaccio merged commit 63c1107 into pcaversaccio:main Sep 15, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📖 Improvements or additions to documentation refactor/cleanup ♻️ Code refactorings and cleanups
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants