<?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 Carl Norburn on Medium]]></title>
        <description><![CDATA[Stories by Carl Norburn on Medium]]></description>
        <link>https://medium.com/@carl.norburn?source=rss-e7644b774783------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FN8395p4njOYOWkk6K7R0g.png</url>
            <title>Stories by Carl Norburn on Medium</title>
            <link>https://medium.com/@carl.norburn?source=rss-e7644b774783------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:45:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carl.norburn/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[Casper Ecosystem SDK’s Standard Tests]]></title>
            <link>https://medium.com/casperblockchain/casper-ecosystem-sdks-standard-tests-b79ce45a94a5?source=rss-e7644b774783------2</link>
            <guid isPermaLink="false">https://medium.com/p/b79ce45a94a5</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[cucumber]]></category>
            <dc:creator><![CDATA[Carl Norburn]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 08:51:18 GMT</pubDate>
            <atom:updated>2023-07-10T12:22:35.052Z</atom:updated>
            <content:encoded><![CDATA[<h3>Standardising tests for the Casper blockchain SDK’s</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgIBmloHaZsINg8r7bbUow.png" /><figcaption>Scary happy robot says your tests passed</figcaption></figure><h3>The Description</h3><p>Nobody wants to interact with a blockchain using RPC curl commands!</p><p>So Casper provides a rich language set of SDK’s to provide ease of access as part of their eco-system.</p><p>The current list is <a href="https://docs.casper.network/sdk/">here</a></p><h3>The Problem</h3><p>Each SDK developer has applied TDD, with unit tests, test cases and simple implementation tests. Some tests will run against <a href="https://testnet.cspr.live/">Testnet</a> or NCTL (more on this later). This approach is good enough for individual SDK development.</p><p>The problem is that a SDK developer can easily miss a test, or easily write a false positive test.</p><p>A rigorous set of standard tests that each SDK must pass before publication is needed.</p><h3>The Solution</h3><p>Casper Association commissioned us to write the set of standard tests. These standard tests therefore become a single point of truth.</p><p>How do you go about writing standard tests that can be applied language agnostically?</p><p>We opted for <a href="https://cucumber.io/">Cucumber</a> tests. Cucumber provides English like scripts, called Gherkin, which build up feature files. Each feature file has a steps class or method to execute the test in the SDK’s native language.</p><p>Feature example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MEGXMe4kNcTpRST73wthQ.png" /></figure><p>The above example is a simple deploy and wait. Note the blue highlighted text that denotes passed in parameters to the step code.</p><p>Corresponding steps example (Python):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTvJevt8xg5_5lmz9UPajQ.png" /></figure><p>Corresponding steps example (Java):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XoqqwXX3wIxImUiqm1qKtw.png" /></figure><p>This is architecturally pleasing, once the hard work of writing initial tests is done (we started with Java) the same tests can be copied/pasted (we plan to repo them) into any other standard test project. This leaves only the steps to be written in the native language.</p><p>The tests can be run via CLI or JetBrains rich IDE’s.</p><p>The following test result is via PyCharm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SuY_Wp6O3GUQpf3wjgJKEQ.png" /></figure><p>We get the pleasing passing green ticks!</p><h3>The Architecture</h3><p>Can be split into three items:</p><ul><li>NCTL</li><li>Github repositories</li><li>Github actions</li></ul><p><strong>NCTL</strong></p><p>NCTL stands for network/node control. It’s a locally running node developed by Casper that tests can be run against. A full description can be found <a href="https://docs.casper.network/developers/dapps/setup-nctl/">here</a>.</p><p>This has been <a href="https://github.com/make-software/casper-nctl-docker">dockerised</a> by the team at Make, with modifications for the standard tests project <a href="https://hub.docker.com/repository/docker/stormeye2000/cspr-nctl/general">here</a>.</p><p>NCTL is seen as a source of truth, meaning that any SDK method call must result in the same corresponding NCTL method call. This can be a view action which returns json to compare, a transfer action which changes the node and will need further view actions to compare. These are executed against NCTL via a mix of NCTL CLI commands, bash script execution and RCP calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KgN_vj7_yH7r5ixucSJHw.png" /><figcaption>Standard tests command flow</figcaption></figure><p><strong>Github repositories</strong></p><p>Each language specific standard test has its own repo. Currently three tests are being developed and nearing release:</p><ul><li><a href="https://github.com/stormeye2000/cspr-sdk-standard-tests-java/tree/dev">Java</a></li><li><a href="https://github.com/stormeye2000/cspr-sdk-standard-tests-python/tree/dev">Python</a></li><li><a href="https://github.com/stormeye2000/cspr-sdk-standard-tests-typescript/tree/dev">Typescript</a></li></ul><p>The remaining SDK’s Go, C# and PHP are scheduled next</p><p><strong>Github actions</strong></p><p>These glue the projects together. On a SDK repo publish, the action will call the corresponding standard test action which will then run the tests against the main branch of the SDK. On demand test runs will also be available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNZyXBQdxoE4G1kviGGZfA.png" /><figcaption>action flow</figcaption></figure><p>When the tests pass the SDK is published, when the tests fail the publish fails.</p><p>The standard test action will publish a report on success or failure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-U_g-e1x7EruxMI5WraShQ.png" /><figcaption>some pass, some fail, c’est la vie</figcaption></figure><p>Reports will also be emailed to interested parties and dropped in Slack channels.</p><h3>Pros and Cons</h3><p><strong>Pros</strong></p><ul><li>Identical Cucumber tests run against each SDK</li><li>Industry standard approach</li><li>Tests can be cloned locally and run pre-release</li><li>Generated reports</li><li>Github responsible for the infrastructure</li><li>SDK expertise and responsibility shared amongst different teams</li></ul><p><strong>Cons</strong></p><ul><li>Takes time to run (approx 8 mins)</li><li>Non implemented node commands will result in failure (probably a pro though!)</li><li>Multiple standard tests repos to maintain</li></ul><p>As can be seen, the pros outweigh the cons.</p><h3>Conclusion</h3><p>SDK’s provide third party developers a way into the Casper chain.</p><p>There’s an obvious need therefore to ensure each SDK sets a high bar of quality. They have to be trusted. They have to not get in the way of third party developers. They need to be out in wild and being used.</p><p>The above testing solution will give Casper the confidence that these requirements can be achieved.</p><p>Thanks for reading</p><p>More from Stormeye:</p><p><a href="https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9">Casper Kafka Event Store Pt 1</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964">Casper Kafka Event Store Pt 2</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119">Casper Kafka Event Store Pt 3</a></p><p><a href="https://medium.com/stormeye2000/casper-event-store-explained-5413b1fe4ba1">Casper Event Store Explained</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b79ce45a94a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/casperblockchain/casper-ecosystem-sdks-standard-tests-b79ce45a94a5">Casper Ecosystem SDK’s Standard Tests</a> was originally published in <a href="https://medium.com/casperblockchain">Casper Association R &amp; D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casper Event Store Explained]]></title>
            <link>https://medium.com/stormeye2000/casper-event-store-explained-5413b1fe4ba1?source=rss-e7644b774783------2</link>
            <guid isPermaLink="false">https://medium.com/p/5413b1fe4ba1</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Carl Norburn]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 16:12:43 GMT</pubDate>
            <atom:updated>2023-01-04T16:57:28.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15R5yYR46UiOzrB9wDi88A.png" /><figcaption>what DALL-E thinks a Kafka Kubernetes cluster is</figcaption></figure><p>The following video showcases our solution to building a highly available Kubernetes Kafka based Event Store.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fq_M5gcWxkd4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dq_M5gcWxkd4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fq_M5gcWxkd4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/800e8ea2686889abf45b38636607b3ec/href">https://medium.com/media/800e8ea2686889abf45b38636607b3ec/href</a></iframe><p>Relevant Links:</p><p><a href="https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9">Casper Kafka Event Store Pt 1</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964">Casper Kafka Event Store Pt 2</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119">Casper Kafka Event Store Pt 3</a></p><p><a href="https://github.com/stormeye2000/cspr-events-store">Event Store Code Repo</a></p><p><a href="https://github.com/stormeye2000/cspr-kafka-cluster">Event Store Cluster Repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5413b1fe4ba1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stormeye2000/casper-event-store-explained-5413b1fe4ba1">Casper Event Store Explained</a> was originally published in <a href="https://medium.com/stormeye2000">Stormeye2000</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casper Kafka Event Store Pt 3]]></title>
            <link>https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119?source=rss-e7644b774783------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f89a1a1119</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[casper]]></category>
            <category><![CDATA[casperlabs]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Carl Norburn]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 17:14:19 GMT</pubDate>
            <atom:updated>2022-12-28T08:31:14.434Z</atom:updated>
            <content:encoded><![CDATA[<h4>Adding Producers and Consumers to the Kubernetes Cluster</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qC1WAn8rOi9-mI-lF71UCA.png" /><figcaption>DALL-E representation of the Stormeye development team</figcaption></figure><p>Now that we have a cluster with a kafka broker and zookeeper ensemble running we can start producing and consuming emitted events.</p><p>Some important decisions had to be made here:</p><ul><li>How many nodes will we connect to?</li><li>How many producer and consumer replicas?</li><li>Maximum size of an event?</li><li>Where is the data going?</li><li>What’s the DR strategy?</li></ul><p>Before we discuss these decision let’s first look at how we approached writing the kafka consumers and producers.</p><p>At project inset we had separate, stand alone GitHub repos for Consumers and Producers. As the project matured we moved over to a single repo with shared classes plus we leveraged the Java SDK functionality.</p><p>Relevant GitHub repositories are here:</p><ul><li><a href="https://github.com/stormeye2000/cspr-events-store">The Event Store</a></li><li><a href="https://github.com/casper-network/casper-java-sdk">The Casper Java SDK</a></li><li><a href="https://github.com/stormeye2000/cspr-kafka-cluster">The Event Store Cluster</a></li></ul><h3>The Producer</h3><p>The producer has two jobs:</p><ul><li>Connect and start a stream from a node(s)</li><li>Wrap events in metadata and fire to Kafka topics as messages</li></ul><p>To connect and stream a node we are using the functionality of the SDK</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bbedda299320f2df62566461b6c1662/href">https://medium.com/media/0bbedda299320f2df62566461b6c1662/href</a></iframe><p>The above code will connect to a node with retries. DR also comes into play here with the option as replaying the stream from a specific event id.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c84d8d7c8bfdf9e3b35fb5a9a9cac9d/href">https://medium.com/media/7c84d8d7c8bfdf9e3b35fb5a9a9cac9d/href</a></iframe><p>The method above will accept for each event in the stream the URI of the emitter and a deserialised event. The topic is extracted from the event, a key is generated, a partition set and then the event is fired to a Kafka topic.</p><p>Topics are determined from the emitter node endpoint, /sigs, /main, /deploys</p><p>After trial and error with setting a Kafka partition we decided to let Kafka determine which partition to send to. We hoped that by adding a unique key and writing to a specific partition we could prevent duplicate events and thus have multiple producers. But at this moment we have yet to prove this. The Kafka partitions and replicas per topic are set at the Kubernetes cluster deployment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baaf2d9152967cef2473b45058cd9b7c/href">https://medium.com/media/baaf2d9152967cef2473b45058cd9b7c/href</a></iframe><p>The producer configuration is set in the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dabe9a196d22a446837252fc581776b9/href">https://medium.com/media/dabe9a196d22a446837252fc581776b9/href</a></iframe><p>Most settings speak for themselves, but what is interesting is the PRODUCER_BYTES constant which sets the message size. The default for a Kafka message is 1mb. We saw Casper events &gt; 20mb.</p><p>This caused a philosophical and existential discussion amongst the team. Should we even be using Kafka if the messages can be this size? What are the implications of handling events this size?</p><p>In the end, after discussion with Casper Labs, we decided that as the frequency of large events is low, it’s acceptable to increase the max size in Kafka. We’ve set it 256mb.</p><h3>The Consumers</h3><p>We are using two consumer groups in the project:</p><ul><li>consumer-audit — writes the raw events to mongo for replays and DR</li><li>consumer-store — writes to Postgres for downstream consumers</li></ul><p>Consumer groups are a very useful feature of Kafka, they allow multiple consumers to read the same message. Messages are not marked as read until all registered consumer groups have read them. This is where Kafka’s scalability becomes an advantage. More consumer groups can be added later, and as we have the replay functionality through the audit service, they can consume events from a set point in time.</p><p>The consumer-audit consumer group is a straight pass through process which will just write the raw event to mongo, we had to use gridFS to allow &gt;16mb messages.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0e1eed0e1931ee606b807efb8e12930/href">https://medium.com/media/e0e1eed0e1931ee606b807efb8e12930/href</a></iframe><p>Kafka config details are left to the annotations, the audit service will simply save the raw event</p><p>The consumer-store consumer group will apply Casper business logic to any message it reads and store it in the relational Postgres db.</p><p>This is the meat of the project, work is ongoing here. This is where block validation and consensus amongst other analytics will happen.</p><p>The following code snippet shows how this happens:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f8dead48262e9de77b842d90600837d/href">https://medium.com/media/7f8dead48262e9de77b842d90600837d/href</a></iframe><p>The storage factory decides where to send the event for processing. Each event type has it’s own factory class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a759235d7bbc7347b4fb67f1768f418/href">https://medium.com/media/9a759235d7bbc7347b4fb67f1768f418/href</a></iframe><p>The above method handles the DeployProcessed event which will extract the deploy data and any transfers, withdrawals and bids.</p><p>The other factory storage classes include blocks, eras, rewards.</p><p>An API has been added to view the live Postgres data <a href="https://store.stormeye2000.com/swagger-ui/index.html">here</a></p><p>So where does that leave us? Lets have a look at the current architectural diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRZak0Fd3cZ8gZ3dM-ttyQ.png" /></figure><p>Everything in the circle is in the Kubernetes cluster and ready to be used.</p><p>The applications on the right outside the cluster are potential applications waiting to be developed.</p><p>The node events pass into the Kafka brokers, there they wait until the consumer reads them, then the consumers process them.</p><p>We’re currently running one replica of the Producer in the cluster, connecting to one Casper node. This prevents event duplication. A single producer can connect to multiple nodes. More producers can be added connecting to more nodes. This will be explained more in a later article.</p><p>At the moment two replicas are running each for the consumer groups.</p><p>There is also an Audit API endpont <a href="https://audit.stormeye2000.com/swagger-ui/index.html">here</a></p><p>The id store mongo db is used for DR, it stores the id of the last event processed. This sets the restart point when reconnecting.</p><p>The next article will walk through the Kubernetes cluster dashboard and logs.</p><p>Previous articles are here:</p><p><a href="https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9">Casper Kafka Event Store Pt 1</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964">Casper Kafka Event Store Pt 2</a></p><p>Carl Norburn is a Software Engineer with Stormeye. He also knows a thing or two about DevOps. Public <a href="https://github.com/stormeye2000?tab=repositories">repos</a>, t<a href="https://twitter.com/stormeye2000">witter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f89a1a1119" width="1" height="1" alt=""><hr><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119">Casper Kafka Event Store Pt 3</a> was originally published in <a href="https://medium.com/casperblockchain">Casper Association R &amp; D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casper Kafka Event Store Pt 2]]></title>
            <link>https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964?source=rss-e7644b774783------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6f1ed37d964</guid>
            <dc:creator><![CDATA[Carl Norburn]]></dc:creator>
            <pubDate>Thu, 29 Sep 2022 11:17:47 GMT</pubDate>
            <atom:updated>2022-12-28T08:29:53.821Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building a Kafka Cluster in a Kubernetes Cluster</h4><p>Carl Sagan quoted that If you wish to make an apple pie from scratch, <strong>you must first invent the universe</strong>.</p><p>Luckily the universe has already been invented, but we still need to build our Kubernetes cluster to host our Kafka cluster.</p><p>For this POC I chose GCP. They’ve done some good work in minimising the UI. Plus the networking works seamlessly behind the scenes.</p><p>Install <strong>gcloud</strong> and <strong>kubectl</strong> and run the following command to create the cluster:</p><pre>gcloud beta container \<br> clusters create &quot;[CLUSTER_NAME]&quot; \<br> --project &quot;[PROJECT_NAME]&quot;  \<br> --zone &quot;[ZONE]&quot; \<br> --machine-type &quot;e2-medium&quot; \<br> --num-nodes 9 \<br> --disk-size &quot;100&quot;</pre><p>After about 5 minutes we should have a cluster.</p><p>Now we can add Zookeeper and Kafka.</p><p>Use the installation guide from this GitHub <a href="https://github.com/stormeye2000/cspr-kafka-cluster">link</a></p><p>As we have no Producers or Consumers configured yet, Kafka will be in a waiting state. No leader has been elected yet. This all happens when topics and partitions are created. More on that later.</p><h4>Things to note in this cluster</h4><p>Zookeeper is a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/">StatefulSet</a> of three replicas. We need consistently named pods in the cluster. If we used a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">Deployment</a>, every time a new pod was instantiated, it would be randomly name with a deployment hash suffix.</p><p>With StatefulSets you get consistent pod names. In this case zookeeper-0, zookeeper-1 and zookeeper-2</p><p>Likewise with the Kafka brokers.</p><p>The Kafka broker StatefulSet starts Kafka.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f74a88f70e088f9d49bc27f0383ca492/href">https://medium.com/media/f74a88f70e088f9d49bc27f0383ca492/href</a></iframe><p>Lines 2–4 define the Dockerfile, source can be viewed <a href="https://github.com/stormeye2000/cspr-kafka-cluster/blob/master/docker/Dockerfile">here</a></p><p>I chose to roll my own Dockerfile to allow more control. There are many Kafka Docker images in the hub, but for this project I needed to be able start Kafka with overridden options.</p><p>Lines 5–8 are allocated resources per pod. I used Kenneth Owens excellent templates <a href="https://github.com/kow3ns/kubernetes-kafka/tree/master/manifests">here</a> to configure this POC.</p><p>Lines 12–20 are environment variables. Line 13 sets the internal IP of the newly created pod. Lines 17–20 are standard java options.</p><p>Lines 21 onward are Kafka start up options.</p><p>Line 24 starts Kafka with the default server properties files, we then override these properties in the following lines with a mix of Kubernetes and custom env vars</p><p>Line 25 sets the broker id from the pod hostname, eg pod <em>kafka-broker-1</em> is assigned broker number 1 (StatefulSets give us this naming convention as discussed above)</p><p>Lines 26–29 set the listeners. The brokers need to know how to communicate with each other internally and with external clients. This is difficult to get right. These settings work and will save a lot of pain. Line 26 tells Kafka to use the default 0.0.0.0 which means listen on all interfaces. Line 27 uses the pod ip env var, KAFKA_POD_IP for the advertised listener. Confluent have a good article on listeners <a href="https://www.confluent.io/en-gb/blog/kafka-listeners-explained/">here</a>.</p><p>Line 28 tells Kafka to use the text string ‘INSIDE’ as the inter broker listener name. I assumed that when it sees this string it knows that this is an internal listener.</p><p>Line 29 as this POC is an internal Kafka ensemble we can use PLAINTEXT for the security protocol. This is setting it to no encryption or authourisation. This will be changed to SSL for any production cluster.</p><p>Line 30 uses Kubernetes env vars to point to our zookeeper pods. The zookeeper deployment uses a Kubernetes service for gateway access. This is all we need to configure the broker. This gives us the option of <em>n </em>zookeepers. We’re just using 3 in this POC</p><p>After running the steps in on the GitHub <a href="https://github.com/stormeye2000/cspr-kafka-cluster">page</a> we will have a sucesfully running Kafka/Zookeeper ensemble within a Kubernetes cluster. The ensemble will be in a waiting state. Part 3 of these articles will discuss and demonstrate how to use the cluster, with Casper node events.</p><p><a href="https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9">Casper Kafka Event Store Pt 1</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119">Casper Kafka Event Store Pt 3</a></p><p>Carl Norburn is a Software Engineer with Stormeye. He also knows a thing or two about DevOps. Public <a href="https://github.com/stormeye2000?tab=repositories">repos</a>, t<a href="https://twitter.com/stormeye2000">witter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6f1ed37d964" width="1" height="1" alt=""><hr><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964">Casper Kafka Event Store Pt 2</a> was originally published in <a href="https://medium.com/casperblockchain">Casper Association R &amp; D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casper Kafka Event Store Pt 1]]></title>
            <link>https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9?source=rss-e7644b774783------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae4bc87aecd9</guid>
            <category><![CDATA[events]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[casper]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[stormeye]]></category>
            <dc:creator><![CDATA[Carl Norburn]]></dc:creator>
            <pubDate>Fri, 16 Sep 2022 14:07:57 GMT</pubDate>
            <atom:updated>2022-12-28T08:27:31.598Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Description</h3><p>Casper nodes emit events on state changes. These events in the platform are categorised into three event stream types:</p><ul><li>Deploy Events</li><li>Finality Signature Event</li><li>Main Events</li></ul><p>Within each stream type there are multiple event types such as <strong>DeployAccepted</strong> or <strong>BlockAdded</strong></p><p>See the Casper <a href="https://docs.casperlabs.io/dapp-dev-guide/building-dapps/monitoring-events/">documentation</a> for a full description.</p><h3>The Problem</h3><p>As can be seen from the diagram below, there will be n nodes emitting 3 event stream types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_O3qGUeJ9rRfae7dswh3vg.png" /><figcaption>Casper Node Events</figcaption></figure><p>This is a lot of events.</p><p>Even if the event stream is restricted to one or a group of nodes we are still seeing many events.</p><p>Casper clients use these events to build up a picture of state changes in the node and smart contracts.</p><p>These state changes can notify audit tools of any discrepancies, such as suspicious transactions, asset mutation or chain failure.</p><h3>The Solution</h3><h4><strong>How can we handle so many events?</strong></h4><p>To reliably consume these event streams we need a high throughput, highly available messaging service.</p><ul><li>We need to differentiate the event types.</li><li>We need to load balance the event stream types into separate silos (Finality Signature events are the majority of events by many multiples)</li><li>We need to be able to replay the events in the case of any data loss or DR</li><li>We need confidence in our architecture</li></ul><p>Enter <a href="https://kafka.apache.org/">Kafka</a>, which will satisfy the concerns above.</p><p>Kafka has concepts such as Brokers, Partitions, Replicas, Topics which will all be discussed in details in later sections.</p><p>For now we just need to know that Kafka will be running n brokers acting as a cluster. The Kafka cluster will use <a href="https://zookeeper.apache.org/">Zookeeper</a> to orchestrate the brokers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*jry044f8MLzRdBDjI21Gcw.png" /><figcaption>Kafka Zookeeper setup</figcaption></figure><p>Kafka uses the leader/follower pattern where it will decide amongst itself who is the leader and who follows. If the leader is lost, a new leader will be elected. An odd number is preferred as is always the case with clusters.</p><p>Like all messaging systems, we need to produce and consume messages, Kafka like RabbitMQ handily names these as Producers and Consumers. Lets look into how these fit into our architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBmi5Q2PwS2EZmeAviTfSw.png" /><figcaption>Event flow</figcaption></figure><p>A simple and clean architecture.</p><p>The event streams are read by the producer, any transformations are made, eg text to json, and the event is added to a Kafka topic.</p><p>The consumer will then retrieve this event via its topic and process it accordingly.</p><h4><strong>Where can we host this architecture?</strong></h4><p><a href="https://kubernetes.io/">Kubernetes</a>. Whatever the question in DevOps, Kubernetes is usually the answer.</p><p>For all it’s minor annoyances (looking at you YAML), what other system can give us guaranteed uptime, replicated apps, ease of deployment/updates etc etc. What else are we going to use? Docker Swarm….</p><p>So that being said, with K8s we can run multiple instances of the producer and consumer. We can also run the Kafka cluster within the K8s cluster to further guarantee its availability. Here’s what the final architecture diagram looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ei4OK2obobdMFjNMl7phFQ.png" /><figcaption>Proof of concept ready architecture</figcaption></figure><p>Consumer groups are a very useful concept added to our solution. They each read a message from a topic once, so both Consumer Group A and B will both read the same message exactly once. Any other consumers can also read the message (Kafka has a time to live on messages)</p><p>As can be seen, we are writing to both an Audit and UI document store. Audit will be used to replay the event history in case of DR, UI will be a structured store which can be used by any UI or reporting tools.</p><p>Implementation details will follow in the coming articles.</p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-2-d6f1ed37d964">Casper Kafka Event Store Pt 2</a></p><p><a href="https://medium.com/casperblockchain/casper-kafka-event-store-pt-3-2f89a1a1119">Casper Kafka Event Store Pt 3</a></p><p>Carl Norburn is a Software Engineer with Stormeye. He also knows a thing or two about DevOps. Public <a href="https://github.com/stormeye2000?tab=repositories">repos</a>, t<a href="https://twitter.com/stormeye2000">witter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae4bc87aecd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/casperblockchain/casper-event-store-pt-1-ae4bc87aecd9">Casper Kafka Event Store Pt 1</a> was originally published in <a href="https://medium.com/casperblockchain">Casper Association R &amp; D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>