<?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 Dustin Brickwood on Medium]]></title>
        <description><![CDATA[Stories by Dustin Brickwood on Medium]]></description>
        <link>https://medium.com/@dustinbrickwood204?source=rss-b1713d44c8c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UUrAo6MnRDu15R1OfSRpNQ.jpeg</url>
            <title>Stories by Dustin Brickwood on Medium</title>
            <link>https://medium.com/@dustinbrickwood204?source=rss-b1713d44c8c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:08:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dustinbrickwood204/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[Rise of the Chatbots in Customer Experience]]></title>
            <link>https://medium.com/master-of-code-global/rise-of-the-chatbots-in-customer-experience-df71ac04905d?source=rss-b1713d44c8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/df71ac04905d</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-chatbot]]></category>
            <category><![CDATA[conversational-commerce]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Dustin Brickwood]]></dc:creator>
            <pubDate>Thu, 11 Jul 2019 08:21:56 GMT</pubDate>
            <atom:updated>2019-07-11T08:37:24.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Rise of the Chatbots in Customer Experience" src="https://cdn-images-1.medium.com/max/1024/1*dpLiFjMfShkFNUrYMz2o6Q.png" /></figure><p>The year was 1966, the average cost of a new home in the US was around $14,200, Good Vibrations by The Beach Boys was playing on every radio and the first chatbot ever, ELIZA, was developed. Invented by prominent German Computer Scientist Joseph Weizenbaum, ELIZA’s inspiration derived from the 1950 “Computing Machinery and Intelligence” publication by mathematician, philosophist, and theoretical biologist Alan Turing. The publication defined machine intelligence as the ability to impersonate a human’s behavior such that the recipient is convinced they are interacting with another human. This instrument of measuring machine intelligence has stood the test of time and is still used today. Unlike ELIZA in 1966, modern machines are now passing the Turing Test that was created nearly 70 years ago.</p><blockquote>I propose to consider the question, ‘Can machines think?’</blockquote><blockquote>- <a href="https://en.wikipedia.org/wiki/Alan_Turing">Alan Turing</a></blockquote><figure><img alt="Chatbot ELIZA" src="https://cdn-images-1.medium.com/max/1024/1*wop1bfL8Scze2mL5_JC62Q.png" /></figure><p>The rise of machine intelligence has brought the rise of chatbots, and as advancements in artificial intelligence and <a href="https://medium.com/@ODSC/an-introduction-to-natural-language-processing-nlp-8e476d9f5f59">Natural Language Processing</a> continues, the more difficult it will be to distinguish human from machine. The aim of this article is to provide readers with a general understanding of chatbots, what they are, their growing popularity, how they are typically built and their value proposition for enterprise organizations.</p><h3>So what are they?</h3><p>Chatbots are a computer program that impersonates human conversation in its natural format. They are able to communicate using sophisticated artificial intelligence techniques, such as Natural Language Processing, through text or voice interfaces. During the lifespan of the bot, it will learn from previous interactions and will incrementally become more intelligent. Gradually understanding nuances in text or speech and handling more complexity throughout the conversation.</p><p>It’s not surprising that big businesses are looking to reap the benefits of these intelligent machines and with increased interest follows improved performance. Gartner, the research and advisory company predicts by 2020 the average person will have more chatbot conversation day with a bot than they do with their spouse. Enterprises understand the benefits and advantages that chatbots can bring not only to their bottom-line but more importantly to their customers.</p><p>Gartner, the research and advisory company predicts by 2020 the average person will have more chatbot conversationa day with a bot than they do with their spouse.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FD7gZF6jusIo%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DD7gZF6jusIo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FD7gZF6jusIo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb5f32275a95538ec03804842ec7dc93/href">https://medium.com/media/eb5f32275a95538ec03804842ec7dc93/href</a></iframe><blockquote><em>Read also: </em><a href="https://masterofcode.com/blog/customer-service"><em>Customer Service. What Can Bots Actually Do?</em></a></blockquote><h3><strong>Value Proposition of Chatbots</strong></h3><p>It is important to understand that chatbots are being developed to complement and support humans, not replace them. The benefits of chatbots for enterprises are abundant but will never substitute human ingenuity and their passion. Below are a few use cases that highlight the potential for chatbots to drive customer satisfaction and sales.</p><h4><strong>24x7 Availability</strong></h4><p>Computer programs do not require sleep and do not mind working 24 hours, 7 days a week for below minimum wage…and people believe they’re smarter than humans. Customers now expect service at any time of day or night, they want their questions answered or their feedback heard. Chatbots are being deployed to assist with this change in consumer expectations by providing an outlet for customers to engage and be serviced outside of business hours. Customers can now have their frequently asked questions answered, information requests delivered and brands can continue to provide exceptional customer service through automation, minimizing costs.</p><figure><img alt="Bots are available 24 hours a day" src="https://cdn-images-1.medium.com/max/1024/1*hSi5KU17dvFfgOpbne0PBQ.png" /></figure><h4><strong>Personalized Experience</strong></h4><p>Conversing with someone who already knows your name, interaction history, and your product preferences will almost always deliver a better experience than interacting with someone who will repetitively ask for that same information. Chatbots have the capacity to integrate with customer relationship management systems (CRMs) and inventory management systems (IMS) to provide a heightened customer experience that is more efficient and engaging. Want to know when the new Google Home Hub becomes available in your city? A quick message to the Best Buy chatbot would respond with the correct information instantly. It even has the ability to ask you if you would like to pre-order the device, or browse a similar product instead. No longer are customers willing to look up a phone number, dial the number, go through pre-set menu options only to be told to stay on the phone while we transfer you to an available agent…cue instrumental music…and then to be put back on hold while the agent looks up that information for you.</p><figure><img alt="Personalized Customer Experience" src="https://cdn-images-1.medium.com/max/1024/1*jlj0Sak_rDOxNXgFK6THhw.png" /></figure><h4><strong>Analytics</strong></h4><p>Data is without a doubt the new oil and the more data you have, the better decision you can make. There is something inherently special about raw customer data, yet capturing the sentiment, range, and needs of a business’s customer base is challenging. Often businesses capture this type of data through surveys, complaint/feedback systems, or transcribed call recordings. Whereas transactional data is easy to capture, and although it can provide insights it cannot provide a 360 degree view of the customer. Using a chatbot enables the capturing of qualitative customer data that can be used to improve business processes, customer satisfaction or product selection. Every conversation is analyzed, comprehending the pain points of each customer and becoming increasingly aware of your customer’s true needs. With consumer demands evolving faster than ever, having real-time conversational (AI) data can ensure businesses are evolving with the customer faster, and allow strategies to be developed that follows the latest consumer trends.</p><h3><strong>How are these bots developed?</strong></h3><p>Chatbot development is primarily comprised of a channel interface, a Natural Language Understanding (NLU) or Natural Language Processing (NLP) engine, a bot platform that may allow 3rd party integrations, and a little creativity.</p><h4><strong>Channel Interfaces</strong></h4><p>A channel interface is simply the way in which users will interact with the bot, whether it’s through Facebook Messenger, SMS, website widgets, Slack or WhatsApp. Today, these channels are exploding with branded chatbots. With Messenger being used by over 1 billion users, it’s no surprise that there are over <a href="https://newsroom.fb.com/news/2018/05/f8-2018-new-tools-for-businesses-and-people-to-deepen-connections-in-messenger/">300,000 bots on the platform</a> serving customers every day.</p><figure><img alt="Chatbot Channels" src="https://cdn-images-1.medium.com/max/1024/1*3dv8qit9kq1x4bzna87e6w.png" /></figure><h4><strong>NLU/NLP Engines</strong></h4><p>This is the intelligence component of the chatbot. The advancements in artificial intelligence and research into varying techniques focused on natural language understanding/processing have been the driving force for the adoption of chatbots. The basic concept of these engines is that they have the ability to parse text or speech into structured data that can be used for further actions. Although there are many different implementations of NLU/NLP engines available, we will focus on intent classification machine learning which involves training the bot to understand intents by attributing them with multiple keywords and phrases that users are expected to input into the chatbot. The more the model is trained, the more it understands patterns and learns from them. It’s important to understand how these systems make sense of this data in order to develop a chatbot that correctly answers and guides users through its experience.</p><h4>Intents</h4><p>An intent is a specific action that a user can invoke or the user’s intention. An example of intent would be if a user types “show me yesterday’s financial news”, the user’s intent is to see a list of financial headlines from yesterday. In development, intents are given names, often a verb or a noun, for this particular case it could be “showNews”. Further, we would define a list of utterances or keywords that would be attached to the relevant intent. For instance, under our “showNews” intent we could have the following utterances:</p><ul><li>“Show me yesterday’s financial news”</li><li>“What’s happening in the financial news”</li><li>“Tell me some news about finance”</li></ul><p>When the engine parses the user’s text and detects words associated with the above utterances or training phrases, it will match it to the “showNews” intent and proceed with an action. The action could be to retrieve a list of financial headlines from a backend service and display that information to the user in a list or gallery format for their review. In the case where the intent is not matched, we would provide a fallback intent, or also called a default bot response that would be triggered and inform the user that their message was not understood.</p><h4>Entities</h4><p>Entities are properties that assist NLU/NLP engines in identifying and extracting meaningful data from natural language inputs, this can consist of a name, location or date. When the engine parses the user requests and identifies an entity, that value can then be used within the following request. For instance, if a user inputted “Show me yesterday’s financial news”, the word yesterday and financial would be considered entities. When we make a request to retrieve news to send back to the user we will utilize these values to query news headlines that are from yesterday and considered financial related.</p><figure><img alt="Artificial conversational entities" src="https://cdn-images-1.medium.com/max/1024/1*__e_fFTP8deAwb3SuPbfjA.png" /></figure><p>The world of AI and machine learning can be a very complex place but the above concepts are an integral part in intent-classification based engines. Luckily for developers and businesses alike, there are a number of platforms dedicated to abstracting the difficulty of setting up these models. Below are some of the markets largest NLP players:</p><ul><li>Dialogflow (Google)</li><li>LUIS (Microsoft)</li><li>Wit.ai (Facebook)</li><li>Amazon Lex</li><li>RASA (Open Source 🤙)</li></ul><h4>Integrations</h4><p>A bot’s capabilities can be extended using third-party API’s which can be integrated into the bot. When the NLU/NLP engine has determined the user’s intent, the next step would be to request that information from some source and send it back to the user to fulfill their request. There are a tremendous amount of possibilities of what information or action you could provide to your users. If we want to create a weather bot that responds to weather and forecast related requests developers can simply leverage an existing weather API, or maybe we want to schedule an appointment using the Google Calendar API. The possibilities are only limited by imagination.</p><figure><img alt="Natural Language Processing Engine (NLP) for Chatbots" src="https://cdn-images-1.medium.com/max/1024/1*-uEQN9nx5_di7udz3JlVng.png" /></figure><h4><strong>Conclusion</strong></h4><p>The chatbot space continues to evolve and with businesses increasingly allocating resources to chatbot development it’s only a matter of time before each chatbot developed will be able to pass the Turing Test. It is the relentless pursuit to provide superior customer service to demanding consumers where chatbots will be most commonly utilized. However, the possibilities are endless and the agony of being stuck on hold with instrumental music is nearing its extinction.</p><blockquote><em>Originally published at </em><a href="https://masterofcode.com/blog/rise-of-the-chatbots-in-customer-experience"><em>Master of Code Global</em></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df71ac04905d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/master-of-code-global/rise-of-the-chatbots-in-customer-experience-df71ac04905d">Rise of the Chatbots in Customer Experience</a> was originally published in <a href="https://medium.com/master-of-code-global">The AI Playbook: Strategies &amp; Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Trie Databases in Ethereum]]></title>
            <link>https://medium.com/shyft-network/understanding-trie-databases-in-ethereum-9f03d2c3325d?source=rss-b1713d44c8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f03d2c3325d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dustin Brickwood]]></dc:creator>
            <pubDate>Thu, 02 Aug 2018 17:24:40 GMT</pubDate>
            <atom:updated>2019-03-05T04:33:37.646Z</atom:updated>
            <content:encoded><![CDATA[<h4>Trust me, this will be fun and informative :)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bf4rl9O12e5Yd_dqX7gfg.png" /></figure><p><strong>Prelude:</strong></p><p><em>The following is my interpretation of trie database structures and their implementation within the Ethereum network. I’ve also included a glossary of keywords used throughout the article. Enjoy!</em></p><p>Hello, avid learners and blockchain enthusiasts!</p><p>The core data structures that exist in Ethereum consist of an optimized implementation of Merkle Patricia tries. This article aims to provide readers with an improved understanding of how Ethereum’s data storage layer operates and the different intricacies that make up the ‘world state’. Specifically, I’ll be discussing different trie structures, their beneficial properties, Ethereum’s modified Merkle Patricia trie, the different tries within Ethereum, and their corresponding purposes. In addition, there are helpful exercises and resources at the bottom of this article to solidify a reader’s understanding.</p><p>Trust me, this will be fun and informative. :)</p><p>Before we discuss Ethereum’s modified Merkle Patricia trie, let’s get a brief introduction of the varying tries that make up the unique properties of Ethereum’s implementation.</p><h4><strong>Trie Data Structures | Radix Trees</strong></h4><p>The origins of the term trie comes from re<strong>trie</strong>ve; for clarity’s sake, article the terms “trie” and “tree” will be used interchangeably. According to Paul Black [1], the use of the term trie was simply to distinguish it from the word tree, but there will be no such distinction made in this article…sorry, Paul. (Didn’t I tell you this would be fun?) Alright, let’s get serious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*2T5L6ThVQVYLVoQ2" /></figure><p><em>Figure A. Source: </em><a href="https://en.wikipedia.org/wiki/Trie"><em>https://en.wikipedia.org/wiki/Trie</em></a></p><p>A trie is a tree-like data structure, also referred to as a <em>digital tree</em>, <em>radix tree</em> or <em>prefix tree</em>, that is used to retrieve a string value by traversing down a branch of nodes that store associated references (keys) that together lead to the end value that can be returned [2]. Specifically, if we begin from the top of the tree at the root node, each character in the key indicates which child node to follow resulting in a path to the corresponding value. The keys can contain N characters, thus each node can contain N children, and the max depth of the tree is the max length of a key [2]. For example, if we were to use the English alphabet to comprise the keys, each node in the tree could have up to 26 children, as there are 26 letters in the alphabet. In order to reduce the time it takes to travel down a branch to get to the end value, keys that begin in the same sequence are grouped in close proximity to one another. In doing so, our search for the end value is optimized and more efficient. To emphasize this point, I will display a radix trie that does NOT group same sequence keys together and another one that does.</p><p>To illustrate, the image below depicts a dataset (Figure B) and an inefficient radix trie (Figure C). In order to retrieve the value 5 using our key BLOCK, we need to descend down the path five internal nodes with null values before reaching our desired value. A lot of wasted space is consumed with this inefficient implementation.</p><p><em>Figure B. Dataset for inefficient radix trie</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*PIQp3RXrI5bql3JM" /></figure><p><em>Figure C. An inefficient radix tree implementation</em></p><p>An improved usage of the same radix tree with the same dataset can be made by combining same sequence keys. Rather than single character keys that represent the path to the value, we create a string. See Figure D.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_HaPHQZ4Df0CCMOUFaE9cg.png" /></figure><p><em>Figure D. An efficient radix tree implementation</em></p><p>Instead of traversing down the path of five null value nodes, we merely have to go down one to get to our desired value of 5, and only two nodes to get to the value of 6, where the key is BLOCK(S).</p><p>Okay, so we’ve covered the basics of tries, specifically radix tree data structures. Let’s discuss Merkle trees.</p><h3><strong>Trie Data Structures | Merkle Trees</strong></h3><p>Merkle trees’ primary purpose is to prove the consistency of data, and is essentially a tree of hashes. The name Merkle Tree comes from Ralph Merkle, who patented the concept in 1979 [3]. Wikipedia defines Merkle Trees more precisely as the following:</p><p><em>“</em><strong><em>Merkle tree</em></strong><em> is a </em><a href="https://en.wikipedia.org/wiki/Tree_(data_structure)"><em>tree</em></a><em> in which every leaf node is labelled with the hash of a data block and every non-leaf node is labelled with the </em><a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function"><em>cryptographic hash</em></a><em> of the labels of its child nodes.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*6jyLdiPV1eaTHDWJ" /></figure><p><em>Figure E. Source: </em><a href="http://en.wikipedia.org/wiki/hash_tree"><em>http://en.wikipedia.org/wiki/hash_tree</em></a></p><p>Let’s examine Figure E above to get a more concrete understanding of Merkle Trees. The bottom leaves (C,D,E,F) represent the hashes of the below data blocks, and these data blocks are the values in which we are storing. The parents of leaves ( [C, D] , [E, F] ) will be equal to Hash(<em>valueOfChild1, valueOfChild2</em>). For instance, node A is the concatenated hashes of its two children C and D. This process of re-hashing the concatenation of the child nodes to create the parent node is performed until the top of the tree is reached, called the ‘root hash’ [3]. The parent-to-child hashing process/structure described above results in a key property of Merkle Trees: they provides a means to prove the integrity and validity of your data.</p><p>For example, if we were to change the value of a data block, the entire path leading to the ‘root hash’ would also be changed. Therefore, if we hold the value of the root hash, we could verify the consistency of data by rebuilding the trie to get the root hash and then compare it with the root hash value in which we are holding [4]. It is impossible to fake data without changing the value of the root.</p><p>Let’s explore more benefits of Merkle Trees, as it will further our understanding of the rationale behind using tries for Ethereum’s ‘world state’.</p><h4><strong>Merkle Trees | Beneficial Properties</strong></h4><p>The key benefits of Merkle Trees consist of the following properties [3]:</p><ol><li>Data Consistency / Verification</li><li>Merkle Tree proofs are computationally easy and fast</li><li>Merkle Tree proofs require only a small chunks of data to be broadcasted across a network</li></ol><p>We briefly discussed how Merkle Trees are able to provide a means to prove the integrity of data, but let’s go a little bit deeper to accentuate the importance of data consistency as it relates to distributed and peer-to-peer (P2P) systems like Ethereum.</p><p>In these distributed systems, data exists in multiple locations; if some piece of data is modified in one location, those changes need to be reflected everywhere else. Merkle Trees are used to verify the data and make sure the data is the same — <em>everywhere</em>. Again, as we described earlier, we can do this by sending a hash for comparison. Consider the below sequence between two computers [5]:</p><ol><li>Computer A sends a hash of the file to computer B.</li><li>Computer B checks that hash against the root of the Merkle tree.</li><li>If there is no difference, we’re done! Otherwise, go to step 4.</li><li>If there is a difference in a single hash, computer B will request the roots of the two subtrees of that hash.</li><li>Computer A creates the necessary hashes and sends them back to computer B.</li><li>Repeat steps 4 and 5 until you’ve found the data block(s) that are inconsistent. It’s possible to find more than one data block that is wrong because there might be more than one error in the data.</li></ol><p>The above sequence illustrates how Merkle Trees facilitate data verification across a network. To clarify, we are only sending the hash of the leaf that was identified as changed over the network. The importance of this is that it allows nodes in a distributed system to <strong>quickly and efficiently identify data that has changed without having to send over all the data in order to make the comparison</strong>. It’s possible to achieve data verification and consistency without the use of Merkle Trees, but to do so would be time-consuming and computationally intensive, requiring the network to check the entirety of each piece of data whenever nodes in the network request to verify data.</p><p>In Ethereum, merkle proofs make it easy to verify the inclusion of a transaction and enable SPV (simple payment verification). Furthermore, now we have the ability to utilize light clients on the network, as nodes are no longer required to a hold a copy of the entire chain. Light clients receive the block headers which contain a merkle root (more on this later) that can be used to query full nodes to verify if a transaction is included in a particular block. However, full nodes are still required to maintain a complete list of transaction and update their local state accordingly.</p><p>Sweet! So that was our introduction into trie data structures and their benefits, specifically radix trees and merkle trees. They’re pretty awesome data structures, and Ethereum managed to make them even better.</p><h4><strong>Ethereum’s Modified Merkle Patricia Trie | The Differences</strong></h4><p>Ethereum’s trie data structure implementation is different than traditional trie implementations, as modifications have been made to increase the performance and efficiency, hence <em>Modified Merkle Patricia Trie</em>. We will go over these improvements, including the encoding systems used by the Ethereum network, and also go over its special node types. However, let’s start with Ethereum’s own definition of its modified Merkle Patricia Trie from their wiki entry:</p><blockquote>Merkle Patricia tries provide a cryptographically authenticated data structure that can be used to store all (key, value) bindings……They are fully deterministic, meaning that a Patricia trie with the same (key,value) bindings is guaranteed to be exactly the same down to the last byte and therefore have the same root hash, provide the holy grail of O(log(n)) efficiency for inserts, lookups and deletes, and are much easier to understand and code…</blockquote><p>To summarize, tries are cryptographically secure, and each node is referenced by its hash, which is used for lookups in a Leveldb database (Go-Ethereum, CPP-Ethereum, Py-Ethereum) or RocksDB (Parity) [2]. In this structure, root nodes become a cryptographic fingerprint of the entire data structure, achieving optimal efficiencies for inserts, lookups and deletes. These tries are stored in a Leveldb instance for Ethereum’s Go, C++ and Python clients. Below is a brief description of Leveldb and some of its features. (RocksDB is out of scope for this article as it pertains mainly to the Parity implementation of Ethereum.)</p><p>Leveldb is an open-sourced Google key-value storage library which provides a variety of cool features that include but are not limited to [6]:</p><ul><li>Data is stored and sorted by keys</li><li>Callers can provide a custom comparison function to override the sort order</li><li>Ordered mapping from string keys to string values</li><li>Multiple changes can be made in one atomic batch</li><li>Forward and backward iteration is supported over the data</li><li>Data is automatically compressed using the <a href="http://google.github.io/snappy/">Snappy compression library</a></li></ul><p>So how do you get to the values of trie data structures? Why, you explore the hex-prefixed (HP) encoded path from their respected root hashes, of course…</p><p>HP encoding is an Ethereum encoding system used solely on the paths that connect nodes of each trie data structure. This encoding system serves a dual purpose: to disambiguate between node types (in particular between leaf and extension nodes — more on those later) and convert the path to an even length [7]. In doing so, the merkle tree will always be a whole number of bytes which is important for machines.</p><p>Let’s further our understanding of how HP encoding is utilized. To begin, <em>Leaf</em> and <em>Extension</em> are two distinct node types. Leaf nodes contain a terminator; think of it as a flag. The terminator is the last byte of the path and has a value of 16 in decimal or 0x10 in hex [8]. A nibble, which is just one hex character, is appended to the front of a key to determine parity (even or odd in length) and if there is a terminator. More precisely, the lowest significant bit encodes the odd-even length, while the next lowest encodes the terminator. When the HP encoding function encounters a terminator it will remove it and then continue to create a prefix into the path. If the prefix is 0x0 or 0x2, the function will add a nibble of <strong>0</strong> followed by the prefix, thus the full prefix would be 0x0<strong>0</strong> or 0x2<strong>0</strong>. Again, the reasoning is to maintain the even length of any given path.</p><p>Consider the table in Figure F: row B is an odd-length extension node beginning with hex 1, thus we prefix the path with 1 and now the path is even-length. Row C is an even-length leaf node; it has a terminator at the end (hex 10) and the path begins with the hex 0. The terminator is removed, and hex 2 is prefixed in front (20) followed by hex 0 in front of hex f, creating an even-length path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/0*N0Z91FQhou9fZCwO" /></figure><p><em>Figure F. Hex-Prefix Example</em></p><p>While HP encodes the path of a given value, Ethereum’s own encoding system known as Recursive Length Prefix (RLP) encodes the actual value. Note that at the time of this writing, while Ethereum still utilizes this methodology for serializing objects, RLP will be replaced by a more optimal form of serialization in the future, as mentioned <a href="https://github.com/ethereum/wiki/wiki/RLP">here</a>. We will discuss its role in the current implementation.</p><p>Storing data properly requires a form of data serialization, meaning, translating data structures or object state into a format that can be stored or transmitted across a network to be reconstructed later. Ethereum utilizes RLP for its data serialization. The purpose of RLP is to encode nested arrays of binary data or to encode structure. The RLP encoding function will take in an item and encode the passed in item accordingly.</p><p>The Ethereum wiki defines an item as follows:</p><ul><li>A string (ie. byte array) is an item</li><li>A list of items is an item</li></ul><p>The Ethereum wiki also provides an in-depth definition of <a href="https://github.com/ethereum/wiki/wiki/RLP">RLP</a> encoding based on the length of bytes among other factors and provides strong examples.</p><p>The optimizations of the Modified Merkle Patricia Trie are a result of added complexity, namely the introduction of different node types. It contains four distinct node types [9]:</p><ul><li>NULL Nodes (represented as an empty string)</li><li>BRANCH Nodes (17-item node, [ v0…..v15, vt ] )</li><li>LEAF Nodes (2-item node, [ encodedPath, value ])</li><li>EXTENSION Nodes (2-item node, [ encodedPath, key ])</li></ul><p>We briefly discussed leaf and extension nodes above, however we did not specify their importance. Without each of the distinct node types, if we were to travel down a 64 character path (in the case of the state trie) we may encounter a node with no differing paths available and this node could have empty values in each index (one for each of the 16 hex characters) besides the target index [9]. To prevent these occurrences and reduce the distance travelling down such a path, Ethereum utilizes extension nodes [ encodedPath, key ], where the encodedPath (recall HP encoding above) consists of a ‘partial path’ that allows us to skip ahead, and the key is then used for the next database lookup in Leveldb [9] .</p><p>Leaf nodes [encodedPath, value], if you recall from when we discussed hex-prefixes, can be identified by their terminator flag in the first nibble of the encodedPath. The same situation described above occurs, the encodedPath contains the ‘partial path’ which fast-forwards us to the complete end of the path where the value is the target value itself [9]. To further our understanding of these node types, let’s look at the example in Figure G.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*t4ziOSL-71LPnkjE" /></figure><p><em>Figure G. Source: Lee Thomas, </em><a href="https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture"><em>https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture</em></a></p><p>In the top-right, we have a simplified world state. The keys represent addresses and the values represent balances. In this example, the root node is an extension node [encodedPath, key] and we know that based on the hex-prefix. Also note that in this example, all the keys share the same nibble of a7, thus they’re grouped accordingly, an attribute of radix tries. Since the root is an extension node [encodedPath, key] the ‘<em>next node</em>’ bucket will be a hash pointing to the next node, which in this case is a branch node [ v0…..v15, vt ]. If we follow the first key in our simplified state (a711355), we use the 1 after a7, to look in the first index of the branch node. This leads us to create a leaf node where if we compare the key and the path, they’re the same, allowing us to skip ahead and leading us to the value or the account balance of 45.0 ETH.</p><h4><strong>Ethereum’s Trie Data Structures | The Details</strong></h4><p>Ethereum utilizes its ‘Modified Merkle Patricia Trie’ for each of its 4 trie data structures:</p><ul><li>Receipt Tree</li><li>State Tree</li><li>Storage Tree</li><li>Transaction Tree</li></ul><p>The root for each of the tries is a Keccak 256-bit hash, and three out of four of the tries listed above exist within the block header, Receipt Tree, State Tree and Transaction Tree. The Storage Tree’s root lives within the RLP encoded data value within the State Trie. See Figure H below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*azxsxkt4uXwlX1y7" /></figure><p><em>Figure H. Source: </em><a href="https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture"><em>https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture</em></a></p><h4><strong>Transaction Trie</strong></h4><p>As mentioned above, the transaction root exists within the block header, and as you can guess, its purpose is to record transactions. Since the ordering of the data is mostly decided upon by the miner, we do not know what the data looks like until it is mined. We do know what parameters are used to compose the transaction trie, and they’re as follows:</p><ul><li>Account nonce</li><li>Gas price</li><li>Gas limit</li><li>Recipient</li><li>Transfer value</li><li>Transaction signature values</li><li>Account initialization (if transaction is of contract creation type), or transaction data (if transaction is a message call)</li></ul><p>Once the block is mined, the transaction trie is never updated [9].</p><h4><strong>Receipt Trie</strong></h4><p>Again, the receipt root lives within the block header and its purpose it to record the outcome of a transaction. According to the yellow paper, the receipt trie can also be useful for zero-knowledge proofs or searches. The parameters that make up the receipt trie are as follows:</p><ul><li>Post-transaction state</li><li>Cumulative gas used</li><li>Logs</li><li>Bloom filter created from the information of the above logs</li></ul><p>This trie never updates.</p><h4><strong>State Trie</strong></h4><p>The one and only one global state trie. It contains a key-value pair for every Ethereum account on the network, where the key is an ethereum address and the value is RLP encoded ethereum account. An ethereum account and the state trie is comprised of the following fields:</p><ul><li>Nonce</li><li>Balance</li><li>Storage Root</li><li>Codehash</li></ul><p>Unlike the transaction and receipt tries, the state trie updates over time….constantly.</p><h4><strong>Storage Trie</strong></h4><p>The storage trie is where all the contract data lives, and there is a separate storage trie for each account [9].</p><p>We have now covered each trie, its purpose and contents. Figure I below displays a strong representation of exactly what we covered above. As you can see, we have the block header on the right which contains the root for the ‘World State Trie’, ‘Transaction Trie’, and ‘Transaction Receipt Trie’. It also depicts the contents within each of those trees, including the storage root for the ‘Account Storage Trie’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*e35CmD76dT-WWwA3" /></figure><p><em>Figure I. Source: Lee Thomas, </em><a href="https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture"><em>https://ethereum.stackexchange.com/questions/268/ethereum-block-architecture</em></a></p><h3><strong>Conclusion</strong></h3><p>This article’s purpose was to provide readers with an improved understanding of trie data structures in Ethereum. I hope this articles purpose has been fulfilled, but if not, I have included a number of resources and exercises below. Thank you for taking the time to read.</p><p><strong>Glossary</strong></p><p><strong>Branch: </strong>A 17-item structure whose first sixteen items correspond to each of the sixteen possible nibble values for the keys at this point in their traversal. The 17th item is used in the case of this being a terminator node and thus a key being ended at this point in its traversal [7].</p><p><strong>Extension: </strong>A two-item structure whose first item corresponds to a series of nibbles of size greater than one that are shared by at least two distinct keys past the accumulation of nibbles keys and branches as traversed from the root. The hex-prefix encoding method is used and the second parameter to the function is required to be false [7].</p><p><strong>Leaf: </strong>A two-item structure whose first item corresponds to the nibbles in the key not already accounted for by the accumulation of keys and branches traversed from the root. The hex-prefix encoding method is used and the second parameter to the function is required to be true [7].</p><p><strong>Nibble: </strong>Hex form of 4 bits (0x1, 0x4, 0xf)</p><h4><strong>Helpful Resources and Exercises</strong></h4><p>Exercises and Ethereum Trie Walk-Through</p><p><a href="https://easythereentropy.wordpress.com/2014/06/04/understanding-the-ethereum-trie/#comments">https://easythereentropy.wordpress.com/2014/06/04/understanding-the-ethereum-trie/#comments</a></p><p><a href="https://medium.com/codechain/modified-merkle-patricia-trie-how-ethereum-saves-a-state-e6d7555078dd">https://medium.com/codechain/modified-merkle-patricia-trie-how-ethereum-saves-a-state-e6d7555078dd</a></p><p>Trie Data Structures</p><p><a href="https://www.codeproject.com/Articles/1176140/Understanding-Merkle-Trees-Why-use-them-who-uses-t">https://www.codeproject.com/Articles/1176140/Understanding-Merkle-Trees-Why-use-them-who-uses-t</a></p><p><a href="https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014">https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014</a></p><p>Video</p><p><a href="https://www.youtube.com/watch?v=wwrf87bq6jo">https://www.youtube.com/watch?v=wwrf87bq6jo</a></p><h4><strong>References</strong></h4><p>[1] Black, Paul E. (2009–11–16). <a href="https://www.webcitation.org/5pqUULy24">“trie”</a>. <em>Dictionary of Algorithms and Data Structures</em>. <a href="https://en.wikipedia.org/wiki/National_Institute_of_Standards_and_Technology">National Institute of Standards and Technology</a>. Archived from <a href="https://xlinux.nist.gov/dads/HTML/trie.html">the original</a> on 2010–05–19.</p><p>[2] <a href="https://easythereentropy.wordpress.com/2014/06/04/understanding-the-ethereum-trie/#comments">https://easythereentropy.wordpress.com/2014/06/04/understanding-the-ethereum-trie/#comments</a></p><p>[3] <a href="https://www.codeproject.com/Articles/1176140/Understanding-Merkle-Trees-Why-use-them-who-uses-t">https://www.codeproject.com/Articles/1176140/Understanding-Merkle-Trees-Why-use-them-who-uses-t</a></p><p>[4]<a href="https://medium.com/coinmonks/data-structure-in-ethereum-episode-2-radix-trie-and-merkle-trie-d941d0bfd69a">https://medium.com/coinmonks/data-structure-in-ethereum-episode-2-radix-trie-and-merkle-trie-d941d0bfd69a</a></p><p>[5] <a href="https://brilliant.org/wiki/merkle-tree/">https://brilliant.org/wiki/merkle-tree/</a></p><p>[6] <a href="https://github.com/google/leveldb">https://github.com/google/leveldb</a></p><p>[7] <a href="http://gavwood.com/Paper.pdf">http://gavwood.com/Paper.pdf</a></p><p>[8] <a href="https://medium.com/coinmonks/data-structure-in-ethereum-episode-1-compact-hex-prefix-encoding-12558ae02791">https://medium.com/coinmonks/data-structure-in-ethereum-episode-1-compact-hex-prefix-encoding-12558ae02791</a></p><p>[9] <a href="https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization">https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f03d2c3325d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/shyft-network/understanding-trie-databases-in-ethereum-9f03d2c3325d">Understanding Trie Databases in Ethereum</a> was originally published in <a href="https://medium.com/shyft-network">Shyft Network</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>