net/: Support accounts on swap-backed tmpfs
This commit is contained in:
		
				
					committed by
					
						
						Trent Nelson
					
				
			
			
				
	
			
			
			
						parent
						
							ddf1d2dbf5
						
					
				
				
					commit
					ff599ace4d
				
			
							
								
								
									
										32
									
								
								net/gce.sh
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								net/gce.sh
									
									
									
									
									
								
							@@ -68,6 +68,7 @@ externalNodes=false
 | 
				
			|||||||
failOnValidatorBootupFailure=true
 | 
					failOnValidatorBootupFailure=true
 | 
				
			||||||
preemptible=true
 | 
					preemptible=true
 | 
				
			||||||
evalInfo=false
 | 
					evalInfo=false
 | 
				
			||||||
 | 
					tmpfsAccounts=false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
publicNetwork=false
 | 
					publicNetwork=false
 | 
				
			||||||
letsEncryptDomainName=
 | 
					letsEncryptDomainName=
 | 
				
			||||||
@@ -154,6 +155,7 @@ Manage testnet instances
 | 
				
			|||||||
                    - Specify validator boot disk size in gb.
 | 
					                    - Specify validator boot disk size in gb.
 | 
				
			||||||
   --client-machine-type [type]
 | 
					   --client-machine-type [type]
 | 
				
			||||||
                    - custom client machine type
 | 
					                    - custom client machine type
 | 
				
			||||||
 | 
					   --tmpfs-accounts - Put accounts directory on a swap-backed tmpfs volume
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 config-specific options:
 | 
					 config-specific options:
 | 
				
			||||||
   -P               - Use public network IP addresses (default: $publicNetwork)
 | 
					   -P               - Use public network IP addresses (default: $publicNetwork)
 | 
				
			||||||
@@ -228,6 +230,9 @@ while [[ -n $1 ]]; do
 | 
				
			|||||||
    elif [[ $1 == --reclaim-all-reservations ]]; then
 | 
					    elif [[ $1 == --reclaim-all-reservations ]]; then
 | 
				
			||||||
      reclaimAllReservations=true
 | 
					      reclaimAllReservations=true
 | 
				
			||||||
      shift
 | 
					      shift
 | 
				
			||||||
 | 
					    elif [[ $1 == --tmpfs-accounts ]]; then
 | 
				
			||||||
 | 
					      tmpfsAccounts=true
 | 
				
			||||||
 | 
					      shift
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      usage "Unknown long option: $1"
 | 
					      usage "Unknown long option: $1"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
@@ -298,6 +303,11 @@ fi
 | 
				
			|||||||
case $cloudProvider in
 | 
					case $cloudProvider in
 | 
				
			||||||
gce)
 | 
					gce)
 | 
				
			||||||
  customMemoryGB="$(cloud_DefaultCustomMemoryGB)"
 | 
					  customMemoryGB="$(cloud_DefaultCustomMemoryGB)"
 | 
				
			||||||
 | 
					  if [[ "$tmpfsAccounts" = "true" ]]; then
 | 
				
			||||||
 | 
					    customMemoryGB=$(( customMemoryGB * 2 ))
 | 
				
			||||||
 | 
					    cpuBootstrapLeaderMachineType+=" --local-ssd interface=nvme"
 | 
				
			||||||
 | 
					    gpuBootstrapLeaderMachineType+=" --local-ssd interface=nvme"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
  cpuBootstrapLeaderMachineType+=" --custom-memory ${customMemoryGB}GB"
 | 
					  cpuBootstrapLeaderMachineType+=" --custom-memory ${customMemoryGB}GB"
 | 
				
			||||||
  gpuBootstrapLeaderMachineType+=" --custom-memory ${customMemoryGB}GB"
 | 
					  gpuBootstrapLeaderMachineType+=" --custom-memory ${customMemoryGB}GB"
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
@@ -305,6 +315,9 @@ ec2|azure|colo)
 | 
				
			|||||||
  if [[ -n $validatorAdditionalDiskSizeInGb ]] ; then
 | 
					  if [[ -n $validatorAdditionalDiskSizeInGb ]] ; then
 | 
				
			||||||
    usage "Error: --validator-additional-disk-size-gb currently only supported with cloud provider: gce"
 | 
					    usage "Error: --validator-additional-disk-size-gb currently only supported with cloud provider: gce"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					  if [[ "$tmpfsAccounts" = "true" ]]; then
 | 
				
			||||||
 | 
					    usage "Error: --tmpfs-accounts only supported on cloud provider: gce"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
*)
 | 
					*)
 | 
				
			||||||
  echo "Error: Unknown cloud provider: $cloudProvider"
 | 
					  echo "Error: Unknown cloud provider: $cloudProvider"
 | 
				
			||||||
@@ -445,6 +458,7 @@ netBasename=$prefix
 | 
				
			|||||||
publicNetwork=$publicNetwork
 | 
					publicNetwork=$publicNetwork
 | 
				
			||||||
sshPrivateKey=$sshPrivateKey
 | 
					sshPrivateKey=$sshPrivateKey
 | 
				
			||||||
letsEncryptDomainName=$letsEncryptDomainName
 | 
					letsEncryptDomainName=$letsEncryptDomainName
 | 
				
			||||||
 | 
					export TMPFS_ACCOUNTS=$tmpfsAccounts
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  touch "$geoipConfigFile"
 | 
					  touch "$geoipConfigFile"
 | 
				
			||||||
@@ -833,6 +847,24 @@ $(printNetworkInfo)
 | 
				
			|||||||
$(creationInfo)
 | 
					$(creationInfo)
 | 
				
			||||||
EOM
 | 
					EOM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(
 | 
				
			||||||
 | 
					  if [[ "$tmpfsAccounts" = "true" ]]; then
 | 
				
			||||||
 | 
					    cat <<'EOSWAP'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Setup swap/tmpfs for accounts
 | 
				
			||||||
 | 
					tmpfsMountPoint=/mnt/solana-accounts
 | 
				
			||||||
 | 
					swapDevice="/dev/nvme0n1"
 | 
				
			||||||
 | 
					swapUUID="43076c54-7840-4e59-a368-2d164f8984fb"
 | 
				
			||||||
 | 
					mkswap --uuid "$swapUUID" "$swapDevice"
 | 
				
			||||||
 | 
					echo "UUID=$swapUUID swap swap defaults 0 0" >> /etc/fstab
 | 
				
			||||||
 | 
					swapon "UUID=$swapUUID"
 | 
				
			||||||
 | 
					mkdir -p -m 0777 "$tmpfsMountPoint"
 | 
				
			||||||
 | 
					echo "tmpfs $tmpfsMountPoint tmpfs defaults,size=300G 0 0" >> /etc/fstab
 | 
				
			||||||
 | 
					mount "$tmpfsMountPoint"
 | 
				
			||||||
 | 
					EOSWAP
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
touch /solana-scratch/.instance-startup-complete
 | 
					touch /solana-scratch/.instance-startup-complete
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -294,6 +294,7 @@ startBootstrapLeader() {
 | 
				
			|||||||
         \"$maybeWarpSlot\" \
 | 
					         \"$maybeWarpSlot\" \
 | 
				
			||||||
         \"$waitForNodeInit\" \
 | 
					         \"$waitForNodeInit\" \
 | 
				
			||||||
         \"$extraPrimordialStakes\" \
 | 
					         \"$extraPrimordialStakes\" \
 | 
				
			||||||
 | 
					         \"$TMPFS_ACCOUNTS\" \
 | 
				
			||||||
      "
 | 
					      "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ) >> "$logFile" 2>&1 || {
 | 
					  ) >> "$logFile" 2>&1 || {
 | 
				
			||||||
@@ -365,6 +366,7 @@ startNode() {
 | 
				
			|||||||
         \"$maybeWarpSlot\" \
 | 
					         \"$maybeWarpSlot\" \
 | 
				
			||||||
         \"$waitForNodeInit\" \
 | 
					         \"$waitForNodeInit\" \
 | 
				
			||||||
         \"$extraPrimordialStakes\" \
 | 
					         \"$extraPrimordialStakes\" \
 | 
				
			||||||
 | 
					         \"$TMPFS_ACCOUNTS\" \
 | 
				
			||||||
      "
 | 
					      "
 | 
				
			||||||
  ) >> "$logFile" 2>&1 &
 | 
					  ) >> "$logFile" 2>&1 &
 | 
				
			||||||
  declare pid=$!
 | 
					  declare pid=$!
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ gpuMode="${19:-auto}"
 | 
				
			|||||||
maybeWarpSlot="${20}"
 | 
					maybeWarpSlot="${20}"
 | 
				
			||||||
waitForNodeInit="${21}"
 | 
					waitForNodeInit="${21}"
 | 
				
			||||||
extraPrimordialStakes="${22:=0}"
 | 
					extraPrimordialStakes="${22:=0}"
 | 
				
			||||||
 | 
					tmpfsAccounts="${23:false}"
 | 
				
			||||||
set +x
 | 
					set +x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
missing() {
 | 
					missing() {
 | 
				
			||||||
@@ -275,6 +276,10 @@ EOF
 | 
				
			|||||||
      --init-complete-file "$initCompleteFile"
 | 
					      --init-complete-file "$initCompleteFile"
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ "$tmpfsAccounts" = "true" ]]; then
 | 
				
			||||||
 | 
					      args+=(--accounts /mnt/solana-accounts)
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $airdropsEnabled = true ]]; then
 | 
					    if [[ $airdropsEnabled = true ]]; then
 | 
				
			||||||
cat >> ~/solana/on-reboot <<EOF
 | 
					cat >> ~/solana/on-reboot <<EOF
 | 
				
			||||||
      ./multinode-demo/faucet.sh > faucet.log 2>&1 &
 | 
					      ./multinode-demo/faucet.sh > faucet.log 2>&1 &
 | 
				
			||||||
@@ -392,6 +397,10 @@ EOF
 | 
				
			|||||||
      maybeSkipAccountsCreation="export SKIP_ACCOUNTS_CREATION=1"
 | 
					      maybeSkipAccountsCreation="export SKIP_ACCOUNTS_CREATION=1"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [[ "$tmpfsAccounts" = "true" ]]; then
 | 
				
			||||||
 | 
					      args+=(--accounts /mnt/solana-accounts)
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cat >> ~/solana/on-reboot <<EOF
 | 
					cat >> ~/solana/on-reboot <<EOF
 | 
				
			||||||
    $maybeSkipAccountsCreation
 | 
					    $maybeSkipAccountsCreation
 | 
				
			||||||
    nohup multinode-demo/validator.sh ${args[@]} > validator.log.\$now 2>&1 &
 | 
					    nohup multinode-demo/validator.sh ${args[@]} > validator.log.\$now 2>&1 &
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user