<?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 Paul Fidika on Medium]]></title>
        <description><![CDATA[Stories by Paul Fidika on Medium]]></description>
        <link>https://medium.com/@fidika?source=rss-b49df4663379------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*84x3JnRMBJe-Gqk3YM5EsQ.png</url>
            <title>Stories by Paul Fidika on Medium</title>
            <link>https://medium.com/@fidika?source=rss-b49df4663379------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:05:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fidika/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[Claude Code is an Addiction and a Failure]]></title>
            <link>https://fidika.medium.com/claude-code-is-a-total-failure-ed86256ad209?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed86256ad209</guid>
            <category><![CDATA[claude-fable-5]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[openai-codex]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 21:05:29 GMT</pubDate>
            <atom:updated>2026-09-03T21:21:14.972Z</atom:updated>
            <content:encoded><![CDATA[<p>When Fable 5 came back July 1st (post-ban), I purchased a total of 16 Claude Code Max accounts; $3,360 per month (after tax). You may think this is a lot, but compared to hiring a full-time software-developer (of which I have hired many; my liftetime spend on upwork is $500k+), this is about $19 an hour.</p><p>Why so many? Because it’s cheaper to buy more subscriptions every time you hit a usage limit (which happens once an hour) than to pay for the API. Anthropic loses money on every subscription; if I were paying api-prices for Fable 5, that same usage would’ve cost me $30,000+ per month.</p><p>I’ve been a full-time software engineer for 6+ years now (not counting all the years I spent as a hobbyist prior). I’ve been using Cursor since early-2023, when the company was valued at only $25 million (Elon Musk acquired it for $60 billion — lol — August 2026); I was one of those people telling all my dev friends ‘You have to try Cursor!’ and buying memberships for all of my employees and teaching them how to use it. This was long before corporate American CEO’s discovered it. I’ve been using Claude Code since early-2025 (it completely replaced Cursor; I haven’t used Cursor since).</p><p>So I am very familiar with agentic coding. I would say I’m at the 99th percentile of agentic coders.</p><h4>The 70 / 1 Rule of Software</h4><p>AI coding agents suck, to put it bluntly. I’d waste days fighting with models like Opus 4.8, but when Fable 5 came out, it felt fundamentally different. I was shocked at how good it was (at first). I thought it was finally a big breakthrough.</p><p>I WAS WRONG.</p><p>You may see all of these ‘AI influencers’ posting things like ‘Fable 5.1 has only been out for 3 days, and people are already doing incredible things with it! I made this entire game with only 3 prompts and $250 in Fable 5.1!’ or something. Yes; I’ve seen the demos. They look cool. But these demo-authors, and their viewers, are not software engineers. They don’t understand the 70 / 1 rule.</p><p>In software, you can get 70% of the apparent progress done, with only 1% of the total time required to finish the project. But the remaining 30% requires 99% of the remaining effort.</p><p>Pre-ChatGPT, I knew an indie-game developer; he’d been a dev for 10 years, but never released a finished game. But every weekend-hackathon / indie-game-dev-jam he’d start building some new game. And by the end of this 3-day coding-binge session he’d have some plausibly fun-looking demo for me to play.</p><p>When you’d play these demos you’d be like ‘oh wow, this is really good! You just need to fix a few bugs here and there and it’ll be a great game!’.</p><p>But these weren’t “bugs”, they were fundamental flaws in a shoddy design. The design doesn’t need to be ‘fixed’, it needs to be discarded and rebuilt properly.</p><p>Think about the life of an indie-game developer; how can a dev create a working prototype in 3 days (with no AI), but need another 3<em> years</em> to finish the game and list it on Steam? Where do 99% of all the game-jam demos go?</p><p>THEY DIE.</p><p>They die on the path from plausible-demo -&gt; releasable project.</p><p>The same fate suffered by all of these ‘vibe coded projects’.</p><p>A long trail of dead bodies. A graveyard of git-repos no one visits; an immutable monument to the ambitious yet ill-prepared projects who died along its path.</p><p>Think about it.</p><p>How many vibe-coded demo apps have you seen on X.com, versus how many vibe-coded applications have you actually used and paid for?</p><p>How many people are using a vibe-coded version of Adobe Photoshop? Salesforce? Google search? Notion? Jira? Microsoft Office? Turbotax? Github?</p><p>Claude Code has <em>18.8 million weekly </em>downloads on NPMjs, and none of those devs thought “hey, why don’t I tell claude to make a better version of Jira?” and then finished it and got someone to pay for it? Really? All 18 million of you couldn’t do it?</p><h4>LLMS are NOT Employees</h4><p>In addition to saving time (delegation), the main point of having an employee is <em>encapsulation</em>. You (the boss) can give a high-level directive like ‘build me X’ and then the employee goes off and spends a week working on it, gives you a plausible-demo, you give him feedback, and then you iterate for years this way.</p><p>You don’t need to understand how what a tsconfig.json does, or read through a list of individual API routes and their request / response shapes, or consider Next.js versus tanstack. You focus on the business and marketing aspects, with only a cursory / rough understanding of how the software product actually works. You can trust that your employee made good decisions on your behalf; there’s no need to micro-manage them and second-guess their engineering decisions.</p><p>THIS IS NOT HOW CLAUDE CODE WORKS AT ALL!</p><p>Claude (or any LLM for that matter) is not an employee you can just trust. It needs constant, deep, supervision and micro-management. You cannot trust its system-design make sense. You cannot trust that its implementations (the actual code) make sense. You cannot even trust that the test-suites it writes actually test anything.</p><p>The only solution is the most expensive one; a human with domain-expertise must carefully review and understand everything Claude does and builds. There is no shortcut around this. This is the exact opposite of an employee.</p><p>Claude is not an employee; it is, at best, an assistant that can 10x your productivity by taking the coding-knowledge and domain expertise you already have and letting you apply it more quickly; less monotonous typing of boilerplate code and manual editing every line, every character. It serves as a higher-level code-editor.</p><p>At worst, Claude is a misleading demon; it invents an incorrect but plausible-sounding design. You only half understand what it’s talking about; that’s not you being lazy, that’s you trying to optimize your time. You’re a human; your lifespan is limited. You cannot read its jargon-dense text walls at 500 tokens per minute. So you do a cursory review, and tell Claude to go ahead and build it. You trust it. It’ll be done in a few hours. It sounds great; very well thought out. Then those hours turn into days, and the days into weeks. It still doesn’t work. The whole time Claude is tantalizing you; you’re just one or two bug fixes away, just a couple more rate-limit hits away, and your design will be complete. You’ll be able to release it tomorrow. The world will be amazed and love you for it. You’ll be rich.</p><p>But it’s a lie.</p><p>It was all a lie.</p><p>If you do not understand what Claude code built, then no one understands what Claude Code built, because sure as hell Claude Code doesn’t understand it.</p><p>And this is the final gate that separates AI from “somewhat helpful assistant” and “replaces every knowledge worker on the planet”. This is the last line saving ten’s of millions of Americans from unemployment, and the last moat around hundreds of billion-dollar businesses. Whenthat line is crossed, the level of disruption you’ll see has no analogy in human history.</p><p>You’re probably objecting to my claim at this point. You’re thinking; surely there is some set of prompt templates, skills, or agent harnesses that can fix this. Surely you can fix this with spec-driven development, agent-loops, and carefully written acceptance tests, right? You’ve seen them all over X.com and Github and Y-Combinator’s YouTube channel.</p><p>Okay fine, I’ll share with you a few examples that actually happened to me this week:</p><ul><li>I’m building an inference-platformed called cozy-creator (launches soon, god willing). I wanted to have a well-defined contract between model-shape &lt;-&gt; executable code. That is, can code-A run model-B? That’s it. We want a preflight check before we download GBs of model-weights. We want code-A to clearly state its requirements, and model-B to clearly state what it provides. The design was ‘when publishing code-A, use a meta-device to produce the tensor-schema it uses; this is a mapping of key (layer name) -&gt; tensor-shape + dtype (a state-dict). We can then compare this to the headers of the model’s saftensors file, and see if the two are compatible. Claude designed this out, built it, and it didn’t work. We re-designed and re-built this system twice, over the course of a few weeks actually. It never worked. One bug after another. Finally, I realized that, in addition to the poor implementation, the design was wrong, and the entire system needed to be scraped. You see, python is flexible; code-A does not have a fixed key -&gt; tensor-shape + dtype mapping. That mapping actually changes depending upon the config-files that ship along with the model itself, which is a property of the model, not a property of the code. You cannot exactly match executable-code to state-dict in this way; at best you can compute a lower-bound, which can preflight-catch models that <em>won’t run</em>, but cannot guarantee that it <em>will run.</em> A human with actual domain expertise in this area would have understand this in 15 minutes, not spent weeks trying to create a system that cannot exist like Claude Code did.</li><li>Claude Code literally built a codebase that had more lines of tests than lines of code. The ratio was insane. It ran on every git-push, on every commit. The CI-tests on github took 15–30 minutes to run each time. The Github actions bill was hundreds of dollars per month. You’d think this meant the code was well tested and worked right at least right? Nope. The codebase failed the first time I ran it.</li><li>For cozy-creator, we needed some docker images to run on runpod. Basically, we put pytorch + some dependencies into a docker image, then spawn it on runpod, then install whatever executable code we need in there (the inference code). Simple right? This is literally like, 1 Dockerfile per dependency-profile you want to support, plus a script to run build + push it into dockerhub. That’s it. That’s the entire system. Well somehow Claude Code turned this into an entire Go-package, with some sort of provenance-system, immutable hashes, Dockerfile templates, multiple postgres database tables tracking every supported profile, etc. Honestly, I didn’t waste the time trying to understand the thousands of lines Claude Code wrote before deleting them all. Basiscally, claude could’ve built this entire system with a few Dockerfiles and a script, and instead it built an entire sophisticated build-pipeline, which happened to also not work.</li><li><a href="https://pypi.org/project/gen-worker/#history">https://pypi.org/project/gen-worker/#history</a> ← this was the client library for cozy creator. Over 1.5 months, Claude Code wrote 363,000 lines of code, and pushed 128 separate releases to PyPi. It was buggy and barely worked, so I scrapped it and started fresh ultimately. And <em>this was with me working side-by-side with Claude Code</em>, guiding it through its design and helping it every day, for weeks. I’m not joking.</li></ul><h4>Claude Addiction</h4><p>I’m going to be honest; Claude is an addiction for ambitious productive people. None of its victims want to talk about, but I will. I basically spent my entire summer locked in a room talking to an AI, which mislead me into thinking that we were building something useful and productive. We weren’t. It was a lie and a dead end. The only guarantee was that Anthropic got lots of my money, and I wasted hundreds of hours of time.</p><p>Claude Code is addictive in the same way video games are addictive to ambitious people. Men normally want to feel like they’re making progress towards a meaningful goal. So you turn on a video game and BAM BAM BAM you beat all the enemy-cpus, and your level goes up. You buy new gear. You get more powerful. The dopamine-feedback loop writes itself; you sit-down in front of game for X hours, grind out Y levels, and then at the end of the day you’re like ‘oh wow, look how productive I was! I gained Y levels and next week I’ll be high enough level to get gear-Z’ or something.</p><p>But it’s ultimately meaningless. No one cares how many times you prestiged in Call of Duty Black Ops whatever. No one cares that you have the ultra-rare skin from season 14 in blah blah.</p><p>Claude Code is the same addiction loop. Its victims withdraw from social life. They suffer from coder-induced autism. They think they’re getting closer to finishing the next great whatever-app — a billion-dollar business. They’re not. They’re just an adult-child in a room talking to a fucking computer at $50 per million output tokens, and that computer is filling their head with lies about how they’re just a few bug fixes away, while filling a slop-repo with thousands of commits that will never even get 3 stars on Github.</p><h4>How to Use Claude Code?</h4><p>How do you use Claude Code productively then? Honestly, I don’t know. And neither does anyone else.</p><p>But my best guess:</p><ol><li>Read every repo, every file and folder it produces. Repeatedly ask Claude ‘what does this do’, ‘do we need this?’, ‘how much of this can be deleted?’. Claude is remarkably bad at finding its own slop. It’ll write out the world’s most over-engineered, overly complex system, and then you’ll ask it like ‘find things we don’t need, delete unused code’ and it’ll just whiz right past this over-engineered system and identify some random shit that doesn’t matter. When you start asking it specifics about that system, it’ll start defending itself usually, like “we need to hash every dependency and env in our environment so that our docker-builds are deterministic and reproducible! We need audit logs for all admin actions stored in an append-only database table for observability!” (I’m not kidding, these are real examples.) Claude will fight you over it, but eventually if you know what you’re talking about it’ll give up and delete the thing that should have never existed in the first place. Deleting things is your single easiest win; you don’t have to fix bugs in code that doesn’t exist.</li><li>List off every API-route, every config-value, every env, and go through each of them and ask Claude ‘do we need this? what does this do?’</li><li>Run the actual program. Like, run it; push every button in the UI, invoke every command you can find. You’ll be amazed at how much of it doesn’t actually work. Note every failure in detail. This is probably the least helpful ironically, since it’s usually failing because of slop-code, so Claude can’t actually fix the problem.</li><li>Read every line of code. A bit extreme, but this can be used as a last-resort. Very slow and monotonous. Try to triage and only read the systems where you only have a vague, superficial knowledge of what’s going on in there, or systems that are causing problems.</li><li>Hire real software devs. These are hard to find anymore; nowadays the software devs are writing their resumes with ChatGPT. When I ask them to fix my AI-slop-codebase they run ChatGPT on the codebase and then give me a ChatGPT-generated audit-dump. Most freelance software-devs have forgotten how to write software and instead have turned themselves into ChatGPT-wrappers — even the American ones that charge $100 an hour. (I’m not kidding; this is also a real story.) Really unfortunate.</li></ol><p>Anyway, I hope this wasn’t all too depressing; I wanted to give you guys a dose of reality ad self-reflection, not rob you of all motivation. Let me know what works for you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed86256ad209" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Framework for Measuring Government Efficiency]]></title>
            <link>https://fidika.medium.com/framework-for-measuring-government-efficiency-f546070ce35d?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/f546070ce35d</guid>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Fri, 15 Nov 2024 05:37:28 GMT</pubDate>
            <atom:updated>2024-11-15T05:42:20.280Z</atom:updated>
            <content:encoded><![CDATA[<p>(This is in relation to DOGE; the new Department Of Government Efficiency.)</p><p>The US Federal Government has 15 departments and 436 agencies.</p><p>Most of those agencies fall within one of the 15 departments, but about 70 of these agencies are considered independent, including the SEC, CFTC, NASA, EPA, CIA, etc.</p><p>For each of these agencies, their budgets increase every year; for example, the SEC increased its budget from $1.82B* -&gt; $2.19B from 2014 -&gt; 2024; a modest 1.8% annual increase. (Though President Biden requested -&gt; $2.6B for 2025; an 18% one-year increase¹).</p><p><strong>Incentive Problem: </strong>an agency or department has little incentive to limit or reduce their budget; the more money they have to work with, the better.</p><p>Budget that is unspent is typically subject to expiration, sequestration (automatic budget cuts), and scrutiny. Meanwhile, there is no reward for returning unspent funds to the treasury.</p><p>What is the goal of each of these agencies? The SEC’s goal is <strong>“To protect investors, maintain fair, orderly, and efficient markets, and facilitate capital formation”</strong>, which is… really three separate goals. But let’s just look at the first one: <strong>protect investors</strong>.</p><p>Each agency should have some metric for measuring its own success; the GPRA (1993) and the GPRA Modernization (2010) require agencies to build and track their own performance metrics.</p><p>Unfortunately, the idiot head of the SEC, Gary Gensler, thinks that his metric is <em>not</em> to protect investors, but to issue penalties and enforcement actions.² (This is like a police officer thinking his job is to issue tickets, rather than keeping the roads safe from drunk drivers.)</p><p>In fact, in their 142-page report for 2023, the SEC makes no attempt at <em>even estimating</em> how much money investors lost in 2023 due to investment-fraud — even though this should be their primary metric! Instead, their report mentions data-encryption rates, Diversity and Inclusion goals amongst their employees, publishing investor alerts, and a survey about how many people liked their Investor.org website (I’m not joking).</p><p>Qutie simply; Gary is measuring <em>activity</em>, not <em>outcomes</em>.</p><p>The correct metric for the SEC is very obvious; figure out how much money investors (both individuals and institutions) lose due to fraud every year. Let’s call this their loss function: $0 is a perfect score, and everything else is negative. The SEC’s goal is to minimize this loss function. That is to say; <strong>the SEC’s goal is to stop investors from losing money due to fraud</strong>.</p><p>The <strong>efficiency</strong> of an agency is it’s ability to minimize losses, relative to <em>all</em> assets it uses. Note that we should not look merely at the budget of an agency, but at the total assets at that agency’s disposal — because these assets could presumably be sold off or reallocated elsewhere within the government, they incur an opportunity cost.</p><p><strong>Efficiency = Performance / Assets</strong></p><p>As we increase the total assets available to an agency, we should ideally see its performance increase. We can graph this out like a curve.</p><p>Think of it like this: for every $1 million in extra budget we give to the SEC, how much additional investor funds will be saved? From the point of view of the government, we are essentially <strong>buying investor protection; </strong>the government should think of themselves as consumers of the SEC’s services.</p><p>The SEC should offer a range of prices, along with the expected amount of protection at each level; presumably more spending -&gt; more protection. But at some point, there will be a rate of diminishing returns. Additionally, the government also has a limited funds, so eventually they will have to accept a certain amount of loss as inevitable.</p><p>Repeat this process with each agency. If the federal government has a discretionary budget of $1.7 trillion for the fiscal year, they must choose which goods to purchase, and in what combination, from which agencies.</p><blockquote><em>Aside: Keep in mind that some purchases will not be recurring every year, but must be committed to for many years ahead of time (such as building aircraft carriers or spaceships).</em></blockquote><p>This requires a <strong>tradeoff function</strong>; for example, how important is protecting investors, relative to protecting the environment, relative to exploring space? This sort of preference system should be influenced by voters — these tradeoffs are too abstract for voters to vote on directly, but using surveys of voters and modeling, we can roughly figure out what sort of tradeoffs we ought to make to optimize the well-being of our nation.</p><p><strong>Motivating Efficiency: </strong>Additionally, the heads of each agency should have their compensation tied to their agency’s “profit” to incentivize efficiency. If the new head of the SEC discovers that he can provide the same level of investor protection with half the budget — only $1.3 billion versus $2.6 billion — then he should be handsomely rewarded for this huge windfall. On the other hand, if the head of the SEC gets a $3 billion budget approved, and yet investor protection worsens, presumably he should be fired.</p><p><strong>Conflict of Interest: </strong>It’s important that the measurement of each agency’s loss function be done by an outside agency or part of the government. Currently, each agency defines and measures their own performance themselves, leading to an obvious conflict of interest; this would be like a publicly traded company “auditing” its own financial statements.</p><blockquote><em>Aside: Within this framework, agencies can end up competing with each other. Suppose that the CFTC also thinks its job is to protect investors; in that case, the federal government can choose some combination between buying from the CFTC or the SEC. If the CFTC can offer more protection for the same amount of money, then the federal government must buy more from the CFTC than the SEC. This could also encourage efficiency within departments, in that their budget allocations are tied to how efficient they are. On the other hand, this could also be bad in that it creates resource duplication while confusing investors as to which agency has jurisdiction — but this is already currently the case.</em></blockquote><p><strong>Collaboration Problem: </strong>Agencies do not collaborate well with each other, and do not share information with each other. They mostly operate within their own silos. (Any solution suggestions?)</p><p>— —</p><ul><li>Note: numbers are 2024 inflation-adjusted dollars.</li><li>1: <a href="https://www.sec.gov/foia-services/frequently-requested-documents-2/budget-history-ba-vs-actual-obligations-000s">https://www.sec.gov/foia-services/frequently-requested-documents-2/budget-history-ba-vs-actual-obligations-000s</a></li><li>2: <a href="https://www.sec.gov/files/fy-2025-congressional-budget-justification.pdf">https://www.sec.gov/files/fy-2025-congressional-budget-justification.pdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f546070ce35d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bring You up to Speed with Comfy Creator]]></title>
            <link>https://fidika.medium.com/bring-you-up-to-speed-with-comfy-creator-4870ed706096?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/4870ed706096</guid>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 23:04:02 GMT</pubDate>
            <atom:updated>2024-02-23T23:12:49.601Z</atom:updated>
            <content:encoded><![CDATA[<p>(Note: Comfy Creator is not yet publicly available; expect it mid-March 2024.)</p><p><a href="https://comfycreator.com/">Comfy Creator</a> (formerly <a href="https://void.tech/">void.tech</a>) is a fork of ComfyUI:</p><p><a href="https://github.com/comfyanonymous/ComfyUI">GitHub - comfyanonymous/ComfyUI: The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.</a></p><p>ComfyUI is an inference pipeline for producing media with AI. It started as a pipeline for stable diffusion models (which are models that take text and produce an image), but it’s become much,<em> much</em> broader than that.</p><p>ComfyUI is the best open-source pipeline for producing media currently in existence. It is better than ForgeUI, Automatic1111, Fooocus, and InvokeAI.</p><p>ComfyUI was written by a solo-anon developer, who has since been hired at StabilityAI.</p><p>ComfyUI can be divided up into two parts: the graph-editor front-end, and the inference backend.</p><h3>Front-End</h3><p>the graph editor looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IPolU-HFGlfJSsmkl2e-1A.png" /></figure><p>This workflow (1) loads a model (UNet, CLIP, and VAE pairing), (2) encodes two pieces of text (positive and negative) into embedding space using CLIP, (3) runs the diffusion process on an empty latent image using the positive and negative embeddings as conditioning and the UNet, (4) decodes the image from a latent into pixels using the VAE.</p><p>This workflow compiles down to a workflow-api JSON format that looks like this:</p><pre>{<br>  &quot;3&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;seed&quot;: 156680208700286,<br>      &quot;steps&quot;: 20,<br>      &quot;cfg&quot;: 8,<br>      &quot;sampler_name&quot;: &quot;euler&quot;,<br>      &quot;scheduler&quot;: &quot;normal&quot;,<br>      &quot;denoise&quot;: 1,<br>      &quot;model&quot;: [<br>        &quot;4&quot;,<br>        0<br>      ],<br>      &quot;positive&quot;: [<br>        &quot;6&quot;,<br>        0<br>      ],<br>      &quot;negative&quot;: [<br>        &quot;7&quot;,<br>        0<br>      ],<br>      &quot;latent_image&quot;: [<br>        &quot;5&quot;,<br>        0<br>      ]<br>    },<br>    &quot;class_type&quot;: &quot;KSampler&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;KSampler&quot;<br>    }<br>  },<br>  &quot;4&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;ckpt_name&quot;: &quot;sdxl_anime\\break_domain_xl_v05g.safetensors&quot;<br>    },<br>    &quot;class_type&quot;: &quot;CheckpointLoaderSimple&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;Load Checkpoint&quot;<br>    }<br>  },<br>  &quot;5&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;width&quot;: 512,<br>      &quot;height&quot;: 512,<br>      &quot;batch_size&quot;: 1<br>    },<br>    &quot;class_type&quot;: &quot;EmptyLatentImage&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;Empty Latent Image&quot;<br>    }<br>  },<br>  &quot;6&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;text&quot;: &quot;beautiful scenery nature glass bottle landscape, , purple galaxy bottle,&quot;,<br>      &quot;clip&quot;: [<br>        &quot;4&quot;,<br>        1<br>      ]<br>    },<br>    &quot;class_type&quot;: &quot;CLIPTextEncode&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;CLIP Text Encode (Prompt)&quot;<br>    }<br>  },<br>  &quot;7&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;text&quot;: &quot;text, watermark&quot;,<br>      &quot;clip&quot;: [<br>        &quot;4&quot;,<br>        1<br>      ]<br>    },<br>    &quot;class_type&quot;: &quot;CLIPTextEncode&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;CLIP Text Encode (Prompt)&quot;<br>    }<br>  },<br>  &quot;8&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;samples&quot;: [<br>        &quot;3&quot;,<br>        0<br>      ],<br>      &quot;vae&quot;: [<br>        &quot;4&quot;,<br>        2<br>      ]<br>    },<br>    &quot;class_type&quot;: &quot;VAEDecode&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;VAE Decode&quot;<br>    }<br>  },<br>  &quot;9&quot;: {<br>    &quot;inputs&quot;: {<br>      &quot;filename_prefix&quot;: &quot;ComfyUI&quot;,<br>      &quot;images&quot;: [<br>        &quot;8&quot;,<br>        0<br>      ]<br>    },<br>    &quot;class_type&quot;: &quot;SaveImage&quot;,<br>    &quot;_meta&quot;: {<br>      &quot;title&quot;: &quot;Save Image&quot;<br>    }<br>  }<br>}</pre><p>This JSON is passed to the server-backend (the API).</p><p>If you want to run ComfyUI, checkout Scott Detweiler’s tutorial series (he’s alos a StabilityAI employee):</p><p><a href="https://www.youtube.com/watch?v=AbB33AxrcZo&amp;t=3s">https://www.youtube.com/watch?v=AbB33AxrcZo&amp;t=3s</a></p><p>Unfortunately, ComfyUI’s frontend code is a complete disaster and is built around LiteGraph.js; a barely-maintained 8 year old graph-editor library.</p><p>After spending a month of failing to refactor ComfyUI’s frontend, we discarded all of it and rewrote it in TypeScript + React, buliting it around React-Flow; a modern graph-editor library.</p><p><a href="https://reactflow.dev/">https://reactflow.dev/</a></p><p><a href="https://github.com/comfy-creator/Comfy-Creator">https://github.com/comfy-creator/Comfy-Creator</a></p><p>We are releasing Comfy Creator’s front-end under a source-available, non-commercial license. This is so that users can run Comfy Creator locally, on their own machine, without censorship, while also preventing our competitors from trivially cloning our repo and launching a copy-cat service.</p><p>Locally-running, uncensored models are important to prevent us from becoming Google:</p><p><a href="https://www.forbes.com/sites/roberthart/2024/02/23/elon-musk-targets-google-search-after-claiming-company-ai-is-insane-and-racist/?sh=47d9a4c52423">Elon Musk Targets Google Search After Claiming Company AI Is &#39;Insane&#39; And &#39;Racist&#39;</a></p><p>Comfy Creator’s motto is “Don’t Be Evil”; this was Larry Paige and Sergei Brin’s original, long-since abandoned motto for Google.</p><p>In the future, the entire world will run on AI models; giving individuals control over their own models, rather than gating access to it and using AI to perpetuate our own biases and values, is important for the future of our Democracy and Capitalism.</p><h3>Backend</h3><p>ComfyUI’s backend is written in Python + PyTorch. It takes the above-mentioned JSON and runs it as a workflow. It also provides an API to the front-end.</p><p><a href="https://github.com/comfy-creator/Comfy-Creator-Server">GitHub - comfy-creator/Comfy-Creator-Server: The backend for Comfy Creator; a flexible PyTorch inference graph and gRPC server.</a></p><p>Comfy Creator Server is a fork of ComfyUI, and is released under a GNU GPL 3.0 license; just like the original ComfyUI. GPL 3.0 requires all forks to use the same license as the original.</p><p>ComfyUI was built only to run locally on the user’s machine. It is important that Comfy Creator be able to run locally, but users should also have the option to access more powerful remote GPUs as well.</p><p>There are a half-dozen startups that provide dockerized cloud-hosted instances of ComfyUI:</p><ul><li><a href="https://rundiffusion.com/">RunDiffusion - Automatic1111 in the Cloud</a></li><li><a href="https://openart.ai/">OpenArt - Free AI Image/Art Generator | OpenArt</a></li><li><a href="https://app.flowt.ai/">flowt.ai</a></li></ul><p>However, the cheapest and easiest way to run dockerized ComfyUI is to simply run it yourself:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFnMHbhvWUhE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFnMHbhvWUhE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFnMHbhvWUhE%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/19c39926db6a87185838c2dc97f336d3/href">https://medium.com/media/19c39926db6a87185838c2dc97f336d3/href</a></iframe><p>Services such as RunPod provide one-click deploys of ComfyUI containers using a template:</p><p><a href="https://blog.runpod.io/how-to-get-stable-diffusion-set-up-with-comfyui-on-runpod/">How to get Stable Diffusion Set Up With ComfyUI</a></p><p>However, Comfy Creator is better. We’ve rebuilt the ComfyUI server around gRPC rather than REST, and built a distributed-queue system using Apache Pulsar; users can place a workflow on our queue, and one of the workers in our worker-cloud will pick it up, process the job, and return media to the user.</p><p><strong>Comfy Creator is the first Serverless instance of ComfyUI.</strong></p><p>Serverless Comfy Creator is far more economical than the dockerized ComfyUI our competitors are using; you do not need to spend minutes spinning up a docker-container on a machine with a dedicated GPU, which sits idle most of the time and needs to be shutdown when you’re done; simply submit your workflow to a single API endpoint, get your results, and forget about it.</p><h4>Stable Diffusion Architecture</h4><p>Stable Diffusion 1, 2, and Midjourney were originally built using OpenAI’s DALLE-2 architecture, published April 2022:</p><p><a href="https://arxiv.org/abs/2204.06125">Hierarchical Text-Conditional Image Generation with CLIP Latents</a></p><p>This popularized Diffusion processes, replacing <a href="https://machinelearningmastery.com/what-are-generative-adversarial-networks-gans/">GANs</a> as the new state of the art. Here’s a tutorial on how to build Stable Diffusion from scratch using PyTorch:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZBKpAp_6TGI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZBKpAp_6TGI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZBKpAp_6TGI%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf4c8f9cba8dbbcb19de3ae5128aa18/href">https://medium.com/media/cbf4c8f9cba8dbbcb19de3ae5128aa18/href</a></iframe><p>Diffusion models have become increasingly large over time:</p><p>Stable Diffusion 1: 1B parameters</p><p>Stable Diffusion XL: 3B parameters + (fine tuner)</p><p>Stable Cascade: 3.6B + 1.5B parameters</p><p>Stable Diffusion 3: up to 8B parameters</p><p>DALLE-3 and Midjourney do not disclose their model-sizes, but I consider DALLE-3 and Midjourney v7 to be the best image-generation models currently (as of Feb 2024).</p><h4>Training Your Own Models</h4><p>First, start by picking a model you want to train on top of:</p><p><a href="https://civitai.com/models/112902/dreamshaper-xl">DreamShaper XL - v2.1 Turbo DPM++ SDE | Stable Diffusion Checkpoint | Civitai</a></p><p>Then use <a href="https://github.com/bmaltais/kohya_ss">Kohya-SS</a> to create a LoRA that modifies the original model however you like. A LoRA is a small set of layers that is trained to modify the original, much larger model, in desirable ways. It is much easier to train 9M parameters (a typical LoRA size) from scratch than to fine-tune 3B parameters (SDXL size).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTpuDOsuKIBo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTpuDOsuKIBo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTpuDOsuKIBo%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/11f34241a84c242895a6cdfb9ae0c51a/href">https://medium.com/media/11f34241a84c242895a6cdfb9ae0c51a/href</a></iframe><p>-</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4870ed706096" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coin23 on Sui: New Controls for Creators and Merchants]]></title>
            <link>https://fidika.medium.com/coin23-on-sui-new-controls-for-creators-and-merchants-89a99eedb69b?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/89a99eedb69b</guid>
            <category><![CDATA[aptos]]></category>
            <category><![CDATA[sui]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solanas]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 22:44:14 GMT</pubDate>
            <atom:updated>2023-07-17T22:55:59.635Z</atom:updated>
            <content:encoded><![CDATA[<p>Coin23 as in ‘Coin 2023’; the 2023-edition of Sui-Coin. This name is a reference to “Token22” or “Token 2022”, which is the new Token-program for Solana (which is still in development even though 2023 is now half-over). We’ve replicated all of Token22’s features*, and added a bunch more (Token22 does not, for example, have any merchant-specific functionality).</p><p>Why Coin23 exists:</p><ul><li>In Sui, Coin is hard for client-applications to work with: a person may own dozens of coins, forcing client-applications to (1) query their balances, and (2) include instructions to split / merge coins as needed to get the balance they need to pay for something.</li><li>Coin does not meet the business requirements of Circle. Circle needs to have freezable balances. On Ethereum or Solana, each person’s USDC-balance is a root-accessible account, and Circle can flip a ‘freeze’ boolean-parameter at any time. Because Coin is a storable Move struct, it is trivial to render it inaccessible to Circle by wrapping it in a non-compliant struct. Circle will never be able to support native-USDC on Sui as a Coin object.</li><li>Coin is a single-writer object, meaning that it is inaccessible to every person on the Sui blockchain other than the owner’s keypair. This means you cannot, for example (1) have an organization delegate spend-authority to an employee, (2) grant a merchant rebill authority, or (3) allow a merchant to issue a hold against an existing balance.</li></ul><p>Coin23 fixes all of these issues. It takes the Balance from within any Coin and places it inside of a shared object called Coin23. Because Coin23 and Coin share the same Balance it’s trivial to convert between the two; a Coin object can be converted to a Coin23 object and vice-versa (subject to some caveats—see below).</p><p>Coin23 adds new creator controls. The current creator-control-settings for a currency are are stored inside of the CurrencyRegistry; a global shared object. Creators of already-existing currencies can assert their control over their own currency by using their existing TreasuryCap. Currencies do not necessarily need any creator controls in order to be used by end-users (for example, SUI will never have any creator controls). New creators of currencies can opt-in to adding creator controls to their currency using a One-Time-Witness they get in their init-function when they publish their currency-defining module for the first time.</p><p>All of the following creator controls are configurable; they can be turned on or off, as needed.</p><p><strong>New creator controls:</strong></p><ul><li><strong>Freeze:</strong> Creators can freeze and unfreeze Coin23 objects. When frozen, users cannot withdraw from or deposit to the available_balance portion of their Coin23 account. This is useful for currencies like USDC, whose issuer, Circle, uses balance-freezes to comply with law-enforcement requests. Existing holds are not affected by a freeze (more on that below).</li><li><strong>Withdraw:</strong> Creators can withdraw balances from Coin23 objects. This is useful for game-developers who might want to punish hackers who found an infinite-money glitch, or recover stolen funds. It also allows game-developers to use a server to debit a player’s virtual-currency without the owner signing a transaction. Aptos’ CoinStore object implements this behavior called BurnCapability; when you submit a transaction, the network withdraws your APT balance and burns it to pay for the gas-fee.</li><li><strong>Transfer Fees:</strong> creators can charge basis-points per transfer, giving currency-issuers a source of royalty-revenue, or of implementing a supply-reducing burn mechanism.</li><li><strong>Non-Transferable:</strong> Creators can prevent the transfer of balances between Coin23 accounts. Balances can still be withdrawn by the creator, or spent by creator-defined functions. This allows game-developers to create virtual currencies that cannot be transferred between players; this is useful if you only want players to be able to buy currencies from the game itself (only primary sales, no secondary sales), or if you want to prevent players from being ‘power-leveled’ by receiving tons of money gifted to them by higher-level players.</li><li><strong>Non-Exportable:</strong> as mentioned previously, the Balance of a Coin23 object can be exported back into a Coin if the creator allows it. However, once outside of Coin23, a Balance is free from all creator-imposed controls. As such, creators are allowed to turn off the exporting of Balance.</li><li><strong>Whitelisted DeFi:</strong> unfortunately, Sui Move DeFi uses store. This means that, in order for you to trade coins on an orderbook for example, you must first remove Balance from within Coin23 and place it inside of the orderbook object. As stated above, this means the creator loses access to their own currency, hence the creator may not want to allow this. How can a creator safely compose their currency with a DeFi program, while also remaining in control of it? That’s why I created a ‘DeFi Whitelist’ feature. This allows the creator to specify programs that are allowed to export Coin23 balances which are not publicly exportable (in case the balance is publicly exportable, there is no point in having an export-program-whitelist). The idea is that the DeFi program honors creator controls, and does a Coin23 → DeFi → Coin23 swap, ensuring that the end-user is never able to use DeFi as a backdoor export to bypass creator-controls.</li></ul><h3>Merchant controls:</h3><ul><li><strong>Rebill:</strong> users can give merchants the ability to withdraw from their Coin23 at regular intervals. This is useful for recurring services like Netflix. Users can specify a maximum amount per interval, and a rebill interval. Users can see upcoming rebills, and cancel them at any time. Merchants are responsible for submitting transactions themselves when a rebill is available; money is not automatically withdrawn. Merchants do not have to withdraw the maximum amount available to them; this is useful for usage-based services like utilities, where the total balance due is not known until the end of the month.</li><li><strong>Held Balances:</strong> users can grant merchants a temporary hold on a portion of their available-balance. Held balances cannot be frozen or taken by creators; they are in the control of the merchant to either withdraw from, or release, at the merchant’s discretion. Holds expire after a specified time. After expiration, the end-user must ‘crank’ their Coin23 account to move expired held-funds back into their available-balance. Holds are useful for merchants who want to guarantee they will be paid, but do not know the final amount, such as hotel-room stays or car-rentals.</li><li><strong>Payment Memo:</strong> end-users can include payment-memos with their transactions. These are unique payment identifiers, which help merchants match transactions to invoices / payment requests. In other words, payments are attributable to some off-chain state (such as an invoice-system). They also help end-users link their payment-history to specific merchants, so they have a record of who they paid and for what.</li></ul><p>Additionally, Coin23 may be easier to use than Coin in that client-applications can simply specify a static, root-level object-id to withdraw from, and have the owner of that object sign the transaction; no need to combine and split multiple Coin objects.</p><h4>Downsides</h4><p>On the downside, Coin23 does not integrate well with existing DeFi programs. If Coin23 is adopted, DeFi programs will need to be refactored to withdraw from, and deposit back into, Coin23 objects rather than using Coin or Balance.</p><p>Another downside is the use of a global CurrencyRegistry object. This is normally read-only, allowing parallel transactions, but modification-transactions to it will be blockers to all other Coin23transactions, potentially causing all consensus on allCoin23objects to be serialized until the write is processed. Unfortunately this is due to the fact that we cannot prove to the runtime that a Currency-Configuration for a given currency <em>does not</em> exist. I.e., if a creator creates a currency with a transfer-fee, the runtime cannot know this unless it reads that currency’s configuration file as an argument to a function. But the creator of the currency may have never created such an object, leaving the currency publicly accessible (no creator controls). As such, we must make the configuration-object input an optional parameter, but then the creator of this transaction can simply not supply a legitimate configuration object that does exist in order to bypass creator controls.</p><p>This relates to Sui’s data-access model. In Solana, account-addresses are deterministic functions of the mint-address and the owner’s public-key, meaning that if an account exists, you know where to find it. Unfortunately Sui object-ids do not have this property. Furthermore Sui lacks runtime data-access provided by Aptos’ global_borrow except from inside of an object’s dynamic fields; the CurrencyRegistry object provides exactly this deterministic-address lookup and runtime data access, allowing the runtime to prove that a Currency-Control for a given currency in fact does _not_ exist.</p><h4>Further Thoughts</h4><p>Note: the only Token22 feature we’re missing in Coin23 is confidential transfers; unfortunately Sui-core had Bulletproofs and Pedersen Commitments prior to mainnet, but these were removed shortly before mainnet because they weren’t production-ready (?). Once these modules are brought back, confidential-transfers can be added to Coin23 (if people want them?). Anonymous transfers (ring signatures?) would also be interesting to explore in the future.</p><p>You can read the most up to date iteration of the module here, which will still change in the future:</p><p><a href="https://github.com/capsule-craft/capsules/blob/master/packages/economy/sources/coin23.move">capsules/packages/economy/sources/coin23.move at master · capsule-craft/capsules</a></p><p>Please leave your thoughts and point out any errors or how this can be improved! This is an initial draft, and can be reworked as needed to accommodate a wide set of use-cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89a99eedb69b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sui Improvement Proposals 2.0]]></title>
            <link>https://fidika.medium.com/sui-improvement-proposals-2-0-110973ef1fbb?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/110973ef1fbb</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[mysten-labs]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[sui]]></category>
            <category><![CDATA[move]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 16:54:53 GMT</pubDate>
            <atom:updated>2022-11-17T02:11:30.371Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been working with Sui Move for about a month now. I’d like to make some suggestions for improvements:</p><h3>More Accurate Terminology</h3><p>‘Shared object’ and ‘owned object’ can be a bit of a misnomer. More accurate terminology is ‘multi-writer’ and ‘single-writer’ objects.</p><p>Many ‘shared objects’ can in fact be ‘owned’ by someone, like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b885cd0f614e8340bd7c77f74486dfa2/href">https://medium.com/media/b885cd0f614e8340bd7c77f74486dfa2/href</a></iframe><p>Here the Sui-defined owner is everyone, while the module-defined owner is whatever address is inside of the ‘owner’ property.</p><p><strong>New terminology:</strong></p><ul><li>Single-Writer Object: an object that can only be used in a transaction by one person; the Sui-defined owner.</li><li>Multi-Writer Object: an object that anyone can reference mutably in a transaction.</li><li>Sui-defined owner: the account specified in Sui’s ownership system.</li><li>Module-defined owner: the module’s system of ownership; if one exists, and however that is defined. Origin-byte is calling this ‘logical ownership’ I believe.</li><li>Nano-Sui: the smallest fractional unit of a Sui-coin (9 decimals of precision). I like this better than ‘Myst’.</li></ul><h3>Pass Shared Objects by Value (not just reference)</h3><p>Currently shared (multi-writer) objects can only be passed by reference, not by value (consumed). This prevents shared-objects from being deleted when they are no longer needed. It’s important shared-objects be deletable, otherwise Sui’s head will be filled up with lots of useless shared-object wrappers from past transactions. People will be incentivized to delete shared objects so that they can claim the storage refund.</p><p>For safety, this pass-by-value behavior should only be allowed by the module that defined the shared object. The follow operations should be available:</p><ul><li>Delete the object</li><li>unshare the object (more on this below)</li></ul><p>Storing a shared object, either with a wrapper struct, or by placing it inside of a dynamic field, should not be allowed, unless the object is unshared first.</p><p>Deleting can be handled in the usual way:</p><pre>let SharedObject { id, field1: _ } = shared_object;<br>object::delete(id);</pre><p>Note that, currently in Sui, every uid must be deleted after it has been taken from a destructured object; it cannot be used to create a new object with that same id. This sort of type-transforming behavior might be interesting however.</p><p>(There was a github issue by Sam Blackshear for this but I can’t find it???)</p><h3>Unshare Objects</h3><p>This could be something like:</p><pre>transfer::take_shared(shared_object, new_owner);</pre><p>again, this would require the shared object to be passed by value, which can only be done by the module defining the object. Furthermore, this operation consumes the object, which means that any storing (wrapping or dynamic field) operations will have to be done as a separate transaction afterwards. (This limits composability but might be more practical.)</p><p>This would allow objects to switch from multi-writer mode, back to single-writer mode, as needed. For example, if you have a game item that you want to allow a friend to use, but then you want to be able to take full ownership of it again at some later point in time. If shared objects can be deleted, this behavior is already possible by simple destructuring the object, deleting its id, and then packing it into a new owned object (although it will have a different UID).</p><p>This is behavior is already sort of possible, in an inelegant way; you can create a wrapper object around T (your owned object), then share Wrapper { T }, add functions that allow for anyone to borrow T temporarily. Then you no longer want to share T, you remove T from the wrapper. However, this is rather clunky and complicates everything and has poor composability (you cannot use entry functions; you would need to wrap entry functions with another module that borrows a reference to T…).</p><p>Ideally the unshared object’s UID should stay the same, but if you must change its UID, that’s okay too.</p><p>We may also want to add a transfer::is_shared_object(object_ref) function as well, that returns a bool depending on whether an object is shared or owned. This would enable some conditional behavior.</p><h3>Unfreeze Objects</h3><p>A common pattern I’ve noticed is something like:</p><pre>public fun use_sword(sword: &amp;mut Sword, config: &amp;GameConfig) {</pre><p>this GameConfig struct can be a big struct that specifies parameters, such as how much damage a sword should do, how much durability it should have, etc.</p><p>Ideally, this GameConfig should be a frozen, immutable object. Then, if the sword is also an owned (single writer) object, then all transactions using this function can be simple transactions (no need for consensus). This is ideal.</p><p>However, what if the developer wants to tweak something in the GameConfig? In that case, they would have to create a new GameConfig, and convince everyone to use this new config file instead, although the old GameConfig will always be around, meaning that users can ‘cheat’ and continue to use the old game-configuration. What is the developer to do? I suppose they could deploy a new, updated module, then migrate everyone over to that…</p><p>The other way around it would be to make the GameConfig a shared (multi-writer) object, that only the game devs can edit. Unfortunately, this forces all game transactions to now go through consensus (which takes longer and costs more), for no reason really.</p><p>A good middle-ground would be to add an ‘unfreeze’ ability.</p><p>transfer::unfreeze_object(object);</p><p>This should only be doable by the module that defines the resource. Furthermore, the transaction should have to be finalized before any edits can be done. In this case, effectively ‘frozen’ objects are not truly immutable they are merely ‘rarely ever written to’. In the case of a GameConfig, which is only changed once every few weeks, this works great; the object can be unfrozen, edited, then re-frozen, in 2 or 3 transactions.</p><h3>Enumerable Table</h3><p>Because table and object_table both use the same key and value types for all entries, it’s possible to create an index of keys, which can just be a simple vector. This would make it possible to iterate over all items in the table.</p><p>For bag, object_bag, dynamic_field, and dynamic_object_field, these allow heterogenous key and value types, so an index is not really possible unfortunately.</p><p>Move’s strict static-type system, where every type must be specified on compile, makes it impossible to be able to fully explore an arbitrary dynamic_field at runtime.</p><h3>Notes on Static Typing in Move</h3><p>I’ve seen a couple people asking for type-reflection, like converting the type of an object to a string at runtime. As far as I can tell, without major changes to the Move VM, this sort of behavior would be useless even if you got it. The Move VM does not allow any sort of conditional types, it does not allow branches where different types are used for the same variable, it does not allow types to be used generically. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3115f9fe4b4247181aba65529e1f0c40/href">https://medium.com/media/3115f9fe4b4247181aba65529e1f0c40/href</a></iframe><p>It would be nice if the Move VM could support this sort of behavior, and most new Move developers would expect this code to work, but adding this sort of behavior would be a big ask (I think?).</p><p>Dynamic_fields are kind of a clever way of working around this limitation within the Move VM, but they’re also severely limiting, in that the application code must now memorize, and get right, the type of value corresponding to each key when reading stored dynamic fields. This limits its practicality.</p><h3>Expanding Dynamic Field Functions</h3><p>As mentioned above, the above code will not work within Move. However, we can enable this sort of behavior at a lower level using native functions; essentially rather than doing these actions within Move, we do them within the Rust-layer that exists inside the Move VM.</p><p>Here’s a list of potential dynamic field operations:</p><ul><li>dynamic_field::drop(parent, key): drops the value and key, assuming the value has the ‘drop’ ability, otherwise this aborts.</li><li>dynamic_object_field::remove_and_transfer(parent, key, owner): this removes the value at ‘key’, drops key, then transfers the value to the new owner, using polymorphic transfer.</li><li>dynamic_field::rekey(parent, old_key, new_key): changes the key for value from old_key to new_key</li><li>dynamic_field::move(old_parent, old_key, new_parent, new_key): moves the value from a dynamic field on the old_parent, to a dynamic field on the new_parent.</li></ul><h3>Script Transactions</h3><p>Diem had the notion of ‘scripts’, which are like ephemeral modules that are only executed once. Sui has the concept of transaction bundles, which put several entry-function calls together into one atomic unit (meaning that if one of the calls fails, all the other transactions revert), which is great, but it’s not the same thing.</p><p>It’s true that a user can deploy a module, then call it, but that’s two transactions, and modules are all immutable on Sui, meaning they cannot be deleted after the fact in exchange for the storage refund. That means that any script-transactions using this ‘hack’ will be slower and more expensive than they need to be, and they’ll also clog up Sui’s head. It would be better if Sui brought back script transactions.</p><h3>Multiple Signers for a Transaction</h3><p>Are there plans to support this in the future? It would require refactoring tx_context::signer() to return a vector of addresses rather than a single address.</p><h3>Rotating Private Keys</h3><p>This was an original feature from Diem, and I’d like it if it were possible for Sui to rotate keypairs. Basically, every user has an address (their first public key), which stays constant, and then they can rotate their keypair whenever they need to. This means that if someone thinks their private key has been compromised, they can rotate their key to a new one before the attacker can use their old private key. Currently, as in Solana, the only way to change your private key would be to transfer all of your resources from your current account to a newly generated account; which is impossible mostly since not all resources are transferrable, and also infeasible, because accounts will eventually own thousands of resources.</p><h3>Timestamps</h3><p>Down to the millisecond would be ideal</p><p><a href="https://github.com/MystenLabs/sui/issues/226">https://github.com/MystenLabs/sui/issues/226</a></p><h3>Greater Balance Precision (u128)</h3><p>Consider mkaing Balance.amount u128 rather than u64. This is because Ethereum and most ERC20 tokens have 18 decimals of precision, which is definitely excessive, but if you’re bridging from Ethereum to Sui you’ll want to be able to represent exact balances. With u64’s we’d be forced to truncate at least a few of those precision-decimals in order to accommodate larger balances of ETH.</p><h3>Restricted-Transfer Problem:</h3><p>The gist of this is; allow key-only objects to be stored within a dynamic_object_field, but only by the module that defined the object. This allows for key-only objects to be used as dynamic_object_fields. Once you add the ‘store’ ability to your objects because you want to enable this behavior, this allows any module to wrap the object, polymorphic transfer it, and put it inside any dynamic_field, which may be undesirable to the module-author.</p><p><strong>Status:</strong> Mysten Labs has debated this idea, and mostly rejected it.</p><p><a href="https://github.com/MystenLabs/sui/issues/5584">https://github.com/MystenLabs/sui/issues/5584</a></p><h3>Misc. Expansions for Move / The Move VM</h3><ul><li>Make strings (both ascii and utf8) into primitive object types, so that they can be used as arguments to entry functions and developers don’t need to perform an extra step on every vector&lt;vector&lt;u8&gt;&gt; input.</li><li>Make options primitive objects, so that they can be used as arguments to entry functions, such as an optional string that can be filled in with a default value. Ideally, options should also be able to store references (although this would require a different type of non-storable, temporary-option that would has to be dropped at the end of the transaction). For example, if I’m calling into a function, like public fun optional_parameter(maybe: Option&lt;&amp;mut SomeObject&gt;) this will not work. My intention here is to allow this function accept an optional mutable reference to some object, but because structs (including Option) cannot store references, this is impossible.</li><li>Add the Modulo operator natively to Move; I’m surprised this was omitted.</li><li>Shorthand vector initialization. We should be able to do let vector = [1, 2, 3, 4, 5, 6], which is much more concise than having to do 6 separate push calls.</li></ul><h3>Developer Experience Suggestions:</h3><ul><li>Add pre-built binaries for various platforms (Linux, Windows, Mac) for the Sui CLI for each release.</li><li>Add a Sui faucet into the cli, which is ideally called automatically when you generate a new keypair on chain. (It should be rate-limited in some way however — I imagine that was the logic behind the Discord faucet.)</li></ul><h3>Transaction Memos</h3><p>In an entry transaction, be able to attach arbitrary data to the ctx (Transaction Context) as a sequence of bytes. This data can be read by on-chain and off-chain modules.</p><p>For example, an exchange might instruct depositors to do a simple transfer of coins to a fixed address (sui::transfer::transfer(coin, address)), and attach a memo to the transaction that specifies the hashed account-number that deposit was intended for.</p><p>You could additionally use it to supply custom module-specific security. For example, suppose you want to deposit coin into another person’s vault, and this vault requires permission. It would work something like:</p><pre>public entry fun deposit(vault: &amp;mut Vault, coin: Coin&lt;Sui&gt;, ctx: &amp;TxContext) {<br>  if (vault.require_permission) {<br>    assert!(check_permission(vault, ctx), ENOT_PERMISSION);<br>  };<br>  coin::merge_into(&amp;mut vault.balance, coin);<br>}<br><br>public fun check_permission(vault: &amp;mut Vault, ctx: &amp;TxContext): bool {<br>  let signature_bytes = tx_context::borrow_memo(ctx);<br>  let owner = &amp;vault.owner;<br>  let nonce = &amp;vault.nonce;<br>  let sender = tx_context::sender(ctx);<br>  // Check that the bytes match a signature from address<br>  ...<br>}</pre><p>the permission-checker do a cryptographic check like “did the owner-address produce a valid signature of (sender_address + vault_nonce)”? If yes, then return true, otherwise return false.</p><p>The bytes could be included explicitly as an argument in the deposit function, but then we’d have to add arguments to both our functions, and a lot of the time we won’t be using those bytes, so callers would be specifying lots of empty u8 vectors for no reason.</p><p>Additionally we could allow functions to attach variables to ctx, and then pass those down to other functions further down on the chain, without needing to explicitly pass every variable. This would work much like contexts in React do, where you wrap functions in a context, and inside of that wrapper all children can access variables within the wrapping-context. (Because ctx does not have a UID, we are currently unable to use dynamic fields for this purpose.)</p><h3>Use A Dual-Native-Coin Model</h3><p>Similar to xDai (now Gnosis-chain) have two native coins:</p><ol><li>Sui-resource: represents a fractional ownership of Sui’s total capacity. This is used to pay for transaction fees and storage. Could possibly be a stablecoin, like dollars.</li><li>Sui-ownership: this token is used to stake, representing control of the network. Supply of this is constant and does not increase or decrease. The sui-resource coins used in transactions are paid to ownership holders.</li></ol><p>If the resource coin is a stablecoin, we could say 1 coin = $1 USD (permanently). Then the cost of the network varies through time, i.e., some days 1 coin = 1,000 transactions, but under heavy usage 1 coin = only 100 transactions. Some days 100 KBs of storage = 1 coin, but other days 100 KBs of storage = 10 coins.</p><p>If the resource coin is not a stablecoin, and its price is allowed to vary, it should be locked to some other resource, i.e., 1 resource coin = 100 KBs of storage.</p><p>The Sui-ownership coins represent ownership and control of the network. If there are 1,000 resource coins consumed in a day by transactions, totally $1,000 USD, then those are divided up and given proportionally to the ownership-holders.</p><p>Resource-coins could be thought of as a currency (dollars) used to buy a company’s services, while Ownership-coins could be thought of as equity (shares) in that company.</p><p>I can’t think of any downside to this model, other than the SEC being more likely to raise a stink because the ownership-coins look more like a security now. But we should design our systems around logic and function, not arbitrary governmental whims.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=110973ef1fbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sui Improvement Proposals]]></title>
            <link>https://fidika.medium.com/sui-improvement-proposals-b76c3409fe01?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/b76c3409fe01</guid>
            <category><![CDATA[move]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[aptos]]></category>
            <category><![CDATA[sui]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Thu, 29 Sep 2022 07:00:51 GMT</pubDate>
            <atom:updated>2022-09-29T07:03:39.573Z</atom:updated>
            <content:encoded><![CDATA[<p>Sui is very novel, but I fear it’s too inflexible to be practical. The following ideas are suggestions for improving Sui’s programming model; I don’t go into how to implement these proposals.</p><h3>Restrict The Transfer Function</h3><p>sui::transfer::transfer is just too powerful; this function allows <em>any</em> resource-owner to transfer <em>any</em> resource to <em>anyone</em>. There are many cases when this might not be desirable.</p><blockquote><em>💡 </em><strong><em>Example:</em></strong><em> USDC. Circle (issuer of USDC) maintains the ability to freeze user-balances at the request of legal authorities, in order to fight money laundering and theft. This is a must-have feature for Circle.</em></blockquote><p>On Aptos, the aptos_framework::coin module has a function, coin::initialize&lt;CoinType&gt;() which creates a new coin type and returns a freeze_cap&lt;CoinType&gt; to the creator address.</p><p>A user’s coin is stored inside of a CoinStore struct, which has a ‘frozen’ state, which defaults to false.</p><p>Anyone with that freeze_cap (usually the creator address) can call coin::freeze_coin_store&lt;CoinType&gt;(address, &amp;freeze_cap) to freeze the CoinStore of the specified user address. Once a CoinStore is frozen, any calls by that user to coin::transfer, coin::deposit, and coin::withdraw will fail. This means that the user’s coin is inaccessible. The creator can reverse the process with a call to coin::unfreeze_coin_store.</p><p>This is a very simple, intuitive implementation. For an indexer, it’s trivial to see who has the ability to freeze or unfreeze coin stores, and to see which user’s CoinStores are frozen.</p><p>Sui has a much more complex attempt at implementing the same behavior, called regulated_coin:</p><p><a href="https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/fungible_tokens/sources/regulated_coin.move">https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/fungible_tokens/sources/regulated_coin.move</a></p><p>First, it defines a RegulatedCoin struct, which has a balance and a ‘creator’ address; this is the REAL owner. If 0x123 owns an instance of RegulatedCoin on Sui (let’s call it r_coin), but r_coin.creator == 0x789, then 0x123 will be unable to do a lot with regulated_coin, because he’s not the “true” owner. That is to say, regulated_coin defines and maintain its own ‘owner’ field, separate from Sui’s concept of ownership.</p><p>When someone creates a RegulatedCoin type, they receive a treasury_cap, and creates a shared object called Registry. This registry contains a vector of banned addresses.</p><p>If 0x789 wants to send a RegulatedCoin to 0x123, he must call my_coin::transfer(&amp;registry, &amp;mut coin, value, 0x123), where ‘coin’ is an instance of RegulatedCoin; this function takes the coin’s balance and wraps it inside of a Transfer struct, which is transferred to its new owner, 0x123. This transfer struct includes a “to” field, which will be 0x123’s address. Note also that the &amp;registry is required; the transfer function will check against this registry to make sure neither the sender nor receiver’s addresses are on the ban list.</p><p>0x123 must then call my_coin::accept_transfer(&amp;registry, &amp;mut my_coin_balance, transfer_struct), which will remove the balance form the Transfer wrapper, and place it inside of his my_coin_balance. Because 0x123 is the ‘true’ owner of the Transfer struct, if 0x123 were to transfer it to 0x456, 0x456 would be unable to unwrap the Transfer struct using accept_transfer because their address isn’t on it; 0x123 is instead.</p><p>Notice how much worse this solution is compared to Aptos’ solution:</p><ul><li>This solution is more complex, and more difficult to understand. It essentially circumvents Sui’s built-in ownership model and makes up its own ownership model.</li><li>There is now a single ban-list vector which must be kept in memory and constantly checked against, whereas Aptos has a bunch of small unrelated objects, allowing better memory-concurrency. The use of a shared object also means that all transfers must now go through Sui’s consensus, which means these transactions cannot take advantage of one of Sui’s biggest strengths.</li><li>Vectors in Move can only hold 65,536 entries, meaning eventually Circle will be unable to ban new RegulatedCoin addresses simply because its ban-list vector is full.</li><li>Transfer now require two transactions; first a transfer transaction from the sender, and then an accept_transfer transaction from the receiver. In Aptos, only the sender needs to do a transaction (assuming the receiver already has a CoinStore available to be deposited into).</li></ul><p>More importantly; this doesn’t really <em>solve</em> the problem. This entire ban list can be circumvented by a simple ‘proxy ownership service’. 0x1 could deploy a module which accepts all regulated_coins sent to it, setting itself (0x1) as the ‘owner’, and then it immediately uses sui::transfer::transfer (not abc_coin::transfer) to send these coins back to the original sender. These regulated coin owners are then free to use sui::transfer::transfer to send regulated coins to each other as they please, even if they’re banned. When they want to take full ownership of the regulated coin again, they simply sui::transfer::transfer it back to 0x1, requesting it to be sent to an unbanned address they control. 0x1 sets the new unbanned address as the new owner, rather than itself, and immediately transfer it, ending the proxy ownership.</p><p>This system effectively defeats the entire purpose of regulated_coin existing.</p><p>The fundamental problem is that module-creators have <em>no real control</em> over the resources they create after they create them and give them to a user; the user has complete, irrevocable control at that point.</p><h4><strong>Proposal:</strong></h4><blockquote><em>💡 Restrict sui::transfer::transfer to being used </em>only within the module that defines the struct being transferred<em>. This will allow module-authors to control how their resources are transferred.</em></blockquote><p>Module-authors can choose to build-in a my_module::transfer() function if they want, or to make an object completely non-transferrable.</p><h4><strong>Downside:</strong></h4><p>I realize that Sui wants generic, system-defined asset-transfers, so perhaps we can give my_module::transfer functions some special status within Sui, or require transfer functions to satisfy a certain specification (spec file).</p><p>The beauty of sui::transfer::transfer is that it allows ownership to be transferred generically; I don’t need to know what the asset type is that I’m transferring, or where it’s coming from. This allows Sui to be very generic.</p><p>Having to replace the universal use sui::transfer::transfer with use coin_address::coin_name::transfer for EVERY struct type I intend to use would make Sui less generic, and less useful. So perhaps we should standardize every module’s transfer function signature, but leave the implementation logic up to the module authors; for example, for a non-transferrable resource, the implementing body would simply be assert!(false, 0); . For regulated coins, we would simply use regular coins with a ‘frozen’ boolean property that can be checked inside of its own transfer function, similar to the Aptos example above.</p><h3>Allow Modules To Use Struct-Types They Defined, Even Without User Permission</h3><p>This is related to the above problem; once a module creates and transfer a resource to a user, it has no control over it.</p><p>In traditional move, a module can use global-memory operators like borrow_global_mut&lt;MyResource&gt;(address) or move_from&lt;MyResource&gt;(address), which allows modules to grab resources that they defined from a user’s global storage, and modify them, without the user signing the transaction. This is amazingly flexible.</p><p>For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7d40ee927cda8a686e72569196166c0/href">https://medium.com/media/f7d40ee927cda8a686e72569196166c0/href</a></iframe><p>This allows 0x1 to create a Budget object, and give it to 0x2. 0x2 can then later use this Budget object to redeem Money from 0x1’s account. Furthermore, 0x1 can revoke 0x2’s Budget at any later time.</p><p>How can we reproduce this in Sui? We could obviously just make Money and Budget shared objects, and then add an ‘owner’ field to both them, which we always check against to figure out who the “real” owner is, but for gas efficiency and parallelization we always want to use owned-objects whenever possible; it seems silly to create a “Shared Object” that can only really be used by one or two persons.</p><h4><strong>Proposal 1:</strong></h4><blockquote><em>💡 Bring back Move’s global storage operators. The sui::test_scenario package already has a bunch of these methods, like take_owned or take_owned_by_id specifically for Sui. These could be very useful in production.</em></blockquote><p><strong>Downside:</strong></p><p>I like that Sui consists solely of pure functions, in the sense that functions are solely dependent upon their inputs, and do not use or modify any global storage. This also provides safety guarantees that a function can, at worst, only steal the objects you gave it as inputs. In Aptos, if you sign a malicious transaction, that function now has your signer object, which it can use to do literally anything with your authority, including draining your wallet.</p><p>That is to say, Sui functions are easier to parallelize (in terms of memory), the state of the blockchain is easier to shard, and transactions are easier to simulate and are safer to sign blindly.</p><p>Perhaps we can accommodate this:</p><h4><strong>Proposal 2:</strong></h4><blockquote><em>💡 Allow structs to contain mutable and immutable references to other structs stored in global storage.</em></blockquote><p>This would look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b95e9ce31d8bb15cfe433b063899cdcd/href">https://medium.com/media/b95e9ce31d8bb15cfe433b063899cdcd/href</a></iframe><p>The reason why this behavior wasn’t included in the original version of Move was because they couldn’t figure out how to serialize references. However in Sui Move references to other global storage objects is easy because every struct with the key or store ability has a unique global identifier.</p><p>These references would essentially act as storable keys, which can be recalled from global storage later, allowing the the owner of these keys to access other people’s globally-stored objects.</p><p>It could get risky if these stored references could be used <em>across</em> modules; imagine Coin giving a reference to its balance to a function in malicious_module; the function then uses the balance and ends execution. Currently, the balance-reference is then dropped from memory, and that module cannot use the balance again unless we call it and give it another reference. BUT if the malicious_module could store this reference, it could access the user’s coin balance again and again in the future, stealing funds in unpredictable ways.</p><p>Because of this, we should have the rule that a module <em>can only store references to other structs which it also defines</em>, as is the case in our above example.</p><p>But wait; I have even more wacky ideas if you don’t like that one.</p><h4><strong>Proposal 3:</strong></h4><blockquote><em>💡 Allow functions to define type-signatures that can accept objects that are </em>neither owned by the transaction sender, nor are shared objects<em>. This is limited to only struct types that are also defined by the module.</em></blockquote><p>This would work something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e2398a78f86d02a9b908ec6941e5231/href">https://medium.com/media/7e2398a78f86d02a9b908ec6941e5231/href</a></iframe><p>Note that the sui::object::owner function does not exist yet, but I imagine it would take a reference to an object and then return the address of the owner of that object.</p><p>Anyway, in the above function money is marked with a ‘!’ in its type, which means that it does not need to be owned by the transaction sender; it can be a Money object (as defined in this module) that is owned by anyone. The spend_money function then makes sure that the budget_cap authorized address and the Money object’s owner address match up; this prevents anyone with a budget_cap from using anyone else’s money.</p><p>Instead of checking the owner address, we could instead link the object id; either method would work perfectly well.</p><p>But basically this allows modules to define functions where users can sign a transaction which takes <em>someone else’s owned objects</em> and modifies them. In this case, protecting ownership is up to the module to implement correctly, rather than up to Sui.</p><p>I think this is a very flexible system that opens up a world of new possibilities, and I can’t really think of any downsides either, other than that you might be able to write-lock someone else’s owned objects by creating one of these transactions and then getting it 33%+ confirmed but not going all the way to 66%+ to get it finalized, which would effectively prevent that user from using that object until that transaction expires. But this is more of a problem with how Sui consensus works than with how Move works; the transaction-verification process should prevent these sorts of blocking-actions.</p><p>Oh but don’t worry; I’m not out of stupid ideas yet!</p><h4>Proposal 4:</h4><p>(Still working on this one…)</p><h4>Further</h4><p>Please drop a comment and give me your feedback and thoughts on these ideas! You can contact me at <a href="/service/mailto:paul@fidika.com">paul@fidika.com</a>, Telegram: @PaulFidika, or Twitter: <a href="https://twitter.com/PaulFidika">PaulFidika</a></p><p>Also checkout my company OpenRails: <a href="https://github.com/orgs/open-rails/repositories">https://github.com/orgs/open-rails/repositories</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b76c3409fe01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aptos VS Sui: Detailed Dev Comparison]]></title>
            <link>https://fidika.medium.com/aptos-vs-sui-detailed-dev-comparison-5d24df53eee8?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d24df53eee8</guid>
            <category><![CDATA[aptos]]></category>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[aptoslab]]></category>
            <category><![CDATA[mysten-labs]]></category>
            <category><![CDATA[sui]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 22:56:29 GMT</pubDate>
            <atom:updated>2022-10-04T22:46:07.652Z</atom:updated>
            <content:encoded><![CDATA[<p>Sui and Aptos are the children born from the demise of Diem; Facebook’s failed attempt at creating a blockchain. They both inherited Diem’s opensource codebase, and were formed by former Facebook engineers; <a href="https://twitter.com/AveryChing">Avery Ching</a> for Aptos, and <a href="https://twitter.com/b1ackd0g?lang=en">Sam Blackshear</a> for Sui. They both raised (or plan to raise) hundreds of millions of dollars to build their own decentralized futures.</p><p>Currently Aptos is further along in development; likely launching mainnet in October 2022, whereas Sui is a bit further behind; likely launching mainnet in January 2023.</p><p>In this series of articles I’ll be comparing these two L1 blockchains.</p><h4>Overall thoughts:</h4><p>Aptos is very similar to, and a significant improvement upon, existing blockchains like Solana; Solana will evolve to be more like Aptos in the near future. Sui is a bit of a wildcard though; they’re trying to be very innovative and different, but it’s unclear if these changes will workout. Despite their similar origins, Aptos and Sui are almost like complete opposites of each other.</p><h4>About Me:</h4><p>Hi I’m <a href="https://twitter.com/PaulFidika">Paul Fidika</a>! I’m developing on Sui right now. If you’re interested in working together on open-source stuff, I’d love to hear from you. Get in touch: <a href="https://discord.com/users/307650516664451072">Discord</a> <a href="/service/mailto:paul@fidika.com">Email</a> <a href="https://t.me/paulfidika">Telegram</a></p><h4>Table of Contents:</h4><p><a href="#3741">Part 1: The Move Programming Language</a><br>Part 2: Consensus<br>Part 3: Empirical Testing</p><h4>Part 1: The Move Programming Language</h4><p>Aptos sticks to traditional Move (as it was built for Diem), whereas Sui modifies Move considerably. In fact, Sui has changed Move so much I don’t think it’s fair to call them the same language anymore. It’s not possible to simply copy-paste code between the two; porting code requires a complete rewrite.</p><p>To illustrate the differences, let’s create a simple module. This module (1) defines a kitty resource, (2) defines a function to create kitties, and (3) defines a function rename kitties.</p><p><strong>Aptos:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8eedf58d676718053d63f82c27b9c2d8/href">https://medium.com/media/8eedf58d676718053d63f82c27b9c2d8/href</a></iframe><p><strong>Sui:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb2b6405bee82f74fba9d05e355c1428/href">https://medium.com/media/bb2b6405bee82f74fba9d05e355c1428/href</a></iframe><p>we break this code down below.</p><h4>Global Storage:</h4><p><strong>Aptos:</strong> In Aptos, Move has its own global storage, in which resources are indexed by (1) the account that owns them and (2) by the resource’s type. For example, if a module defines a resource called ‘Kitty’, and your account address is 0x69, then you would access this resource by doing something like let kitty_ref = borrow_global&lt;Kitty&gt;(0x69)</p><blockquote><em>💡 </em><strong><em>Rule:</em></strong><em> for a given resource type, an account can only store at most one of that resource at a time. If an account needs to hold more than one instance of a resource, such as storing multiple NFTs all belonging to the same collection, then the module author can create a container resource; essentially a vector that will hold all of the user’s NFTs, and then store that vector in global storage.</em></blockquote><p><strong>Sui:</strong> Sui completely does away with Move’s global storage, and replaces it with its own global storage.</p><blockquote><em>💡 </em><strong><em>Rule: </em></strong><em>In Sui, every resource is indexed with a unique global identifier.</em></blockquote><p>To enable this, every Sui object (a resource that can be directly stored in Sui’s global storage) must have an id defined at the time of its creation. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8734841898480bf6c9e2ab94ee76b8f/href">https://medium.com/media/d8734841898480bf6c9e2ab94ee76b8f/href</a></iframe><p>this id object provides a unique object_id. Sui also associates an owner_id with every object_id, which can be either an account address, another object_id, or a ‘shared object’ (more on this later).</p><p>Note: Aptos has no concept of resources owning other resources. (This is distinct from a resource containing another resource s a field, otherwise known as “wrapping”, which IS possible.)</p><blockquote><em>💡 </em><strong><em>Consequence: </em></strong><em>any Sui address can own an unlimited number of resources of the same type.</em></blockquote><p>For example, for the native Sui token, a single account could own 10 different Sui token objects; one object with a value of 420, another with a value of 100, another with a value of 69, etc. These fungible resources can be combined or split up into separate objects, and Sui’s Coin module provides functions to do this.</p><p>This might be a little confusing to blockchain natives, because no other blockchain has this concept; for example, on Solana, if you own USDC, you’ll always only have one USDC account associated with your address, and that account holds your entire USDC balance. To understand this better, think of each object as a ‘stack’ of money; the stacks can be combined or split up, but the total value always stays the same.</p><h3>Global Storage Operators:</h3><p><strong>Aptos:</strong> In Aptos, Move has <a href="https://move-language.github.io/move/global-storage-operators.html">5 global storage operators</a>:</p><ul><li>move_to: deposits a resource into an account’s global storage. This is the only operator that requires the account’s permission; the remaining 4 do not.</li><li>move_from: withdraws a resource from an account’s global storage.</li><li>borrow_global: creates an immutable reference to an item in global storage</li><li>borrow_global_mut: creates a mutable reference to an item in global storage</li><li>exists: returns a boolean, checking to see if a resource exists at an account address.</li></ul><blockquote><em>💡 </em><strong><em>Rule: </em></strong><em>These storage operators can only be used within the module that defines the resource; this means that the module authors have complete control over how their resources are stored and retrieved from global storage. Transaction, transaction scripts, and modules can only use these operators indirectly by calling whatever public functions the module makes available for them. This also means that module authors could build functions in that allow them to modify or take away resources from users without that user’s consent (I call this “weak ownership” or “module-defined ownership”).</em></blockquote><blockquote><em>💡 </em><strong><em>Note: </em></strong><em>because the move_to operator requires the recipients permission, this means that we cannot airdrop resources to random people’s accounts; the account owner must sign the transaction containing the move_to instruction in order to receive it.</em></blockquote><p><strong>Sui:</strong> Sui completely removes traditional Move’s global storage. Furthermore, Sui has no global storage operators; it does have the following methods, which are similar to traditional Move, but these can <strong><em>only be used in test packages</em></strong>, not actual production code:</p><ul><li>take_owned&lt;T&gt;: takes resource type T from the sender’s global storage. Fails if there is more or less than one resource of type T.</li><li>can_take_owned: boolean for whether or not the above function will abort.</li><li>take_last_created_owned&lt;T&gt;: same as take_owned, but it will not abort if there is more than one resource of type T.</li><li>take_owned_by_id&lt;T&gt;: same as take_owned, except that that you must specify the object ID you want to borrow.</li></ul><p>…and many more. <a href="https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/sources/test_scenario.move">Read the full list here</a>.</p><p>This has profound consequences to Sui’s programming model, for the good and bad (we’ll explore both below).</p><p>On the other hand, Sui does have 7 ownership operators, which are used to change the owner of a resource. They’re contained inside Sui’s transfer module:</p><ul><li>transfer: gives ownership of an object to a specified account address. Does not require the receiving account’s permission.</li><li>transfer_to_object: gives ownership of an object to another object, returning a ChildRef.</li><li>transfer_to_object_id: same as transfer_to_object, except you pass in an object_id rather than an object. Useful in case the object hasn’t been created yet, but you’ll be creating an object with that object_id later on.</li><li>transfer_child_to_object: transfers a child object from an old parent object to a new parent object.</li><li>transfer_child_to_address: transfer a child object from an old parent to an address (meaning it is no longer a child object).</li><li>freeze_object: irreversibly make an object immutable (no one owns it)</li><li>share_object: irreversibly make an object shared, meaning everyone owns it and can use it in any of their transactions.</li></ul><blockquote><em>💡</em><strong><em> Rule: </em></strong><em>ownership of objects can be transferred arbitrarily by the owner, without the module needing to define its own ‘transfer’ function. This means that the module authors can never take away owned resources, or modify owned resources after the resource is initially created and given to an account; the owner must opt-in by signing a transaction. I call this ‘strong ownership’ or ‘protocol-defined ownership’.</em></blockquote><blockquote><em>💡 </em><strong><em>Consequence: </em></strong><em>because the transfer operator does not require the recipients permission, this means that permissionless airdrops are possible; I can send tokens to people without their consent or without them doing anything. This may be convenient as a “growth hack” for tokens looking to get quick distribution, but this will also lead to lots of spam and scams (i.e., airdropping lots of unwanted tokens to users), which is already a minor problem on Solana.</em></blockquote><h3>Function Arguments</h3><p>Capability management is a question of ‘how does the Move VM decide what account has the rights to use a resource and call a function?’ For example, if I “own” an NFT, I should have to sign a message for it to be transferred.</p><p><strong>Aptos:</strong> module authors in Aptos can restrict who can use a function by requiring a ‘signer’ object. The signer object is a Move native type which is produced by the Move VM. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3ab0c472d4d1fdd5ffb1a6e3810e9ff/href">https://medium.com/media/c3ab0c472d4d1fdd5ffb1a6e3810e9ff/href</a></iframe><p>In this function, only the owner of the account can change their own kitty’s name. For example, if my address is 0x69, then only I can call this function with the address of 0x69, because only I can produce a signer object for the 0x69 account. However, if the module authors wanted to allow anyone to rename anyone else’s kitty, they would simply change the function’s signature from account: &amp;signer to addr: address instead. That is to say, rather than requiring a signature for 0x69 as a parameter, this function would merely require 0x69 as an address, which anyone can supply.</p><p><strong>Sui:</strong> Sui does away with Move’s native ‘signer’ type. Instead it manages capabilities by requiring senders to pass objects into its functions. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3516b704c134c0c3ca1e3db75d39d308/href">https://medium.com/media/3516b704c134c0c3ca1e3db75d39d308/href</a></iframe><blockquote><em>💡 </em><strong><em>Rule: </em></strong><em>the Sui Move VM restricts anyone from using an object as an argument, except for its owner.</em></blockquote><p>In this function, a Kitty object must be passed in as an argument. The transaction signer is restricted to only using the objects they own as arguments.</p><blockquote><em>💡 </em><strong><em>Definition:</em></strong><em> this is where ‘shared objects’ come into Sui; they are objects which are owned by everyone, which means any can include them in a transaction. This is useful for markets, like DeFi protocols. In Sui terminology, ‘owned objects’ are owned by a single account, while ‘shared objects’ are owned by everyone.</em></blockquote><p>Objects can be passed into functions as mutable / immutable references or by value (the function takes ownership of the object).</p><h3>Standard Data Types:</h3><p>Both Sui and Aptos expand on the native Move types with their own libraries, defining new custom data types.</p><p><strong>Aptos:</strong> Introduces ‘Table’, which can manage millions of records. Note that Aptos Tables do not have a ‘length’ parameter on purpose, because they want the Aptos’ runtime to be able to mass-parallelize Table operations; i.e., insertion or deletion of records should not require the entire table to be write-locked; the runtime should only have to lock whatever table entries are being modified. This means that Tables cannot be enumerated over (I think?).</p><p><strong>Sui:</strong> Sui data types are still in flux, but so far they’ve added UID; a global universal identifier for objects with the ‘key’ property. Additionally Sui is building the concept of child-objects; objects that stored independently in global storage (they are not nested / wrapped inside another struct) but are owned by other objects (the have a parent object). This sort of behavior is impossible in Aptos.</p><h3>Key Management:</h3><p><strong>Aptos:</strong> supports single-key and K of N multiple-signature keys. For multi-sigs, all of the signatures must be submitted along with the transaction (on-chain aggregation). Off-chain multi-sig aggregation is coming in the future.</p><p>Additionally Aptos supports keypair rotation; you can change your signing keypair whenever you like, such as in cases when your private key may have been compromised or you want to upgrade to from a single-key to a multi-sig. To accomodate this, Aptos has an account abstraction, where a user’s account-address is usually different from the public-key used to sign transactions.</p><p><strong>Sui:</strong> supports single-key and simulated K of N multi-sig. (To Do: clarify these details.) Sui does not support keypair rotation.</p><h3>Multi-signer transactions:</h3><p><strong>Aptos:</strong> supports an arbitrary number of signers per transaction. This makes atomic swaps very easy.</p><p><strong>Sui:</strong> only supports one signer at a time. Redoing this would mean changing the tx_context::sender(ctx) function to a vector of multiple senders instead of just one. Sui may add multiple-signer support if possible, although this would cause problems with FastPay in that a malicious co-signer could ‘freeze’ your objects.</p><p>Example: person-1 and person-2 both sign transaction(person_1_object, person_2_object) , then at the same time person-2 goes behind person-1’s back and also submits other_ransaction(person_2_object) . These are both valid transactions; let’s say they both accumulate 49% of the validator’s stake-weighted votes. That’s fine… BUT they are conflicting transactions in that sense that person_2_object is being used in two places at the same time. As a result, the original transaction will never be able to reach the 66% quorum majority it needs to be finalized (because the other validators already voted on a conflicting transaction), meaning person_1_object will be stuck in unconfirmed limbo until the current epoch ends (about 1 day max).</p><h3>Transaction Scripts:</h3><p>Move introduces an amazing new concept; transaction scripts. These allow transaction-senders to write ephemeral, single-use modules, rather than just calling entry functions on modules. This allows developers to move much of their logic out of on-chain modules and into custom-built transactions, if they wish.</p><p>Aptos fully supports these, while Sui does not yet support them. Sui technically allows you to do transaction-scripts by deploying custom modules and then calling them, however this is a two-step process, and is more expensive because you’re wasting storage space storing a module that will only be called once. I think Sui should keep transaction scripts.</p><p>Sui does support ‘transaction bundles’, which are lists of simple transactions sequenced together as an atomic unit. I believe they all must be entry functions, meaning the output of an earlier transaction cannot be used as input in a later one.</p><h3>Off-Chain Data Exploration</h3><p>Aptos has an indexer inside of its aptos-core repo, and Topaz is working on its own custom indexer specifically for NFT markets.</p><p>Sui does not yet have an indexer, although one is in the works.</p><p>In Aptos and Sui, move-modules can emit events, which are droppable, copyable structs. These events are not used on-chain, and are used solely as an index for querying RPC nodes.</p><h3>Misc. Differences:</h3><p><strong>Aptos: </strong>uses 32-byte addresses (the default Diem address size), which are encoded as 64-digit hexadecimals, looking like this:<br>0x375153e0983320667c8ccd98fd0b7057b35bc8a82670d10a6b44506f189bd4f1</p><p><strong>Sui:</strong> went with 20-byte addresses instead, which are encoded as 40-digit hexadecimals, looking like this:<br>0x3c17c86120d41b854f2603d001eba3705eb16368</p><h3>Thoughts for Improvements to Aptos</h3><p><strong>Gas schedule: </strong>currently, the gas schedule does not give you any reward for parallelism, which is a very important part of Aptos (block STM). A better gas-cost system would reward developers for using data-structures on which transactions can be run in parallel, and avoiding data-structures that force transactions to be done sequentially (example: if you create a table that has a ‘length’ property which needs to be updated on every insertion and deletion).</p><p>Additionally, developers should be incentivized to de-allocate resources they are no longer using, i.e., if you delete a struct from global storage, you should receive some storage refund.</p><h3>Summary Comparison:</h3><p><strong>Airdrops:</strong></p><p>Permissionless airdrops are not possible in Aptos; the recipients must opt-in to receive resources from you prior. For Sui, mass permissionless airdrops are one of the main use-cases Sui was designed for. In my opinion, being able to drop random objects into any account’s wallet is more of a bug than a feature, so I think Aptos has the better idea here.</p><p><strong>On-Chain Exploration of Objects / No Global Storage Operators:</strong></p><p>Because Sui doesn’t have global storage operators, there is no ‘on chain exploration’. In our first example code, our Aptos module can check global storage to see if our Kitty resource exists already when we try to rename it, and if it doesn’t, then we’ll create the Kitty resource and store it prior to renaming it. On Sui, this sort of on-chain check is not possible.</p><p>Sui expects us to give object-ids for our function arguments, but how are we supposed to know what object-ids we can use? This introduces a lot of off-chain logic, which must be placed inside of the wallet or the dapp; in order to construct a transaction, the wallet or dapp must query a Fullnode, get a list of objects the would-be-signer owns, select an object from the would-be-signer’s account, and then present a transaction with those object-ids filled in. This is a lot of work, and I don’t like the logic being all off-chain.</p><p>I would like to say though that Sui is very ‘cute’; I like to visualize Sui storing a bunch of ‘spheres’ that represent resources, and then every function being a ‘machine’ with slots waiting for spheres to be inserted. You grab the right spheres, insert them into all the slots to active the machine, and then WHIRRRR out comes some newly processed spheres at the bottom. It’s a very intuitive system.</p><p>One advantage of Sui for validators is sharding their memory; a validator only needs to know about the objects being used in the current transaction, all of which are owned by the same person; they don’t need to worry about storing the ENTIRE state of all accounts on the blockchain that could potentially be accessed by a global-storage call. This makes Sui functions pure functions, because they do not rely upon or modify global storage.</p><p>Solana’s current biggest bottleneck is disc read-write speeds; memory access, rather than network traffic or CPU usage will likely be the largest bottleneck in most blockchains, so this is a smart move on behalf of Sui.</p><p>Even so, I would like to see object-selection and object-conditional logic moved on chain; I imagine that transaction-scripts could consist of two phases; (1) logic to select objects from global storage that will be used in function calls, and (2) the actual function calls.</p><p><strong>Code Safety:</strong></p><p>The signer object in traditional Move (Aptos) is very powerful; essentially if a malicious module can get ahold of your signer object (you signed its malicious transaction), the module can take that object and do whatever it wants with it, including withdrawing arbitrary tokens and transferring it to another address. This is true in most blockchains however; you have to be careful what you sign! Which is why transaction simulations are important.</p><p>In Sui however, a malicious transaction can only ever steal or harm whatever objects you passed into the function call. This provides somewhat more protection, because it’s much easier to predict what resources will be affected by a transaction.</p><p><strong>Code Complexity:</strong></p><p>Overall, Sui will be a considerably more complex chain to build on, at least in its current incarnation. The complexity mostly stems from managing objects (see above), and wallets being much more engaged in validating a transaction (see Part 2).</p><p><strong>Weak Ownership VS Strong Ownership:<br></strong>(Module Defined Ownership VS Protocol-Defined Ownership)</p><p>In Aptos, modules have complete control over defining how their resources are controlled, the same as in Ethereum. I call this ‘weak ownership’; it is defined at the module-layer.</p><p>In Sui, ownership is a protocol-level primitive, and users can transfer ownership regardless of what the module authors want. This is a very powerful, key distinction. Let me give some examples:</p><p>Suppose that Circle creates a module that defines USDC as a resource; and Circle wants to be able to give themselves the ability to freeze an account’s USDC from being transferred whenever they get a request form law-enforcement to do so; they cannot do this.</p><p>Suppose an NFT project on Sui messes up half its mint, giving half of the buyers malformed metadata. The project wants to be able to correct this bugged-out metadata; they cannot do this without the owners signing a migration transaction to do so.</p><p>Module-authors could get around this by making all of their resources shared-objects, rather than owned-objects, and then building their own ownership-checking systems within each object; i.e., writing down the address of the resource’s ‘owner’ as a field inside the struct, then checking that address versus the transaction sender’s address for every transaction, but this is a terrible, hackish solution that ruins many of the advantages Sui is introducing.</p><p>The primitive that Sui is missing the most is <strong>capability delegation</strong>; perhaps you ‘own’ a resource in Sui, but you should be able to grant limited control over that resource to other addresses without turning owned-objects into shared-objects. In the above example, Circle would very much like to be able to call some confiscate_asset function that removes your ownership of their USDC, preventing you from being able to transfer it. Also the NFT project would like to be able to call some update_metadata function on each malformed resource they created. These are both legitimate and common use-cases on other blockchains. I think this capability delegation needs to be built into Sui at the protocol-level. Essentially this would allow other accounts to use objects they do not own, but in a limited, permissioned way.</p><p>Additionally, I’d like to point out that ‘transfer’ being a protocol-wide definition, rather than a module-wide definition, along with the Bag datatype, makes building marketplaces very simple; on Aptos every module can define its own custom transfer function, meaning marketplaces need to build separate functions for each type of resource they deal with, while on Sui you can create generic marketplaces that work for any arbitrary resource. I like this level of genericness, even though it takes some control away from module authors.</p><h3>Part 2: Consensus</h3><p>(Coming eventually…)</p><h3>Part 3: Latency and Throughput</h3><p>(Coming at some point — let’s try to break some testnets!)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d24df53eee8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solana’s Crypto-Native Phone is Genius, Bold, and (maybe) Doomed]]></title>
            <link>https://fidika.medium.com/why-solanas-crypto-native-mobile-phone-is-genius-bold-and-doomed-f685faeea344?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/f685faeea344</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[solanas]]></category>
            <category><![CDATA[solana-mobile-stack]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[solana-sdk]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 04:11:46 GMT</pubDate>
            <atom:updated>2022-06-25T07:27:58.291Z</atom:updated>
            <content:encoded><![CDATA[<p>When I pay for an Uber on my iPhone, a bottom-sheet slides up, I press ‘confirm’, authenticate with my face, my payment completes in 3 seconds, and I’m on my way. This feels so natural, so intuitive, so sleek.</p><p>The problem with building a crypto-payment app like this is that it really needs to be built into the operating-system level. iOS, iPhone’s operating system, creates a confusing web of APIs between apps, and backgrounded-apps are treated like second-class citizens. Apple obviously creates its own operating systems, and it uses this privilege to make Apple Pay both ubiquitous across its 1 billion hardware devices, and also unassailable, in that it has a privileged monopolistic position, being built directly into the operating system layer. The developer APIs simply do not exist for another company to build a competitor to Apple Pay on iPhone, and even if it did, Apple’s policies would forbid it.</p><p>Apple and Google’s business model runs counter to opening up their app-store marketplaces, payment platforms, hardware, and operating systems to third-party competitors. In 2021 Apple probably took in around $23 billion in fees from Apple App Store sales, and they’ve worked hard to protect these fees in the eyes of congress and courtrooms. (I say “probably” because Apple doesn’t report the actual amount of money they’re making.)</p><h4>Anatoly’s Bombshell</h4><p>On June 23rd, Solana announced both a phone, and a mobile android SDK. Solana is building (1) private-key management directly into the hardware layer of their new phone, and (2) building a wallet API directly into the operating system.</p><p>Advantages this provides:</p><ul><li>App-developers will now have a direct financial relationship with their users, without the platform taking huge fees or imposing restrictions.</li><li>Private-keys are now stored more securely. This eliminates janky hardware wallets, and makes private-key signing more accessible than it is in browser-extension wallets.</li><li>Apps don’t have to worry about being rugged by their platform, or complying with an arbitrary, changing TOS. (Remember when Google and Apple woke up one day and decided to ban Perler, one of the top social media apps, from their app store? Apple almost pulled Uber multiple times from its app store due to non-compliance with its privacy-terms.)</li><li>Users will have a better experience with crypto apps, with the wallet-handoff being handled at the operating-system level rather than using janky OS-redirect APIs.</li><li>Apps no longer have to compete directly against the platform they are building on top of. (Remember when Apple deliberately took billions off of Facebook’s ad revenue with a software update?)</li></ul><p>This is exactly what crypto needs.</p><h4>Doomed Future</h4><p>Unfortunately, Solana’s Saga Phone is unlikely to have much impact. This is because:</p><ul><li>Outside of a few million hardcore crypto fans, most people simply don’t care about crypto. All of the above-mentioned features and apps will be irrelevant to them. Their attention will focus on other attributes, such as camera-quality and price.</li><li>Apple’s reach is broad, both in hardware, software, and cloud services. In the 15 years since iPhone, Apple has become a master at locking in its users. It will be nearly impossible for iOS users to leave, even if they enjoy the features offered by a crypto phone.</li></ul><p>The phone will likely sell only 1 million units at best in 2023 (probably less), which will greatly limit the reach of these devices. For myself, a diehard iPhone user who upgrades to the latest model every year, I’ll still use iPhone as my primary phone, while owning a Solana Saga phone for the occasional crypto-related task (I ordered one within hours of its announcement).</p><p>Still, I want to see something like Solana Saga succeed. What are the best steps forward to make this a success?</p><ol><li>Get other android devices to build private-key management into their phones, and include the Solana Mobile Stack SDK / wallet adapter into their android-operating system. (Samsung might.)</li><li>Convince Facebook or Amazon to launch their own phones, with crypto as a feature. (Unlikely — this was already tried in 2013 and 2014 respectively, and both attempts failed).</li><li>Force Apple to open up their operating-system to competing wallets, using lobbyists, regulators, and anti-trust lawsuits. (Unlikely.)</li><li>Build on top of iOS and android the best we can within our limitations. (Not optimal, but still somewhat doable.)</li></ol><p>In all honesty, Apple and Google are more likely to launch their own private blockchain before they’ll give up their app-store fees and allow another blockchain payment system to integrate into their OS-layer.</p><p>If anyone has any suggestions or ideas on how to move forward on this, or your thoughts on what the future will look like, please email me at <a href="/service/mailto:paul@fidika.com">paul@fidika.com</a>, I’d love to hear your thoughts.</p><p><strong>Side notes:</strong></p><ul><li>Apple Pay processed $90 billion in merchant transaction volume in 2021, but Apple only takes a 15-basis point fee, making Apple Pay revenue a rounding error for Apple. Additionally, Apple also has 6.7 million Apple Card users, although growth was anemic in 2021.</li></ul><p><strong>Sources:</strong></p><p><a href="https://www.cnbc.com/2022/01/10/apple-implies-it-generated-record-revenue-from-app-store-during-2021-.html">https://www.cnbc.com/2022/01/10/apple-implies-it-generated-record-revenue-from-app-store-during-2021-.html#:~:text=Last%20year%2C%20CNBC%20analysis%20suggested,on%20a%2030%25%20commission%20rate.</a></p><p><a href="https://www.inputmag.com/tech/hardly-any-iphone-owners-in-the-us-use-apple-pay">https://www.inputmag.com/tech/hardly-any-iphone-owners-in-the-us-use-apple-pay</a></p><p><a href="https://www.forbes.com/sites/ronshevlin/2022/06/10/cutting-through-the-apple-pay-later-hype-and-theres-a-lot-of-it/?sh=727aa08a2b07">https://www.forbes.com/sites/ronshevlin/2022/06/10/cutting-through-the-apple-pay-later-hype-and-theres-a-lot-of-it/?sh=727aa08a2b07</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f685faeea344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solana Scaling Strategy: Parallelize Across Multiple Machines?]]></title>
            <link>https://fidika.medium.com/solana-scaling-strategy-parallelize-across-multiple-machines-f8418a6c4764?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8418a6c4764</guid>
            <category><![CDATA[solana-blockchain]]></category>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[parallelization]]></category>
            <category><![CDATA[validator]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Fri, 24 Jun 2022 07:20:17 GMT</pubDate>
            <atom:updated>2022-06-24T07:20:17.009Z</atom:updated>
            <content:encoded><![CDATA[<p>Random thought; what if the demand on the Solana network exceeds that which is possible to be provided by a single (even very powerful) machine? How could Solana scale across multiple hardware machines?</p><p>Solana’s Sealevel runtime was designed for massive parallelization; each transaction has a header that specifies the accounts that will be read from and written to within that transaction. That allows transactions to be sorted into groups that will not affect each other. Each of these groups can be processed concurrently on multiple CPU cores, and in the future they may be run on GPUs as well.</p><p>But what if this is still not enough? Theoretically, Solana could add a ‘load balancer’ validator, which accepts transactions, groups them, and then forwards those transaction-groups to a set of leaders (leaders rotate every 4 slots as currently). These leaders process their-transaction group within the time allotted, and then broadcast them to the rest of the network to produce the finished block. The partial-blocks are disseminated via a gossip network to the rest of the validators on the network, who vote on each block as a whole.</p><p>The problem with this is:</p><ol><li>The load-balancer step will add latency to the network, mostly because of the time it takes to do the network transmission (it would probably add 150ms per block). But the benefits are worth the sacrifice.</li><li>Each validator will still need to carry the entire blockchain head in their RAM or hard-disk, because they will not know which accounts they will be called upon to process or validate ahead of time. This would limit scalability in terms of memory; we cannot scale to having a head larger than what the smallest validator can hold in its disc drive.* If we partitioned Solana by dividing all Solana accounts into Shard-A and Shard-B, and assign validators to each of these shards (meaning that each validator only needs to worry about storying its own half of the network in memory), then this would work fine until there was a transaction involving accounts from both Shard-A and Shard-B at the same time; in that case it would be impossible for any one validator to process this transaction because it does not have the relevant data to do this. Solana’s programming model also lacks the ability to do asynchronous transactions (transactions that settle across multiple blocks), meaning partitioning Solana is impossible unless we rewrite all code on the blockchain.</li><li>The usefulness of this parallelization would be limited, in that each validator would be left with mostly sequential groups of transactions to work on. This means it wouldn’t be able to use its own parallelization strategy (multiple CPU or GPU threads).</li><li>Parallelization in general (across a single machine or multiple machines) will be frustrated by very popular contracts. For example, a single liquidity-pool that gets lots of arbitrage-bot activity, or a single minting-contract for a large collection. These transactions depend on each other and hence must be done sequentially. Remember the ’80 / 20&#39; rule; most likely 80% of your transactions will come from 20% of your accounts.</li></ol><p>Overall, I’m going to make this idea as a <strong>failure</strong>; parallelizing Solana across multiple machines will not work without fundamentally changing Solana’s programming model.</p><p>*Theoretically Solana can ‘run out of memory’; SOL has a 342.6 million circulating supply right now. At 7 SOL per 1 MB, that means that the Solana head could grow to a size of 48.94 TBs, which far exceeds most validator’s ability to store. (Validators currently only have 1 TB of storage plus 256 GB of RAM.) Although storing this much data would, in today’s price of $38 per SOL, cost about $13 billion (lol lol lol).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8418a6c4764" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solana’s Network Performance Will Continue to be Choppy]]></title>
            <link>https://fidika.medium.com/solanas-network-performance-will-continue-to-be-choppy-cdbb196a8152?source=rss-b49df4663379------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdbb196a8152</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[solana-network]]></category>
            <category><![CDATA[validator-node]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[web3-development]]></category>
            <dc:creator><![CDATA[Paul Fidika]]></dc:creator>
            <pubDate>Sat, 14 May 2022 23:54:25 GMT</pubDate>
            <atom:updated>2022-05-15T00:11:39.396Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Synopsis:</strong> Solana’s transaction-throughput capability has been overestimated, and it has no clear roadmap on scaling (yet). Furthermore, performance does not (yet) degrade gracefully when this peak-performance cap is met. The validator network is brittle by design and can be halted by a powerful bad-actor or network of spam-bots. These are problems fundamental with Solana’s architecture, and cannot be solved quickly or easily (i.e., we won’t see a “Solana 2.0” in production for a year or two at least).</p><h4>Blockchain generations:</h4><ul><li><strong>Gen 1: </strong>(Bitcoin, XRP, Dogecoin) Focuses on the transfer of tokens.</li><li><strong>Gen 2:</strong> (Ethereum, Solana, Cardano) Adds smart-contract functionality, so that on-chain programs can do simple, non-intensive, computations.</li><li><strong>Gen 2.5</strong> (Cosmos, Polkadot, Avalanche) Side-chains running independent of each other, with the ability to pass messages in some standardized way.</li><li><strong>Gen 3</strong> (Eth 2.0, NEAR) Maintains a single global state, but this state is sharded across machines. Programs execute asynchronously.</li></ul><h4>What makes Solana performant:</h4><p>Solana is the most performant Gen 2 blockchain available. It accomplishes this feat using the following 4 methods:</p><ol><li><strong>Execution optimization:</strong> Rather than the standard EVM execution environment (Ethereum, Polygon), Solana created “Sealevel”; it’s own custom execution environment. This system allows transactions to be broken into groups and executed in parallel using multi-core CPUs and eventually (hopefully) GPUs. Code is written in Rust and compiled into binary, which is more performant than Solidity-written programs.</li><li><strong>Storage optimization:</strong> Solana wrote their own custom database software, “Cloudbreak”, which allows for many more disc read / write operations than possible with traditional database software. Cloudbreak can do around 1 million write-operations per second on a single SSD (solid state drive).</li><li><strong>Leader-schedule:</strong> on Ethereum and Bitcoin, pending transactions are placed inside of a ‘mempool’, which is gossiped between miners, and takes log(n) to reach the entire network. Transactions from this mempool are used to construct the next block. It is not known in advance which machine will produce the next block. Solana instead uses a leader-schedule; the next block-producer (leader) is publicly known and determined one epoch (about 2 days) in advance. This means that pending transactions can be forwarded directly to the next leader to be included in the next block, without the need to gossip the transactions around the validator network and wait for these transactions to be picked up.</li><li><strong>High validator requirements:</strong> Solana validator nodes cannot be run with consumer-grade hardware in your home. You need a 1 GBit/s unmetered connection, high availability, 4+ SSDs, 256GBs of RAM, etc. This means that all Solana validator nodes must be run in datacenters and cost around $800+ per month (in just hardware) to operate. Restricting validators to only use powerful machines allows for many more transactions per second than if weaker machines were allowed.</li></ol><h4>Problems:</h4><ul><li><strong>Leader schedules are fundamentally brittle:</strong> because the leader is known in advance, that means a bad-actor can halt the network by targeting the leader-machines with a DDoS attack in order of its leader-schedule. Essentially, this is why the Solana network has halted multiple times; mint-bots, trying to mint an NFT first, were spamming the leader with duplicate transactions. All of these duplicated transactions eventually overloaded the leader’s memory. On Ethereum this would be impossible; the next block producer is not known in advance. And even if you knew what machine was going to produce the next block, and took it offline before it could, another machine would simply produce the block instead. This makes leaderless blockchains like Ethereum and Avalanche much more robust to attack. Leader schedules are more performant, but unsafe in an adverse network environment.</li><li><strong>Fixed Fees / Low cost to spam:</strong> On Ethereum, you are charged a “gas fee” for transactions. These gas-fees are based on the total amount of resources consumed by the transaction; i.e., more computations = higher fee. On Solana, fees are fixed at .000005 SOL per signer. These “low fees” are one of Solana’s main marketing points. However, this is an arbitrary number set by Solana itself, not based on any sort of resource-utilization or network availability. This means it is cheap to spam transactions, and you are only charged once for a failed transaction, even if you submitted it 1,000 times. (Solana is currently moving to begin charging fees based loosely on compute-units consumed to encourage optimized programs, and is looking at strategies such as ramping up consecutive failed-transaction fees exponentially to deter spam.)</li><li><strong>No Gas Marketplace / Poor Network Degradation:</strong> Once a network has reached capacity, how do you ration that capacity? Think of it as a bus stop; the bus comes to the next stop, picks everyone up, and leaves. But if the bus has 50 seats, and 100 people trying to get on, how do you decide who gets on, and who has to wait for the next bus? On Ethereum, there is a “gas marketplace” where you bid against other participants to have your transactions included next. You are essentially biding for the set of available seats. This is neat and orderly. On Solana… well, it would be more like a fist fight. Imagine that the 100 people at the bus stop start shoving and kicking each other to try to get on first, and due to a fight breaking out at the bus stop, only 20 people are able to get on the bus before it leaves. This is essentially Solana. Programs are now designed to spam Solana — submit your transaction multiple times automatically — in order to get on the bus first. This leads to a better user experience, in terms of the user getting their transactions in sooner, but the more apps that are “clever” like this, the more the Solana network degrades. Solana wasn’t always like this; back in August 2021, retrying failed transactions wasn’t needed. But usage has picked up, the network has become more unreliable, and block-times have slowed down considerably (going from 400ms to 700ms currently). Solana mainnet has been consistently maxing out around 2.5k — 3k tps, although its testnet was able to do as much as 4k — 5k. Like the rowdy people at the bus stop, total max capacity on Solana goes down as a function of usage. Unfortunately Solana so far has gone with a “we just need bigger buses” strategy to solve this problem, rather than addressing how the network handles bottlenecks.</li><li><strong>No ability to scale:</strong> For most blockchains, such as Bitcoin, Solana or Ethereum, blocks are produced on just ONE MACHINE. Yes you read that correctly; the entire Solana, Ethereum, and Bitcoin blockchains are just <em>one physical computer</em>, humming away, doing all the calculations by itself. Yes, the physical machine doing the calculation rotates, but still, it is fundamentally just one computer. I imagine you can see why this is a problem; what if there is more demand than what any one machine can handle? Well… yeah we’re all fucked. This is why scaling to multiple simultaneous block-producing machines is important. But I’ve never heard anyone even suggest the idea of Solana scaling: layer-2’s, sharding, side-chains… nothing. I believe this was due to a gross overestimate of Solana’s transaction ability; Solana seems to believe their network can handle 50k transactions per second, but realistically it’s struggling to do 3k, and was pushed beyond its full capacity when OpenSea launched on Solana in April. Solana certainly cannot support millions of daily active users. Solana-scaling is likely many years off into the future. The best we can hope for, ironically, is that Solana and crypto in general will fade in popularity, making the network less used and hence more performant.</li></ul><h4><strong>Solana’s Future</strong></h4><p>Solana will continue to be used for a few applications, such as orderbooks for synthetic stocks (Serum) or trading NFTs (MagicEden), but Solana simply does not have the capacity or reliability to support all the applications developers want to build on it (i.e., a global settlement layer for payments, on-chain banking, or games that store their state on-chain). These projects will be disappointed and will eventually abandon their efforts in favor of other chains.</p><p>Fortunately, as the crypto bubble deflates, it’s likely that Solana’s usage will drop off, as users looking to get rich quick move on to other hobbies. This will alleviate some of Solana’s congestion temporarily.</p><h4><strong>Recommendations</strong></h4><p>Solana would be best advised to (1) come up a potential scaling strategy, (2) consider abandoning leader-based block production*, (3) start computing gas usage for programs, and (4) have a gas marketplace to ration network capacity and prioritize transactions. This would make Solana much more similar to Ethereum, and less performant and cheap than it is currently, but ultimately having a scalable, reliable network is more important than fast transaction times and low fees. For a blockchain with billions of dollars locked into it, reliability and robustness to attack are far more important than being fast and inexpensive.</p><p>If this plan is executed well, when the next crypto-mania starts again in 2 or 3 years, Solana could be well positioned to overtake Eth 2.0 as the dominant chain. If this plan is not executed well, it is likely Solana will be surpassed by newer chains.</p><h4>Other Thoughts</h4><p><strong>Note from Justin Kookie (Solana Dev):</strong> some of these issues have been recognized and are being addressed. For example, the GenesysGo Shadow Protocol is a side chain used to keep track of account state. Strata Protocol is also working on bot prevention in candy machine mints, as well as NFT dutch auctions.</p><p>For recommended improvements, I want to push for public anchor idl in order to legitimize custom contracts. For example, a custom token-metadata contract can use the Metaplex standard as the base then add functionality. Phantom wallet and Solana explorers could decode the data instead of the NFTs showing up as unknown.</p><p><strong>*Dissenting Opinion (from a top Solana Validator):</strong> It might be possible to make a leader-based system work robustly, and there are techniques to mitigate DDoS attacks. More experimentation is needed prior to abandoning a leader-based system; leader-based systems have many performance advantages. Sharding is as-of-yet unproven in practice, and may not be practical in that it introduces more problems than it solves. The 50k tps figure was an estimate assuming Solana could utilize GPUs for massive parallelization, but so far this has not happened. If GPUs could be properly utilized, tps for a single machine could theoretically reach into the tens of thousands. Right now, GPUs do almost nothing on Solana; they just offload a tiny bit of PoH (Proof of History) verification, which is so unimportant compute-cost-wise as to be meaningless.</p><p>I would recommend that pending transactions be submitted to non-leader validators, and these validators selectively forward the transactions to the leader. There would need to be incentive mechanisms to encourage only forwarding good transactions, and not withholding transactions.</p><p>I also think expired transactions should be charged a partial-fee from the fee-payer’s account. Users wouldn’t like paying fees for failed transactions, but it would deter spam-transactions in the sense that all of their failed submitted transactions could potentially have a cost.</p><h4><strong>Sources:</strong></h4><p><a href="https://medium.com/solana-labs/sealevel-parallel-processing-thousands-of-smart-contracts-d814b378192">https://medium.com/solana-labs/sealevel-parallel-processing-thousands-of-smart-contracts-d814b378192</a><br><a href="https://docs.solana.com/running-validator/validator-reqs">https://docs.solana.com/running-validator/validator-reqs</a><br><a href="https://shdw.genesysgo.com/">https://shdw.genesysgo.com/</a><br><a href="https://nitter.net/i/status/1497214981150056448">https://nitter.net/i/status/1497214981150056448</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdbb196a8152" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>