Reghack “Down Under” event roundup

Reghack was a 3 day hackfest that ran in Melbourne, Australia https://reghack.org/

The problem statement asked:
Do you have an interest in helping solve regulatory issues in the Financial Services and the Energy Sector in Australia?
How do we use RegTech to make regulatory compliance a strategic advantage that’s a win for the regulator, market participants and the consumer?

The focus of the event was to try and invigorate local innovation in the energy & financial services sectors, by allowing people to come together and explore how Blockchain could be utilised in these areas. The event was the brainchild of Chami Akmeemana https://www.linkedin.com/in/chami1/ who is a director of ConsenSys, the largest Blockchain focused consulting company in the world. Chami came to Melbourne and asked for local community support to help him organise and run the event. I was lucky enough to be tapped by Chami and invited to assist. I helped out by providing sponsorship for the meals via Microsoft, and delivered training to help upskill the community beforehand (more about that below).

The event had around 90 participants, with many more volunteers on the day. In the end 14 teams pitched their ideas which ranged from energy trading systems, ways to authenticate documents, to ways to eliminate GST during B2B transactions.
A big thanks to Chami for organising it all, and to all the volunteers that helped make the event a resounding success.

20170512_204517

Note: The roundup of the teams pitches are at the bottom of this post.

Continue reading

How to install Truffle & TestRPC on Ubuntu or Windows 10 with “Windows subsystem for Linux”

I previously wrote how you can install Truffle & TestRPC on a windows machine, by using the Windows installers for Node & npm.

However I have found it is a much nicer experience to use the Windows Subsystem for Linux which provides a native Ubuntu shell with bash, which allows me to run all the Linux tools natively without issues. These install steps will work on an Ubuntu machine as well.

Prerequisite if running on Windows

  1. Enable Windows subsystem for Linux.
    Follow this short guide on how to enable it https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
    image
  2. After following the steps in the guide above. Simply start the Ubuntu bash shell
    image

 

Install steps

# Takes a clean Ubuntu image, up to being dev ready.
# install npm from official repo, as apt-get has a very old version of npm
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash –
sudo apt-get update -y && sudo apt-get upgrade -y

# install the basics
sudo apt-get install -y build-essential python nodejs

# upgrade npm before install tools
sudo npm install -g npm
sudo npm install -g ethereumjs-testrpc truffle

Additional things to do

Now that your machine has it installed, I recommend you follow my other guide to get Visual Studio code configured for Truffle development.

Ethereum DevOps with Truffle, TestRPC & Visual Studio Team Services

I have been working on automating the compilation and testing of Ethereum solidity contracts, via the use of Truffle. I’ve got the test results being published back into the portal, allowing me to see on each commit if my code still compiles and passes my tests.

image

I’m assuming you already have a Truffle project locally that you want to automate the continuous builds & testing on. Follow my tutorial on installing Truffle & TestRPC on Windows.

My final system will allow you to run “truffle test” locally to see standard test output, but will modify the test runner on the server to output it as JUnit format.

The Build system

The system uses the Visual Studio Team Services (VSTS) build engine to automate this. You can sign up for free, and get unlimited private Git repos.
You can have the code hosted on any Git provider. So either within VSTS itself, or GitHub, BitBucket, etc.

Prepare truffle.js

A pre-step is to define the  test section in the truffle.js file

mocha: {
reporter: “spec”,
reporterOptions: {
mochaFile: ‘junitresults.xml’
}
}

image

Create a build agent

VSTS does provide hosted build agents, which are generic and can build standard .Net projects, Xamarin, etc. But because we are going to use npm packages installed globally on the box to handle the Truffle builds

  • Create a new Windows VM (Can be your own hosted server, or Azure).
    e.g. Windows Server 2016 Datacentre edition on Azure
  • Install the VSTS build agent. Instructions at https://www.visualstudio.com/en-us/docs/build/admin/agents/v2-windows
    Note: DON’T select to run service as NT AUTHORITY\NETWORK, this will not work with TestRPC (needs to open ports).
    Run the service as another user, or NT AUTHORITY\SYSTEM
  • Install chocolatey
    https://chocolatey.org/install
  • Install these chocolatey packages
    • choco install git -y
    • choco install nodejs.install –
  • Install npm packages (make sure you open a new PowerShell window so that node is in your path)
    • npm install -g npm
    • npm install -g –production windows-build-tools
    • npm install -g ethereumjs-testrpc
    • npm install -g truffle
    • npm install -g mocha
    • npm install -g mocha-junit-reporter
  • Restart the build agent so that all new paths are working

Configure VSTS build

    • Create a new variable with the path to where the npm global path is, for the user you installed the npm packages on above
      variable name: npm.path
      variable value: path to npm packages e.g. C:\Users\<user>\AppData\Roaming\npm
      image
    • Add 7 PowerShell tasks, and configure them like this
      • Name: System version information
        Script:
        #Setting environment paths
        $ENV:Path = $ENV:Path + “;” + $env:npm_path
        npm config set prefix $env:npm_path    #only needs to be set once, will update for user
        #DEBUG
        #$env:path
        #npm list -g –depth=0
        #Display system information
        Write-Host “System version information”
        Write-Host -nonewline    “node version: ” ; node -v
        Write-Host -nonewline    “npm version: “; npm -v
        Write-Host -nonewline    “npm prefix: “;  npm prefix -g
        Write-Host -nonewline    “truffle: ” ;    truffle version
        image
    • Name: Config transform & test clean
      Script:
      # remove old test results
      rm .\junitresults.xml -ea SilentlyContinue
       

      # Modify the Truffle test runner to use the JUnit reporter
      Rename-Item .\truffle.js .\truffle_temp.js
      cat .\truffle_temp.js | % { $_ -replace ‘reporter: “spec”‘, ‘reporter: “mocha-junit-reporter”‘ } | Out-File -Encoding ASCII .\truffle.js
      rm .\truffle_temp.js
      image

    • Name: Truffle build
      Script:
      #Setting environment paths
      $ENV:Path = $ENV:Path + “;” + $env:npm_path
      #Truffle build
      truffle compile
      image
    • Name: Launch TestRPC
      Script:
      #Setting environment paths
      $ENV:Path = $ENV:Path + “;” + $env:npm_path
      # launch the process
      echo “launching TestRPC”
      $testrpcProcess = Start-Process testrpc -passthru
      # persist the PID to disk and display in logs
      $testrpcProcess.Id | Export-CliXml testrpcPID.xml
      cat testrpcPID.xml

      image

    • Name: Run Truffle tests
      Script:
      #Setting environment paths
      $ENV:Path = $ENV:Path + “;” + $env:npm_path
      # Run the tests
      truffle test
      image
    • Name: Shutdown TestRPC
      Other Settings: Enable “Always Run” (to make sure it is shutdown if there is an error)
      Script:
      #Setting environment paths
      $ENV:Path = $ENV:Path + “;” + $env:npm_path
      # retrieve the PID and kill the entire processs tree
      cat testrpcPID.xml
      $testrpcPID = Import-CliXml testrpcPID.xml
      taskkill /pid $testrpcPID /F /T
      image
  • Add a new Publish test result
    • Test Result Format: JUnit
      Test Result Files: junitresults.xml
      image

 

Future work

Things that I would like to add in the future:

  • Figure out how to automate this on a Linux build agent (VSTS supports both Windows & Linux based build agents)
  • Automate Release Management to run “truffle migrate” to push to a Bletchley test environment

Configuring Visual Studio code for Ethereum Blockchain development

Visual Studio code is a great tool for editing Solidity smart contracts, and is available on Windows, Mac & Linux. There is a great plugin that enables Syntax highlighting, snippets, and compiling of the current contract (if you aren’t using an external tool) https://github.com/juanfranblanco/vscode-solidity/

This configuration works really well with Truffle (as shown in the final screenshot). You can read how to install Truffle on Windows in my previous post https://davidburela.wordpress.com/2016/11/18/how-to-install-truffle-testrpc-on-windows-for-blockchain-development/

Step 1: Install Visual Studio code
https://code.visualstudio.com/

Easy option on Windows: Just install via https://chocolatey.org/ by using the command
choco install VisualstudioCode –y

Step 2: Install Visual Studio extensions
Go into the extensions section, then install these plugins:

  • solidity
  • Material Icon Theme

image

Step 3: Enable icon theme
File –> Preferences –> File Icon Themeimage

Final result: Sexy workspace
image

Analysing my progress and profitability in cryptocurrency mining

TL;DR I purchased some cryptocurrency mining power in the cloud. I found that SHA256 mining is not that great, but Ethereum mining is more profitable. I plan on investing in more mining power.
If you want to jump in right now here are my affiliate links: https://www.genesis-mining.com/  Affiliate code for discount ODVnHM

 

Outsourcing Cryptocurrency mining

Previously I blogged how to mine Bitcoin on Azure (and why it is a terrible idea). In it I concluded that CPU mining is terrible with the advent of cheap USB ASIC miners and that you are better off purchasing one of them rather than wasting cloud computing credits.

I did more research and discovered rather than purchasing hardware, and running them myself and paying for electricity, maintenance, etc. I could just purchase raw mining power in a specialised mining datacentre.

Where did I purchase from

I eventually decided to go with https://www.genesis-mining.com
I liked that sign up was simple, that you could allocate your mining power/payouts (see below) and most importantly that it had Ethereum miners (look out for future posts on Ethereum!).

What did I purchase

I decided up front to invest a bit over $100 in SHA256 & Ethereum mining and roughly distribute it between the 2:

SHA256       USD $70.81        0.15 TH/s        $0.45 per GH/s      Lifetime contract
Ethereum     USD $57.62        3 MH/s            $17.99 per MH/s    1 year contract

Distributing the mining power

The reason I liked Genesis Mining was how you could allocate your mining and payouts across the many altcoins. Below I’ve included screenshots of the payout screens and my configuration.

SHA256
The original Bitcoin hashing algorithm. Mining power is being added to this at a crazy rapid pace with ASIC manufacturers trying to cash in and mine as many Bitcoin as they can. Profitability of mining this will drop rapidly.
Here I allocated my payouts as 90% Bitcoin (as that was the point of the exercise) but then 10% into Dogecoin. Dogecoin was created as a “fun” cryptocurrency and the development community has fun with using it as tips throughout Reddit. I wanted a small trickle of this so that I could tip people.

image

X11
Built to be more ASIC resistant by incorporating 11 different hashing algorithms.
I haven’t purchased any mining power in this mining algorithm yet, but I plan to in the future.

SNAGHTML354ee67

Ethereum
Not much in the way of options, as it has been designed to be a unique ASIC resistant algorithm. This is just for Ethereum mining.

SNAGHTML33b8d45

 

Analysising the data

I’ve been mining for 9 days now and thought it would be a good time to analyse how my mining has been going.

Payouts occur at the same time every day, meaning my 1st day only saw a partial payout on the day I signed up. I have removed the datapoint to make the graphs clearer.
Exchange values used are from https://www.coingecko.com

Ethereum
The amount I’m mining each day has been trending very slightly downwards but is more or less stable.
Profitability/day: $2.77 / 9 days = $0.30/day

image

SHA256 Bitcoin
Fairly stable mining, but it is trending down sharper than Ethereum. This is most likely due to the rapid pace that additional mining capacity is brought on globally from all the ASIC miners
Profitability/day: $1.04 / 9 days = $0.11/day

image

SHA256 Dogecoin
A very sudden drop in Doge earned per day. This can be explained by looking at the exchange (see graphs below).
Dogecoin isn’t mined directly by Genesis mining, but instead Bitcoin is mined and then converted into Dogecoin. Over the last 3 days the price of BTC has gone down while DOGE has gone up, meaning during the daily conversion of earned BTC to DOGE the exchange rate is lower.
Profitability/day: $0.20 / 9 days = $0.02/day

image

Exchange rates for last 30 days

image

Profitability breakdown

Ethereum mining
1 year contact: $57.62
Daily profit: $0.30
Daily ROI: 0.30/57.62 =  0.0052
Yearly profit at current values^: $0.30 * 365 = $109.5

SHA256 mining
Lifetime contract: $70.81
Daily profit: $0.13 ($0.11 + $0.02)
Daily ROI: 70.81/0.13 =  0.0018
Yearly profit at current values^: $0.13 * 365 = $47.45

^I do not believe that this will be the true yearly values. Exchange rates will fluctuate and amount mined per day will go down.

I was interested in the SHA256 miners because of the lifetime contract that will always be mining until it is no longer profitable. However I am wary of the long term profitability of it. The chart below from blockchain.info shows the crazy rate that ASIC miners are are bringing on more hashing power. This will rapidly diminish the amount of BTC I mine per day. I do not plan to invest more in Bitcoin mining as I don’t think it will economical to compete.
image

 

Conclusion

I am very happy with the progress of my Ethereum miners. Ethereum is more resistant to ASIC miners and therefore the amount of global mining power brought should not reduce my profitability as much as quickly as it is with SHA256.
Ethereum mining is also almost 3x as profitable per $ as SHA256 mining (0.0052 vs 0.0018).

Because of this I plan on purchasing more Ethereum mining power as well as some X11 mining power. But I will not be investing any further in SHA256 mining.
I’d like to get some data points from the X11 miner to share next time.

 

Remember if you want to signup for your own, here are my affiliate links to get a discount
https://www.genesis-mining.com/  ODVnHM