How to build your own testnet and test the smt hardfork yourself
hive-139531·@howo·
0.000 HBDHow to build your own testnet and test the smt hardfork yourself
Hello, In the past weeks, there was a lot of times where the official testnet was down because the steemit team didn't want to put it back up until they fixed the issue that made it crash. Which is understandeable, but it slows down testing by quite a bit, same goes for getting actual testnet funds. Usually the testnet goes up and then we have to wait a few additionnal days to get funds to do actual testing. So I decided to build my own local testnet for those reasons, first to stop breaking the public testnet whenever I find something bad and second to test my own fixes. Like the one : https://github.com/steemit/steem/pull/3582 # How to setup a local testnet and test things on it I do my testing on ubuntu 19, but it's better to have ubuntu 18 as I'm forced to do some hacks to get it working. You need about 10gb of disk space, 8gb of ram and the faster/more core your cpu has, the better. If you are reading this in the future (in months/years), this doc may be more up to date : https://github.com/steemit/steem/blob/master/doc/building.md So first of all install all of the dependencies : ``` # Required packages sudo apt-get install -y \ autoconf \ automake \ cmake \ g++ \ git \ libbz2-dev \ libsnappy-dev \ libssl-dev \ libtool \ make \ pkg-config \ python3 \ python3-jinja2 \ doxygen # Boost packages (also required) sudo apt-get install -y \ libboost-chrono-dev \ libboost-context-dev \ libboost-coroutine-dev \ libboost-date-time-dev \ libboost-filesystem-dev \ libboost-iostreams-dev \ libboost-locale-dev \ libboost-program-options-dev \ libboost-serialization-dev \ libboost-signals-dev \ libboost-system-dev \ libboost-test-dev \ libboost-thread-dev # Optional packages (not required, but will make a nicer experience) sudo apt-get install -y \ libncurses5-dev \ libreadline-dev \ perl ``` # Get and build steem In this step we are checking out the master branch, but it may not be the correct branch to do testing, for instance the current "valid" branch for testing is `20200205-check-emission-accounts` if you don't know which one it is, ask around :) ``` git clone https://github.com/steemit/steem cd steem git checkout stable git submodule update --init --recursive mkdir build cd build ``` Then we call cmake to configure our build options to build a testnet instead of a main net ``` cmake -DENABLE_COVERAGE_TESTING=ON -DBUILD_STEEM_TESTNET=ON -DLOW_MEMORY_NODE=OFF -DCLEAR_VOTES=ON -DSKIP_BY_TX_ID=ON -DCHAINBASE_CHECK_LOCKING=OFF .. ``` And finally you can build steemd ``` make -j$(nproc) steemd ``` Some notes on `make -j$(nproc)` when I build with all of my cores, my computer tends to freeze and crash, so I would suggest trying out like this and then if you experience some bad freezes to reduce the number of core used. You can also build the cli wallet and the unit test util but that's optional: ``` make -j$(nproc) cli_wallet chain_test ``` Now you should be good to go to run and configure your testnet. ## Configuring and running your testnet Run for a few seconds and then exit steemd like so `./programs/steemd/steemd -d testnet/` You will see something like this ``` ------------------------------------------------------ STARTING TEST NETWORK ------------------------------------------------------ initminer public key: TST6LLegbAgLAy28EHrffBVuANFWcFgmqRMW13wBmTExqFE9SCkg4 initminer private key: 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n blockchain version: 0.23.0 ``` Save initminer's private key somewhere. Now, after running steemd, you should now have a `testnet` directory and in it what's interesting to us is the config.ini. You want to edit it and change these fields : ``` # Enable block production, even if the chain is stale. enable-stale-production = 1 # Percent of witnesses (0-99) that must be participating in order to produce blocks required-participation = 0 # name of witness controlled by this node (e.g. initwitness ) witness = "initminer" # WIF PRIVATE KEY to be used by one or more witnesses or miners private-key = 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n # Skip enforcing bandwidth restrictions. Default is true in favor of rc_plugin. witness-skip-enforce-bandwidth = 1 # Local http endpoint for webserver requests. webserver-http-endpoint = 127.0.0.1:8090 # Local websocket endpoint for webserver requests. webserver-ws-endpoint =127.0.0.1:8091 plugin = webserver p2p json_rpc witness account_by_key reputation market_history plugin = database_api account_by_key_api network_broadcast_api reputation_api market_history_api condenser_api block_api rc_api ``` And you're good to go, you should now have a full testnet node. Run steemd again and you should see something like this:  Congrats ! Your testnet is running :) # Actually using your testnet Now go up a bit in the logs to find the chain_id, it should be the very first thing you see : ``` $ ./programs/steemd/steemd -d testnet 1808419ms database.cpp:522 set_chain_id ] steem_chain_id: 18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e 1808419ms rc_plugin.cpp:1466 plugin_initialize ] Initializing resource credit plugin 1808424ms rc_plugin.cpp:1557 plugin_initialize ] RC's will be computed starting at block 1 ``` As you noticed we configured above the http endpoint to be 127.0.0.1:8090. Well now you can use your favorite library to interact with your local node. Here's a small code snippet using steem-js, note how I use my custom chain id and url: ``` var steem = require('steem'); steem.api.setOptions({url: 'http://127.0.0.1:8090', useAppbaseApi : true, address_prefix : 'TST', 'chain_id' : '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e'}); steem.api.getAccounts(['initminer'], function(err, response){ console.log(err, response); }); ``` You can also use the cli wallet to interact with it using the wss endpoint. Now that you are running things locally you can just make changes to the code, recompile and re-run the testnet to check your changes :) And if you feel that you have messed up a bit too much, just go to your testnet folder and erase the content of the blockchain folder. # Final thoughts and additionnal material You may want to test things on a testnet that is more akin to the main net (with all the data in it) and for that I recommend using tinman and gatling from @inertia https://github.com/steemit/tinman And it's guide : https://developers.steem.io/tutorials-recipes/setting-up-a-testnet
👍 scholaris, mustard-seed, alitavirgen, jaydih, kimseun, kanadaramagi123, loveecho, angelslake, wordit, sj-jeong, wondumyungga, aquawink, ringit, coreabeforekorea, talkative-bk, whatdidshewear, sjgod4018, ctime, funtraveller, revisesociology, gerber, daan, exyle, accelerator, cadawg, bestboom, dlike, triptolemus, permaculturedude, rycharde, blockbrothers, investprosper, techken, miti, smallpusher, laissez-faire, tarazkp, webdeals, bigbot, raiseup, jacuzzi, dalz, mehta, stupid, bdvoter, zaku, hafizullah, alamin33, hmetu, rem-steem, engrsayful, ritxi, msg768, jesus.christ, mcoinz79, howo, itchyfeetdonica, kimzwarch, archisteem-cn, russia-btc, kevinwong, magicmonk, lemouth, markkujantunen, feedmytwi, omstavan, steemfriends, unsw, unimelb, swiftcash, swiftbot, spurisna, tubcat, trafalgar, znnuksfe, raindrop, traf, wajahatsardar, shaka, ilyasismail, smon-joa, uwelang, vannour, obvious, tookta, hungryharish, rayshiuimages, plainoldme, holydog, wwwfernand, corsica, tresor, bert0, memeteca, ammar0344, flamingirl, mangou007, rokyupjung, funcounts, agromeror, jamzed, saqibnazir, milarose, chatitsimo, drsensor, thomasthewolf, tdogvoid, rosepac, borislavzlatanov, primeradue, joanawatts, inertia, jim888, imbritish, mdosev, jeffrey24864, msena, nathen007, gtg, techslut, didic, arcange, raphaelle, cardboard, cfminer, profitcheck, netuoso, jphamer1, espoem, mops2e, steempeak, sekhet, traciyork, remlaps-lite, danielsaori, watchlist, oaldamster, transisto, promobot, vndragon, hasenmann, paulo19750, fredrikaa, greenman, theycallmedan, briggsy, cesinfenianos, steem-star, arson-crew, etka, mes, jondoe, eremus, witcher73, dimarss, pastzam, schnauzerbigotes, leynedayana, kork75, sonder-an, giuatt07, britvr, osavi, davidesimoncini, davy73, aggroed, rombtc, konti, judasp, elmetro, blackpot, goumao, wf9877, geoffrey, holovision, mysteemit96, fedesox, jamesbattler, gandalfthewhite, shogo, christianytony, cunigarro, tamito0201, never-giveup, v4vapid, alauddinsee, kgbinternational, binkyprod, lecumberre, springlining, afukichi, jungch98, pedrohmc23, upvotenev, preparedwombat, cheema1, steemitboard, we-are, adityajainxds, mastersa, rofilm, oppongk, tsc, jeff-kubitz, thesuccess, jgvinstl, javirid, murathe, pathumnadeeshan, nacbotics, travoved, superhardness, foruni73, reverendrum, abdullahyusuf, blocktrades, bdmillergallery, steemitpatina, asgarth, boykeren, alexei83, francescomai, vcpandya, goldmann, santoninoatocha, toyo, andreasgrubhofer, blockchainstudio, spikykevin, steem-ambassador, starkerz, tj4real, dokter-purnama, khusairi, kamalkhann, yohan2on, steemit-uruguay, exhibition, milagros, leotrap, leyla5, sireh, herryazmi11, littledisciples, bait002, meemee, berniesanders, ngc, z8teyb289qav9z, sirvotesalot, abusereports, thecyclist, nextgencrypto, ozchartart, anarcotech, kesolink, zaibkang, nairadaddy, raymondbruce, kingsolo, kilianparadise, steemitcanarias, megaraz, jozef230, mariela53, faissalchahid, cauac, racibo, rocksg, enderrag, kinakomochi, steemit-jp, steemitbae, sumomo, fujisan, yusaku, jp-tiger, roelandp, blakemag, cloris, disguarpe, dylanhobalart, cpufronz, roman1973, valerious, rafpokmac, zdamna100egebio, seredina, izmy.steemit, netraleon, tigerz, karcher-310, darsn, zdamna100ogebio, biochem, probaperra, nervniymen, orange777, bonadicta, shaotech, jexus77, jarunik, nnippuzz, peeterxnjoroge, msp-foundation, holdonla, ausbitbank, radicalpears, ocdb, guchtere, postpromoter, smartsteem, rimicane, thevote, yougotavote, tombstone, lordjames, crystalhuman, elieserurabno, simply-happy, epicdice, boombastic, pairmike, drifter1, diana.catherine, gammagooblin, shadowspub, dexter-k, ansharphoto, shafay, nasgu, azzurra92, elevator09, sarasate, tyzzzz, federacion45, vannfrik, robi, bargolis, ribalinux, roomservice, costopher, sustainablyyours, idas4you, r3ap3r, arvindkumar, podnikatel, sunisa, therealwolf, szabolcs, upme, hannesl, globetrottergcc, sagarthukral, bebeomega, zainejj, smooms, zipsardinia, spiritualmax, smartmarket, errajesh, nedy, zelenicic, layra, kyuubi, spe3dy123, srijana-gurung, spreadfire1, minerthreat, mikemoi, stay4true, sky.nikolas20, mrnightmare89, xmrking, drinkyouroj, jcbit, drfk, steemjetmedia, colecornell, new-steemit, crypt0renegade, steemtank, wolfinator, andresurrego, elizabethharvey, steemdapps, aaronkroeblinger, insteem, lupo, kggymlife, kharma.scribbles, backtomining, vezo, paullifefit, riad1112, suzn.poudel, josepimpo, cryptonewz, puffi, vampire-steem, atta09, dobartim, mys, whd, imperfect-one, beleg, julian2013, archisteem, bernardr34, karinxxl, gecit, promo-mentors, mvd, dante31, futurethinker, ashleykalila, tpkidkai, osarueseosato, kanabeatz, elmundodexao, podanrj, luthfinanda, netaterra, stef1, dgbtech, monaposher, ped4enko, borodaus, bue, gulf41, firesteem, hilarymedina, gertu, sniper555, marcusantoniu26, htotoo, zord189, sam.hsuu, nanastraybutt, wanaf, mslily, notimetospace, shaunctanley, doeyorvine, devonibarton, nawaljoyne, seanrotbers, ynisrayax, haronclarkso, sianacroswer, kadensanto, tiannawalle, rosenorse, kylapettiy, erbertlucer, wyattburks, lianahayde, snehaschnei, stacyleigh, jaydanscotts, pazdelvillar, alessioalmon, findlayfleming, eoghangarz, lissiaqainwrig, rosebrewer, niyahvasqu, aherinederri, beckdowlin, liyahjohnso, mahaschne, maisiehobb, olafcohmid, corinechapma, leonapowel, cosmesende, lockroachs, kiterdonov, njordfranke, shanistonlu, phoenixmarqu, joycehinto, janacowan, feninferre, biepoort, bridgettbarry, mistycrote, reneegarza, brodiemackenzie, dadontex, verityedge, faithfrey, beulahnarkham, alimahviyrne, aileenrenes, acevedort, deanestelle, xaquinatela, damiansykes, nemorelles, tienneshelto, amritsamue, mollyriddlek, juliadavison, pseudolaria, gordondaean, feclantraver, cantonhugo, zacharygreig, haniyagrime, josienchelsea, eugenedray, iscillamaldona, melinekimef, siernichols, bertramlister, aydancoffey, ahmanonagha, vanesanewma, emmagerey, agdalenavasque, serapheimy, taniawhitehead, stellaconley, georgiebost, chanicelindsay, saideregan, jasmiivaad, kazuoporras, sicerarias, amandarpie, pohirriane, codieficken, promatet, gildadalet, maenbrigh, chayhaynes, sylviadonelly, leucomelas, gradyegilmour, hantelleyeaco, iviangardine, fabianhurst, shaydeme, chalfonts, anamwoodpock, jirachype, virgiepugh, kaiyasloa, guthrispaul, mitchgarhel, honormcarthur, saetanvigo, abbimaxwer, malitavit, zaydenrangelo, dallahamire, mirondagart, huntingfields, bertafreeman, monicahepar, celeomason, lillianetwillams, joshuherrera, noramatews, joycetreino, tyriquecal, vanesavelez, damonratliff, odupkuk, fizaballard, aneeseross, yishmeraye, matthewaylon, tanvirventura, beratallen, lendamolina, tinavorbet, krisarmos, boydemaguire, stipodcloudstar, maesweeney, kieranswney, tasnimmcgowan, nedydonovle, sethlamb, glysevami, larythisat, dushtyvysaa, thelmabouv, galeztortis, jesisdunlop, jolenebooks, ceavykullen, louisecampo, faithtorry, marisawyel, khadijagilber, organfeilki, ynisnixis, aphroditevlac, c0nnieblack, leterpener, nurerjeffery, dominickdorno, jaxsonclark, karolinatimmys, chelgarneter, qyrtilas, beatrixgibb, staciequinny, jimydomingu, karenherrera, lilahbartony, hatfieldarry, rahulstout, spearsavery, sibrandiva, assworname, rudimcintosh, mishadillia, mjovadalr, heartjean, boberpike, damonmagana, nicoblandr, arnarodger, tracikhavez, imaninae, gutobrayn, uisekavana, beverleygilliam, brodymayert, fredeliferu, zachariahkoch, rascalov, jennarook, clementaynard, elysebuckner, brunoherrin, rahamhollis, jibrilhenders, kaelanpetier, goroquiro, cohenromart, marcelselile, allyjearne, reevadickin, jamesriveran, jaynedayer, hutaamyshryr, ciprianasea, begrohqua, nariariojas, junaydhamer, harrycochrane, fucernas, daisyaewormal, chiloepoole, marirvine, alissiaselers, palmiraheloisa, osmokeith, dustinderric, wojciechnase, saharcorozco, hunterosuna, skalafell, ettamcpherson, parkernurph, raheemoyce, taephae, adeelfranks, hortenhenri, edwinblai, selinseay, edgarwilkes, inocente, asminewardel, ucianamcghe, robyndevlin, stevievance, dertelyert, celestestepeh, nykomi, cryptottech, bieitoabru, cashfraser, raidensreew, kittyamos, walidgraha, megnvatdarkstrid, athenamansell, riccardomack, miltonrodrip, eliquetyler, leonehouse, riannarodrigu, toddthompso, jaderosha, erchiecneil, janisdejesu, terryconno, sannairvine, zungkaleoflen, angelikacuevas, arjunstaffor, arnoudtapa, anikaybarton, pokevgeor, folajohns, taliyahleblan, joepcrython, garcozin, carlobrow, jacebarrera, ambattara, kilaylindsay, sabethourne, riquenoble, ivorpotter, qorealis, manrajmchee, kaifcoate, santizobruno, oliviaderjaro, gideepquinta, qliunesa, remihaines, meganhitehead, hantereden, goodmanwinifred, glysolaha, lesteryoder, heldreichiy, hugowatson, pliniostubbs, kathlenrellin, vickiebates, eshaneccon, zainesherma, williemacdonal, doloresinnek, hanaypatel, zeshanmurray, jamieweritt, efanihoward, afonzavesa, hanicevlark, irisellisont, nuharsharpe, chararisa, ayazgutierr, julachester, ekshayale, sanarleigh, hajrahkaur, boncimeong, lukasdaughert, aetasumber, preamoiz, abdullahreed, nadalandrys, isabellpark, ediedonnell, jaxsonweb, amandawolton, braissinas, haseebwel, finnianwan, ernestcampos, falezsoris, essingcorte, aryanolson, teviestace, lettemicholl, bernaldolema, adilynbaldame, benjamingriffin, shaashamene, ammadterir, pranatina, isellerobins, sahilerickson, zilantarab, gopinafalk, fisnicuviddr, ruficauds, aniyapitet, allamprosse, evangelineba, baharphoebe, marabeowes, loydknight, rufeytenily, sadevillarre, betonicifolia, vhesynorex, farhanarks, bethanyfarle, eliciatran, iranehogan, zunzaakzakram, faizhicksa, koritsambra, obgunwaeloj, walideloyd, pippagran, arleysamuel, pompadoras, hanleydodso, bibahelake, nidiacross, nikhilmcormick, flynnkeelin, ertrudeknot, danvirrood, rosengosod, aydenherad, maevemillar, josevillega, amberwesit, monstarestt, shakilredmond, ecoinbarber, jac0bcollins, vindermilley, arunmait, billetewing, lynchtavu, shanilake, miyamcfadde, harrislevin, daphnerave, edithestes, zurmueladel, rorymorrison, cordeliamorgan, eridanblogg, jaydnfraser, ibertyckee, aramparkins, saiahdave, sydneymayo, kokami, savannacha, sohirleads, euanfrye, gukundabrodb, henryrowle, eurydikest, tahnalfaro, norablanke, eloisasolom, betriadinox, goiovara, miaijavlaer, pasmerito, pipermetcalf, entoinerichard, calumguerra, keenanavar, ardisenjef, ryanhube, sophiebolto, rubencarrol, noreenmontoya, xorkozas, elinyoder, rosalesnathan, waqarknights, florencejenkin, ruthguerreror, hamadwhittington, gonguskarosa, uvviepastor, alexiatyle, rogamiyafa, tammyschwart, amanipeck, halemahaines, romanaleach, drewsratliff, reaganmajo, ronniemccann, deryebradley, steinborgta, hayaansouth, onyxtig, allanellirt, boryscotto, ribbyecnama, nataliacoraj, teraroiz, ristinaleo, hamedrowthe, killyhitmor, reliaconner, lorenafreeman, caldepodan, amirafloyd, votysiku, jillecarson, maddietanne, anenefoley, shirleyslate, jaxongrimes, lesterfeays, gobertohobs, oscadrades, malakaicarter, hauryadrak, blogfrdonate, renaepower, gusoneill, merinhendrick, rosalenlopez, gracereyesin, dorothyshah, tadeucea, carolesparz, jesdodjo, herecagehol, sarahblevins, ketimulas, uncanpaterso, aminahpatto, ranciscoholde, madinasoto, edmonpeggy, nancynoble, alfiecampbell, caremokeke, synisneth, akariakoum, cheyannewhit, prisenluxe, abbienstone, shoaibwalter, donnerandall, kaspercrane, zeynepsims, blairebouvet, caspianbrown, cherrydeaco, callamzamora, reemaportill, miahmoran, charlottekrist, kerifdianne, maiseykarris, desiresonal, grenitresnes, handleralby, merlintorres, olivierhaylo, dhysarrah, bakarsolis, nialilrlove, rayopetersen, angelinadurha, maretliyane, avarcrossle, tarfieldsomal, blaskeggsa, natemcarthur, tiyaphartley, tyronesbegum, aneurinharet, bastianadams, nishacain, lissiarodger, uvusinyvrash, yanswithae, ebengote, haroonbentler, maermajor, lisacarpente, curtisbyrd, neveworod, matildabalil, janisrogerer, kelliemikay, gadrian, atanas007, art-venture, myskye, dlstudios, randomeno, sultan-aceh, daniel-vs, abdex9, steeminer4up, bewarecenterbase, kuberman, steamsteem, selfvotejustice, accountsale, mansi94, meedo,