github.com/ethereum-optimism/optimism/l2geth@v0.0.0-20230612200230-50b04ade19e3/scripts/init.sh (about) 1 #!/bin/bash 2 3 # script to help simplify l2geth initialization 4 # it needs a path on the filesystem to the state 5 # dump 6 7 set -eou pipefail 8 9 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" 10 REPO=$DIR/.. 11 STATE_DUMP=${STATE_DUMP:-$REPO/../packages/contracts/dist/dumps/state-dump.latest.json} 12 DATADIR=${DATADIR:-$HOME/.ethereum} 13 14 # These are the initial key and address that must be used for the clique 15 # signer on the optimism network. All nodes must be initialized with this 16 # key before they are able to join the network and sync correctly. 17 # The signer address needs to be in the genesis block's extradata. 18 SIGNER_KEY=6587ae678cf4fc9a33000cdbf9f35226b71dcc6a4684a31203241f9bcfd55d27 19 SIGNER=0x00000398232e2064f896018496b4b44b3d62751f 20 21 mkdir -p $DATADIR 22 23 if [[ ! -f $STATE_DUMP ]]; then 24 echo "Cannot find $STATE_DUMP" 25 exit 1 26 fi 27 28 # Add funds to the signer account so that it can be used to send transactions 29 if [[ ! -z "$DEVELOPMENT" ]]; then 30 echo "Setting up development genesis" 31 echo "Assuming that the initial clique signer is $SIGNER, this is configured in genesis extradata" 32 DUMP=$(cat $STATE_DUMP | jq '.alloc += {"0x00000398232e2064f896018496b4b44b3d62751f": {balance: "10000000000000000000"}}') 33 TEMP=$(mktemp) 34 echo "$DUMP" | jq . > $TEMP 35 STATE_DUMP=$TEMP 36 fi 37 38 geth="$REPO/build/bin/geth" 39 USING_OVM=true $geth init --datadir $DATADIR $STATE_DUMP 40 41 echo "6587ae678cf4fc9a33000cdbf9f35226b71dcc6a4684a31203241f9bcfd55d27" \ 42 > $DATADIR/keyfile 43 44 echo "password" > $DATADIR/password 45 46 USING_OVM=true $geth account import \ 47 --datadir $DATADIR --password $DATADIR/password $DATADIR/keyfile