Angel \”Java\” Lopez on Blog

October 7, 2017

New Month’s Resolutions: October 2017

The end of new year is near. It’s time to write down my list of resolutions for a new month. Review of the previous month ones:

– Continue Yasold
– Continue BlockchainJ [complete] see repo
– Continue BlockchainSharp [complete] see repo
– Continue ChineseP [complete] see repo
– Continue TensorSharp [complete] see repo
– Continue SimpleTensor [complete] see repo
– Continue WikiExpert [pending]
– Continue Neurum [pending]
– Continue LLLJS [pending]
– Continue Elmie [pending]

Additionally, I worked on

– Improving RustScript [complete] see repo
– Improving BInte [complete] see repo
– Started simpleevm, Ethereum Virtual Machine in JavaScript [complete] see repo
– Improving SolidityCompiler [complete] see repo
– Writing EvmHook [complete] see repo
– Writing SimpleAbi [complete] see repo
– Improving RSharp [complete] see repo
– Improving EthSharp [complete] see repo
– Starting smartie, a new smart contract language compiler/transpiler [complete] see repo

My new resolutions are

– Continue smartie
– Continue simpleevm
– Continue BInte
– Continue Yasold
– Continue BlockchainJ
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue SimpleTensor
– Continue Elmie

Stay tuned!

Angel “Java” Lopez
https://github.com/ajlopez
http://www.ajlopez.com
https://twitter.com/ajlopez

September 24, 2017

Building A Blockchain (16)

Previous Post

In recent months I have been busy working on the RSK project. It’s time to write about my personal blockchain projects:

https://github.com/ajlopez/BlockchainSharp
https://github.com/ajlopez/SimpleBlockchain
https://github.com/ajlopez/RskSharp

Currently, the most active one is the C# project. I added one project:

https://github.com/ajlopez/BlockchainJ

in Java. The experience I gained written all this code (using test-driven design, as usual) gaves me a clear idea of what is involved when building a blockchain. Writing my own implementations gave me better understanding of the parts related to the creation of a blockchain. And now the RSK project (Java core implementation) is public, I’m free to relate this work with an existing full implementation.

The key points to be written are:

  • Entities
  • States
  • Virtual machine to run smart contracts
  • Encoders
  • Consensus
  • Validation logic
  • Inter-node communication
  • Expose node state to external applications

The base entities are:

  • Block
  • Transaction
  • Account

The states to be kept are:

  • Blockchain
  • Account state
  • Contract state

My projects are oriented to have smart contracts, a la Ethereum. One reason to have a virtual machine is be agnostic of host programming language. I think that having a way of run smart contract that is independent of the programming language used in each project, is an interesting feature. So, I should define:

  • Virtual machine opcodes
  • Transient (memory) storage
  • Persistent storage

I need encoders for blocks, transactions and account states. The encoded entities are used in the network communication, local storage, and in the hash calculation. For example, when I have to transmit a block I encoded it. And if I want to send the block to another node, I should encoded the block before transmission. And the encoded data is the basis for hash calculation.

The inter-node communication includes:

  • Message definitions
  • Message and handshake protocol
  • Peer-discovery protocol

Validation logic refers to:

  • Validation of blocks
  • Sign of transaction and its validation

Consensus logic has:

  • Selection of the next block
  • Run of the transactions, updating the accounts/contracts states

The exposure of a node state is implemented in Bitcoin and Ethereum using JSON RPC (Remote procudure call), usually exposed via http. In this way, the node can be accessed by external technologies implemented in different technologies (JavaScript blockchain ecosystems are the more popular).

Followin Ethereum ideas, one entity I implemented many times is a trie. I think my implementations are very simple and effective. I hope to be able to write in the next posts about those implementations.

Stay tuned!

Angel “Java” Lopez
https://github.com/ajlopez
http://www.ajlopez.com
http://twitter.com/ajlopez

 

 

 

September 6, 2017

New Month’s Resolutions: September 2017

Filed under: C Sharp, Java, JavaScript, NodeJs, Open Source Projects — ajlopez @ 5:25 pm

A lot of ideas and projects, and only one life. Time to review the last month’s resolutions:

– Continue Yasold [complete] see repo
– Continue SimpleBlockchain [pending]
– Continue BlockchainSharp [complete] see repo
– Continue ChineseP [complete] see repo
– Continue TensorSharp [complete] see repo
– Continue SimpleTensor [complete] see repo
– Continue WikiExpert [pending]
– Continue Neurum [complete] see repo
– Continue LLLJS [pending]
– Continue HuskyJS [pending]

Additionally I worked on:

– Started BlockchainJ [complete] see repo
– Improve RustScript [complete] see repo
– Start Elmie, Eml-like language transpiler to JavaScript [complete] see repo
– Improve PLangRe [complete] see repo
– Improve RSharp [complete] see repo
– Improve RskAPI [complete] see repo

My new resolutions:

– Continue Yasold
– Continue BlockchainJ
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue SimpleTensor
– Continue WikiExpert
– Continue Neurum
– Continue LLLJS
– Continue Elmie

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

 

August 8, 2017

New Month’s Resolutions: August 2017

Filed under: C Sharp, Haskell, JavaScript, Open Source Projects, Smart Contracts, Solidity — ajlopez @ 2:35 pm

It was a very busy and interesting month. It’s time for review my previous resolutions and write down the new ones.

– Continue RskSharp [pending]
– Continue SimpleBlockchain [pending]
– Continue BlockchainSharp [complete] see repo
– Continue ChineseP [complete] see repo
– Continue TensorSharp [complete] see repo
– Continue RSharp [pending]
– Continue WikiExpert [pending]
– Continue SimpleGA [pending]
– Continue Neurum [pending]
– Continue HuskyJS [complete] see repo

I also was working on:

– Minor improve in SimpleGrammar [complete] see repo
– Refactor in Complexo [complete] see repo
– Improve SharpGo [complete] see repo
– Start Yasold, Solidity decompiler [complete] see repo
– Improve Domie, simple DOM [complete] see repo
– Start BInte [complete] see repo
– Create BRati [complete] see repo
– Improve SparkSharp [complete] see repo
– Start Llljs, compiler of LLL to Ethereum VM bytecodes [complete] see repo
– Start Smarc, Smart Contracts in JavaScript [complete] see repo
– Improve SolidityCompiler [complete] see repo
– Start Smarc, Smart Contracts in JavaScript [complete] see repo
– Minor improve on Golin [complete] see repo
– Start SimpleTensor, TensorFlow ideas in JavaScript [complete] see repo

My new month’s resolutions:

– Continue Yasold
– Continue SimpleBlockchain
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue SimpleTensor
– Continue WikiExpert
– Continue Neurum
– Continue LLLJS
– Continue HuskyJS

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com

 

July 11, 2017

New Month’s Resolutions: July 2017

We are in the second part of the year, a long year with interesting projects. Time to write the new month’s resolutions and review the past ones:

– Continue RskSharp [pending]
– Continue SimpleBlockchain [pending]
– Continue BlockchainSharp [complete] see repo
– Continue ChineseP [complete] see repo
– Continue TensorSharp [pending]
– Continue RSharp [complete] see repo
– Experiments with RSKJ fork [complete] see repo
– Continue Vyu [pending]
– Continue Domie [complete] see repo
– Continue Wordie [pending]

Also, I was working on:

– Start WikiExpert [complete] see repo
– Start PerProm [complete] see repo
– Start RskApi [complete] see repo
– Improve SharpGo [complete] see repo
– Improve Neurum [complete] see repo
– Improve ClojJS [complete] see repo
– Improve SimpleScraper [complete] see repo
– New Sample in SimpleGA [complete] see repo
– Start GenPrj [complete] see repo
– Start RskUtils [complete] see repo
– Start SimpleJsonRpc [complete] see repo
– Start HuskyJS [complete] see repo
– Improve Husky [complete] see repo

My new month’s resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue RSharp
– Continue WikiExpert
– Continue SimpleGA
– Continue Neurum
– Continue HuskyJS

Stay tuned!

Angel “Java” Lopez*
http://www.ajlopez.com
http://twitter.com/ajlopez

 

 

 

 

June 11, 2017

Running an Ethereum/RSK Node

Filed under: Blockchain, Ethereum, Open Source Projects, RSK — ajlopez @ 2:43 pm

The RSK public testnet was launched, and the core source was opened. If don’t know what RSK is, please visit:

http://rsk.co/

Technically, it is a fork of Ethereum (Java source), with a 2-way peg with Bitcoin, and merge-mining capabilities. You can run your own node, alone, in your own network, or join it to the public testnet. There are instructions at thecore project github wiki:

https://github.com/rsksmart/rskj/wiki

In this post, I want to describe my usual workflow, to run experiments with RSK implementation and ideas (disclaimer:I’m a member of RSK development team, but this is a description of my personal experiments). First, you have to downloadthe source code from:

https://github.com/rsksmart/rskj

Currently, the most updated published version is at branch Ginger:

https://github.com/rsksmart/rskj/tree/ginger

Also, you can clone the repository into your own one. Once you have the source code, you can compile using IntelliJ  deaCommunity Edition, or use the command line:

.\gradlew build shadow -x testnet

(I’m usually work with Windows, in Linux, Mac, you must use the normal /). More details at:

https://github.com/rsksmart/rskj/wiki/Compile-and-run-a-RSK-node-locally

The shadow option is to build a jar with all the dependencies. The -x test skips the run of test from build step. The command generates a .jar file in one subdirectory. Then, you can execute

cd rskj-core\build\libs
java -Drsk.conf.file=<path> -cp rskj-core-0.2.0-GINGER-all.jar co.rsk.Start

What config file to use and to configure it? More info at:

https://github.com/rsksmart/rskj/wiki/How-to-initialize-RSK-node-configuration-file-settings

An initial config file at:

https://github.com/rsksmart/rskj/blob/master/rskj-core/src/main/resources/config/rsk-sample.conf

You must set a unique nodeId for your instance. You can generate a nodeId using the command line:

java -cp rskj-core-0.2.0-GINGER-all.jar co.rsk.GenNodeKeyId

It dumps a JSON file to console. You must copy the private key and the node id, to your config file:

# Private key of the peer
nodeId = 66cf57...
privateKey = 46f850...

You only need to copy the privateKey to run the node, but you can include the nodeId also for your own reference. The other line to configure is the coinbase secret:

# this string is computed
# to be eventually the address
# that get the miner reward
coinbase.secret = mytreasure

You must put an arbitrary string here.

To allow the CORS (Cross-Origin Resource Sharing) for your JSON RPC (Remote Procedure Call), set the cors property:

rpc {
    enabled = true		# you can disable rpc
    port = 4444
    
    cors = "*.rsk.co"    # you can put "localhost here"

The RPC capability is only used to query the node, and disabling it does not interfere with the normalwork of the node. How the node knows how to connect to the public Testnet? There is a list of bootstrap nodes:

peer {
	discovery = {
        # if peer discovery is off
        # the peer window will show
        # only what retrieved by active
        # peer [true/false]
        enabled = true

        # List of the peers to start
        # the search of the online peers
        # values: [ip:port]
        ip.list = [
            "bootstrap01.testnet.rsk.co:50505",
            "bootstrap02.testnet.rsk.co:50505",
            "bootstrap03.testnet.rsk.co:50505",
            "bootstrap04.testnet.rsk.co:50505"
        ]

to use in what is call the “peer discovery” process. You can disable them if you want only to use your own node in your network.

If you want to run MANY local nodes, you must have MANY configuration file. In these files, adjust also the properties:

    # Peer for server to listen for incoming connections
    # 50505 for testnet
    listen.port = 50505 # ie to 50506

and the already mentioned:

rpc {
    enabled = true
    port = 4444		# ie to 4445

Additionally, you can set your own network id, so your local o networked nodes only work for this network:

    # Network id
    networkId = 777  # ie to 42

You can also specify in each of your nodes the active nodes to connect, instead of using peer discovery and bootstrap public nodes:

    # Boot node list
    # Use to connect to specific nodes
    active = [    
        #{ 
        #    ip = 11.22.33.44
        #    port = 50505
        #    nodeId = e437a483...
        #}
    ]

As usual, you can set the machine name instead of IP number, using the same property ip.

If you want your node mine new blocks, change these properties to true:

# miner options
miner {
    server.enabled = false  # change to true
    client.enabled = false	# change to true

If you change only the server.enabled property to true, you can expose the new block to merge mining process, but this feature is beyond the scope of this post.

Any other question? You can visit the RSKJ gitter channel:

https://gitter.im/rsksmart/rskj

Enjoy!

RSK is hiring! Interested?

https://twitter.com/RSKsmart/status/872169805515718657

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

 

June 6, 2017

New Month’s Resolutions: June 2017

Filed under: C Sharp, Domie, JavaScript, NodeJs, Open Source Projects, Vyu, Wordie — ajlopez @ 11:17 am

A new month begins, time to write down the monthly resolutions. But first, a review of the past ones:

– Continue RskSharp [pending]
– Continue SimpleBlockchain [complete] see repo
– Continue BlockchainSharp [pending]
– Continue ChineseP [pending]
– Continue TensorSharp [pending
– Continue RSharp [complete] see repo

I also worked on:

– Improve AjDrawJS [complete] see repo
– Improve AjTalkJS [complete] see repo
– Improve SimpleForth [complete] see repo
– Improve ClojJS Clojure in JavaScript [complete] see repo
– Additional sample for SimpleGA, genetic algorithms [complete] see repo
– Experiments on RSKJ form [complete] see repo
– Create wordie, literate programming language [complete] see repo
– Create domie, a DOM-like for JavaScript testing [complete] see repo
– Create vyu, a vue.js-like framework [complete] see repo

My new resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue RSharp
– Experiments with RSKJ fork
– Continue Vyu
– Continue Domie
– Continue Wordie

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

May 24, 2017

Launch of RSK TestNet

Filed under: Blockchain, Open Source Projects, RSK — ajlopez @ 11:05 am

The project started on 2015. I’m a member of dev team since one year and two months. Past Monday, the RSK TestNet was presented to the public, after running for months in private mode. The announce was made in Consensus 2017:

http://www.coindesk.com/events/consensus-2017/
http://media.rsk.co/rsk-releases-ginger-the-open-source-public-testnet/

The intructions to participate in the TestNet:

https://github.com/rsksmart/rskj/wiki

The main open source code repo at:

https://github.com/rsksmart/rskj

You can check the TestNet status (some nodes) at:

http://stats.rsk.co/

The project is oriented to run an autonomous Ethereum network that allows the execution of smart contracts, using bitcoins to pay for the cost of running those contracts. There is a 2-way peg system to transfer from your BTC account to your own RSK account, and viceversa. The exchange is one to one. This is one of the pillars of the project: leverage Bitcoin network to use smart contracts. Another interesting pillar: RSK uses merge-mining, associated with miners that produces Proof of Work for RSK blocks using the PoW for BTC.

If the smart contract word is new to you, check the project:

https://www.ethereum.org/

I’m sharing resources and writing about blockchain (including code examples) in:

https://ajlopez.wordpress.com/category/blockchain/
https://ajlopez.wordpress.com/category/rsk/

I hope to write more posts describing the RSK project.

Nos leemos!

Angel "Java" Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

May 8, 2017

New Month’s Resolutions: May 2017

Filed under: AjTalk, Blockchain, C Sharp, Ethereum, JavaScript, NodeJs, Open Source Projects, RSK — ajlopez @ 11:51 am

There is a new month, time to write the new resolutions. First, a review of the previous ones:

– Continue RskSharp [complete] see repo
– Continue SimpleBlockchain [complete] see repo
– Continue Solidity Compiler [pending]
– Continue ChineseP [complete] see repo
– Continue TensorSharp [complete] see repo
– Continue RSharp [complete] see repo
– Continue SimpleForth [pending]

Additionally, I was working on:

– Continue BlockchainSharp [complete] see repo
– Start Neurum, neural networks in C# [complete] see repo
– Improve AjTalkJS, Smalltalk interpreter in JavaScript [complete] see repo
– Improve SimpleProlog, Prolog interpreter in JavaScript [complete] see repo
– Improve AjDrawJS [complete] see repo

New month’s resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue RSharp

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

March 7, 2017

New Month’s Resolutions: March 2017

Filed under: C Sharp, Erlang, Go, Haskell, JavaScript, NodeJs, Open Source Projects, Solidity — ajlopez @ 11:30 am

A new month begins, and it’s time to write down my new resolutions. First, a review of the February resolutions:

– Improve SharpGo [complete] see repo
– Improve BlockchainSharp [pending]
– Improve SimpleBlockchain [complete]
– Continue Solidity Compiler [complete] see repo
– Continue ChineseP [pending]
– Improve ErlSharp [complete] see repo

Additionally, I worked on:

– Start RskSharp [complete] see repo
– Start TensorSharp [complete] see repo
– Improve AjDrawJs [complete] see repo
– Improve SimpleForth [complete] see repo
– Improve CrysSharp [complete] see repo
– New Bitcoin example in SimpleGA [complete] see repo
– Improve Husky, my Haskell interpreter [complete] see repo
– Improve SimpleLisp [complete] see repo
– Improve CrysJS [complete] see repo

My new resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue Solidity Compiler
– Continue ChineseP
– Continue TensorSharp

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Older Posts »

Create a free website or blog at WordPress.com.