diff --git a/shell_scripts/flag_bypasser.ps1 b/shell_scripts/flag_bypasser.ps1 new file mode 100644 index 0000000..46b7cd6 --- /dev/null +++ b/shell_scripts/flag_bypasser.ps1 @@ -0,0 +1,10 @@ +# This file is used for converting "--" flag prefix to "-" +# before being processed by the main script +# since "--" cannot be used for flags in Powershell + +$InstallDir = $Env:APPDATA + "\LUKSO" + +$cmd = "$args" +$cmd = $cmd.Replace(" --", " -") + +powershell -command "$InstallDir\lukso.ps1 $cmd" \ No newline at end of file diff --git a/shell_scripts/install-win.ps1 b/shell_scripts/install-win.ps1 index 0cc4875..d03fe65 100644 --- a/shell_scripts/install-win.ps1 +++ b/shell_scripts/install-win.ps1 @@ -27,17 +27,21 @@ download_network_config("l15-prod") download_network_config("l15-staging") download_network_config("l15-dev") -Invoke-WebRequest -Uri https://raw.githubusercontent.com/lukso-network/lukso-orchestrator/feature/l15-setup/scripts/lukso-win.ps1 -OutFile $InstallDir\lukso.ps1 +download "https://raw.githubusercontent.com/lukso-network/network-lukso-cli/feature/windows-script/shell_scripts/lukso-win.ps1" $InstallDir\lukso.ps1 if (Test-Path "$InstallDir\globalPath\lukso") { - rm "$InstallDir\globalPath\lukso" + Remove-Item "$InstallDir\globalPath\lukso" } -Write-Output "powershell.exe -File $InstallDir\lukso.ps1 %*" | Out-File -Encoding ASCII -FilePath "$InstallDir\globalPath\lukso.bat" +# Write-Output "powershell.exe -File $InstallDir\lukso.ps1 %*" | Out-File -Encoding ASCII -FilePath "$InstallDir\globalPath\lukso.bat" +download "https://raw.githubusercontent.com/lukso-network/network-lukso-cli/feature/windows-script/shell_scripts/flag_bypasser.ps1" $InstallDir\globalPath\lukso.ps1 + +$Env:Path += ";$InstallDir\globalPath" lukso bind-binaries ` --orchestrator v0.2.0-rc.1 ` --pandora v0.2.0-rc.1 ` --vanguard v0.2.0-rc.1 ` --validator v0.2.0-rc.1 ` --eth2stats v0.1.0-rc.1 ` --deposit v1.2.6-LUKSO +-orchestrator v0.2.0-rc.2 ` +-pandora v0.2.0-rc.2 ` +-vanguard v0.2.0-rc.2 ` +-validator v0.2.0-rc.2 ` +-eth2stats v0.1.0-develop ` +-deposit v1.2.6-LUKSO ` +-lukso-status v0.0.1-alpha.9 diff --git a/shell_scripts/lukso-win.ps1 b/shell_scripts/lukso-win.ps1 index 730da05..8da9433 100755 --- a/shell_scripts/lukso-win.ps1 +++ b/shell_scripts/lukso-win.ps1 @@ -4,10 +4,13 @@ # Flags declaration param ( - [Parameter(Position = 0, Mandatory)][String]$command, + [Parameter(Position = 0)][String]$command, [Parameter(Position = 1)][String]$argument, [String]$deposit, [String]$eth2stats, + [String]${lukso-status}, + [Switch]${status-page}, + [String]${eth2stats-beacon-addr}, [String]$network, [String]${lukso-home}, [String]$datadir, @@ -24,10 +27,16 @@ param ( [String]${node-name}, [Switch]$validate, [String]$orchestrator, + [String]${orc-http-address}, + [String]${orc-http-port}, + [String]${orc-ws-address}, + [String]${orc-ws-port}, + [String]${orchestrator-pandora-rpc-endpoint}, + [String]${orchestrator-vanguard-rpc-endpoint}, [String]${orchestrator-verbosity}, [String]$pandora, [String]${pandora-bootnodes}, - [String]${pandora-http-port}, +# [String]${pandora-http-port}, [Switch]${pandora-metrics}, [String]${pandora-nodekey}, [String]${pandora-rpcvhosts}, @@ -35,15 +44,34 @@ param ( [Switch]${pandora-universal-profile-expose}, [Switch]${pandora-unsafe-expose}, [String]${pandora-verbosity}, + [String]${pan-port}, + [String]${pan-http-addr}, + [String]${pan-http-port}, + [String]${pan-http-miner-addr}, + [String]${pan-ws-addr}, + [String]${pan-ws-miner-addr}, + [String]${pan-ethstats}, [String]$vanguard, [String]${vanguard-bootnodes}, [String]${vanguard-p2p-priv-key}, [String]${vanguard-external-ip}, [String]${vanguard-p2p-host-dns}, [String]${vanguard-rpc-host}, + [String]${vanguard-http-web3provider}, + [String]${vanguard-orc-rpc-provider}, [String]${vanguard-monitoring-host}, [String]${vanguard-verbosity}, + [String]${van-ethstats-metrics}, + [String]${van-rpc-port}, + [String]${van-udp-port}, + [String]${van-tcp-port}, + [String]${van-grpc-gateway-port}, + [String]${van-min-sync-peers}, + [String]${van-max-p2p-peers}, + [String]${van-ethstats}, [String]$validator, + [String]${validator-beacon-rpc-provider}, + [String]${validator-pandora-http-provider}, [String]${validator-verbosity}, [String]${cors-domain}, [String]${external-ip}, @@ -53,7 +81,8 @@ param ( $platform = "Windows" $architecture = "x86_64" -$InstallDir = $Env:APPDATA + "\LUKSO"; +$InstallDir = $Env:APPDATA + "\LUKSO" +$LuksoScriptVersion = "v1.7" $RunDate = Get-Date -Format "yyyy-m-dd__HH-mm-ss" # Parsing config File and setting defaults @@ -73,6 +102,8 @@ Function pick_network($picked_network) $NetworkConfig = ConvertFrom-Yaml $(Get-Content -Raw $NetworkConfigFile) } +$command = If ($command) {$command} Else {"help"} + $network = If ($network) {$network} ElseIf ($ConfigFile.NETWORK) {$ConfigFile.NETWORK} Else {""} ${l15-prod} = If (${l15-prod}) {${l15-prod}} ElseIf ($ConfigFile.L15_PROD) {$ConfigFile.L15_PROD} Else {$false} @@ -109,8 +140,20 @@ If ($network) { $NetworkConfig = ConvertFrom-Yaml $(Get-Content -Raw $NetworkConfigFile) } -$deposit = If ($deposit) {$deposit} ElseIf ($ConfigFile.DEPOSIT) {$ConfigFile.DEPOSIT} Else {"v1.2.6-LUKSO"} +${pan-http-addr} = If (${pan-http-addr}) {${pan-http-addr}} ElseIf ($ConfigFile.PANDORA_HTTP_ADDR) {$ConfigFile.PANDORA_HTTP_ADDR} Else {"127.0.0.1"} +${pan-http-port} = If (${pan-http-port}) {${pan-http-port}} ElseIf ($ConfigFile.PANDORA_HTTP_PORT) {$ConfigFile.PANDORA_HTTP_PORT} Else {"8545"} + +${vanguard-rpc-host} = If (${vanguard-rpc-host}) {${vanguard-rpc-host}} ElseIf ($ConfigFile.VANGUARD_RPC_HOST) {$ConfigFile.VANGUARD_RPC_HOST} Else {"127.0.0.1"} +${van-rpc-port} = If (${van-rpc-port}) {${van-rpc-port}} ElseIf ($ConfigFile.VANGUARD_RPC_PORT) {$ConfigFile.VANGUARD_RPC_PORT} Else {"4000"} + +${vanguard-rpc} = "${vanguard-rpc-host}:${van-rpc-port}" +${pandora-rpc} = "http://${pan-http-addr}:${pan-http-port}" + +$deposit = If ($deposit) {$deposit} ElseIf ($ConfigFile.DEPOSIT) {$ConfigFile.DEPOSIT} Else {""} $eth2stats = If ($eth2stats) {$eth2stats} ElseIf ($ConfigFile.ETH2STATS) {$ConfigFile.ETH2STATS} Else {""} +${lukso-status} = If (${lukso-status}) {${lukso-status}} ElseIf ($ConfigFile.LUKSO_STATUS) {$ConfigFile.LUKSO_STATUS} Else {""} +${status-page} = If (${status-page}) {${status-page}} ElseIf ($ConfigFile.STATUS_PAGE) {$ConfigFile.STATUS_PAGE} Else {$false} +${eth2stats-beacon-addr} = If (${eth2stats-beacon-addr}) {${eth2stats-beacon-addr}} ElseIf ($ConfigFile.ETH2STATS_BEACON_ADDR) {$ConfigFile.ETH2STATS_BEACON_ADDR} Else {${vanguard-rpc}} ${lukso-home} = If (${lukso-home}) {${lukso-home}} ElseIf ($ConfigFile.LUKSO_HOME) {$ConfigFile.LUKSO_HOME} Else {"$HOME\.lukso"} $datadir = If ($datadir) {$datadir} ElseIf ($ConfigFile.DATADIR) {$ConfigFile.DATADIR} Else {"${lukso-home}\$network\datadir"} $logsdir = If ($logsdir) {$logsdir} ElseIf ($ConfigFile.LOGSDIR) {$ConfigFile.LOGSDIR} Else {"${lukso-home}\$network\logs"} @@ -123,10 +166,15 @@ $coinbase = If ($coinbase) {$coinbase} ElseIf ($ConfigFile.COINBASE) {$ConfigFil ${node-name} = If (${node-name}) {${node-name}} ElseIf ($ConfigFile.NODE_NAME) {$ConfigFile.NODE_NAME} Else {""} $validate = If ($validate) {$validate} ElseIf ($ConfigFile.VALIDATE) {$ConfigFile.VALIDATE} Else {$false} $orchestrator = If ($orchestrator) {$orchestrator} ElseIf ($ConfigFile.ORCHESTRATOR) {$ConfigFile.ORCHESTRATOR} Else {""} +${orc-http-address} = If (${orc-http-address}) {${orc-http-address}} ElseIf ($ConfigFile.ORC_HTTP_ADDR) {$ConfigFile.ORC_HTTP_ADDR} Else {"127.0.0.1"} +${orc-http-port} = If (${orc-http-port}) {${orc-http-port}} ElseIf ($ConfigFile.ORC_HTTP_PORT) {$ConfigFile.ORC_HTTP_PORT} Else {"7877"} +${orc-ws-address} = If (${orc-ws-address}) {${orc-ws-address}} ElseIf ($ConfigFile.ORC_WS_ADDR) {$ConfigFile.ORC_WS_ADDR} Else {"127.0.0.1"} +${orc-ws-port} = If (${orc-ws-port}) {${orc-ws-port}} ElseIf ($ConfigFile.ORC_WS_PORT) {$ConfigFile.ORC_WS_PORT} Else {"7878"} +${orchestrator-pandora-rpc-endpoint} = If (${orchestrator-pandora-rpc-endpoint}) {${orchestrator-pandora-rpc-endpoint}} ElseIf ($ConfigFile.ORCHESTRATOR_PANDORA_RPC_ENDPOINT) {$ConfigFile.ORCHESTRATOR_PANDORA_RPC_ENDPOINT} Else {"ws://127.0.0.1:8546"} +${orchestrator-vanguard-rpc-endpoint} = If (${orchestrator-vanguard-rpc-endpoint}) {${orchestrator-vanguard-rpc-endpoint}} ElseIf ($ConfigFile.ORCHESTRATOR_VANGUARD_RPC_ENDPOINT) {$ConfigFile.ORCHESTRATOR_VANGUARD_RPC_ENDPOINT} Else {${vanguard-rpc}} ${orchestrator-verbosity} = If (${orchestrator-verbosity}) {${orchestrator-verbosity}} ElseIf ($ConfigFile.ORCHESTRATOR_VERBOSITY) {$ConfigFile.ORCHESTRATOR_VERBOSITY} Else {"info"} $pandora = If ($pandora) {$pandora} ElseIf ($ConfigFile.PANDORA) {$ConfigFile.PANDORA} Else {""} ${pandora-bootnodes} = If (${pandora-bootnodes}) {${pandora-bootnodes}} ElseIf ($ConfigFile.PANDORA_BOOTNODES) {$ConfigFile.PANDORA_BOOTNODES} Else {$NetworkConfig.PANDORA_BOOTNODES} -${pandora-http-port} = If (${pandora-http-port}) {${pandora-http-port}} ElseIf ($ConfigFile.PANDORA_HTTP_PORT) {$ConfigFile.PANDORA_HTTP_PORT} Else {"8545"} ${pandora-metrics} = If (${pandora-metrics}) {${pandora-metrics}} ElseIf ($ConfigFile.PANDORA_METRICS) {$ConfigFile.PANDORA_METRICS} Else {$false} ${pandora-nodekey} = If (${pandora-nodekey}) {${pandora-nodekey}} ElseIf ($ConfigFile.PANDORA_NODEKEY) {$ConfigFile.PANDORA_NODEKEY} Else {""} ${pandora-rpcvhosts} = If (${pandora-rpcvhosts}) {${pandora-rpcvhosts}} ElseIf ($ConfigFile.PANDORA_RPCVHOSTS) {$ConfigFile.PANDORA_RPCVHOSTS} Else {""} @@ -134,22 +182,39 @@ ${pandora-external-ip} = If (${pandora-external-ip}) {${pandora-external-ip}} El ${pandora-universal-profile-expose} = If (${pandora-universal-profile-expose}) {${pandora-universal-profile-expose}} ElseIf ($ConfigFile.PANDORA_UNIVERSAL_PROFILE_EXPOSE) {$ConfigFile.PANDORA_UNIVERSAL_PROFILE_EXPOSE} Else {$false} ${pandora-unsafe-expose} = If (${pandora-unsafe-expose}) {${pandora-unsafe-expose}} ElseIf ($ConfigFile.PANDORA_UNSAFE_EXPOSE) {$ConfigFile.PANDORA_UNSAFE_EXPOSE} Else {$false} ${pandora-verbosity} = If (${pandora-verbosity}) {${pandora-verbosity}} ElseIf ($ConfigFile.PANDORA_VERBOSITY) {$ConfigFile.PANDORA_VERBOSITY} Else {"info"} +#${pandora-http-port} = If (${pandora-http-port}) {${pandora-http-port}} ElseIf ($ConfigFile.PANDORA_HTTP_PORT) {$ConfigFile.PANDORA_HTTP_PORT} Else {"8545"} +${pan-port} = If (${pan-port}) {${pan-port}} ElseIf ($ConfigFile.PANDORA_PORT) {$ConfigFile.PANDORA_PORT} Else {"30405"} +${pan-http-miner-addr} = If (${pan-http-miner-addr}) {${pan-http-miner-addr}} ElseIf ($ConfigFile.PANDORA_HTTP_MINER_ADDR) {$ConfigFile.PANDORA_HTTP_MINER_ADDR} Else {"ws://127.0.0.1:7877"} +${pan-ws-addr} = If (${pan-ws-addr}) {${pan-ws-addr}} ElseIf ($ConfigFile.PANDORA_WS_ADDR) {$ConfigFile.PANDORA_WS_ADDR} Else {"127.0.0.1"} +${pan-ws-port} = If (${pan-ws-port}) {${pan-ws-port}} ElseIf ($ConfigFile.PANDORA_WS_PORT) {$ConfigFile.PANDORA_WS_PORT} Else {"8546"} +${pan-ws-miner-addr} = If (${pan-ws-miner-addr}) {${pan-ws-miner-addr}} ElseIf ($ConfigFile.PANDORA_WS_MINER_ADDR) {$ConfigFile.PANDORA_WS_MINER_ADDR} Else {"ws://127.0.0.1:7878"} +${pan-ethstats} = If (${pan-ethstats}) {${pan-ethstats}} ElseIf ($ConfigFile.PANDORA_ETHSTATS) {$ConfigFile.PANDORA_ETHSTATS} Else {"6Tcpc53R5V763Aur9LgD@stats.pandora.l15.lukso.network"} $vanguard = If ($vanguard) {$vanguard} ElseIf ($ConfigFile.VANGUARD) {$ConfigFile.VANGUARD} Else {""} ${vanguard-bootnodes} = If (${vanguard-bootnodes}) {${vanguard-bootnodes}} ElseIf ($ConfigFile.VANGUARD_BOOTNODES) {$ConfigFile.VANGUARD_BOOTNODES} Else {$NetworkConfig.VANGUARD_BOOTNODES} ${vanguard-p2p-priv-key} = If (${vanguard-p2p-priv-key}) {${vanguard-p2p-priv-key}} ElseIf ($ConfigFile.VANGUARD_P2P_PRIV_KEY) {$ConfigFile.VANGUARD_P2P_PRIV_KEY} Else {""} ${vanguard-external-ip} = If (${vanguard-external-ip}) {${vanguard-external-ip}} ElseIf ($ConfigFile.VANGUARD_EXTERNAL_IP) {$ConfigFile.VANGUARD_EXTERNAL_IP} Else {""} ${vanguard-p2p-host-dns} = If (${vanguard-p2p-host-dns}) {${vanguard-p2p-host-dns}} ElseIf ($ConfigFile.VANGUARD_P2P_HOST_DNS) {$ConfigFile.VANGUARD_P2P_HOST_DNS} Else {""} -${vanguard-rpc-host} = If (${vanguard-rpc-host}) {${vanguard-rpc-host}} ElseIf ($ConfigFile.VANGUARD_RPC_HOST) {$ConfigFile.VANGUARD_RPC_HOST} Else {""} ${vanguard-monitoring-host} = If (${vanguard-monitoring-host}) {${vanguard-monitoring-host}} ElseIf ($ConfigFile.VANGUARD_MONITORING_HOST) {$ConfigFile.VANGUARD_MONITORING_HOST} Else {""} +${vanguard-http-web3provider} = If (${vanguard-http-web3provider}) {${vanguard-http-web3provider}} ElseIf ($ConfigFile.VANGUARD_HTTP_WEB3PROVIDER) {$ConfigFile.VANGUARD_HTTP_WEB3PROVIDER} Else {"http://127.0.0.1:8545"} +${vanguard-orc-rpc-provider} = If (${vanguard-orc-rpc-provider}) {${vanguard-orc-rpc-provider}} ElseIf ($ConfigFile.VANGUARD_ORC_RPC_PROVIDER) {$ConfigFile.VANGUARD_ORC_RPC_PROVIDER} Else {"http://127.0.0.1:7877"} ${vanguard-verbosity} = If (${vanguard-verbosity}) {${vanguard-verbosity}} ElseIf ($ConfigFile.VANGUARD_VERBOSITY) {$ConfigFile.VANGUARD_VERBOSITY} Else {"info"} -$validator = If ($validator) {$validator} ElseIf ($ConfigFile.VALIDATOR) {$ConfigFile.VALIDATOR} Else {"v0.2.0-rc.1"} +${van-ethstats-metrics} = If (${van-ethstats-metrics}) {${van-ethstats-metrics}} ElseIf ($ConfigFile.VANGUARD_ETHSTATS_METRICS) {$ConfigFile.VANGUARD_ETHSTATS_METRICS} Else {"http://127.0.0.1:8080/metrics"} +${van-udp-port} = If (${van-udp-port}) {${van-udp-port}} ElseIf ($ConfigFile.VANGUARD_UDP_PORT) {$ConfigFile.VANGUARD_UDP_PORT} Else {"12000"} +${van-tcp-port} = If (${van-tcp-port}) {${van-tcp-port}} ElseIf ($ConfigFile.VANGUARD_TCP_PORT) {$ConfigFile.VANGUARD_TCP_PORT} Else {"13000"} +${van-grpc-gateway-port} = If (${van-grpc-gateway-port}) {${van-grpc-gateway-port}} ElseIf ($ConfigFile.VANGUARD_GRPC_GATEWAY_PORT) {$ConfigFile.VANGUARD_GRPC_GATEWAY_PORT} Else {"3500"} +${van-min-sync-peers} = If (${van-min-sync-peers}) {${van-min-sync-peers}} ElseIf ($ConfigFile.VANGUARD_MIN_SYNC_PEERS) {$ConfigFile.VANGUARD_MIN_SYNC_PEERS} Else {"2"} +${van-max-p2p-peers} = If (${van-max-p2p-peers}) {${van-max-p2p-peers}} ElseIf ($ConfigFile.VANGUARD_MAX_P2P_PEERS) {$ConfigFile.VANGUARD_MAX_P2P_PEERS} Else {"50"} +${van-ethstats} = If (${van-ethstats}) {${van-ethstats}} ElseIf ($ConfigFile.VAN_ETHSTATS) {$ConfigFile.VAN_ETHSTATS} Else {"34.141.156.125:9090"} +$validator = If ($validator) {$validator} ElseIf ($ConfigFile.VALIDATOR) {$ConfigFile.VALIDATOR} Else {""} +${validator-beacon-rpc-provider} = If (${validator-beacon-rpc-provider}) {${validator-beacon-rpc-provider}} ElseIf ($ConfigFile.VALIDATOR_BEACON_RPC_PROVIDER) {$ConfigFile.VALIDATOR_BEACON_RPC_PROVIDER} Else {${vanguard-rpc}} +${validator-pandora-http-provider} = If (${validator-pandora-http-provider}) {${validator-pandora-http-provider}} ElseIf ($ConfigFile.VALIDATOR_PANDORA_HTTP_PROVIDER) {$ConfigFile.VALIDATOR_PANDORA_HTTP_PROVIDER} Else {${pandora-rpc}} ${validator-verbosity} = If (${validator-verbosity}) {${validator-verbosity}} ElseIf ($ConfigFile.VALIDATOR_VERBOSITY) {$ConfigFile.VALIDATOR_VERBOSITY} Else {"info"} ${cors-domain} = If (${cors-domain}) {${cors-domain}} ElseIf ($ConfigFile.CORS_DOMAIN) {$ConfigFile.CORS_DOMAIN} Else {""} ${external-ip} = If (${external-ip}) {${external-ip}} ElseIf ($ConfigFile.EXTERNAL_IP) {$ConfigFile.EXTERNAL_IP} Else {""} ${allow-respin} = If (${allow-respin}) {${allow-respin}} ElseIf ($ConfigFile.ALLOW_RESPIN) {$ConfigFile.ALLOW_RESPIN} Else {$false} $force = If ($force) {$force} ElseIf ($ConfigFile.FORCE) {$ConfigFile.FORCE} Else {$false} - +$TempPassFile = "" @@ -188,7 +253,7 @@ Function download_binary($client, $tag) $repo = "network-deposit-cli" } - eth2stats { + eth2stats-client { $repo = "network-vanguard-stats-client" } } @@ -217,7 +282,7 @@ Function bind_binary($client, $tag) download_binary $client $tag } if (Test-Path "$InstallDir\globalPath\$client") { - rm "$InstallDir\globalPath\$client" + Remove-Item "$InstallDir\globalPath\$client" } cmd /c mklink "$InstallDir\globalPath\$client" "$InstallDir\binaries\$client\$tag\$client-$platform-$architecture.exe" | Out-Null @@ -252,7 +317,8 @@ Function generate_keys() $Arguments.Add("--folder $(${keys-dir})") $Arguments.Add("--num_validators $ValidatorsNumber") - powershell.exe -command $("$InstallDir\binaries\lukso-deposit-cli\$deposit\lukso-deposit-cli-Windows-x86_64.exe $Arguments") + $depositPath = $(Get-Item "$InstallDir\globalPath\lukso-deposit-cli").Target[0] + powershell.exe -command "$depositPath $Arguments" } Function import_accounts() { @@ -271,35 +337,104 @@ Function import_accounts() { $Arguments.Add("--keys-dir=$(${keys-dir})") $Arguments.Add("--wallet-dir=$(${wallet-dir})") - powershell.exe -command $("$InstallDir\binaries\lukso-validator\$validator\lukso-validator-Windows-x86_64.exe $Arguments") + $validatorPath = $(Get-Item "$InstallDir\globalPath\lukso-validator").Target[0] + powershell.exe -command "$validatorPath $Arguments" } +Function setup_config() +{ + $input_configLocation = Read-Host -Prompt "Where to store config file? (Default: config.yaml) " + if ($input_configLocation) {$input_configLocation} Else {"config.yaml"} + + while (!($input_coinbase -match '^0x[a-fA-F0-9]{40}$')) + { + $input_coinbase = Read-Host -Prompt "Enter your coinbase (0x)" + if (!($input_coinbase -match '^0x[a-fA-F0-9]{40}$')) { + Write-Host "Enter proper coinbase ex. 0x74cbB1D4F9F79Eabd601405Db6A5950E608F5885" + } + } + + while (!($input_walletDir) -or !($(Resolve-Path -ErrorAction 'silentlycontinue' $input_walletDir))) { + $input_walletDir = Read-Host -Prompt "Enter wallet directory location" + } + $input_walletDir = $(Resolve-Path $input_walletDir).Path + + while (!($input_dataDir) -or !($(Resolve-Path -ErrorAction 'silentlycontinue' $input_dataDir))) { + $input_dataDir = Read-Host -Prompt "Enter data directory (chain will be stored there) location" + } + $input_dataDir = $(Resolve-Path $input_dataDir).Path + + while (!($input_logsDir) -or !($(Resolve-Path -ErrorAction 'silentlycontinue' $input_logsDir))) { + $input_logsDir = Read-Host -Prompt "Enter logs directory location" + } + $input_logsDir = $(Resolve-Path $input_logsDir).Path + + while (!($input_nodeName)) { + $input_nodeName = Read-Host -Prompt "Enter node name" + } + + $configData = @{ + "COINBASE"=$input_coinbase + "WALLET_DIR"=$input_walletDir + "DATADIR"=$input_dataDir + "LOGSDIR"=$input_logsDir + "NODE_NAME"=$input_nodeName + } + + $yaml = ConvertTo-Yaml $configData + Write-Output $yaml > $input_configLocation + Write-Output "Saved to $($(Resolve-Path $input_configLocation).Path)" +} Function check_validator_requirements() { + $CanValidate = $true - if (${wallet-dir}) { - if (!(Test-Path ${wallet-dir})) { - Write-Output "ERROR! Cannot Validate, wallet not found" - exit - } + if ( ($argument -ne "validator") -and (!($coinbase)) ) { + Write-Output "Please provide coinbase: -coinbase 0x" + } + + if ( ($argument -eq "validator") -and (!($coinbase)) ) { + + $pandoraPath = $(Get-Item "$InstallDir\globalPath\pandora").Target[0] + if (!($(powershell.exe -command "$pandoraPath attach ipc:\\.\pipe\geth.ipc --exec 'eth.coinbase'") -match '^\"0x[a-fA-F0-9]{40}\"$')) { + Write-Output "ERROR: Coinbase is not set on already running pandora. Please provide it using:" + Write-Output "--coinbase 0x" + $CanValidate = $false + } } - if (${wallet-password-file}) { - if (!(Test-Path ${wallet-password-file})) { + if ( (${wallet-dir}) -and (!(Test-Path ${wallet-dir})) ) { + Write-Output "Cannot validate, wallet not found. Your wallet directory is: ${wallet-dir}" + Write-Output "Create new wallet using: `"lukso wallet`" " + $CanValidate = $false + } + + if ( (${wallet-password-file}) -and (!(Test-Path ${wallet-password-file})) ) { Write-Output "ERROR! Cannot Validate, password file not found" - exit - } + $CanValidate = $false } + if (!($CanValidate)) { + exit 1 + } if (!${wallet-password-file}) { - $securedValue = Read-Host -AsSecureString -Prompt "Enter validator password" - $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue) - $value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr) - $filename = "$Env:APPDATA\LUKSO\temp_pass.txt" - [IO.File]::WriteAllLines($filename, $value) + $PasswordCheck = $false + while (!($PasswordCheck)) { + $securedValue = Read-Host -AsSecureString -Prompt "Enter validator password" + $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue) + $value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr) + $global:TempPassFile = "$Env:APPDATA\LUKSO\temp_pass.txt" + [IO.File]::WriteAllLines($global:TempPassFile, $value) + $validatorPath = $(Get-Item "$InstallDir\globalPath\lukso-validator").Target[0] + powershell.exe -command "$validatorPath accounts list --wallet-dir ${wallet-dir} --wallet-password-file $global:TempPassFile" | Out-Null + $PasswordCheck = $? + if (!($PasswordCheck)) { + Write-Output "Wrong password for wallet in ${wallet-dir}" + } + } } } @@ -320,23 +455,24 @@ Function start_orchestrator() $arguments = @( "--datadir=$datadir\orchestrator" - "--vanguard-grpc-endpoint=127.0.0.1:4000" + "--vanguard-grpc-endpoint=$(${orchestrator-vanguard-rpc-endpoint})" "--http" - "--http.addr=0.0.0.0" - "--http.port=7877" + "--http.addr=$(${orc-http-address})" + "--http.port=$(${orc-http-port})" "--ws" - "--ws.addr=0.0.0.0" - "--ws.port=7878" - "--pandora-rpc-endpoint=ws://127.0.0.1:8546" + "--ws.addr=$(${orc-ws-address})" + "--ws.port=$(${orc-ws-port})" + "--pandora-rpc-endpoint=$(${orchestrator-pandora-rpc-endpoint})" "--verbosity=trace" ) + $OrchestratorPath = $(Get-Item "$InstallDir\globalPath\lukso-orchestrator").Target[0] - Start-Process -FilePath lukso-orchestrator ` + Start-Process -FilePath "$OrchestratorPath" ` -ArgumentList $arguments ` - -NoNewWindow ` - -RedirectStandardOutput "orchestrator_$runDate.out" ` - -RedirectStandardError "orchestrator_$runDate.err" ` + -WindowStyle hidden ` + -RedirectStandardOutput "$logsdir\orchestrator\orchestrator_$runDate.out" ` + -RedirectStandardError "$logsdir\orchestrator\orchestrator_$runDate.err" ` } function start_pandora() @@ -381,9 +517,11 @@ function start_pandora() $Arguments.Add("init") $Arguments.Add("$InstallDir\networks\$NETWORK\config\pandora-genesis.json") $Arguments.Add("--datadir=$datadir\pandora") - Start-Process -Wait -FilePath "pandora" ` + + $PandoraPath = $(Get-Item "$InstallDir\globalPath\pandora").Target[0] + Start-Process -Wait -FilePath $PandoraPath ` -ArgumentList $Arguments ` - -NoNewWindow ` + -WindowStyle Hidden ` -RedirectStandardOutput "$logsdir\pandora\init_pandora_$runDate.out" ` -RedirectStandardError "$logsdir\pandora\init_pandora_$runDate.err" @@ -396,28 +534,33 @@ function start_pandora() if (${pan-ethstats}) { $Arguments.Add("--ethstats=$(${node-name}):@$(${pan-ethstats})") } - $Arguments.Add("--port=30405") + $Arguments.Add("--port=$(${pan-port})") $Arguments.Add("--http") - $Arguments.Add("--http.addr=0.0.0.0") - $Arguments.Add("--http.port=${pandora-http-port}") + $Arguments.Add("--http.addr=$(${pan-http-addr})") + $Arguments.Add("--http.port=$(${pan-http-port})") $Arguments.Add("--http.api=admin,net,eth,debug,miner,personal,txpool,web3") $Arguments.Add("--http.corsdomain=*") - $Arguments.Add("--bootnodes=${pandora-bootnodes}") + $Arguments.Add("--bootnodes=$(${pandora-bootnodes})") $Arguments.Add("--ws") - $Arguments.Add("--ws.port=8546") + $Arguments.Add("--ws.addr=$(${pan-ws-addr})") + $Arguments.Add("--ws.port=$(${pan-ws-port})") $Arguments.Add("--ws.api=admin,net,eth,debug,miner,personal,txpool,web3") $Arguments.Add("--ws.origins=*") - $Arguments.Add("--mine") - $Arguments.Add("--miner.notify=ws://127.0.0.1:7878,http://127.0.0.1:7877") - $Arguments.Add("--miner.etherbase=$coinbase") + $Arguments.Add("--miner.notify=$(${pan-ws-miner-addr}),$(${pan-http-miner-addr})") $Arguments.Add("--syncmode=full") $Arguments.Add("--allow-insecure-unlock") $Arguments.Add("--verbosity=${pandora-verbosity}") + + if ($coinbase) { + $Arguments.Add("--mine") + $Arguments.Add("--miner.etherbase=$coinbase") + } + if (${pandora-external-ip}) { $Arguments.Add("--nat=extip:${pandora-external-ip}") } - if (${pandora-metrics}) { + if (${pandora-metrics} -or ${status-page}) { $Arguments.Add("--metrics") $Arguments.Add("--metrics.expensive") $Arguments.Add("--pprof") @@ -428,10 +571,10 @@ function start_pandora() $Arguments.Add("--nodekey=${pandora-nodekey}") } - - Start-Process -FilePath "pandora" ` + $PandoraPath = $(Get-Item "$InstallDir\globalPath\pandora").Target[0] + Start-Process -FilePath $PandoraPath ` -ArgumentList $Arguments ` - -NoNewWindow ` + -WindowStyle Hidden ` -RedirectStandardOutput "$logsdir\pandora\pandora_$runDate.out" ` -RedirectStandardError "$logsdir\pandora\pandora_$runDate.err" } @@ -456,19 +599,19 @@ function start_vanguard() { foreach ($Bootnode in $BootnodesArray) { $Arguments.Add("--bootstrap-node=$Bootnode") } - $Arguments.Add("--http-web3provider=http://127.0.0.1:${pandora-http-port}") + $Arguments.Add("--http-web3provider=$(${vanguard-http-web3provider})") $Arguments.Add("--deposit-contract=0x000000000000000000000000000000000000cafe") $Arguments.Add("--contract-deployment-block=0") $Arguments.Add("--rpc-host=0.0.0.0") $Arguments.Add("--monitoring-host=0.0.0.0") $Arguments.Add("--verbosity=${vanguard-verbosity}") - $Arguments.Add("--min-sync-peers=2") - $Arguments.Add("--p2p-max-peers=50") - $Arguments.Add("--orc-http-provider=http://127.0.0.1:7877") - $Arguments.Add("--rpc-port=4000") - $Arguments.Add("--p2p-udp-port=12000") - $Arguments.Add("--p2p-tcp-port=13000") - $Arguments.Add("--grpc-gateway-port=3500") + $Arguments.Add("--min-sync-peers=$(${van-min-sync-peers})") + $Arguments.Add("--p2p-max-peers=$(${van-max-p2p-peers})") + $Arguments.Add("--orc-http-provider=$(${vanguard-orc-rpc-provider})") + $Arguments.Add("--rpc-port=$(${van-rpc-port})") + $Arguments.Add("--p2p-udp-port=$(${van-udp-port})") + $Arguments.Add("--p2p-tcp-port=$(${van-tcp-port})") + $Arguments.Add("--grpc-gateway-port=$(${van-grpc-gateway-port})") $Arguments.Add("--update-head-timely") $Arguments.Add("--lukso-network") @@ -488,15 +631,24 @@ function start_vanguard() { $Arguments.Add("--p2p-host-ip=$vanguard_external_ip") } - Start-Process -FilePath "vanguard" ` + $VanguardPath = $(Get-Item "$InstallDir\globalPath\vanguard").Target[0] + Start-Process -FilePath $VanguardPath ` -ArgumentList $Arguments ` - -NoNewWindow ` + -WindowStyle Hidden ` -RedirectStandardOutput "$logsdir\vanguard\vanguard_$runDate.out" ` -RedirectStandardError "$logsdir\vanguard\vanguard_$runDate.err" } function start_validator() { + + if (($argument -eq "validator") -and ($coinbase)) { + $pandoraPath = $(Get-Item "$InstallDir\globalPath\pandora").Target[0] + $pandoraCommand = "$pandoraPath attach ipc:\\.\pipe\geth.ipc --exec `"miner.setEtherbase(`'"+$coinbase+"`')`"" + "$pandoraPath $pandoraCommand" | Out-Null + powershell.exe -command "$pandoraPath attach ipc:\\.\pipe\geth.ipc --exec 'miner.start()'" + } + if (!(Test-Path $logsdir\validator)) { New-Item -ItemType Directory -Force -Path $logsdir\validator @@ -507,9 +659,10 @@ function start_validator() { $Arguments = New-Object System.Collections.Generic.List[System.Object] $Arguments.Add("--datadir=$datadir\validator") $Arguments.Add("--accept-terms-of-use") - $Arguments.Add("--beacon-rpc-provider=localhost:4000") + $Arguments.Add("--beacon-rpc-provider=$(${validator-beacon-rpc-provider})") $Arguments.Add("--chain-config-file=$InstallDir\networks\$network\config\vanguard-config.yaml") $Arguments.Add("--verbosity=$(${validator-verbosity})") + $Arguments.Add("--pandora-http-provider=$(${validator-pandora-http-provider})") $Arguments.Add("--wallet-dir=$(${wallet-dir})") $Arguments.Add("--rpc") $Arguments.Add("--log-file=$logsdir\validator\validator_$runDate.log") @@ -519,20 +672,61 @@ function start_validator() { $Arguments.Add("--wallet-password-file=${wallet-password-file}") } - if (!${wallet-password-file}) { + if ($global:TempPassFile) { $Arguments.Add("--wallet-password-file=$Env:APPDATA\LUKSO\temp_pass.txt") } - Start-Process -FilePath "lukso-validator" ` + $ValidatorPath = $(Get-Item "$InstallDir\globalPath\lukso-validator").Target[0] + Start-Process -FilePath $ValidatorPath ` -ArgumentList $arguments ` - -NoNewWindow ` + -WindowStyle Hidden ` -RedirectStandardOutput "$logsdir\validator\validator_$runDate.out" ` -RedirectStandardError "$logsdir\validator\validator_$runDate.err" } -function start_eth2stats() { +function start_eth2stats_client() { + if (!(Test-Path $logsdir\eth2stats)) + { + New-Item -ItemType Directory -Force -Path $logsdir\eth2stats + } + + Write-Output $runDate | Out-File -FilePath "$logsdir\eth2stats\current.tmp" + + $Arguments = New-Object System.Collections.Generic.List[System.Object] + + $Arguments.Add("run") + $Arguments.Add("--beacon.type=`"prysm`"") + $Arguments.Add("--beacon.addr=`"$(${eth2stats-beacon-addr})`"") + $Arguments.Add("--beacon.metrics-addr=`"$(${van-ethstats-metrics})`"") + $Arguments.Add("--data.folder=$datadir\eth2stats-client") + $Arguments.Add("--eth2stats.node-name=`"$(${node-name})`"") + $Arguments.Add("--eth2stats.addr=`"$(${van-ethstats})`"") + $Arguments.Add("--eth2stats.tls=`"false`"") + + $Eth2StatsPath = $(Get-Item "$InstallDir\globalPath\eth2stats-client").Target[0] + Start-Process -FilePath $Eth2StatsPath ` + -ArgumentList $Arguments ` + -WindowStyle Hidden ` + -RedirectStandardOutput "$logsdir\eth2stats\eth2stats_$runDate.out" ` + -RedirectStandardError "$logsdir\eth2stats\eth2stats_$runDate.err" + +} + +function start_lukso_status() { + if (!(Test-Path $logsdir\lukso-status)) + { + New-Item -ItemType Directory -Force -Path $logsdir\lukso-status + } + + Write-Output $runDate | Out-File -FilePath "$logsdir\lukso-status\current.tmp" + + $LuksoStatusPath = $(Get-Item "$InstallDir\globalPath\lukso-status").Target[0] + Start-Process -FilePath $LuksoStatusPath ` + -WindowStyle Hidden ` + -RedirectStandardOutput "$logsdir\lukso-status\lukso-status_$runDate.out" ` + -RedirectStandardError "$logsdir\lukso-status\lukso-status_$runDate.err" } function start_all() { @@ -543,7 +737,10 @@ function start_all() { start_orchestrator start_pandora start_vanguard - start_eth2stats + start_eth2stats_client + if (${status-page}) { + start_lukso_status + } } # "start" is a reserved keyword in PowerShell @@ -568,6 +765,14 @@ function _start($client) start_validator } + eth2stats { + start_eth2stats_client + } + + lukso-status { + start_lukso_status + } + all { start_all } @@ -579,23 +784,69 @@ function _start($client) } function stop_orchestrator() { - Stop-Process -ProcessName "lukso-orchestrator-Windows-x86_64" + $orchestratorProcess = Get-Process -Name "lukso-orchestrator-Windows-x86_64" -ErrorAction SilentlyContinue + if ($orchestratorProcess) { + Write-Output "Stopping orchestrator" + Stop-Process -ProcessName "lukso-orchestrator-Windows-x86_64" + } else { + Write-Host "Orchestrator not running" + } + Remove-Variable orchestratorProcess } function stop_pandora() { - Stop-Process -ProcessName "pandora-Windows-x86_64" + $pandoraProcess = Get-Process -Name "pandora-Windows-x86_64" -ErrorAction SilentlyContinue + if ($pandoraProcess) { + Write-Output "Stopping pandora" + Stop-Process -ProcessName "pandora-Windows-x86_64" + } else { + Write-Host "Pandora not running" + } + Remove-Variable pandoraProcess } function stop_vanguard() { - Stop-Process -ProcessName "vanguard-Windows-x86_64" + $vanguardProcess = Get-Process -Name "vanguard-Windows-x86_64" -ErrorAction SilentlyContinue + if ($vanguardProcess) { + Write-Output "Stopping vanguard" + Stop-Process -ProcessName "vanguard-Windows-x86_64" + } else { + Write-Host "Vanguard not running" + } + Remove-Variable vanguardProcess } function stop_validator() { - Stop-Process -ProcessName "lukso-validator-Windows-x86_64" + $validatorProcess = Get-Process -Name "lukso-validator-Windows-x86_64" -ErrorAction SilentlyContinue + if ($validatorProcess) { + Write-Output "Stopping validator" + Stop-Process -ProcessName "lukso-validator-Windows-x86_64" + } else { + Write-Host "Validator not running" + } + Remove-Variable validatorProcess } function stop_eth2stats() { - Stop-Process -ProcessName "eth2stats-Windows-x86_64" + $eth2statsProcess = Get-Process -Name "eth2stats-client-Windows-x86_64" -ErrorAction SilentlyContinue + if ($eth2statsProcess) { + Write-Output "Stopping eth2stats" + Stop-Process -ProcessName "eth2stats-client-Windows-x86_64" + } else { + Write-Host "eth2stats not running" + } + Remove-Variable eth2statsProcess +} + +function stop_lukso_status() { + $luksoStatusProcess = Get-Process -Name "lukso-status" -ErrorAction SilentlyContinue + if ($luksoStatusProcess) { + Write-Output "Stopping lukso-status" + Stop-Process -ProcessName "lukso-status" + } else { + Write-Host "lukso-status not running" + } + Remove-Variable luksoStatusProcess } function stop_all() { @@ -692,6 +943,27 @@ function _reset($client) { } } +Function _logs($client) { + + Workflow MultipleTail + { + Param([string[]] $Path) + $ProgressPreference='SilentlyContinue' + foreach -parallel ($file in $path) + { + Get-Content -Path $file -Tail 10 -Wait + } + } + + $CurrentLogs = (Get-Content $logsdir\$client\current.tmp -Raw).Trim() + $logfiles = @( + "$logsdir\$client\$client"+"_$CurrentLogs.out" + "$logsdir\$client\$client"+"_$CurrentLogs.err" + ) + MultipleTail($logfiles) + +} + function _help() { Write-Output "USAGE:" Write-Output "lukso [argument] [--flags]" @@ -835,7 +1107,7 @@ if ($validator) if ($eth2stats) { - bind_binary eth2stats $eth2stats + bind_binary eth2stats-client $eth2stats } if ($deposit) @@ -843,13 +1115,25 @@ if ($deposit) bind_binary lukso-deposit-cli $deposit } +if (${lukso-status}) +{ + download "https://github.com/rryter/node-status/releases/download/${lukso-status}/lukso-status-${lukso-status}-windows-amd64.zip" $InstallDir\lukso-status-${lukso-status}-windows-amd64.zip + New-Item -ItemType Directory -Force -Path $InstallDir\binaries\lukso-status\${lukso-status} + Expand-Archive -Path "$InstallDir\lukso-status-${lukso-status}-windows-amd64.zip" -DestinationPath "$InstallDir\binaries\lukso-status\${lukso-status}" -Force + if (Test-Path "$InstallDir\globalPath\lukso-status") { + Remove-Item "$InstallDir\globalPath\lukso-status" + } + + cmd /c mklink "$InstallDir\globalPath\lukso-status" "$InstallDir\binaries\lukso-status\${lukso-status}\lukso-status.exe" +} + switch ($command) { "start" { _start $argument - $KeepShell = $true + # $KeepShell = $true } "stop" { @@ -861,7 +1145,7 @@ switch ($command) } "config" { - Write-Output "Not available yet" + setup_config } "help" { @@ -878,12 +1162,17 @@ switch ($command) } "logs" { - Write-Output "Work in progress. To get the logs go to $USER\.lukso\$network\logs\" -# logs $argument + # Write-Output "Work in progress. To get the logs go to $USER\.lukso\$network\logs\" + _logs $argument + } + + "version" { + Write-Output $LuksoScriptVersion } "attach" { - pandora attach ipc:\\.\pipe\geth.ipc + $pandoraPath = $(Get-Item "$InstallDir\globalPath\pandora").Target[0] + powershell.exe -command "$pandoraPath attach ipc:\\.\pipe\geth.ipc" } "bind-binaries" { @@ -896,13 +1185,13 @@ switch ($command) } } -if ($KeepShell) -{ - Write-Output "LUKSO clients are working do not close this shell" -} +# if ($KeepShell) +# { +# Write-Output "LUKSO clients are working, do not close this shell" +# } -while ($KeepShell) -{ - Read-Host -} +# while ($KeepShell) +# { +# Read-Host +# }