Skip to content

Commit

Permalink
fix: remove leading 0x from private keys when whitelisting strategi…
Browse files Browse the repository at this point in the history
…es (#171)

This PR removes a `0x` that we suffixed on the private key when
whitelisting strategies. It was causing the whitelisting to silently
fail because the private key already had a leading `0x`.
Also, it introduces an early return when whitelisting an empty list of
strategies, and adds `--confirmations 0` to each `cast send` call, to
reduce deployment time.
  • Loading branch information
MegaRedHand authored Jan 14, 2025
1 parent b66ac01 commit e6a3ae8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions kurtosis_package/deployers/eigenlayer.star
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def deploy_mocktoken(plan, context, deployment_name, verify):

verify_args = utils.get_verify_args(context) if verify else ""

cmd = "set -e ; forge create --broadcast --rpc-url {} --private-key 0x{} {} src/ERC20Mock.sol:ERC20Mock 2> /dev/null \
cmd = "set -e ; forge create --broadcast --rpc-url {} --private-key {} {} src/ERC20Mock.sol:ERC20Mock 2> /dev/null \
| awk '/Deployed to: .*/{{ print $3 }}' | tr -d '\"\n'".format(
http_rpc_url,
private_key,
Expand Down Expand Up @@ -154,11 +154,14 @@ def format_strategies(context, token_address, strategies):


def whitelist_strategies(plan, context, deployment_name, strategies):
if len(strategies) == 0:
return

data = context.data
addresses = data["addresses"][deployment_name]
strategy_params = ",".join([addresses[strategy["name"]] for strategy in strategies])
flag_params = ",".join(["true" for _ in strategies])
cmd = "set -e ; cast send --rpc-url {rpc} --private-key 0x{pk} \
cmd = "set -e ; cast send --rpc-url {rpc} --private-key {pk} \
{addr} 'addStrategiesToDepositWhitelist(address[],bool[])' '[{strategy_params}]' '[{flag_params}]'".format(
rpc=data["http_rpc_url"],
pk=data["deployer_private_key"],
Expand All @@ -181,8 +184,10 @@ def register_operators(plan, context, deployment_name, operators):
operator_keys = data["keys"][keys_name]
addresses = data["addresses"][deployment_name]

send_cmd = "cast send --rpc-url {rpc} --private-key {pk}".format(
rpc=data["http_rpc_url"], pk=operator_keys["private_key"]
send_cmd = (
"cast send --confirmations 0 --rpc-url {rpc} --private-key {pk}".format(
rpc=data["http_rpc_url"], pk=operator_keys["private_key"]
)
)
cmds = ["set -e"]
cmds.append(
Expand Down
2 changes: 1 addition & 1 deletion kurtosis_package/deployers/utils.star
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def generate_deploy_cmd(context, script, contract_name, user_extra_args, verify)
target_contract_arg = ("--tc " + contract_name) if contract_name != None else ""
extra_args = " ".join([verify_args, target_contract_arg])

cmd = "forge script --rpc-url {} --private-key 0x{} {} --broadcast --non-interactive -vvv {} {}".format(
cmd = "forge script --rpc-url {} --private-key {} {} --broadcast --non-interactive -vvv {} {}".format(
http_rpc_url, private_key, extra_args, script, user_extra_args
)
return cmd
Expand Down
2 changes: 1 addition & 1 deletion kurtosis_package/shared_utils.star
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def read_json_artifact(plan, artifact_name, json_field, file_path="*.json"):
def send_funds(plan, context, to, amount="10ether"):
http_rpc_url = context.ethereum.all_participants[0].el_context.rpc_http_url
funded_private_key = context.ethereum.pre_funded_accounts[0].private_key
cmd = "cast send --value {} --private-key {} --rpc-url {} {}".format(
cmd = "cast send --confirmations 0 --value {} --private-key {} --rpc-url {} {}".format(
amount, funded_private_key, http_rpc_url, to
)
plan.run_sh(
Expand Down

0 comments on commit e6a3ae8

Please sign in to comment.