Skip to content

Conversation

@parketh
Copy link
Contributor

@parketh parketh commented Nov 20, 2024

Summary

This PR prevents overwrite of existing generated L2 addresses at the make l2-prepare step.

Currently, if the Ansible script execution fails at any step, re-executing the script will override existing addresses and cause funds to be lost.

Test plan

# run ansible
ansible-playbook -i ini/l2.ini playbooks/debian_op_babylon_devnet_l2.yml

# or run the script
make l2-gen-addresses

script logs

make l2-gen-addresses                                                                                       ─╯
Addresses already exist in .env file. Backing up and running teardown.
Draining ADMIN address: 0x9880E4428DF1428688E144997C66A6D5C06cb2bC
Existing balance: 0
Gas cost (+50% buffer): 1028205366795000
Gas cost exceeds balance, skipping...

Draining BATCHER address: 0x38a24855D71c6269BC0e3259403a98Bc11486e8b
Existing balance: 0
Gas cost (+50% buffer): 1028205366795000
Gas cost exceeds balance, skipping...

Draining PROPOSER address: 0x06e978948df8dFC0460814DcF189Bd343A32878f
Existing balance: 0
Gas cost (+50% buffer): 1028205366795000
Gas cost exceeds balance, skipping...

Draining complete.
Teardown complete.
Generated new addresses and updated .env file.
Funding ADMIN address: 0x18B66e27Db710cD5bCEC9C015A68909054D0eEdc with amount 0.1ether

blockHash               0xbfb747557e2f59fb6ca47edf35279daab93fec046d51af5b3a06be1adcde021c
blockNumber             7130243
contractAddress
cumulativeGasUsed       16952369
effectiveGasPrice       22571642853
from                    0xD417DEFFAA4185E88A07e9a16Bc736CA72dEB6bC
gasUsed                 21000
logs                    []
logsBloom               0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
root
status                  1 (success)
transactionHash         0x566268c6df98945d80e5636bd07e5bae8a80a5a31774399f5a8a76533d89a0a8
transactionIndex        257
type                    2
blobGasPrice
blobGasUsed
authorizationList
to                      0x18B66e27Db710cD5bCEC9C015A68909054D0eEdc

Funding BATCHER address: 0xB042e1451778A3FD88947e037f9B606025a58801 with amount 0.1ether

blockHash               0xf177c4ee4d947889aef5e6841e7b3e52becb1dcbcf7b0dd251df65d8b03862af
blockNumber             7130244
contractAddress
cumulativeGasUsed       9725228
effectiveGasPrice       24116362790
from                    0xD417DEFFAA4185E88A07e9a16Bc736CA72dEB6bC
gasUsed                 21000
logs                    []
logsBloom               0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
root
status                  1 (success)
transactionHash         0x52d64ec7415ff9358f76d7199a2108c15768a223a5244463e271f06aa846c086
transactionIndex        174
type                    2
blobGasPrice
blobGasUsed
authorizationList
to                      0xB042e1451778A3FD88947e037f9B606025a58801

Funding PROPOSER address: 0xC8002d2B06520CBD0b669d0e4e1F71524c829f5D with amount 0.1ether

blockHash               0xf82599a133f8350f14c8bc2b0382c0ca75c968892ea1a48b3b5ae4c41225f37f
blockNumber             7130245
contractAddress
cumulativeGasUsed       6782698
effectiveGasPrice       23489796832
from                    0xD417DEFFAA4185E88A07e9a16Bc736CA72dEB6bC
gasUsed                 21000
logs                    []
logsBloom               0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
root
status                  1 (success)
transactionHash         0x2c8844e93530a3485968885c850f30d1265917edd36a66f206bb3e0ac83c1c83
transactionIndex        104
type                    2
blobGasPrice
blobGasUsed
authorizationList
to                      0xC8002d2B06520CBD0b669d0e4e1F71524c829f5D

Funding complete.

}

if check_addresses_exist; then
echo "Error: Addresses or private keys already exist in .env file. Please remove them first."
Copy link
Member

@bap2pecs bap2pecs Nov 20, 2024

Choose a reason for hiding this comment

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

it might be inconvenient to require manual removing the keys in cases such as the deployment failed in the middle and we want to start from scratch. maybe add a flag to allow overwrite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about:

  • if existing keys exist, check if they are funded
  • if funded, run teardown
  • backup keys to another file, e.g. .env.bak-202411200953
  • overwrite keys and continue script execution

Copy link
Member

Choose a reason for hiding this comment

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

yeah let's do that.

@parketh parketh marked this pull request as ready for review November 22, 2024 15:40
@parketh parketh requested a review from a team as a code owner November 22, 2024 15:40
@parketh
Copy link
Contributor Author

parketh commented Nov 22, 2024

tested this, now ready for review @bap2pecs

@parketh parketh merged commit aeef239 into main Nov 22, 2024
1 check passed
@parketh parketh deleted the feat/prevent-overwrite-gen-l2-addresses branch November 22, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants