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

Separation of deployer and paymaster signer #42

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def setup_4337_contracts(config: L2Config):
)
# set private key for deployment
if config.deployer_key is None:
priv_key = input("Enter private key that you would like to deploy contracts with: ")
config.deployer_key = priv_key
else:
priv_key = config.deployer_key
lib.run("set private key", f"echo PRIVATE_KEY={priv_key} > account-abstraction/.env")
config.deployer_key = input("Enter private key that you would like to deploy contracts with: ")
lib.run("set deployment key", f"echo PRIVATE_KEY={config.deployer_key} > account-abstraction/.env")
# set private key for paymaster
if config.paymaster_key is None:
config.paymaster_key = input("Enter private key for paymaster signer: ")
lib.run(
"set paymaster key",
f"echo PAYMASTER_PRIVATE_KEY={config.paymaster_key} >> account-abstraction/.env"
)
Copy link
Member

Choose a reason for hiding this comment

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

What about getting rid of the variable altogether, in favor of just using config.paymaster_key everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certainly very good point, have done that now.

# set rpc url for deployment
lib.run("set rpc url", f"echo RPC_URL={config.l2_engine_rpc} >> account-abstraction/.env")
log_file = "logs/deploy_4337_contracts.log"
Expand All @@ -98,11 +102,8 @@ def setup_stackup_bundler(config: L2Config):
f"echo ERC4337_BUNDLER_ETH_CLIENT_URL={config.l2_engine_rpc} > .env"
)
if config.bundler_key is None:
priv_key = input("Enter private key for bundler: ")
config.bundler_key = priv_key
else:
priv_key = config.bundler_key
lib.run("set private key", f"echo ERC4337_BUNDLER_PRIVATE_KEY={priv_key} >> .env")
config.bundler_key = input("Enter private key for bundler: ")
lib.run("set private key", f"echo ERC4337_BUNDLER_PRIVATE_KEY={config.bundler_key} >> .env")

# start bundler as a persistent process
print("Starting bundler...")
Expand Down Expand Up @@ -155,12 +156,7 @@ def setup_paymaster(config: L2Config):
f"echo TIME_VALIDITY={config.paymaster_validity} >> paymaster/.env"
)
# set private key for paymaster
if config.deployer_key is None:
priv_key = input("Enter private key for paymaster signer: ")
config.deployer_key = priv_key
else:
priv_key = config.deployer_key
lib.run("set private key", f"echo PRIVATE_KEY={priv_key} >> paymaster/.env")
lib.run("set private key", f"echo PRIVATE_KEY={config.paymaster_key} >> paymaster/.env")

# start paymaster signer service
print("Starting paymaster signer service...")
Expand Down
8 changes: 7 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self):

self.deployer_key = None
"""
Private key to use for deploying 4337 contracts and paymaster signature (None by default).
Private key to use for deploying 4337 contracts (None by default).
Will be used if set, otherwise will prompt users to enter private key.
"""

Expand All @@ -392,6 +392,12 @@ def __init__(self):
Will be used if set, otherwise will prompt users to enter private key.
"""

self.paymaster_key = None
"""
Private key as paymaster signer (None by default).
Will be used if set, otherwise will prompt users to enter private key.
"""

self.paymaster_validity = 300
"""
Time validity (in seconds) for the sponsored transaction that is signed by paymaster.
Expand Down