<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dogus Ural on Medium]]></title>
        <description><![CDATA[Stories by Dogus Ural on Medium]]></description>
        <link>https://medium.com/@dogusural?source=rss-d9db61b7511e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-OhBGwrIHbQuIk7y.jpg</url>
            <title>Stories by Dogus Ural on Medium</title>
            <link>https://medium.com/@dogusural?source=rss-d9db61b7511e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 23:24:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dogusural/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Linux uzerinde AVA denali test nodunu acik tutma yontemleri]]></title>
            <link>https://medium.com/@dogusural/linux-uzerinde-ava-denali-test-nodunu-acik-tutma-yontemleri-c494b8925e00?source=rss-d9db61b7511e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c494b8925e00</guid>
            <category><![CDATA[systemd]]></category>
            <category><![CDATA[ava]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Dogus Ural]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 00:00:38 GMT</pubDate>
            <atom:updated>2020-06-02T00:00:38.080Z</atom:updated>
            <content:encoded><![CDATA[<h3>&amp; Kullanimi</h3><p>Sonuna ampersand ekleyip cagirdigimiz her program, arka plana atilip orada calismaya devam eder.</p><p>Şu şekılde cağırılınabilir :</p><p>./path/to/workspace/gecko-0.5.0/ava &amp;</p><p>Fakat kendisini cagiran terminal kapatildiginda o terminalin chld processi oldugundan child process olan ava da ölür bu sebeple tercıh edılmemelidir.</p><h4>Programın Çalışma Testi</h4><p>ps aux | grep ava</p><h4>Program Sonlandırılması</h4><ul><li>pkill -9 ava</li><li>killall ava</li></ul><p>Komutlarıyla sonlandırılabilir.</p><h3>nohup Kullanımı</h3><p>Ampersand’ın gelışmiş halidir. Bağlı olduğu terminal kapatılsa bile, hayatta kalmaya devam eder. Fakat sistem reset, program çökmesi gibi durumlarda programı tekrar ayağa kaldırmaz. Programın manuel olarak tekrar başlatılması gerekir.</p><p>Şu şekılde cağırılınabilir :</p><p>önce cd komutu ile ava programının olduğu klasöre gidin.</p><pre>nohup ./ava --public-ip `curl <a href="https://ipinfo.io/ip%60">https://ipinfo.io/ip`</a> &gt; ava.log &amp;</pre><p>Programın çıktısını, ava.log adlı dosyanın içine yazıyoruz. cat ava.log komutu ile loglara bakılıp, programın çalışıp çalışmadığı gözlenebilir.</p><h4>Programın Çalışma Testi</h4><p>ps aux | grep ava</p><h4>Program Sonlandırılması</h4><ul><li>pkill -9 ava</li><li>killall ava</li></ul><p>Komutlarıyla sonlandırılabilir.</p><h3>screen Kullanımı</h3><p>screen programları bağlı olduğu terminalden detach etmeye yarayan bır yazılımdır. Bu komutu kullanarak oluşturulan termınaller arka planda siz görmesenız de kendine bağlı programı çalıştırmaya devam eder.</p><p>screen --version komutu ile sıstemınızde halihazırda kurulu olup olmadığını kontrol edebilirsiniz. Eğer kurulu değilse :</p><p>sudo apt update</p><p>sudo apt install screen</p><p>Komutları ile kurulum yapılır, ardından cd komutu ile ava&#39;nın olduğu dizine gidilir.</p><p>screen -d -m ./ava komutu ile bağlı olduğunuz terminalden bağımsız olarak ava&#39;yı çalıştırabilirsiniz.</p><h4>Programın Çalışma Testi</h4><p>ps aux | grep ava</p><h4>Program Sonlandırılması</h4><ul><li>screen -list komutu ile tum screen ile oluşturulmuş terminallerı görebilirsiniz. Cıkan listeden sonlandırmak istediğiniz terminale screen -r &lt;TERMINAL_ID&gt; komutu ile bağlanıp , ctrl +d komutu ile terminalı ve bu terminale bağlı ava&#39;yı sonlandırabilirsiniz.</li><li>screen -list komutunun çıktısına örnek olarak :</li></ul><p>There is a screen on: 4188..dodo-server (06/01/2020 11:23:53 PM) (Detached)</p><p>screen -r 4188..dodo-server</p><p>ctrl+d</p><h3>Linux Service Kullanımı</h3><p>Daha önce verilen metodların aksine , systemd servisleri teknik aksaklık ve restartlar sonrasında dahi programın tekrar çalıştırılmasından sorumludurlar, kurulum biraz daha uzun sürse de node,un ayakta kalması için en zahmetsiz ve kesin çözümü bu yöntem sağlamaktadır.</p><p>Öncelikle service dosyamızı oluşturalım.</p><pre>sudo touch /etc/systemd/system/denali.service</pre><p>Ardından istediğiniz bir text editör ile bu dosyayı açıp içine aşağıdaki satırları girelim. Dosyanın sahibi root olduğu için text editoru sudo komutu ile çalıştırmayı unutmayalım.</p><pre>[Unit]<br>Description=Denali test node<br>After=network.target<br>StartLimitIntervalSec=0<br>[Service]<br>Type=simple<br>Restart=always<br>RestartSec=1<br>User=YOUR_USER_NAME<br>SyslogIdentifier=denali.service<br>ExecStart=/bin/sh -c &#39;exec /YOUR/AVA/PATH/gecko-0.5.0/ava --public-ip &quot;$(/usr/bin/curl https://ipinfo.io/ip)&quot;&#39;<br>​<br>[Install]<br>WantedBy=multi-user.target<br>​<br>[Install]<br>WantedBy=multi-user.target</pre><p>User alanının karşısındaki yere kendi kullanıcı adınızı , /YOUR/AVA/PATH/ yerıne de ava,nın yüklü olduğu dizinin tam adresini yazın.</p><p>Kullanıcı adınızı whoamikomutu ile öğrenebilirsiniz.</p><p>Dosyayı kayıt edip çıktıktan sonra , bu service’yi etkinleştirmemiz gerekiyor. Aşağıdaki komutlar ile önce çalıştırıp sonra da resetlerden sonra da aktif kalması için enable opsiyonunu çağıracağız.</p><p>sudo systemctl start denali.service sudo systemctl enable denali.service</p><h4>Programın Çalışma Testi</h4><p>sudo systemctl | grep denali komutu ile servisimizin etkinleştirilip etkinleştirilmediğini kontrol edebiliriz.</p><p>Eğer terminalde denali.servıce karşısındaloaded active running görüyorsanız servıs aktıfleştirilmiştir. Bundan sonra yapmanız gereken hiçbir şey yok zira ; denali.service program çalışmıyorsa çalıştıracak, herhangi bir sebepten ötürü durursa ise 1 sn sonra tekrar başlatacaktır.</p><p>ps aux | grep ava komutu ile programimiz çalışan processler arasinda mi kontrolü yapabiliriz.</p><h4>Program Sonlandırılması</h4><p>ava’yı durdursak bile service tekrar ayağa kaldıracağından önce service’yi devre dışı bırakmamız gerekiyor.</p><p>sudo systemctl stop denali.service sudo systemctl disable denali.service</p><p>Komutları ardından</p><ul><li>pkill -9 ava</li><li>killall ava</li></ul><p>komutları ile ava’yı durdurabiliriz.</p><p>Not : Tum islemler i5–4200U CPU @ 1.60GHz, 8 gb RAM , Ubuntu Server 20.04 ozellikli bir makinada yapilmistir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c494b8925e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to keep Denali node alive on Linux]]></title>
            <link>https://medium.com/@dogusural/how-to-keep-denali-node-alive-on-linux-c16d57e561ca?source=rss-d9db61b7511e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c16d57e561ca</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[systemd]]></category>
            <category><![CDATA[ava]]></category>
            <dc:creator><![CDATA[Dogus Ural]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 18:35:16 GMT</pubDate>
            <atom:updated>2020-06-02T17:13:53.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OgC7jnjdkiZ3M4qjvvEp2Q.png" /></figure><p>AVA team has released the final version of their ava node before the main net launch this summer. One of the requirements to participate and be rewarded in the incentivized test net is to maintain at least 50% percent up time which equals to 180 hours of up time for the next two weeks.</p><p>A healthy, robust network consists of highly operational nodes that are resistant to power shortages, system failures and software crashes. While we can not interfere with the first two requirements, there are a few options to take with regard to the third option.</p><p>Let’s start from the easiest but least robust solution and work our way through more resistant alternatives.</p><h3>Using ‘&amp;’</h3><p>Ampersand starts the process in the background and makes the current shell available to the user.</p><pre>./path/to/workspace/gecko-0.5.0/ava &amp;</pre><p>When parent process of the <em>ava binary</em> (which is the terminal that is being used) is terminated, it sends a SIGHUP signal to its child processes. This signal ends the child process, unless your shell is programmed to do otherwise. With default shell configuration ava node is alive as long as our terminal is up.</p><p>You can check if terminal is sending SIGHUP on exit with the command below:</p><pre>shopt | grep hupon</pre><p>if the output is huponexit off , <em>ava </em>won’t be terminated when the shell exits.</p><p><em>ava </em>process can be killed anytime, with the command below :</p><pre>kill -9 `pgrep ava`</pre><h3>Using nohup</h3><p>Nohup is the stronger version of the ampersand. Because it catches the SIGHUP and ignores it while ampersand does not.</p><p><strong>Note : </strong>As I was getting “NAT traversal has failed. If this node becomes a staker, it may lose its reward due to being unreachable.” error right after running the binary. I was advised on the official AVA Discord channel to use — public-ip x.x.x.x option. That indeed stopped the warning, so I will be using it in the coming examples.</p><p><em>ava </em>node can be run with nohup as following. Note that we redirect the stdout of the program to an arbitrary file called ava.log located in the directory where <em>ava </em>is.</p><pre>nohup ./ava --public-ip `curl https://ipinfo.io/ip` &gt; ava.log &amp;</pre><p>You can see the stdout of the ava node by observing the ava.log file as it is updated constantly.</p><p>You can kill the process, as described above :</p><pre>kill -9 `pgrep ava`</pre><h3>Using systemd</h3><p>As I have described how linux services are useful in my previous blog <a href="https://medium.com/@dogusural/writing-a-systemd-service-for-ava-testnet-on-ubuntu-cfa532cc38f4">post</a>, I will spare you the details and get right into the business. Needless to say this method persists after reboots, shutdowns, program crashes as it will be automatically run again.</p><p>Let’s create the service file with the <em>touch </em>command :</p><pre>sudo touch /etc/systemd/system/denali.service</pre><p>Then fill it with the following lines using any text editor.</p><pre>[Unit]<br>Description=Denali test node<br>After=network.target<br>StartLimitIntervalSec=0<br>[Service]<br>Type=simple<br>Restart=always<br>RestartSec=1<br>User=YOUR_USER_NAME<br>SyslogIdentifier=denali.service<br>ExecStart=/bin/sh -c &#39;exec /YOUR/AVA/PATH/gecko-0.5.0/ava --public-ip &quot;$(/usr/bin/curl <a href="https://ipinfo.io/ip">https://ipinfo.io/ip</a>)&quot;&#39;</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><p>Note that you have to change User field with your linux user . You can see which user you are logged as with whoami command.</p><p>And YOUR/AVA/PATH/ with the absolute path of your gecko-x.y.z folder.</p><p>Save and exit the file. Then start your service and enable it so that it persists after reboot.</p><pre>sudo systemctl start denali.service<br>sudo systemctl enable denali.service</pre><p>It will prompt you for your password for authentication. Enter it and you are done .</p><p>If you wish to stop the service from bringing the node up constantly , do the following :</p><pre>sudo systemctl stop denali.service<br>sudo systemctl disable denali.service</pre><h3>Testing</h3><p>Let’s test if the service is actually up.</p><p>sudo systemctl | grep denali</p><p>the output should look like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwE4TkQ9P8p7oyYS7TDVFQ.png" /></figure><p>Check if ava node is up with :</p><p>ps -aux | grep ava</p><p>You should see ava being highligted on the screen.</p><p>kill the process either with</p><pre>killall ava </pre><p>or</p><pre>kill -9 `pgrep ava`</pre><p>and observe it coming back online with a different <em>PID </em>using the ps -aux command.</p><p>You can check the logs your node is printing with</p><p>sudo journalctl -f command. Check the logs which are labelled as denali.service. journalctl will keep updating until you kill it with ctrl + c.</p><p><strong>Warning</strong></p><p>Currently by the time service starts running , network stack is still down. For that matter /usr/bin/curl <a href="https://ipinfo.io/ip">https://ipinfo.io/ip</a> return empty. I tried to make denali service depend on systemd-networkd-wait-online.service so that it would wait for the network to come online but dependency service didnt work properly on my machine and ended up giving up. You can either kill the ava node once after reset so that it starts with IP or leave it as it is since I am not even sure if — public-ip argument is needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c16d57e561ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Secure Elements]]></title>
            <link>https://blog.riddleandcode.com/introduction-to-secure-elements-9159d977b717?source=rss-d9db61b7511e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9159d977b717</guid>
            <category><![CDATA[secure-element]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[private-key]]></category>
            <category><![CDATA[cryptochips]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Dogus Ural]]></dc:creator>
            <pubDate>Tue, 26 May 2020 08:28:12 GMT</pubDate>
            <atom:updated>2020-05-29T12:21:21.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5od-TwIsCE0_TpF7fDc8IA.jpeg" /><figcaption>Secure Element — RIDDLE&amp;CODE</figcaption></figure><p>If you are into cryptography and cryptocurrencies, you have probably heard the saying that goes “not your keys, not your coins “. If an attacker gets hold of private keys just once, he basically has full control over your data, or in cryptocurrency context — your funds. Therefore, protecting keys is crucial.</p><p>As a rule of thumb, you should never keep your keys in the cloud, in a mail or your hard drive without encryption. This constraint already thins down the options for key storing to a few, including:</p><ul><li>Memorizing the whole key. Although it sweeps away most of the attack vectors, this is a bad approach for obvious reasons.</li><li>Writing down the phrase on a piece of paper and storing it in a secure place. The written form of secret must preferably be in mnemonic encoded format that is less prone to mistakes and typos. This method is best when used as a back-up mechanism with other digital methods, and expanded with QR codes, crypto-steel or even embedding secrets inside a picture.</li><li>Storing the keys inside an external HDD or SSD. This method is safe as long as data on the drive, and the USB communication is encrypted and protected with passwords.</li><li>Storing the secret on mcu flash after encrypting the data. This approach comes with another liability which is the storage of the master key that encrypts the other sensible data. One can always memorize a relatively short password, run it through a Key Derivation or hashing function and use it as the master key. Since the same input is provided, both of these hardening functions will result in the same output.</li></ul><p>Hardware security modules handle storing of sensitive data in an unorthodox way. Dedicated integrated circuits are designed for just one specific purpose — to enhance the overall security of the host system.<br>HSM consists of subsystems that are responsible for different operations, such as:</p><p><strong>Random Generator Hardware<br></strong>Having a true random generation function is crucial for key generation. With this function, the conditions to find the same number can’t be replayed. For example, if epoch time is used as a seed value for random generation, anybody could access the random value given the time of generation is known.<br>Secure elements come with uniform and independent random variable generator circuits embedded inside which can be used to create cryptographic keys of many kinds (ECC, RSA, Symmetric).</p><p><strong>Secure storage of the generated and installed keys<br></strong>If the secret is created on the device, it is hidden inside the EEPROM memory of the secure chip which makes it impossible to back-up the secret. If the secret has to be persistent for a long amount of time it can be generated and written on a paper wallet as described above, then it can be injected into the device. This approach is robust, as well as safe. Same EEPROM memory can also be used for general storage purposes.</p><p><strong>On chip signature generation<br></strong>Ownership of a private key can be forged inside specialized hardware through digital signatures. This is extremely useful in situations such as the creation of blockchain transactions or TLS certificates. The private key never leaves the silicon during operations that require the usage of private keys.</p><p><strong>Encryption and key derivation<br></strong>Just like digital signature generation, key derivation from a single seed (HKDF) or encryption can be done on chip. Once the symmetric key has been provisioned into the device, the rest of the cryptographic operations are done on chip.<br>After the provisioning phase, secrets never leave the device. Operations such as signing, verifying, encrypting, key derivation, certificate generation are done on chip. The output of these operations are fed back to the host mcu through the supported physical layer without exposing the secret key behind. Combining this with an encrypted physical layer creates a bulletproof solution.</p><h3>What is a Secure Element ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*24lX4aOSqaAjsmZvLX5MpQ.png" /><figcaption>Common crypto accelerator</figcaption></figure><p>The need for hardware level security is a rising trend since IoT has become a part of our lives. Specialized hardware and software enclaves carry the trust layer from user space to kernel level, creating an isolated and hard to tamper with environments for sensitive data operations. Since crypto-accelerator chips are specifically built for this type of operations, they are faster, more powerful and efficient than their software implementations. This fits perfectly into the IoT concept where devices are generally battery powered and not as performant as an x86 machine. Let’s explore the merits and risks of introducing a secure element to your system.</p><p>Secure elements are being used in various environments, such as:</p><ul><li>Hardware cryptocurrency wallets in generating and storing key pairs.</li><li>Payment systems like Chip and PIN cards for storage of secrets and on-chip cryptographic operations.</li><li>Integrity checks during boot loading to check if the software being loaded is the intended one through hashing functions and ECDSA (Secure Boot).</li><li>Authenticity checks with TLS handshake to only communicate with the intended host.</li></ul><p>Secure devices come with a general purpose microcontroller and a companion secure element chip equipped with a crypto-accelerator. These two are connected to each other mostly through i2c, SMBUS on the physical layer. T=1 or Smart card application protocol data unit (APDU) on the second layer.</p><p>In essence, a secure element is a black-box with a closed sourced software to protect the vendor IP and provide security through obscurity. It comes equipped with a crypto logic and sort of operating systems of their own, the middleware code which runs above the vendor specific operating system primitives and acts as an interface between the physical world and the secure element.</p><p>The system is as secure as its weakest link. If the channel between SE and the host mcu is not encrypted, this poses a huge security threat. This weakness can be leveraged against even with cheap hardware and unsophisticated methods, unlike side channel attacks.</p><p><strong>Cost of Extra Security<br></strong>Although secure elements may seem superior on many levels to the other methods, its superiority in functionality and extra security doesn’t come cheap. It exposes the system to a new spectrum of attack vectors such as side channel attacks which use the electromagnetic noises emitted by the device of extract sensitive data, physical attacks unless the chip is tamper proof, need for channel encryption that encrypts the communication layer between the secure element and the host-PC.</p><p>Some of these possible weaknesses can be overcome by efficiently using the provided vendor middleware while the rest has to be implemented as a feature by the vendor. Main HSM developers to choose from are NXP, (A71CH, se050), Microchip (atecc608a, atecc508), Optiga (Trust-X), Atmel. All exist with different features and varying software complexities.</p><p>Finally, here is a few caveats for users considering to deploy a hardware security module into their system:</p><ul><li>Closed source nature of secure elements is definitely a downside in today’s world of software where transparency and auditability are everything. This may raise concerns for possible intentional back doors or badly implemented software. This is why some wallets like Trezor use the encrypted storage of their mcu EEPROM rather than a dedicated hardware.</li><li>Secure element integration increases both hardware and software complexity leading to a less agile system.</li><li>Other shortcomings of the secure element that have been mentioned above can be only fixed on the vendor implementation side. This thins down the options for the developer.</li><li>Porting the secure element to a different architecture can be challenging especially in bare-metal environments.</li></ul><p>In the next article, we will delve more into the use cases of Secure Elements and show how RIDDLE&amp;CODE utilizes HSMs in the fintech, mobility and energy industries.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9159d977b717" width="1" height="1" alt=""><hr><p><a href="https://blog.riddleandcode.com/introduction-to-secure-elements-9159d977b717">Introduction to Secure Elements</a> was originally published in <a href="https://blog.riddleandcode.com/">Riddle&amp;Code Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a systemd service for AVA testnet on Ubuntu]]></title>
            <link>https://medium.com/@dogusural/writing-a-systemd-service-for-ava-testnet-on-ubuntu-cfa532cc38f4?source=rss-d9db61b7511e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfa532cc38f4</guid>
            <category><![CDATA[avalanche]]></category>
            <category><![CDATA[testnet]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[systemd]]></category>
            <dc:creator><![CDATA[Dogus Ural]]></dc:creator>
            <pubDate>Sat, 02 May 2020 01:35:08 GMT</pubDate>
            <atom:updated>2020-05-02T01:35:08.472Z</atom:updated>
            <content:encoded><![CDATA[<p>Long waited Avalanche test-net has arrived. There is nothing better than tinkering with the system to have deep understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*NgRcedj_RX0w7zsFKnpueg.png" /></figure><p>If you follow the instructions on the official ava <a href="https://docs.ava.network/v1.0/en/quickstart/ava-getting-started/">hub</a> you will have a working node in less than than 10 minutes. But running it once only solves half of the problems. To have a stable network for the developers &amp; testers there must be as much online nodes as possible. Network failures, reboots, crashes may happen and so there must be an automated way to make our process recover from any possible fail scenario.</p><p>This is where Linux services come into play, they are easy to write and deploy. The service that we are going to write tries to bring our process back to life as long as our OS is running.</p><p>If you did everything right, you should have an executable called <em>ava</em> under</p><pre>/src/github.com/ava-labs/gecko/build</pre><p>We will start with creating our service file under /etc/systemd/system</p><pre>sudo touch /etc/systemd/system/ava.service</pre><p>Open the file with your favourite text editor with sudo and add the following lines :</p><pre>[Unit]<br>Description=AVA test node<br>After=network.target<br>StartLimitIntervalSec=0<br>[Service]<br>Type=simple<br>WorkingDirectory=&lt;gecko_folder&gt;<br>Restart=always<br>RestartSec=1<br>User=&lt;your_user_name&gt;<br>ExecStart=&lt;your_ava_build_folder&gt;</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><p>Replace the User and ExecStart fields with your values.</p><p>To give an example: build folder and gecko folder on my Ubuntu Server machine is :</p><pre>ExecStart=/home/dodo/workspace/src/github.com/ava-labs/gecko/build/ava<br>WorkingDirectory=/home/dodo/workspace/src/github.com/ava-labs/gecko</pre><ul><li>RestartSec=1 , means the service will try to bring the process back alive every second when it is down.</li><li>StartLimitIntervalSec=0, makes sure service will try forever to make the process work. Normally if the process fails more than 5 times in 10 seconds. Service stops bothering.</li><li>WorkingDirectory , ava executable is expecting certificates and RSA keys to be under <em>…/src/github.com/ava-labs/gecko/keys</em> folder, relative to the gecko folder. When we are calling the <em>ava </em>executable with the absolute path, the keys folder name cant be resolved. So we set our process’s cwd to <em>gecko </em>folder. (I looked for a command line argument that may solve this to no avail)</li></ul><p>Run this commands to start automating your ava test node.</p><pre>systemctl start ava</pre><pre>systemctl enable ava</pre><p>If all is well , run the code below and you should see the ava service <em>active running</em> in the terminal</p><pre>systemctl | grep ava.service</pre><p>Make sure your node is online with</p><pre>ps aux | grep ava</pre><p>That is all folks, happy testing .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfa532cc38f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Makefile ve Komut Satırından Proje Derlemek]]></title>
            <link>https://medium.com/@dogusural/makefile-ve-komut-sat%C4%B1r%C4%B1ndan-proje-derlemek-199835207483?source=rss-d9db61b7511e------2</link>
            <guid isPermaLink="false">https://medium.com/p/199835207483</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[makefile]]></category>
            <dc:creator><![CDATA[Dogus Ural]]></dc:creator>
            <pubDate>Sun, 26 May 2019 21:29:36 GMT</pubDate>
            <atom:updated>2019-05-27T03:41:56.774Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong><em>Makefile &amp; Komut Satırı ile Proje Derlemek</em></strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*i5nq-Pdb1GOfB3J2f7Jzvg.jpeg" /></figure><p>Derlemek istediğiniz projeyi , komut satırından gcc / g++ yardımıyla ya da <strong>Make</strong> aracı yardımıyla binary ya da bir library haline dönüştürebilirsiniz. Makefile ‘ın komut satırıyla derleme yöntemine göre avantajlarını şu şekilde sıralayabiliriz.</p><ul><li>Elimizde farklı klasörlerdeki .h ve .c /cc /ccp dosyaları barındıran ya da dependency’leri olan bir projeyi her derlediğimizde, aynı komutları tekrardan yazmamak.</li><li>Uzun sürede derlenen bir proje’nin sadece değişen kısımlarını build etmek ve derleme süresinden tasarruf etmek.</li><li>Büyük projelerde gitgide artan dosyalar ve derleme ve linkleme opsiyonlarını kontrol edilebilir bir formatta tutmak.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*tbOWhTS3mdPtPF0jusrMIw.png" /><figcaption><strong>Proje Dosyası Tree Komutu Çıktısı</strong></figcaption></figure><p>Yukarıdaki dosya hiyerarşisine sahip proje, diğer kaynak dosyalarından deklare edilen fonksiyonları çağıran main.c, pthread callback’ini tanımlayan pThreadFuncs.c ve içerisinde sadece integer arttırımı fonksiyonu bulunan ops.c adlı üç tane kaynak dosyasından oluşmaktadır.</p><p>Proje Dosyalarına <a href="https://github.com/dogusural/MakefileTutorial"><strong>Github</strong></a> sayfamdan göz atabilirsiniz.</p><pre>CC = gcc</pre><pre>CFLAGS = -Wall -Werror</pre><pre>INC = -I./Inc</pre><pre>LIBS = -pthread</pre><pre>SOURCES =./Src/</pre><pre>BUILD_DIR =./build/</pre><pre>executable: $(BUILD_DIR)main.o $(BUILD_DIR)pThreadFuncs.o $(BUILD_DIR)ops.o</pre><pre>$(CC) $(INC) -o executable main.o ops.o pThreadFuncs.o $(LIBS)</pre><pre>mkdir -p build</pre><pre>mv *.o executable build/</pre><pre>$(BUILD_DIR)main.o: $(SOURCES)main.c</pre><pre>$(CC) $(INC) -c $(SOURCES)main.c</pre><pre>$(BUILD_DIR)pThreadFuncs.o: $(SOURCES)pThreadFuncs.c</pre><pre>$(CC) $(INC) -c $(SOURCES)pThreadFuncs.c</pre><pre>$(BUILD_DIR)ops.o: $(SOURCES)ops.c</pre><pre>$(CC) $(INC) -c $(SOURCES)ops.c</pre><pre>clean:</pre><pre>rm -Rf build/</pre><p>Yukarıdaki Makefile’da her bir source dosyasını, önce gcc’ye vereceğimiz -c opsiyonu ile object dosyası haline getiriyoruz( .o ), ardından gene gcc ile tüm bu object dosyalarını executable adındaki executable’a linkliyoruz. Yukarıdaki executable , main.o .. gibi gördüğünüz adlar Makefile için rule adları, iki noktadan sonra gelenler ise bu targetleri build etmeden önce nelerin build edilmesi gerektiğini bildiren dependency’lerdir.</p><p>Konsola <strong>make</strong> yazdığımızda en üst sıradaki rule olan executable çalışır. Onun çalışması için de dependency olarak girilen sırasıyla : main.o , pThreadFunction.o ve ops.o objeleri belirtilen kurallar eşliğinde build edilir. Gördüğünüz gibi makefile’da yukarıdan aşağı bir kod akışı yerine ,dependencyleri izleyen ve dependency sırasına göre zıplayan bir akış vardır.</p><p>Header dosyaları ile .c dosyaları aynı klasörde olmadığından gcc’ye header dosyalarını nerede bulabileceğini -I/&lt;path_to_headers&gt; opsiyonu ile sunuyoruz.</p><p>Eğer dışarıdan bir kütüphane kullanmak istesek kütüphanenin dosya sistemindeki lokasyonunu <strong>-L/&lt;path-to-libfoo.a&gt;</strong> komutuyla verip, kütüphaneyi de <strong>-l/foo</strong> opsiyonuyla: yani başındaki lib ön eki ve sonundaki statik ya da dinamik kütüphane olduğunu belirten, .so ya da .a ekini atıp kullanıyoruz. Aynı kütüphanenin hem dinamik hem de statik versiyonu aynı klasördeyse ; maalesef hangisine öncelik verileceğini seçemiyoruz. <strong>-L </strong>opsiyonu yerine . Komut satırından :</p><pre>export LIBRARY_PATH=$LIBRARY_PATH:/your/custom/path/</pre><p>komutu ile ya da .bashrc’ye aşağıdaki satırın eklenmesi ile de linkleyeceğiniz kütüphanelerin path’ini derleyiciye bildirebilirsiniz. export ile yapacağınız değişiklikler sadece kullandığınız shell prompt’da geçerli olacakken .bashrc de yapılan değişiklikler kalıcıdır.</p><p>bashrc. dosyasına eklenecek satır :</p><pre>LIBRARY_PATH=$LIBRARY_PATH:/your/custom/path/</pre><p>Örneğin libfoo.so’yu executable’mize linklemek istediğimizde yazacağımız makefile komutu :</p><pre>$(CC) $(INC) -o executable main.o ops.o pThreadFuncs.o $(LIBS) <br>-L./Lib -lfoo</pre><p>Genelde LIBRARY_PATH ile karıştırılan LD_LIBRARY_PATH ise executable’nin çalışması sırasında ihtiyaç duyduğu dinamik kütüphanelerin dinamik linker’a yerini bildirir. Bu değişkenin path’ini de export ile ya da <em>/etc/ld.so.conf.d/</em>.conf altına ekleyerek güncelleyebiliriz.</p><p>Şimdi aradaki farkı görmek açısından aynı işlemleri bir de komut satırından makefile olmaksızın yapalım :</p><pre>gcc -c Src/main.c -I./Inc </pre><pre>/* -c opsiyonuyla gcc’ye executable yerine object dosyası çıkarmasını ve gerekli header dosyalarını bulunduğumuz klasördeki Inc klasöründe bulabileceğini söyledik. */</pre><pre>gcc -c Src/pThreadFuncs.c -I./Inc</pre><pre>gcc -c Src/ops.c -I./Inc</pre><pre>gcc *.o -o executable -I./Inc -L./Lib -pthread -lfoo </pre><pre>/* Daha önce oluşturduğumuz tüm object dosyalarını executable adındaki binary dosyası altında linkle. Linkleyeceğin diğer external kütüphaneleri /Lib klasöründe bulabilirsin. Bu kütüphanelerin isimleri de libfoo.so ve libpthread.so’dur.*/</pre><pre>./executable</pre><p>Dikkatinizi çektiyse pthread kütüphanesini -lpthread yerine -pthread diye çağırdım. -lpthread sadece libpthread kütüphanesini linklerken -pthread bir takım define’lar ekler koda. Yani -pthread hem preprocessor hem de linker flagi eklerken, -lpthread sadece linkler. Kısacası -pthread kullanın.</p><p>Diğer ilginç nokta ise , printf fonksiyonunu kullanmak için eklediğimiz stdio.h header dosyasını ve printf fonksiyonunu çağırdığımız <strong>glibc </strong>‘yi executable’ımiza linklemedik. Bunun sebebi gcc’nin bu standart fonksiyonlar için önceden belirlenmiş search pathlere bakmasındandır.</p><p>printf () fonksiyonunun hangi kütüphaneyle linklendiğini görmek için aşağıdaki komutu çağıralım.</p><pre>$ ldd executable<br> <br> linux-vdso.so.1 (0x00007ffd3abe9000)<br> libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007faa72805000)<br> libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa7261b000)<br> /lib64/ld-linux-x86–64.so.2 (0x00007faa72844000)</pre><p>Biz explicit olarak linklemediğimiz halde, libc.so.6 soname’li kütüphane , binary’mize linklenmiş halde. Bunun sebebi standart kütüphanelerin yukarıda LIBRARY_PATH olarak ya da gcc ye verilen -L opsiyonu olarak verilen path’e default olarak eklenmiş olmasıdır. Aşağıdaki komutu çalıştırarak LIBRARY_PATH’da neler olduğunu görebilir ve libc-x.x.so kütüphanesinin bu path’de olduğunu doğrulayabilirsiniz.Ben, Ubuntu 18.04 sürümünde, /lib/x86_64-linux-gnu altında buldum kütüphaneyi.</p><pre>ld  — verbose | grep SEARCH_DIR  //Linker default arama pathlerini listele</pre><p>Aynı şekilde #include &lt;stdio.h &gt; ifadesinin de sorunsuz bir şekilde derlenmesinin sebebi : bu header’in bulunduğu path’in standart include path’e eklenmiş olmasındandır. Aşağıdaki komutu çalıştırıp bu pathleri görebilir ve stdio.h ve diğer standart kütüphane headerlarının bu pathlerde olup olmadığını kontrol edebilirsiniz. Benim sistemimde stdio.h, /usr/include altındadır.</p><pre>gcc -xc -E -v -</pre><p>Eğer projemizde dinamik bir kütüphane kullanmış olsaydık, yani executablemizi dinamik br kütüphane ile linklemiş olsaydık. Programı çalıştırdığımızda runtime linker’a bu dinamik kütüphaneleri nerede bulabileceğini söylemek zorundaydık. Tabii ki linklediğimiz kütüphaneler standart olduğundan LD_LIBRARY_PATH değişkeni bu standart kütüphanelerin pathlerine zaten sahip , standart olmayan kütüphane pathlerini de yukarıdaki bölümde anlatığımız gibi export ile ya da /etc altındaki config dosyalarını editleyip, ardından da aşağıdaki komut çalıştırılarak güncelleyebilirsiniz.</p><pre>sudo ldconfig -v</pre><p>Yukarıda adı geçen dinamik linker(runtime linker) projemize linklenmiş olarak <strong>/lib64/ld-linux-x86–64.so.2 </strong>adıyla görebiliriz.</p><p>Dinamik ve statik kütüphanelere daha detaylı değineceğim bir sonraki yazımda görüşmek üzere …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=199835207483" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>