ā®ā®ā®Ā Today we will be looking at Stateless-Channels, as described within some of our research papers and Multi-Dimensional Token Pools in particular – from the userās perspective. This is the first article in the series of articles related to the subject. In a way material described here gets ahead of what had been documented in our official research publications. Nevertheless, it has been implemented, found its way into ā®ā®ā®GRIDNET OS already and does more than great! Some may compare Stateless-Channels to Lightning Network found within the Bitcoinās realm. Indeed, the comparison would be valid. Under the hood, implementation of State Less Blockchain channels is more āstreamlinedā than what can be seen within the Lightning Protocol.
We believe this leads to fewer constraints and more use-case flexibility. Not only do we allow for anonymized network, where data is onion routed, we also allow the network to span across web-browsers, giving users and developers access to an extremely convenient JavaScript API.
This could beĀ seen with the crypto-snake game where partiesĀ are rewarded without being previously known to any smart-contract and no a priori preparation needs to be take place before an unknown party begins receiving micro-payments.
Thatās a thing which is simply not possible within the Lightning Protocol.
The topicsĀ described in here have been covered partially already within theĀ Whitepaper.
In this article weĀ will approach things from a practical point of view whileĀ havingĀ access to theĀ ā®ā®ā®GRIDNET OS Decentralized Terminal Interface (DTI)Ā and handleĀ ā®ā®ā®Token mobile app. What a joy! ~The two seem to go along quite well,Ā donāt they? š
By reading on you will:
- get some hands-on experience with #GridScript basics
- you will get to know how to time-travel
- learn why on-the-chain transactions are not always good and the ā®ā®ā®GRIDNET OS solution
- get to know how the Snakeš game issues rewards
- how to cash-out rewards received within the game
- check for yourself if double-spends are possible š
- learn how to create and register Token Pools of your own
#GridScriptĀ definitely needs a documentation on its own. You will be glad to know that it is backwards compatible with Forth and there are a lot of places on the Internet to start from!Ā HereĀ may be a good place to get you started. #GridScript is backwards compatible, but it includes A LOT of new extensions, security mechanics, cryptography and decentralized consensus operandi. It includes support of runtime-metadata, type conversions, Java-like memory management, pay-per instruction mechanisms, decentralized applications support and so much more. From your current viewpoint it includes something as essential as in-line parameters which allows the entire #GridScript interpreter to be perceived as a command-line interface.
Indeed, everything you have ever typed so far onĀ ā®ā®ā®GRIDNET OS, all the Linux/Windows parametrised commands utilities- these are either direct low level native #GridSscript instructions or high-level utilities implemented using the former.
Basic Concepts
For the purposes of this Tutorial keep in mind the following simple concepts:
- Invocation ofĀ each instruction comes at a cost. Similarly like in Ethereum. The more resources (CPU/storage/memory) the instruction involves, the more costly it is. Each low-levelĀ #GridScriptĀ instruction has a cost associated.
- TheĀ ā®ā®ā®GRIDNET VM. Everything you type is done within aĀ ā®ā®ā® Virtual Machine. While you play Crypto snake, itās the ā®ā®ā®VM serving you each and every frame. Each time you connect either through SSH or accessĀ ā®ā®ā®DesktopĀ through web-browser, a fresh new instance is spawned for you and killed automatically once you are done or should the system detect any kind of abuse. Even theĀ ā®ā®ā®GRIDNET TokenĀ mobile spawns 1-2 VM instances as needed.
- The Sandbox Mode – whatās important to note about theĀ ā®ā®ā®GRIDNET VM? By default it operates within a Sandbox. A certain amount of assets is arranged for your connection and you are free to use these assets as you see fit. However, none of these operations would permanently affect the decentralized state-machine. Results of your instructions/commands/operations, asset transfers.. these would only live within the current state of your Sandbox.
Escape The Sandboxš«
Can we escape the current reality as we know it (while keeping āaliveā)šµāš«? At least for now we donāt know howš. Luckily for us we can escape theĀ ā®ā®ā®GRIDNET OSā SandboxĀ and have the results of computations affect the entire Decentralized State Machine thus at high redundancy and security.
How?
That is not overly difficult!š.
- Before executing instructions, use theĀ Begin TransactionĀ command (ābtā)
- When over, issueĀ Commit TransactionĀ (āctā)
- at any moment you may see the auto-generated transactionās source code by usingĀ View TransactionĀ (āvtā)
- even when using ā®ā®ā®GRIDNET Desktop, all your actions are translated into #GridScript under the hood by theĀ ā®ā®ā®GRIDNET OS JavaScript Context
Thatās it. Ā The system would then guide you through any questions if needed and present you with a QR Intent which you would scan with your mobile appš. Within the ā®ā®ā®GRIDNET Desktop graphical environment things will be even easier and definitely more pleasurable to look atĀ š
Letās now get into some more details.
Each instruction which affects the state of the ā®ā®ā®VM puts it into another āperspectiveā.Ā Perspective is the identifier of its state. State-Domains may exist in multiple perspectives at the same time, but only the most recent one is the effective one. All others are assumed to exist in the past.
How does one get to know the current perspective? easily. Simply type… āperspectiveā within the Decentralized Terminal Interface:
You may just think of it as the current perspective on things indeed.
You may choose to make your current ā®ā®ā®VM switch to any perspective from the past by using theĀ āsyncāĀ command.
HowĀ does oneĀ get perspectives from the past? For one let me go into my home Directory and execute theĀ āinfoāĀ command.
Here I can see that my State-Domain (i.e. account) is available in 10 perspectives. The last one at index 9 is the current perspective.
I can choose to time-travel all the way back to the first state. For this I type āsyncā followed by the perspective of my choice.
if I type ‘sync’ alone, the ā®ā®ā®VM will synchronize with the current state of the network i.e. with the most recent perspective.
LetĀ me see if it actually worked by checking the reported balance:
Certainly it worked! šAfter all, itās been conceived, researched and implemented by Wizardsš§. How could it notš.
As you may see above, the values are different. Itās like using a Time-Machine. Congratulations! Youāve just learned not only how to escape the Sandbox, youāve already learned how to teleport yourself back and forth in time! Can Ethereum do this? Donāt think so.. Letās keep going!
The story about Ethereum
Why is Ethereum being mentioned in here? Well, to get a better perspective on things in short. Folks behind Ether never managed to research and implement effective data pruning for their VM. Here such mechanics are integrated on day 1. Not only that, as youāve just seen, you may teleport yourself back and forth across states with ease.
Accessing previous state in Ethereum is impossible in short, from the perspective of a smart-contract.
Here are sample places where you may read up on these subjects:
- https://ethereum.stackexchange.com/questions/10534/do-the-ethereum-clients-store-historic-state-or-just-current-state
- https://ethereum.stackexchange.com/questions/47215/how-can-we-obtain-the-state-value-of-a-variable-from-previous-block-number-using
- https://ethereum.stackexchange.com/questions/29024/how-to-get-all-historic-changes-of-a-state-variable-in-a-smart-contract
Folks at Ether built up on Bitcoin.. well, weāve researched everything from the bottom up thereās not a single line in common with other projects. Weāve learned from the best and what youāre seeing right now is a true peace of Art. It isš.
State-Channels and Off The Chain Transactions
These are already described quite a lot within the White Paper as far as theory goes. Here we are about practice.
Whatās wrong with on-the-chain transactions? Is there anything wrong with these?
As you might know, decentralized state-machines, theyāve got a problem. They do not scale so well. If somebody is trying to sell you yet another decentralized computer, you might want to think twice. You need to be aware that both Bitcoin and Ethereum these are products. Somebody is trying to make money on. Either by being an owner or by trying to make returns from investments. Both of these are brands. Both can be assumed to be riding on the peoplesā lack of technical knowledge to some extent. Back when Ethereum was coming out, it caught many by surprise. It actually painted visions of a decentralized computer whereas theyāve ended up with a DOS-like code execution system nobody knows how to use. Sorry, thereās no decentralized computer from the perspective of a typical end-user as far as Ethereum goes. There never was to be. Donāt get me wrong. Folks at Ether, together with its mastermind, Vitalik, they did a lot. But all in all it can be said that just the Bitcoinsā programming language got replaced by a different one.
Letās get back to off-the chain and on-the-chain transactions.
Be it Bitcoin, Ethereum, or even ā®ā®ā®GRIDNET OS. Changes done to the decentralized system, they need to replicate across the network. Thus transactions no more are only financial transactionsĀ sensu stricto but are closer in their meaning within the data processing realm. They can represent arbitrary authenticated operations that are to be executed by nodes maintaining the system.
Now imagine millions of users use the platform simultaneously. What happens? It gets stuck. What if you were to reward for propagation of data packets of the entire Internet? Would it be possible? Well certainly not with the current blockchain systems.
Enter ā®ā®ā®GRIDNET OS which boards unique implementation of the researched by us State-Less Blockchain Channels, and the related Multi-Dimensional Token Pools.
Here we are after practice not science so lets stick to it.
The Snake Multiplayer Gameš
A tutorial describing how to play the game is availableĀ here.
Here we are after more technicalities, we will also get to see how to cash-out the received tokens. So that to receive the actual ā®ā®ā®GRIDNET Bacis Units (GBUs)
The game, when launched, tries to access a token pool which was made available by the full-nodeās Operator, the one the user is connected to.
For this to work, the operator has to do sacrifice a certain amount of assets. Those sacrificed assets were not ultimately lost, however. Those would be used to create an off-the-chain value store. The data store is represented on-the-chain by an innovative data structure nicknamed the Multi-Dimensional Token-Pool. The total cumulative value comprising the token pool is up to the value of the sacrificial transaction. Each Pool is comprised of (multiple) dimensions. You may think of each dimension as of a bank. Each such bank can be used to keep rewarding single, unique recipient. When rewarding from the given bank one keeps releasing new versions of a Transmission Token. The recipient may choose to cash-out the Transmission Token anytime but each such operations involves a fee, thus itās in the recipientās best interest to keep receiving updated versions off of Transmission Token as long as possible (until resources from a given dimension get depleted or once the recipient is not to receive additional rewards) and cash maximum value at a single processing fee.
Sounds reasonable? It isš.
So. For you to be able to receive rewards by playing the Crypto-Snakeš game, the Operator sacrificedĀ 10 MILLION GBUs. Now thatās a lotĀ š.
The Operator used the receipt of the sacrificial transaction to generate a Token-Pool. What are some of the important Token Pool details?
It would be best to take a look at help displayed by the Token-Pool generation utility:
- The value – this one is computed automatically for you. The token pool generation utility takes the receipt of a sacrificial transaction and looks it value up.
- The number of dimensions. – that parameter tells how many peers youāll be able to reward simultaneously.Ā The more dimensions the bigger the Token Poolās data structure and the more expensive it will be to deploy. From our research it turns out you should never be in need to use a token pool with more than 30-100 dimensions. Even when using things like a decentralized YouTube, we plan to deploy.
- Value of a single token – that also gets calculated for you automatically if you donāt provide. Itās the value of a single token within each of the dimensions. Note: value tokensĀ within each dimension are the same.
Letās go about generating a Token Pool of our own!
First I sacrifice 10000 GBUs. The QR will be shown I confirm on the mobile app.
Nice! The important thing to me is the Receipt. Iāll use it while generating the Token Pool.
Letās go about using the token-pool utility now.
Important: We are about to issue yet another transaction. Once containing a Multi-Dimensional Token Pool which will be generated by the mobile app.
Thus, we need to bing the ā®ā®ā®VM into the current state. Otherwise nonce value associated with your account as seen by your ā®ā®ā®VM, one used by the Transactionās Composer would be out of sync and the resulting transaction – rejected.Ā Use the āsyncā command now to synchronize with the network now.
Iāve synced and executed āgenpoolā just to see the help screen.
Time to begin formulating new transaction by executing the āBegin Transactionā command, i.e. ābtā.
and then executing the āgenpoolā command by providing it with the sacrificial transaction,meaning the Receipt of it.
Letās go! Youāll be notified that quite a big QR Intent is to be rendered within the Terminal. The system attempts to automatically detectĀ the size of your Terminal and warn you or even pauseĀ execution and wait for you to increase the Terminalās Width (by resizing its window) should ā®ā®ā®GRIDNET OS detect that the width is insufficient.
That’s quite a BIG QR Intent indeed. Rendered using UNICODE 1.1 characters from the DOS era. The technology never ceases to amaze us.
The mobile GRIDNE Token app seems to have no trouble scanning it as well.
Once scanned you’ll be shown with a mobile screen looking like one on an iPhone below:
The app says that you can SWIPE your finger for more. And it actually means it! Let us try shall weĀ š Simply swipe to the left on the upper bluish field.
What just happened? How does the app know.. how does it understand what Iām about to commit? š¤ÆĀ Well:
- the mobile app boards a #GridScript decompiler of its own
- in some cases the mobile app is required to perform computations on its own so it needs to understand perfectly well whatās being done and how the results of computations are about to be delivered to the network.
Here the app, being the only trusted device on the system as per our Security-Threat models, is asked by one of the full nodes to generate a Token Pool. See, the Token Pool couldnāt be generated by the full-node itself as the resulting data structure needs to contain a secret value which cannot be known to the full-node itself. See.. Wizardsš§š§āāļø really, really.. they took their work.. seriously. Theyāve saved upon nothing š
The description which you see is generated dynamically. Really. What youāre seeing is dynamically generated HTML and CSS representing the tasks to be executed by the mobile app. The app strives to provideĀ as accurate description as it possibly can. The cool thing about it is that the app can represent operations it has never been initially prepared for or operations that Wizardsš§š§āāļø havenāt initially envisioned.
If you’ve kept track ofĀ the ProjectĀ for some time already you know very well that the autonomous remote Log-Me-In functionality describedĀ hereĀ has been implemented and deployed without requiring any updates to the mobile app itself. It simply worked and provided custom, new messages within the mobile appās UI.
Let’s keep going and confirm actionsĀ within the mobile app. An onion routed connection to the very ā®ā®ā®VM hosting your SSH session would be initiated and established. The mobile app would keepĀ notifying you upon any changes to its status. Interestingly the app receives updates about both the network-layer connectivity, the decentralized state-machine operations, results of tasks related to the remote peer.. and a few othersš Quite smart it is, still everything is wrapped in a very minimalistic UI with all the details hidden away for your convenience.
If everything goes well, soonĀ enough youāll get to see confirmation within the SSH terminal that a Token Pool has been generated and delivered from the mobile app. The representation of the token Pool Delivered from the mobile app is ādisarmedā, meaning it does not contain the secret value but it is enough to be put into the decentralized state machineās storage and validate any consecutive token you might be issuing on its behalf later on.
An interesting thing to note: the ā®ā®ā®VM has already generated, fully autonomously, source code of a transaction whose instructions instruct the decentralized state machine to register the very token pool you mobile app has just delivered. How cool is that? How amazingly sophisticated. Let us keep going, shall we?
You may view the transactionās source code by using the previously mentioned āvtā instruction. There could be a very short friction as the source code is generated. The large portion of text is the base64 encoded Token Pool your mobile app has just provided.
As you may see the entire transaction is 5723 bytes in length.
Letās commit! Thereās nothing to wait for. Use Commit Transaction (āctā). The ā®ā®ā®VM would automatically calculate the costs based on the encountered transactions. All you need to do is accept the proposed valuesš.
The VM would now show yet another QR intent which asks for your permission to sign and broadcast the just generated transaction. Once you confirm the mobile app would sign it and then onion route it across the network (end-to-end encryption for anonymity at all times).
You are constantly being notified about results…
Presumably the transaction got published successfully and is now being processed by the decentralized network of full nodes.
At any point you may check status of the previous transaction by using the āgetresultā command. If you donāt provide parameter, it will check the result of the most recent transaction. You may, however, provide it with a custom receipt. The utility would contact the network and fetch result along with the stack-frame including meta-data should anything have gone wrong.
Luckily, everything went just fine. Like above you may CD into my directory i.e. use ācd /CodesInChaosā and then enter the TokenPools directory to see that the token pool under the name āsampleā indeed is there. What a joy! You may also use full path right away ex.Ā ācd /CodesInChaos/TokenPoolsā
āsampleā is just another file on theĀ GRIDNET OSā Decentralized File System. This very file is stored in theĀ GRIDNET OSEternal Storage,Ā meaning full redundancy at each and every full-node.
You may use Linux-style ālessā command to view its contents. You may want to use theĀ -tpĀ parameter so that the binary interpretation layer kicks in and the binary code is treated as a Token-Pool with all the fields depicted as in the picture above.
How to be using Tokens From a Token Pool will be a subject for another tutorial! Something is telling us youāll be getting to know how to use these from the GRIDNET Desktop Graphical User Interface very, very soonĀ š.
Cashing Out Of Tokens
So youāve played Crypto-Snake a lot and now you want to cash-out your rewards? Itāve very simple.
Say I had my current Snake Token equal to āCETH71fZGK8nc6yctJBjKTzy7cG92DSsRQhGA6aUzbP5uN82p4zY1VoWo3LLzz3PvQ9uH63zz5bGts3VaZ2myS6oKDadKKYeYi4HchcivMwcqHq799z9dqPnkXajfT1ā
Letās see what the xtt command shows when I try to cash it out in SandBox. We may use theĀ āxttāĀ command, as in the picture below.
so looks like I would get 10GBUs were I to wrap this code in BT <-> CT block and commit.
If I want more, I can play Crypto snake further by providing this token during game start
While playing, I gathered 2 bags of coins. The app provided me with a new token equal to:
racTiXpHsLyVTfBzNp43A4GK1Pyfmjy3GPFZL54MU3jtm9DX6cyx1DjUxbCy6rY2C9ZcYxYjnNpb6VFEb6fXeykxjq6Nui6tgoiAW6TLDpg122R99F6qv6W74CXSKriK
Let’s try to cash it out shall we !
Looking good! After collecting 2 more bags of coins in single-player I now have 30GBUs to cash out. Note that itās not really worthwhile for me to do so since the fees are higher than the rewards. Gotta play Snake some more!š.
Thank you for reading stay tuned!
This post has been written by CodesInChaos ~one of the Wizardsš§š§āāļø