From 5513b2d7e1c23730b80db53ee5c5248a83954e4e Mon Sep 17 00:00:00 2001 From: Michael Dougherty Date: Tue, 2 Apr 2019 11:28:12 -0700 Subject: [PATCH 01/83] WIP: update mdbook to reflect "call" method changes --- .../src/conductor_json_rpc_api.md | 40 +++++++++---------- doc/holochain_101/src/json_rpc_http.md | 3 ++ doc/holochain_101/src/json_rpc_websockets.md | 2 + 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/doc/holochain_101/src/conductor_json_rpc_api.md b/doc/holochain_101/src/conductor_json_rpc_api.md index 5a2905db6c..a5ba73cf98 100644 --- a/doc/holochain_101/src/conductor_json_rpc_api.md +++ b/doc/holochain_101/src/conductor_json_rpc_api.md @@ -31,41 +31,41 @@ The method `info/instances` doesn't require any input parameters, so `params` ca The following explains the general JSON-RPC pattern for how to call a Zome function. -### method -To call a Zome function, for the `method` we need three things: -1. The instance ID, corresponding to the instance IDs returned by `info/instances` -2. The name of the Zome -3. The name of the function +Unlike `info/instances`, a zome function call also expects arguments. We will need to include a JSON-RPC `params` field in our RPC call. -The three are combined into a single string, separated by forward slash (`/`) characters, to use as the JSON-RPC "method". +To call a Zome function, use `"call"` as the JSON-RPC `method`, and a `params` object with four items: +1. `instance_id`: The instance ID, corresponding to the instance IDs returned by `info/instances` +2. `zome`: The name of the Zome +3. `function`: The name of the function +4. `params`: The actual parameters of the zome function call + - (yes, it's a little confusing that a sub-field of `params` is also named `params`, but we are using an RPC method to call a zome function, so nested parameters are inevitable!) -In the last example, the instance ID "test-instance" was returned, which can be used here as the instance ID. Say there was a Zome in a DNA called "blogs", this is the Zome name. That Zome has a function called "create_blog", that is the function name. Append these together with `/` characters to get the "method" for the JSON-RPC call. +In the last example, the instance ID "test-instance" was returned, which can be used here as the instance ID. Say there was a Zome in a DNA called "blogs", this is the Zome name. That Zome has a function called "create_blog", that is the function name. -**example method** -``` -"test-instance/blogs/create_blog" -``` - -### params -Unlike `info/instances`, Zome functions usually expect arguments. To give arguments, a JSON object should be constructed. +> Any top level keys of the `params` field should correspond **exactly** with the name of an argument expected by the Zome method being called. -> Any top level keys of the input object should correspond **exactly** with the name of an argument expected by the Zome method being called. +**example zome function arguments** -**example params** ```json { "blog": { "content": "sample content" }} ``` -### Example +### Example request + **example request** ```json { "jsonrpc": "2.0", "id": "0", - "method": "test-instance/blogs/create_blog", + "method": "call", "params": { - "blog": { - "content":"sample content" + "instance_id": "test-instance", + "zome": "blog", + "function": "create_blog", + "params": { + "blog": { + "content": "sample content" + } } } } diff --git a/doc/holochain_101/src/json_rpc_http.md b/doc/holochain_101/src/json_rpc_http.md index a9aca62567..685b0b5633 100644 --- a/doc/holochain_101/src/json_rpc_http.md +++ b/doc/holochain_101/src/json_rpc_http.md @@ -37,9 +37,12 @@ A response something like the following might be returned: The following discusses how to use cURL (and thus HTTP generally) to make calls to Zome functions. +The JSON-RPC method To use as the JSON-RPC "method" the instance ID (as seen in the `info/instances` example), the Zome name, and the function name are combined into a single string, separated by forward slash (`/`) characters. It could look like the following: `"method": "test-instance/blogs/create_blog"` +**TODO: update to reflect the new "call" method** + Unlike `info/instances`, Zome functions usually expect arguments. To give arguments, a JSON object should be constructed. It may look like the following: `"params": {"blog": {"content": "sample content"}}` diff --git a/doc/holochain_101/src/json_rpc_websockets.md b/doc/holochain_101/src/json_rpc_websockets.md index 6bc56c9ee7..07c95d1050 100644 --- a/doc/holochain_101/src/json_rpc_websockets.md +++ b/doc/holochain_101/src/json_rpc_websockets.md @@ -67,6 +67,8 @@ The following discusses how to use `rpc-websockets` to make calls to Zome functi To use as the JSON-RPC "method" the instance ID (as seen in the `info/instances` example), the Zome name, and the function name are combined into a single string, separated by forward slash (`/`) characters. It could look like the following: `'test-instance/blogs/create_blog'` +**TODO: update to reflect the new "call" method** + A JSON object is constructed to give arguments. It could look like the following: `{ blog: { content: 'sample content' }}` From 3fc92faaaef15f280a360badc16ccf9f1cc69902 Mon Sep 17 00:00:00 2001 From: hoijui Date: Thu, 4 Apr 2019 10:14:58 +0200 Subject: [PATCH 02/83] linux install script: update apt cache as root [fix] APT cache is stored system globally, and thus in a place where only root has access to, so updating it requires root access. --- scripts/install/linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/linux.sh b/scripts/install/linux.sh index be4ed515d2..36200f3a70 100644 --- a/scripts/install/linux.sh +++ b/scripts/install/linux.sh @@ -19,7 +19,7 @@ else fi # basics -apt-get update +$as_root apt-get update $as_root apt-get install -y curl git # needed for rust_sodium-sys + neon From 8484a497632cdfa06bd6a30b71b245c4783f5ce0 Mon Sep 17 00:00:00 2001 From: James Ray <16969914+jamesray1@users.noreply.github.com> Date: Tue, 9 Apr 2019 14:18:23 +1000 Subject: [PATCH 03/83] Swirld -> [Swirlds](https://www.swirlds.com/) --- doc/holochain_101/src/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/holochain_101/src/faq.md b/doc/holochain_101/src/faq.md index 19af72e6bc..3b712890f6 100644 --- a/doc/holochain_101/src/faq.md +++ b/doc/holochain_101/src/faq.md @@ -114,7 +114,7 @@ That's how holochains are implemented. Each source chain for each person/agent/p The minor exception to the singular vantage point of each chain, is the case when a multi-party transaction is signed to each party's chain. That is an act of consensus -- but consensus on a very small scale -- just between the parties involved in the transaction. Each party signs the exact same transaction to with links to each of their previous chain entries. Luckily, it's pretty easy to reach consensus between 2 or 3 parties. In fact, that is already why they're doing a transaction together, because they all agree to it. -Holochains do sign every change of data and timestamp (without a universal time synchronization solution), This provides ample foundation for most applications which need solid data integrity for shared data in a fully distributed multi-agent system. Surely, there will be people who will build consensus algorithms on top of foundation (maybe like rounds, witnesses, supermajorities of Swirld), +Holochains do sign every change of data and timestamp (without a universal time synchronization solution), This provides ample foundation for most applications which need solid data integrity for shared data in a fully distributed multi-agent system. Surely, there will be people who will build consensus algorithms on top of foundation (maybe like rounds, witnesses, supermajorities of [Swirlds](https://www.swirlds.com/)), However, if your system is designed around data having one absolute true state, not one which is dynamic and varied based on vantage point, we would suggest you rethink your design. So far, for every problem space where people thought they needed an absolute sequence of events or global consensus, we have been able to map an alternate approach without those requirements. Also, we already know this is how the world outside of computers works, so to design your system to require (or construct) an artificial reality is probably setting yourself up for failure, or at the very least for massive amounts of unnecessary computation, communication, and fragility within your system. From 55cef3c59470265d4e9241e74cb4083d583f3da1 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 18 Apr 2019 12:20:17 +0100 Subject: [PATCH 04/83] adding azure build scripts --- azure/build.ps1 | 432 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 432 insertions(+) create mode 100644 azure/build.ps1 diff --git a/azure/build.ps1 b/azure/build.ps1 new file mode 100644 index 0000000000..cd3fafce71 --- /dev/null +++ b/azure/build.ps1 @@ -0,0 +1,432 @@ +# Auto login image +# SO THIS IS ALREADY BAKED IN +#Reason to create callme.ps1 file is to make script copy-paste-able to PS windows and still be able to ask for password + +'Write-Warning "This script will overwrite current auto-logon settings if they exist" + +$user = whoami +$securePwd = Read-Host "Please enter password for current user to be saved for auto-logon" -AsSecureString + +#http://stackoverflow.com/questions/21741803/powershell-securestring-encrypt-decrypt-to-plain-text-not-working +$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd) +$pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType String -Value 1 + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -PropertyType String -Value $user + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -PropertyType String -Value $pwd + +del .\callme.ps1' > callme.ps1 + +.\callme.ps1 +####### +# SO THIS IS ALREADY BAKED IN + + +Write-Host "Changing PS execution policy to Unrestricted" -ForegroundColor Cyan +Set-ExecutionPolicy Unrestricted -Force + +Write-Host "Disabling Server Manager auto-start" -ForegroundColor Cyan +$serverManagerMachineKey = "HKLM:\SOFTWARE\Microsoft\ServerManager" +$serverManagerUserKey = "HKCU:\SOFTWARE\Microsoft\ServerManager" +if(Test-Path $serverManagerMachineKey) { + Set-ItemProperty -Path $serverManagerMachineKey -Name "DoNotOpenServerManagerAtLogon" -Value 1 + Write-Host "Disabled Server Manager at logon for all users" -ForegroundColor Green +} +if(Test-Path $serverManagerUserKey) { + Set-ItemProperty -Path $serverManagerUserKey -Name "CheckedUnattendLaunchSetting" -Value 0 + Write-Host "Disabled Server Manager for current user" -ForegroundColor Green +} + +# disable scheduled task +schtasks /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE + +Write-Host "Disabling UAC" -ForegroundColor Cyan + +Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 +Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" + +Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green + +Write-Host "Disabling Windows Error Reporting (WER)" -ForegroundColor Cyan +$werKey = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" +Set-ItemProperty $werKey -Name "ForceQueue" -Value 1 + +if(Test-Path "$werKey\Consent") { + Set-ItemProperty "$werKey\Consent" -Name "DefaultConsent" -Value 1 +} +Write-Host "Windows Error Reporting (WER) dialog has been disabled." -ForegroundColor Green + +Write-Host "Disabling Internet Explorer ESC" -ForegroundColor Cyan +$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" +$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" +if((Test-Path $AdminKey) -or (Test-Path $UserKey)) { + Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 + Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 + Stop-Process -Name Explorer + Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green +} + +Write-Host "WinRM - allow * hosts" -ForegroundColor Cyan +cmd /c 'winrm set winrm/config/client @{TrustedHosts="*"}' +Write-Host "WinRM configured" -ForegroundColor Green + +reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f +reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NetworkLocationWizard /v HideWizard /t REG_DWORD /d 1 /f + +$pathUtilsPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules\path-utils" +New-Item $pathUtilsPath -ItemType Directory -Force +(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/appveyor/ci/master/scripts/path-utils.psm1', "$pathUtilsPath\path-utils.psm1") +Remove-Module path-utils -ErrorAction SilentlyContinue +Import-Module path-utils + +$UserModulesPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules" +$PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') +if(-not $PSModulePath.contains($UserModulesPath)) { + [Environment]::SetEnvironmentVariable('PSModulePath', "$PSModulePath;$UserModulesPath", 'Machine') +} + +Write-Host "Installing 7-Zip..." -ForegroundColor Cyan +$exePath = "$env:USERPROFILE\7z1604-x64.exe" +Invoke-WebRequest http://www.7-zip.org/a/7z1604-x64.exe -OutFile $exePath +cmd /c start /wait $exePath /S +del $exePath + +$sevenZipFolder = 'C:\Program Files\7-Zip' +Add-SessionPath $sevenZipFolder +Add-Path "$sevenZipFolder" + +Write-Host "7-Zip installed" -ForegroundColor Green + + +if(Test-Path 'C:\ProgramData\chocolatey\bin') { + # update + Write-Host "Updating Chocolatey..." -ForegroundColor Cyan + choco upgrade chocolatey +} else { + # install + Write-Host "Installing Chocolatey..." -ForegroundColor Cyan + iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) +} + +choco --version + +# enable -y +$configPath = "C:\ProgramData\chocolatey\config\chocolatey.config" +$config = [xml](Get-Content $configPath) +$allowGlobalConfirmation = $config.chocolatey.features.feature | where {$_.name -eq 'allowGlobalConfirmation'} +$allowGlobalConfirmation.enabled = 'true' +$allowGlobalConfirmation.setExplicitly = 'true' +$config.Save($configPath) + +Write-Host "Chocolatey installed" -ForegroundColor Green + +$webPIFolder = "$env:ProgramFiles\Microsoft\Web Platform Installer" +if([IO.File]::Exists("$webPIFolder\webpicmd.exe")) { + Add-SessionPath $webPIFolder + Write-Host "Web PI is already installed" -ForegroundColor Green + return +} + +Write-Host "Installing Web Platform Installer (Web PI)..." -ForegroundColor Cyan + +# http://www.iis.net/learn/install/web-platform-installer/web-platform-installer-direct-downloads +$msiPath = "$env:USERPROFILE\WebPlatformInstaller_amd64_en-US.msi" +(New-Object Net.WebClient).DownloadFile('http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi', $msiPath) + +cmd /c start /wait msiexec /i "$msiPath" /q +del $msiPath +Add-SessionPath $webPIFolder +Write-Host "Web PI installed" -ForegroundColor Green + +Write-Host "Installing NuGet..." -ForegroundColor Cyan + +# nuget 3.x +Write-Host "NuGet 3.x" +$nuget3Path = "$env:SYSTEMDRIVE\Tools\NuGet" +if(-not (Test-Path $nuget3Path)) { + New-Item $nuget3Path -ItemType Directory -Force | Out-Null +} + +(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', "$nuget3Path\nuget.exe") + +Remove-Path $nuget2Path +Remove-Path $nuget3Path + +# add default nuget configuration +$appDataNugetConfig = ' + + + + + +' +$configDirectory = "$env:APPDATA\NuGet" +if(-not (Test-Path $configDirectory)) { + New-Item $configDirectory -ItemType Directory -Force | Out-Null +} +Set-Content "$configDirectory\NuGet.config" -Value $appDataNugetConfig + +Add-Path $nuget3Path +Add-SessionPath $nuget3Path + +Write-Host "NuGet installed" -ForegroundColor Green + +Write-Host "Installing Git 2.14.1..." -ForegroundColor Cyan + +$exePath = "$env:TEMP\Git-2.14.1-64-bit.exe" + +Write-Host "Downloading..." +(New-Object Net.WebClient).DownloadFile('https://github.com/git-for-windows/git/releases/download/v2.14.1.windows.1/Git-2.14.1-64-bit.exe', $exePath) + +Write-Host "Installing..." +cmd /c start /wait $exePath /VERYSILENT /NORESTART /NOCANCEL /SP- /NOICONS /COMPONENTS="icons,icons\quicklaunch,ext,ext\reg,ext\reg\shellhere,ext\reg\guihere,assoc,assoc_sh" /LOG +del $exePath + +Add-Path "$env:ProgramFiles\Git\cmd" +$env:path = "$env:ProgramFiles\Git\cmd;$env:path" + +Add-Path "$env:ProgramFiles\Git\usr\bin" +$env:path = "$env:ProgramFiles\Git\usr\bin;$env:path" + +#Remove-Item 'C:\Program Files\Git\mingw64\etc\gitconfig' +git config --global core.autocrlf input +git config --system --unset credential.helper +#git config --global credential.helper store + +git --version +Write-Host "Git installed" -ForegroundColor Green + +Write-Host "Installing Git LFS..." -ForegroundColor Cyan + +# delete existing Git LFS +del 'C:\Program Files\Git\mingw64\bin\git-lfs.exe' -ErrorAction SilentlyContinue + +$exePath = "$env:TEMP\git-lfs-windows-2.2.1.exe" + +Write-Host "Downloading..." +(New-Object Net.WebClient).DownloadFile('https://github.com/git-lfs/git-lfs/releases/download/v2.2.1/git-lfs-windows-2.2.1.exe', $exePath) + +Write-Host "Installing..." +cmd /c start /wait $exePath /VERYSILENT /SUPPRESSMSGBOXES /NORESTART + +Add-Path "$env:ProgramFiles\Git LFS" +$env:path = "$env:ProgramFiles\Git LFS;$env:path" + +git lfs install --force +git lfs version + +Write-Host "Git LFS installed" -ForegroundColor Green + +function Get-IPs { + + Param( + [Parameter(Mandatory = $true)] + [array] $Subnets + ) + +foreach ($subnet in $subnets) + { + #Split IP and subnet + $IP = ($Subnet -split "\/")[0] + $SubnetBits = ($Subnet -split "\/")[1] + if ($SubnetBits -eq "32") { + $IP + } else { + #Convert IP into binary + #Split IP into different octects and for each one, figure out the binary with leading zeros and add to the total + $Octets = $IP -split "\." + $IPInBinary = @() + foreach($Octet in $Octets) + { + #convert to binary + $OctetInBinary = [convert]::ToString($Octet,2) + + #get length of binary string add leading zeros to make octet + $OctetInBinary = ("0" * (8 - ($OctetInBinary).Length) + $OctetInBinary) + + $IPInBinary = $IPInBinary + $OctetInBinary + } + $IPInBinary = $IPInBinary -join "" + + #Get network ID by subtracting subnet mask + $HostBits = 32-$SubnetBits + $NetworkIDInBinary = $IPInBinary.Substring(0,$SubnetBits) + + #Get host ID and get the first host ID by converting all 1s into 0s + $HostIDInBinary = $IPInBinary.Substring($SubnetBits,$HostBits) + $HostIDInBinary = $HostIDInBinary -replace "1","0" + + #Work out all the host IDs in that subnet by cycling through $i from 1 up to max $HostIDInBinary (i.e. 1s stringed up to $HostBits) + #Work out max $HostIDInBinary + $imax = [convert]::ToInt32(("1" * $HostBits),2) -1 + + $IPs = @() + + #Next ID is first network ID converted to decimal plus $i then converted to binary + For ($i = 1 ; $i -le $imax ; $i++) + { + #Convert to decimal and add $i + $NextHostIDInDecimal = ([convert]::ToInt32($HostIDInBinary,2) + $i) + #Convert back to binary + $NextHostIDInBinary = [convert]::ToString($NextHostIDInDecimal,2) + #Add leading zeros + #Number of zeros to add + $NoOfZerosToAdd = $HostIDInBinary.Length - $NextHostIDInBinary.Length + $NextHostIDInBinary = ("0" * $NoOfZerosToAdd) + $NextHostIDInBinary + + #Work out next IP + #Add networkID to hostID + $NextIPInBinary = $NetworkIDInBinary + $NextHostIDInBinary + #Split into octets and separate by . then join + $IP = @() + For ($x = 1 ; $x -le 4 ; $x++) + { + #Work out start character position + $StartCharNumber = ($x-1)*8 + #Get octet in binary + $IPOctetInBinary = $NextIPInBinary.Substring($StartCharNumber,8) + #Convert octet into decimal + $IPOctetInDecimal = [convert]::ToInt32($IPOctetInBinary,2) + #Add octet to IP + $IP += $IPOctetInDecimal + } + + #Separate by . + $IP = $IP -join "." + $IPs += $IP + } + $IPs + } + } +} + + +Write-Host "Adding SSH known hosts..." -ForegroundColor Cyan +$sshPath = Join-Path $Home ".ssh" +if(-not (Test-Path $sshPath)) { + New-Item $sshPath -ItemType directory -Force +} + +$contents = @() +# GitHub IP addresses + +$GIthubIPs="192.30.252.0/22", + "185.199.108.0/22", + "13.229.188.59/32", + "13.250.177.223/32", + "18.194.104.89/32", + "18.195.85.27/32", + "35.159.8.160/32", + "52.74.223.119/32" +Get-IPs -subnets $GIthubIPs | ForEach-Object { + $contents += "github.com,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" +} + +# BitBucket +$BitBucketIPs="104.192.143.1", + "104.192.143.2", + "104.192.143.3", + "104.192.143.65", + "104.192.143.66", + "104.192.143.67" +$BitBucketIPs | ForEach-Object { + $contents += "bitbucket.org,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==" +} + +$knownhostfile = Join-Path $sshPath "known_hosts" +[IO.File]::WriteAllLines($knownhostfile, $contents) + +Write-Host "Known hosts configured" -ForegroundColor Green + +$installerUrl = 'http://www.appveyor.com/downloads/build-agent/latest/AppveyorBuildAgent.msi' +$installerFileName = "$($env:TEMP)\AppveyorBuildAgent.msi" + +$process = Get-Process -Name 'Appveyor.BuildAgent.Service' -ErrorAction SilentlyContinue +if($process) { + $process | Stop-Process -Force +} +$process = Get-Process -Name 'Appveyor.BuildAgent.Interactive' -ErrorAction SilentlyContinue +if($process) { + $process | Stop-Process -Force +} + +(New-Object Net.WebClient).DownloadFile($installerUrl, $installerFileName) +cmd /c start /wait msiexec /i $installerFileName /quiet APPVEYOR_MODE=Azure +Remove-Item $installerFileName + +# display appveyor version +& "C:\Program Files\AppVeyor\BuildAgent\appveyor.exe" version + +Clear-EventLog -LogName AppVeyor -ErrorAction SilentlyContinue + +Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azure" + +# Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "AmazonEC2" + +################### DO UP TO HERE FIRST + + +################# APP VEYOR SPECIFICS + +Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppVeyor.BuildAgent" ` + -Value 'powershell -File "C:\Program Files\AppVeyor\BuildAgent\start-appveyor-agent.ps1"' + +################# Dependencies + +choco install cmake + +choco install openssl.light + +# Check Path and add manually if cmake isn't there + +choco install nodist + +$env:NODIST_X64 = "1" +$env:NODIST_PREFIX = "C:\Program Files (x86)\Nodist" +$env:Path += ";C:\Program Files (x86)\Nodist\bin" +[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") + +& RefreshEnv.cmd + +nodist add 9 + +nodist 9 + +nodist npm add 5 + +nodist npm 5 + +npm install --global --production windows-build-tools + + + +####################### + +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\Users\master\Downloads\rustup-init.exe" + +C:\Users\master\Downloads\rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2019-01-24 + +# Add Cargo to Path + +$env:Path += ";C:\Users\master\.cargo\bin" +$env:Path += ";C:\Program Files\CMake\bin" + +####################### Rust specifics + +rustup target add wasm32-unknown-unknown + +rustup default nightly-2019-01-24 + +[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") +[Environment]::SetEnvironmentVariable("RUSTFLAGS", "-D warnings -Z external-macro-backtrace -Z thinlto -C codegen-units=16 -C opt-level=z", "Machine") +[Environment]::SetEnvironmentVariable("hc_target_prefix", "C:\build") +git clone https://github.com/holochain/holochain-rust C:\Users\master\build + +cd C:\Users\master\build \ No newline at end of file From 9ac070d028533d4cb309b51e00cdd9027918fd81 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 18 Apr 2019 12:30:10 +0100 Subject: [PATCH 05/83] comment out auto login --- azure/build.ps1 | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/azure/build.ps1 b/azure/build.ps1 index cd3fafce71..95ab867eb1 100644 --- a/azure/build.ps1 +++ b/azure/build.ps1 @@ -1,28 +1,26 @@ -# Auto login image -# SO THIS IS ALREADY BAKED IN -#Reason to create callme.ps1 file is to make script copy-paste-able to PS windows and still be able to ask for password - -'Write-Warning "This script will overwrite current auto-logon settings if they exist" +## Auto login image +## THIS IS ALREADY BAKED IN +# 'Write-Warning "This script will overwrite current auto-logon settings if they exist" -$user = whoami -$securePwd = Read-Host "Please enter password for current user to be saved for auto-logon" -AsSecureString +# $user = whoami +# $securePwd = Read-Host "Please enter password for current user to be saved for auto-logon" -AsSecureString -#http://stackoverflow.com/questions/21741803/powershell-securestring-encrypt-decrypt-to-plain-text-not-working -$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd) -$pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) +# #http://stackoverflow.com/questions/21741803/powershell-securestring-encrypt-decrypt-to-plain-text-not-working +# $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd) +# $pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType String -Value 1 +# Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue +# New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType String -Value 1 -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -PropertyType String -Value $user +# Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -ErrorAction SilentlyContinue +# New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -PropertyType String -Value $user -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -PropertyType String -Value $pwd +# Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue +# New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -PropertyType String -Value $pwd -del .\callme.ps1' > callme.ps1 +# del .\callme.ps1' > callme.ps1 -.\callme.ps1 +# .\callme.ps1 ####### # SO THIS IS ALREADY BAKED IN @@ -403,8 +401,6 @@ nodist npm 5 npm install --global --production windows-build-tools - - ####################### [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 From 6aeaa89906de3c0e05042136182c32405f19d083 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 18 Apr 2019 12:59:04 +0100 Subject: [PATCH 06/83] testing hc cold --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0db71f386e..e9014ad7b7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ # https://www.appveyor.com/docs/enterprise/running-builds-on-aws/ build_cloud: azure -image: hc-azure +image: hc-cold shallow_clone: true version: 1.0.{build} From aae180270e338a954b3a264cfc1b128e22d4f0e6 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 18 Apr 2019 14:27:21 +0100 Subject: [PATCH 07/83] commented out ran on the VM --- azure/build.ps1 | 127 +++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 62 deletions(-) diff --git a/azure/build.ps1 b/azure/build.ps1 index 95ab867eb1..44963a8bba 100644 --- a/azure/build.ps1 +++ b/azure/build.ps1 @@ -1,4 +1,5 @@ ## Auto login image +## master / p4ssw0rd!1234 ## THIS IS ALREADY BAKED IN # 'Write-Warning "This script will overwrite current auto-logon settings if they exist" @@ -21,60 +22,62 @@ # del .\callme.ps1' > callme.ps1 # .\callme.ps1 -####### -# SO THIS IS ALREADY BAKED IN -Write-Host "Changing PS execution policy to Unrestricted" -ForegroundColor Cyan -Set-ExecutionPolicy Unrestricted -Force +# Write-Host "Changing PS execution policy to Unrestricted" -ForegroundColor Cyan +# Set-ExecutionPolicy Unrestricted -Force -Write-Host "Disabling Server Manager auto-start" -ForegroundColor Cyan -$serverManagerMachineKey = "HKLM:\SOFTWARE\Microsoft\ServerManager" -$serverManagerUserKey = "HKCU:\SOFTWARE\Microsoft\ServerManager" -if(Test-Path $serverManagerMachineKey) { - Set-ItemProperty -Path $serverManagerMachineKey -Name "DoNotOpenServerManagerAtLogon" -Value 1 - Write-Host "Disabled Server Manager at logon for all users" -ForegroundColor Green -} -if(Test-Path $serverManagerUserKey) { - Set-ItemProperty -Path $serverManagerUserKey -Name "CheckedUnattendLaunchSetting" -Value 0 - Write-Host "Disabled Server Manager for current user" -ForegroundColor Green -} +# Write-Host "Disabling Server Manager auto-start" -ForegroundColor Cyan +# $serverManagerMachineKey = "HKLM:\SOFTWARE\Microsoft\ServerManager" +# $serverManagerUserKey = "HKCU:\SOFTWARE\Microsoft\ServerManager" +# if(Test-Path $serverManagerMachineKey) { +# Set-ItemProperty -Path $serverManagerMachineKey -Name "DoNotOpenServerManagerAtLogon" -Value 1 +# Write-Host "Disabled Server Manager at logon for all users" -ForegroundColor Green +# } +# if(Test-Path $serverManagerUserKey) { +# Set-ItemProperty -Path $serverManagerUserKey -Name "CheckedUnattendLaunchSetting" -Value 0 +# Write-Host "Disabled Server Manager for current user" -ForegroundColor Green +# } -# disable scheduled task -schtasks /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE +# # disable scheduled task +# schtasks /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE -Write-Host "Disabling UAC" -ForegroundColor Cyan +# Write-Host "Disabling UAC" -ForegroundColor Cyan -Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" +# Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 +# Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" -Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green +# Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green -Write-Host "Disabling Windows Error Reporting (WER)" -ForegroundColor Cyan -$werKey = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Set-ItemProperty $werKey -Name "ForceQueue" -Value 1 +# Write-Host "Disabling Windows Error Reporting (WER)" -ForegroundColor Cyan +# $werKey = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" +# Set-ItemProperty $werKey -Name "ForceQueue" -Value 1 -if(Test-Path "$werKey\Consent") { - Set-ItemProperty "$werKey\Consent" -Name "DefaultConsent" -Value 1 -} -Write-Host "Windows Error Reporting (WER) dialog has been disabled." -ForegroundColor Green - -Write-Host "Disabling Internet Explorer ESC" -ForegroundColor Cyan -$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -if((Test-Path $AdminKey) -or (Test-Path $UserKey)) { - Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 - Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 - Stop-Process -Name Explorer - Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green -} +# if(Test-Path "$werKey\Consent") { +# Set-ItemProperty "$werKey\Consent" -Name "DefaultConsent" -Value 1 +# } +# Write-Host "Windows Error Reporting (WER) dialog has been disabled." -ForegroundColor Green + +# Write-Host "Disabling Internet Explorer ESC" -ForegroundColor Cyan +# $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" +# $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" +# if((Test-Path $AdminKey) -or (Test-Path $UserKey)) { +# Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 +# Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 +# Stop-Process -Name Explorer +# Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green +# } -Write-Host "WinRM - allow * hosts" -ForegroundColor Cyan -cmd /c 'winrm set winrm/config/client @{TrustedHosts="*"}' -Write-Host "WinRM configured" -ForegroundColor Green +# Write-Host "WinRM - allow * hosts" -ForegroundColor Cyan +# cmd /c 'winrm set winrm/config/client @{TrustedHosts="*"}' +# Write-Host "WinRM configured" -ForegroundColor Green -reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f -reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NetworkLocationWizard /v HideWizard /t REG_DWORD /d 1 /f +# reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f +# reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NetworkLocationWizard /v HideWizard /t REG_DWORD /d 1 /f + + +####### +# SO THIS IS ALREADY BAKED IN $pathUtilsPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules\path-utils" New-Item $pathUtilsPath -ItemType Directory -Force @@ -341,28 +344,28 @@ $knownhostfile = Join-Path $sshPath "known_hosts" Write-Host "Known hosts configured" -ForegroundColor Green -$installerUrl = 'http://www.appveyor.com/downloads/build-agent/latest/AppveyorBuildAgent.msi' -$installerFileName = "$($env:TEMP)\AppveyorBuildAgent.msi" +# $installerUrl = 'http://www.appveyor.com/downloads/build-agent/latest/AppveyorBuildAgent.msi' +# $installerFileName = "$($env:TEMP)\AppveyorBuildAgent.msi" -$process = Get-Process -Name 'Appveyor.BuildAgent.Service' -ErrorAction SilentlyContinue -if($process) { - $process | Stop-Process -Force -} -$process = Get-Process -Name 'Appveyor.BuildAgent.Interactive' -ErrorAction SilentlyContinue -if($process) { - $process | Stop-Process -Force -} +# $process = Get-Process -Name 'Appveyor.BuildAgent.Service' -ErrorAction SilentlyContinue +# if($process) { +# $process | Stop-Process -Force +# } +# $process = Get-Process -Name 'Appveyor.BuildAgent.Interactive' -ErrorAction SilentlyContinue +# if($process) { +# $process | Stop-Process -Force +# } -(New-Object Net.WebClient).DownloadFile($installerUrl, $installerFileName) -cmd /c start /wait msiexec /i $installerFileName /quiet APPVEYOR_MODE=Azure -Remove-Item $installerFileName +# (New-Object Net.WebClient).DownloadFile($installerUrl, $installerFileName) +# cmd /c start /wait msiexec /i $installerFileName /quiet APPVEYOR_MODE=Azure +# Remove-Item $installerFileName -# display appveyor version -& "C:\Program Files\AppVeyor\BuildAgent\appveyor.exe" version +# # display appveyor version +# & "C:\Program Files\AppVeyor\BuildAgent\appveyor.exe" version -Clear-EventLog -LogName AppVeyor -ErrorAction SilentlyContinue +# Clear-EventLog -LogName AppVeyor -ErrorAction SilentlyContinue -Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azure" +# Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azure" # Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "AmazonEC2" @@ -371,8 +374,8 @@ Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azu ################# APP VEYOR SPECIFICS -Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppVeyor.BuildAgent" ` - -Value 'powershell -File "C:\Program Files\AppVeyor\BuildAgent\start-appveyor-agent.ps1"' +# Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppVeyor.BuildAgent" ` +# -Value 'powershell -File "C:\Program Files\AppVeyor\BuildAgent\start-appveyor-agent.ps1"' ################# Dependencies From ca7634753d8bc1974a1861f812adf87828477cc3 Mon Sep 17 00:00:00 2001 From: carm Date: Wed, 24 Apr 2019 02:11:35 -0400 Subject: [PATCH 08/83] Stub new commit function w/provenances. --- core/src/action.rs | 4 ++- core/src/agent/actions/commit.rs | 3 +- core/src/agent/state.rs | 14 +++++--- core/src/dht/dht_reducers.rs | 2 +- core/src/network/handler/send.rs | 1 + .../actions/build_validation_package.rs | 10 +++--- core/src/nucleus/ribosome/api/commit.rs | 36 +++++++++++++++++-- core/src/nucleus/ribosome/api/link_entries.rs | 2 +- core/src/nucleus/ribosome/api/remove_entry.rs | 1 + core/src/nucleus/ribosome/api/remove_link.rs | 2 +- core/src/nucleus/ribosome/api/update_entry.rs | 1 + core/src/workflows/author_entry.rs | 8 +++-- .../respond_validation_package_request.rs | 7 ++-- core_types/src/entry/mod.rs | 24 +++++++++++++ hdk-rust/src/api.rs | 16 +++++++-- 15 files changed, 109 insertions(+), 22 deletions(-) diff --git a/core/src/action.rs b/core/src/action.rs index ef67fd9ef9..c3e1d8142e 100644 --- a/core/src/action.rs +++ b/core/src/action.rs @@ -21,6 +21,7 @@ use holochain_core_types::{ error::HolochainError, link::Link, validation::ValidationPackage, + signature::Provenance, }; use holochain_net::{ connection::json_protocol::{ @@ -32,6 +33,7 @@ use snowflake; use std::{ hash::{Hash, Hasher}, sync::Arc, + vec::Vec, }; /// Wrapper for actions that provides a unique ID @@ -93,7 +95,7 @@ pub enum Action { // ---------------- /// Writes an entry to the source chain. /// Does not validate, assumes entry is valid. - Commit((Entry, Option
)), + Commit((Entry, Option
, Vec)), // ------------- // DHT actions: diff --git a/core/src/agent/actions/commit.rs b/core/src/agent/actions/commit.rs index 8a1a7bcbe7..cc81119a27 100644 --- a/core/src/agent/actions/commit.rs +++ b/core/src/agent/actions/commit.rs @@ -23,7 +23,8 @@ pub async fn commit_entry( context: &Arc, ) -> Result { let action_wrapper = - ActionWrapper::new(Action::Commit((entry.clone(), maybe_link_update_delete))); + ActionWrapper::new(Action::Commit((entry.clone(), maybe_link_update_delete, + vec![]))); dispatch_action(context.action_channel(), action_wrapper.clone()); await!(CommitFuture { context: context.clone(), diff --git a/core/src/agent/state.rs b/core/src/agent/state.rs index 5f626f770a..1f102eae03 100644 --- a/core/src/agent/state.rs +++ b/core/src/agent/state.rs @@ -163,6 +163,7 @@ pub fn create_new_chain_header( entry: &Entry, context: Arc, crud_link: &Option
, + provenances: &Vec ) -> Result { let agent_state = context .state() @@ -180,10 +181,14 @@ pub fn create_new_chain_header( let duration_since_epoch = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .expect("System time must not be before UNIX EPOCH"); + + let mut provenances: Vec = provenances.to_vec(); + provenances.push(Provenance::new(agent_address, signature)); + Ok(ChainHeader::new( &entry.entry_type(), &entry.address(), - &vec![Provenance::new(agent_address, signature)], + &provenances, &agent_state .top_chain_header .clone() @@ -212,9 +217,9 @@ fn reduce_commit_entry( action_wrapper: &ActionWrapper, ) { let action = action_wrapper.action(); - let (entry, maybe_link_update_delete) = unwrap_to!(action => Action::Commit); + let (entry, maybe_link_update_delete, provenances) = unwrap_to!(action => Action::Commit); - let result = create_new_chain_header(&entry, context.clone(), &maybe_link_update_delete) + let result = create_new_chain_header(&entry, context.clone(), &maybe_link_update_delete, provenances) .and_then(|chain_header| { let storage = &state.chain_store.content_storage().clone(); storage.write().unwrap().add(entry)?; @@ -408,7 +413,8 @@ pub mod tests { .unwrap() .set_state(Arc::new(RwLock::new(state))); - let header = create_new_chain_header(&test_entry(), context.clone(), &None).unwrap(); + let header = create_new_chain_header(&test_entry(), context.clone(), &None, + vec![]).unwrap(); println!("{:?}", header); assert_eq!( header, diff --git a/core/src/dht/dht_reducers.rs b/core/src/dht/dht_reducers.rs index 67fb05916b..93c6844a1d 100644 --- a/core/src/dht/dht_reducers.rs +++ b/core/src/dht/dht_reducers.rs @@ -59,7 +59,7 @@ pub(crate) fn reduce_hold_entry( action_wrapper: &ActionWrapper, ) -> Option { match action_wrapper.action().clone() { - Action::Commit((entry, _)) => reduce_store_entry_common(context, old_store, &entry), + Action::Commit((entry, _, _)) => reduce_store_entry_common(context, old_store, &entry), Action::Hold(EntryWithHeader { entry, header }) => { reduce_store_entry_common(context.clone(), old_store, &entry).and_then(|state| { state.add_header_for_entry(&entry, &header).ok()?; diff --git a/core/src/network/handler/send.rs b/core/src/network/handler/send.rs index 0e5f3a2949..5920d412a5 100644 --- a/core/src/network/handler/send.rs +++ b/core/src/network/handler/send.rs @@ -43,6 +43,7 @@ pub fn handle_send_message(message_data: MessageData, context: Arc) { message_data.request_id, address, context.clone(), + &vec![] )); }); } diff --git a/core/src/nucleus/actions/build_validation_package.rs b/core/src/nucleus/actions/build_validation_package.rs index 959650b5f6..61185cf234 100644 --- a/core/src/nucleus/actions/build_validation_package.rs +++ b/core/src/nucleus/actions/build_validation_package.rs @@ -16,13 +16,15 @@ use holochain_core_types::{ entry::{entry_type::EntryType, Entry}, error::HolochainError, validation::{ValidationPackage, ValidationPackageDefinition::*}, + signature::Provenance, }; use snowflake; -use std::{convert::TryInto, pin::Pin, sync::Arc, thread}; +use std::{convert::TryInto, pin::Pin, sync::Arc, thread, vec::Vec}; -pub async fn build_validation_package( - entry: &Entry, +pub async fn build_validation_package<'a>( + entry: &'a Entry, context: Arc, + provenances: &'a Vec, ) -> Result { let id = snowflake::ProcessUniqueId::new(); @@ -88,7 +90,7 @@ pub async fn build_validation_package( // and just used for the validation, I don't see why it would be a problem. // If it was a problem, we would have to make sure that the whole commit process // (including validtion) is atomic. - agent::state::create_new_chain_header(&entry, context.clone(), &None)?, + agent::state::create_new_chain_header(&entry, context.clone(), &None, provenances)?, ); thread::spawn(move || { diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 52ace11232..2aba3c2f46 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -2,7 +2,8 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::author_entry::author_entry, }; -use holochain_core_types::{cas::content::Address, entry::Entry, error::HolochainError}; +use holochain_core_types::{cas::content::Address, + entry::{Entry, EntryWithProvenance}, error::HolochainError}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; @@ -27,11 +28,42 @@ pub fn invoke_commit_app_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> Zom }; // Wait for future to be resolved let task_result: Result = - context.block_on(author_entry(&entry, None, &context)); + context.block_on(author_entry(&entry, None, &context, &vec![])); runtime.store_result(task_result) } +/// ZomeApiFunction::CommitAppEntry function code +/// args: [0] encoded MemoryAllocation as u64 +/// Expected complex argument: CommitWithProvenanceArgs +/// Returns an HcApiReturnCode as I64 +pub fn invoke_commit_app_entry_with_provenance( + runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApiResult { + let context = runtime.context()?; + // deserialize args + let args_str = runtime.load_json_string_from_args(&args); + let entry_with_provenance = + match EntryWithProvenance::try_from(args_str.clone()) { + Ok(entry_with_provenance_input) => entry_with_provenance_input, + // Exit on error + Err(_) => { + context.log(format!( + "err/zome: invoke_commit_app_entry failed to deserialize Entry: {:?}", + args_str + )); + return ribosome_error_code!(ArgumentDeserializationFailed); + } + }; + // Wait for future to be resolved + let task_result: Result = + context.block_on(author_entry( + &entry_with_provenance.entry(), None, &context, + &entry_with_provenance.provenances())); + + runtime.store_result(task_result) +} + + #[cfg(test)] pub mod tests { use crate::nucleus::ribosome::{ diff --git a/core/src/nucleus/ribosome/api/link_entries.rs b/core/src/nucleus/ribosome/api/link_entries.rs index f4dc7d3b86..026cfeb37a 100644 --- a/core/src/nucleus/ribosome/api/link_entries.rs +++ b/core/src/nucleus/ribosome/api/link_entries.rs @@ -35,7 +35,7 @@ pub fn invoke_link_entries(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi let entry = Entry::LinkAdd(link_add); // Wait for future to be resolved let result: Result<(), HolochainError> = context - .block_on(author_entry(&entry, None, &context)) + .block_on(author_entry(&entry, None, &context, &vec![])) .map(|_| ()); runtime.store_result(result) diff --git a/core/src/nucleus/ribosome/api/remove_entry.rs b/core/src/nucleus/ribosome/api/remove_entry.rs index 3a366fdfa8..a169ae0820 100644 --- a/core/src/nucleus/ribosome/api/remove_entry.rs +++ b/core/src/nucleus/ribosome/api/remove_entry.rs @@ -63,6 +63,7 @@ pub fn invoke_remove_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi &deletion_entry.clone(), Some(deleted_entry_address.clone()), &context.clone(), + &vec![] )) .map(|_| ()); diff --git a/core/src/nucleus/ribosome/api/remove_link.rs b/core/src/nucleus/ribosome/api/remove_link.rs index 5e705e077a..1116f0c30f 100644 --- a/core/src/nucleus/ribosome/api/remove_link.rs +++ b/core/src/nucleus/ribosome/api/remove_link.rs @@ -38,7 +38,7 @@ pub fn invoke_remove_link(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApiR // Wait for future to be resolved let result: Result<(), HolochainError> = context - .block_on(author_entry(&entry, None, &context)) + .block_on(author_entry(&entry, None, &context, &vec![])) .map(|_| ()); runtime.store_result(result) diff --git a/core/src/nucleus/ribosome/api/update_entry.rs b/core/src/nucleus/ribosome/api/update_entry.rs index 1f0441ac84..6e286f2bcb 100644 --- a/core/src/nucleus/ribosome/api/update_entry.rs +++ b/core/src/nucleus/ribosome/api/update_entry.rs @@ -58,6 +58,7 @@ pub fn invoke_update_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi &entry, Some(latest_entry.clone().address()), &context.clone(), + &vec![] // TODO should provenance be a parameter? )) .map_err(|validation_error| HolochainError::from(validation_error)); diff --git a/core/src/workflows/author_entry.rs b/core/src/workflows/author_entry.rs index a68ff2a743..b2d1953129 100644 --- a/core/src/workflows/author_entry.rs +++ b/core/src/workflows/author_entry.rs @@ -13,13 +13,16 @@ use holochain_core_types::{ entry::Entry, error::HolochainError, validation::{EntryLifecycle, ValidationData}, + signature::Provenance, }; -use std::sync::Arc; + +use std::{vec::Vec, sync::Arc}; pub async fn author_entry<'a>( entry: &'a Entry, maybe_link_update_delete: Option
, context: &'a Arc, + provenances: &'a Vec ) -> Result { let address = entry.address(); context.log(format!( @@ -28,7 +31,8 @@ pub async fn author_entry<'a>( )); // 1. Build the context needed for validation of the entry - let validation_package = await!(build_validation_package(&entry, context.clone()))?; + let validation_package = await!( + build_validation_package(&entry, context.clone(), provenances))?; let validation_data = ValidationData { package: validation_package, lifecycle: EntryLifecycle::Chain, diff --git a/core/src/workflows/respond_validation_package_request.rs b/core/src/workflows/respond_validation_package_request.rs index 615011c520..e13f47b017 100644 --- a/core/src/workflows/respond_validation_package_request.rs +++ b/core/src/workflows/respond_validation_package_request.rs @@ -6,8 +6,8 @@ use crate::{ nucleus::actions::build_validation_package::build_validation_package, }; -use holochain_core_types::{cas::content::Address, entry::Entry, error::HolochainError}; -use std::{convert::TryFrom, sync::Arc}; +use holochain_core_types::{cas::content::Address, entry::Entry, error::HolochainError, signature::Provenance}; +use std::{convert::TryFrom, sync::Arc, vec::Vec}; fn get_entry(address: &Address, context: &Arc) -> Result { let raw = context @@ -31,9 +31,10 @@ pub async fn respond_validation_package_request( msg_id: String, requested_entry_address: Address, context: Arc, + provenances: &Vec ) { let maybe_validation_package = match get_entry(&requested_entry_address, &context) { - Ok(entry) => await!(build_validation_package(&entry, context.clone())).ok(), + Ok(entry) => await!(build_validation_package(&entry, context.clone(), provenances)).ok(), Err(_) => None, }; diff --git a/core_types/src/entry/mod.rs b/core_types/src/entry/mod.rs index 25d1b7e1c1..ebb2754ae3 100644 --- a/core_types/src/entry/mod.rs +++ b/core_types/src/entry/mod.rs @@ -25,6 +25,7 @@ use multihash::Hash; use serde::{ser::SerializeTuple, Deserialize, Deserializer, Serializer}; use snowflake; use std::convert::TryFrom; +use signature::Provenance; pub type AppEntryValue = JsonString; @@ -76,6 +77,29 @@ pub enum Entry { CapTokenGrant(CapTokenGrant), } +#[derive(Clone, Debug, Serialize, Deserialize, DefaultJson)] +pub struct EntryWithProvenance { + entry: Entry, + provenances: Vec +} + +impl EntryWithProvenance { + pub fn new(entry:Entry, provenances:Vec) -> Self { + EntryWithProvenance { + entry, + provenances + } + } + + pub fn entry(&self) -> Entry { + self.entry.clone() + } + + pub fn provenances(&self) -> Vec { + self.provenances.clone() + } +} + impl From> for JsonString { fn from(maybe_entry: Option) -> Self { default_to_json(maybe_entry) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 8bc41e74bb..b81691cf7c 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -1,11 +1,11 @@ -//! This file contains many of the structs, enums, and functions relevant for Zome + //! developers! Detailed references and examples can be found here for how to use the //! HDK exposed functions to access powerful Holochain functions. use crate::error::{ZomeApiError, ZomeApiResult}; use holochain_core_types::{ cas::content::Address, - entry::Entry, + entry::{Entry, EntryWithProvenance}, error::{RibosomeEncodedAllocation, RibosomeEncodingBits, ZomeApiInternalResult}, signature::Provenance, time::Timeout, @@ -140,6 +140,7 @@ macro_rules! def_api_fns { def_api_fns! { hc_init_globals, InitGlobals; hc_commit_entry, CommitEntry; + hc_commit_entry_with_provenance, CommitEntryWithProvenance; hc_get_entry, GetEntry; hc_entry_address, EntryAddress; hc_query, Query; @@ -364,6 +365,8 @@ pub enum BundleOnClose { /// # #[no_mangle] /// # pub fn hc_commit_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] +/// # pub fn hc_commit_entry_with_provenance(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } +/// # #[no_mangle] /// # pub fn hc_get_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] /// # pub fn hc_entry_address(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } @@ -462,6 +465,8 @@ pub enum BundleOnClose { /// # #[no_mangle] /// # pub fn hc_commit_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] +/// # pub fn hc_commit_entry_with_provenance(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } +/// # #[no_mangle] /// # pub fn hc_get_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] /// # pub fn hc_entry_address(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } @@ -632,6 +637,13 @@ pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ Dispatch::CommitEntry.with_input(entry) } +// TODO document (copy / mutate the above) +pub fn commit_entry_with_provenance( + entry_with_provenance: &EntryWithProvenance) -> ZomeApiResult
{ + Dispatch::CommitEntryWithProvenance.with_input(entry_with_provenance) +} + + /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using /// the specified address. /// Returns None if no entry exists at the specified address or From 17f9fb13847164eaec1902a2aeb12c4692e73fd5 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Wed, 24 Apr 2019 08:48:34 -0400 Subject: [PATCH 09/83] fixes and updates to hdk docs --- hdk-rust/src/api.rs | 111 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 22 deletions(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 8bc41e74bb..d1c201c440 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -336,14 +336,13 @@ pub enum BundleOnClose { //-------------------------------------------------------------------------------------------------- /// Call an exposed function from another zome or another (bridged) instance running -/// on the same agent in the same conductor. -/// Arguments for the called function are passed as `JsonString`. -/// Returns the value that's returned by the given function as a json str. +/// in the same conductor. +/// Arguments for the called function are passed and resturned as `JsonString`. /// # Examples -/// In order to utilize `call`, you must have at least two separate Zomes. -/// Here are two Zome examples, where one performs a `call` into the other. +/// Here are two example Zomes, where one performs a `call` into the other. /// -/// This first one, is the one that is called into, with the Zome name `summer`. +/// This first zome, is the "callee" i.e. the zome that receives the call, and is named name `summer` +/// because the call sums two numbers. /// ```rust /// # #![feature(try_from)] /// # #[macro_use] @@ -434,7 +433,7 @@ pub enum BundleOnClose { /// # } /// ``` /// -/// This second one, is the one that performs the call into the `summer` Zome. +/// This second zome is the "caller" that makes the call into the `summer` Zome. /// ```rust /// # #![feature(try_from)] /// # #[macro_use] @@ -555,7 +554,7 @@ pub fn call>( }) } -/// Prints a string through the stdout of the running service, and also +/// Prints a string through the stdout of the running conductor, and also /// writes that string to the logger in the execution context /// # Examples /// ```rust @@ -580,10 +579,10 @@ pub fn debug>(msg: J) -> ZomeApiResult<()> { Ok(()) } -/// Attempts to commit an entry to your local source chain. The entry -/// will have to pass the defined validation rules for that entry type. -/// If the entry type is defined as public, will also publish the entry to the DHT. -/// Returns either an address of the committed entry as a string, or an error. +/// Attempts to commit an entry to the local source chain. The entry +/// will also be checked against the defined validation rules for that entry type. +/// If the entry type is defined as public, it will also be published to the DHT. +/// Returns either an address of the committed entry, or an error. /// # Examples /// ```rust /// # #![feature(try_from)] @@ -635,7 +634,10 @@ pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using /// the specified address. /// Returns None if no entry exists at the specified address or -/// if the entry's crud-status is not LIVE. +/// if the entry's status DELETED. Note that if the entry was updated, the value retrieved +/// may be of the updated entry which will have a different hash value. If you need +/// to get the value what ever the status, use [get_entry_initial](fn.get_entry_initial.html), or if you need to know +/// the address of the updated entry use [get_entry_result](fn.get_entry_result.html) /// # Examples /// ```rust /// # extern crate hdk; @@ -666,7 +668,7 @@ pub fn get_entry(address: &Address) -> ZomeApiResult> { Ok(entry) } -/// Returns the Entry at the exact address specified, whatever its crud-status. +/// Returns the Entry at the exact address specified, whatever its status. /// Returns None if no entry exists at the specified address. pub fn get_entry_initial(address: &Address) -> ZomeApiResult> { let entry_result = get_entry_result( @@ -706,6 +708,7 @@ pub fn get_entry_result( }) } +/// Adds a named, directed link between two entries on the DHT. /// Consumes three values, two of which are the addresses of entries, and one of which is a string that defines a /// relationship between them, called a `tag`. Later, lists of entries can be looked up by using [get_links](fn.get_links.html). Entries /// can only be looked up in the direction from the `base`, which is the first argument, to the `target`. @@ -774,6 +777,7 @@ pub fn link_entries>( }) } +/// Marks a link as deleted. /// Consumes three values, two of which are the addresses of entries, and one of which is a string that removes a /// relationship between them, called a `tag`. Later, lists of entries. /// # Examples @@ -836,14 +840,57 @@ pub fn remove_link>( }) } -/// sign ( priv_id_str, base64payload ) -> ( base64signature ) +/// Signs a string payload using the agent's private key. +/// Returns the signature as a string. +/// # Examples +/// ```rust +/// # #![feature(try_from)] +/// # extern crate hdk; +/// # extern crate serde_json; +/// # #[macro_use] +/// # extern crate serde_derive; +/// # extern crate holochain_core_types; +/// # #[macro_use] +/// # extern crate holochain_core_types_derive; +/// # use holochain_core_types::json::JsonString; +/// # use holochain_core_types::error::HolochainError; +/// # use holochain_core_types::signature::{Provenance, Signature}; +/// # use hdk::error::ZomeApiResult; +/// # fn main() { +/// pub fn handle_sign_message(message: String) -> ZomeApiResult { +/// hdk::sign(message).map(Signature::from) +/// } +/// # } +/// ``` pub fn sign>(payload: S) -> ZomeApiResult { Dispatch::Sign.with_input(SignArgs { payload: payload.into(), }) } -/// sign_one_time ( priv_id_str, base64payloads ) -> ( base64signature ) +/// Signs a vector of payloads with a private key that is generated and shredded. +/// Returns the signatures of the payloads and the public key that can be used to verify the signatures. +/// # Examples +/// ```rust +/// # #![feature(try_from)] +/// # extern crate hdk; +/// # extern crate serde_json; +/// # #[macro_use] +/// # extern crate serde_derive; +/// # extern crate holochain_core_types; +/// # #[macro_use] +/// # extern crate holochain_core_types_derive; +/// # use holochain_core_types::json::JsonString; +/// # use holochain_core_types::error::HolochainError; +/// # use holochain_core_types::signature::{Provenance, Signature}; +/// # use hdk::error::ZomeApiResult; +/// # use hdk::holochain_wasm_utils::api_serialization::sign::{OneTimeSignArgs, SignOneTimeResult}; +/// # fn main() { +/// pub fn handle_one_time_sign(key_id: String, message: String) -> ZomeApiResult { +/// hdk::sign(message).map(Signature::from) +/// } +/// # } +/// ``` pub fn sign_one_time>(payloads: Vec) -> ZomeApiResult { let mut converted_payloads = Vec::new(); for p in payloads { @@ -854,12 +901,12 @@ pub fn sign_one_time>(payloads: Vec) -> ZomeApiResult ( Vec ) +/// Returns a list of the named secrets stored in the keystore. pub fn keystore_list() -> ZomeApiResult { Dispatch::KeystoreList.without_input() } -/// keystore_new_random ( dst_id, size ) -> ( () ) +/// Creates a new random "root" Seed secret in the keystore pub fn keystore_new_random>(dst_id: S, size: usize) -> ZomeApiResult<()> { Dispatch::KeystoreNewRandom.with_input(KeystoreNewRandomArgs { dst_id: dst_id.into(), @@ -867,7 +914,7 @@ pub fn keystore_new_random>(dst_id: S, size: usize) -> ZomeApiRe }) } -/// keystore_derive_seed ( ) -> ( () ) +/// Creates a new derived Seed secret in the keystore derived from on a previously defined seed pub fn keystore_derive_seed>( src_id: S, dst_id: S, @@ -882,7 +929,7 @@ pub fn keystore_derive_seed>( }) } -/// keystore_derive_key ( ) -> ( ) +/// Creates a new derived Key secret in the keystore derived from on a previously defined seed pub fn keystore_derive_key>( src_id: S, dst_id: S, @@ -895,7 +942,7 @@ pub fn keystore_derive_key>( }) } -/// keystore_sign ( ) -> ( ) +/// Signs a payload using a key from the keystore. pub fn keystore_sign>(src_id: S, payload: S) -> ZomeApiResult { Dispatch::KeystoreSign.with_input(KeystoreSignArgs { src_id: src_id.into(), @@ -956,7 +1003,27 @@ pub fn entry_address(entry: &Entry) -> ZomeApiResult
{ Dispatch::EntryAddress.with_input(entry) } -/// NOT YET AVAILABLE +/// Verifies that a provenance (public key, signature) against a payload +/// # Examples +/// ```rust +/// # #![feature(try_from)] +/// # extern crate hdk; +/// # extern crate serde_json; +/// # #[macro_use] +/// # extern crate serde_derive; +/// # extern crate holochain_core_types; +/// # #[macro_use] +/// # extern crate holochain_core_types_derive; +/// # use holochain_core_types::json::JsonString; +/// # use holochain_core_types::error::HolochainError; +/// # use holochain_core_types::signature::Provenance; +/// # use hdk::error::ZomeApiResult; +/// # fn main() { +/// pub fn handle_verify_message(message: String, provenance: Provenance) -> ZomeApiResult { +/// hdk::verify_signature(provenance, message) +/// } +/// # } +/// ``` pub fn verify_signature>( provenance: Provenance, payload: S, From bd8b1081f5d8d10e5967c8ea47f6ee64c9bc2f20 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 24 Apr 2019 10:33:06 -0400 Subject: [PATCH 10/83] Apply suggestions from code review Co-Authored-By: zippy --- hdk-rust/src/api.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index d11ea965b8..6cd79f39dd 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -346,7 +346,7 @@ pub enum BundleOnClose { /// # Examples /// Here are two example Zomes, where one performs a `call` into the other. /// -/// This first zome, is the "callee" i.e. the zome that receives the call, and is named name `summer` +/// This first zome, is the "callee" i.e. the zome that receives the call, and is named `summer` /// because the call sums two numbers. /// ```rust /// # #![feature(try_from)] @@ -563,7 +563,7 @@ pub fn call>( }) } -/// Prints a string through the stdout of the running conductor, and also +/// Prints a string through the stdout of the running Conductor, and also /// writes that string to the logger in the execution context /// # Examples /// ```rust From 91c101423bc142e8f03453a2881dbdae152845f7 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Wed, 24 Apr 2019 10:39:00 -0400 Subject: [PATCH 11/83] updates per review request --- hdk-rust/src/api.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 6cd79f39dd..7539a3a1fe 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -786,7 +786,8 @@ pub fn link_entries>( }) } -/// Marks a link as deleted. +/// Commits a LinkRemove entry to your local source chain that marks a link as 'deleted' by setting +/// its status metadata to `Deleted` which gets published to the DHT. /// Consumes three values, two of which are the addresses of entries, and one of which is a string that removes a /// relationship between them, called a `tag`. Later, lists of entries. /// # Examples @@ -1061,9 +1062,8 @@ pub fn update_agent() -> ZomeApiResult
{ Err(ZomeApiError::FunctionNotImplemented) } -/// Commit a DeletionEntry to your local source chain that marks an entry as 'deleted' by setting -/// its status metadata to `Deleted` and adding the DeleteEntry's address in the deleted entry's -/// metadata, which will be used by validation routes. +/// Commit a Deletion entry to your local source chain that marks an entry as 'deleted' by setting +/// its status metadata to `Deleted` which gets propagated to the DHT. pub fn remove_entry(address: &Address) -> ZomeApiResult<()> { Dispatch::RemoveEntry.with_input(address.to_owned()) } From e770280439eaa8d05f327ee84acff0bf79e1ff20 Mon Sep 17 00:00:00 2001 From: Paul d'Aoust Date: Wed, 24 Apr 2019 13:49:06 -0400 Subject: [PATCH 12/83] Apply suggestions from code review Co-Authored-By: zippy --- hdk-rust/src/api.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 7539a3a1fe..ebbfc4f1e1 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -346,7 +346,7 @@ pub enum BundleOnClose { /// # Examples /// Here are two example Zomes, where one performs a `call` into the other. /// -/// This first zome, is the "callee" i.e. the zome that receives the call, and is named `summer` +/// This first zome is the "callee"; i.e., the zome that receives the call, and is named `summer`. /// because the call sums two numbers. /// ```rust /// # #![feature(try_from)] @@ -643,9 +643,9 @@ pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using /// the specified address. /// Returns None if no entry exists at the specified address or -/// if the entry's status DELETED. Note that if the entry was updated, the value retrieved +/// if the entry's status is DELETED. Note that if the entry was updated, the value retrieved /// may be of the updated entry which will have a different hash value. If you need -/// to get the value what ever the status, use [get_entry_initial](fn.get_entry_initial.html), or if you need to know +/// to get the original value whatever the status, use [get_entry_initial](fn.get_entry_initial.html), or if you need to know /// the address of the updated entry use [get_entry_result](fn.get_entry_result.html) /// # Examples /// ```rust @@ -924,7 +924,8 @@ pub fn keystore_new_random>(dst_id: S, size: usize) -> ZomeApiRe }) } -/// Creates a new derived Seed secret in the keystore derived from on a previously defined seed +/// Creates a new derived seed secret in the keystore, derived from a previously defined seed. +/// Accepts two arguments: the keystore ID of the previously defined seed, and a keystore ID for the newly derived seed. pub fn keystore_derive_seed>( src_id: S, dst_id: S, @@ -939,7 +940,8 @@ pub fn keystore_derive_seed>( }) } -/// Creates a new derived Key secret in the keystore derived from on a previously defined seed +/// Creates a new derived key secret in the keystore derived from on a previously defined seed. +/// Accepts two arguments: the keystore ID of the previously defined seed, and a keystore ID for the newly derived key. pub fn keystore_derive_key>( src_id: S, dst_id: S, @@ -952,7 +954,8 @@ pub fn keystore_derive_key>( }) } -/// Signs a payload using a key from the keystore. +/// Signs a payload using a private key from the keystore. +/// Accepts one argument: the keystore ID of the desired private key. pub fn keystore_sign>(src_id: S, payload: S) -> ZomeApiResult { Dispatch::KeystoreSign.with_input(KeystoreSignArgs { src_id: src_id.into(), From 593111eca1fa3ca5bca3211130695b849ba6503a Mon Sep 17 00:00:00 2001 From: carm Date: Wed, 24 Apr 2019 14:40:52 -0400 Subject: [PATCH 13/83] Make tests compile again --- core/src/action.rs | 2 +- core/src/agent/state.rs | 2 +- core/src/instance.rs | 11 ++--- core/src/link_tests.rs | 9 ++-- core/src/network/mod.rs | 2 +- .../actions/build_validation_package.rs | 4 ++ .../src/nucleus/actions/call_zome_function.rs | 2 +- core/src/nucleus/ribosome/api/call.rs | 6 +-- core/src/nucleus/ribosome/api/commit.rs | 41 +++++++++++++++++-- core/src/nucleus/ribosome/api/mod.rs | 7 +++- core/src/workflows/author_entry.rs | 1 + nodejs_waiter/src/waiter.rs | 24 +++++------ 12 files changed, 78 insertions(+), 33 deletions(-) diff --git a/core/src/action.rs b/core/src/action.rs index c3e1d8142e..2430f39fe9 100644 --- a/core/src/action.rs +++ b/core/src/action.rs @@ -314,7 +314,7 @@ pub mod tests { /// dummy action wrapper with commit of test_entry() pub fn test_action_wrapper_commit() -> ActionWrapper { - ActionWrapper::new(Action::Commit((test_entry(), None))) + ActionWrapper::new(Action::Commit((test_entry(), None, vec![]))) } /// dummy action for a get of test_hash() diff --git a/core/src/agent/state.rs b/core/src/agent/state.rs index 1f102eae03..766e41139a 100644 --- a/core/src/agent/state.rs +++ b/core/src/agent/state.rs @@ -414,7 +414,7 @@ pub mod tests { .set_state(Arc::new(RwLock::new(state))); let header = create_new_chain_header(&test_entry(), context.clone(), &None, - vec![]).unwrap(); + &vec![]).unwrap(); println!("{:?}", header); assert_eq!( header, diff --git a/core/src/instance.rs b/core/src/instance.rs index cfca7c752e..b14d9f535a 100644 --- a/core/src/instance.rs +++ b/core/src/instance.rs @@ -535,7 +535,7 @@ pub mod tests { .history .iter() .find(|aw| match aw.action() { - Action::Commit((entry, _)) => { + Action::Commit((entry, _, _)) => { assert!( entry.entry_type() == EntryType::AgentId || entry.entry_type() == EntryType::Dna @@ -734,7 +734,7 @@ pub mod tests { let context = test_context("alex", netname); let dna = test_utils::create_test_dna_with_wat("test_zome", None); let dna_entry = Entry::Dna(Box::new(dna)); - let commit_action = ActionWrapper::new(Action::Commit((dna_entry.clone(), None))); + let commit_action = ActionWrapper::new(Action::Commit((dna_entry.clone(), None, vec![]))); // Set up instance and process the action let instance = Instance::new(test_context("jason", netname)); @@ -750,7 +750,7 @@ pub mod tests { .history .iter() .find(|aw| match aw.action() { - Action::Commit((entry, _)) => { + Action::Commit((entry, _, _)) => { assert_eq!(entry.entry_type(), EntryType::Dna); assert_eq!(entry.content(), dna_entry.content()); true @@ -766,7 +766,8 @@ pub mod tests { // Create Context, Agent and Commit AgentIdEntry Action let context = test_context("alex", netname); let agent_entry = Entry::AgentId(context.agent_id.clone()); - let commit_agent_action = ActionWrapper::new(Action::Commit((agent_entry.clone(), None))); + let commit_agent_action = ActionWrapper::new( + Action::Commit((agent_entry.clone(), None, vec![]))); // Set up instance and process the action let instance = Instance::new(context.clone()); @@ -782,7 +783,7 @@ pub mod tests { .history .iter() .find(|aw| match aw.action() { - Action::Commit((entry, _)) => { + Action::Commit((entry, _, _)) => { assert_eq!(entry.entry_type(), EntryType::AgentId); assert_eq!(entry.content(), agent_entry.content()); true diff --git a/core/src/link_tests.rs b/core/src/link_tests.rs index 6c8494a6db..eb293701c0 100644 --- a/core/src/link_tests.rs +++ b/core/src/link_tests.rs @@ -52,7 +52,8 @@ pub mod tests { let link = create_example_link(); let link_list = LinkList::new(&[link]); let link_list_entry = Entry::LinkList(link_list); - let commit_action = ActionWrapper::new(Action::Commit((link_list_entry.clone(), None))); + let commit_action = + ActionWrapper::new(Action::Commit((link_list_entry.clone(), None, vec![]))); // Set up instance and process the action let instance = Instance::new(test_context("jason", netname)); let state_observers: Vec = Vec::new(); @@ -66,7 +67,7 @@ pub mod tests { .history .iter() .find(|aw| match aw.action() { - Action::Commit((entry, _)) => { + Action::Commit((entry, _, _)) => { assert_eq!(entry.entry_type(), EntryType::LinkList,); assert_eq!(entry.content(), link_list_entry.content()); true @@ -86,7 +87,7 @@ pub mod tests { let link_c = create_test_link_c(); let link_list = LinkList::new(&[link_a, link_b, link_c]); let link_list_entry = Entry::LinkList(link_list.clone()); - let commit_action = ActionWrapper::new(Action::Commit((link_list_entry.clone(), None))); + let commit_action = ActionWrapper::new(Action::Commit((link_list_entry.clone(), None, vec![]))); println!("commit_multilink: {:?}", commit_action); // Set up instance and process the action let instance = Instance::new(test_context("jason", netname)); @@ -101,7 +102,7 @@ pub mod tests { .history .iter() .find(|aw| match aw.action() { - Action::Commit((entry, _)) => { + Action::Commit((entry, _, _)) => { assert_eq!(entry.entry_type(), EntryType::LinkList,); assert_eq!(entry.content(), link_list_entry.content()); true diff --git a/core/src/network/mod.rs b/core/src/network/mod.rs index 9e92f96551..fabdf53837 100644 --- a/core/src/network/mod.rs +++ b/core/src/network/mod.rs @@ -199,7 +199,7 @@ pub mod tests { let entry = test_entry(); context1 - .block_on(author_entry(&entry, None, &context1)) + .block_on(author_entry(&entry, None, &context1, &vec![])) .expect("Could not author entry"); let agent1_state = context1.state().unwrap().agent(); diff --git a/core/src/nucleus/actions/build_validation_package.rs b/core/src/nucleus/actions/build_validation_package.rs index 61185cf234..94e1a4ea70 100644 --- a/core/src/nucleus/actions/build_validation_package.rs +++ b/core/src/nucleus/actions/build_validation_package.rs @@ -232,6 +232,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_entry(), context.clone(), + &vec![] )); println!("{:?}", maybe_validation_package); assert!(maybe_validation_package.is_ok()); @@ -260,6 +261,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_entries(), context.clone(), + &vec![] )); println!("{:?}", maybe_validation_package); assert!(maybe_validation_package.is_ok()); @@ -288,6 +290,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_headers(), context.clone(), + &vec![] )); assert!(maybe_validation_package.is_ok()); @@ -315,6 +318,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_full(), context.clone(), + &vec![] )); assert!(maybe_validation_package.is_ok()); diff --git a/core/src/nucleus/actions/call_zome_function.rs b/core/src/nucleus/actions/call_zome_function.rs index 1d1dda38d8..ed7cf1827f 100644 --- a/core/src/nucleus/actions/call_zome_function.rs +++ b/core/src/nucleus/actions/call_zome_function.rs @@ -381,7 +381,7 @@ pub mod tests { .unwrap(); let grant_entry = Entry::CapTokenGrant(grant.clone()); let grant_addr = context - .block_on(author_entry(&grant_entry, None, &context)) + .block_on(author_entry(&grant_entry, None, &context, &vec![])) .unwrap(); let maybe_grant = get_grant(&context, &grant_addr); assert_eq!(maybe_grant, Some(grant)); diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 76fbbbb188..d6f627a41e 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -328,7 +328,7 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let addr = test_setup .context - .block_on(author_entry(&grant_entry, None, &test_setup.context)) + .block_on(author_entry(&grant_entry, None, &test_setup.context, &vec![])) .unwrap(); let other_agent_context = test_context("other agent", None); let cap_request = @@ -373,7 +373,7 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let grant_addr = test_setup .context - .block_on(author_entry(&grant_entry, None, &test_setup.context)) + .block_on(author_entry(&grant_entry, None, &test_setup.context, &vec![])) .unwrap(); let cap_request = make_cap_request_for_call( test_context("random other agent", None), @@ -485,7 +485,7 @@ pub mod tests { .unwrap(); let grant_entry = Entry::CapTokenGrant(grant); let grant_addr = context - .block_on(author_entry(&grant_entry, None, &context)) + .block_on(author_entry(&grant_entry, None, &context, &vec![])) .unwrap(); // make the call with a valid capability call from a random source should succeed diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 2aba3c2f46..a4d286f651 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -33,9 +33,9 @@ pub fn invoke_commit_app_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> Zom runtime.store_result(task_result) } -/// ZomeApiFunction::CommitAppEntry function code +/// ZomeApiFunction::CommitAppEntryWithProvenance function code /// args: [0] encoded MemoryAllocation as u64 -/// Expected complex argument: CommitWithProvenanceArgs +/// Expected complex argument: EntryWithProvenance /// Returns an HcApiReturnCode as I64 pub fn invoke_commit_app_entry_with_provenance( runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApiResult { @@ -48,7 +48,7 @@ pub fn invoke_commit_app_entry_with_provenance( // Exit on error Err(_) => { context.log(format!( - "err/zome: invoke_commit_app_entry failed to deserialize Entry: {:?}", + "err/zome: invoke_commit_app_entry_with_provenance failed to deserialize Entry: {:?}", args_str )); return ribosome_error_code!(ArgumentDeserializationFailed); @@ -66,15 +66,17 @@ pub fn invoke_commit_app_entry_with_provenance( #[cfg(test)] pub mod tests { + use super::*; use crate::nucleus::ribosome::{ api::{tests::test_zome_api_function, ZomeApiFunction}, Defn, }; use holochain_core_types::{ - cas::content::Address, + cas::content::{Address, AddressableContent}, entry::{test_entry, Entry}, error::ZomeApiInternalResult, json::JsonString, + signature::{test_signature, Provenance}, }; /// dummy commit args from standard test entry @@ -85,6 +87,17 @@ pub mod tests { JsonString::from(serialized_entry).to_bytes() } + /// dummy commit args from standard test entry + pub fn test_commit_with_provenance_args_bytes() -> Vec { + let entry = test_entry(); + let address : Address = entry.address(); + let signature = test_signature(); + let provenances = vec![Provenance::new(address, signature)]; + let serialized_entry_with_provenance = + EntryWithProvenance::new(entry, provenances); + JsonString::from(serialized_entry_with_provenance).to_bytes() + } + #[test] /// test that we can round trip bytes through a commit action and get the result from WASM fn test_commit_round_trip() { @@ -102,4 +115,24 @@ pub mod tests { ), ); } + + #[test] + /// test that we can round trip bytes through a commit action with + /// additional provenance and get the result from WASM + fn test_commit_with_provenance_round_trip() { + let (call_result, _) = test_zome_api_function( + ZomeApiFunction::CommitAppEntryWithProvenance.as_str(), + test_commit_with_provenance_args_bytes(), + ); + + assert_eq!( + call_result, + JsonString::from_json( + &(String::from(JsonString::from(ZomeApiInternalResult::success( + Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq") + ))) + "\u{0}") + ), + ); + } + } diff --git a/core/src/nucleus/ribosome/api/mod.rs b/core/src/nucleus/ribosome/api/mod.rs index 6d7fda76ba..f8660bebfe 100644 --- a/core/src/nucleus/ribosome/api/mod.rs +++ b/core/src/nucleus/ribosome/api/mod.rs @@ -24,7 +24,7 @@ pub mod verify_signature; use crate::nucleus::ribosome::{ api::{ call::invoke_call, - commit::invoke_commit_app_entry, + commit::{invoke_commit_app_entry, invoke_commit_app_entry_with_provenance}, debug::invoke_debug, entry_address::invoke_entry_address, get_entry::invoke_get_entry, @@ -67,6 +67,11 @@ link_zome_api! { /// commit_entry(entry_type: String, entry_value: String) -> Address "hc_commit_entry", CommitAppEntry, invoke_commit_app_entry; + /// Commit an app entry to source chain + /// commit_entry(entry_type: String, entry_value: String) -> Address + "hc_commit_entry_with_provenance", CommitAppEntryWithProvenance, invoke_commit_app_entry_with_provenance; + + /// Get an app entry from source chain by key (header hash) /// get_entry(address: Address) -> Entry "hc_get_entry", GetAppEntry, invoke_get_entry; diff --git a/core/src/workflows/author_entry.rs b/core/src/workflows/author_entry.rs index b2d1953129..5c30f30ef7 100644 --- a/core/src/workflows/author_entry.rs +++ b/core/src/workflows/author_entry.rs @@ -107,6 +107,7 @@ pub mod tests { &test_entry_with_value("{\"stuff\":\"test entry value\"}"), None, &context1, + &vec![] )) .unwrap(); thread::sleep(time::Duration::from_millis(500)); diff --git a/nodejs_waiter/src/waiter.rs b/nodejs_waiter/src/waiter.rs index 67115df037..b9c42486e0 100644 --- a/nodejs_waiter/src/waiter.rs +++ b/nodejs_waiter/src/waiter.rs @@ -178,7 +178,7 @@ impl Waiter { } }, - (Some(checker), Action::Commit((committed_entry, link_update_delete))) => { + (Some(checker), Action::Commit((committed_entry, link_update_delete, _provenances))) => { // Pair every `Commit` with N `Hold`s of that same entry, regardless of type // TODO: is there a possiblity that this can get messed up if the same // entry is committed multiple times? @@ -471,7 +471,7 @@ mod tests { assert_eq!(waiter.checkers.len(), 1); assert_eq!(num_conditions(&waiter, &call), 1); - waiter.process_signal(sig(Commit((entry.clone(), None)))); + waiter.process_signal(sig(Commit((entry.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call), 2); waiter.process_signal(sig(Hold(entry_wh))); @@ -500,10 +500,10 @@ mod tests { assert_eq!(waiter.checkers.len(), 1); assert_eq!(num_conditions(&waiter, &call), 1); - waiter.process_signal(sig(Commit((entry_1.clone(), None)))); + waiter.process_signal(sig(Commit((entry_1.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call), 2); - waiter.process_signal(sig(Commit((entry_2.clone(), None)))); + waiter.process_signal(sig(Commit((entry_2.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call), 3); waiter.process_signal(sig(ReturnZomeFunctionResult(zf_response(call.clone())))); @@ -537,7 +537,7 @@ mod tests { assert_eq!(waiter.checkers.len(), 0); waiter.process_signal(sig(SignalZomeFunctionCall(call_1.clone()))); assert_eq!(waiter.checkers.len(), 0); - waiter.process_signal(sig(Commit((entry_1.clone(), None)))); + waiter.process_signal(sig(Commit((entry_1.clone(), None, vec![])))); waiter.process_signal(sig(ReturnZomeFunctionResult(zf_response(call_1.clone())))); assert_eq!(waiter.checkers.len(), 0); // no checkers should be registered during any of this @@ -551,10 +551,10 @@ mod tests { assert_eq!(waiter.checkers.len(), 1); assert_eq!(num_conditions(&waiter, &call_2), 1); - waiter.process_signal(sig(Commit((entry_2.clone(), None)))); + waiter.process_signal(sig(Commit((entry_2.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call_2), 2); - waiter.process_signal(sig(Commit((entry_3.clone(), None)))); + waiter.process_signal(sig(Commit((entry_3.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call_2), 3); // a Hold left over from that first unregistered function: should do nothing @@ -567,7 +567,7 @@ mod tests { assert_eq!(waiter.checkers.len(), 1); waiter.process_signal(sig(SignalZomeFunctionCall(call_3.clone()))); assert_eq!(waiter.checkers.len(), 1); - waiter.process_signal(sig(Commit((entry_4.clone(), None)))); + waiter.process_signal(sig(Commit((entry_4.clone(), None, vec![])))); waiter.process_signal(sig(ReturnZomeFunctionResult(zf_response(call_3.clone())))); assert_eq!(waiter.checkers.len(), 1); // again, shouldn't change things at all @@ -604,7 +604,7 @@ mod tests { assert_eq!(num_conditions(&waiter, &call), 1); // this adds two actions to await - waiter.process_signal(sig(Commit((entry.clone(), None)))); + waiter.process_signal(sig(Commit((entry.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call), 3); waiter.process_signal(sig(Hold(entry_wh))); @@ -639,7 +639,7 @@ mod tests { assert_eq!(waiter.checkers.len(), 1); assert_eq!(num_conditions(&waiter, &call_1), 1); - waiter.process_signal(sig(Commit((entry_1.clone(), None)))); + waiter.process_signal(sig(Commit((entry_1.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call_1), 2); waiter.process_signal(sig(ReturnZomeFunctionResult(zf_response(call_1.clone())))); @@ -654,10 +654,10 @@ mod tests { assert_eq!(waiter.checkers.len(), 2); assert_eq!(num_conditions(&waiter, &call_2), 1); - waiter.process_signal(sig(Commit((entry_2.clone(), None)))); + waiter.process_signal(sig(Commit((entry_2.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call_2), 2); - waiter.process_signal(sig(Commit((entry_3.clone(), None)))); + waiter.process_signal(sig(Commit((entry_3.clone(), None, vec![])))); assert_eq!(num_conditions(&waiter, &call_2), 3); expect_final(control_rx_1, || { From b0a27fb7eac4803e00e07626e6cf8a31dd5aba3b Mon Sep 17 00:00:00 2001 From: neonphog Date: Wed, 24 Apr 2019 16:50:06 -0600 Subject: [PATCH 14/83] allow n3h to shutdown gracefully --- net/Cargo.toml | 1 + net/src/ipc/spawn.rs | 7 +++++++ net/src/lib.rs | 1 + 3 files changed, 9 insertions(+) diff --git a/net/Cargo.toml b/net/Cargo.toml index 5a7d081eaa..28e9425a0f 100644 --- a/net/Cargo.toml +++ b/net/Cargo.toml @@ -14,6 +14,7 @@ holochain_common = { path = "../common" } holochain_core_types = { path = "../core_types" } holochain_core_types_derive = { path = "../core_types_derive" } lazy_static = "=1.2.0" +libc = "=0.2.50" reqwest = "=0.9.11" sha2 = "=0.8.0" serde = "=1.0.89" diff --git a/net/src/ipc/spawn.rs b/net/src/ipc/spawn.rs index c71301e008..f4a492ecf5 100644 --- a/net/src/ipc/spawn.rs +++ b/net/src/ipc/spawn.rs @@ -149,6 +149,13 @@ pub fn ipc_spawn( // Set shutdown function to kill the sub-process out.kill = Some(Box::new(move || { + unsafe { + if libc::kill(child.id() as i32, libc::SIGTERM) == 0 { + libc::waitpid(child.id() as i32, std::ptr::null_mut(), 0); + kill_child(&real_pid); + return + } + } match child.kill() { Ok(()) => kill_child(&real_pid), Err(e) => println!("failed to kill ipc sub-process: {:?}", e), diff --git a/net/src/lib.rs b/net/src/lib.rs index 0de64e1783..350990395c 100644 --- a/net/src/lib.rs +++ b/net/src/lib.rs @@ -14,6 +14,7 @@ extern crate holochain_common; pub extern crate holochain_core_types_derive; #[macro_use] extern crate lazy_static; +extern crate libc; extern crate directories; extern crate reqwest; extern crate sha2; From f9c3c7d7d871ef257b1b6dcf72de6f672012cffb Mon Sep 17 00:00:00 2001 From: carm Date: Wed, 24 Apr 2019 23:54:27 -0400 Subject: [PATCH 15/83] Fix some test errors. --- core/src/action.rs | 2 +- core/src/agent/actions/commit.rs | 8 ++-- core/src/agent/state.rs | 33 +++++++------ core/src/instance.rs | 4 +- core/src/link_tests.rs | 5 +- .../actions/build_validation_package.rs | 10 ++-- core/src/nucleus/ribosome/api/call.rs | 14 +++++- core/src/nucleus/ribosome/api/commit.rs | 46 ++++++++++++------- core/src/nucleus/ribosome/api/remove_entry.rs | 2 +- core/src/nucleus/ribosome/api/update_entry.rs | 2 +- core/src/workflows/author_entry.rs | 15 +++--- .../respond_validation_package_request.rs | 13 ++++-- core_types/src/entry/mod.rs | 11 ++--- core_types/src/signature.rs | 4 ++ hdk-rust/src/api.rs | 5 +- nodejs_waiter/src/waiter.rs | 5 +- 16 files changed, 111 insertions(+), 68 deletions(-) diff --git a/core/src/action.rs b/core/src/action.rs index 2430f39fe9..ce5c7aa990 100644 --- a/core/src/action.rs +++ b/core/src/action.rs @@ -20,8 +20,8 @@ use holochain_core_types::{ entry::{Entry, EntryWithMetaAndHeader}, error::HolochainError, link::Link, - validation::ValidationPackage, signature::Provenance, + validation::ValidationPackage, }; use holochain_net::{ connection::json_protocol::{ diff --git a/core/src/agent/actions/commit.rs b/core/src/agent/actions/commit.rs index cc81119a27..7a9b054445 100644 --- a/core/src/agent/actions/commit.rs +++ b/core/src/agent/actions/commit.rs @@ -22,9 +22,11 @@ pub async fn commit_entry( maybe_link_update_delete: Option
, context: &Arc, ) -> Result { - let action_wrapper = - ActionWrapper::new(Action::Commit((entry.clone(), maybe_link_update_delete, - vec![]))); + let action_wrapper = ActionWrapper::new(Action::Commit(( + entry.clone(), + maybe_link_update_delete, + vec![], + ))); dispatch_action(context.action_channel(), action_wrapper.clone()); await!(CommitFuture { context: context.clone(), diff --git a/core/src/agent/state.rs b/core/src/agent/state.rs index 766e41139a..ba020a5690 100644 --- a/core/src/agent/state.rs +++ b/core/src/agent/state.rs @@ -163,7 +163,7 @@ pub fn create_new_chain_header( entry: &Entry, context: Arc, crud_link: &Option
, - provenances: &Vec + provenances: &Vec, ) -> Result { let agent_state = context .state() @@ -219,17 +219,22 @@ fn reduce_commit_entry( let action = action_wrapper.action(); let (entry, maybe_link_update_delete, provenances) = unwrap_to!(action => Action::Commit); - let result = create_new_chain_header(&entry, context.clone(), &maybe_link_update_delete, provenances) - .and_then(|chain_header| { - let storage = &state.chain_store.content_storage().clone(); - storage.write().unwrap().add(entry)?; - storage.write().unwrap().add(&chain_header)?; - Ok((chain_header, entry.address())) - }) - .and_then(|(chain_header, address)| { - state.top_chain_header = Some(chain_header); - Ok(address) - }); + let result = create_new_chain_header( + &entry, + context.clone(), + &maybe_link_update_delete, + provenances, + ) + .and_then(|chain_header| { + let storage = &state.chain_store.content_storage().clone(); + storage.write().unwrap().add(entry)?; + storage.write().unwrap().add(&chain_header)?; + Ok((chain_header, entry.address())) + }) + .and_then(|(chain_header, address)| { + state.top_chain_header = Some(chain_header); + Ok(address) + }); state .actions @@ -413,8 +418,8 @@ pub mod tests { .unwrap() .set_state(Arc::new(RwLock::new(state))); - let header = create_new_chain_header(&test_entry(), context.clone(), &None, - &vec![]).unwrap(); + let header = + create_new_chain_header(&test_entry(), context.clone(), &None, &vec![]).unwrap(); println!("{:?}", header); assert_eq!( header, diff --git a/core/src/instance.rs b/core/src/instance.rs index b14d9f535a..dff72a71a8 100644 --- a/core/src/instance.rs +++ b/core/src/instance.rs @@ -766,8 +766,8 @@ pub mod tests { // Create Context, Agent and Commit AgentIdEntry Action let context = test_context("alex", netname); let agent_entry = Entry::AgentId(context.agent_id.clone()); - let commit_agent_action = ActionWrapper::new( - Action::Commit((agent_entry.clone(), None, vec![]))); + let commit_agent_action = + ActionWrapper::new(Action::Commit((agent_entry.clone(), None, vec![]))); // Set up instance and process the action let instance = Instance::new(context.clone()); diff --git a/core/src/link_tests.rs b/core/src/link_tests.rs index eb293701c0..62ae07a231 100644 --- a/core/src/link_tests.rs +++ b/core/src/link_tests.rs @@ -52,7 +52,7 @@ pub mod tests { let link = create_example_link(); let link_list = LinkList::new(&[link]); let link_list_entry = Entry::LinkList(link_list); - let commit_action = + let commit_action = ActionWrapper::new(Action::Commit((link_list_entry.clone(), None, vec![]))); // Set up instance and process the action let instance = Instance::new(test_context("jason", netname)); @@ -87,7 +87,8 @@ pub mod tests { let link_c = create_test_link_c(); let link_list = LinkList::new(&[link_a, link_b, link_c]); let link_list_entry = Entry::LinkList(link_list.clone()); - let commit_action = ActionWrapper::new(Action::Commit((link_list_entry.clone(), None, vec![]))); + let commit_action = + ActionWrapper::new(Action::Commit((link_list_entry.clone(), None, vec![]))); println!("commit_multilink: {:?}", commit_action); // Set up instance and process the action let instance = Instance::new(test_context("jason", netname)); diff --git a/core/src/nucleus/actions/build_validation_package.rs b/core/src/nucleus/actions/build_validation_package.rs index 94e1a4ea70..f1f53447c1 100644 --- a/core/src/nucleus/actions/build_validation_package.rs +++ b/core/src/nucleus/actions/build_validation_package.rs @@ -15,8 +15,8 @@ use holochain_core_types::{ chain_header::ChainHeader, entry::{entry_type::EntryType, Entry}, error::HolochainError, - validation::{ValidationPackage, ValidationPackageDefinition::*}, signature::Provenance, + validation::{ValidationPackage, ValidationPackageDefinition::*}, }; use snowflake; use std::{convert::TryInto, pin::Pin, sync::Arc, thread, vec::Vec}; @@ -232,7 +232,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_entry(), context.clone(), - &vec![] + &vec![], )); println!("{:?}", maybe_validation_package); assert!(maybe_validation_package.is_ok()); @@ -261,7 +261,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_entries(), context.clone(), - &vec![] + &vec![], )); println!("{:?}", maybe_validation_package); assert!(maybe_validation_package.is_ok()); @@ -290,7 +290,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_headers(), context.clone(), - &vec![] + &vec![], )); assert!(maybe_validation_package.is_ok()); @@ -318,7 +318,7 @@ mod tests { let maybe_validation_package = context.block_on(build_validation_package( &test_entry_package_chain_full(), context.clone(), - &vec![] + &vec![], )); assert!(maybe_validation_package.is_ok()); diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index d6f627a41e..ab03128b11 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -328,7 +328,12 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let addr = test_setup .context - .block_on(author_entry(&grant_entry, None, &test_setup.context, &vec![])) + .block_on(author_entry( + &grant_entry, + None, + &test_setup.context, + &vec![], + )) .unwrap(); let other_agent_context = test_context("other agent", None); let cap_request = @@ -373,7 +378,12 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let grant_addr = test_setup .context - .block_on(author_entry(&grant_entry, None, &test_setup.context, &vec![])) + .block_on(author_entry( + &grant_entry, + None, + &test_setup.context, + &vec![], + )) .unwrap(); let cap_request = make_cap_request_for_call( test_context("random other agent", None), diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index a4d286f651..45f480be9d 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -2,8 +2,11 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::author_entry::author_entry, }; -use holochain_core_types::{cas::content::Address, - entry::{Entry, EntryWithProvenance}, error::HolochainError}; +use holochain_core_types::{ + cas::content::Address, + entry::{Entry, EntryWithProvenance}, + error::HolochainError, +}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; @@ -38,12 +41,13 @@ pub fn invoke_commit_app_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> Zom /// Expected complex argument: EntryWithProvenance /// Returns an HcApiReturnCode as I64 pub fn invoke_commit_app_entry_with_provenance( - runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApiResult { + runtime: &mut Runtime, + args: &RuntimeArgs, +) -> ZomeApiResult { let context = runtime.context()?; // deserialize args let args_str = runtime.load_json_string_from_args(&args); - let entry_with_provenance = - match EntryWithProvenance::try_from(args_str.clone()) { + let entry_with_provenance = match EntryWithProvenance::try_from(args_str.clone()) { Ok(entry_with_provenance_input) => entry_with_provenance_input, // Exit on error Err(_) => { @@ -55,15 +59,16 @@ pub fn invoke_commit_app_entry_with_provenance( } }; // Wait for future to be resolved - let task_result: Result = - context.block_on(author_entry( - &entry_with_provenance.entry(), None, &context, - &entry_with_provenance.provenances())); + let task_result: Result = context.block_on(author_entry( + &entry_with_provenance.entry(), + None, + &context, + &entry_with_provenance.provenances(), + )); runtime.store_result(task_result) } - #[cfg(test)] pub mod tests { use super::*; @@ -76,7 +81,7 @@ pub mod tests { entry::{test_entry, Entry}, error::ZomeApiInternalResult, json::JsonString, - signature::{test_signature, Provenance}, + signature::{Provenance, Signature}, }; /// dummy commit args from standard test entry @@ -87,14 +92,21 @@ pub mod tests { JsonString::from(serialized_entry).to_bytes() } - /// dummy commit args from standard test entry + /// dummy commit with provenance args from standard test entry pub fn test_commit_with_provenance_args_bytes() -> Vec { let entry = test_entry(); - let address : Address = entry.address(); - let signature = test_signature(); - let provenances = vec![Provenance::new(address, signature)]; - let serialized_entry_with_provenance = - EntryWithProvenance::new(entry, provenances); + let address: Address = entry.address(); + + let agent_nick = "counter-signer"; + let agent_id = test_utils::mock_signing::registered_test_agent(agent_nick); + + let signature = Signature::from(test_utils::mock_signing::mock_signer( + address.clone().into(), + &agent_id, + )); + + let provenances = vec![Provenance::new(agent_id.address(), signature)]; + let serialized_entry_with_provenance = EntryWithProvenance::new(entry, provenances); JsonString::from(serialized_entry_with_provenance).to_bytes() } diff --git a/core/src/nucleus/ribosome/api/remove_entry.rs b/core/src/nucleus/ribosome/api/remove_entry.rs index a169ae0820..0593461169 100644 --- a/core/src/nucleus/ribosome/api/remove_entry.rs +++ b/core/src/nucleus/ribosome/api/remove_entry.rs @@ -63,7 +63,7 @@ pub fn invoke_remove_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi &deletion_entry.clone(), Some(deleted_entry_address.clone()), &context.clone(), - &vec![] + &vec![], )) .map(|_| ()); diff --git a/core/src/nucleus/ribosome/api/update_entry.rs b/core/src/nucleus/ribosome/api/update_entry.rs index 6e286f2bcb..9af50e9a8d 100644 --- a/core/src/nucleus/ribosome/api/update_entry.rs +++ b/core/src/nucleus/ribosome/api/update_entry.rs @@ -58,7 +58,7 @@ pub fn invoke_update_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi &entry, Some(latest_entry.clone().address()), &context.clone(), - &vec![] // TODO should provenance be a parameter? + &vec![], // TODO should provenance be a parameter? )) .map_err(|validation_error| HolochainError::from(validation_error)); diff --git a/core/src/workflows/author_entry.rs b/core/src/workflows/author_entry.rs index 5c30f30ef7..d8baca48c7 100644 --- a/core/src/workflows/author_entry.rs +++ b/core/src/workflows/author_entry.rs @@ -12,17 +12,17 @@ use holochain_core_types::{ cas::content::{Address, AddressableContent}, entry::Entry, error::HolochainError, - validation::{EntryLifecycle, ValidationData}, signature::Provenance, + validation::{EntryLifecycle, ValidationData}, }; -use std::{vec::Vec, sync::Arc}; +use std::{sync::Arc, vec::Vec}; pub async fn author_entry<'a>( entry: &'a Entry, maybe_link_update_delete: Option
, context: &'a Arc, - provenances: &'a Vec + provenances: &'a Vec, ) -> Result { let address = entry.address(); context.log(format!( @@ -31,8 +31,11 @@ pub async fn author_entry<'a>( )); // 1. Build the context needed for validation of the entry - let validation_package = await!( - build_validation_package(&entry, context.clone(), provenances))?; + let validation_package = await!(build_validation_package( + &entry, + context.clone(), + provenances + ))?; let validation_data = ValidationData { package: validation_package, lifecycle: EntryLifecycle::Chain, @@ -107,7 +110,7 @@ pub mod tests { &test_entry_with_value("{\"stuff\":\"test entry value\"}"), None, &context1, - &vec![] + &vec![], )) .unwrap(); thread::sleep(time::Duration::from_millis(500)); diff --git a/core/src/workflows/respond_validation_package_request.rs b/core/src/workflows/respond_validation_package_request.rs index e13f47b017..436ac56575 100644 --- a/core/src/workflows/respond_validation_package_request.rs +++ b/core/src/workflows/respond_validation_package_request.rs @@ -6,7 +6,9 @@ use crate::{ nucleus::actions::build_validation_package::build_validation_package, }; -use holochain_core_types::{cas::content::Address, entry::Entry, error::HolochainError, signature::Provenance}; +use holochain_core_types::{ + cas::content::Address, entry::Entry, error::HolochainError, signature::Provenance, +}; use std::{convert::TryFrom, sync::Arc, vec::Vec}; fn get_entry(address: &Address, context: &Arc) -> Result { @@ -31,10 +33,15 @@ pub async fn respond_validation_package_request( msg_id: String, requested_entry_address: Address, context: Arc, - provenances: &Vec + provenances: &Vec, ) { let maybe_validation_package = match get_entry(&requested_entry_address, &context) { - Ok(entry) => await!(build_validation_package(&entry, context.clone(), provenances)).ok(), + Ok(entry) => await!(build_validation_package( + &entry, + context.clone(), + provenances + )) + .ok(), Err(_) => None, }; diff --git a/core_types/src/entry/mod.rs b/core_types/src/entry/mod.rs index ebb2754ae3..e94a4f8572 100644 --- a/core_types/src/entry/mod.rs +++ b/core_types/src/entry/mod.rs @@ -23,9 +23,9 @@ use json::{default_to_json, default_try_from_json, JsonString, RawString}; use link::{link_data::LinkData, link_list::LinkList}; use multihash::Hash; use serde::{ser::SerializeTuple, Deserialize, Deserializer, Serializer}; +use signature::Provenance; use snowflake; use std::convert::TryFrom; -use signature::Provenance; pub type AppEntryValue = JsonString; @@ -80,15 +80,12 @@ pub enum Entry { #[derive(Clone, Debug, Serialize, Deserialize, DefaultJson)] pub struct EntryWithProvenance { entry: Entry, - provenances: Vec + provenances: Vec, } impl EntryWithProvenance { - pub fn new(entry:Entry, provenances:Vec) -> Self { - EntryWithProvenance { - entry, - provenances - } + pub fn new(entry: Entry, provenances: Vec) -> Self { + EntryWithProvenance { entry, provenances } } pub fn entry(&self) -> Entry { diff --git a/core_types/src/signature.rs b/core_types/src/signature.rs index 8a562fda52..4c4b702f58 100644 --- a/core_types/src/signature.rs +++ b/core_types/src/signature.rs @@ -11,6 +11,10 @@ use crate::{cas::content::Address, error::HolochainError, json::JsonString}; pub struct Provenance(pub Address, pub Signature); impl Provenance { + /// Creates a new provenance instance with source typically + /// being an agent address (public key) and the signature + /// some signed data using the private key associated with + /// the public key. pub fn new(source: Address, signature: Signature) -> Self { Provenance(source, signature) } diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index b81691cf7c..67885448f1 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -1,4 +1,3 @@ - //! developers! Detailed references and examples can be found here for how to use the //! HDK exposed functions to access powerful Holochain functions. @@ -639,11 +638,11 @@ pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ // TODO document (copy / mutate the above) pub fn commit_entry_with_provenance( - entry_with_provenance: &EntryWithProvenance) -> ZomeApiResult
{ + entry_with_provenance: &EntryWithProvenance, +) -> ZomeApiResult
{ Dispatch::CommitEntryWithProvenance.with_input(entry_with_provenance) } - /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using /// the specified address. /// Returns None if no entry exists at the specified address or diff --git a/nodejs_waiter/src/waiter.rs b/nodejs_waiter/src/waiter.rs index b9c42486e0..3f486acff7 100644 --- a/nodejs_waiter/src/waiter.rs +++ b/nodejs_waiter/src/waiter.rs @@ -178,7 +178,10 @@ impl Waiter { } }, - (Some(checker), Action::Commit((committed_entry, link_update_delete, _provenances))) => { + ( + Some(checker), + Action::Commit((committed_entry, link_update_delete, _provenances)), + ) => { // Pair every `Commit` with N `Hold`s of that same entry, regardless of type // TODO: is there a possiblity that this can get messed up if the same // entry is committed multiple times? From e4db6bfb252eb858d4875d4b9d4566193b2df392 Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 25 Apr 2019 01:11:56 -0400 Subject: [PATCH 16/83] Failing app spec test for commit w/provenances. --- app_spec/test/test.js | 21 ++++++++++++++++ app_spec/zomes/blog/code/src/blog.rs | 25 ++++++++++++++++++- app_spec/zomes/blog/code/src/lib.rs | 11 ++++++-- .../src/nucleus/actions/call_zome_function.rs | 3 +++ test_utils/src/mock_signing.rs | 7 +++--- 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index 74a03fbb28..5f0c1e2a18 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -144,6 +144,27 @@ scenario1.runTape('create_post', async (t, { alice }) => { t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk") }) +scenario2.runTape('create_post_countersigned', async (t, { alice, bob }) => { + + const content = "Holo world" + const in_reply_to = null + + const message = "Hello everyone! Time to start the secret meeting"; + + const SignResult = bob.call("converse", "sign_message", { key_id:"", message: message }); + t.deepEqual(SignResult, { Ok: 'YVystBCmNEJGW/91bg43cUUybbtiElex0B+QWYy+PlB+nE3W8TThYGE4QzuUexvzkGqSutV04dSN8oyZxTJiBg==' }); + + const provenance = [bob.agentId, SignResult.Ok]; + + const params = { content, in_reply_to, provenance } + const result = alice.call("blog", "create_post_countersigned", params) + + t.ok(result.Ok) + t.notOk(result.Err) + t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk") +}) + + scenario1.runTape('create_memo', async (t, { alice }) => { const content = "Reminder: Buy some HOT." diff --git a/app_spec/zomes/blog/code/src/blog.rs b/app_spec/zomes/blog/code/src/blog.rs index 763559100c..cb077c62b0 100644 --- a/app_spec/zomes/blog/code/src/blog.rs +++ b/app_spec/zomes/blog/code/src/blog.rs @@ -2,8 +2,9 @@ use hdk::{ self, error::{ZomeApiError, ZomeApiResult}, holochain_core_types::{ - cas::content::Address, dna::capabilities::CapabilityRequest, entry::Entry, + cas::content::Address, dna::capabilities::CapabilityRequest, entry::{Entry, EntryWithProvenance}, error::HolochainError, json::JsonString, + signature::Provenance }, holochain_wasm_utils::api_serialization::{ get_entry::{ @@ -120,6 +121,28 @@ pub fn handle_create_post(content: String, in_reply_to: Option
) -> Zome Ok(address) } +pub fn handle_create_post_countersigned(content: String, in_reply_to: Option
, + counter_signature: Provenance) -> ZomeApiResult
{ + + let entry = post_entry(content); + + let entry_with_provenance = + EntryWithProvenance::new(entry, vec![counter_signature]); + + let address = hdk::commit_entry_with_provenance(&entry_with_provenance)?; + + hdk::link_entries(&AGENT_ADDRESS, &address, "authored_posts")?; + + if let Some(in_reply_to_address) = in_reply_to { + // return with Err if in_reply_to_address points to missing entry + hdk::get_entry_result(&in_reply_to_address, GetEntryOptions::default())?; + hdk::link_entries(&in_reply_to_address, &address, "comments")?; + } + + Ok(address) +} + + pub fn handle_create_post_with_agent(agent_id:Address,content: String, in_reply_to: Option
) -> ZomeApiResult
{ let address = hdk::commit_entry(&post_entry(content))?; diff --git a/app_spec/zomes/blog/code/src/lib.rs b/app_spec/zomes/blog/code/src/lib.rs index 23954e108c..589113d13b 100755 --- a/app_spec/zomes/blog/code/src/lib.rs +++ b/app_spec/zomes/blog/code/src/lib.rs @@ -19,6 +19,7 @@ use hdk::{ error::ZomeApiResult, holochain_core_types::{ cas::content::Address, entry::Entry, error::HolochainError, json::JsonString, + signature::Provenance }, holochain_wasm_utils::api_serialization::{ get_entry::{EntryHistory, GetEntryResult}, @@ -92,7 +93,13 @@ define_zome! { outputs: |result: ZomeApiResult
|, handler: blog::handle_create_post_with_agent } - + + create_post_countersigned: { + inputs: |content: String, in_reply_to: Option
, counter_signature:Provenance|, + outputs: |result: ZomeApiResult
|, + handler: blog::handle_create_post_countersigned + } + create_memo: { inputs: |content: String|, outputs: |result: ZomeApiResult
|, @@ -204,6 +211,6 @@ define_zome! { ] traits: { - hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts,memo_address,get_memo,my_memos,create_memo,my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post,get_history_post,get_post_with_options,get_post_with_options_latest,authored_posts_with_sources,create_post_with_agent] + hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, create_post_countersigned, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts,memo_address,get_memo,my_memos,create_memo,my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post,get_history_post,get_post_with_options,get_post_with_options_latest,authored_posts_with_sources,create_post_with_agent] } } diff --git a/core/src/nucleus/actions/call_zome_function.rs b/core/src/nucleus/actions/call_zome_function.rs index ed7cf1827f..85e30e2895 100644 --- a/core/src/nucleus/actions/call_zome_function.rs +++ b/core/src/nucleus/actions/call_zome_function.rs @@ -108,6 +108,9 @@ pub async fn call_zome_function( .expect("action channel to be open in reducer"); }); + context.log(format!("debug/actions/call_zome_fn: awaiting for \ + future call result of {:?}", zome_call)); + await!(CallResultFuture { context: context.clone(), zome_call, diff --git a/test_utils/src/mock_signing.rs b/test_utils/src/mock_signing.rs index 23d13588ce..33bd7df8f7 100644 --- a/test_utils/src/mock_signing.rs +++ b/test_utils/src/mock_signing.rs @@ -48,12 +48,13 @@ pub fn registered_test_agent>(nick: S) -> AgentId { /// but with key generated from a static/deterministic mock seed. /// This enables unit testing of core code that creates signatures without /// depending on the conductor or actual key files. -pub fn mock_signer(payload: String, agent_id: &AgentId) -> String { - TEST_AGENT_KEYBUNDLES +pub fn mock_signer(payload: String, agent_id: &AgentId) -> String { TEST_AGENT_KEYBUNDLES .lock() .unwrap() .get(&agent_id.address()) - .expect("Test agent keys need to be registered first") + .expect(format!( + "Agent {:?} not found in mock registry. \ + Test agent keys need to be registered first.", agent_id)) .lock() .map(|mut keybundle| { // Convert payload string into a SecBuf From 04eec6825a0340e200b6ed5a00c3c2d19a3ae866 Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 25 Apr 2019 01:14:59 -0400 Subject: [PATCH 17/83] Update rust doc --- core/src/nucleus/ribosome/api/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/nucleus/ribosome/api/mod.rs b/core/src/nucleus/ribosome/api/mod.rs index f8660bebfe..c9ae6d00b7 100644 --- a/core/src/nucleus/ribosome/api/mod.rs +++ b/core/src/nucleus/ribosome/api/mod.rs @@ -67,8 +67,8 @@ link_zome_api! { /// commit_entry(entry_type: String, entry_value: String) -> Address "hc_commit_entry", CommitAppEntry, invoke_commit_app_entry; - /// Commit an app entry to source chain - /// commit_entry(entry_type: String, entry_value: String) -> Address + /// Commit an app entry with additional provenances to source chain + /// commit_entry_with_provenance(entry_type: String, entry_value: String, provenances: Vec) -> Address "hc_commit_entry_with_provenance", CommitAppEntryWithProvenance, invoke_commit_app_entry_with_provenance; From 73a29e735ced11a7e1532d68e7371f53f6975c12 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 25 Apr 2019 08:38:23 +0100 Subject: [PATCH 18/83] adding av cold config --- av-cold.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 av-cold.yml diff --git a/av-cold.yml b/av-cold.yml new file mode 100644 index 0000000000..0db71f386e --- /dev/null +++ b/av-cold.yml @@ -0,0 +1,65 @@ +# https://www.appveyor.com/docs/enterprise/running-builds-on-aws/ + +build_cloud: azure +image: hc-azure + +shallow_clone: true +version: 1.0.{build} +build: false +max_jobs: 20 + +environment: + # global: + # hc_target_prefix: C:\build + + matrix: + - test_p: holochain_dna_c_binding + test_path: dna_c_binding + wasm_path: + wasm_path_2: + + - test_p: holochain_core_types + test_path: core_types + wasm_path: + wasm_path_2: + + - test_p: holochain_wasm_utils + test_path: wasm_utils + wasm_path: wasm-test\integration-test + wasm_path_2: + + - test_p: hdk + test_path: hdk-rust + wasm_path: wasm-test + wasm_path_2: + + - test_p: holochain_conductor_api + test_path: conductor_api + wasm_path: wasm-test + wasm_path_2: test-bridge-caller + + # - test_p: holochain_cas_implementations + # test_path: cas_implementations\ + + - test_p: holochain_core + test_path: core + wasm_path: src\nucleus\actions\wasm-test + wasm_path_2: + + - test_p: hc + test_path: cli + wasm_path: + wasm_path_2: + + - test_p: holochain_sodium + test_path: sodium + wasm_path: + wasm_path_2: + + - test_p: holochain_net + test_path: net + wasm_path: + wasm_path_2: + +test_script: + - scripts\windows\do-ci-test.bat From 271288f352ac11f65bd1bfc804c471e6665b8dff Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 25 Apr 2019 09:16:08 +0100 Subject: [PATCH 19/83] initial dual project --- appveyor.yml | 2 - av-cold.yml | 4 +- build.ps1 | 430 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 431 insertions(+), 5 deletions(-) create mode 100644 build.ps1 diff --git a/appveyor.yml b/appveyor.yml index 0db71f386e..7996f87793 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,3 @@ -# https://www.appveyor.com/docs/enterprise/running-builds-on-aws/ - build_cloud: azure image: hc-azure diff --git a/av-cold.yml b/av-cold.yml index 0db71f386e..426ee3753a 100644 --- a/av-cold.yml +++ b/av-cold.yml @@ -1,7 +1,5 @@ -# https://www.appveyor.com/docs/enterprise/running-builds-on-aws/ - build_cloud: azure -image: hc-azure +image: hc-cold shallow_clone: true version: 1.0.{build} diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..25751fd3da --- /dev/null +++ b/build.ps1 @@ -0,0 +1,430 @@ +# Auto login image +#Reason to create callme.ps1 file is to make script copy-paste-able to PS windows and still be able to ask for password + +'Write-Warning "This script will overwrite current auto-logon settings if they exist" + +$user = whoami +$securePwd = Read-Host "Please enter password for current user to be saved for auto-logon" -AsSecureString + +#http://stackoverflow.com/questions/21741803/powershell-securestring-encrypt-decrypt-to-plain-text-not-working +$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd) +$pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType String -Value 1 + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -PropertyType String -Value $user + +Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue +New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -PropertyType String -Value $pwd + +del .\callme.ps1' > callme.ps1 + +.\callme.ps1 +####### + + +Write-Host "Changing PS execution policy to Unrestricted" -ForegroundColor Cyan +Set-ExecutionPolicy Unrestricted -Force + +Write-Host "Disabling Server Manager auto-start" -ForegroundColor Cyan +$serverManagerMachineKey = "HKLM:\SOFTWARE\Microsoft\ServerManager" +$serverManagerUserKey = "HKCU:\SOFTWARE\Microsoft\ServerManager" +if(Test-Path $serverManagerMachineKey) { + Set-ItemProperty -Path $serverManagerMachineKey -Name "DoNotOpenServerManagerAtLogon" -Value 1 + Write-Host "Disabled Server Manager at logon for all users" -ForegroundColor Green +} +if(Test-Path $serverManagerUserKey) { + Set-ItemProperty -Path $serverManagerUserKey -Name "CheckedUnattendLaunchSetting" -Value 0 + Write-Host "Disabled Server Manager for current user" -ForegroundColor Green +} + +# disable scheduled task +schtasks /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE + +Write-Host "Disabling UAC" -ForegroundColor Cyan + +Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 +Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" + +Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green + +Write-Host "Disabling Windows Error Reporting (WER)" -ForegroundColor Cyan +$werKey = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" +Set-ItemProperty $werKey -Name "ForceQueue" -Value 1 + +if(Test-Path "$werKey\Consent") { + Set-ItemProperty "$werKey\Consent" -Name "DefaultConsent" -Value 1 +} +Write-Host "Windows Error Reporting (WER) dialog has been disabled." -ForegroundColor Green + +Write-Host "Disabling Internet Explorer ESC" -ForegroundColor Cyan +$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" +$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" +if((Test-Path $AdminKey) -or (Test-Path $UserKey)) { + Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 + Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 + Stop-Process -Name Explorer + Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green +} + +Write-Host "WinRM - allow * hosts" -ForegroundColor Cyan +cmd /c 'winrm set winrm/config/client @{TrustedHosts="*"}' +Write-Host "WinRM configured" -ForegroundColor Green + +reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f +reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NetworkLocationWizard /v HideWizard /t REG_DWORD /d 1 /f + +$pathUtilsPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules\path-utils" +New-Item $pathUtilsPath -ItemType Directory -Force +(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/appveyor/ci/master/scripts/path-utils.psm1', "$pathUtilsPath\path-utils.psm1") +Remove-Module path-utils -ErrorAction SilentlyContinue +Import-Module path-utils + +$UserModulesPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules" +$PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') +if(-not $PSModulePath.contains($UserModulesPath)) { + [Environment]::SetEnvironmentVariable('PSModulePath', "$PSModulePath;$UserModulesPath", 'Machine') +} + +Write-Host "Installing 7-Zip..." -ForegroundColor Cyan +$exePath = "$env:USERPROFILE\7z1604-x64.exe" +Invoke-WebRequest http://www.7-zip.org/a/7z1604-x64.exe -OutFile $exePath +cmd /c start /wait $exePath /S +del $exePath + +$sevenZipFolder = 'C:\Program Files\7-Zip' +Add-SessionPath $sevenZipFolder +Add-Path "$sevenZipFolder" + +Write-Host "7-Zip installed" -ForegroundColor Green + + +if(Test-Path 'C:\ProgramData\chocolatey\bin') { + # update + Write-Host "Updating Chocolatey..." -ForegroundColor Cyan + choco upgrade chocolatey +} else { + # install + Write-Host "Installing Chocolatey..." -ForegroundColor Cyan + iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) +} + +choco --version + +# enable -y +$configPath = "C:\ProgramData\chocolatey\config\chocolatey.config" +$config = [xml](Get-Content $configPath) +$allowGlobalConfirmation = $config.chocolatey.features.feature | where {$_.name -eq 'allowGlobalConfirmation'} +$allowGlobalConfirmation.enabled = 'true' +$allowGlobalConfirmation.setExplicitly = 'true' +$config.Save($configPath) + +Write-Host "Chocolatey installed" -ForegroundColor Green + +$webPIFolder = "$env:ProgramFiles\Microsoft\Web Platform Installer" +if([IO.File]::Exists("$webPIFolder\webpicmd.exe")) { + Add-SessionPath $webPIFolder + Write-Host "Web PI is already installed" -ForegroundColor Green + return +} + +Write-Host "Installing Web Platform Installer (Web PI)..." -ForegroundColor Cyan + +# http://www.iis.net/learn/install/web-platform-installer/web-platform-installer-direct-downloads +$msiPath = "$env:USERPROFILE\WebPlatformInstaller_amd64_en-US.msi" +(New-Object Net.WebClient).DownloadFile('http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi', $msiPath) + +cmd /c start /wait msiexec /i "$msiPath" /q +del $msiPath +Add-SessionPath $webPIFolder +Write-Host "Web PI installed" -ForegroundColor Green + +Write-Host "Installing NuGet..." -ForegroundColor Cyan + +# nuget 3.x +Write-Host "NuGet 3.x" +$nuget3Path = "$env:SYSTEMDRIVE\Tools\NuGet" +if(-not (Test-Path $nuget3Path)) { + New-Item $nuget3Path -ItemType Directory -Force | Out-Null +} + +(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', "$nuget3Path\nuget.exe") + +Remove-Path $nuget2Path +Remove-Path $nuget3Path + +# add default nuget configuration +$appDataNugetConfig = ' + + + + + +' +$configDirectory = "$env:APPDATA\NuGet" +if(-not (Test-Path $configDirectory)) { + New-Item $configDirectory -ItemType Directory -Force | Out-Null +} +Set-Content "$configDirectory\NuGet.config" -Value $appDataNugetConfig + +Add-Path $nuget3Path +Add-SessionPath $nuget3Path + +Write-Host "NuGet installed" -ForegroundColor Green + +Write-Host "Installing Git 2.14.1..." -ForegroundColor Cyan + +$exePath = "$env:TEMP\Git-2.14.1-64-bit.exe" + +Write-Host "Downloading..." +(New-Object Net.WebClient).DownloadFile('https://github.com/git-for-windows/git/releases/download/v2.14.1.windows.1/Git-2.14.1-64-bit.exe', $exePath) + +Write-Host "Installing..." +cmd /c start /wait $exePath /VERYSILENT /NORESTART /NOCANCEL /SP- /NOICONS /COMPONENTS="icons,icons\quicklaunch,ext,ext\reg,ext\reg\shellhere,ext\reg\guihere,assoc,assoc_sh" /LOG +del $exePath + +Add-Path "$env:ProgramFiles\Git\cmd" +$env:path = "$env:ProgramFiles\Git\cmd;$env:path" + +Add-Path "$env:ProgramFiles\Git\usr\bin" +$env:path = "$env:ProgramFiles\Git\usr\bin;$env:path" + +#Remove-Item 'C:\Program Files\Git\mingw64\etc\gitconfig' +git config --global core.autocrlf input +git config --system --unset credential.helper +#git config --global credential.helper store + +git --version +Write-Host "Git installed" -ForegroundColor Green + +Write-Host "Installing Git LFS..." -ForegroundColor Cyan + +# delete existing Git LFS +del 'C:\Program Files\Git\mingw64\bin\git-lfs.exe' -ErrorAction SilentlyContinue + +$exePath = "$env:TEMP\git-lfs-windows-2.2.1.exe" + +Write-Host "Downloading..." +(New-Object Net.WebClient).DownloadFile('https://github.com/git-lfs/git-lfs/releases/download/v2.2.1/git-lfs-windows-2.2.1.exe', $exePath) + +Write-Host "Installing..." +cmd /c start /wait $exePath /VERYSILENT /SUPPRESSMSGBOXES /NORESTART + +Add-Path "$env:ProgramFiles\Git LFS" +$env:path = "$env:ProgramFiles\Git LFS;$env:path" + +git lfs install --force +git lfs version + +Write-Host "Git LFS installed" -ForegroundColor Green + +function Get-IPs { + + Param( + [Parameter(Mandatory = $true)] + [array] $Subnets + ) + +foreach ($subnet in $subnets) + { + #Split IP and subnet + $IP = ($Subnet -split "\/")[0] + $SubnetBits = ($Subnet -split "\/")[1] + if ($SubnetBits -eq "32") { + $IP + } else { + #Convert IP into binary + #Split IP into different octects and for each one, figure out the binary with leading zeros and add to the total + $Octets = $IP -split "\." + $IPInBinary = @() + foreach($Octet in $Octets) + { + #convert to binary + $OctetInBinary = [convert]::ToString($Octet,2) + + #get length of binary string add leading zeros to make octet + $OctetInBinary = ("0" * (8 - ($OctetInBinary).Length) + $OctetInBinary) + + $IPInBinary = $IPInBinary + $OctetInBinary + } + $IPInBinary = $IPInBinary -join "" + + #Get network ID by subtracting subnet mask + $HostBits = 32-$SubnetBits + $NetworkIDInBinary = $IPInBinary.Substring(0,$SubnetBits) + + #Get host ID and get the first host ID by converting all 1s into 0s + $HostIDInBinary = $IPInBinary.Substring($SubnetBits,$HostBits) + $HostIDInBinary = $HostIDInBinary -replace "1","0" + + #Work out all the host IDs in that subnet by cycling through $i from 1 up to max $HostIDInBinary (i.e. 1s stringed up to $HostBits) + #Work out max $HostIDInBinary + $imax = [convert]::ToInt32(("1" * $HostBits),2) -1 + + $IPs = @() + + #Next ID is first network ID converted to decimal plus $i then converted to binary + For ($i = 1 ; $i -le $imax ; $i++) + { + #Convert to decimal and add $i + $NextHostIDInDecimal = ([convert]::ToInt32($HostIDInBinary,2) + $i) + #Convert back to binary + $NextHostIDInBinary = [convert]::ToString($NextHostIDInDecimal,2) + #Add leading zeros + #Number of zeros to add + $NoOfZerosToAdd = $HostIDInBinary.Length - $NextHostIDInBinary.Length + $NextHostIDInBinary = ("0" * $NoOfZerosToAdd) + $NextHostIDInBinary + + #Work out next IP + #Add networkID to hostID + $NextIPInBinary = $NetworkIDInBinary + $NextHostIDInBinary + #Split into octets and separate by . then join + $IP = @() + For ($x = 1 ; $x -le 4 ; $x++) + { + #Work out start character position + $StartCharNumber = ($x-1)*8 + #Get octet in binary + $IPOctetInBinary = $NextIPInBinary.Substring($StartCharNumber,8) + #Convert octet into decimal + $IPOctetInDecimal = [convert]::ToInt32($IPOctetInBinary,2) + #Add octet to IP + $IP += $IPOctetInDecimal + } + + #Separate by . + $IP = $IP -join "." + $IPs += $IP + } + $IPs + } + } +} + + +Write-Host "Adding SSH known hosts..." -ForegroundColor Cyan +$sshPath = Join-Path $Home ".ssh" +if(-not (Test-Path $sshPath)) { + New-Item $sshPath -ItemType directory -Force +} + +$contents = @() +# GitHub IP addresses + +$GIthubIPs="192.30.252.0/22", + "185.199.108.0/22", + "13.229.188.59/32", + "13.250.177.223/32", + "18.194.104.89/32", + "18.195.85.27/32", + "35.159.8.160/32", + "52.74.223.119/32" +Get-IPs -subnets $GIthubIPs | ForEach-Object { + $contents += "github.com,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" +} + +# BitBucket +$BitBucketIPs="104.192.143.1", + "104.192.143.2", + "104.192.143.3", + "104.192.143.65", + "104.192.143.66", + "104.192.143.67" +$BitBucketIPs | ForEach-Object { + $contents += "bitbucket.org,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==" +} + +$knownhostfile = Join-Path $sshPath "known_hosts" +[IO.File]::WriteAllLines($knownhostfile, $contents) + +Write-Host "Known hosts configured" -ForegroundColor Green + +$installerUrl = 'http://www.appveyor.com/downloads/build-agent/latest/AppveyorBuildAgent.msi' +$installerFileName = "$($env:TEMP)\AppveyorBuildAgent.msi" + +$process = Get-Process -Name 'Appveyor.BuildAgent.Service' -ErrorAction SilentlyContinue +if($process) { + $process | Stop-Process -Force +} +$process = Get-Process -Name 'Appveyor.BuildAgent.Interactive' -ErrorAction SilentlyContinue +if($process) { + $process | Stop-Process -Force +} + +(New-Object Net.WebClient).DownloadFile($installerUrl, $installerFileName) +cmd /c start /wait msiexec /i $installerFileName /quiet APPVEYOR_MODE=Azure +Remove-Item $installerFileName + +# display appveyor version +& "C:\Program Files\AppVeyor\BuildAgent\appveyor.exe" version + +Clear-EventLog -LogName AppVeyor -ErrorAction SilentlyContinue + +Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azure" + +# Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "AmazonEC2" + +################### DO UP TO HERE FIRST + + +################# APP VEYOR SPECIFICS + +Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppVeyor.BuildAgent" ` + -Value 'powershell -File "C:\Program Files\AppVeyor\BuildAgent\start-appveyor-agent.ps1"' + +################# Dependencies + +choco install cmake + +choco install openssl.light + +# Check Path and add manually if cmake isn't there + +choco install nodist + +$env:NODIST_X64 = "1" +$env:NODIST_PREFIX = "C:\Program Files (x86)\Nodist" +$env:Path += ";C:\Program Files (x86)\Nodist\bin" +[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") + +& RefreshEnv.cmd + +nodist add 9 + +nodist 9 + +nodist npm add 5 + +nodist npm 5 + +npm install --global --production windows-build-tools + + + +####################### + +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\Users\master\Downloads\rustup-init.exe" + +C:\Users\master\Downloads\rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2019-01-24 + +# Add Cargo to Path + +$env:Path += ";C:\Users\master\.cargo\bin" +$env:Path += ";C:\Program Files\CMake\bin" + +####################### Rust specifics + +rustup target add wasm32-unknown-unknown + +rustup default nightly-2019-01-24 + +[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") +[Environment]::SetEnvironmentVariable("RUSTFLAGS", "-D warnings -Z external-macro-backtrace -Z thinlto -C codegen-units=16 -C opt-level=z", "Machine") +[Environment]::SetEnvironmentVariable("hc_target_prefix", "C:\build") +git clone https://github.com/holochain/holochain-rust C:\Users\master\build + +cd C:\Users\master\build \ No newline at end of file From 7f749c71d3ea0279007693eb2ad1365d168dc724 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Thu, 25 Apr 2019 09:29:42 +0100 Subject: [PATCH 20/83] testing --- appveyor.yml | 2 +- av-cold.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 426ee3753a..7996f87793 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ build_cloud: azure -image: hc-cold +image: hc-azure shallow_clone: true version: 1.0.{build} diff --git a/av-cold.yml b/av-cold.yml index 426ee3753a..a566a4735e 100644 --- a/av-cold.yml +++ b/av-cold.yml @@ -6,10 +6,13 @@ version: 1.0.{build} build: false max_jobs: 20 +install: + # to run script as a PowerShell command prepend it with ps: + - ps: .\azure\build.ps1 + environment: # global: # hc_target_prefix: C:\build - matrix: - test_p: holochain_dna_c_binding test_path: dna_c_binding From 7dd0ad97e919fe2be3455ee7eeb8655d9e4095fe Mon Sep 17 00:00:00 2001 From: carm Date: Thu, 25 Apr 2019 12:22:25 -0400 Subject: [PATCH 21/83] More logging of commit sequence --- core/src/nucleus/actions/call_zome_function.rs | 10 ++++++++-- core/src/nucleus/ribosome/api/commit.rs | 9 ++++++--- test_utils/src/mock_signing.rs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/src/nucleus/actions/call_zome_function.rs b/core/src/nucleus/actions/call_zome_function.rs index 85e30e2895..82080943c7 100644 --- a/core/src/nucleus/actions/call_zome_function.rs +++ b/core/src/nucleus/actions/call_zome_function.rs @@ -97,19 +97,25 @@ pub async fn call_zome_function( Some(zome_call_clone.clone().parameters.to_bytes()), WasmCallData::new_zome_call(context_clone.clone(), zome_call_clone.clone()), ); + context_clone.log("debug/actions/call_zome_fn: got call_result from ribosome::run_dna."); // Construct response let response = ExecuteZomeFnResponse::new(zome_call_clone, call_result); // Send ReturnZomeFunctionResult Action + context_clone.log("debug/actions/call_zome_fn: sending ReturnZomeFunctionResult action."); context_clone .action_channel() .send(ActionWrapper::new(Action::ReturnZomeFunctionResult( response, ))) .expect("action channel to be open in reducer"); + context_clone.log("debug/actions/call_zome_fn: sent ReturnZomeFunctionResult action."); }); - context.log(format!("debug/actions/call_zome_fn: awaiting for \ - future call result of {:?}", zome_call)); + context.log(format!( + "debug/actions/call_zome_fn: awaiting for \ + future call result of {:?}", + zome_call + )); await!(CallResultFuture { context: context.clone(), diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 45f480be9d..c77fc85ea2 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -45,15 +45,17 @@ pub fn invoke_commit_app_entry_with_provenance( args: &RuntimeArgs, ) -> ZomeApiResult { let context = runtime.context()?; + context.log("debug/zome: invoke_commit_app_entry_with_provenance started."); // deserialize args let args_str = runtime.load_json_string_from_args(&args); let entry_with_provenance = match EntryWithProvenance::try_from(args_str.clone()) { Ok(entry_with_provenance_input) => entry_with_provenance_input, // Exit on error - Err(_) => { + Err(error) => { context.log(format!( - "err/zome: invoke_commit_app_entry_with_provenance failed to deserialize Entry: {:?}", - args_str + "err/zome: invoke_commit_app_entry_with_provenance failed to \ + deserialize Entry: {:?} with error {:?}", + args_str, error )); return ribosome_error_code!(ArgumentDeserializationFailed); } @@ -66,6 +68,7 @@ pub fn invoke_commit_app_entry_with_provenance( &entry_with_provenance.provenances(), )); + context.log("debug/zome: invoke_commit_app_entry_with_provenance finished."); runtime.store_result(task_result) } diff --git a/test_utils/src/mock_signing.rs b/test_utils/src/mock_signing.rs index 33bd7df8f7..29cf4f2227 100644 --- a/test_utils/src/mock_signing.rs +++ b/test_utils/src/mock_signing.rs @@ -54,7 +54,7 @@ pub fn mock_signer(payload: String, agent_id: &AgentId) -> String { TEST_AGENT_K .get(&agent_id.address()) .expect(format!( "Agent {:?} not found in mock registry. \ - Test agent keys need to be registered first.", agent_id)) + Test agent keys need to be registered first.", agent_id).as_str()) .lock() .map(|mut keybundle| { // Convert payload string into a SecBuf From e9f47fc211975f46184f9e9088a8e1d5bd29a010 Mon Sep 17 00:00:00 2001 From: neonphog Date: Thu, 25 Apr 2019 10:30:36 -0600 Subject: [PATCH 22/83] fmt --- net/src/ipc/spawn.rs | 2 +- net/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/src/ipc/spawn.rs b/net/src/ipc/spawn.rs index f4a492ecf5..ac137a4f9e 100644 --- a/net/src/ipc/spawn.rs +++ b/net/src/ipc/spawn.rs @@ -153,7 +153,7 @@ pub fn ipc_spawn( if libc::kill(child.id() as i32, libc::SIGTERM) == 0 { libc::waitpid(child.id() as i32, std::ptr::null_mut(), 0); kill_child(&real_pid); - return + return; } } match child.kill() { diff --git a/net/src/lib.rs b/net/src/lib.rs index 350990395c..5ba47aa354 100644 --- a/net/src/lib.rs +++ b/net/src/lib.rs @@ -14,8 +14,8 @@ extern crate holochain_common; pub extern crate holochain_core_types_derive; #[macro_use] extern crate lazy_static; -extern crate libc; extern crate directories; +extern crate libc; extern crate reqwest; extern crate sha2; // macros used in tests From 1401c59d62769d63e2d58e3ec9f7613d9b1ce60a Mon Sep 17 00:00:00 2001 From: Paul d'Aoust Date: Thu, 25 Apr 2019 10:52:11 -0700 Subject: [PATCH 23/83] Fix mismatched zome fn name / public trait in example Follow-up to [my comment on #1321](https://github.com/holochain/holochain-rust/pull/1321#pullrequestreview-230179705). --- hdk-rust/src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index ebbfc4f1e1..eb23ffcccd 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -541,7 +541,7 @@ pub enum BundleOnClose { /// ] /// /// traits: { -/// hc_public [sum] +/// hc_public [check_sum] /// } /// } /// From 620d37de17022c13ed58438c8c5c3567fd69edc0 Mon Sep 17 00:00:00 2001 From: carm Date: Fri, 26 Apr 2019 02:31:47 -0400 Subject: [PATCH 24/83] Fix various bugs in app spec test --- app_spec/test/test.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index 969d3e83b4..1f9114604c 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -151,14 +151,16 @@ scenario2.runTape('create_post_countersigned', async (t, { alice, bob }) => { const content = "Holo world" const in_reply_to = null - const message = "Hello everyone! Time to start the secret meeting"; + const address_params = { content } + const address_result = bob.call("blog", "post_address", address_params) - const SignResult = bob.call("converse", "sign_message", { key_id:"", message: message }); - t.deepEqual(SignResult, { Ok: 'YVystBCmNEJGW/91bg43cUUybbtiElex0B+QWYy+PlB+nE3W8TThYGE4QzuUexvzkGqSutV04dSN8oyZxTJiBg==' }); + t.ok(address_result.Ok) + const SignResult = bob.call("converse", "sign_message", { key_id:"", message: address_result.Ok }); + t.ok(SignResult.Ok) - const provenance = [bob.agentId, SignResult.Ok]; + const counter_signature = [bob.agentId, SignResult.Ok]; - const params = { content, in_reply_to, provenance } + const params = { content, in_reply_to, counter_signature } const result = alice.call("blog", "create_post_countersigned", params) t.ok(result.Ok) From c1b1863a686ae1e6e1b6ead4428a87ea2b220b15 Mon Sep 17 00:00:00 2001 From: carm Date: Fri, 26 Apr 2019 02:38:18 -0400 Subject: [PATCH 25/83] Remove some verbose logging --- core/src/nucleus/ribosome/api/commit.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index c77fc85ea2..161f629521 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -45,7 +45,6 @@ pub fn invoke_commit_app_entry_with_provenance( args: &RuntimeArgs, ) -> ZomeApiResult { let context = runtime.context()?; - context.log("debug/zome: invoke_commit_app_entry_with_provenance started."); // deserialize args let args_str = runtime.load_json_string_from_args(&args); let entry_with_provenance = match EntryWithProvenance::try_from(args_str.clone()) { @@ -68,7 +67,6 @@ pub fn invoke_commit_app_entry_with_provenance( &entry_with_provenance.provenances(), )); - context.log("debug/zome: invoke_commit_app_entry_with_provenance finished."); runtime.store_result(task_result) } From 46098b28760d6c10a7d3a2592f61388fe2e2517f Mon Sep 17 00:00:00 2001 From: carm Date: Fri, 26 Apr 2019 02:39:03 -0400 Subject: [PATCH 26/83] hc-rust-fmt --- hdk-rust/src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index ec0549820e..6bb8944863 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -7,7 +7,7 @@ use holochain_core_types::{ dna::capabilities::CapabilityRequest, entry::{ cap_entries::{CapFunctions, CapabilityType}, - Entry, EntryWithProvenance + Entry, EntryWithProvenance, }, error::{RibosomeEncodedAllocation, RibosomeEncodingBits, ZomeApiInternalResult}, signature::Provenance, From f55694fcb54c8a2ebe67bc84615bc237fcdbefe9 Mon Sep 17 00:00:00 2001 From: carm Date: Fri, 26 Apr 2019 02:59:54 -0400 Subject: [PATCH 27/83] Fix merge error. --- app_spec/zomes/blog/code/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/app_spec/zomes/blog/code/src/lib.rs b/app_spec/zomes/blog/code/src/lib.rs index 6dfda71862..79806a2216 100755 --- a/app_spec/zomes/blog/code/src/lib.rs +++ b/app_spec/zomes/blog/code/src/lib.rs @@ -98,6 +98,7 @@ define_zome! { inputs: |content: String, in_reply_to: Option
, counter_signature:Provenance|, outputs: |result: ZomeApiResult
|, handler: blog::handle_create_post_countersigned + } request_post_grant: { inputs: | |, From d9cc9c40413acf95b8ac872d033c4b1bdc763344 Mon Sep 17 00:00:00 2001 From: Michael Dougherty Date: Fri, 26 Apr 2019 13:43:59 -0700 Subject: [PATCH 28/83] Adds missing breaking change in CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15e7b3b7bf..6187ca4338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Clarifies the error received when attempting to add a DNA whose expected hash mismatches the actual hash [#1287](https://github.com/holochain/holochain-rust/pull/1287). - Binary tarballs no longer extract to a subdirectory [#1265](https://github.com/holochain/holochain-rust/pull/1265) - Linux binary tarballs are now named `generic` rather than `ubuntu` [#1265](https://github.com/holochain/holochain-rust/pull/1265) +- When getting links, the result has changed from `addresses: Vec
` to `links: Vec`. [#1250](https://github.com/holochain/holochain-rust/pull/1250) ### Deprecated From 97b4f6f26cfae98fa70b0accd7fe93ce51ddc286 Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 12:42:48 -0400 Subject: [PATCH 29/83] changed return types --- app_spec/zomes/blog/code/src/blog.rs | 8 +++----- app_spec/zomes/blog/code/src/lib.rs | 4 ++-- core/src/nucleus/ribosome/api/link_entries.rs | 12 +++++++----- core/src/nucleus/ribosome/api/remove_entry.rs | 4 ++-- hdk-rust/src/api.rs | 4 ++-- hdk-rust/tests/integration_test.rs | 4 ++-- hdk-rust/wasm-test/src/lib.rs | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app_spec/zomes/blog/code/src/blog.rs b/app_spec/zomes/blog/code/src/blog.rs index 76125f0d30..357220b628 100644 --- a/app_spec/zomes/blog/code/src/blog.rs +++ b/app_spec/zomes/blog/code/src/blog.rs @@ -235,12 +235,10 @@ pub fn handle_get_post(post_address: Address) -> ZomeApiResult> { hdk::get_entry(&post_address) } -pub fn handle_delete_entry_post(post_address: Address) -> ZomeApiResult<()> { +pub fn handle_delete_entry_post(post_address: Address) -> ZomeApiResult
{ hdk::get_entry(&post_address)?; - hdk::remove_entry(&post_address)?; - - Ok(()) + hdk::remove_entry(&post_address) } pub fn handle_get_initial_post(post_address: Address) -> ZomeApiResult> { @@ -287,7 +285,7 @@ pub fn handle_update_post(post_address: Address, new_content: String) -> ZomeApi } } -pub fn handle_recommend_post(post_address: Address, agent_address: Address) -> ZomeApiResult<()> { +pub fn handle_recommend_post(post_address: Address, agent_address: Address) -> ZomeApiResult
{ hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS.to_string()))?; hdk::debug(format!("other address:\n{:?}", agent_address.to_string()))?; hdk::link_entries(&agent_address, &post_address, "recommended_posts") diff --git a/app_spec/zomes/blog/code/src/lib.rs b/app_spec/zomes/blog/code/src/lib.rs index 508ec23767..8ef3417819 100755 --- a/app_spec/zomes/blog/code/src/lib.rs +++ b/app_spec/zomes/blog/code/src/lib.rs @@ -120,7 +120,7 @@ define_zome! { delete_entry_post: { inputs: |post_address: Address|, - outputs: |result: ZomeApiResult<()>|, + outputs: |result: ZomeApiResult
|, handler: blog::handle_delete_entry_post } @@ -205,7 +205,7 @@ define_zome! { recommend_post: { inputs: |post_address: Address, agent_address: Address|, - outputs: |result: ZomeApiResult<()>|, + outputs: |result: ZomeApiResult
|, handler: blog::handle_recommend_post } diff --git a/core/src/nucleus/ribosome/api/link_entries.rs b/core/src/nucleus/ribosome/api/link_entries.rs index f4dc7d3b86..9f477d6a0e 100644 --- a/core/src/nucleus/ribosome/api/link_entries.rs +++ b/core/src/nucleus/ribosome/api/link_entries.rs @@ -6,6 +6,7 @@ use holochain_core_types::{ entry::Entry, error::HolochainError, link::{link_data::LinkData, LinkActionKind}, + cas::content::{Address,AddressableContent} }; use holochain_wasm_utils::api_serialization::link_entries::LinkEntriesArgs; use std::convert::TryFrom; @@ -34,9 +35,9 @@ pub fn invoke_link_entries(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi let link_add = LinkData::from_link(&link, LinkActionKind::ADD); let entry = Entry::LinkAdd(link_add); // Wait for future to be resolved - let result: Result<(), HolochainError> = context + let result: Result = context .block_on(author_entry(&entry, None, &context)) - .map(|_| ()); + .map(|_| entry.address().clone()); runtime.store_result(result) } @@ -55,10 +56,11 @@ pub mod tests { }, }; use holochain_core_types::{ - cas::content::AddressableContent, + cas::content::{Address,AddressableContent}, entry::{test_entry, Entry}, error::{CoreError, ZomeApiInternalResult}, json::JsonString, + hash::HashString }; use holochain_wasm_utils::api_serialization::link_entries::*; use serde_json; @@ -144,7 +146,7 @@ pub mod tests { test_link_args_bytes(String::from("test-tag")), ); - let no_entry: Option = None; + let no_entry: Option
= Some(HashString::from("QmWXM2r3iujqGvka8XMKU2wLdz5N14bEhvDp7Rx3R3oaEP")); let result = ZomeApiInternalResult::success(no_entry); assert_eq!( call_result, @@ -189,7 +191,7 @@ pub mod tests { test_link_2_args_bytes(String::from("test-tag")), ); - let no_entry: Option = None; + let no_entry: Option
= Some(HashString::from("QmcmcrbAfoaqJMZun74Xs1TsCUndXAohJNrKu7xZyr68P8")); let result = ZomeApiInternalResult::success(no_entry); assert_eq!( diff --git a/core/src/nucleus/ribosome/api/remove_entry.rs b/core/src/nucleus/ribosome/api/remove_entry.rs index 3a366fdfa8..270cd82183 100644 --- a/core/src/nucleus/ribosome/api/remove_entry.rs +++ b/core/src/nucleus/ribosome/api/remove_entry.rs @@ -58,13 +58,13 @@ pub fn invoke_remove_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi // Create deletion entry let deletion_entry = Entry::Deletion(DeletionEntry::new(deleted_entry_address.clone())); - let res: Result<(), HolochainError> = context + let res: Result = context .block_on(author_entry( &deletion_entry.clone(), Some(deleted_entry_address.clone()), &context.clone(), )) - .map(|_| ()); + .map(|_| deletion_entry.address()); runtime.store_result(res) } diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index bd27498920..ab609a4456 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -775,7 +775,7 @@ pub fn link_entries>( base: &Address, target: &Address, tag: S, -) -> Result<(), ZomeApiError> { +) -> Result { Dispatch::LinkEntries.with_input(LinkEntriesArgs { base: base.clone(), target: target.clone(), @@ -997,7 +997,7 @@ pub fn update_agent() -> ZomeApiResult
{ /// Commit a DeletionEntry to your local source chain that marks an entry as 'deleted' by setting /// its status metadata to `Deleted` and adding the DeleteEntry's address in the deleted entry's /// metadata, which will be used by validation routes. -pub fn remove_entry(address: &Address) -> ZomeApiResult<()> { +pub fn remove_entry(address: &Address) -> ZomeApiResult
{ Dispatch::RemoveEntry.with_input(address.to_owned()) } diff --git a/hdk-rust/tests/integration_test.rs b/hdk-rust/tests/integration_test.rs index eb64a5567f..1773d4652e 100755 --- a/hdk-rust/tests/integration_test.rs +++ b/hdk-rust/tests/integration_test.rs @@ -575,7 +575,7 @@ fn can_link_entries() { let result = make_test_call(&mut hc, "link_two_entries", r#"{}"#); assert!(result.is_ok(), "\t result = {:?}", result); - assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":null}"#)); + assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#)); } #[test] @@ -584,7 +584,7 @@ fn can_remove_link() { let result = make_test_call(&mut hc, "link_two_entries", r#"{}"#); assert!(result.is_ok(), "\t result = {:?}", result); - assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":null}"#)); + assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#)); } #[test] diff --git a/hdk-rust/wasm-test/src/lib.rs b/hdk-rust/wasm-test/src/lib.rs index d8daf4f496..286a56c8d7 100755 --- a/hdk-rust/wasm-test/src/lib.rs +++ b/hdk-rust/wasm-test/src/lib.rs @@ -125,7 +125,7 @@ fn handle_commit_validation_package_tester() -> ZomeApiResult
{ )) } -fn handle_link_two_entries() -> ZomeApiResult<()> { +fn handle_link_two_entries() -> ZomeApiResult
{ let entry_1 = Entry::App( "testEntryType".into(), EntryStruct { @@ -610,7 +610,7 @@ define_zome! { link_two_entries: { inputs: | |, - outputs: |result: ZomeApiResult<()>|, + outputs: |result: ZomeApiResult
|, handler: handle_link_two_entries } From ccf4ac0c334a331e714cbbe9b744ab75b79155d3 Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 12:55:23 -0400 Subject: [PATCH 30/83] Update test.js --- app_spec/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index 4500afc04c..d97ac991ba 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -266,7 +266,7 @@ scenario2.runTape('delete_entry_post', async (t, { alice, bob }) => { const deletionParams = { post_address: createResult.Ok } const deletionResult = await alice.callSync("blog", "delete_entry_post", deletionParams) - t.notOk(deletionResult.Ok) + t.Ok(deletionResult.Ok) //delete should fail @@ -436,7 +436,7 @@ scenario2.runTape('remove_update_modifed_entry', async (t, { alice, bob }) => { //delete const removeParamsV2 = { post_address: createResult.Ok } const removeResultV2 = await bob.callSync("blog", "delete_entry_post", removeParamsV2) - t.notOk(removeResultV2.Ok) + t.Ok(removeResultV2.Ok) //get v2 using initial adders const Postv2Initial = alice.call("blog", "get_initial_post", { post_address: createResult.Ok }) From be6a004a57031d3c0a4bffed8a1429951eb6370e Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 12:58:13 -0400 Subject: [PATCH 31/83] Update link_entries.rs --- core/src/nucleus/ribosome/api/link_entries.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/nucleus/ribosome/api/link_entries.rs b/core/src/nucleus/ribosome/api/link_entries.rs index 9f477d6a0e..a1e5e98624 100644 --- a/core/src/nucleus/ribosome/api/link_entries.rs +++ b/core/src/nucleus/ribosome/api/link_entries.rs @@ -3,10 +3,10 @@ use crate::{ workflows::author_entry::author_entry, }; use holochain_core_types::{ + cas::content::{Address, AddressableContent}, entry::Entry, error::HolochainError, link::{link_data::LinkData, LinkActionKind}, - cas::content::{Address,AddressableContent} }; use holochain_wasm_utils::api_serialization::link_entries::LinkEntriesArgs; use std::convert::TryFrom; @@ -56,11 +56,11 @@ pub mod tests { }, }; use holochain_core_types::{ - cas::content::{Address,AddressableContent}, + cas::content::{Address, AddressableContent}, entry::{test_entry, Entry}, error::{CoreError, ZomeApiInternalResult}, + hash::HashString, json::JsonString, - hash::HashString }; use holochain_wasm_utils::api_serialization::link_entries::*; use serde_json; @@ -146,7 +146,9 @@ pub mod tests { test_link_args_bytes(String::from("test-tag")), ); - let no_entry: Option
= Some(HashString::from("QmWXM2r3iujqGvka8XMKU2wLdz5N14bEhvDp7Rx3R3oaEP")); + let no_entry: Option
= Some(HashString::from( + "QmWXM2r3iujqGvka8XMKU2wLdz5N14bEhvDp7Rx3R3oaEP", + )); let result = ZomeApiInternalResult::success(no_entry); assert_eq!( call_result, @@ -191,7 +193,9 @@ pub mod tests { test_link_2_args_bytes(String::from("test-tag")), ); - let no_entry: Option
= Some(HashString::from("QmcmcrbAfoaqJMZun74Xs1TsCUndXAohJNrKu7xZyr68P8")); + let no_entry: Option
= Some(HashString::from( + "QmcmcrbAfoaqJMZun74Xs1TsCUndXAohJNrKu7xZyr68P8", + )); let result = ZomeApiInternalResult::success(no_entry); assert_eq!( From 6d7319f74f379cbc00a41a33d07aabdbd3d9ee6c Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 13:03:34 -0400 Subject: [PATCH 32/83] Update integration_test.rs --- hdk-rust/tests/integration_test.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hdk-rust/tests/integration_test.rs b/hdk-rust/tests/integration_test.rs index 1773d4652e..53b27d4357 100755 --- a/hdk-rust/tests/integration_test.rs +++ b/hdk-rust/tests/integration_test.rs @@ -575,7 +575,10 @@ fn can_link_entries() { let result = make_test_call(&mut hc, "link_two_entries", r#"{}"#); assert!(result.is_ok(), "\t result = {:?}", result); - assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#)); + assert_eq!( + result.unwrap(), + JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#) + ); } #[test] @@ -584,7 +587,10 @@ fn can_remove_link() { let result = make_test_call(&mut hc, "link_two_entries", r#"{}"#); assert!(result.is_ok(), "\t result = {:?}", result); - assert_eq!(result.unwrap(), JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#)); + assert_eq!( + result.unwrap(), + JsonString::from_json(r#"{"Ok":"QmQvTQKNEXSrPxqB8VBz7vmpf44vubPD7jhPTWRBATZuDD"}"#) + ); } #[test] From 16ef2ea03c03fd3724eca9c0163aa1e4b983de69 Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 13:31:18 -0400 Subject: [PATCH 33/83] fixed app_sec tests --- app_spec/test/regressions.js | 6 +++--- app_spec/test/test.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app_spec/test/regressions.js b/app_spec/test/regressions.js index b439992d77..826568956a 100644 --- a/app_spec/test/regressions.js +++ b/app_spec/test/regressions.js @@ -70,7 +70,7 @@ scenario.runTape('alice create & publish post -> recommend own post to self', as agent_address: alice.agentId }) console.log("linked: ", linked) - t.equal(linked.Ok, null) + t.equal(linked.Ok, "QmQja9SJhYWA5B3myrtnd9bR6dNeaFj6Lr3DRjumfTPWaX") const recommendedPosts = alice.call('blog', 'my_recommended_posts', {}) console.log("recommendedPosts", recommendedPosts) @@ -94,7 +94,7 @@ scenario.runTape('alice create & publish post -> tash recommend to self', async agent_address: tash.agentId }) console.log("linked: ", linked) - t.equal(linked.Ok, null) + t.equal(linked.Ok, "QmYZKfRGykurtW96zv9ra8D9cof7Ki4Df8XFSgupWP711Y") const recommendedPosts = tash.call("blog", "my_recommended_posts", {}) console.log("recommendedPosts", recommendedPosts) @@ -118,7 +118,7 @@ scenario.runTape('create & publish post -> recommend to other agent', async (t, agent_address: tash.agentId }) console.log("linked: ", linked) - t.equal(linked.Ok, null) + t.equal(linked.Ok, "QmZg7WfQhyUMzfd68VJZg9ah6WhtpLSZQe9BHaz8pmN3Pz") const recommendedPosts = tash.call('blog', 'my_recommended_posts', {}) console.log("recommendedPosts", recommendedPosts) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index d97ac991ba..0f34cbd494 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -436,7 +436,7 @@ scenario2.runTape('remove_update_modifed_entry', async (t, { alice, bob }) => { //delete const removeParamsV2 = { post_address: createResult.Ok } const removeResultV2 = await bob.callSync("blog", "delete_entry_post", removeParamsV2) - t.Ok(removeResultV2.Ok) + t.ok(removeResultV2.Ok) //get v2 using initial adders const Postv2Initial = alice.call("blog", "get_initial_post", { post_address: createResult.Ok }) From 4d7507833055add6a3529071ee42d13778b96990 Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Sat, 27 Apr 2019 13:52:28 -0400 Subject: [PATCH 34/83] Update test.js --- app_spec/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index 0f34cbd494..07381cb4a2 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -266,7 +266,7 @@ scenario2.runTape('delete_entry_post', async (t, { alice, bob }) => { const deletionParams = { post_address: createResult.Ok } const deletionResult = await alice.callSync("blog", "delete_entry_post", deletionParams) - t.Ok(deletionResult.Ok) + t.ok(deletionResult.Ok) //delete should fail From 5f0fc3d10fb7dc4ae8d15117b1ddd0d831d5574b Mon Sep 17 00:00:00 2001 From: carm Date: Sat, 27 Apr 2019 17:13:00 -0400 Subject: [PATCH 35/83] commit_entry_with_provenance -> commit_entry_result --- app_spec/zomes/blog/code/src/blog.rs | 8 +- conductor_api/wasm-test/src/lib.rs | 11 ++- core/src/nucleus/ribosome/api/commit.rs | 97 +++++-------------- core/src/nucleus/ribosome/api/get_entry.rs | 4 +- core/src/nucleus/ribosome/api/mod.rs | 7 +- core_types/src/entry/mod.rs | 21 ---- hdk-rust/src/api.rs | 22 ++--- .../src/api_serialization/commit_entry.rs | 54 +++++++++++ wasm_utils/src/api_serialization/mod.rs | 1 + 9 files changed, 102 insertions(+), 123 deletions(-) create mode 100644 wasm_utils/src/api_serialization/commit_entry.rs diff --git a/app_spec/zomes/blog/code/src/blog.rs b/app_spec/zomes/blog/code/src/blog.rs index 1f2c0218c0..ff24546d31 100644 --- a/app_spec/zomes/blog/code/src/blog.rs +++ b/app_spec/zomes/blog/code/src/blog.rs @@ -4,7 +4,7 @@ use hdk::{ holochain_core_types::{ cas::content::Address, dna::capabilities::CapabilityRequest, - entry::{cap_entries::CapabilityType, entry_type::EntryType, Entry, EntryWithProvenance}, + entry::{cap_entries::CapabilityType, entry_type::EntryType, Entry}, error::HolochainError, json::JsonString, signature::Provenance @@ -13,6 +13,7 @@ use hdk::{ get_entry::{ EntryHistory, GetEntryOptions, GetEntryResult, GetEntryResultType, StatusRequestKind, }, + commit_entry::CommitEntryOptions, get_links::{GetLinksOptions, GetLinksResult}, }, AGENT_ADDRESS, AGENT_ID_STR, CAPABILITY_REQ, DNA_ADDRESS, DNA_NAME, PUBLIC_TOKEN, @@ -154,10 +155,9 @@ pub fn handle_create_post_countersigned(content: String, in_reply_to: Option ) -> Result { // Put args in struct and serialize into memory let entry = Entry::App( entry_type_name.to_owned().into(), RawString::from(entry_value).into(), ); - let allocation_of_input = mem_stack.write_json(entry)?; + + let args = holochain_wasm_utils::api_serialization::commit_entry::CommitEntryArgs { + entry, + options:holochain_wasm_utils::api_serialization::commit_entry::CommitEntryOptions::new(provenance.to_vec()) + }; + let allocation_of_input = mem_stack.write_json(args)?; // Call WASMI-able commit let encoded_allocation_of_result = @@ -220,7 +227,7 @@ pub extern "C" fn commit_test( Err(code) => return code.into(), }; - let result = hdk_commit(&mut mem_stack, "testEntryType", "hello"); + let result = hdk_commit(&mut mem_stack, "testEntryType", "hello", &vec![]); return_code_for_allocation_result(mem_stack.write_json(result)).into() } diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 161f629521..1428a9e75c 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -2,57 +2,27 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::author_entry::author_entry, }; -use holochain_core_types::{ - cas::content::Address, - entry::{Entry, EntryWithProvenance}, - error::HolochainError, -}; +use holochain_core_types::{cas::content::Address, error::HolochainError}; + +use holochain_wasm_utils::api_serialization::commit_entry::CommitEntryArgs; + use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; -/// ZomeApiFunction::CommitAppEntry function code +/// ZomeApiFunction::CommitArgs function code /// args: [0] encoded MemoryAllocation as u64 -/// Expected complex argument: CommitArgs +/// Expected complex argument: CommitEntryArg /// Returns an HcApiReturnCode as I64 pub fn invoke_commit_app_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApiResult { let context = runtime.context()?; // deserialize args let args_str = runtime.load_json_string_from_args(&args); - let entry = match Entry::try_from(args_str.clone()) { - Ok(entry_input) => entry_input, - // Exit on error - Err(_) => { - context.log(format!( - "err/zome: invoke_commit_app_entry failed to deserialize Entry: {:?}", - args_str - )); - return ribosome_error_code!(ArgumentDeserializationFailed); - } - }; - // Wait for future to be resolved - let task_result: Result = - context.block_on(author_entry(&entry, None, &context, &vec![])); - - runtime.store_result(task_result) -} - -/// ZomeApiFunction::CommitAppEntryWithProvenance function code -/// args: [0] encoded MemoryAllocation as u64 -/// Expected complex argument: EntryWithProvenance -/// Returns an HcApiReturnCode as I64 -pub fn invoke_commit_app_entry_with_provenance( - runtime: &mut Runtime, - args: &RuntimeArgs, -) -> ZomeApiResult { - let context = runtime.context()?; - // deserialize args - let args_str = runtime.load_json_string_from_args(&args); - let entry_with_provenance = match EntryWithProvenance::try_from(args_str.clone()) { - Ok(entry_with_provenance_input) => entry_with_provenance_input, + let commit_entry_arg = match CommitEntryArgs::try_from(args_str.clone()) { + Ok(commit_entry_arg_input) => commit_entry_arg_input, // Exit on error Err(error) => { context.log(format!( - "err/zome: invoke_commit_app_entry_with_provenance failed to \ + "err/zome: invoke_commit_app_commit_entry_arg failed to \ deserialize Entry: {:?} with error {:?}", args_str, error )); @@ -61,10 +31,10 @@ pub fn invoke_commit_app_entry_with_provenance( }; // Wait for future to be resolved let task_result: Result = context.block_on(author_entry( - &entry_with_provenance.entry(), + &commit_entry_arg.entry(), None, &context, - &entry_with_provenance.provenances(), + &commit_entry_arg.options().provenance(), )); runtime.store_result(task_result) @@ -72,29 +42,23 @@ pub fn invoke_commit_app_entry_with_provenance( #[cfg(test)] pub mod tests { - use super::*; use crate::nucleus::ribosome::{ api::{tests::test_zome_api_function, ZomeApiFunction}, Defn, }; use holochain_core_types::{ cas::content::{Address, AddressableContent}, - entry::{test_entry, Entry}, + entry::test_entry, error::ZomeApiInternalResult, json::JsonString, signature::{Provenance, Signature}, }; - - /// dummy commit args from standard test entry - pub fn test_commit_args_bytes() -> Vec { - let entry = test_entry(); - - let serialized_entry = Entry::from(entry); - JsonString::from(serialized_entry).to_bytes() - } + use holochain_wasm_utils::api_serialization::commit_entry::{ + CommitEntryArgs, CommitEntryOptions, + }; /// dummy commit with provenance args from standard test entry - pub fn test_commit_with_provenance_args_bytes() -> Vec { + pub fn test_commit_entry_args_bytes() -> Vec { let entry = test_entry(); let address: Address = entry.address(); @@ -107,35 +71,18 @@ pub mod tests { )); let provenances = vec![Provenance::new(agent_id.address(), signature)]; - let serialized_entry_with_provenance = EntryWithProvenance::new(entry, provenances); - JsonString::from(serialized_entry_with_provenance).to_bytes() - } - - #[test] - /// test that we can round trip bytes through a commit action and get the result from WASM - fn test_commit_round_trip() { - let (call_result, _) = test_zome_api_function( - ZomeApiFunction::CommitAppEntry.as_str(), - test_commit_args_bytes(), - ); - - assert_eq!( - call_result, - JsonString::from_json( - &(String::from(JsonString::from(ZomeApiInternalResult::success( - Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq") - ))) + "\u{0}") - ), - ); + let serialized_commit_entry_arg = + CommitEntryArgs::new(entry, CommitEntryOptions::new(provenances)); + JsonString::from(serialized_commit_entry_arg).to_bytes() } #[test] /// test that we can round trip bytes through a commit action with /// additional provenance and get the result from WASM - fn test_commit_with_provenance_round_trip() { + fn test_commit_round_trip() { let (call_result, _) = test_zome_api_function( - ZomeApiFunction::CommitAppEntryWithProvenance.as_str(), - test_commit_with_provenance_args_bytes(), + ZomeApiFunction::CommitAppEntry.as_str(), + test_commit_entry_args_bytes(), ); assert_eq!( diff --git a/core/src/nucleus/ribosome/api/get_entry.rs b/core/src/nucleus/ribosome/api/get_entry.rs index 416f8acd4f..6a1a8e51e1 100644 --- a/core/src/nucleus/ribosome/api/get_entry.rs +++ b/core/src/nucleus/ribosome/api/get_entry.rs @@ -43,7 +43,7 @@ pub mod tests { ribosome::{ self, api::{ - commit::tests::test_commit_args_bytes, + commit::tests::test_commit_entry_args_bytes, tests::{test_parameters, test_zome_name}, }, runtime::WasmCallData, @@ -213,7 +213,7 @@ pub mod tests { test_parameters(), ); let call_result = ribosome::run_dna( - Some(test_commit_args_bytes()), + Some(test_commit_entry_args_bytes()), WasmCallData::new_zome_call(Arc::clone(&context), commit_call), ) .expect("test should be callable"); diff --git a/core/src/nucleus/ribosome/api/mod.rs b/core/src/nucleus/ribosome/api/mod.rs index 6cc19e562a..62269fc0ac 100644 --- a/core/src/nucleus/ribosome/api/mod.rs +++ b/core/src/nucleus/ribosome/api/mod.rs @@ -26,7 +26,7 @@ use crate::nucleus::ribosome::{ api::{ call::invoke_call, capabilities::invoke_grant_capability, - commit::{invoke_commit_app_entry, invoke_commit_app_entry_with_provenance}, + commit::invoke_commit_app_entry, debug::invoke_debug, entry_address::invoke_entry_address, get_entry::invoke_get_entry, @@ -69,11 +69,6 @@ link_zome_api! { /// commit_entry(entry_type: String, entry_value: String) -> Address "hc_commit_entry", CommitAppEntry, invoke_commit_app_entry; - /// Commit an app entry with additional provenances to source chain - /// commit_entry_with_provenance(entry_type: String, entry_value: String, provenances: Vec) -> Address - "hc_commit_entry_with_provenance", CommitAppEntryWithProvenance, invoke_commit_app_entry_with_provenance; - - /// Get an app entry from source chain by key (header hash) /// get_entry(address: Address) -> Entry "hc_get_entry", GetAppEntry, invoke_get_entry; diff --git a/core_types/src/entry/mod.rs b/core_types/src/entry/mod.rs index e94a4f8572..25d1b7e1c1 100644 --- a/core_types/src/entry/mod.rs +++ b/core_types/src/entry/mod.rs @@ -23,7 +23,6 @@ use json::{default_to_json, default_try_from_json, JsonString, RawString}; use link::{link_data::LinkData, link_list::LinkList}; use multihash::Hash; use serde::{ser::SerializeTuple, Deserialize, Deserializer, Serializer}; -use signature::Provenance; use snowflake; use std::convert::TryFrom; @@ -77,26 +76,6 @@ pub enum Entry { CapTokenGrant(CapTokenGrant), } -#[derive(Clone, Debug, Serialize, Deserialize, DefaultJson)] -pub struct EntryWithProvenance { - entry: Entry, - provenances: Vec, -} - -impl EntryWithProvenance { - pub fn new(entry: Entry, provenances: Vec) -> Self { - EntryWithProvenance { entry, provenances } - } - - pub fn entry(&self) -> Entry { - self.entry.clone() - } - - pub fn provenances(&self) -> Vec { - self.provenances.clone() - } -} - impl From> for JsonString { fn from(maybe_entry: Option) -> Self { default_to_json(maybe_entry) diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 6bb8944863..27b21d7e65 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -7,7 +7,7 @@ use holochain_core_types::{ dna::capabilities::CapabilityRequest, entry::{ cap_entries::{CapFunctions, CapabilityType}, - Entry, EntryWithProvenance, + Entry, }, error::{RibosomeEncodedAllocation, RibosomeEncodingBits, ZomeApiInternalResult}, signature::Provenance, @@ -17,6 +17,7 @@ pub use holochain_wasm_utils::api_serialization::validation::*; use holochain_wasm_utils::{ api_serialization::{ capabilities::GrantCapabilityArgs, + commit_entry::{CommitEntryArgs, CommitEntryOptions}, get_entry::{ EntryHistory, GetEntryArgs, GetEntryOptions, GetEntryResult, GetEntryResultType, StatusRequestKind, @@ -143,7 +144,6 @@ macro_rules! def_api_fns { def_api_fns! { hc_init_globals, InitGlobals; hc_commit_entry, CommitEntry; - hc_commit_entry_with_provenance, CommitEntryWithProvenance; hc_get_entry, GetEntry; hc_entry_address, EntryAddress; hc_query, Query; @@ -369,8 +369,6 @@ pub enum BundleOnClose { /// # #[no_mangle] /// # pub fn hc_commit_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] -/// # pub fn hc_commit_entry_with_provenance(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } -/// # #[no_mangle] /// # pub fn hc_get_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] /// # pub fn hc_entry_address(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } @@ -471,8 +469,6 @@ pub enum BundleOnClose { /// # #[no_mangle] /// # pub fn hc_commit_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] -/// # pub fn hc_commit_entry_with_provenance(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } -/// # #[no_mangle] /// # pub fn hc_get_entry(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } /// # #[no_mangle] /// # pub fn hc_entry_address(_: RibosomeEncodingBits) -> RibosomeEncodingBits { RibosomeEncodedValue::Success.into() } @@ -641,15 +637,15 @@ pub fn debug>(msg: J) -> ZomeApiResult<()> { /// /// # } /// ``` -pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ - Dispatch::CommitEntry.with_input(entry) +pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeApiResult
{ + Dispatch::CommitEntry.with_input(CommitEntryArgs { + entry: entry.clone(), + options, + }) } -// TODO document (copy / mutate the above) -pub fn commit_entry_with_provenance( - entry_with_provenance: &EntryWithProvenance, -) -> ZomeApiResult
{ - Dispatch::CommitEntryWithProvenance.with_input(entry_with_provenance) +pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ + commit_entry_result(entry, CommitEntryOptions::default()) } /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using diff --git a/wasm_utils/src/api_serialization/commit_entry.rs b/wasm_utils/src/api_serialization/commit_entry.rs new file mode 100644 index 0000000000..d6ce33455e --- /dev/null +++ b/wasm_utils/src/api_serialization/commit_entry.rs @@ -0,0 +1,54 @@ +use holochain_core_types::{entry::Entry, error::HolochainError, json::*, signature::Provenance}; + +/// Structure used to specify what should be returned to a call to commit_entry_result() +/// The default is to return the latest entry. +#[derive(Deserialize, Debug, Serialize, DefaultJson, PartialEq, Clone)] +pub struct CommitEntryOptions { + pub provenance: Vec, +} + +impl Default for CommitEntryOptions { + fn default() -> Self { + CommitEntryOptions { provenance: vec![] } + } +} + +impl CommitEntryOptions { + pub fn new(provenance: Vec) -> Self { + Self { provenance } + } + + pub fn provenance(&self) -> Vec { + self.provenance.clone() + } +} + +#[derive(Deserialize, Debug, Serialize, DefaultJson)] +pub struct CommitEntryArgs { + pub entry: Entry, + pub options: CommitEntryOptions, +} + +impl CommitEntryArgs { + pub fn new(entry: Entry, options: CommitEntryOptions) -> Self { + return Self { entry, options }; + } + + pub fn entry(&self) -> Entry { + self.entry.clone() + } + + pub fn options(&self) -> CommitEntryOptions { + self.options.clone() + } +} + +#[cfg(test)] +mod tests { + /* use super::*; + use holochain_core_types::{ + chain_header::test_chain_header, + entry::{test_entry, test_entry_a, test_entry_b}, + };*/ + +} diff --git a/wasm_utils/src/api_serialization/mod.rs b/wasm_utils/src/api_serialization/mod.rs index 9915e32e83..4bf0f63973 100644 --- a/wasm_utils/src/api_serialization/mod.rs +++ b/wasm_utils/src/api_serialization/mod.rs @@ -10,6 +10,7 @@ mod call; /// For the case of HDK-rust we can use the exact same types by /// importing this module. pub mod capabilities; +pub mod commit_entry; pub mod get_entry; pub mod get_links; pub mod keystore; From 0031d04dd4f56dad0f2f76d48fbe1aeff4afa9fc Mon Sep 17 00:00:00 2001 From: carm Date: Sat, 27 Apr 2019 21:44:07 -0400 Subject: [PATCH 36/83] Introduce CommitEntryResult type --- .../src/nucleus/actions/call_zome_function.rs | 2 +- core/src/nucleus/ribosome/api/call.rs | 6 ++-- core/src/nucleus/ribosome/api/commit.rs | 12 ++++--- core/src/nucleus/ribosome/api/get_entry.rs | 6 ++-- core/src/nucleus/ribosome/api/update_entry.rs | 4 +-- core/src/workflows/author_entry.rs | 8 +++-- hdk-rust/src/api.rs | 6 ++-- .../src/api_serialization/commit_entry.rs | 34 +++++++++++++------ 8 files changed, 49 insertions(+), 29 deletions(-) diff --git a/core/src/nucleus/actions/call_zome_function.rs b/core/src/nucleus/actions/call_zome_function.rs index 82080943c7..fbc56bdc31 100644 --- a/core/src/nucleus/actions/call_zome_function.rs +++ b/core/src/nucleus/actions/call_zome_function.rs @@ -391,7 +391,7 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant.clone()); let grant_addr = context .block_on(author_entry(&grant_entry, None, &context, &vec![])) - .unwrap(); + .unwrap().address(); let maybe_grant = get_grant(&context, &grant_addr); assert_eq!(maybe_grant, Some(grant)); } diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index ab03128b11..c150a0bdbb 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -334,7 +334,7 @@ pub mod tests { &test_setup.context, &vec![], )) - .unwrap(); + .unwrap().address(); let other_agent_context = test_context("other agent", None); let cap_request = make_cap_request_for_call(other_agent_context.clone(), addr, "test", "{}"); @@ -384,7 +384,7 @@ pub mod tests { &test_setup.context, &vec![], )) - .unwrap(); + .unwrap().address(); let cap_request = make_cap_request_for_call( test_context("random other agent", None), grant_addr.clone(), @@ -496,7 +496,7 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let grant_addr = context .block_on(author_entry(&grant_entry, None, &context, &vec![])) - .unwrap(); + .unwrap().address(); // make the call with a valid capability call from a random source should succeed let zome_call = ZomeFnCall::new( diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 1428a9e75c..82c560862d 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -2,9 +2,10 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::author_entry::author_entry, }; -use holochain_core_types::{cas::content::Address, error::HolochainError}; +use holochain_core_types::error::HolochainError; -use holochain_wasm_utils::api_serialization::commit_entry::CommitEntryArgs; +use holochain_wasm_utils::api_serialization::commit_entry:: + {CommitEntryArgs, CommitEntryResult}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; @@ -30,7 +31,7 @@ pub fn invoke_commit_app_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> Zom } }; // Wait for future to be resolved - let task_result: Result = context.block_on(author_entry( + let task_result: Result = context.block_on(author_entry( &commit_entry_arg.entry(), None, &context, @@ -54,7 +55,7 @@ pub mod tests { signature::{Provenance, Signature}, }; use holochain_wasm_utils::api_serialization::commit_entry::{ - CommitEntryArgs, CommitEntryOptions, + CommitEntryArgs, CommitEntryOptions, CommitEntryResult }; /// dummy commit with provenance args from standard test entry @@ -89,7 +90,8 @@ pub mod tests { call_result, JsonString::from_json( &(String::from(JsonString::from(ZomeApiInternalResult::success( - Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq") + CommitEntryResult::new( + Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq")) ))) + "\u{0}") ), ); diff --git a/core/src/nucleus/ribosome/api/get_entry.rs b/core/src/nucleus/ribosome/api/get_entry.rs index 6a1a8e51e1..4ae52e9b03 100644 --- a/core/src/nucleus/ribosome/api/get_entry.rs +++ b/core/src/nucleus/ribosome/api/get_entry.rs @@ -59,7 +59,9 @@ pub mod tests { error::ZomeApiInternalResult, json::JsonString, }; - use holochain_wasm_utils::api_serialization::get_entry::*; + use holochain_wasm_utils::api_serialization:: + {get_entry::*, commit_entry::CommitEntryResult}; + use std::sync::Arc; /// dummy get args from standard test entry @@ -222,7 +224,7 @@ pub mod tests { call_result, JsonString::from_json( &(String::from(JsonString::from(ZomeApiInternalResult::success( - test_entry().address() + CommitEntryResult::new(test_entry().address()) ))) + "\u{0}") ), ); diff --git a/core/src/nucleus/ribosome/api/update_entry.rs b/core/src/nucleus/ribosome/api/update_entry.rs index 9af50e9a8d..22f64298f0 100644 --- a/core/src/nucleus/ribosome/api/update_entry.rs +++ b/core/src/nucleus/ribosome/api/update_entry.rs @@ -3,7 +3,7 @@ use crate::{ workflows::{author_entry::author_entry, get_entry_result::get_entry_result_workflow}, }; use holochain_core_types::{ - cas::content::{Address, AddressableContent}, + cas::content::AddressableContent, entry::Entry, error::HolochainError, }; @@ -53,7 +53,7 @@ pub fn invoke_update_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi // Create Chain Entry let entry = Entry::from(entry_args.new_entry.clone()); - let res: Result = context + let res: Result<_, HolochainError> = context .block_on(author_entry( &entry, Some(latest_entry.clone().address()), diff --git a/core/src/workflows/author_entry.rs b/core/src/workflows/author_entry.rs index d8baca48c7..aeb2dc43ca 100644 --- a/core/src/workflows/author_entry.rs +++ b/core/src/workflows/author_entry.rs @@ -16,6 +16,8 @@ use holochain_core_types::{ validation::{EntryLifecycle, ValidationData}, }; +use holochain_wasm_utils::api_serialization::commit_entry::CommitEntryResult; + use std::{sync::Arc, vec::Vec}; pub async fn author_entry<'a>( @@ -23,7 +25,7 @@ pub async fn author_entry<'a>( maybe_link_update_delete: Option
, context: &'a Arc, provenances: &'a Vec, -) -> Result { +) -> Result { let address = entry.address(); context.log(format!( "debug/workflow/authoring_entry: {} with content: {:?}", @@ -86,7 +88,7 @@ pub async fn author_entry<'a>( address )); } - Ok(addr) + Ok(CommitEntryResult::new(addr)) } #[cfg(test)] @@ -112,7 +114,7 @@ pub mod tests { &context1, &vec![], )) - .unwrap(); + .unwrap().address(); thread::sleep(time::Duration::from_millis(500)); let mut json: Option = None; diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index 27b21d7e65..c45144e362 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -17,7 +17,7 @@ pub use holochain_wasm_utils::api_serialization::validation::*; use holochain_wasm_utils::{ api_serialization::{ capabilities::GrantCapabilityArgs, - commit_entry::{CommitEntryArgs, CommitEntryOptions}, + commit_entry::{CommitEntryArgs, CommitEntryOptions, CommitEntryResult}, get_entry::{ EntryHistory, GetEntryArgs, GetEntryOptions, GetEntryResult, GetEntryResultType, StatusRequestKind, @@ -637,7 +637,7 @@ pub fn debug>(msg: J) -> ZomeApiResult<()> { /// /// # } /// ``` -pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeApiResult
{ +pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeApiResult { Dispatch::CommitEntry.with_input(CommitEntryArgs { entry: entry.clone(), options, @@ -645,7 +645,7 @@ pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeAp } pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ - commit_entry_result(entry, CommitEntryOptions::default()) + commit_entry_result(entry, CommitEntryOptions::default()).map(|result| result.address()) } /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using diff --git a/wasm_utils/src/api_serialization/commit_entry.rs b/wasm_utils/src/api_serialization/commit_entry.rs index d6ce33455e..ccfe649f99 100644 --- a/wasm_utils/src/api_serialization/commit_entry.rs +++ b/wasm_utils/src/api_serialization/commit_entry.rs @@ -1,13 +1,16 @@ -use holochain_core_types::{entry::Entry, error::HolochainError, json::*, signature::Provenance}; +use holochain_core_types::{cas::content::Address, + entry::Entry, error::HolochainError, json::*, signature::Provenance +}; -/// Structure used to specify what should be returned to a call to commit_entry_result() -/// The default is to return the latest entry. +/// Structure used to specify additional options to a commit_entry_result call. #[derive(Deserialize, Debug, Serialize, DefaultJson, PartialEq, Clone)] pub struct CommitEntryOptions { pub provenance: Vec, } impl Default for CommitEntryOptions { + + /// The default CommitEntryOptions has no additional provenance. fn default() -> Self { CommitEntryOptions { provenance: vec![] } } @@ -23,6 +26,8 @@ impl CommitEntryOptions { } } + +/// The arguments required to execute a commit_entry_result() call. #[derive(Deserialize, Debug, Serialize, DefaultJson)] pub struct CommitEntryArgs { pub entry: Entry, @@ -43,12 +48,21 @@ impl CommitEntryArgs { } } -#[cfg(test)] -mod tests { - /* use super::*; - use holochain_core_types::{ - chain_header::test_chain_header, - entry::{test_entry, test_entry_a, test_entry_b}, - };*/ +/// Represents any useful information to return after +/// entries are committed +#[derive(Deserialize, Debug, Clone, Serialize, DefaultJson)] +pub struct CommitEntryResult { + pub address: Address, +} + +impl CommitEntryResult { + pub fn new(address:Address) -> Self { + Self { + address + } + } + + pub fn address(&self) -> Address { self.address.clone() } } + From 366515ff1593530afde3403240607efd8db73321 Mon Sep 17 00:00:00 2001 From: carm Date: Sat, 27 Apr 2019 21:53:06 -0400 Subject: [PATCH 37/83] Rust doc, update changelog --- CHANGELOG.md | 2 ++ hdk-rust/src/api.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0572cbb139..3ad2d46fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Adds hdk::grant_capability() for zome functions to be able to create [capability grant](doc/architecture/decisions/0017-capabilities.md) [#1285](https://github.com/holochain/holochain-rust/pull/1285) +- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320) + ### Changed - changed JSON-RPC Zome call `params` key to `args` for clarity (due to confusion between JSON-RPC `params` and Holochain `params` keys): see [#1203](https://github.com/holochain/holochain-rust/pull/1203) and [#1271](https://github.com/holochain/holochain-rust/pull/1271) - Remove sleeps during network initialization, block until P2pReady event is received [#1284](https://github.com/holochain/holochain-rust/pull/1284). diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index c45144e362..d66000b59c 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -637,6 +637,17 @@ pub fn debug>(msg: J) -> ZomeApiResult<()> { /// /// # } /// ``` +pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ + commit_entry_result(entry, CommitEntryOptions::default()).map(|result| result.address()) +} + + +/// Attempts to commit an entry to your local source chain. The entry +/// will have to pass the defined validation rules for that entry type. +/// If the entry type is defined as public, will also publish the entry to the DHT. +/// +/// Additional provenances can be added to the commit using the options argument. +/// Returns a CommitEntryResult which contains the address of the committed entry. pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeApiResult { Dispatch::CommitEntry.with_input(CommitEntryArgs { entry: entry.clone(), @@ -644,10 +655,6 @@ pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeAp }) } -pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ - commit_entry_result(entry, CommitEntryOptions::default()).map(|result| result.address()) -} - /// Retrieves latest version of an entry from the local chain or the DHT, by looking it up using /// the specified address. /// Returns None if no entry exists at the specified address or From e10cc65011fcb81d435a22c1ede754be02011979 Mon Sep 17 00:00:00 2001 From: carm Date: Sat, 27 Apr 2019 21:59:02 -0400 Subject: [PATCH 38/83] Return CommitEntryResult in author_entry workflow --- core/src/nucleus/actions/call_zome_function.rs | 3 ++- core/src/nucleus/ribosome/api/call.rs | 9 ++++++--- core/src/nucleus/ribosome/api/commit.rs | 10 +++++----- core/src/nucleus/ribosome/api/get_entry.rs | 3 +-- core/src/nucleus/ribosome/api/update_entry.rs | 6 +----- core/src/workflows/author_entry.rs | 3 ++- hdk-rust/src/api.rs | 6 ++++-- .../src/api_serialization/commit_entry.rs | 18 +++++++----------- 8 files changed, 28 insertions(+), 30 deletions(-) diff --git a/core/src/nucleus/actions/call_zome_function.rs b/core/src/nucleus/actions/call_zome_function.rs index fbc56bdc31..72e899cc88 100644 --- a/core/src/nucleus/actions/call_zome_function.rs +++ b/core/src/nucleus/actions/call_zome_function.rs @@ -391,7 +391,8 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant.clone()); let grant_addr = context .block_on(author_entry(&grant_entry, None, &context, &vec![])) - .unwrap().address(); + .unwrap() + .address(); let maybe_grant = get_grant(&context, &grant_addr); assert_eq!(maybe_grant, Some(grant)); } diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index c150a0bdbb..3524cee1cb 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -334,7 +334,8 @@ pub mod tests { &test_setup.context, &vec![], )) - .unwrap().address(); + .unwrap() + .address(); let other_agent_context = test_context("other agent", None); let cap_request = make_cap_request_for_call(other_agent_context.clone(), addr, "test", "{}"); @@ -384,7 +385,8 @@ pub mod tests { &test_setup.context, &vec![], )) - .unwrap().address(); + .unwrap() + .address(); let cap_request = make_cap_request_for_call( test_context("random other agent", None), grant_addr.clone(), @@ -496,7 +498,8 @@ pub mod tests { let grant_entry = Entry::CapTokenGrant(grant); let grant_addr = context .block_on(author_entry(&grant_entry, None, &context, &vec![])) - .unwrap().address(); + .unwrap() + .address(); // make the call with a valid capability call from a random source should succeed let zome_call = ZomeFnCall::new( diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index 82c560862d..f98593b6c2 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -4,8 +4,7 @@ use crate::{ }; use holochain_core_types::error::HolochainError; -use holochain_wasm_utils::api_serialization::commit_entry:: - {CommitEntryArgs, CommitEntryResult}; +use holochain_wasm_utils::api_serialization::commit_entry::{CommitEntryArgs, CommitEntryResult}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; @@ -55,7 +54,7 @@ pub mod tests { signature::{Provenance, Signature}, }; use holochain_wasm_utils::api_serialization::commit_entry::{ - CommitEntryArgs, CommitEntryOptions, CommitEntryResult + CommitEntryArgs, CommitEntryOptions, CommitEntryResult, }; /// dummy commit with provenance args from standard test entry @@ -90,8 +89,9 @@ pub mod tests { call_result, JsonString::from_json( &(String::from(JsonString::from(ZomeApiInternalResult::success( - CommitEntryResult::new( - Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq")) + CommitEntryResult::new(Address::from( + "Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq" + )) ))) + "\u{0}") ), ); diff --git a/core/src/nucleus/ribosome/api/get_entry.rs b/core/src/nucleus/ribosome/api/get_entry.rs index 4ae52e9b03..8ca4914c66 100644 --- a/core/src/nucleus/ribosome/api/get_entry.rs +++ b/core/src/nucleus/ribosome/api/get_entry.rs @@ -59,8 +59,7 @@ pub mod tests { error::ZomeApiInternalResult, json::JsonString, }; - use holochain_wasm_utils::api_serialization:: - {get_entry::*, commit_entry::CommitEntryResult}; + use holochain_wasm_utils::api_serialization::{commit_entry::CommitEntryResult, get_entry::*}; use std::sync::Arc; diff --git a/core/src/nucleus/ribosome/api/update_entry.rs b/core/src/nucleus/ribosome/api/update_entry.rs index 22f64298f0..b911cae696 100644 --- a/core/src/nucleus/ribosome/api/update_entry.rs +++ b/core/src/nucleus/ribosome/api/update_entry.rs @@ -2,11 +2,7 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::{author_entry::author_entry, get_entry_result::get_entry_result_workflow}, }; -use holochain_core_types::{ - cas::content::AddressableContent, - entry::Entry, - error::HolochainError, -}; +use holochain_core_types::{cas::content::AddressableContent, entry::Entry, error::HolochainError}; use holochain_wasm_utils::api_serialization::{get_entry::*, UpdateEntryArgs}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; diff --git a/core/src/workflows/author_entry.rs b/core/src/workflows/author_entry.rs index aeb2dc43ca..234bbb96c8 100644 --- a/core/src/workflows/author_entry.rs +++ b/core/src/workflows/author_entry.rs @@ -114,7 +114,8 @@ pub mod tests { &context1, &vec![], )) - .unwrap().address(); + .unwrap() + .address(); thread::sleep(time::Duration::from_millis(500)); let mut json: Option = None; diff --git a/hdk-rust/src/api.rs b/hdk-rust/src/api.rs index d66000b59c..09f90bbcb6 100644 --- a/hdk-rust/src/api.rs +++ b/hdk-rust/src/api.rs @@ -641,14 +641,16 @@ pub fn commit_entry(entry: &Entry) -> ZomeApiResult
{ commit_entry_result(entry, CommitEntryOptions::default()).map(|result| result.address()) } - /// Attempts to commit an entry to your local source chain. The entry /// will have to pass the defined validation rules for that entry type. /// If the entry type is defined as public, will also publish the entry to the DHT. /// /// Additional provenances can be added to the commit using the options argument. /// Returns a CommitEntryResult which contains the address of the committed entry. -pub fn commit_entry_result(entry: &Entry, options: CommitEntryOptions) -> ZomeApiResult { +pub fn commit_entry_result( + entry: &Entry, + options: CommitEntryOptions, +) -> ZomeApiResult { Dispatch::CommitEntry.with_input(CommitEntryArgs { entry: entry.clone(), options, diff --git a/wasm_utils/src/api_serialization/commit_entry.rs b/wasm_utils/src/api_serialization/commit_entry.rs index ccfe649f99..3c7ffbbae6 100644 --- a/wasm_utils/src/api_serialization/commit_entry.rs +++ b/wasm_utils/src/api_serialization/commit_entry.rs @@ -1,5 +1,5 @@ -use holochain_core_types::{cas::content::Address, - entry::Entry, error::HolochainError, json::*, signature::Provenance +use holochain_core_types::{ + cas::content::Address, entry::Entry, error::HolochainError, json::*, signature::Provenance, }; /// Structure used to specify additional options to a commit_entry_result call. @@ -9,7 +9,6 @@ pub struct CommitEntryOptions { } impl Default for CommitEntryOptions { - /// The default CommitEntryOptions has no additional provenance. fn default() -> Self { CommitEntryOptions { provenance: vec![] } @@ -26,7 +25,6 @@ impl CommitEntryOptions { } } - /// The arguments required to execute a commit_entry_result() call. #[derive(Deserialize, Debug, Serialize, DefaultJson)] pub struct CommitEntryArgs { @@ -56,13 +54,11 @@ pub struct CommitEntryResult { } impl CommitEntryResult { - - pub fn new(address:Address) -> Self { - Self { - address - } + pub fn new(address: Address) -> Self { + Self { address } } - pub fn address(&self) -> Address { self.address.clone() } + pub fn address(&self) -> Address { + self.address.clone() + } } - From ede50b1c4f5e919f6a2384c436334472a453472a Mon Sep 17 00:00:00 2001 From: carm Date: Sun, 28 Apr 2019 14:37:15 -0400 Subject: [PATCH 39/83] Fix compiler error in blog.rs --- app_spec/zomes/blog/code/src/blog.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_spec/zomes/blog/code/src/blog.rs b/app_spec/zomes/blog/code/src/blog.rs index ff24546d31..34cf5c2d40 100644 --- a/app_spec/zomes/blog/code/src/blog.rs +++ b/app_spec/zomes/blog/code/src/blog.rs @@ -157,7 +157,7 @@ pub fn handle_create_post_countersigned(content: String, in_reply_to: Option Date: Sun, 28 Apr 2019 15:06:44 -0400 Subject: [PATCH 40/83] Fix update entry regression --- core/src/nucleus/ribosome/api/update_entry.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/nucleus/ribosome/api/update_entry.rs b/core/src/nucleus/ribosome/api/update_entry.rs index b911cae696..b90a96f6f6 100644 --- a/core/src/nucleus/ribosome/api/update_entry.rs +++ b/core/src/nucleus/ribosome/api/update_entry.rs @@ -2,7 +2,11 @@ use crate::{ nucleus::ribosome::{api::ZomeApiResult, Runtime}, workflows::{author_entry::author_entry, get_entry_result::get_entry_result_workflow}, }; -use holochain_core_types::{cas::content::AddressableContent, entry::Entry, error::HolochainError}; +use holochain_core_types::{ + cas::content::{Address, AddressableContent}, + entry::Entry, + error::HolochainError, +}; use holochain_wasm_utils::api_serialization::{get_entry::*, UpdateEntryArgs}; use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; @@ -49,13 +53,14 @@ pub fn invoke_update_entry(runtime: &mut Runtime, args: &RuntimeArgs) -> ZomeApi // Create Chain Entry let entry = Entry::from(entry_args.new_entry.clone()); - let res: Result<_, HolochainError> = context + let res: Result = context .block_on(author_entry( &entry, Some(latest_entry.clone().address()), &context.clone(), &vec![], // TODO should provenance be a parameter? )) + .map(|result| result.address()) .map_err(|validation_error| HolochainError::from(validation_error)); runtime.store_result(res) From cb45fbf024146bdff0e16c29a35ceb038813b9f5 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 19:52:08 +1000 Subject: [PATCH 41/83] wip on binary release process for dist --- holonix/dist/build.nix | 14 ++++++++------ holonix/dist/cli/build.nix | 6 ++++++ holonix/dist/cli/config.nix | 11 +++++++++++ holonix/dist/cli/src/cli.nix | 7 +++++++ holonix/dist/conductor/build.nix | 6 ++++++ holonix/dist/conductor/config.nix | 11 +++++++++++ holonix/dist/conductor/src/conductor.nix | 7 +++++++ holonix/dist/src/audit.nix | 17 +++++++++++++++++ holonix/dist/src/hc.nix | 14 -------------- holonix/dist/src/holochain.nix | 14 -------------- holonix/dist/src/lib.nix | 14 +++++++------- 11 files changed, 80 insertions(+), 41 deletions(-) create mode 100644 holonix/dist/cli/build.nix create mode 100644 holonix/dist/cli/config.nix create mode 100644 holonix/dist/cli/src/cli.nix create mode 100644 holonix/dist/conductor/build.nix create mode 100644 holonix/dist/conductor/config.nix create mode 100644 holonix/dist/conductor/src/conductor.nix create mode 100644 holonix/dist/src/audit.nix delete mode 100644 holonix/dist/src/hc.nix delete mode 100644 holonix/dist/src/holochain.nix diff --git a/holonix/dist/build.nix b/holonix/dist/build.nix index f38a1f3ab1..a15e319ff5 100644 --- a/holonix/dist/build.nix +++ b/holonix/dist/build.nix @@ -1,14 +1,16 @@ let + pkgs = import ../nixpkgs/nixpkgs.nix; + + audit = import ./src/audit.nix; dist = import ./src/dist.nix; flush = import ./src/flush.nix; - - holochain = import ./src/holochain.nix; - hc = import ./src/hc.nix; in [ + pkgs.nix-prefetch-scripts + + audit dist flush - - holochain - hc ] +++ import ./cli/build.nix +++ import ./conductor/build.nix diff --git a/holonix/dist/cli/build.nix b/holonix/dist/cli/build.nix new file mode 100644 index 0000000000..fb506d3dec --- /dev/null +++ b/holonix/dist/cli/build.nix @@ -0,0 +1,6 @@ +let + cli = import ./src/cli.nix; +in +[ + cli +] diff --git a/holonix/dist/cli/config.nix b/holonix/dist/cli/config.nix new file mode 100644 index 0000000000..ec4415cb68 --- /dev/null +++ b/holonix/dist/cli/config.nix @@ -0,0 +1,11 @@ +{ + name = "cli"; + + sha256 = { + darwin = "0n0cq0b9x0jblbydjrpfql7qminkrnxnq8hcb6kb57q08i71pwza"; + linux = "15frnjn3q4mfsg53dy59mwnkhzwkf6iwm0d5jix2d575i8cyn5xi"; + }; + + binary = "hc"; + +} diff --git a/holonix/dist/cli/src/cli.nix b/holonix/dist/cli/src/cli.nix new file mode 100644 index 0000000000..cc1e6012d1 --- /dev/null +++ b/holonix/dist/cli/src/cli.nix @@ -0,0 +1,7 @@ +let + pkgs = import ../../../nixpkgs/nixpkgs.nix; + lib = import ../../src/lib.nix; + + args = import ../config.nix; +in +lib.binary-derivation args diff --git a/holonix/dist/conductor/build.nix b/holonix/dist/conductor/build.nix new file mode 100644 index 0000000000..b6e5833b8c --- /dev/null +++ b/holonix/dist/conductor/build.nix @@ -0,0 +1,6 @@ +let + conductor = import ./src/conductor.nix; +in +[ + conductor +] diff --git a/holonix/dist/conductor/config.nix b/holonix/dist/conductor/config.nix new file mode 100644 index 0000000000..4774851d5c --- /dev/null +++ b/holonix/dist/conductor/config.nix @@ -0,0 +1,11 @@ +{ + name = "conductor"; + + sha256 = { + darwin = "012kga02mnci4vj92jxm1jp5w5z8x0phh4s7hbg0vihk56png43n"; + linux = "0wdlv85vwwp9cwnmnsp20aafrxljsxlc6m00h0905q0cydsf86kq"; + }; + + binary = "holochain"; + +} diff --git a/holonix/dist/conductor/src/conductor.nix b/holonix/dist/conductor/src/conductor.nix new file mode 100644 index 0000000000..cc1e6012d1 --- /dev/null +++ b/holonix/dist/conductor/src/conductor.nix @@ -0,0 +1,7 @@ +let + pkgs = import ../../../nixpkgs/nixpkgs.nix; + lib = import ../../src/lib.nix; + + args = import ../config.nix; +in +lib.binary-derivation args diff --git a/holonix/dist/src/audit.nix b/holonix/dist/src/audit.nix new file mode 100644 index 0000000000..473ee2bde3 --- /dev/null +++ b/holonix/dist/src/audit.nix @@ -0,0 +1,17 @@ +let + pkgs = import ../../nixpkgs/nixpkgs.nix; + + dist = import ../config.nix; + + name = "hc-dist-audit"; + + script = pkgs.writeShellScriptBin name + '' + echo + echo "All the important dist vars:" + echo + + echo "Binary version is ${dist.version}" + ''; +in +script diff --git a/holonix/dist/src/hc.nix b/holonix/dist/src/hc.nix deleted file mode 100644 index fe7961fd74..0000000000 --- a/holonix/dist/src/hc.nix +++ /dev/null @@ -1,14 +0,0 @@ -let - pkgs = import ../../nixpkgs/nixpkgs.nix; - lib = import ./lib.nix; -in -lib.binary-derivation { - name = "cli"; - sha256 = if pkgs.stdenv.isDarwin - then - "0n0cq0b9x0jblbydjrpfql7qminkrnxnq8hcb6kb57q08i71pwza" - else - "15frnjn3q4mfsg53dy59mwnkhzwkf6iwm0d5jix2d575i8cyn5xi" - ; - binary = "hc"; -} diff --git a/holonix/dist/src/holochain.nix b/holonix/dist/src/holochain.nix deleted file mode 100644 index d0e369ff54..0000000000 --- a/holonix/dist/src/holochain.nix +++ /dev/null @@ -1,14 +0,0 @@ -let - pkgs = import ../../nixpkgs/nixpkgs.nix; - lib = import ./lib.nix; -in -lib.binary-derivation { - name = "conductor"; - sha256 = if pkgs.stdenv.isDarwin - then - "012kga02mnci4vj92jxm1jp5w5z8x0phh4s7hbg0vihk56png43n" - else - "0wdlv85vwwp9cwnmnsp20aafrxljsxlc6m00h0905q0cydsf86kq" - ; - binary = "holochain"; -} diff --git a/holonix/dist/src/lib.nix b/holonix/dist/src/lib.nix index f365cd2095..44f8e729ec 100644 --- a/holonix/dist/src/lib.nix +++ b/holonix/dist/src/lib.nix @@ -3,19 +3,19 @@ let rust = import ../../rust/config.nix; dist = import ../config.nix; git = import ../../git/config.nix; -in +in rec { + artifact-name = args: "${args.name}-v${dist.version}-${dist.artifact-target}"; + + artifact-url = args: "https://github.com/${git.github.repo}/releases/download/v${dist.version}/${artifact-name args}.tar.gz"; + binary-derivation = args: - let - artifact-name = "${args.name}-v${dist.version}-${dist.artifact-target}"; - in pkgs.stdenv.mkDerivation { name = "holochain-${args.name}"; - src = pkgs.fetchurl { - url = "https://github.com/${git.github.repo}/releases/download/v${dist.version}/${artifact-name}.tar.gz"; - sha256 = args.sha256; + url = artifact-url args; + sha256 = if pkgs.stdenv.isDarwin then args.sha256.darwin else args.sha256.linux; }; unpackPhase = "tar --strip-components=1 -zxvf $src"; From 4dfc63ff0389fa25ca5f19e6c8dc53d1cb138ade Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 20:39:40 +1000 Subject: [PATCH 42/83] bump binary versions for 0.0.13-alpha1 --- holonix/dist/cli/config.nix | 4 ++-- holonix/dist/conductor/config.nix | 4 ++-- holonix/dist/config.nix | 16 ++++++------- holonix/dist/src/audit.nix | 38 +++++++++++++++++++++++++++++++ holonix/dist/src/lib.nix | 4 ++-- 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/holonix/dist/cli/config.nix b/holonix/dist/cli/config.nix index ec4415cb68..8de8ee8ff3 100644 --- a/holonix/dist/cli/config.nix +++ b/holonix/dist/cli/config.nix @@ -2,8 +2,8 @@ name = "cli"; sha256 = { - darwin = "0n0cq0b9x0jblbydjrpfql7qminkrnxnq8hcb6kb57q08i71pwza"; - linux = "15frnjn3q4mfsg53dy59mwnkhzwkf6iwm0d5jix2d575i8cyn5xi"; + linux = "11fgjg5vib58n2fnz3x43cp1l5r4r9xckm18pcsv5p5240gbr69h"; + darwin = "0wdjn918hanjflmi264w2pkgmpi8b006jw90kcin4qgvcbfc6ibf"; }; binary = "hc"; diff --git a/holonix/dist/conductor/config.nix b/holonix/dist/conductor/config.nix index 4774851d5c..86f2fd238f 100644 --- a/holonix/dist/conductor/config.nix +++ b/holonix/dist/conductor/config.nix @@ -2,8 +2,8 @@ name = "conductor"; sha256 = { - darwin = "012kga02mnci4vj92jxm1jp5w5z8x0phh4s7hbg0vihk56png43n"; - linux = "0wdlv85vwwp9cwnmnsp20aafrxljsxlc6m00h0905q0cydsf86kq"; + linux = "0c1fxzf1k6pxmklvyjb6xbqcwwck01cwkl7zwhzgc1sq9zp4si17"; + darwin = "0yswl3dnhs90vdn5x5x2xq19rnvkq4n7nfk9pi66iq7qxzbz5mky"; }; binary = "holochain"; diff --git a/holonix/dist/config.nix b/holonix/dist/config.nix index 63d3041d6f..6f680a7aac 100644 --- a/holonix/dist/config.nix +++ b/holonix/dist/config.nix @@ -1,20 +1,20 @@ let pkgs = import ../nixpkgs/nixpkgs.nix; rust = import ../rust/config.nix; -in +in rec { path = "dist"; - version = "0.0.12-alpha1"; + version = "0.0.13-alpha1"; - artifact-target = if pkgs.stdenv.isDarwin - then - rust.generic-mac-target - else - builtins.replaceStrings + normalize-artifact-target = target: + builtins.replaceStrings [ "unknown" ] [ "generic" ] - rust.generic-linux-target; + target + ; + + artifact-target = normalize-artifact-target ( if pkgs.stdenv.isDarwin then rust.generic-mac-target else rust.generic-linux-target ); } diff --git a/holonix/dist/src/audit.nix b/holonix/dist/src/audit.nix index 473ee2bde3..72375b8793 100644 --- a/holonix/dist/src/audit.nix +++ b/holonix/dist/src/audit.nix @@ -1,7 +1,14 @@ let pkgs = import ../../nixpkgs/nixpkgs.nix; + rust = import ../../rust/config.nix; dist = import ../config.nix; + release = import ../../release/config.nix; + + cli = import ../cli/config.nix; + conductor = import ../conductor/config.nix; + + lib = import ./lib.nix; name = "hc-dist-audit"; @@ -11,7 +18,38 @@ let echo "All the important dist vars:" echo + echo "Release version is ${release.core.version.current}" echo "Binary version is ${dist.version}" + + echo + + echo "CLI linux hash is ${cli.sha256.linux}" + echo "CLI darwin hash is ${cli.sha256.darwin}" + + echo + + echo "Conductor linux hash is ${conductor.sha256.linux}" + echo "Conductor darwin hash is ${conductor.sha256.darwin}" + + echo + echo "All the prefetching:" + echo + + echo "CLI linux prefetch:" + nix-prefetch-url ${lib.artifact-url { name = cli.name; target = ( dist.normalize-artifact-target rust.generic-linux-target ); }} + echo + + echo "CLI darwin prefetch:" + nix-prefetch-url ${lib.artifact-url { name = cli.name; target = ( dist.normalize-artifact-target rust.generic-mac-target ); }} + echo + + echo "Conductor linux prefetch:" + nix-prefetch-url ${lib.artifact-url { name = conductor.name; target = ( dist.normalize-artifact-target rust.generic-linux-target ); }} + echo + + echo "Conductor darwin prefetch:" + nix-prefetch-url ${lib.artifact-url { name = conductor.name; target = ( dist.normalize-artifact-target rust.generic-mac-target ); }} + echo ''; in script diff --git a/holonix/dist/src/lib.nix b/holonix/dist/src/lib.nix index 44f8e729ec..2dc88a2559 100644 --- a/holonix/dist/src/lib.nix +++ b/holonix/dist/src/lib.nix @@ -5,7 +5,7 @@ let git = import ../../git/config.nix; in rec { - artifact-name = args: "${args.name}-v${dist.version}-${dist.artifact-target}"; + artifact-name = args: "${args.name}-v${dist.version}-${args.target}"; artifact-url = args: "https://github.com/${git.github.repo}/releases/download/v${dist.version}/${artifact-name args}.tar.gz"; @@ -14,7 +14,7 @@ in rec name = "holochain-${args.name}"; src = pkgs.fetchurl { - url = artifact-url args; + url = artifact-url ( { target = dist.artifact-target; } // args ); sha256 = if pkgs.stdenv.isDarwin then args.sha256.darwin else args.sha256.linux; }; From e372cec3296d4e0265ae90f8eadfe0a3ddc6adf5 Mon Sep 17 00:00:00 2001 From: Chris Belfield Date: Mon, 29 Apr 2019 12:19:36 +0100 Subject: [PATCH 43/83] removing unnecessary build script --- build.ps1 | 430 ------------------------------------------------------ 1 file changed, 430 deletions(-) delete mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 25751fd3da..0000000000 --- a/build.ps1 +++ /dev/null @@ -1,430 +0,0 @@ -# Auto login image -#Reason to create callme.ps1 file is to make script copy-paste-able to PS windows and still be able to ask for password - -'Write-Warning "This script will overwrite current auto-logon settings if they exist" - -$user = whoami -$securePwd = Read-Host "Please enter password for current user to be saved for auto-logon" -AsSecureString - -#http://stackoverflow.com/questions/21741803/powershell-securestring-encrypt-decrypt-to-plain-text-not-working -$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd) -$pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) - -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -PropertyType String -Value 1 - -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUsername -PropertyType String -Value $user - -Remove-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue -New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -PropertyType String -Value $pwd - -del .\callme.ps1' > callme.ps1 - -.\callme.ps1 -####### - - -Write-Host "Changing PS execution policy to Unrestricted" -ForegroundColor Cyan -Set-ExecutionPolicy Unrestricted -Force - -Write-Host "Disabling Server Manager auto-start" -ForegroundColor Cyan -$serverManagerMachineKey = "HKLM:\SOFTWARE\Microsoft\ServerManager" -$serverManagerUserKey = "HKCU:\SOFTWARE\Microsoft\ServerManager" -if(Test-Path $serverManagerMachineKey) { - Set-ItemProperty -Path $serverManagerMachineKey -Name "DoNotOpenServerManagerAtLogon" -Value 1 - Write-Host "Disabled Server Manager at logon for all users" -ForegroundColor Green -} -if(Test-Path $serverManagerUserKey) { - Set-ItemProperty -Path $serverManagerUserKey -Name "CheckedUnattendLaunchSetting" -Value 0 - Write-Host "Disabled Server Manager for current user" -ForegroundColor Green -} - -# disable scheduled task -schtasks /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE - -Write-Host "Disabling UAC" -ForegroundColor Cyan - -Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Set-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0" - -Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green - -Write-Host "Disabling Windows Error Reporting (WER)" -ForegroundColor Cyan -$werKey = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Set-ItemProperty $werKey -Name "ForceQueue" -Value 1 - -if(Test-Path "$werKey\Consent") { - Set-ItemProperty "$werKey\Consent" -Name "DefaultConsent" -Value 1 -} -Write-Host "Windows Error Reporting (WER) dialog has been disabled." -ForegroundColor Green - -Write-Host "Disabling Internet Explorer ESC" -ForegroundColor Cyan -$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -if((Test-Path $AdminKey) -or (Test-Path $UserKey)) { - Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 - Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 - Stop-Process -Name Explorer - Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green -} - -Write-Host "WinRM - allow * hosts" -ForegroundColor Cyan -cmd /c 'winrm set winrm/config/client @{TrustedHosts="*"}' -Write-Host "WinRM configured" -ForegroundColor Green - -reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f -reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NetworkLocationWizard /v HideWizard /t REG_DWORD /d 1 /f - -$pathUtilsPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules\path-utils" -New-Item $pathUtilsPath -ItemType Directory -Force -(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/appveyor/ci/master/scripts/path-utils.psm1', "$pathUtilsPath\path-utils.psm1") -Remove-Module path-utils -ErrorAction SilentlyContinue -Import-Module path-utils - -$UserModulesPath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules" -$PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') -if(-not $PSModulePath.contains($UserModulesPath)) { - [Environment]::SetEnvironmentVariable('PSModulePath', "$PSModulePath;$UserModulesPath", 'Machine') -} - -Write-Host "Installing 7-Zip..." -ForegroundColor Cyan -$exePath = "$env:USERPROFILE\7z1604-x64.exe" -Invoke-WebRequest http://www.7-zip.org/a/7z1604-x64.exe -OutFile $exePath -cmd /c start /wait $exePath /S -del $exePath - -$sevenZipFolder = 'C:\Program Files\7-Zip' -Add-SessionPath $sevenZipFolder -Add-Path "$sevenZipFolder" - -Write-Host "7-Zip installed" -ForegroundColor Green - - -if(Test-Path 'C:\ProgramData\chocolatey\bin') { - # update - Write-Host "Updating Chocolatey..." -ForegroundColor Cyan - choco upgrade chocolatey -} else { - # install - Write-Host "Installing Chocolatey..." -ForegroundColor Cyan - iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) -} - -choco --version - -# enable -y -$configPath = "C:\ProgramData\chocolatey\config\chocolatey.config" -$config = [xml](Get-Content $configPath) -$allowGlobalConfirmation = $config.chocolatey.features.feature | where {$_.name -eq 'allowGlobalConfirmation'} -$allowGlobalConfirmation.enabled = 'true' -$allowGlobalConfirmation.setExplicitly = 'true' -$config.Save($configPath) - -Write-Host "Chocolatey installed" -ForegroundColor Green - -$webPIFolder = "$env:ProgramFiles\Microsoft\Web Platform Installer" -if([IO.File]::Exists("$webPIFolder\webpicmd.exe")) { - Add-SessionPath $webPIFolder - Write-Host "Web PI is already installed" -ForegroundColor Green - return -} - -Write-Host "Installing Web Platform Installer (Web PI)..." -ForegroundColor Cyan - -# http://www.iis.net/learn/install/web-platform-installer/web-platform-installer-direct-downloads -$msiPath = "$env:USERPROFILE\WebPlatformInstaller_amd64_en-US.msi" -(New-Object Net.WebClient).DownloadFile('http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi', $msiPath) - -cmd /c start /wait msiexec /i "$msiPath" /q -del $msiPath -Add-SessionPath $webPIFolder -Write-Host "Web PI installed" -ForegroundColor Green - -Write-Host "Installing NuGet..." -ForegroundColor Cyan - -# nuget 3.x -Write-Host "NuGet 3.x" -$nuget3Path = "$env:SYSTEMDRIVE\Tools\NuGet" -if(-not (Test-Path $nuget3Path)) { - New-Item $nuget3Path -ItemType Directory -Force | Out-Null -} - -(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', "$nuget3Path\nuget.exe") - -Remove-Path $nuget2Path -Remove-Path $nuget3Path - -# add default nuget configuration -$appDataNugetConfig = ' - - - - - -' -$configDirectory = "$env:APPDATA\NuGet" -if(-not (Test-Path $configDirectory)) { - New-Item $configDirectory -ItemType Directory -Force | Out-Null -} -Set-Content "$configDirectory\NuGet.config" -Value $appDataNugetConfig - -Add-Path $nuget3Path -Add-SessionPath $nuget3Path - -Write-Host "NuGet installed" -ForegroundColor Green - -Write-Host "Installing Git 2.14.1..." -ForegroundColor Cyan - -$exePath = "$env:TEMP\Git-2.14.1-64-bit.exe" - -Write-Host "Downloading..." -(New-Object Net.WebClient).DownloadFile('https://github.com/git-for-windows/git/releases/download/v2.14.1.windows.1/Git-2.14.1-64-bit.exe', $exePath) - -Write-Host "Installing..." -cmd /c start /wait $exePath /VERYSILENT /NORESTART /NOCANCEL /SP- /NOICONS /COMPONENTS="icons,icons\quicklaunch,ext,ext\reg,ext\reg\shellhere,ext\reg\guihere,assoc,assoc_sh" /LOG -del $exePath - -Add-Path "$env:ProgramFiles\Git\cmd" -$env:path = "$env:ProgramFiles\Git\cmd;$env:path" - -Add-Path "$env:ProgramFiles\Git\usr\bin" -$env:path = "$env:ProgramFiles\Git\usr\bin;$env:path" - -#Remove-Item 'C:\Program Files\Git\mingw64\etc\gitconfig' -git config --global core.autocrlf input -git config --system --unset credential.helper -#git config --global credential.helper store - -git --version -Write-Host "Git installed" -ForegroundColor Green - -Write-Host "Installing Git LFS..." -ForegroundColor Cyan - -# delete existing Git LFS -del 'C:\Program Files\Git\mingw64\bin\git-lfs.exe' -ErrorAction SilentlyContinue - -$exePath = "$env:TEMP\git-lfs-windows-2.2.1.exe" - -Write-Host "Downloading..." -(New-Object Net.WebClient).DownloadFile('https://github.com/git-lfs/git-lfs/releases/download/v2.2.1/git-lfs-windows-2.2.1.exe', $exePath) - -Write-Host "Installing..." -cmd /c start /wait $exePath /VERYSILENT /SUPPRESSMSGBOXES /NORESTART - -Add-Path "$env:ProgramFiles\Git LFS" -$env:path = "$env:ProgramFiles\Git LFS;$env:path" - -git lfs install --force -git lfs version - -Write-Host "Git LFS installed" -ForegroundColor Green - -function Get-IPs { - - Param( - [Parameter(Mandatory = $true)] - [array] $Subnets - ) - -foreach ($subnet in $subnets) - { - #Split IP and subnet - $IP = ($Subnet -split "\/")[0] - $SubnetBits = ($Subnet -split "\/")[1] - if ($SubnetBits -eq "32") { - $IP - } else { - #Convert IP into binary - #Split IP into different octects and for each one, figure out the binary with leading zeros and add to the total - $Octets = $IP -split "\." - $IPInBinary = @() - foreach($Octet in $Octets) - { - #convert to binary - $OctetInBinary = [convert]::ToString($Octet,2) - - #get length of binary string add leading zeros to make octet - $OctetInBinary = ("0" * (8 - ($OctetInBinary).Length) + $OctetInBinary) - - $IPInBinary = $IPInBinary + $OctetInBinary - } - $IPInBinary = $IPInBinary -join "" - - #Get network ID by subtracting subnet mask - $HostBits = 32-$SubnetBits - $NetworkIDInBinary = $IPInBinary.Substring(0,$SubnetBits) - - #Get host ID and get the first host ID by converting all 1s into 0s - $HostIDInBinary = $IPInBinary.Substring($SubnetBits,$HostBits) - $HostIDInBinary = $HostIDInBinary -replace "1","0" - - #Work out all the host IDs in that subnet by cycling through $i from 1 up to max $HostIDInBinary (i.e. 1s stringed up to $HostBits) - #Work out max $HostIDInBinary - $imax = [convert]::ToInt32(("1" * $HostBits),2) -1 - - $IPs = @() - - #Next ID is first network ID converted to decimal plus $i then converted to binary - For ($i = 1 ; $i -le $imax ; $i++) - { - #Convert to decimal and add $i - $NextHostIDInDecimal = ([convert]::ToInt32($HostIDInBinary,2) + $i) - #Convert back to binary - $NextHostIDInBinary = [convert]::ToString($NextHostIDInDecimal,2) - #Add leading zeros - #Number of zeros to add - $NoOfZerosToAdd = $HostIDInBinary.Length - $NextHostIDInBinary.Length - $NextHostIDInBinary = ("0" * $NoOfZerosToAdd) + $NextHostIDInBinary - - #Work out next IP - #Add networkID to hostID - $NextIPInBinary = $NetworkIDInBinary + $NextHostIDInBinary - #Split into octets and separate by . then join - $IP = @() - For ($x = 1 ; $x -le 4 ; $x++) - { - #Work out start character position - $StartCharNumber = ($x-1)*8 - #Get octet in binary - $IPOctetInBinary = $NextIPInBinary.Substring($StartCharNumber,8) - #Convert octet into decimal - $IPOctetInDecimal = [convert]::ToInt32($IPOctetInBinary,2) - #Add octet to IP - $IP += $IPOctetInDecimal - } - - #Separate by . - $IP = $IP -join "." - $IPs += $IP - } - $IPs - } - } -} - - -Write-Host "Adding SSH known hosts..." -ForegroundColor Cyan -$sshPath = Join-Path $Home ".ssh" -if(-not (Test-Path $sshPath)) { - New-Item $sshPath -ItemType directory -Force -} - -$contents = @() -# GitHub IP addresses - -$GIthubIPs="192.30.252.0/22", - "185.199.108.0/22", - "13.229.188.59/32", - "13.250.177.223/32", - "18.194.104.89/32", - "18.195.85.27/32", - "35.159.8.160/32", - "52.74.223.119/32" -Get-IPs -subnets $GIthubIPs | ForEach-Object { - $contents += "github.com,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" -} - -# BitBucket -$BitBucketIPs="104.192.143.1", - "104.192.143.2", - "104.192.143.3", - "104.192.143.65", - "104.192.143.66", - "104.192.143.67" -$BitBucketIPs | ForEach-Object { - $contents += "bitbucket.org,$_ ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==" -} - -$knownhostfile = Join-Path $sshPath "known_hosts" -[IO.File]::WriteAllLines($knownhostfile, $contents) - -Write-Host "Known hosts configured" -ForegroundColor Green - -$installerUrl = 'http://www.appveyor.com/downloads/build-agent/latest/AppveyorBuildAgent.msi' -$installerFileName = "$($env:TEMP)\AppveyorBuildAgent.msi" - -$process = Get-Process -Name 'Appveyor.BuildAgent.Service' -ErrorAction SilentlyContinue -if($process) { - $process | Stop-Process -Force -} -$process = Get-Process -Name 'Appveyor.BuildAgent.Interactive' -ErrorAction SilentlyContinue -if($process) { - $process | Stop-Process -Force -} - -(New-Object Net.WebClient).DownloadFile($installerUrl, $installerFileName) -cmd /c start /wait msiexec /i $installerFileName /quiet APPVEYOR_MODE=Azure -Remove-Item $installerFileName - -# display appveyor version -& "C:\Program Files\AppVeyor\BuildAgent\appveyor.exe" version - -Clear-EventLog -LogName AppVeyor -ErrorAction SilentlyContinue - -Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "Azure" - -# Set-ItemProperty "HKLM:\SOFTWARE\AppVeyor\Build Agent\" -Name "Mode" -Value "AmazonEC2" - -################### DO UP TO HERE FIRST - - -################# APP VEYOR SPECIFICS - -Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppVeyor.BuildAgent" ` - -Value 'powershell -File "C:\Program Files\AppVeyor\BuildAgent\start-appveyor-agent.ps1"' - -################# Dependencies - -choco install cmake - -choco install openssl.light - -# Check Path and add manually if cmake isn't there - -choco install nodist - -$env:NODIST_X64 = "1" -$env:NODIST_PREFIX = "C:\Program Files (x86)\Nodist" -$env:Path += ";C:\Program Files (x86)\Nodist\bin" -[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") - -& RefreshEnv.cmd - -nodist add 9 - -nodist 9 - -nodist npm add 5 - -nodist npm 5 - -npm install --global --production windows-build-tools - - - -####################### - -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - -Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\Users\master\Downloads\rustup-init.exe" - -C:\Users\master\Downloads\rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2019-01-24 - -# Add Cargo to Path - -$env:Path += ";C:\Users\master\.cargo\bin" -$env:Path += ";C:\Program Files\CMake\bin" - -####################### Rust specifics - -rustup target add wasm32-unknown-unknown - -rustup default nightly-2019-01-24 - -[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine") -[Environment]::SetEnvironmentVariable("RUSTFLAGS", "-D warnings -Z external-macro-backtrace -Z thinlto -C codegen-units=16 -C opt-level=z", "Machine") -[Environment]::SetEnvironmentVariable("hc_target_prefix", "C:\build") -git clone https://github.com/holochain/holochain-rust C:\Users\master\build - -cd C:\Users\master\build \ No newline at end of file From ce0f7d315d0c4c34e93f5764876b17b0114041c4 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 21:53:05 +1000 Subject: [PATCH 44/83] debug docker builds --- .circleci/config.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8cbbe6d7ca..0fdce9a31d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -237,13 +237,13 @@ workflows: - develop dockers: # https://circleci.com/docs/2.0/workflows/#scheduling-a-workflow - triggers: - - schedule: - cron: "0 0 * * *" - filters: - branches: - only: - - develop + # triggers: + # - schedule: + # cron: "0 0 * * *" + # filters: + # branches: + # only: + # - develop jobs: - docker.start - docker.01: From 2d5f3d953dba5f798cdb101ecee7e82d0e383d92 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:03:26 +1000 Subject: [PATCH 45/83] try sysctl change for docker priviledges --- .circleci/Dockerfile..start | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/Dockerfile..start b/.circleci/Dockerfile..start index 8d08e89f08..71d8f443e5 100644 --- a/.circleci/Dockerfile..start +++ b/.circleci/Dockerfile..start @@ -1,5 +1,7 @@ FROM nixorg/nix:circleci +RUN sysctl -w kernel.unprivileged_userns_clone=1 + # keep this matching nix-shell! ENV NIX_PATH nixpkgs=https://github.com/Holo-Host/nixpkgs-channels/archive/680f9d7ea90dd0b48b51f29899c3110196b0e913.tar.gz ENV HC_TARGET_PREFIX /tmp/holochain From 366ca30cb12ebbb4e680eef93e68fc8d032d6d04 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:07:23 +1000 Subject: [PATCH 46/83] try setting sysctl on machine for circleci --- .circleci/Dockerfile..start | 2 -- .circleci/config.yml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/Dockerfile..start b/.circleci/Dockerfile..start index 71d8f443e5..8d08e89f08 100644 --- a/.circleci/Dockerfile..start +++ b/.circleci/Dockerfile..start @@ -1,7 +1,5 @@ FROM nixorg/nix:circleci -RUN sysctl -w kernel.unprivileged_userns_clone=1 - # keep this matching nix-shell! ENV NIX_PATH nixpkgs=https://github.com/Holo-Host/nixpkgs-channels/archive/680f9d7ea90dd0b48b51f29899c3110196b0e913.tar.gz ENV HC_TARGET_PREFIX /tmp/holochain diff --git a/.circleci/config.yml b/.circleci/config.yml index 0fdce9a31d..243b2f57bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,6 +104,7 @@ jobs: machine: true steps: - checkout + - run: sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker build -f .circleci/Dockerfile..start -t holochain/holochain-rust:circle..start . - run: docker push holochain/holochain-rust:circle..start From eaabb5886da7bc76f37df433fc00cded55106618 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:14:12 +1000 Subject: [PATCH 47/83] try sysctl on docker 01 --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 243b2f57bd..e723a1d338 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,6 +112,7 @@ jobs: machine: true steps: - checkout + - run: sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker pull holochain/holochain-rust:circle..start - run: docker build -f .circleci/Dockerfile.01.warm.nix -t holochain/holochain-rust:circle.01.warm.nix . From 616b08042dd2764f5a23725ff5308ab753ce3a3f Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:21:47 +1000 Subject: [PATCH 48/83] debug --- .circleci/Dockerfile.01.warm.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/Dockerfile.01.warm.nix b/.circleci/Dockerfile.01.warm.nix index 96fb676ef1..fd24c68a62 100644 --- a/.circleci/Dockerfile.01.warm.nix +++ b/.circleci/Dockerfile.01.warm.nix @@ -1,4 +1,6 @@ FROM holochain/holochain-rust:circle..start +RUN ls + # run a no-op to warm the nix store RUN nix-shell --run "echo 1" --show-trace --max-jobs 4 --cores 0 From 66580cab3593db7cc7be2e6bb358ac8377ee057e Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:35:56 +1000 Subject: [PATCH 49/83] debug --- .circleci/Dockerfile.01.warm.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/Dockerfile.01.warm.nix b/.circleci/Dockerfile.01.warm.nix index fd24c68a62..0ba5598b4f 100644 --- a/.circleci/Dockerfile.01.warm.nix +++ b/.circleci/Dockerfile.01.warm.nix @@ -2,5 +2,7 @@ FROM holochain/holochain-rust:circle..start RUN ls +RUN ls ./holonix/dist + # run a no-op to warm the nix store RUN nix-shell --run "echo 1" --show-trace --max-jobs 4 --cores 0 From ab3c21e126a792755fac699c25248bf5ddf9b662 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:47:40 +1000 Subject: [PATCH 50/83] don't ignore holonix in dockerfile --- .circleci/Dockerfile.01.warm.nix | 4 ---- .dockerignore | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/Dockerfile.01.warm.nix b/.circleci/Dockerfile.01.warm.nix index 0ba5598b4f..96fb676ef1 100644 --- a/.circleci/Dockerfile.01.warm.nix +++ b/.circleci/Dockerfile.01.warm.nix @@ -1,8 +1,4 @@ FROM holochain/holochain-rust:circle..start -RUN ls - -RUN ls ./holonix/dist - # run a no-op to warm the nix store RUN nix-shell --run "echo 1" --show-trace --max-jobs 4 --cores 0 diff --git a/.dockerignore b/.dockerignore index 4b80a3d374..a18dd44f5f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,4 @@ **/.git **/node_modules **/bin-package +!holonix/** From 1df337b5d6814ae6f74b6d11515db2e6bf7678d2 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 22:57:14 +1000 Subject: [PATCH 51/83] debug --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e723a1d338..b8b230b747 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,7 +104,7 @@ jobs: machine: true steps: - checkout - - run: sysctl -w kernel.unprivileged_userns_clone=1 + # - run: sudo sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker build -f .circleci/Dockerfile..start -t holochain/holochain-rust:circle..start . - run: docker push holochain/holochain-rust:circle..start @@ -112,7 +112,7 @@ jobs: machine: true steps: - checkout - - run: sysctl -w kernel.unprivileged_userns_clone=1 + # - run: sudo sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker pull holochain/holochain-rust:circle..start - run: docker build -f .circleci/Dockerfile.01.warm.nix -t holochain/holochain-rust:circle.01.warm.nix . From 8ed5749cb06ee4ed6b1867e3b811813db8663d64 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 23:07:48 +1000 Subject: [PATCH 52/83] debug --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b8b230b747..0fdce9a31d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -104,7 +104,6 @@ jobs: machine: true steps: - checkout - # - run: sudo sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker build -f .circleci/Dockerfile..start -t holochain/holochain-rust:circle..start . - run: docker push holochain/holochain-rust:circle..start @@ -112,7 +111,6 @@ jobs: machine: true steps: - checkout - # - run: sudo sysctl -w kernel.unprivileged_userns_clone=1 - run: docker login -u $DOCKER_USER -p $DOCKER_PASS - run: docker pull holochain/holochain-rust:circle..start - run: docker build -f .circleci/Dockerfile.01.warm.nix -t holochain/holochain-rust:circle.01.warm.nix . From eb289a8a874d1ce9ac4c17b7682575cd4b2919b6 Mon Sep 17 00:00:00 2001 From: David Meister Date: Mon, 29 Apr 2019 23:17:15 +1000 Subject: [PATCH 53/83] move docker builds back to cron --- .circleci/config.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0fdce9a31d..8cbbe6d7ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -237,13 +237,13 @@ workflows: - develop dockers: # https://circleci.com/docs/2.0/workflows/#scheduling-a-workflow - # triggers: - # - schedule: - # cron: "0 0 * * *" - # filters: - # branches: - # only: - # - develop + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - develop jobs: - docker.start - docker.01: From 47cc632badbd184f2b96b7bce42b388f782730cc Mon Sep 17 00:00:00 2001 From: David Meister Date: Tue, 30 Apr 2019 00:44:23 +1000 Subject: [PATCH 54/83] add default nix for dist builds --- default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..3e5371a843 --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +let + + pkgs = import ./holonix/nixpkgs/nixpkgs.nix; + +in +with pkgs; +stdenv.mkDerivation rec { + + name = "holonix-binaries"; + + buildInputs = import ./holonix/dist/build.nix; + +} From 35079e0af475b3045f01306554224d71a84b6130 Mon Sep 17 00:00:00 2001 From: David Meister Date: Tue, 30 Apr 2019 00:51:44 +1000 Subject: [PATCH 55/83] less things in default.nix --- default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 3e5371a843..3c09975670 100644 --- a/default.nix +++ b/default.nix @@ -2,12 +2,18 @@ let pkgs = import ./holonix/nixpkgs/nixpkgs.nix; + cli = import ./holonix/dist/cli/build.nix; + conductor = import ./holonix/dist/conductor.build.nix; + in with pkgs; stdenv.mkDerivation rec { name = "holonix-binaries"; - buildInputs = import ./holonix/dist/build.nix; + buildInputs = [ + cli + conductor + ]; } From c988c289f51340dc12e2461317c986e460b2ff89 Mon Sep 17 00:00:00 2001 From: David Meister Date: Tue, 30 Apr 2019 00:53:07 +1000 Subject: [PATCH 56/83] rename holonix-binaries to holochain-binaries --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 3c09975670..f7fd7885ee 100644 --- a/default.nix +++ b/default.nix @@ -9,7 +9,7 @@ in with pkgs; stdenv.mkDerivation rec { - name = "holonix-binaries"; + name = "holochain-binaries"; buildInputs = [ cli From 9dd8648b2be398dd51433f18170cdc268bdd51c7 Mon Sep 17 00:00:00 2001 From: David Meister Date: Tue, 30 Apr 2019 01:01:01 +1000 Subject: [PATCH 57/83] lint --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index f7fd7885ee..2df79ccae9 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ let pkgs = import ./holonix/nixpkgs/nixpkgs.nix; cli = import ./holonix/dist/cli/build.nix; - conductor = import ./holonix/dist/conductor.build.nix; + conductor = import ./holonix/dist/conductor/build.nix; in with pkgs; From a92099ae3091479ac7f0043f21375bfed9952c29 Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Mon, 29 Apr 2019 11:02:08 -0400 Subject: [PATCH 58/83] Update CHANGELOG-UNRELEASED.md --- CHANGELOG-UNRELEASED.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index a6935c9358..8e320560e8 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +- Changes `LinkAdd` and `RemoveEntry` so that they return a hash instead of a null [#1343](https://github.com/holochain/holochain-rust/pull/1343) ### Deprecated From 2e56a3f771605079ba70fda7944cdbc5d3c80c8e Mon Sep 17 00:00:00 2001 From: carm Date: Mon, 29 Apr 2019 12:45:59 -0400 Subject: [PATCH 59/83] Move PR to CHANGELOG-UNRELEASED.md --- CHANGELOG-UNRELEASED.md | 2 ++ CHANGELOG.md | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index a6935c9358..71db66c330 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320) + ### Changed ### Deprecated diff --git a/CHANGELOG.md b/CHANGELOG.md index 0830b3f647..49adb3b944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adds hdk::grant_capability() for zome functions to be able to create [capability grant](doc/architecture/decisions/0017-capabilities.md) [#1285](https://github.com/holochain/holochain-rust/pull/1285) - `nix-shell` includes latest `hc` and `holochain` binaries [#1306](https://github.com/holochain/holochain-rust/pull/1306) - Adds `hc-cli-uninstall` and `hc-conductor-rust-uninstall` to drop local development installations of these binaries that would override dist binaries [#1351](https://github.com/holochain/holochain-rust/pull/1351) - -- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320) - ### Changed - changed JSON-RPC Zome call `params` key to `args` for clarity (due to confusion between JSON-RPC `params` and Holochain `params` keys): see [#1203](https://github.com/holochain/holochain-rust/pull/1203) and [#1271](https://github.com/holochain/holochain-rust/pull/1271) - Remove sleeps during network initialization, block until P2pReady event is received [#1284](https://github.com/holochain/holochain-rust/pull/1284). From 87733210074c12bca9177c4ad22e81a8cc35dfe7 Mon Sep 17 00:00:00 2001 From: carm Date: Mon, 29 Apr 2019 12:53:55 -0400 Subject: [PATCH 60/83] CommitArgs -> CommitAppEntry --- core/src/nucleus/ribosome/api/commit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/nucleus/ribosome/api/commit.rs b/core/src/nucleus/ribosome/api/commit.rs index f98593b6c2..1e26bb9bcd 100644 --- a/core/src/nucleus/ribosome/api/commit.rs +++ b/core/src/nucleus/ribosome/api/commit.rs @@ -9,7 +9,7 @@ use holochain_wasm_utils::api_serialization::commit_entry::{CommitEntryArgs, Com use std::convert::TryFrom; use wasmi::{RuntimeArgs, RuntimeValue}; -/// ZomeApiFunction::CommitArgs function code +/// ZomeApiFunction::CommitAppEntry function code /// args: [0] encoded MemoryAllocation as u64 /// Expected complex argument: CommitEntryArg /// Returns an HcApiReturnCode as I64 From 9188ee0539b342883b36d978c7b800a0146f1a2c Mon Sep 17 00:00:00 2001 From: Purple Hair Rust Bard Date: Mon, 29 Apr 2019 14:58:37 -0400 Subject: [PATCH 61/83] Update api_functions.md --- doc/holochain_101/src/zome/api_functions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/holochain_101/src/zome/api_functions.md b/doc/holochain_101/src/zome/api_functions.md index a2c1cdedee..5e4bb407bd 100644 --- a/doc/holochain_101/src/zome/api_functions.md +++ b/doc/holochain_101/src/zome/api_functions.md @@ -118,8 +118,8 @@ Not yet available. Canonical name: `remove_entry` Enables an entry, referred to by its address, to be marked in the chain as 'deleted'. This is done by adding a new entry -which indicates the deleted status of the old one. This will change which types of results that entry would then show up in, -according to its new 'deleted' status. It can still be retrieved, but only if specifically asked for. +which indicates the deleted status of the old one. This will changes which types of results that entry would then show up in, +according to its new 'deleted' status. It can still be retrieved, but only if specifically asked for. This function also returns the Hash of the deletion entry on completion [View it in the Rust HDK](https://developer.holochain.org/api/0.0.7-alpha/hdk/api/fn.remove_entry.html) @@ -159,7 +159,7 @@ Consumes two values, the first of which is the address of an entry, base, and th Canonical name: `link_entries` -Consumes three values, two of which are the addresses of entries, and one of which is a string that defines a relationship between them, called a `tag`. Later, lists of entries can be looked up by using `get_links`. Entries can only be looked up in the direction from the `base`, which is the first argument, to the `target`, which is the second. +Consumes three values, two of which are the addresses of entries, and one of which is a string that defines a relationship between them, called a `tag`. Later, lists of entries can be looked up by using `get_links`. Entries can only be looked up in the direction from the `base`, which is the first argument, to the `target`, which is the second. This function returns a hash for the LinkAdd entry on completion. [View it in the Rust HDK](https://developer.holochain.org/api/0.0.7-alpha/hdk/api/fn.link_entries.html) From a8ad76d4cdbd153913872c270bb1466bd16e5918 Mon Sep 17 00:00:00 2001 From: neonphog Date: Mon, 29 Apr 2019 13:14:32 -0600 Subject: [PATCH 62/83] only send signals on non-windows targets --- net/src/ipc/spawn.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/src/ipc/spawn.rs b/net/src/ipc/spawn.rs index ac137a4f9e..c8887f5946 100644 --- a/net/src/ipc/spawn.rs +++ b/net/src/ipc/spawn.rs @@ -149,12 +149,8 @@ pub fn ipc_spawn( // Set shutdown function to kill the sub-process out.kill = Some(Box::new(move || { - unsafe { - if libc::kill(child.id() as i32, libc::SIGTERM) == 0 { - libc::waitpid(child.id() as i32, std::ptr::null_mut(), 0); - kill_child(&real_pid); - return; - } + if term_child(child.id()) { + return; } match child.kill() { Ok(()) => kill_child(&real_pid), @@ -165,6 +161,22 @@ pub fn ipc_spawn( Ok(out) } +#[cfg(windows)] +fn term_child(_pid: u32) -> bool { + false +} + +#[cfg(not(windows))] +fn term_child(pid: u32) -> bool { + unsafe { + if libc::kill(pid as i32, libc::SIGTERM) == 0 { + libc::waitpid(pid as i32, std::ptr::null_mut(), 0); + return true; + } + } + false +} + #[cfg(windows)] fn kill_child(pid: &str) { let mut child_killer = std::process::Command::new("taskkill"); From 12a185657e61757d2dc2d42d66978400f23a3ec1 Mon Sep 17 00:00:00 2001 From: damien Date: Mon, 29 Apr 2019 17:42:44 -0400 Subject: [PATCH 63/83] Renamed P2pNode to TestNode, and gave it its own folder (might use the P2pNode name for a trait). Have TestNode handle multiple DNAs. --- test_bin/src/basic_workflows.rs | 92 +-- test_bin/src/connection_workflows.rs | 28 +- test_bin/src/constants.rs | 2 +- test_bin/src/main.rs | 84 +-- test_bin/src/p2p_node/dna_store.rs | 25 + test_bin/src/p2p_node/ipc_config.rs | 77 +++ test_bin/src/p2p_node/meta_store.rs | 85 +++ test_bin/src/p2p_node/mod.rs | 4 + .../{p2p_node.rs => p2p_node/test_node.rs} | 541 +++++++++--------- test_bin/src/publish_hold_workflows.rs | 46 +- test_bin/src/three_workflows.rs | 35 +- 11 files changed, 586 insertions(+), 433 deletions(-) create mode 100644 test_bin/src/p2p_node/dna_store.rs create mode 100644 test_bin/src/p2p_node/ipc_config.rs create mode 100644 test_bin/src/p2p_node/meta_store.rs create mode 100644 test_bin/src/p2p_node/mod.rs rename test_bin/src/{p2p_node.rs => p2p_node/test_node.rs} (70%) diff --git a/test_bin/src/basic_workflows.rs b/test_bin/src/basic_workflows.rs index 1ef8b65661..9f7de0001c 100644 --- a/test_bin/src/basic_workflows.rs +++ b/test_bin/src/basic_workflows.rs @@ -8,13 +8,13 @@ use holochain_net::{ }, tweetlog::TWEETLOG, }; -use p2p_node::P2pNode; +use p2p_node::test_node::TestNode; /// Tests if we can get back data published on the network #[cfg_attr(tarpaulin, skip)] fn confirm_published_data( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, address: &Address, content: &serde_json::Value, ) -> NetResult<()> { @@ -48,8 +48,8 @@ fn confirm_published_data( /// Tests if we can get back metadata published on the network #[cfg_attr(tarpaulin, skip)] fn confirm_published_metadata( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, address: &Address, attribute: &str, link_entry_address: &serde_json::Value, @@ -85,12 +85,14 @@ fn confirm_published_metadata( /// and check that we received 'PeerConnected' #[cfg_attr(tarpaulin, skip)] pub fn setup_one_node( - alex: &mut P2pNode, - _billy: &mut P2pNode, + alex: &mut TestNode, + _billy: &mut TestNode, + dna_address: &Address, can_connect: bool, ) -> NetResult<()> { // Send TrackDna message on both nodes - alex.track_dna().expect("Failed sending TrackDna on alex"); + alex.track_dna(dna_address, true) + .expect("Failed sending TrackDna on alex"); // Check if PeerConnected is received let connect_result_1 = alex .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) @@ -135,18 +137,22 @@ pub fn setup_one_node( /// and check that we received 'PeerConnected' #[cfg_attr(tarpaulin, skip)] pub fn setup_two_nodes( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, + dna_address: &Address, can_connect: bool, ) -> NetResult<()> { // Send TrackDna message on both nodes - alex.track_dna().expect("Failed sending TrackDna on alex"); + alex.track_dna(dna_address, true) + .expect("Failed sending TrackDna on alex"); // Check if PeerConnected is received let connect_result_1 = alex .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) .unwrap(); log_i!("self connected result 1: {:?}", connect_result_1); - billy.track_dna().expect("Failed sending TrackDna on billy"); + billy + .track_dna(dna_address, true) + .expect("Failed sending TrackDna on billy"); let connect_result_2 = billy .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) .unwrap(); @@ -223,10 +229,9 @@ pub fn setup_two_nodes( } #[cfg_attr(tarpaulin, skip)] -pub fn send_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn send_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> NetResult<()> { // Setup - println!("Testing: send_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Send a message from alex to billy alex.send_message(BILLY_AGENT_ID.to_string(), ENTRY_CONTENT_1.clone()); @@ -267,10 +272,9 @@ pub fn send_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> // this is all debug code, no need to track code test coverage #[cfg_attr(tarpaulin, skip)] -pub fn meta_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn meta_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> NetResult<()> { // Setup - println!("Testing: meta_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Send data & metadata on same address confirm_published_data(alex, billy, &ENTRY_ADDRESS_1, &ENTRY_CONTENT_1)?; @@ -339,10 +343,9 @@ pub fn meta_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> // this is all debug code, no need to track code test coverage #[cfg_attr(tarpaulin, skip)] -pub fn dht_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn dht_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> NetResult<()> { // Setup - println!("Testing: dht_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Alex publish data on the network alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; @@ -386,7 +389,13 @@ pub fn dht_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> N } /// Sending a Message before doing a 'TrackDna' should fail -pub fn no_setup_test(alex: &mut P2pNode, billy: &mut P2pNode, _connect: bool) -> NetResult<()> { +pub fn no_setup_test(alex: &mut TestNode, billy: &mut TestNode, _connect: bool) -> NetResult<()> { + alex.track_dna(&DNA_ADDRESS_A, true) + .expect("Failed sending TrackDna message on alex"); + alex.untrack_current_dna() + .expect("Failed sending UntrackDna message on alex"); + alex.set_current_dna(&DNA_ADDRESS_A); + // Send a message from alex to billy alex.send_message(BILLY_AGENT_ID.to_string(), ENTRY_CONTENT_1.clone()); @@ -403,17 +412,17 @@ pub fn no_setup_test(alex: &mut P2pNode, billy: &mut P2pNode, _connect: bool) -> /// Sending a Message before doing a 'TrackDna' should fail pub fn untrack_alex_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup - println!("Testing: untrack_alex_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Send Untrack - alex.untrack_dna() + alex.untrack_current_dna() .expect("Failed sending UntrackDna message on alex"); + alex.set_current_dna(&DNA_ADDRESS_A); // Send a message from alex to billy let before_count = alex.count_recv_json_messages(); @@ -431,17 +440,16 @@ pub fn untrack_alex_test( /// Sending a Message before doing a 'TrackDna' should fail pub fn untrack_billy_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup - println!("Testing: untrack_billy_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Send Untrack billy - .untrack_dna() + .untrack_current_dna() .expect("Failed sending UntrackDna message on alex"); // Making sure Untrack has been received @@ -467,18 +475,17 @@ pub fn untrack_billy_test( } /// Sending a Message before doing a 'TrackDna' should fail -pub fn retrack_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn retrack_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> NetResult<()> { // Setup - println!("Testing: untrack_billy_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Billy untracks DNA billy - .untrack_dna() + .untrack_current_dna() .expect("Failed sending UntrackDna message on billy"); // Alex untracks DNA - alex.untrack_dna() + alex.untrack_current_dna() .expect("Failed sending UntrackDna message on alex"); // Making sure Untrack has been received @@ -487,9 +494,12 @@ pub fn retrack_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) billy.listen(100); // Billy re-tracks DNA - billy.track_dna().expect("Failed sending TrackDna on billy"); + billy + .track_dna(&DNA_ADDRESS_A, true) + .expect("Failed sending TrackDna on billy"); // alex re-tracks DNA - alex.track_dna().expect("Failed sending TrackDna on alex"); + alex.track_dna(&DNA_ADDRESS_A, true) + .expect("Failed sending TrackDna on alex"); // Making sure Track has been received // TODO: Have server reply with successResult @@ -537,9 +547,9 @@ pub fn retrack_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) // this is all debug code, no need to track code test coverage #[cfg_attr(tarpaulin, skip)] -pub fn no_meta_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn no_meta_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> NetResult<()> { // Setup - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // No Meta & No Entry // ================== diff --git a/test_bin/src/connection_workflows.rs b/test_bin/src/connection_workflows.rs index f162521e36..782ea45800 100644 --- a/test_bin/src/connection_workflows.rs +++ b/test_bin/src/connection_workflows.rs @@ -11,7 +11,7 @@ use holochain_net::{ }, tweetlog::*, }; -use p2p_node::P2pNode; +use p2p_node::test_node::TestNode; // Disconnect & reconnect a Node in a two nodes scenario #[cfg_attr(tarpaulin, skip)] @@ -24,17 +24,15 @@ pub(crate) fn two_nodes_disconnect_test( let alex_dir = tempfile::tempdir().expect("Failed to created a temp directory."); let alex_dir_path = alex_dir.path().to_string_lossy().to_string(); // Create two nodes - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], Some(alex_dir_path.clone()), ); - let mut billy = P2pNode::new_with_spawn_ipc_network( + let mut billy = TestNode::new_with_spawn_ipc_network( BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], @@ -55,16 +53,15 @@ pub(crate) fn two_nodes_disconnect_test( log_i!("#### billy got: {}\n\n\n\n", count); // re-enable alex - alex = P2pNode::new_with_spawn_ipc_network( + alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), // TODO test bootstrap with billy's endpoint vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], Some(alex_dir_path), ); - basic_workflows::setup_one_node(&mut alex, &mut billy, true)?; + basic_workflows::setup_one_node(&mut alex, &mut billy, &DNA_ADDRESS_A, true)?; let alex_binding_2 = alex.p2p_binding.clone(); log_i!("#### alex_binding_2: {}", alex_binding_2); @@ -119,9 +116,8 @@ pub(crate) fn three_nodes_disconnect_test( // Create alex & temp dir let alex_dir = tempfile::tempdir().expect("Failed to created a temp directory."); let alex_dir_path = alex_dir.path().to_string_lossy().to_string(); - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], @@ -130,9 +126,8 @@ pub(crate) fn three_nodes_disconnect_test( // Create billy & temp dir let billy_dir = tempfile::tempdir().expect("Failed to created a temp directory."); let billy_dir_path = billy_dir.path().to_string_lossy().to_string(); - let mut billy = P2pNode::new_with_spawn_ipc_network( + let mut billy = TestNode::new_with_spawn_ipc_network( BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], @@ -141,9 +136,8 @@ pub(crate) fn three_nodes_disconnect_test( // Create camille & temp dir let camille_dir = tempfile::tempdir().expect("Failed to created a temp directory."); let camille_dir_path = camille_dir.path().to_string_lossy().to_string(); - let mut camille = P2pNode::new_with_spawn_ipc_network( + let mut camille = TestNode::new_with_spawn_ipc_network( CAMILLE_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], @@ -166,15 +160,15 @@ pub(crate) fn three_nodes_disconnect_test( log_i!("#### billy got alex camille authoring: {}\n\n\n\n", count); // re-enable alex - alex = P2pNode::new_with_spawn_ipc_network( + alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec![billy.p2p_binding.clone()], Some(alex_dir_path), ); - alex.track_dna().expect("Failed sending TrackDna on alex"); + alex.track_dna(&DNA_ADDRESS_A, true) + .expect("Failed sending TrackDna on alex"); log_i!("#### alex reborn ({})", alex.p2p_binding.clone()); let count = alex.listen(500); diff --git a/test_bin/src/constants.rs b/test_bin/src/constants.rs index c7dc20b778..b9066a4778 100644 --- a/test_bin/src/constants.rs +++ b/test_bin/src/constants.rs @@ -12,7 +12,7 @@ pub static META_CRUD_ATTRIBUTE: &'static str = "crud"; pub static META_LINK_ATTRIBUTE: &'static str = "link__yay"; lazy_static! { - pub static ref DNA_ADDRESS: Address = HashString::from("DNA_A"); + pub static ref DNA_ADDRESS_A: Address = HashString::from("DNA_A"); pub static ref DNA_ADDRESS_B: Address = HashString::from("DNA_B"); pub static ref DNA_ADDRESS_C: Address = HashString::from("DNA_C"); pub static ref ENTRY_ADDRESS_1: Address = HashString::from("entry_addr_1"); diff --git a/test_bin/src/main.rs b/test_bin/src/main.rs index fa0f461b03..341fcd2541 100755 --- a/test_bin/src/main.rs +++ b/test_bin/src/main.rs @@ -26,27 +26,25 @@ pub mod three_workflows; use constants::*; use holochain_net::{connection::NetResult, tweetlog::*}; -use p2p_node::P2pNode; +use p2p_node::test_node::TestNode; use std::{collections::HashMap, fs::File}; pub(crate) type TwoNodesTestFn = - fn(alex: &mut P2pNode, billy: &mut P2pNode, can_test_connect: bool) -> NetResult<()>; + fn(alex: &mut TestNode, billy: &mut TestNode, can_test_connect: bool) -> NetResult<()>; type ThreeNodesTestFn = fn( - alex: &mut P2pNode, - billy: &mut P2pNode, - camille: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, can_test_connect: bool, ) -> NetResult<()>; -type MultiNodesTestFn = fn(nodes: &mut Vec, can_test_connect: bool) -> NetResult<()>; +type MultiNodesTestFn = fn(nodes: &mut Vec, can_test_connect: bool) -> NetResult<()>; lazy_static! { // List of tests pub static ref TWO_NODES_BASIC_TEST_FNS: Vec = vec![ - basic_workflows::setup_one_node, basic_workflows::no_setup_test, - basic_workflows::setup_two_nodes, basic_workflows::send_test, basic_workflows::untrack_alex_test, basic_workflows::untrack_billy_test, @@ -65,7 +63,6 @@ lazy_static! { publish_hold_workflows::many_meta_test, ]; pub static ref THREE_NODES_TEST_FNS: Vec = vec![ - three_workflows::setup_three_nodes, three_workflows::hold_and_publish_test, three_workflows::publish_entry_stress_test, ]; @@ -229,14 +226,8 @@ fn main() { // Do general test with config #[cfg_attr(tarpaulin, skip)] fn launch_two_nodes_test_with_memory_network(test_fn: TwoNodesTestFn) -> NetResult<()> { - let mut alex = - P2pNode::new_with_unique_memory_network(ALEX_AGENT_ID.to_string(), DNA_ADDRESS.clone()); - let mut billy = P2pNode::new_with_config( - BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.config, - None, - ); + let mut alex = TestNode::new_with_unique_memory_network(ALEX_AGENT_ID.to_string()); + let mut billy = TestNode::new_with_config(BILLY_AGENT_ID.to_string(), &alex.config, None); log_i!(""); print_two_nodes_test_name("IN-MEMORY TWO NODE TEST: ", test_fn); @@ -259,19 +250,15 @@ fn launch_two_nodes_test_with_ipc_mock( test_fn: TwoNodesTestFn, ) -> NetResult<()> { // Create two nodes - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath, vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], None, ); - let mut billy = P2pNode::new_with_uri_ipc_network( - BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.endpoint(), - ); + let mut billy = + TestNode::new_with_uri_ipc_network(BILLY_AGENT_ID.to_string(), &alex.endpoint()); log_i!(""); print_two_nodes_test_name("IPC-MOCK TWO NODE TEST: ", test_fn); @@ -294,17 +281,15 @@ fn launch_two_nodes_test( test_fn: TwoNodesTestFn, ) -> NetResult<()> { // Create two nodes - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], None, ); - let mut billy = P2pNode::new_with_spawn_ipc_network( + let mut billy = TestNode::new_with_spawn_ipc_network( BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath, vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], @@ -332,20 +317,9 @@ fn launch_two_nodes_test( #[cfg_attr(tarpaulin, skip)] fn launch_three_nodes_test_with_memory_network(test_fn: ThreeNodesTestFn) -> NetResult<()> { // Create nodes - let mut alex = - P2pNode::new_with_unique_memory_network(ALEX_AGENT_ID.to_string(), DNA_ADDRESS.clone()); - let mut billy = P2pNode::new_with_config( - BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.config, - None, - ); - let mut camille = P2pNode::new_with_config( - CAMILLE_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.config, - None, - ); + let mut alex = TestNode::new_with_unique_memory_network(ALEX_AGENT_ID.to_string()); + let mut billy = TestNode::new_with_config(BILLY_AGENT_ID.to_string(), &alex.config, None); + let mut camille = TestNode::new_with_config(CAMILLE_AGENT_ID.to_string(), &alex.config, None); // Launch test log_i!(""); @@ -372,24 +346,17 @@ fn launch_three_nodes_test_with_ipc_mock( test_fn: ThreeNodesTestFn, ) -> NetResult<()> { // Create two nodes - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath, vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], None, ); - let mut billy = P2pNode::new_with_uri_ipc_network( - BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.endpoint(), - ); - let mut camille = P2pNode::new_with_uri_ipc_network( - CAMILLE_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), - &alex.endpoint(), - ); + let mut billy = + TestNode::new_with_uri_ipc_network(BILLY_AGENT_ID.to_string(), &alex.endpoint()); + let mut camille = + TestNode::new_with_uri_ipc_network(CAMILLE_AGENT_ID.to_string(), &alex.endpoint()); log_i!(""); print_three_nodes_test_name("IPC-MOCK THREE NODE TEST: ", test_fn); @@ -413,25 +380,22 @@ fn launch_three_nodes_test( test_fn: ThreeNodesTestFn, ) -> NetResult<()> { // Create two nodes - let mut alex = P2pNode::new_with_spawn_ipc_network( + let mut alex = TestNode::new_with_spawn_ipc_network( ALEX_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], None, ); - let mut billy = P2pNode::new_with_spawn_ipc_network( + let mut billy = TestNode::new_with_spawn_ipc_network( BILLY_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath.clone(), vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], None, ); - let mut camille = P2pNode::new_with_spawn_ipc_network( + let mut camille = TestNode::new_with_spawn_ipc_network( CAMILLE_AGENT_ID.to_string(), - DNA_ADDRESS.clone(), Some(config_filepath), maybe_end_user_config_filepath, vec!["/ip4/127.0.0.1/tcp/12345/ipfs/blabla".to_string()], diff --git a/test_bin/src/p2p_node/dna_store.rs b/test_bin/src/p2p_node/dna_store.rs new file mode 100644 index 0000000000..7461e48904 --- /dev/null +++ b/test_bin/src/p2p_node/dna_store.rs @@ -0,0 +1,25 @@ +use holochain_core_types::cas::content::Address; +use std::collections::HashMap; + +use super::meta_store::MetaStore; + +/// Holds DNA-specific data +pub struct DnaStore { + pub dna_address: Address, + pub entry_store: HashMap, + pub meta_store: MetaStore, + pub authored_entry_store: HashMap, + pub authored_meta_store: MetaStore, +} + +impl DnaStore { + pub fn new(dna_address: Address) -> Self { + DnaStore { + dna_address, + entry_store: HashMap::new(), + meta_store: MetaStore::new(), + authored_entry_store: HashMap::new(), + authored_meta_store: MetaStore::new(), + } + } +} diff --git a/test_bin/src/p2p_node/ipc_config.rs b/test_bin/src/p2p_node/ipc_config.rs new file mode 100644 index 0000000000..4ebccfd679 --- /dev/null +++ b/test_bin/src/p2p_node/ipc_config.rs @@ -0,0 +1,77 @@ +use holochain_net::{p2p_config::*, tweetlog::*}; + +/// Create a P2pConfig for an IPC node that uses n3h and possibily a specific folder. +/// Return the generated P2pConfig and the created tempdir if no dir was provided. +#[cfg_attr(tarpaulin, skip)] +pub(crate) fn create_ipc_config( + maybe_config_filepath: Option<&str>, + maybe_end_user_config_filepath: Option, + bootstrap_nodes: Vec, + maybe_dir_path: Option, +) -> (P2pConfig, Option) { + // Create temp directory if no dir was provided + let mut maybe_dir_ref = None; + let dir = if let Some(dir_path) = maybe_dir_path { + dir_path + } else { + let dir_ref = tempfile::tempdir().expect("Failed to created a temp directory."); + let dir_path = dir_ref.path().clone().to_string_lossy().to_string(); + maybe_dir_ref = Some(dir_ref); + dir_path + }; + + log_i!("create_ipc_config() dir = {}", dir); + + // Create config + let mut config: P2pConfig = match maybe_config_filepath { + Some(filepath) => { + log_d!("filepath = {}", filepath); + // Get config from file + let p2p_config = P2pConfig::from_file(filepath); + assert_eq!(p2p_config.backend_kind, P2pBackendKind::IPC); + // complement missing fields + serde_json::from_value(json!({ + "backend_kind": String::from(p2p_config.backend_kind), + "backend_config": + { + "socketType": p2p_config.backend_config["socketType"], + "bootstrapNodes": bootstrap_nodes, + "spawn": + { + "workDir": dir.clone(), + "env": { + "N3H_MODE": p2p_config.backend_config["spawn"]["env"]["N3H_MODE"], + "N3H_WORK_DIR": dir.clone(), + "N3H_IPC_SOCKET": p2p_config.backend_config["spawn"]["env"]["N3H_IPC_SOCKET"], + "N3H_LOG_LEVEL": p2p_config.backend_config["spawn"]["env"]["N3H_LOG_LEVEL"], + } + }, + }})).expect("Failled making valid P2pConfig with filepath") + } + None => { + // use default config + serde_json::from_value(json!({ + "backend_kind": "IPC", + "backend_config": + { + "socketType": "ws", + "bootstrapNodes": bootstrap_nodes, + "spawn": + { + "workDir": dir.clone(), + "env": { + "N3H_MODE": "HACK", + "N3H_WORK_DIR": dir.clone(), + "N3H_IPC_SOCKET": "tcp://127.0.0.1:*", + "N3H_LOG_LEVEL": "t" + } + }, + }})) + .expect("Failled making valid default P2pConfig") + } + }; + config.maybe_end_user_config = Some(P2pConfig::load_end_user_config( + maybe_end_user_config_filepath, + )); + return (config, maybe_dir_ref); +} diff --git a/test_bin/src/p2p_node/meta_store.rs b/test_bin/src/p2p_node/meta_store.rs new file mode 100644 index 0000000000..949978e407 --- /dev/null +++ b/test_bin/src/p2p_node/meta_store.rs @@ -0,0 +1,85 @@ +use holochain_core_types::{cas::content::Address, hash::HashString}; +use holochain_net::{ + connection::json_protocol::{MetaKey, MetaTuple}, + tweetlog::*, +}; +use multihash::Hash; +use std::collections::HashMap; + +pub type MetaStoreValue = serde_json::Value; + +pub struct MetaStore { + // TODO: Changed once meta is only Addresses + // pub meta_store: HashMap>, + store: HashMap>, +} + +impl MetaStore { + pub fn new() -> Self { + MetaStore { + store: HashMap::new(), + } + } + + /// Check if this value is already stored + pub fn has(&self, meta_key: MetaKey, v: &MetaStoreValue) -> bool { + let hash = HashString::encode_from_str(&v.to_string(), Hash::SHA2256); + let maybe_map = self.store.get(&meta_key); + if maybe_map.is_none() { + return false; + } + maybe_map.unwrap().get(&hash).is_some() + } + + /// + pub fn insert(&mut self, meta_key: MetaKey, v: MetaStoreValue) { + let hash = HashString::encode_from_str(&v.to_string(), Hash::SHA2256); + if let None = self.store.get_mut(&meta_key) { + let mut map = HashMap::new(); + log_tt!( + "metastore", + "MetaStore: first content for '{:?}' = {} | {}", + meta_key, + v, + hash, + ); + map.insert(hash, v); + self.store.insert(meta_key, map); + } else { + if let Some(map) = self.store.get_mut(&meta_key) { + assert!(map.get(&hash).is_none()); + log_tt!( + "metastore", + "MetaStore: adding content for '{:?}' = {} | {}", + meta_key, + v, + hash, + ); + map.insert(hash, v); + }; + }; + } + + /// Get all values for a meta_key as a vec + pub fn get(&self, meta_key: MetaKey) -> Vec { + let maybe_metas = self.store.get(&meta_key); + let metas = match maybe_metas.clone() { + Some(map) => map.clone(), + // if meta not found return empty list (will make the aggregation easier) + None => HashMap::new(), + }; + let res = metas.iter().map(|(_, v)| v.clone()).collect(); + res + } + + /// Get all values stored + pub fn get_all(&self) -> Vec { + let mut meta_list: Vec = Vec::new(); + for (meta_key, meta_map) in self.store.clone() { + for (_, v) in meta_map { + meta_list.push((meta_key.0.clone(), meta_key.1.clone(), v)); + } + } + meta_list + } +} diff --git a/test_bin/src/p2p_node/mod.rs b/test_bin/src/p2p_node/mod.rs new file mode 100644 index 0000000000..88987a616d --- /dev/null +++ b/test_bin/src/p2p_node/mod.rs @@ -0,0 +1,4 @@ +pub mod dna_store; +pub mod ipc_config; +pub mod meta_store; +pub mod test_node; diff --git a/test_bin/src/p2p_node.rs b/test_bin/src/p2p_node/test_node.rs similarity index 70% rename from test_bin/src/p2p_node.rs rename to test_bin/src/p2p_node/test_node.rs index 2af7432e77..fe67a725f5 100644 --- a/test_bin/src/p2p_node.rs +++ b/test_bin/src/p2p_node/test_node.rs @@ -1,12 +1,12 @@ #![allow(non_snake_case)] -use holochain_core_types::{cas::content::Address, hash::HashString}; +use holochain_core_types::cas::content::Address; use holochain_net::{ connection::{ json_protocol::{ DhtMetaData, EntryData, EntryListData, FailureResultData, FetchEntryData, FetchEntryResultData, FetchMetaData, FetchMetaResultData, GetListData, JsonProtocol, - MessageData, MetaKey, MetaListData, MetaTuple, TrackDnaData, + MessageData, MetaKey, MetaListData, TrackDnaData, }, net_connection::NetSend, protocol::Protocol, @@ -16,91 +16,19 @@ use holochain_net::{ p2p_network::P2pNetwork, tweetlog::{TweetProxy, *}, }; -use multihash::Hash; -use std::{collections::HashMap, convert::TryFrom, sync::mpsc}; -static TIMEOUT_MS: usize = 5000; - -pub type MetaStoreValue = serde_json::Value; - -pub struct MetaStore { - // TODO: Changed once meta is only Addresses - // pub meta_store: HashMap>, - store: HashMap>, -} - -impl MetaStore { - pub fn new() -> Self { - MetaStore { - store: HashMap::new(), - } - } - - /// Check if this value is already stored - pub fn has(&self, meta_key: MetaKey, v: &MetaStoreValue) -> bool { - let hash = HashString::encode_from_str(&v.to_string(), Hash::SHA2256); - let maybe_map = self.store.get(&meta_key); - if maybe_map.is_none() { - return false; - } - maybe_map.unwrap().get(&hash).is_some() - } +use std::{ + collections::{HashMap, HashSet}, + convert::TryFrom, + sync::mpsc, +}; - /// - pub fn insert(&mut self, meta_key: MetaKey, v: MetaStoreValue) { - let hash = HashString::encode_from_str(&v.to_string(), Hash::SHA2256); - if let None = self.store.get_mut(&meta_key) { - let mut map = HashMap::new(); - log_tt!( - "metastore", - "MetaStore: first content for '{:?}' = {} | {}", - meta_key, - v, - hash, - ); - map.insert(hash, v); - self.store.insert(meta_key, map); - } else { - if let Some(map) = self.store.get_mut(&meta_key) { - assert!(map.get(&hash).is_none()); - log_tt!( - "metastore", - "MetaStore: adding content for '{:?}' = {} | {}", - meta_key, - v, - hash, - ); - map.insert(hash, v); - }; - }; - } +use super::{dna_store::DnaStore, ipc_config::create_ipc_config}; - /// Get all values for a meta_key as a vec - pub fn get(&self, meta_key: MetaKey) -> Vec { - let maybe_metas = self.store.get(&meta_key); - let metas = match maybe_metas.clone() { - Some(map) => map.clone(), - // if meta not found return empty list (will make the aggregation easier) - None => HashMap::new(), - }; - let res = metas.iter().map(|(_, v)| v.clone()).collect(); - res - } - - /// Get all values stored - pub fn get_all(&self) -> Vec { - let mut meta_list: Vec = Vec::new(); - for (meta_key, meta_map) in self.store.clone() { - for (_, v) in meta_map { - meta_list.push((meta_key.0.clone(), meta_key.1.clone(), v)); - } - } - meta_list - } -} +static TIMEOUT_MS: usize = 5000; /// Core Mock -pub struct P2pNode { +pub struct TestNode { // Need to hold the tempdir to keep it alive, otherwise we will get a dir error. _maybe_temp_dir: Option, p2p_connection: P2pNetwork, @@ -117,14 +45,11 @@ pub struct P2pNode { recv_msg_log: Vec, recv_dm_log: Vec, - // datastores for one dna - // TODO: Have a datastore per dna ; perhaps in a CoreMock struct - pub dna_address: Address, - pub entry_store: HashMap, + // datastores per dna + dna_stores: HashMap, + tracked_dnas: HashSet
, - pub meta_store: MetaStore, - pub authored_entry_store: HashMap, - pub authored_meta_store: MetaStore, + pub current_dna: Option
, pub logger: TweetProxy, @@ -133,7 +58,7 @@ pub struct P2pNode { } /// Query logs -impl P2pNode { +impl TestNode { /// Return number of JsonProtocol message this node has received pub fn count_recv_json_messages(&self) -> usize { let mut count = 0; @@ -168,53 +93,107 @@ impl P2pNode { } } -// Track, publish, hold -impl P2pNode { - pub fn track_dna(&mut self) -> NetResult<()> { - let dna_address = self.dna_address.clone(); - self.track_extra_dna(&dna_address) +// Track +impl TestNode { + pub fn track_current_dna(&mut self) -> NetResult<()> { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + self.track_dna(¤t_dna, false) } - fn track_extra_dna(&mut self, dna_address: &Address) -> NetResult<()> { + pub fn track_dna(&mut self, dna_address: &Address, can_set_current: bool) -> NetResult<()> { + if self.tracked_dnas.contains(dna_address) { + if can_set_current { + self.set_current_dna(dna_address); + } + return Ok(()); + } let agent_id = self.agent_id.clone(); - self.send( + let res = self.send( JsonProtocol::TrackDna(TrackDnaData { dna_address: dna_address.clone(), agent_id, }) .into(), - ) + ); + if res.is_ok() { + self.tracked_dnas.insert(dna_address.clone()); + if !self.dna_stores.contains_key(dna_address) { + self.dna_stores + .insert(dna_address.clone(), DnaStore::new(dna_address.clone())); + } + if can_set_current { + self.set_current_dna(dna_address); + } + } + res } - pub fn untrack_dna(&mut self) -> NetResult<()> { - let dna_address = self.dna_address.clone(); - self.untrack_extra_dna(&dna_address) + pub fn untrack_current_dna(&mut self) -> NetResult<()> { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + let res = self.untrack_dna(¤t_dna); + if res.is_ok() { + self.current_dna = None; + } + res } - fn untrack_extra_dna(&mut self, dna_address: &Address) -> NetResult<()> { + pub fn untrack_dna(&mut self, dna_address: &Address) -> NetResult<()> { + if !self.tracked_dnas.contains(dna_address) { + return Ok(()); + } let agent_id = self.agent_id.clone(); - self.send( + let res = self.send( JsonProtocol::UntrackDna(TrackDnaData { dna_address: dna_address.clone(), agent_id, }) .into(), - ) + ); + if res.is_ok() { + self.tracked_dnas.remove(dna_address); + } + res + } + + /// + pub fn is_tracking(&self, dna_address: &Address) -> bool { + self.tracked_dnas.contains(dna_address) } + /// + pub fn set_current_dna(&mut self, dna_address: &Address) { + if self.dna_stores.contains_key(dna_address) { + self.current_dna = Some(dna_address.clone()); + }; + } +} + +/// publish, hold +impl TestNode { pub fn author_entry( &mut self, entry_address: &Address, entry_content: &serde_json::Value, can_publish: bool, ) -> NetResult<()> { - assert!(!self.authored_entry_store.get(&entry_address).is_some()); - assert!(!self.entry_store.get(&entry_address).is_some()); - self.authored_entry_store - .insert(entry_address.clone(), entry_content.clone()); + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + assert!(!dna_store.authored_entry_store.get(&entry_address).is_some()); + assert!(!dna_store.entry_store.get(&entry_address).is_some()); + dna_store + .authored_entry_store + .insert(entry_address.clone(), entry_content.clone()); + } if can_publish { let msg_data = EntryData { - dna_address: self.dna_address.clone(), + dna_address: current_dna, provider_agent_id: self.agent_id.clone(), entry_address: entry_address.clone(), entry_content: entry_content.clone(), @@ -232,19 +211,28 @@ impl P2pNode { link_entry_address: &serde_json::Value, can_publish: bool, ) -> NetResult { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); let meta_key = (entry_address.clone(), attribute.to_string()); // bookkeep { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); // Must not already have meta - assert!(!self.meta_store.has(meta_key.clone(), link_entry_address)); - self.authored_meta_store + assert!(!dna_store + .meta_store + .has(meta_key.clone(), link_entry_address)); + dna_store + .authored_meta_store .insert(meta_key.clone(), link_entry_address.clone()); } // publish it if can_publish { let msg_data = DhtMetaData { - dna_address: self.dna_address.clone(), + dna_address: self.current_dna.clone().unwrap(), provider_agent_id: self.agent_id.clone(), entry_address: entry_address.clone(), attribute: attribute.to_string(), @@ -258,9 +246,16 @@ impl P2pNode { } pub fn hold_entry(&mut self, entry_address: &Address, entry_content: &serde_json::Value) { - assert!(!self.authored_entry_store.get(&entry_address).is_some()); - assert!(!self.entry_store.get(&entry_address).is_some()); - self.entry_store + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + assert!(!dna_store.authored_entry_store.get(&entry_address).is_some()); + assert!(!dna_store.entry_store.get(&entry_address).is_some()); + dna_store + .entry_store .insert(entry_address.clone(), entry_content.clone()); } @@ -270,17 +265,25 @@ impl P2pNode { attribute: &str, link_entry_address: &serde_json::Value, ) { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); let meta_key = (entry_address.clone(), attribute.to_string()); // Must not already have meta - assert!(!self + assert!(!dna_store .authored_meta_store .has(meta_key.clone(), link_entry_address)); - self.meta_store.insert(meta_key, link_entry_address.clone()); + dna_store + .meta_store + .insert(meta_key, link_entry_address.clone()); } } /// fetch & sendMessage -impl P2pNode { +impl TestNode { /// generate a new request_id fn generate_request_id(&mut self) -> String { self.request_count += 1; @@ -291,9 +294,11 @@ impl P2pNode { /// Node asks for some entry on the network. pub fn request_entry(&mut self, entry_address: Address) -> FetchEntryData { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); let fetch_data = FetchEntryData { request_id: self.generate_request_id(), - dna_address: self.dna_address.clone(), + dna_address: current_dna, requester_agent_id: self.agent_id.clone(), entry_address, }; @@ -304,9 +309,11 @@ impl P2pNode { /// Node asks for some meta on the network. pub fn request_meta(&mut self, entry_address: Address, attribute: String) -> FetchMetaData { + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); let fetch_meta = FetchMetaData { request_id: self.generate_request_id(), - dna_address: self.dna_address.clone(), + dna_address: current_dna, requester_agent_id: self.agent_id.to_string(), entry_address, attribute, @@ -318,8 +325,11 @@ impl P2pNode { /// Node sends Message on the network. pub fn send_message(&mut self, to_agent_id: String, content: serde_json::Value) -> MessageData { + println!("set_current_dna: {:?}", self.current_dna); + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); let msg_data = MessageData { - dna_address: self.dna_address.clone(), + dna_address: current_dna, from_agent_id: self.agent_id.to_string(), request_id: self.generate_request_id(), to_agent_id, @@ -336,10 +346,12 @@ impl P2pNode { msg: MessageData, response_content: serde_json::Value, ) -> MessageData { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(msg.dna_address, current_dna.clone()); assert_eq!(msg.to_agent_id, self.agent_id); let response = MessageData { - dna_address: self.dna_address.clone(), + dna_address: current_dna.clone(), from_agent_id: self.agent_id.to_string(), request_id: msg.request_id, to_agent_id: msg.from_agent_id.clone(), @@ -352,18 +364,24 @@ impl P2pNode { } // Replies -impl P2pNode { +impl TestNode { // -- FETCH -- // /// Send a reponse to a FetchDhtData request pub fn reply_to_HandleFetchEntry(&mut self, request: &FetchEntryData) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); let msg; { // Get data from local datastores - let mut maybe_data = self.authored_entry_store.get(&request.entry_address); + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + let mut maybe_data = dna_store.authored_entry_store.get(&request.entry_address); if maybe_data.is_none() { - maybe_data = self.entry_store.get(&request.entry_address); + maybe_data = dna_store.entry_store.get(&request.entry_address); } // Send failure or success response msg = match maybe_data.clone() { @@ -398,14 +416,20 @@ impl P2pNode { /// Send a reponse to a FetchDhtMetaData request pub fn reply_to_HandleFetchMeta(&mut self, request: &FetchMetaData) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); let msg; { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); // Get meta from local datastores let meta_key = (request.entry_address.clone(), request.attribute.clone()); - let mut metas = self.authored_meta_store.get(meta_key.clone()); + let mut metas = dna_store.authored_meta_store.get(meta_key.clone()); if metas.is_empty() { - metas = self.meta_store.get(meta_key); + metas = dna_store.meta_store.get(meta_key); } self.logger.t(&format!("metas = {:?}", metas)); msg = FetchMetaResultData { @@ -428,17 +452,26 @@ impl P2pNode { &mut self, request: &GetListData, ) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); - let entry_address_list = self - .authored_entry_store - .iter() - .map(|(k, _)| k.clone()) - .collect(); - let msg = EntryListData { - entry_address_list: entry_address_list, - request_id: request.request_id.clone(), - dna_address: request.dna_address.clone(), - }; + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); + let msg; + { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + let entry_address_list = dna_store + .authored_entry_store + .iter() + .map(|(k, _)| k.clone()) + .collect(); + msg = EntryListData { + entry_address_list: entry_address_list, + request_id: request.request_id.clone(), + dna_address: request.dna_address.clone(), + }; + } self.send(JsonProtocol::HandleGetPublishingEntryListResult(msg).into()) } /// Look for the first HandleGetPublishingEntryList request received from network module and reply @@ -456,12 +489,21 @@ impl P2pNode { /// Reply to a HandleGetPublishingMetaList request pub fn reply_to_HandleGetPublishingMetaList(&mut self, request: &GetListData) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); - let msg = MetaListData { - request_id: request.request_id.clone(), - dna_address: request.dna_address.clone(), - meta_list: self.authored_meta_store.get_all(), - }; + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); + let msg; + { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + msg = MetaListData { + request_id: request.request_id.clone(), + dna_address: request.dna_address.clone(), + meta_list: dna_store.authored_meta_store.get_all(), + }; + } self.send(JsonProtocol::HandleGetPublishingMetaListResult(msg).into()) } /// Look for the first HandleGetPublishingMetaList request received from network module and reply @@ -483,13 +525,26 @@ impl P2pNode { /// Reply to a HandleGetHoldingEntryList request pub fn reply_to_HandleGetHoldingEntryList(&mut self, request: &GetListData) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); - let entry_address_list = self.entry_store.iter().map(|(k, _)| k.clone()).collect(); - let msg = EntryListData { - request_id: request.request_id.clone(), - dna_address: request.dna_address.clone(), - entry_address_list: entry_address_list, - }; + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); + let msg; + { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + let entry_address_list = dna_store + .entry_store + .iter() + .map(|(k, _)| k.clone()) + .collect(); + msg = EntryListData { + request_id: request.request_id.clone(), + dna_address: request.dna_address.clone(), + entry_address_list: entry_address_list, + }; + } self.send(JsonProtocol::HandleGetHoldingEntryListResult(msg).into()) } /// Look for the first HandleGetHoldingEntryList request received from network module and reply @@ -509,12 +564,21 @@ impl P2pNode { /// Reply to a HandleGetHoldingMetaList request pub fn reply_to_HandleGetHoldingMetaList(&mut self, request: &GetListData) -> NetResult<()> { - assert_eq!(request.dna_address, self.dna_address); - let msg = MetaListData { - request_id: request.request_id.clone(), - dna_address: request.dna_address.clone(), - meta_list: self.meta_store.get_all(), - }; + assert!(self.current_dna.is_some()); + let current_dna = self.current_dna.clone().unwrap(); + assert_eq!(request.dna_address, current_dna); + let msg; + { + let dna_store = self + .dna_stores + .get_mut(¤t_dna) + .expect("No dna_store for this DNA"); + msg = MetaListData { + request_id: request.request_id.clone(), + dna_address: request.dna_address.clone(), + meta_list: dna_store.meta_store.get_all(), + }; + } self.send(JsonProtocol::HandleGetHoldingMetaListResult(msg).into()) } /// Look for the first HandleGetHoldingMetaList request received from network module and reply @@ -533,18 +597,17 @@ impl P2pNode { } } -impl P2pNode { +impl TestNode { /// Private constructor #[cfg_attr(tarpaulin, skip)] pub fn new_with_config( agent_id_arg: String, - dna_address: Address, config: &P2pConfig, _maybe_temp_dir: Option, ) -> Self { log_dd!( "p2pnode", - "new P2pNode '{}' with config: {:?}", + "new TestNode '{}' with config: {:?}", agent_id_arg, config ); @@ -563,7 +626,7 @@ impl P2pNode { ) .expect("Failed to create P2pNetwork"); - P2pNode { + TestNode { _maybe_temp_dir, p2p_connection, receiver, @@ -573,11 +636,9 @@ impl P2pNode { request_count: 0, recv_msg_log: Vec::new(), recv_dm_log: Vec::new(), - dna_address, - entry_store: HashMap::new(), - meta_store: MetaStore::new(), - authored_entry_store: HashMap::new(), - authored_meta_store: MetaStore::new(), + dna_stores: HashMap::new(), + tracked_dnas: HashSet::new(), + current_dna: None, logger: TweetProxy::new("p2pnode"), is_network_ready: false, p2p_binding: String::new(), @@ -591,27 +652,22 @@ impl P2pNode { /// Constructor for an in-memory P2P Network #[cfg_attr(tarpaulin, skip)] - pub fn new_with_unique_memory_network(agent_id: String, dna_address: Address) -> Self { + pub fn new_with_unique_memory_network(agent_id: String) -> Self { let config = P2pConfig::new_with_unique_memory_backend(); - return P2pNode::new_with_config(agent_id, dna_address, &config, None); + return TestNode::new_with_config(agent_id, &config, None); } /// Constructor for an IPC node that uses an existing n3h process and a temp folder #[cfg_attr(tarpaulin, skip)] - pub fn new_with_uri_ipc_network( - agent_id: String, - dna_address: Address, - ipc_binding: &str, - ) -> Self { + pub fn new_with_uri_ipc_network(agent_id: String, ipc_binding: &str) -> Self { let p2p_config = P2pConfig::default_ipc_uri(Some(ipc_binding)); - return P2pNode::new_with_config(agent_id, dna_address, &p2p_config, None); + return TestNode::new_with_config(agent_id, &p2p_config, None); } /// Constructor for an IPC node that spawns and uses a n3h process and a temp folder #[cfg_attr(tarpaulin, skip)] pub fn new_with_spawn_ipc_network( agent_id: String, - dna_address: Address, maybe_config_filepath: Option<&str>, maybe_end_user_config_filepath: Option, bootstrap_nodes: Vec, @@ -623,7 +679,7 @@ impl P2pNode { bootstrap_nodes, maybe_dir_path, ); - return P2pNode::new_with_config(agent_id, dna_address, &p2p_config, _maybe_temp_dir); + return TestNode::new_with_config(agent_id, &p2p_config, _maybe_temp_dir); } /// See if there is a message to receive, and log it @@ -830,7 +886,7 @@ impl P2pNode { // n/a } JsonProtocol::HandleSendMessage(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // log the direct message sent to us self.recv_dm_log.push(msg); } @@ -845,7 +901,7 @@ impl P2pNode { // n/a } JsonProtocol::HandleFetchEntry(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // n/a } JsonProtocol::HandleFetchEntryResult(_msg) => { @@ -856,15 +912,24 @@ impl P2pNode { panic!("Core should not receive PublishDhtData message"); } JsonProtocol::HandleStoreEntry(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // Store data in local datastore - self.entry_store + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); + dna_store + .entry_store .insert(msg.entry_address, msg.entry_content); } JsonProtocol::HandleDropEntry(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // Remove data in local datastore - self.entry_store.remove(&msg.entry_address); + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); + dna_store.entry_store.remove(&msg.entry_address); } JsonProtocol::FetchMeta(_msg) => { @@ -874,7 +939,7 @@ impl P2pNode { // n/a } JsonProtocol::HandleFetchMeta(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // n/a } JsonProtocol::HandleFetchMetaResult(_msg) => { @@ -885,30 +950,32 @@ impl P2pNode { panic!("Core should not receive PublishDhtMeta message"); } JsonProtocol::HandleStoreMeta(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + assert!(self.is_tracking(&msg.dna_address)); // Store data in local datastore let meta_key = (msg.entry_address, msg.attribute); + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); for content in msg.content_list { - self.meta_store.insert(meta_key.clone(), content); + dna_store.meta_store.insert(meta_key.clone(), content); } } // TODO // JsonProtocol::HandleDropMeta(msg) => { - // assert_eq!(msg.dna_address, self.dna_address); + // assert!(self.is_tracking(&msg.dna_address)); // // Remove data in local datastore // self.meta_store.remove(&(msg.entry_address, msg.attribute)); // } // -- Publish & Hold data -- // - JsonProtocol::HandleGetPublishingEntryList(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + JsonProtocol::HandleGetPublishingEntryList(_) => { // n/a } JsonProtocol::HandleGetPublishingEntryListResult(_) => { panic!("Core should not receive HandleGetPublishingDataListResult message"); } - JsonProtocol::HandleGetHoldingEntryList(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + JsonProtocol::HandleGetHoldingEntryList(_) => { // n/a } // Our request for the hold_list has returned @@ -917,15 +984,13 @@ impl P2pNode { } // -- Publish & Hold meta -- // - JsonProtocol::HandleGetPublishingMetaList(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + JsonProtocol::HandleGetPublishingMetaList(_) => { // n/a } JsonProtocol::HandleGetPublishingMetaListResult(_) => { panic!("Core should not receive HandleGetPublishingMetaListResult message"); } - JsonProtocol::HandleGetHoldingMetaList(msg) => { - assert_eq!(msg.dna_address, self.dna_address); + JsonProtocol::HandleGetHoldingMetaList(_) => { // n/a } // Our request for the hold_list has returned @@ -938,7 +1003,7 @@ impl P2pNode { } } -impl NetSend for P2pNode { +impl NetSend for TestNode { /// send a Protocol message to the p2p network instance fn send(&mut self, data: Protocol) -> NetResult<()> { self.logger @@ -946,83 +1011,3 @@ impl NetSend for P2pNode { self.p2p_connection.send(data) } } - -//-------------------------------------------------------------------------------------------------- -// create_ipc_config -//-------------------------------------------------------------------------------------------------- - -/// Create a P2pConfig for an IPC node that uses n3h and possibily a specific folder. -/// Return the generated P2pConfig and the created tempdir if no dir was provided. -#[cfg_attr(tarpaulin, skip)] -fn create_ipc_config( - maybe_config_filepath: Option<&str>, - maybe_end_user_config_filepath: Option, - bootstrap_nodes: Vec, - maybe_dir_path: Option, -) -> (P2pConfig, Option) { - // Create temp directory if no dir was provided - let mut maybe_dir_ref = None; - let dir = if let Some(dir_path) = maybe_dir_path { - dir_path - } else { - let dir_ref = tempfile::tempdir().expect("Failed to created a temp directory."); - let dir_path = dir_ref.path().clone().to_string_lossy().to_string(); - maybe_dir_ref = Some(dir_ref); - dir_path - }; - - log_i!("create_ipc_config() dir = {}", dir); - - // Create config - let mut config: P2pConfig = match maybe_config_filepath { - Some(filepath) => { - log_d!("filepath = {}", filepath); - // Get config from file - let p2p_config = P2pConfig::from_file(filepath); - assert_eq!(p2p_config.backend_kind, P2pBackendKind::IPC); - // complement missing fields - serde_json::from_value(json!({ - "backend_kind": String::from(p2p_config.backend_kind), - "backend_config": - { - "socketType": p2p_config.backend_config["socketType"], - "bootstrapNodes": bootstrap_nodes, - "spawn": - { - "workDir": dir.clone(), - "env": { - "N3H_MODE": p2p_config.backend_config["spawn"]["env"]["N3H_MODE"], - "N3H_WORK_DIR": dir.clone(), - "N3H_IPC_SOCKET": p2p_config.backend_config["spawn"]["env"]["N3H_IPC_SOCKET"], - "N3H_LOG_LEVEL": p2p_config.backend_config["spawn"]["env"]["N3H_LOG_LEVEL"], - } - }, - }})).expect("Failled making valid P2pConfig with filepath") - } - None => { - // use default config - serde_json::from_value(json!({ - "backend_kind": "IPC", - "backend_config": - { - "socketType": "ws", - "bootstrapNodes": bootstrap_nodes, - "spawn": - { - "workDir": dir.clone(), - "env": { - "N3H_MODE": "HACK", - "N3H_WORK_DIR": dir.clone(), - "N3H_IPC_SOCKET": "tcp://127.0.0.1:*", - "N3H_LOG_LEVEL": "t" - } - }, - }})) - .expect("Failled making valid default P2pConfig") - } - }; - config.maybe_end_user_config = Some(P2pConfig::load_end_user_config( - maybe_end_user_config_filepath, - )); - return (config, maybe_dir_ref); -} diff --git a/test_bin/src/publish_hold_workflows.rs b/test_bin/src/publish_hold_workflows.rs index 98d402e24f..5b8a9de67a 100644 --- a/test_bin/src/publish_hold_workflows.rs +++ b/test_bin/src/publish_hold_workflows.rs @@ -4,7 +4,7 @@ use holochain_net::{ connection::{json_protocol::JsonProtocol, NetResult}, tweetlog::*, }; -use p2p_node::P2pNode; +use p2p_node::test_node::TestNode; /// Test the following workflow after normal setup: /// sequenceDiagram @@ -18,13 +18,13 @@ use p2p_node::P2pNode; /// net->>b: FailureResult #[cfg_attr(tarpaulin, skip)] pub fn empty_publish_entry_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: empty_publish_entry_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Alex replies an empty list to the initial HandleGetPublishingEntryList alex.reply_to_first_HandleGetPublishingEntryList(); // Billy asks for unpublished data. @@ -43,13 +43,13 @@ pub fn empty_publish_entry_list_test( /// Return some data in publish_list request #[cfg_attr(tarpaulin, skip)] pub fn publish_entry_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: publish_entry_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // author an entry without publishing it alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, false)?; // Reply to the publish_list request received from network module @@ -79,13 +79,13 @@ pub fn publish_entry_list_test( /// Reply some data in publish_meta_list #[cfg_attr(tarpaulin, skip)] pub fn publish_meta_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: publish_meta_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Author meta and reply to HandleGetPublishingMetaList alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; alex.author_meta( @@ -121,13 +121,13 @@ pub fn publish_meta_list_test( /// Reply with some meta in hold_meta_list #[cfg_attr(tarpaulin, skip)] pub fn hold_meta_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: hold_meta_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Have alex hold some data alex.hold_meta(&ENTRY_ADDRESS_1, META_LINK_ATTRIBUTE, &META_LINK_CONTENT_1); // Alex: Look for the hold_list request received from network module and reply @@ -160,12 +160,12 @@ pub fn hold_meta_list_test( /// Return some data in publish_list request #[cfg_attr(tarpaulin, skip)] pub fn double_publish_entry_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { println!("Testing: double_publish_entry_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; alex.reply_to_first_HandleGetPublishingEntryList(); // Should NOT receive a HandleFetchEntry request from network module @@ -192,13 +192,13 @@ pub fn double_publish_entry_list_test( /// Reply some data in publish_meta_list #[cfg_attr(tarpaulin, skip)] pub fn double_publish_meta_list_test( - alex: &mut P2pNode, - billy: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: double_publish_meta_list_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Author meta and reply to HandleGetPublishingMetaList alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; @@ -234,10 +234,14 @@ pub fn double_publish_meta_list_test( /// Reply some data in publish_meta_list #[cfg_attr(tarpaulin, skip)] -pub fn many_meta_test(alex: &mut P2pNode, billy: &mut P2pNode, can_connect: bool) -> NetResult<()> { +pub fn many_meta_test( + alex: &mut TestNode, + billy: &mut TestNode, + can_connect: bool, +) -> NetResult<()> { // Setup println!("Testing: many_meta_test()"); - setup_two_nodes(alex, billy, can_connect)?; + setup_two_nodes(alex, billy, &DNA_ADDRESS_A, can_connect)?; // Author meta and reply to HandleGetPublishingMetaList alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; log_d!("entry authored"); diff --git a/test_bin/src/three_workflows.rs b/test_bin/src/three_workflows.rs index f19e51f731..dcd419e0bc 100644 --- a/test_bin/src/three_workflows.rs +++ b/test_bin/src/three_workflows.rs @@ -1,4 +1,5 @@ use constants::*; +use holochain_core_types::cas::content::Address; use holochain_net::{ connection::{ json_protocol::{ConnectData, JsonProtocol}, @@ -7,34 +8,38 @@ use holochain_net::{ }, tweetlog::*, }; -use p2p_node::P2pNode; +use p2p_node::test_node::TestNode; use std::time::SystemTime; /// Do normal setup: 'TrackDna' & 'Connect', /// and check that we received 'PeerConnected' #[cfg_attr(tarpaulin, skip)] pub fn setup_three_nodes( - alex: &mut P2pNode, - billy: &mut P2pNode, - camille: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, + dna_address: &Address, can_connect: bool, ) -> NetResult<()> { // Send TrackDna message on all nodes // alex - alex.track_dna().expect("Failed sending TrackDna on alex"); + alex.track_dna(dna_address, true) + .expect("Failed sending TrackDna on alex"); let connect_result_1 = alex .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) .unwrap(); println!("self connected result 1: {:?}", connect_result_1); // billy - billy.track_dna().expect("Failed sending TrackDna on billy"); + billy + .track_dna(dna_address, true) + .expect("Failed sending TrackDna on billy"); let connect_result_2 = billy .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) .unwrap(); println!("self connected result 2: {:?}", connect_result_2); // camille camille - .track_dna() + .track_dna(dna_address, true) .expect("Failed sending TrackDna on camille"); let connect_result_3 = camille .wait(Box::new(one_is!(JsonProtocol::PeerConnected(_)))) @@ -163,14 +168,14 @@ pub fn setup_three_nodes( /// Reply with some data in hold_list #[cfg_attr(tarpaulin, skip)] pub fn hold_and_publish_test( - alex: &mut P2pNode, - billy: &mut P2pNode, - camille: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, can_connect: bool, ) -> NetResult<()> { // Setup println!("Testing: hold_entry_list_test()"); - setup_three_nodes(alex, billy, camille, can_connect)?; + setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; // Have alex hold some data alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, false)?; @@ -256,15 +261,15 @@ pub fn hold_and_publish_test( /// #[cfg_attr(tarpaulin, skip)] pub fn publish_entry_stress_test( - alex: &mut P2pNode, - billy: &mut P2pNode, - camille: &mut P2pNode, + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, can_connect: bool, ) -> NetResult<()> { let time_start = SystemTime::now(); // Setup - setup_three_nodes(alex, billy, camille, can_connect)?; + setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; let time_after_startup = SystemTime::now(); From 9453cf1a2c07598d5748057bc162120fe6bc5dd8 Mon Sep 17 00:00:00 2001 From: Julio Monteiro Date: Tue, 30 Apr 2019 11:55:11 -0300 Subject: [PATCH 64/83] Added test for bridging to demonstrate double serialization issue #1360 --- app_spec/test/test.js | 20 ++++++++++++++++++++ app_spec/zomes/blog/code/src/blog.rs | 23 ++++++++++++++++++++++- app_spec/zomes/blog/code/src/lib.rs | 8 +++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/app_spec/test/test.js b/app_spec/test/test.js index 07381cb4a2..dee46a6a08 100644 --- a/app_spec/test/test.js +++ b/app_spec/test/test.js @@ -17,6 +17,9 @@ const scenario1 = new Scenario([instanceAlice], { debugLog:true }) const scenario2 = new Scenario([instanceAlice, instanceBob], { debugLog: true }) const scenario3 = new Scenario([instanceAlice, instanceBob, instanceCarol], { debugLog: true }) +const testBridge = Config.bridge('test-bridge', instanceAlice, instanceBob) +const scenarioBridge = new Scenario([instanceAlice, instanceBob], { bridges: [testBridge], debugLog: true }) + scenario2.runTape('sign_and_verify_message', async (t, { alice, bob }) => { const message = "Hello everyone! Time to start the secret meeting"; @@ -635,6 +638,23 @@ scenario2.runTape('scenario test create & publish post -> get from other instanc t.equal(value.content, initialContent) }) +scenarioBridge.runTape('scenario test create & publish -> getting post via bridge', async (t, {alice, bob}) => { + + const initialContent = "Holo world" + const params = { content: initialContent, in_reply_to: null } + const create_result = await bob.callSync("blog", "create_post", params) + + t.equal(create_result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk") + + const post_address = create_result.Ok + const params_get = { post_address } + + const result = alice.call("blog", "get_post_bridged", params_get) + console.log("BRIDGE CALL RESULT: " + JSON.stringify(result)) + const value = JSON.parse(result.Ok.App[1]) + t.equal(value.content, initialContent) +}) + scenario2.runTape('request grant', async (t, { alice, bob }) => { /* diff --git a/app_spec/zomes/blog/code/src/blog.rs b/app_spec/zomes/blog/code/src/blog.rs index 357220b628..2751e2fc16 100644 --- a/app_spec/zomes/blog/code/src/blog.rs +++ b/app_spec/zomes/blog/code/src/blog.rs @@ -19,7 +19,7 @@ use hdk::{ use memo::Memo; use post::Post; -use std::{collections::BTreeMap, convert::TryFrom}; +use std::{collections::BTreeMap, convert::TryFrom, convert::TryInto}; #[derive(Serialize, Deserialize, Debug, DefaultJson, PartialEq)] struct SumInput { @@ -295,6 +295,27 @@ pub fn handle_my_recommended_posts() -> ZomeApiResult { hdk::get_links(&AGENT_ADDRESS, "recommended_posts") } +pub fn handle_get_post_bridged(post_address: Address) -> ZomeApiResult> { + // Obtains the post via bridge to another instance + let raw_json = hdk::call( + "test-bridge", + "blog", + Address::from(PUBLIC_TOKEN.to_string()), + "get_post", + json!({ + "post_address": post_address, + }).into() + )?; + + hdk::debug(format!("********DEBUG******** BRIDGING RAW response from test-bridge {:?}", raw_json))?; + + let entry : Option = raw_json.try_into()?; + + hdk::debug(format!("********DEBUG******** BRIDGING ACTUAL response from hosting-bridge {:?}", entry))?; + + Ok(entry) +} + #[cfg(test)] pub mod tests { diff --git a/app_spec/zomes/blog/code/src/lib.rs b/app_spec/zomes/blog/code/src/lib.rs index 8ef3417819..70e77769bb 100755 --- a/app_spec/zomes/blog/code/src/lib.rs +++ b/app_spec/zomes/blog/code/src/lib.rs @@ -190,6 +190,12 @@ define_zome! { handler: blog::handle_my_post_with_options } + get_post_bridged: { + inputs: |post_address: Address|, + outputs: |post: ZomeApiResult>|, + handler: blog::handle_get_post_bridged + } + my_posts_immediate_timeout: { inputs: | |, outputs: |post_hashes: ZomeApiResult|, @@ -217,6 +223,6 @@ define_zome! { ] traits: { - hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts, memo_address, get_memo, my_memos, create_memo, my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post, get_history_post, get_post_with_options, get_post_with_options_latest, authored_posts_with_sources, create_post_with_agent, request_post_grant,get_grants] + hc_public [show_env, check_sum, check_send, get_sources, post_address, create_post, delete_post, delete_entry_post, update_post, posts_by_agent, get_post, my_posts, memo_address, get_memo, my_memos, create_memo, my_posts_as_committed, my_posts_immediate_timeout, recommend_post, my_recommended_posts,get_initial_post, get_history_post, get_post_with_options, get_post_with_options_latest, authored_posts_with_sources, create_post_with_agent, request_post_grant, get_grants, get_post_bridged] } } From be71860a947470310ce93f1fdd96591cce50e157 Mon Sep 17 00:00:00 2001 From: damien Date: Tue, 30 Apr 2019 13:23:37 -0400 Subject: [PATCH 65/83] Added basic multidna tests --- test_bin/src/basic_workflows.rs | 3 +- test_bin/src/main.rs | 4 + test_bin/src/multidna_workflows.rs | 227 +++++++++++++++++++++++++++++ test_bin/src/p2p_node/test_node.rs | 60 ++++---- test_bin/src/three_workflows.rs | 1 - 5 files changed, 263 insertions(+), 32 deletions(-) create mode 100644 test_bin/src/multidna_workflows.rs diff --git a/test_bin/src/basic_workflows.rs b/test_bin/src/basic_workflows.rs index 9f7de0001c..99701ee228 100644 --- a/test_bin/src/basic_workflows.rs +++ b/test_bin/src/basic_workflows.rs @@ -245,7 +245,7 @@ pub fn send_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) - JsonProtocol::HandleSendMessage(msg) => msg, _ => unreachable!(), }; - assert_eq!("{\"ry\":\"hello\"}".to_string(), msg.content.to_string()); + assert_eq!(ENTRY_CONTENT_1.to_string(), msg.content.to_string()); // Send a message back from billy to alex billy.send_reponse( @@ -390,6 +390,7 @@ pub fn dht_test(alex: &mut TestNode, billy: &mut TestNode, can_connect: bool) -> /// Sending a Message before doing a 'TrackDna' should fail pub fn no_setup_test(alex: &mut TestNode, billy: &mut TestNode, _connect: bool) -> NetResult<()> { + // Little dance for making alex have its current_dna set to DNA_ADDRESS_A alex.track_dna(&DNA_ADDRESS_A, true) .expect("Failed sending TrackDna message on alex"); alex.untrack_current_dna() diff --git a/test_bin/src/main.rs b/test_bin/src/main.rs index 341fcd2541..aa581ffeb9 100755 --- a/test_bin/src/main.rs +++ b/test_bin/src/main.rs @@ -20,6 +20,7 @@ pub mod predicate; pub mod basic_workflows; pub mod connection_workflows; pub mod constants; +pub mod multidna_workflows; pub mod p2p_node; pub mod publish_hold_workflows; pub mod three_workflows; @@ -65,6 +66,9 @@ lazy_static! { pub static ref THREE_NODES_TEST_FNS: Vec = vec![ three_workflows::hold_and_publish_test, three_workflows::publish_entry_stress_test, + multidna_workflows::send_test, + multidna_workflows::dht_test, + multidna_workflows::meta_test, ]; pub static ref MULTI_NODES_TEST_FNS: Vec = vec![ ]; diff --git a/test_bin/src/multidna_workflows.rs b/test_bin/src/multidna_workflows.rs new file mode 100644 index 0000000000..29634adb5c --- /dev/null +++ b/test_bin/src/multidna_workflows.rs @@ -0,0 +1,227 @@ +use crate::three_workflows::setup_three_nodes; +use constants::*; +use holochain_core_types::cas::content::Address; +use holochain_net::{ + connection::{json_protocol::JsonProtocol, NetResult}, + tweetlog::TWEETLOG, +}; +use p2p_node::test_node::TestNode; + +/// Have multiple nodes track multiple dnas +#[cfg_attr(tarpaulin, skip)] +pub fn multi_track(mut nodes: Vec<&mut TestNode>, dnas: &[&Address]) -> NetResult<()> { + for dna in dnas { + for mut node in &mut nodes { + node.track_dna(dna, false)?; + } + } + Ok(()) +} + +/// Have multiple nodes untrack multiple dnas +#[cfg_attr(tarpaulin, skip)] +pub fn multi_untrack(mut nodes: Vec<&mut TestNode>, dnas: &[&Address]) -> NetResult<()> { + for mut node in &mut nodes { + for dna in dnas { + node.untrack_dna(dna)?; + } + } + Ok(()) +} + +/// Have 3 nodes. +/// Each pair of nodes are tracking the same DNA +/// Pairs should be able to send messages between them. +/// Non-pairs should not. +#[cfg_attr(tarpaulin, skip)] +pub fn send_test( + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, + can_connect: bool, +) -> NetResult<()> { + // Setup + setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; + multi_untrack(vec![billy], &[&DNA_ADDRESS_A])?; + multi_track(vec![alex, billy], &[&DNA_ADDRESS_B])?; + multi_track(vec![billy, camille], &[&DNA_ADDRESS_C])?; + + // Send messages on DNA A + // ====================== + alex.set_current_dna(&DNA_ADDRESS_A); + billy.set_current_dna(&DNA_ADDRESS_A); + camille.set_current_dna(&DNA_ADDRESS_A); + + // Camille should receive it + alex.send_message(CAMILLE_AGENT_ID.to_string(), ENTRY_CONTENT_1.clone()); + let res = camille + .wait(Box::new(one_is!(JsonProtocol::HandleSendMessage(_)))) + .unwrap(); + log_i!("#### got: {:?}", res); + let msg = match res { + JsonProtocol::HandleSendMessage(msg) => msg, + _ => unreachable!(), + }; + assert_eq!(ENTRY_CONTENT_1.to_string(), msg.content.to_string()); + log_i!("Send messages on DNA A COMPLETE \n\n\n"); + + // Billy should not receive it + alex.send_message(BILLY_AGENT_ID.to_string(), ENTRY_CONTENT_1.clone()); + let res = billy.wait_with_timeout(Box::new(one_is!(JsonProtocol::HandleSendMessage(_))), 1000); + assert!(res.is_none()); + + // Send messages on DNA B + // ====================== + alex.set_current_dna(&DNA_ADDRESS_B); + billy.set_current_dna(&DNA_ADDRESS_B); + camille.set_current_dna(&DNA_ADDRESS_B); + + // Billy should receive it + alex.send_message(BILLY_AGENT_ID.to_string(), ENTRY_CONTENT_2.clone()); + let res = billy + .wait(Box::new(one_is!(JsonProtocol::HandleSendMessage(_)))) + .unwrap(); + log_i!("#### got: {:?}", res); + let msg = match res { + JsonProtocol::HandleSendMessage(msg) => msg, + _ => unreachable!(), + }; + assert_eq!(ENTRY_CONTENT_2.to_string(), msg.content.to_string()); + + // Camille should not receive it + alex.send_message(CAMILLE_AGENT_ID.to_string(), ENTRY_CONTENT_2.clone()); + let res = + camille.wait_with_timeout(Box::new(one_is!(JsonProtocol::HandleSendMessage(_))), 1000); + assert!(res.is_none()); + log_i!("Send messages on DNA B COMPLETE \n\n\n"); + + // Send messages on DNA C + // ====================== + alex.set_current_dna(&DNA_ADDRESS_C); + billy.set_current_dna(&DNA_ADDRESS_C); + camille.set_current_dna(&DNA_ADDRESS_C); + + // Camille should receive it + camille.send_message(BILLY_AGENT_ID.to_string(), ENTRY_CONTENT_3.clone()); + let res = billy + .wait(Box::new(one_is!(JsonProtocol::HandleSendMessage(_)))) + .unwrap(); + log_i!("#### got: {:?}", res); + let msg = match res { + JsonProtocol::HandleSendMessage(msg) => msg, + _ => unreachable!(), + }; + assert_eq!(ENTRY_CONTENT_3.to_string(), msg.content.to_string()); + + // Alex should not receive it + camille.send_message(ALEX_AGENT_ID.to_string(), ENTRY_CONTENT_3.clone()); + let res = alex.wait_with_timeout(Box::new(one_is!(JsonProtocol::HandleSendMessage(_))), 1000); + assert!(res.is_none()); + log_i!("Send messages on DNA C COMPLETE \n\n\n"); + + // Done + Ok(()) +} + +// this is all debug code, no need to track code test coverage +#[cfg_attr(tarpaulin, skip)] +pub fn dht_test( + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, + can_connect: bool, +) -> NetResult<()> { + // Setup + setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; + multi_untrack(vec![billy], &[&DNA_ADDRESS_A])?; + multi_track(vec![alex, billy], &[&DNA_ADDRESS_B])?; + multi_track(vec![billy, camille], &[&DNA_ADDRESS_C])?; + alex.set_current_dna(&DNA_ADDRESS_A); + + // wait for gossip + let _msg_count = alex.listen(200); + + // Alex publish data on the network + alex.author_entry(&ENTRY_ADDRESS_1, &ENTRY_CONTENT_1, true)?; + + // Camille asks for that data + let fetch_data = camille.request_entry(ENTRY_ADDRESS_1.clone()); + + // Alex sends that data back to the network + alex.reply_to_HandleFetchEntry(&fetch_data)?; + + // Camille should receive requested data + let result = camille + .wait(Box::new(one_is!(JsonProtocol::FetchEntryResult(_)))) + .unwrap(); + log_i!("got FetchEntryResult: {:?}", result); + + // Billy asks for data on unknown DNA + let fetch_data = billy.request_entry(ENTRY_ADDRESS_1.clone()); + + // Alex sends that data back to the network + alex.reply_to_HandleFetchEntry(&fetch_data)?; + + // Billy might receive FailureResult + let result = billy.wait_with_timeout(Box::new(one_is!(JsonProtocol::FailureResult(_))), 1000); + log_i!("got FailureResult: {:?}", result); + + // Done + Ok(()) +} + +// this is all debug code, no need to track code test coverage +#[cfg_attr(tarpaulin, skip)] +pub fn meta_test( + alex: &mut TestNode, + billy: &mut TestNode, + camille: &mut TestNode, + can_connect: bool, +) -> NetResult<()> { + // Setup + setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; + multi_untrack(vec![billy], &[&DNA_ADDRESS_A])?; + multi_track(vec![alex, billy], &[&DNA_ADDRESS_B])?; + multi_track(vec![billy, camille], &[&DNA_ADDRESS_C])?; + alex.set_current_dna(&DNA_ADDRESS_B); + billy.set_current_dna(&DNA_ADDRESS_B); + + // wait for gossip + let _msg_count = billy.listen(200); + + // Alex publishs entry & meta on DNA B + alex.author_entry(&ENTRY_ADDRESS_3, &ENTRY_CONTENT_3, true)?; + alex.author_meta( + &ENTRY_ADDRESS_3, + &META_LINK_ATTRIBUTE.to_string(), + &META_LINK_CONTENT_3, + true, + )?; + + // Billy requests that meta + let fetch_meta = billy.request_meta(ENTRY_ADDRESS_3.clone(), META_LINK_ATTRIBUTE.to_string()); + // Alex sends HandleFetchMetaResult message + alex.reply_to_HandleFetchMeta(&fetch_meta)?; + // billy should receive requested metadata + let result = billy + .wait(Box::new(one_is!(JsonProtocol::FetchMetaResult(_)))) + .unwrap(); + log_i!("got GetMetaResult: {:?}", result); + let meta_data = unwrap_to!(result => JsonProtocol::FetchMetaResult); + assert_eq!(meta_data.entry_address, ENTRY_ADDRESS_3.clone()); + assert_eq!(meta_data.attribute, META_LINK_ATTRIBUTE.clone()); + assert_eq!(meta_data.content_list.len(), 1); + assert_eq!(meta_data.content_list[0], META_LINK_CONTENT_3.clone()); + + // Camille requests that meta + let _fetch_meta = + camille.request_meta(ENTRY_ADDRESS_3.clone(), META_LINK_ATTRIBUTE.to_string()); + // Camille should not receive requested metadata + let result = + camille.wait_with_timeout(Box::new(one_is!(JsonProtocol::FetchMetaResult(_))), 1000); + log_i!("got GetMetaResult: {:?}", result); + assert!(result.is_none()); + + // Done + Ok(()) +} diff --git a/test_bin/src/p2p_node/test_node.rs b/test_bin/src/p2p_node/test_node.rs index fe67a725f5..d2d5d459ec 100644 --- a/test_bin/src/p2p_node/test_node.rs +++ b/test_bin/src/p2p_node/test_node.rs @@ -886,7 +886,6 @@ impl TestNode { // n/a } JsonProtocol::HandleSendMessage(msg) => { - assert!(self.is_tracking(&msg.dna_address)); // log the direct message sent to us self.recv_dm_log.push(msg); } @@ -900,8 +899,7 @@ impl TestNode { JsonProtocol::FetchEntryResult(_) => { // n/a } - JsonProtocol::HandleFetchEntry(msg) => { - assert!(self.is_tracking(&msg.dna_address)); + JsonProtocol::HandleFetchEntry(_msg) => { // n/a } JsonProtocol::HandleFetchEntryResult(_msg) => { @@ -912,24 +910,26 @@ impl TestNode { panic!("Core should not receive PublishDhtData message"); } JsonProtocol::HandleStoreEntry(msg) => { - assert!(self.is_tracking(&msg.dna_address)); - // Store data in local datastore - let mut dna_store = self - .dna_stores - .get_mut(&msg.dna_address) - .expect("No dna_store for this DNA"); - dna_store - .entry_store - .insert(msg.entry_address, msg.entry_content); + if self.is_tracking(&msg.dna_address) { + // Store data in local datastore + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); + dna_store + .entry_store + .insert(msg.entry_address, msg.entry_content); + } } JsonProtocol::HandleDropEntry(msg) => { - assert!(self.is_tracking(&msg.dna_address)); - // Remove data in local datastore - let mut dna_store = self - .dna_stores - .get_mut(&msg.dna_address) - .expect("No dna_store for this DNA"); - dna_store.entry_store.remove(&msg.entry_address); + if self.is_tracking(&msg.dna_address) { + // Remove data in local datastore + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); + dna_store.entry_store.remove(&msg.entry_address); + } } JsonProtocol::FetchMeta(_msg) => { @@ -938,8 +938,7 @@ impl TestNode { JsonProtocol::FetchMetaResult(_msg) => { // n/a } - JsonProtocol::HandleFetchMeta(msg) => { - assert!(self.is_tracking(&msg.dna_address)); + JsonProtocol::HandleFetchMeta(_msg) => { // n/a } JsonProtocol::HandleFetchMetaResult(_msg) => { @@ -950,15 +949,16 @@ impl TestNode { panic!("Core should not receive PublishDhtMeta message"); } JsonProtocol::HandleStoreMeta(msg) => { - assert!(self.is_tracking(&msg.dna_address)); - // Store data in local datastore - let meta_key = (msg.entry_address, msg.attribute); - let mut dna_store = self - .dna_stores - .get_mut(&msg.dna_address) - .expect("No dna_store for this DNA"); - for content in msg.content_list { - dna_store.meta_store.insert(meta_key.clone(), content); + if self.is_tracking(&msg.dna_address) { + // Store data in local datastore + let meta_key = (msg.entry_address, msg.attribute); + let mut dna_store = self + .dna_stores + .get_mut(&msg.dna_address) + .expect("No dna_store for this DNA"); + for content in msg.content_list { + dna_store.meta_store.insert(meta_key.clone(), content); + } } } // TODO diff --git a/test_bin/src/three_workflows.rs b/test_bin/src/three_workflows.rs index dcd419e0bc..6241f10ca2 100644 --- a/test_bin/src/three_workflows.rs +++ b/test_bin/src/three_workflows.rs @@ -174,7 +174,6 @@ pub fn hold_and_publish_test( can_connect: bool, ) -> NetResult<()> { // Setup - println!("Testing: hold_entry_list_test()"); setup_three_nodes(alex, billy, camille, &DNA_ADDRESS_A, can_connect)?; // Have alex hold some data From ec458f3e868fcaad1f59cf986a0ae7add60b45f8 Mon Sep 17 00:00:00 2001 From: David Meister Date: Wed, 1 May 2019 20:04:52 +1000 Subject: [PATCH 66/83] working nix build for cli and conductor --- default.nix | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/default.nix b/default.nix index 2df79ccae9..c3801a7839 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,4 @@ -let - - pkgs = import ./holonix/nixpkgs/nixpkgs.nix; - +{ cli = import ./holonix/dist/cli/build.nix; conductor = import ./holonix/dist/conductor/build.nix; - -in -with pkgs; -stdenv.mkDerivation rec { - - name = "holochain-binaries"; - - buildInputs = [ - cli - conductor - ]; - } From f83c22a2ea227c118d61c30a50ee8228d85f7792 Mon Sep 17 00:00:00 2001 From: David Meister Date: Wed, 1 May 2019 20:11:59 +1000 Subject: [PATCH 67/83] tweak names of binaries for default.nix --- default.nix | 4 ++-- holonix/dist/src/lib.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index c3801a7839..a45b0e25d5 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ { - cli = import ./holonix/dist/cli/build.nix; - conductor = import ./holonix/dist/conductor/build.nix; + hc = import ./holonix/dist/cli/build.nix; + holochain = import ./holonix/dist/conductor/build.nix; } diff --git a/holonix/dist/src/lib.nix b/holonix/dist/src/lib.nix index 2dc88a2559..68b6c20147 100644 --- a/holonix/dist/src/lib.nix +++ b/holonix/dist/src/lib.nix @@ -11,7 +11,7 @@ in rec binary-derivation = args: pkgs.stdenv.mkDerivation { - name = "holochain-${args.name}"; + name = "${args.binary}"; src = pkgs.fetchurl { url = artifact-url ( { target = dist.artifact-target; } // args ); From 313a3bdcf3903de50bbcf3554dd2738a595ef1f0 Mon Sep 17 00:00:00 2001 From: David Meister Date: Wed, 1 May 2019 20:21:07 +1000 Subject: [PATCH 68/83] updated changelog --- CHANGELOG-UNRELEASED.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index a6935c9358..4c96f93b18 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- default.nix file added to facilitate `nix-env` based binary installation [#1356](https://github.com/holochain/holochain-rust/pull/1356) + ### Changed ### Deprecated @@ -15,5 +17,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security - - From 88bc3ca9c481ab6f957240a7de283c90088825c4 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 13:22:25 -0400 Subject: [PATCH 69/83] Update json_rpc_http.md --- doc/holochain_101/src/json_rpc_http.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/holochain_101/src/json_rpc_http.md b/doc/holochain_101/src/json_rpc_http.md index 50e7f88032..8e433fffa3 100644 --- a/doc/holochain_101/src/json_rpc_http.md +++ b/doc/holochain_101/src/json_rpc_http.md @@ -37,16 +37,15 @@ A response something like the following might be returned: The following discusses how to use cURL (and thus HTTP generally) to make calls to Zome functions. -The JSON-RPC method -To use as the JSON-RPC "method" the instance ID (as seen in the `info/instances` example), the Zome name, and the function name are combined into a single string, separated by forward slash (`/`) characters. It could look like the following: -`"method": "test-instance/blogs/create_blog"` +The JSON-RPC "method" to use is simply "call". -**TODO: update to reflect the new "call" method** +The instance ID (as seen in the `info/instances` example), the Zome name, and the function name all need to be given as values in the "params" value of the JSON-RPC, in addition to the arguments to pass that function. This part of the "params" object might look like this: +`{"instance_id": "test-instance", "zome": "blog", "function": "create_post"}` -Unlike `info/instances`, Zome functions usually expect arguments. To give arguments, a JSON object should be constructed. It may look like the following: +Unlike `info/instances`, Zome functions usually expect arguments. To give arguments, a JSON object should be constructed, and given as `"args"` key of the "params" value. It may look like the following: `"args": {"content": "sample content"}` -With all this, a request like the following could be made via cURL from a terminal: +Combining these, a request like the following could be made via cURL from a terminal: `curl -X POST -H "Content-Type: application/json" -d '{"id": "0", "jsonrpc": "2.0", "method": "call", "params": {"instance_id": "test-instance", "zome": "blog", "function": "create_post", "args": { "content": "sample content"} }}' http://127.0.0.1:8888` A response like the following might be returned: From ebb219fb1bd87e444020821557b679cbe158a1e9 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 13:24:28 -0400 Subject: [PATCH 70/83] Update conductor_json_rpc_api.md --- doc/holochain_101/src/conductor_json_rpc_api.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/holochain_101/src/conductor_json_rpc_api.md b/doc/holochain_101/src/conductor_json_rpc_api.md index a5ba73cf98..1071a35bcc 100644 --- a/doc/holochain_101/src/conductor_json_rpc_api.md +++ b/doc/holochain_101/src/conductor_json_rpc_api.md @@ -31,18 +31,17 @@ The method `info/instances` doesn't require any input parameters, so `params` ca The following explains the general JSON-RPC pattern for how to call a Zome function. -Unlike `info/instances`, a zome function call also expects arguments. We will need to include a JSON-RPC `params` field in our RPC call. +Unlike `info/instances`, a Zome function call also expects arguments. We will need to include a JSON-RPC `args` field in our RPC call. To call a Zome function, use `"call"` as the JSON-RPC `method`, and a `params` object with four items: 1. `instance_id`: The instance ID, corresponding to the instance IDs returned by `info/instances` 2. `zome`: The name of the Zome 3. `function`: The name of the function -4. `params`: The actual parameters of the zome function call - - (yes, it's a little confusing that a sub-field of `params` is also named `params`, but we are using an RPC method to call a zome function, so nested parameters are inevitable!) +4. `args`: The actual parameters of the zome function call In the last example, the instance ID "test-instance" was returned, which can be used here as the instance ID. Say there was a Zome in a DNA called "blogs", this is the Zome name. That Zome has a function called "create_blog", that is the function name. -> Any top level keys of the `params` field should correspond **exactly** with the name of an argument expected by the Zome method being called. +> Any top level keys of the `args` field should correspond **exactly** with the name of an argument expected by the Zome method being called. **example zome function arguments** @@ -62,7 +61,7 @@ In the last example, the instance ID "test-instance" was returned, which can be "instance_id": "test-instance", "zome": "blog", "function": "create_blog", - "params": { + "args": { "blog": { "content": "sample content" } From 339adee40c929995b61c8238b71d4b5ecb6c981c Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 13:25:33 -0400 Subject: [PATCH 71/83] Update json_rpc_websockets.md --- doc/holochain_101/src/json_rpc_websockets.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/holochain_101/src/json_rpc_websockets.md b/doc/holochain_101/src/json_rpc_websockets.md index 786235fe17..8daef6574c 100644 --- a/doc/holochain_101/src/json_rpc_websockets.md +++ b/doc/holochain_101/src/json_rpc_websockets.md @@ -67,8 +67,6 @@ The following discusses how to use `rpc-websockets` to make calls to Zome functi To use as the JSON-RPC "method" the instance ID (as seen in the `info/instances` example), the Zome name, and the function name are combined into a single string, separated by forward slash (`/`) characters. It could look like the following: `'test-instance/blogs/create_blog'` -**TODO: update to reflect the new "call" method** - A JSON object is constructed to give arguments. It could look like the following: `{ blog: { content: 'sample content' }}` From 3b449c9e5e36b750df37501226dc1533da6f7fbf Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 13:30:07 -0400 Subject: [PATCH 72/83] Update json_rpc_websockets.md --- doc/holochain_101/src/json_rpc_websockets.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/holochain_101/src/json_rpc_websockets.md b/doc/holochain_101/src/json_rpc_websockets.md index 8daef6574c..147597c728 100644 --- a/doc/holochain_101/src/json_rpc_websockets.md +++ b/doc/holochain_101/src/json_rpc_websockets.md @@ -64,11 +64,13 @@ If this code was run in nodejs, the output should be: ### Calling Zome Functions The following discusses how to use `rpc-websockets` to make calls to Zome functions. -To use as the JSON-RPC "method" the instance ID (as seen in the `info/instances` example), the Zome name, and the function name are combined into a single string, separated by forward slash (`/`) characters. It could look like the following: -`'test-instance/blogs/create_blog'` +The JSON-RPC "method" to use is simply "call". -A JSON object is constructed to give arguments. It could look like the following: -`{ blog: { content: 'sample content' }}` +The instance ID (as seen in the `info/instances` example), the Zome name, and the function name all need to be given as values in the "params" value of the JSON-RPC, in addition to the arguments to pass that function. This part of the "params" object might look like this: +`{"instance_id": "test-instance", "zome": "blog", "function": "create_post"}` + + Unlike `info/instances`, Zome functions usually expect arguments. To give arguments, a JSON object should be constructed, and given as `"args"` key of the "params" value. It may look like the following: +`{ blog: { content: "sample content" }}` The following code shows how to use `rpc-websockets` to call Zome functions. ```js From 3dd32eceabf19ca1c8660134f3fb49caa214f007 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 13:31:38 -0400 Subject: [PATCH 73/83] Update conductor_json_rpc_api.md --- doc/holochain_101/src/conductor_json_rpc_api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/holochain_101/src/conductor_json_rpc_api.md b/doc/holochain_101/src/conductor_json_rpc_api.md index 1071a35bcc..82066b0127 100644 --- a/doc/holochain_101/src/conductor_json_rpc_api.md +++ b/doc/holochain_101/src/conductor_json_rpc_api.md @@ -43,13 +43,13 @@ In the last example, the instance ID "test-instance" was returned, which can be > Any top level keys of the `args` field should correspond **exactly** with the name of an argument expected by the Zome method being called. -**example zome function arguments** +**Example Zome Function Arguments** ```json { "blog": { "content": "sample content" }} ``` -### Example request +### Example Request **example request** ```json From e013673c1bf72c2534c3c515008dcf514a357e65 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 22:27:47 +0200 Subject: [PATCH 74/83] Fix bridge calls by translating serialized Result to native Result --- core/src/nucleus/ribosome/api/call.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 76fbbbb188..2661c952c3 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -12,6 +12,7 @@ use jsonrpc_lite::JsonRpc; use snowflake::ProcessUniqueId; use std::{convert::TryFrom, sync::Arc}; use wasmi::{RuntimeArgs, RuntimeValue}; +use serde_json::Value; // ZomeFnCallArgs to ZomeFnCall impl ZomeFnCall { @@ -113,7 +114,30 @@ fn bridge_call(runtime: &mut Runtime, input: ZomeFnCallArgs) -> Result Ok(JsonString::from(response.get_result().unwrap().to_owned())), + JsonRpc::Success(_) => { + // The response contains a serialized ZomeApiResult which we need to map the native + // Result that this function returns.. + + // First we try to unwrap a potential stringification: + let value_response = response.get_result().unwrap().to_owned(); + let string_response = value_response.to_string(); + let maybe_parsed_string: Result = serde_json::from_str(&string_response); + let sanitized_response = match maybe_parsed_string { + Ok(string) => string, + Err(_) => string_response, + }; + // Below, sanitized_response is the same response but guaranteed without quotes. + + // Now we unwrap the Result by parsing it into a Result: + let maybe_parsed_result: Result, serde_json::error::Error> = serde_json::from_str(&sanitized_response); + maybe_parsed_result + .map_err(|e| HolochainError::SerializationError(e.to_string())) + .and_then(|result| match result { + Ok(value) => Ok(JsonString::from(value)), + Err(error) => Err(error) + }) + + }, JsonRpc::Error(_) => Err(HolochainError::ErrorGeneric( serde_json::to_string(&response.get_error().unwrap()).unwrap(), )), From e82c715dab67180aad3deebde9de3d2e9f089a8e Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 22:28:35 +0200 Subject: [PATCH 75/83] rustfmt --- core/src/nucleus/ribosome/api/call.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 2661c952c3..996ea01be1 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -121,23 +121,26 @@ fn bridge_call(runtime: &mut Runtime, input: ZomeFnCallArgs) -> Result = serde_json::from_str(&string_response); - let sanitized_response = match maybe_parsed_string { + let maybe_parsed_string: Result = + serde_json::from_str(&string_response); + let sanitized_response = match maybe_parsed_string { Ok(string) => string, Err(_) => string_response, }; // Below, sanitized_response is the same response but guaranteed without quotes. // Now we unwrap the Result by parsing it into a Result: - let maybe_parsed_result: Result, serde_json::error::Error> = serde_json::from_str(&sanitized_response); + let maybe_parsed_result: Result< + Result, + serde_json::error::Error, + > = serde_json::from_str(&sanitized_response); maybe_parsed_result .map_err(|e| HolochainError::SerializationError(e.to_string())) .and_then(|result| match result { Ok(value) => Ok(JsonString::from(value)), - Err(error) => Err(error) + Err(error) => Err(error), }) - - }, + } JsonRpc::Error(_) => Err(HolochainError::ErrorGeneric( serde_json::to_string(&response.get_error().unwrap()).unwrap(), )), From 7570f5655a86b00cf0a2e1541720ef5400270534 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 22:30:02 +0200 Subject: [PATCH 76/83] Remove unused import --- core/src/nucleus/ribosome/api/call.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 996ea01be1..968898bbd4 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -12,7 +12,6 @@ use jsonrpc_lite::JsonRpc; use snowflake::ProcessUniqueId; use std::{convert::TryFrom, sync::Arc}; use wasmi::{RuntimeArgs, RuntimeValue}; -use serde_json::Value; // ZomeFnCallArgs to ZomeFnCall impl ZomeFnCall { From 317cc66154debc99c8ea78f37b7126367de02f40 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 22:30:02 +0200 Subject: [PATCH 77/83] Revert "Remove unused import" This reverts commit 7570f5655a86b00cf0a2e1541720ef5400270534. --- core/src/nucleus/ribosome/api/call.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 3c291061f8..4535bdaf23 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -12,6 +12,7 @@ use jsonrpc_lite::JsonRpc; use snowflake::ProcessUniqueId; use std::{convert::TryFrom, sync::Arc}; use wasmi::{RuntimeArgs, RuntimeValue}; +use serde_json::Value; // ZomeFnCallArgs to ZomeFnCall impl ZomeFnCall { From 9caafef22493c7c5aeaccfa516fe282c43bceaaa Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 22:34:23 +0200 Subject: [PATCH 78/83] rustfmt --- core/src/nucleus/ribosome/api/call.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 4535bdaf23..5ebb573895 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -9,10 +9,10 @@ use crate::{ use holochain_core_types::{error::HolochainError, json::JsonString}; use holochain_wasm_utils::api_serialization::{ZomeFnCallArgs, THIS_INSTANCE}; use jsonrpc_lite::JsonRpc; +use serde_json::Value; use snowflake::ProcessUniqueId; use std::{convert::TryFrom, sync::Arc}; use wasmi::{RuntimeArgs, RuntimeValue}; -use serde_json::Value; // ZomeFnCallArgs to ZomeFnCall impl ZomeFnCall { From a3dcf9254acbb0679506a4784abe498b534f67f4 Mon Sep 17 00:00:00 2001 From: Nicolas Luck Date: Wed, 1 May 2019 23:08:09 +0200 Subject: [PATCH 79/83] Make it possible to (still) bridge-call zome functions w/out Result Like the zome function in our test which just returns a plain string.. --- core/src/nucleus/ribosome/api/call.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/nucleus/ribosome/api/call.rs b/core/src/nucleus/ribosome/api/call.rs index 5ebb573895..7ffc61cc62 100644 --- a/core/src/nucleus/ribosome/api/call.rs +++ b/core/src/nucleus/ribosome/api/call.rs @@ -6,7 +6,10 @@ use crate::{ ZomeFnCall, }, }; -use holochain_core_types::{error::HolochainError, json::JsonString}; +use holochain_core_types::{ + error::HolochainError, + json::{JsonString, RawString}, +}; use holochain_wasm_utils::api_serialization::{ZomeFnCallArgs, THIS_INSTANCE}; use jsonrpc_lite::JsonRpc; use serde_json::Value; @@ -140,6 +143,20 @@ fn bridge_call(runtime: &mut Runtime, input: ZomeFnCallArgs) -> Result Ok(JsonString::from(value)), Err(error) => Err(error), }) + .or_else(|_| { + // If we could not parse the result into a Result, well then the called + // zome function maybe returns a plain return value. + // We don't want to make this impossible so we just return that as + // JsonString. + // We just need to make sure it is valid JSON, so we do try to parse + // one last time: + let maybe_parsed_value: Result = + serde_json::from_str(&sanitized_response); + match maybe_parsed_value { + Ok(parsed_value) => Ok(JsonString::from(parsed_value)), + Err(_) => Ok(JsonString::from(RawString::from(sanitized_response))), + } + }) } JsonRpc::Error(_) => Err(HolochainError::ErrorGeneric( serde_json::to_string(&response.get_error().unwrap()).unwrap(), From 78f5fbd8dc00a60fa9b94a2ac1d82a37874de156 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 1 May 2019 21:44:29 -0400 Subject: [PATCH 80/83] Update pull_request_template.md --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index eb7948850b..d67f8acef3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,7 +10,7 @@ ## changelog -Please check one of the following, relating to the [CHANGELOG](https://github.com/holochain/holochain-rust/blob/develop/CHANGELOG.md) +Please check one of the following, relating to the [CHANGELOG-UNRELEASED.md](https://github.com/holochain/holochain-rust/blob/develop/CHANGELOG-UNRELEASED.md) -- [ ] this is a code change that effects some consumer (e.g. zome developers) of holochain core so there is an 'Unreleased' CHANGELOG item, with the format `- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)` +- [ ] this is a code change that effects some consumer (e.g. zome developers) of holochain core so it is added to the CHANGELOG-UNRELEASED.md (linked above), with the format `- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)` - [ ] this is not a code change, or doesn't effect anyone outside holochain core development From 863b1f13a8c5d5f26f37ebf08e6e75ec8ee302b2 Mon Sep 17 00:00:00 2001 From: David Meister Date: Thu, 2 May 2019 18:31:49 +1000 Subject: [PATCH 81/83] merge shell.nix and default.nix --- default.nix | 39 +++++++++++++++++++++++++++++++++++++++ shell.nix | 37 ------------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-) delete mode 100644 shell.nix diff --git a/default.nix b/default.nix index a45b0e25d5..4fab6a6bde 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,43 @@ +let + + pkgs = import ./holonix/nixpkgs/nixpkgs.nix; + darwin = import ./holonix/darwin/config.nix; + openssl = import ./holonix/openssl/config.nix; + rust = import ./holonix/rust/config.nix; + +in +with pkgs; { + holonix-shell = + stdenv.mkDerivation rec { + name = "holonix-shell"; + + buildInputs = import ./holonix/build.nix; + + # non-nixos OS can have a "dirty" setup with rustup installed for the current + # user. + # `nix-shell` can inherit this e.g. through sourcing `.bashrc`. + # even `nix-shell --pure` will still source some files and inherit paths. + # for those users we can at least give the OS a clue that we want our pinned + # rust version through this environment variable. + # https://github.com/rust-lang/rustup.rs#environment-variables + # https://github.com/NixOS/nix/issues/903 + RUSTUP_TOOLCHAIN = rust.nightly.version; + RUSTFLAGS = rust.compile.flags; + CARGO_INCREMENTAL = rust.compile.incremental; + RUST_LOG = rust.log; + NUM_JOBS = rust.compile.jobs; + + OPENSSL_STATIC = openssl.static; + + shellHook = '' + # cargo installs things to the user's home so we need it on the path + export PATH=~/.cargo/bin:$PATH + export HC_TARGET_PREFIX=~/nix-holochain/ + export NIX_LDFLAGS="${darwin.ld-flags}$NIX_LDFLAGS" + ''; + }; + hc = import ./holonix/dist/cli/build.nix; holochain = import ./holonix/dist/conductor/build.nix; } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 62cb2b82d7..0000000000 --- a/shell.nix +++ /dev/null @@ -1,37 +0,0 @@ -let - - pkgs = import ./holonix/nixpkgs/nixpkgs.nix; - darwin = import ./holonix/darwin/config.nix; - openssl = import ./holonix/openssl/config.nix; - rust = import ./holonix/rust/config.nix; - -in -with pkgs; -stdenv.mkDerivation rec { - name = "holonix-shell"; - - buildInputs = import ./holonix/build.nix; - - # non-nixos OS can have a "dirty" setup with rustup installed for the current - # user. - # `nix-shell` can inherit this e.g. through sourcing `.bashrc`. - # even `nix-shell --pure` will still source some files and inherit paths. - # for those users we can at least give the OS a clue that we want our pinned - # rust version through this environment variable. - # https://github.com/rust-lang/rustup.rs#environment-variables - # https://github.com/NixOS/nix/issues/903 - RUSTUP_TOOLCHAIN = rust.nightly.version; - RUSTFLAGS = rust.compile.flags; - CARGO_INCREMENTAL = rust.compile.incremental; - RUST_LOG = rust.log; - NUM_JOBS = rust.compile.jobs; - - OPENSSL_STATIC = openssl.static; - - shellHook = '' - # cargo installs things to the user's home so we need it on the path - export PATH=~/.cargo/bin:$PATH - export HC_TARGET_PREFIX=~/nix-holochain/ - export NIX_LDFLAGS="${darwin.ld-flags}$NIX_LDFLAGS" - ''; -} From b681ee88c59e86f87b2388741aaaaea45a8d13f1 Mon Sep 17 00:00:00 2001 From: David Meister Date: Thu, 2 May 2019 18:40:51 +1000 Subject: [PATCH 82/83] update changelog --- CHANGELOG-UNRELEASED.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index 0da3e20cde..65d22ce835 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Changes `LinkAdd` and `RemoveEntry` so that they return a hash instead of a null [#1343](https://github.com/holochain/holochain-rust/pull/1343) +- Merged `default.nix` and `shell.nix` to improve `nix-shell` handling [#1371](https://github.com/holochain/holochain-rust/pull/1371) ### Deprecated From ca901fb724c11036543d43bc1723ed027c1d0b1f Mon Sep 17 00:00:00 2001 From: David Meister Date: Thu, 2 May 2019 23:32:15 +1000 Subject: [PATCH 83/83] Release 0.0.14-alpha1 --- CHANGELOG-UNRELEASED.md | 7 ++----- CHANGELOG.md | 19 +++++++++++++++++++ app_spec/zomes/blog/code/Cargo.toml | 2 +- app_spec/zomes/summer/code/Cargo.toml | 2 +- benchmarks/Cargo.toml | 2 +- cas_implementations/Cargo.toml | 2 +- cli/Cargo.toml | 2 +- cli/README.md | 2 +- cli/src/cli/js-tests-scaffold/package.json | 2 +- cli/src/cli/scaffold/rust.rs | 2 +- cli/src/cli/scaffold/rust/lib.rs | 2 +- common/Cargo.toml | 2 +- conductor/Cargo.toml | 2 +- conductor/README.md | 2 +- conductor_api/Cargo.toml | 2 +- conductor_api/test-bridge-caller/Cargo.toml | 2 +- conductor_api/wasm-test/Cargo.toml | 2 +- core/Cargo.toml | 2 +- core/src/nucleus/actions/wasm-test/Cargo.toml | 2 +- core_api_c_binding/Cargo.toml | 2 +- core_types/Cargo.toml | 2 +- core_types_derive/Cargo.toml | 2 +- dna_c_binding/Cargo.toml | 2 +- dpki/Cargo.toml | 2 +- hdk-rust/Cargo.toml | 2 +- hdk-rust/wasm-test/Cargo.toml | 2 +- holonix/release/config.nix | 10 +++++----- holonix/release/pulse/config.nix | 5 +++-- holonix/release/src/audit.nix | 6 ++++++ net/Cargo.toml | 2 +- nodejs_conductor/native/Cargo.toml | 2 +- nodejs_conductor/package.json | 2 +- nodejs_waiter/Cargo.toml | 2 +- sodium/Cargo.toml | 2 +- test_bin/Cargo.toml | 2 +- test_utils/Cargo.toml | 2 +- wasm_utils/Cargo.toml | 2 +- .../wasm-test/integration-test/Cargo.toml | 2 +- 38 files changed, 68 insertions(+), 45 deletions(-) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index 65d22ce835..a6935c9358 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -6,12 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320) -- default.nix file added to facilitate `nix-env` based binary installation [#1356](https://github.com/holochain/holochain-rust/pull/1356) - ### Changed -- Changes `LinkAdd` and `RemoveEntry` so that they return a hash instead of a null [#1343](https://github.com/holochain/holochain-rust/pull/1343) -- Merged `default.nix` and `shell.nix` to improve `nix-shell` handling [#1371](https://github.com/holochain/holochain-rust/pull/1371) ### Deprecated @@ -20,3 +15,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security + + diff --git a/CHANGELOG.md b/CHANGELOG.md index c6e207be32..e9012a98e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.14-alpha1] - 2019-05-02 + +### Added + +- Adds hdk::commit_entry_result() which features: optional argument to include additional provenances. [#1320](https://github.com/holochain/holochain-rust/pull/1320) +- default.nix file added to facilitate `nix-env` based binary installation [#1356](https://github.com/holochain/holochain-rust/pull/1356) + +### Changed +- Changes `LinkAdd` and `RemoveEntry` so that they return a hash instead of a null [#1343](https://github.com/holochain/holochain-rust/pull/1343) +- Merged `default.nix` and `shell.nix` to improve `nix-shell` handling [#1371](https://github.com/holochain/holochain-rust/pull/1371) + +### Deprecated + +### Removed + +### Fixed + +### Security + ## [0.0.13-alpha1] - 2019-04-29 ### Added diff --git a/app_spec/zomes/blog/code/Cargo.toml b/app_spec/zomes/blog/code/Cargo.toml index 7b19c87fe8..61d97463d4 100644 --- a/app_spec/zomes/blog/code/Cargo.toml +++ b/app_spec/zomes/blog/code/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "code" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/app_spec/zomes/summer/code/Cargo.toml b/app_spec/zomes/summer/code/Cargo.toml index d3bf789232..085e62901c 100644 --- a/app_spec/zomes/summer/code/Cargo.toml +++ b/app_spec/zomes/summer/code/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "code" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index a9820322c8..8e1eb8cd3b 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "benchmarks" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/cas_implementations/Cargo.toml b/cas_implementations/Cargo.toml index b4df13c31c..96c39bf61c 100644 --- a/cas_implementations/Cargo.toml +++ b/cas_implementations/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_cas_implementations" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 2a0b28f277..6401470af3 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hc" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/cli/README.md b/cli/README.md index f5a91b330c..7046dd358b 100644 --- a/cli/README.md +++ b/cli/README.md @@ -39,7 +39,7 @@ $ cargo install hc --force --git https://github.com/holochain/holochain-rust.git To install the latest released version of the Holochain conductor, run the following command in a terminal ```shell -$ cargo install hc --force --git https://github.com/holochain/holochain-rust.git --tag v0.0.13-alpha1 +$ cargo install hc --force --git https://github.com/holochain/holochain-rust.git --tag v0.0.14-alpha1 ``` The command line tools are now available in your command line using the `hc` command. diff --git a/cli/src/cli/js-tests-scaffold/package.json b/cli/src/cli/js-tests-scaffold/package.json index 50c5ffd1d3..cbf5b4d4dd 100644 --- a/cli/src/cli/js-tests-scaffold/package.json +++ b/cli/src/cli/js-tests-scaffold/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@holochain/holochain-nodejs": "0.4.12-alpha1", + "@holochain/holochain-nodejs": "0.4.13-alpha1", "json3": "*", "tape": "^4.9.1" } diff --git a/cli/src/cli/scaffold/rust.rs b/cli/src/cli/scaffold/rust.rs index 542f456a61..df543706d8 100644 --- a/cli/src/cli/scaffold/rust.rs +++ b/cli/src/cli/scaffold/rust.rs @@ -34,7 +34,7 @@ fn generate_cargo_toml(name: &str, contents: &str) -> DefaultResult { let version_default = if maybe_version.is_some() { maybe_version.unwrap() } else { - String::from("tag = \"v0.0.13-alpha1\"") + String::from("tag = \"v0.0.14-alpha1\"") }; let maybe_package = config.get("package"); diff --git a/cli/src/cli/scaffold/rust/lib.rs b/cli/src/cli/scaffold/rust/lib.rs index 2705ec3393..1ed415b971 100755 --- a/cli/src/cli/scaffold/rust/lib.rs +++ b/cli/src/cli/scaffold/rust/lib.rs @@ -21,7 +21,7 @@ use hdk::holochain_core_types::{ validation::EntryValidationData }; -// see https://developer.holochain.org/api/0.0.13-alpha1/hdk/ for info on using the hdk library +// see https://developer.holochain.org/api/0.0.14-alpha1/hdk/ for info on using the hdk library // This is a sample zome that defines an entry type "MyEntry" that can be committed to the // agent's chain via the exposed function create_my_entry diff --git a/common/Cargo.toml b/common/Cargo.toml index ec3f8354ea..64341b4b06 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_common" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/conductor/Cargo.toml b/conductor/Cargo.toml index 0f0726e5e9..9d28c770fd 100644 --- a/conductor/Cargo.toml +++ b/conductor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/conductor/README.md b/conductor/README.md index fc48b0e969..c944276837 100644 --- a/conductor/README.md +++ b/conductor/README.md @@ -29,7 +29,7 @@ $ cargo install holochain --force --git https://github.com/holochain/holochain-r To install the latest released version of the Holochain conductor, run the following command in a terminal ```shell -$ cargo install holochain --force --git https://github.com/holochain/holochain-rust.git --tag v0.0.13-alpha1 +$ cargo install holochain --force --git https://github.com/holochain/holochain-rust.git --tag v0.0.14-alpha1 ``` The Conductor should then be available from your command line using the `holochain` command. diff --git a/conductor_api/Cargo.toml b/conductor_api/Cargo.toml index f906df1331..8c21b39ee0 100644 --- a/conductor_api/Cargo.toml +++ b/conductor_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_conductor_api" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/conductor_api/test-bridge-caller/Cargo.toml b/conductor_api/test-bridge-caller/Cargo.toml index 5087f9fd2e..75c5f3a425 100644 --- a/conductor_api/test-bridge-caller/Cargo.toml +++ b/conductor_api/test-bridge-caller/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-bridge-caller" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/conductor_api/wasm-test/Cargo.toml b/conductor_api/wasm-test/Cargo.toml index 34281b4b08..4aed27e76b 100644 --- a/conductor_api/wasm-test/Cargo.toml +++ b/conductor_api/wasm-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "example_api_wasm" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/core/Cargo.toml b/core/Cargo.toml index 5af157efeb..d3fe6ede77 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_core" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/core/src/nucleus/actions/wasm-test/Cargo.toml b/core/src/nucleus/actions/wasm-test/Cargo.toml index f7b01cde22..9e47e5c7d5 100644 --- a/core/src/nucleus/actions/wasm-test/Cargo.toml +++ b/core/src/nucleus/actions/wasm-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nucleus-actions-tests" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/core_api_c_binding/Cargo.toml b/core_api_c_binding/Cargo.toml index 8417c5b03c..aadece6153 100644 --- a/core_api_c_binding/Cargo.toml +++ b/core_api_c_binding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_core_api_c_binding" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/core_types/Cargo.toml b/core_types/Cargo.toml index 8d858b6bc7..5627bcee90 100644 --- a/core_types/Cargo.toml +++ b/core_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_core_types" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] build = "build.rs" diff --git a/core_types_derive/Cargo.toml b/core_types_derive/Cargo.toml index 02ad6486e8..3ba35d0958 100644 --- a/core_types_derive/Cargo.toml +++ b/core_types_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_core_types_derive" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/dna_c_binding/Cargo.toml b/dna_c_binding/Cargo.toml index 5324c1e11f..96c24a00fe 100644 --- a/dna_c_binding/Cargo.toml +++ b/dna_c_binding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_dna_c_binding" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/dpki/Cargo.toml b/dpki/Cargo.toml index c01f60b6b8..353d0920bb 100644 --- a/dpki/Cargo.toml +++ b/dpki/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_dpki" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/hdk-rust/Cargo.toml b/hdk-rust/Cargo.toml index afe4ad7b59..2fde06630a 100644 --- a/hdk-rust/Cargo.toml +++ b/hdk-rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hdk" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/hdk-rust/wasm-test/Cargo.toml b/hdk-rust/wasm-test/Cargo.toml index 1442a50c4b..748e118f90 100644 --- a/hdk-rust/wasm-test/Cargo.toml +++ b/hdk-rust/wasm-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-globals" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib] diff --git a/holonix/release/config.nix b/holonix/release/config.nix index 899a8c5e4f..13b93c94c1 100644 --- a/holonix/release/config.nix +++ b/holonix/release/config.nix @@ -3,22 +3,22 @@ let # the commit from `develop` branch that the release is targetting # the final release(s) will differ from this due to changelog updates etc. - commit = "aa38cb700e4262824669f9d9b64ab00c9321e4b5"; + commit = "04e4bbd8ea0dc187e0d4c0960ac32841a4493645"; # current documentation for the release process process-url = "https://hackmd.io/8kfuapVEQSuWSMiuI0LYhg"; core = { version = { - previous = "0.0.12-alpha1"; - current = "0.0.13-alpha1"; + previous = "0.0.13-alpha1"; + current = "0.0.14-alpha1"; }; }; node-conductor = { version = { - previous = "0.4.11-alpha1"; - current = "0.4.12-alpha1"; + previous = "0.4.12-alpha1"; + current = "0.4.13-alpha1"; }; }; diff --git a/holonix/release/pulse/config.nix b/holonix/release/pulse/config.nix index 0a6991ebe2..26273ad50f 100644 --- a/holonix/release/pulse/config.nix +++ b/holonix/release/pulse/config.nix @@ -3,9 +3,10 @@ let # the unique hash at the end of the medium post url # e.g. https://medium.com/@holochain/foos-and-bars-4867d777de94 # would be 4867d777de94 - url-hash = "14fc7dfeb6cd"; + url-hash = "f653f10a82d8"; # current dev-pulse iteration, as seen by general public - version = "26"; + version = "27"; + hash-list = "https://bit.ly/2LiQuJk"; }; derived = base // { diff --git a/holonix/release/src/audit.nix b/holonix/release/src/audit.nix index b526916261..d088935ea6 100644 --- a/holonix/release/src/audit.nix +++ b/holonix/release/src/audit.nix @@ -8,6 +8,12 @@ let script = pkgs.writeShellScriptBin name '' + echo + echo "Current git:" + echo + + git show --pretty=oneline + echo echo "All the important release vars:" echo diff --git a/net/Cargo.toml b/net/Cargo.toml index f2c841004a..dc0ef35c14 100644 --- a/net/Cargo.toml +++ b/net/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_net" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/nodejs_conductor/native/Cargo.toml b/nodejs_conductor/native/Cargo.toml index 08b2a64eca..ef46792abf 100644 --- a/nodejs_conductor/native/Cargo.toml +++ b/nodejs_conductor/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain-node" -version = "0.4.12-alpha1" +version = "0.4.13-alpha1" authors = ["Holochain Core Dev Team "] license = "MIT" build = "build.rs" diff --git a/nodejs_conductor/package.json b/nodejs_conductor/package.json index 0a41438260..b51b9707b1 100644 --- a/nodejs_conductor/package.json +++ b/nodejs_conductor/package.json @@ -1,6 +1,6 @@ { "name": "@holochain/holochain-nodejs", - "version": "0.4.12-alpha1", + "version": "0.4.13-alpha1", "description": "Nodejs Holochain Conductor primarily for test execution", "repository": { "type": "git", diff --git a/nodejs_waiter/Cargo.toml b/nodejs_waiter/Cargo.toml index 8d08c1644d..db877b294e 100644 --- a/nodejs_waiter/Cargo.toml +++ b/nodejs_waiter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_node_test_waiter" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/sodium/Cargo.toml b/sodium/Cargo.toml index 04cca37de2..e188431fc6 100644 --- a/sodium/Cargo.toml +++ b/sodium/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_sodium" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["neonphog ","zo-el"] edition = "2018" diff --git a/test_bin/Cargo.toml b/test_bin/Cargo.toml index 2c81cb8dfd..e84f8b5979 100644 --- a/test_bin/Cargo.toml +++ b/test_bin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_test_bin" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index e9b50f5757..455f79c659 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_utils" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] edition = "2018" diff --git a/wasm_utils/Cargo.toml b/wasm_utils/Cargo.toml index f7a4343c91..9b516ed95f 100644 --- a/wasm_utils/Cargo.toml +++ b/wasm_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holochain_wasm_utils" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [dependencies] diff --git a/wasm_utils/wasm-test/integration-test/Cargo.toml b/wasm_utils/wasm-test/integration-test/Cargo.toml index ca6687a9da..6440fd8fac 100644 --- a/wasm_utils/wasm-test/integration-test/Cargo.toml +++ b/wasm_utils/wasm-test/integration-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-integration-test" -version = "0.0.13-alpha1" +version = "0.0.14-alpha1" authors = ["Holochain Core Dev Team "] [lib]