Browse Source

net.sh: add --copy-program (#7155)

add --copy-program to net.sh
Alex Pyattaev 3 months ago
parent
commit
e11a1aa857
1 changed files with 16 additions and 0 deletions
  1. 16 0
      net/net.sh

+ 16 - 0
net/net.sh

@@ -87,6 +87,9 @@ Operate a configured testnet
                                         in genesis config for external nodes
                                         in genesis config for external nodes
    --no-snapshot-fetch
    --no-snapshot-fetch
                                       - If set, disables booting validators from a snapshot
                                       - If set, disables booting validators from a snapshot
+   --copy-program URL_OR_MONIKER PUBKEY
+                                      - Copies a program PUBKEY from URL_OR_MONIKER.
+                                      For example, --copy-program t recr1L3PCGKLbckBqMNcJhuuyU1zgo8nBhfLVsJNwr5
    --skip-poh-verify
    --skip-poh-verify
                                       - If set, validators will skip verifying
                                       - If set, validators will skip verifying
                                         the ledger they already have saved to disk at
                                         the ledger they already have saved to disk at
@@ -624,6 +627,13 @@ deploy() {
   echo "Deployment started at $(date)"
   echo "Deployment started at $(date)"
   $metricsWriteDatapoint "testnet-deploy net-start-begin=1"
   $metricsWriteDatapoint "testnet-deploy net-start-begin=1"
 
 
+  if [[ -n "$copyProgramPubkey" ]]; then
+      echo "Copying program from ${copyProgramUrl}"
+      solana -u "${copyProgramUrl}" program dump "${copyProgramPubkey}" "${copyProgramPubkey}".so || exit 1
+
+      genesisOptions="${genesisOptions} --bpf-program ${copyProgramPubkey} BPFLoader2111111111111111111111111111111111 /home/solana/solana/net/${copyProgramPubkey}.so"
+  fi
+
   declare bootstrapLeader=true
   declare bootstrapLeader=true
   for nodeAddress in "${validatorIpList[@]}" "${blockstreamerIpList[@]}"; do
   for nodeAddress in "${validatorIpList[@]}" "${blockstreamerIpList[@]}"; do
     nodeType=
     nodeType=
@@ -815,6 +825,8 @@ externalPrimordialAccountsFile=
 remoteExternalPrimordialAccountsFile=
 remoteExternalPrimordialAccountsFile=
 internalNodesStakeLamports=
 internalNodesStakeLamports=
 internalNodesLamports=
 internalNodesLamports=
+copyProgramUrl=""
+copyProgramPubkey=""
 maybeNoSnapshot=""
 maybeNoSnapshot=""
 maybeLimitLedgerSize=""
 maybeLimitLedgerSize=""
 maybeSkipLedgerVerify=""
 maybeSkipLedgerVerify=""
@@ -905,6 +917,10 @@ while [[ -n $1 ]]; do
     elif [[ $1 = --internal-nodes-lamports ]]; then
     elif [[ $1 = --internal-nodes-lamports ]]; then
       internalNodesLamports="$2"
       internalNodesLamports="$2"
       shift 2
       shift 2
+    elif [[ $1 = --copy-program ]]; then
+      copyProgramUrl="$2"
+      copyProgramPubkey="$3"
+      shift 3
     elif [[ $1 = --external-accounts-file ]]; then
     elif [[ $1 = --external-accounts-file ]]; then
       externalPrimordialAccountsFile="$2"
       externalPrimordialAccountsFile="$2"
       remoteExternalPrimordialAccountsFile=/tmp/external-primordial-accounts.yml
       remoteExternalPrimordialAccountsFile=/tmp/external-primordial-accounts.yml