# SourceLess Chain - Intellectual property of Alexandru Marius Stratulat and the SourceLess team. # GitHub: alexccoin | Email: alex@strlabs.io | All rights reserved. No use without written # consent. See LICENSE. # # Join SourceLess Asgard mainnet as a worker node - full state and relay; seals only with a seat key the genesis names (STARW class: quasar). # Windows. Generated by scripts/himinbjorg.mjs - do not edit this file, edit the generator. # # powershell -ExecutionPolicy Bypass -File asgard-quasar-windows.ps1 # # WHAT THIS DOES, IN ORDER, AND NOTHING ELSE # 1. refuses to run if this machine cannot hold a quasar (448 MiB RAM, 2048 MiB disk) # 2. fetches brokkr.ps1 and the Asgard genesis from https://asgard.xplstr.org/get # 3. checks both against the SHA-256 digests written into this file, and STOPS on a mismatch # 4. runs the installer with this realm, this class, a fixed p2p port and the published seeds # # WHAT IT CANNOT DO # It cannot make this node SEAL BLOCKS. Asgard is a production chain, and only the validator set # named in its genesis can seal a block on it. A quasar is a producing class, so this install can seal the moment it holds a seat key, and runs as a follower until then. # # WHAT THE DIGESTS BELOW ARE WORTH # They pin what this script fetches, so the only file you check by hand is this one. They are # worth what TLS and the download page are worth and no more. What is worth more is the genesis # PIN 1cf8655125cc1bbbc0ca06a491f53775499785c349b4d0f5748d5ea170e517bf, # compiled into the build; strblk refuses any other genesis, so a tampered file cannot put this # node on another chain. [CmdletBinding()] param([Parameter(ValueFromRemainingArguments = $true)] $Rest) $ErrorActionPreference = 'Stop' # TLS 1.2 explicitly. Windows PowerShell 5.1 still negotiates SSL3/TLS1.0 by default on some builds # and get.xplstr.org serves none of them, so without this the download fails with a connection error # that reads like a network fault. try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch { } $Base = if ($env:SOURCELESS_DOWNLOAD_BASE) { $env:SOURCELESS_DOWNLOAD_BASE } else { 'https://asgard.xplstr.org/get' } $Class = 'quasar' $P2pPort = 13130 $Peers = 'asgard.xplstr.org:47001,asgard.xplstr.org:47002,asgard.xplstr.org:47003,asgard.xplstr.org:47004,asgard.xplstr.org:47005,asgard.xplstr.org:47006,asgard.xplstr.org:47007' $BrokkrSha256 = 'ebeeb346018b32377c76f5079abad69894de992884df26ef930722559be08c46' $GenesisSha256 = 'fdb62e83e025b282382536af7bfc97091cb900b5b1432a6b089491c38a2d6054' function Say { param([string]$m) Write-Host " $m" } function Step { param([string]$m) Write-Host ''; Write-Host "== $m" } function Die { param([string]$m) Write-Host ''; Write-Host "join-asgard: $m"; exit 2 } Step 'this machine' # The interpreter, resolved and reported. A Scheduled Task started as SYSTEM reads the MACHINE PATH # from the registry, and nvm-windows, a portable zip and a per-user MSI all put node on the USER # path only - so a service installs cleanly and fails at every start with a message Task Scheduler # records as a result code and nothing else. Brokkr resolves it for itself and refuses without it. $nodeBin = $env:SOURCELESS_NODE_BIN if (-not $nodeBin) { $cmd = Get-Command node -ErrorAction SilentlyContinue if ($cmd -and $cmd.Source) { $nodeBin = $cmd.Source } } if (-not $nodeBin) { foreach ($candidate in @((Join-Path $env:ProgramFiles 'nodejs\node.exe'), (Join-Path $env:LOCALAPPDATA 'Programs\nodejs\node.exe'))) { if ($candidate -and (Test-Path $candidate)) { $nodeBin = $candidate; break } } } if (-not $nodeBin) { Die 'no node on this machine. Install Node 22.11 or newer, or set SOURCELESS_NODE_BIN to the full path of node.exe. This installer builds the node FROM SOURCE and cannot do that without one. If installing Node is not what you want, https://asgard.xplstr.org/get/#binaries publishes a single-file executable that carries its own runtime - but it does not configure a network, and started without --network asgard it joins the DEVELOPMENT chain.' } Say "node $nodeBin ($(& $nodeBin --version))" $totalMib = [int]((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1MB) Say "memory $totalMib MiB total, 448 MiB wanted by a quasar" if ($totalMib -lt 448) { Die "a quasar wants 448 MiB and this machine has $totalMib MiB. The figure is measured idle RSS plus the class retention budget plus 64 MiB of headroom; see deploy/profiles/starw-classes.json. A smaller class will fit: https://asgard.xplstr.org/get/asgard-pulsar-windows.ps1" } # Disk, against the same profile, on the volume the install will live on. Claimed in this script's # banner, so it is CHECKED: a requirement printed and not enforced is a requirement discovered when # the store cannot append. $installRoot = if ($env:SOURCELESS_PREFIX) { $env:SOURCELESS_PREFIX } else { Join-Path $env:LOCALAPPDATA 'SourceLess' } $driveLetter = [IO.Path]::GetPathRoot($installRoot).TrimEnd('\').TrimEnd(':') $drive = Get-PSDrive -Name $driveLetter -ErrorAction SilentlyContinue if ($drive -and $drive.Free -ne $null) { $freeMib = [int]($drive.Free / 1MB) Say "disk $freeMib MiB free on $driveLetter, 2048 MiB wanted (reasoned floor)" if ($freeMib -lt 2048) { Die "a quasar wants 2048 MiB and drive $driveLetter has $freeMib MiB free. A smaller class will fit: https://asgard.xplstr.org/get/asgard-pulsar-windows.ps1" } } else { Say "disk UNCHECKED - could not read free space on $driveLetter" } Step 'download' $work = Join-Path ([IO.Path]::GetTempPath()) ("sourceless-join-" + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $work -Force | Out-Null function Get-Sha256 { param([string]$p) return (Get-FileHash -Algorithm SHA256 -Path $p).Hash.ToLowerInvariant() } function Assert-Digest { param([string]$p, [string]$want) $got = Get-Sha256 $p if ($got -ne $want) { Write-Host '' Write-Host "join-asgard: $p is NOT the file this installer expects." Write-Host " expected $want" Write-Host " got $got" Write-Host '' Write-Host ' Nothing has been installed. Do not work around this. Either the download was' Write-Host ' corrupted or it was replaced; in both cases the remedy is to fetch it again and,' Write-Host ' if it still differs, to stop.' Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue exit 2 } Say ("verified " + (Split-Path -Leaf $p) + " " + $want) } try { $brokkr = Join-Path $work 'brokkr.ps1' Invoke-WebRequest -UseBasicParsing -Uri "$Base/brokkr.ps1" -OutFile $brokkr Assert-Digest $brokkr $BrokkrSha256 $genesisTmp = Join-Path $work 'asgard-genesis.json' Invoke-WebRequest -UseBasicParsing -Uri "$Base/asgard-genesis.json" -OutFile $genesisTmp Assert-Digest $genesisTmp $GenesisSha256 # The genesis has to outlive this script: the installed node reads it at every start. $genesisHome = if ($env:SOURCELESS_GENESIS_DIR) { $env:SOURCELESS_GENESIS_DIR } else { Join-Path $env:LOCALAPPDATA 'SourceLess' } New-Item -ItemType Directory -Path $genesisHome -Force | Out-Null $genesis = Join-Path $genesisHome 'asgard-genesis.json' Copy-Item -Force $genesisTmp $genesis # VERIFIED after copying, not assumed: a copy onto a full disk and a copy onto a redirected # folder both fail in ways that report success one step later. if (-not (Test-Path $genesis)) { Die "the genesis did not land at $genesis" } Assert-Digest $genesis $GenesisSha256 Step 'install' Say "class $Class (worker node - full state and relay; seals only with a seat key the genesis names)" Say "p2p port $P2pPort" Say ("seeds " + ($Peers -split ',').Count + " published") Write-Host '' # -Advertise is NOT passed. A node behind NAT that advertises an address nobody can reach gets # quarantined, and this script cannot know whether the port is forwarded. Pass it yourself once it # is, and pass a HOST and never host:port - brokkr refuses the second form, because the node # appends the port it bound and the result is an address every peer discards. $brokkrArgs = @( '-Network', 'asgard', '-Genesis', $genesis, '-Class', $Class, '-P2pPort', "$P2pPort", '-Peers', $Peers ) if ($Rest) { $brokkrArgs += $Rest } & powershell -NoProfile -ExecutionPolicy Bypass -File $brokkr @brokkrArgs if ($LASTEXITCODE -ne 0) { Die "brokkr exited $LASTEXITCODE. Nothing above this line was undone; read its output." } } finally { Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue } Write-Host '' Say 'Done. What to do next:' Say " read it strblk status --dir $env:LOCALAPPDATA\SourceLess\data\asgard-quasar" Say " open it forward TCP $P2pPort to this machine, then re-run brokkr with -Advertise " Say ' the chain https://asgard.xplstr.org'