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

Stylus deployer #294

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Stylus deployer #294

wants to merge 18 commits into from

Conversation

yahgwai
Copy link
Collaborator

@yahgwai yahgwai commented Jan 29, 2025

No description provided.

@cla-bot cla-bot bot added the s label Jan 29, 2025
src/stylus/StylusDeployer.sol Fixed Show fixed Hide fixed
src/stylus/StylusDeployer.sol Fixed Show fixed Hide fixed
src/stylus/StylusDeployer.sol Fixed Show fixed Hide fixed
@yahgwai yahgwai changed the base branch from main to develop January 29, 2025 17:24
Copy link
Contributor

@godzillaba godzillaba left a comment

Choose a reason for hiding this comment

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

haven't dug into the tests yet but the deployer looks pretty good

src/stylus/StylusDeployer.sol Outdated Show resolved Hide resolved
Comment on lines +152 to +157
// bubble up the revert if there was one
if and(iszero(newContractAddress), not(iszero(returndatasize()))) {
let p := mload(0x40)
returndatacopy(p, 0, returndatasize())
revert(p, returndatasize())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

these could be pulled out of the if/else

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my assembly foo isnt good enough, you got a suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

lol no the assembly is good i was just thinking like this:

address newContractAddress;
if (salt != 0) {
    assembly {
        newContractAddress := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
    }
} else {
    assembly {
        newContractAddress := create(0, add(bytecode, 0x20), mload(bytecode))
    }
}

assembly {
    // bubble up the revert if there was one
    if and(iszero(newContractAddress), not(iszero(returndatasize()))) {
        let p := mload(0x40)
        returndatacopy(p, 0, returndatasize())
        revert(p, returndatasize())
    }
}

src/stylus/StylusDeployer.sol Outdated Show resolved Hide resolved
src/stylus/StylusDeployer.sol Outdated Show resolved Hide resolved
src/stylus/StylusDeployer.sol Outdated Show resolved Hide resolved
src/stylus/StylusDeployer.sol Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants