[Steem Smart Contracts] Dpos & Witness Testnet + Angular app πŸ’»

avatar

2 weeks ago @harpagon posted this Steem Smart Contracts: a few words regarding the consensus layer where he explained working on The Consensus Layer based on a DPoS system for Steem Smart Contracts (SSC) and looking for 5 interested people to participate in the Testnet.

I thought it was a great opportunity, because it's an interesting project that I think has potential. Moreover, having sometimes looked at some codes that he had already done, I quickly realized that he's far from being bad 🀣

comment: My @imtase account being more for travel posts I decided to use my tech account more adapted for this type of post πŸ˜‰


Personal_System_2_Series_of_Computers.png wikimedia

To tell you a little more about me, I am part of a time where you were proud to have an i386 SX 25 MHz, to finally get rid of your 30 3"1/2 floppy disks of Windows 3.1 for only one CD ROM, where you were looking forward to be the next month to have new computer magazines to read.... I have no complaints about my professional career in IT and was able to witness the birth of many things as the World Wide Web. I am in my 3rd year on Steem and I have expatriated to Thailand, for more than 6 years now, where I have my IT resource company next to a well known IT university where I take all my employees.

13732038_10154986937240744_6353821861784638921_o.jpg

29101867_10157190221375744_4105232172191842304_omin.jpg

29186174_10157190221370744_7672236003674816512_omin.jpg

53255389_10158235947065744_954259329928658944_o.jpg Bang Tao beach


Having kept all these years this same desire to learn, to see new things in a domain that I love, right after reading his post I therefore contacted him to tell him that it was OK for me to participate. Although, I know that witness on Steem is not the most popular thing among the Steemians (as proof, my 2 failed attempts to organize a #witnessweekend)

A few days later, he invited me on Discord on a channel created for the occasion where I was able to meet the other participants of the testnet. Namely @dlike @mcfarhat @wonsama @untersatz @beggars @happyberrysboy @cryptomancer, yes, I know, with me we are 8 and not 5 😁

Mastering the prerequisites (Linux server install, nodejs, mongoDB...), the implementation was quite fast. Especially since Harpagon did a very nice procedure to finalize the installation and start the Testnet.

For my part, I started with a standard configuration, a server that meets the prerequisites at OVH located in Germany in order to change from Asia, France or Canada for once. On it I put:

  • Ubuntu 18.04 Server + the packages I'm usually install (vim, lnav, fail2ban....)
  • nodejs v12.13.0
  • mongoDB v4.2.1
  • the branch of the git repository created for the purpose

And here we go!

An exciting adventure where we meet interesting people, help each other, see the project grow a little more each day with daily features...

Implementation of rounds:

  • 1 round = 21 slots
  • slots attribution:
    • the top 20 witnesses receive automatically a slot
    • 1 backup witness is randomly picked
    • once 21 witnesses have been found, they are randomly shuffled

Round.PNG

Implementation of round verification process:

  • the last witness of the round is in charge of verifying it

  • when all the blocks composing a round have been parsed from the Steem blockchain, the witness in charge of verifying the round sends what is called the "round hash" (it is a hash that "summarizes" all the hashes of the blocks) to the other witnesses that are part of the round in a P2P fashion

  • when 17 signatures are received, a custom_json including these signatures is broadcasted to the Steem blockchain, it is then caught by the nodes and run though a smart contract that verifies the signatures of the witnesses

  • the blocks that were part of the round are marked as "verified"

proposeRound.PNG

A project where everyone participates, which allows it to progress well and grow with the addition of new endpoints (such as server status), new data from witness server (versioning, last Steem block parsed, last block on the Sidechain...), and modifications (change in the management of server witness failures...).

Next to be added the witness awards, the witness that was in charge of verifying the round is rewarded for helping securing the network with ENG tokens (as stake).

As a consequence, this project gives me an excellent opportunity and motivation to deepen my knowledge of the Steem and Steem Smart Contracts environments and for that nothing better than a little development 😊


So I had fun making a little Angular 8 Web Progressive Application to monitor the witnesses server even I'm already very busy with my work.

Application architecture

I went to Angular, which I've been using for years, with no backend to avoid wasting time. All data will be stored either in IndexedDB or LocalStorage/SessionStorage.

Specific packages

To interact with the Steem blockchain and the Steem Smart Contract sidechain, I had to install some specific packages

Authentication

First of all, you need libraries to be able to authenticate with a Steem account. Either via browser extension or Oauth2

Login mix.png The application login page

Steem Keychain

For authentication with browser extension I started with the Steem Keychain package from @yabapmatt. The documentation is very useful, well done and I didn't have too many problems.

The only specificity being to have to use a setTimeout, the Windows object being returned too early when the application is initialized

steem-keychain.service.ts

/* Check Steem Keychain */
async _check() {
     const c = await this._checkSteemKeychain(450);
     if (c) {
          this.skcBoolean = true;
     }
}

/* Check if have Steem Keychain */ 
_checkSteemKeychain(ms){
     return new Promise(resolve => setTimeout(() => {
          if ((<any>window).steem_keychain) {
               resolve(true);
          } else {
               resolve(false);
          }
     }, ms));
}
Steem Connect

For the Oauth2 authentication I obviously went to Steem Connect from @fabien, making a Progressive Web Application to be used also via smartphone.

I have not yet implemented the functionality of the desktop version (browser extension) and only tested it but as Steem Keychain you have to use a setTimeout.

Off topic: By the way, speaking of Fabien it would be nice if you took the time to read his SteemDAO Proposal #37: SteemConnect continued improvements about Steemconnect, something that everyone uses and yet we can't say he gets a lot of support.

Screenshot from 20191117 184736.png

Query

Now that we have authentication we need the appropriate tools to query the chains

Steem Blockchain

At first I started on Steem.js from Steemit but from the first attempt to build in production environment I quickly gave up due to an error with the package cf. Github issue #465 that I opened. So I changed to dsteem which seems to be a good library.

Steem Smart Contracts Sidechain

For this library I didn't have to go far to look for it 🀣 I took sscjs from @harpagon. Same dsteem I didn't have any problems to use it.

The application

The purpose of the application is to:

  • Retrieve witnesses information every 5 minutes
  • Retrieve witnesses server status every 10 seconds
  • Retrieve round of witnesses every 6 seconds
  • Retrieve new block every 10 seconds
  • To be able to approve/disapprove a witness
  • To be able to enable a witness server

And this is what it looks like after a few hours of development. Starting with a little colorful log console (I let you appreciate the nice warning for the cookie ??? of steemitimages 🀣)

Screenshot from 20191117 183840.png

And the WITNESSES SERVER LIST

Screenshot from 20191117 184926.png

Screenshot from 20191117 185405.png

Screenshot from 20191117 185531.png


Next step, a dashboard for witness to monitor our owned server and blocks in more detail and why not, a dynamic geomap of where the blocks are produced. But it won't be until next weekend πŸ˜‰

divider-french-tech.png


If you liked this article
Feel free to let me know by
[ Upvote | Resteem | Comment ]
THANKS :)
@french-tech

divider-french-tech.png



0
0
0.000
5 comments