Skip to content

Commit

Permalink
deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Dec 10, 2024
1 parent 3caa037 commit 1b4cf38
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 20 deletions.
4 changes: 4 additions & 0 deletions contracts/base/BasePaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { IPaymaster } from "account-abstraction/interfaces/IPaymaster.sol";
import { IEntryPoint } from "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/core/UserOperationLib.sol";

import {console} from "forge-std/console.sol";

/**
* Helper class for creating a paymaster.
* provides helper methods for staking.
Expand All @@ -22,6 +25,7 @@ abstract contract BasePaymaster is IPaymaster, SoladyOwnable {
uint256 internal constant _PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET;

constructor(address owner, IEntryPoint entryPointArg) SoladyOwnable(owner) {
console.log("0-0");
_validateEntryPointInterface(entryPointArg);
entryPoint = entryPointArg;
}
Expand Down
8 changes: 8 additions & 0 deletions contracts/sponsorship/BiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { IBiconomySponsorshipPaymaster } from "../interfaces/IBiconomySponsorshipPaymaster.sol";

import {console} from "forge-std/console.sol";

/**
* @title BiconomySponsorshipPaymaster
* @author livingrockrises<[email protected]>
Expand Down Expand Up @@ -65,13 +67,19 @@ contract BiconomySponsorshipPaymaster is
)
BasePaymaster(owner, entryPointArg)
{
console.log("0");
_checkConstructorArgs(verifyingSignerArg, feeCollectorArg, unaccountedGasArg);
console.log("1");
assembly ("memory-safe") {
sstore(verifyingSigner.slot, verifyingSignerArg)
}
console.log("2");
feeCollector = feeCollectorArg;
console.log("3");
unaccountedGas = unaccountedGasArg;
console.log("4");
paymasterIdWithdrawalDelay = paymasterIdWithdrawalDelayArg;
console.log("5");
minDeposit = minDepositArg;
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/utils/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ contract Deployer is SoladyOwnable {

constructor(address _owner) SoladyOwnable(_owner) {}

function deploy(bytes32 _salt, bytes calldata _creationCode, bytes calldata signature) external {
function deploy(bytes32 _salt, bytes calldata _creationCode, bytes calldata signature) external returns (address deployedContract) {
bytes32 hash = keccak256(_creationCode);
if (!_verifySignature(hash, signature)) revert InvalidBytecodeSignature();
address deployedContract = Create3.create3(_salt, _creationCode);
deployedContract = Create3.create3(_salt, _creationCode);
emit ContractDeployed(deployedContract);
}

function deploy(bytes32 _salt, bytes calldata _creationCode) onlyOwner external {
address deployedContract = Create3.create3(_salt, _creationCode);
function deploy(bytes32 _salt, bytes calldata _creationCode) onlyOwner external returns (address deployedContract) {
deployedContract = Create3.create3(_salt, _creationCode);
emit ContractDeployed(deployedContract);
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/bash-deploy/artifacts/Deployer/Deployer.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/bash-deploy/deploy-gasdaddy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if [ $proceed = "y" ]; then
{
printf "Proceeding with deployment \n"
mkdir -p ./logs/$CHAIN_NAME
forge script DeployGasdaddy false --sig "run(bool)" --rpc-url $CHAIN_NAME --etherscan-api-key $CHAIN_NAME --private-key $PRIVATE_KEY $VERIFY -vv --broadcast --slow $GAS_SUFFIX 1> ./logs/$CHAIN_NAME/$CHAIN_NAME-deploy-gasdaddy.log 2> ./logs/$CHAIN_NAME/$CHAIN_NAME-deploy-gasdaddy-errors.log
forge script DeployGasdaddy false --sig "run(bool)" --rpc-url $CHAIN_NAME --etherscan-api-key $CHAIN_NAME --private-key $PRIVATE_KEY $VERIFY -vv --broadcast --slow $GAS_SUFFIX # 1> ./logs/$CHAIN_NAME/$CHAIN_NAME-deploy-gasdaddy.log 2> ./logs/$CHAIN_NAME/$CHAIN_NAME-deploy-gasdaddy-errors.log
} || {
printf "Deployment failed\n See logs for more details\n"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions scripts/bash-deploy/deploy-prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fi

### Create3 Deployer ###

CREATE3_DEPLOYER_SIZE=$(cast codesize --rpc-url $CHAIN_NAME 0x0000007EC036cf611B5877d698c62297012a097E)
CREATE3_DEPLOYER_SIZE=$(cast codesize --rpc-url $CHAIN_NAME 0x000000aFCC4940A247A53bEa5f3f4602433fe815)
# printf "CREATE3 DEPLOYER Codesize: $CREATE3_DEPLOYER_SIZE\n"

if [ $CREATE3_DEPLOYER_SIZE -eq 0 ]; then
Expand All @@ -135,7 +135,7 @@ if [ $CREATE3_DEPLOYER_SIZE -eq 0 ]; then
read -r -p "Do you want to rebuild create3 deployer? (y/n)" REBUILD
if [ $REBUILD = "y" ]; then
printf "Rebuilding create3 deployer artifacts...\n"
forge build
forge build > /dev/null
cp ../../out/Deployer.sol/Deployer.json ./artifacts/Deployer/.
else
printf "Using existing create3 deployer artifacts\n"
Expand Down
6 changes: 3 additions & 3 deletions scripts/foundry/DeployDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {DeterministicDeployerLib} from "./utils/DeterministicDeployerLib.sol";

contract DeployDeployer is Script {

bytes32 constant CREATE3_DEPLOYER_DEPLOYMENT_SALT = 0x00000000000000000000000000000000000000005328f95dfa58cf03e311ce44;
bytes32 constant CREATE3_DEPLOYER_DEPLOYMENT_SALT = 0x00000000000000000000000000000000000000007d24613b61566e02484a50c5;
address constant DEPLOYER_OWNER = 0x336A8f5251F3b0723d04FBDD25858fca02BB22E3;
bytes32 constant DEPLOYER_BYTECODE_HASH = 0x2b2eaf7fbe1e33745154ad0e5e3e0dc0f415dc619e233ee0a317a9c1e7d53657;
bytes32 constant DEPLOYER_BYTECODE_HASH = 0xb474e2c7cd2df923dc66b1fbf61eb752b66b7aecb94e055878c3c75061de219c;

function setUp() public {}

Expand All @@ -19,7 +19,7 @@ contract DeployDeployer is Script {
address expectedDeployer = DeterministicDeployerLib.computeAddress(bytecode, args, CREATE3_DEPLOYER_DEPLOYMENT_SALT);

// initcode hash to look for the salt
// console.logBytes32(keccak256(abi.encodePacked(bytecode, args)));
console.logBytes32(keccak256(abi.encodePacked(bytecode, args)));

bytes32 deployerBytecodeHash;
uint256 codeLength;
Expand Down
37 changes: 30 additions & 7 deletions scripts/foundry/DeployGasdaddy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ pragma solidity ^0.8.13;
import {Script, console} from "forge-std/Script.sol";
import {DeterministicDeployerLib} from "./utils/DeterministicDeployerLib.sol";

interface Create3Deployer {
function addressOf(bytes32 salt) external view returns (address);

function deploy(bytes32 salt, bytes calldata creationCode, bytes calldata signature) external returns (address);
}

contract DeployGasdaddy is Script {
// SALTS
bytes32 constant SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT = 0x0000000000000000000000000000000000000000000000000000000000000000;
bytes32 constant SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT = 0x0000000cc000000000000000000000000000000048da08a98903870005d16743;

// CREATE3 DEPLOYER ADDRESS
address constant CREATE3_DEPLOYER_ADDRESS = 0x000000aFCC4940A247A53bEa5f3f4602433fe815;

// CONSTRUCTOR ARGS
address constant VERIFYING_PAYMASTER_OWNER = 0x2cf491602ad22944D9047282aBC00D3e52F56B37;
Expand All @@ -17,8 +26,12 @@ contract DeployGasdaddy is Script {
uint256 constant MIN_DEPOSIT = 1e15;
address constant ENTRY_POINT_V07 = 0x0000000071727De22E5E9d8BAf0edAc6f37da032;

Create3Deployer create3Deployer;


function setUp() public {}
function setUp() public {
create3Deployer = Create3Deployer(CREATE3_DEPLOYER_ADDRESS);
}

function run(bool check) public {
if (check) {
Expand All @@ -39,7 +52,7 @@ contract DeployGasdaddy is Script {
PAYMASTER_ID_WITHDRAWAL_DELAY,
MIN_DEPOSIT
);
address sponsorshipPM = DeterministicDeployerLib.computeAddress(bytecode, args, SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT);
address sponsorshipPM = create3Deployer.addressOf(SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT);

uint256 codeSize;
assembly {
Expand All @@ -48,11 +61,15 @@ contract DeployGasdaddy is Script {

console.log("Sponsorship Paymaster address: ", sponsorshipPM, " || >> Code Size: ", codeSize);

//inicode hash to look for the salt
console.logBytes32(keccak256(abi.encodePacked(bytecode, args)));
//initcode hash to look for the salt
//console.logBytes32(keccak256(abi.encodePacked(bytecode, args)));
}

function deployGasDaddy() public {

//
// SPONSORSHIP PAYMASTER
//
bytes memory bytecode = vm.getCode("scripts/bash-deploy/artifacts/BiconomySponsorshipPaymaster/BiconomySponsorshipPaymaster.json");
bytes memory args = abi.encode(
VERIFYING_PAYMASTER_OWNER,
Expand All @@ -63,16 +80,22 @@ contract DeployGasdaddy is Script {
PAYMASTER_ID_WITHDRAWAL_DELAY,
MIN_DEPOSIT
);
address sponsorshipPM = DeterministicDeployerLib.computeAddress(bytecode, args, SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT);
address sponsorshipPM = create3Deployer.addressOf(SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT);
uint256 codeSize;
assembly {
codeSize := extcodesize(sponsorshipPM)
}
if (codeSize > 0) {
console.log("Sponsorship Paymaster already deployed at", sponsorshipPM);
} else {
sponsorshipPM = DeterministicDeployerLib.broadcastDeploy(bytecode, args, SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT);
bytes memory initcode = abi.encodePacked(bytecode, args);
bytes memory signature = hex'f799f0e37b89b42d667d6cf6ca461bb4e1d9818a5568a640ad89dbe74a16b18b105a3ecbe06828faaf91153bf2238bd5bf9f52cda834eb2ddc81c5665b77901f1b'; //pre-computed signature
sponsorshipPM = create3Deployer.deploy(SPONSORSHIP_PAYMASTER_DEPLOYMENT_SALT, initcode, signature);
console.log("Sponsorship Paymaster deployed at", sponsorshipPM);
}

//
//
//
}
}

0 comments on commit 1b4cf38

Please sign in to comment.