<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Igor Mandrigin — All updates</title>
<link>https://255c.org</link>
<atom:link href="https://255c.org/rss/all.xml" rel="self" type="application/rss+xml"/>
<description>Igor Mandrigin — All updates</description>
<item>
<title>Practical privacy for institutional EVM networks</title>
<link>https://255c.org/practical-privacy/</link>
<guid isPermaLink="true">https://255c.org/practical-privacy/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Sat, 05 Sep 2026 00:00:00 +0000</pubDate>
<description>Confidentiality and auditability have to coexist in institutional onchain systems. Choosing an architecture starts with three decisions: whose access to restrict, what another party must verify, and which information must cross the boundary between institutions. This is a written companion by Igor Mandrigin, published September 5, 2026. It develops the privacy and interoperability thread behind…</description>
<content:encoded><![CDATA[<p>Confidentiality and auditability have to coexist in institutional onchain systems. Choosing an architecture starts with three decisions: whose access to restrict, what another party must verify, and which information must cross the boundary between institutions.</p>
<p>This is a written companion by <a href="/about/" class="sec-link">Igor Mandrigin</a>, published September 5, 2026. It develops the privacy and interoperability thread behind <a href="https://www.youtube.com/watch?v=5xiuSqab1fY">Practical Privacy at DAppCon, June 16, 2026</a>, and the <a href="https://www.lfdecentralizedtrust.org/learn/webinars/lfdt-webinar-with-gateway.fm-practical-approaches-to-interoperable-blockchain-privacy">LF Decentralized Trust workshop, March 18, 2026</a>. The <a href="https://vibes.dappcon.io/?view=events">DAppCon programme</a> lists the session as “Practical Approaches to Interoperable Blockchain Privacy.”</p>
<h2 id="define-the-property-before-choosing-the-technology">Define the property before choosing the technology <a class="plink" href="#define-the-property-before-choosing-the-technology">§</a></h2>
<p>Four terms describe different jobs:</p>
<ul>
<li><strong>Confidentiality:</strong> keep specified information from specified observers. “Private from other participants” and “private from the infrastructure operator” are different requirements.</li>
<li><strong>Selective disclosure:</strong> release a defined part of that information to a particular recipient under stated conditions.</li>
<li><strong>Auditability:</strong> preserve enough evidence for a reviewer to establish what happened and which controls applied.</li>
<li><strong>Interoperability:</strong> move value, instructions, or proofs between systems without requiring every participant to use the same environment.</li>
</ul>
<p>My <a href="/notes/private-doors-interoperable-roads/">doors and roads frame</a> connects these properties. Doors define access to a room. Roads let the rooms participate in a market. Neither tells us, on its own, who holds the keys or what a traveller reveals when leaving.</p>
<h2 id="work-through-one-transfer">Work through one transfer <a class="plink" href="#work-through-one-transfer">§</a></h2>
<p>Consider a hypothetical transfer between two institutions. The sender needs a record of its instruction. The recipient needs to reconcile the payment. Other participants should not receive the underlying customer information. An appointed reviewer may need access to selected evidence later.</p>
<p>Before comparing products, write down the intended views:</p>
<div class="table-scroll" role="region" tabindex="0" aria-label="Table: Participant, Information needed for this example, Boundary to test"><table>
<thead><tr><th scope="col">Participant</th><th scope="col">Information needed for this example</th><th scope="col">Boundary to test</th></tr></thead><tbody>
<tr><td>Sender</td><td>Its instruction, transfer result, and reconciliation reference</td><td>Its credentials do not expose another institution’s records</td></tr>
<tr><td>Recipient</td><td>The transfer details needed to credit and reconcile it</td><td>Receipt of one transfer does not reveal the sender’s unrelated positions</td></tr>
<tr><td>Unrelated participant</td><td>Whatever shared state the protocol requires it to verify</td><td>Shared verification does not silently reveal customer-level records</td></tr>
<tr><td>Appointed reviewer</td><td>The records and control evidence covered by the review</td><td>A disclosure grant has a defined scope and duration</td></tr>
</tbody></table></div>
<p>This is a design example. The institution must decide the actual disclosure rules and evidence requirements for its workflow.</p>
<p>Now add the infrastructure. A sequencer, validator, prover, RPC operator, or key custodian may see data that no application user can request. That produces a second access map: the people and systems that can read the underlying state, memory, keys, or logs. I am developing that map in <a href="/notes/privacy-from-operators/">Privacy from operators</a>.</p>
<p>The reader map describes the desired product. The operator map describes the trust placed in its operation. An architecture needs both.</p>
<h2 id="place-the-control-where-it-can-enforce-the-rule">Place the control where it can enforce the rule <a class="plink" href="#place-the-control-where-it-can-enforce-the-rule">§</a></h2>
<p>A policy layer at the JSON-RPC interface can fit an existing application stack. JSON-RPC is the request-and-response interface used to query and interact with an Ethereum-compatible node. Keeping that interface can reduce the integration changes needed for a controlled view.</p>
<p>At Gateway.fm, <a href="https://gateway.fm/open-privacy-suite/">Open Privacy Suite</a> applies identity, role, and purpose to supported RPC requests. Its configured RPC and explorer surfaces can return a permitted value, a consistent pseudonym, or a redaction. Disclosure grants and access decisions can produce audit evidence. Coverage depends on the client, methods, and deployment configuration.</p>
<p>That boundary has a precise limit: raw-node access, infrastructure administrators, and connected systems need separate controls. Filtering one response does not remove another route to the data. The <a href="https://gateway.fm/open-privacy-suite/">product’s enforcement-boundary notes</a> make this distinction explicit.</p>
<p>For public Ethereum, data published in plaintext remains available to other readers of the ledger. A private endpoint cannot make that public record confidential. Ethereum’s <a href="https://ethereum.org/privacy/ethereum">privacy overview</a> explains the exposure from public state and transaction metadata.</p>
<h2 id="match-the-architecture-to-the-observer">Match the architecture to the observer <a class="plink" href="#match-the-architecture-to-the-observer">§</a></h2>
<p>These approaches can be combined. They solve different parts of the problem.</p>
<div class="table-scroll" role="region" tabindex="0" aria-label="Table: Approach, Where it helps, What still needs an answer"><table>
<thead><tr><th scope="col">Approach</th><th scope="col">Where it helps</th><th scope="col">What still needs an answer</th></tr></thead><tbody>
<tr><td>Permissioned network with controlled application reads</td><td>Restrict participation and give authenticated users different views</td><td>Which node operators and administrators retain access to the underlying data?</td></tr>
<tr><td>Cryptographic private state and proofs</td><td>Let a verifier check a defined statement while hiding its private inputs</td><td>Who generates the proof, who sees its inputs, and what do public outputs or metadata reveal?</td></tr>
<tr><td>A dedicated institutional network connected to other networks</td><td>Give the institution control over its operating environment</td><td>How do counterparties verify settlement and exchange assets without joining that environment?</td></tr>
</tbody></table></div>
<p>The distinction between a verifier and a prover matters. A zero-knowledge proof can hide private inputs from the verifier; it does not establish that the service generating the proof never received those inputs. Public inputs, emitted events, submission paths, and application logs also need review. Ethereum’s <a href="https://ethereum.org/latest/privacy-apps-on-ethereum/">guide to building privacy applications</a> describes these surrounding sources of disclosure.</p>
<p>My architectural conclusion is to select the privacy mechanism against the observer it must exclude. A requirement to hide positions from another application user does not automatically require the same machinery as a requirement to hide them from the execution operator.</p>
<h2 id="separate-a-validity-proof-from-an-audit-record">Separate a validity proof from an audit record <a class="plink" href="#separate-a-validity-proof-from-an-audit-record">§</a></h2>
<p>A proof that a transaction followed a rule answers a particular question. An audit may ask additional questions: which identity authorised the instruction, which policy version applied, who received a disclosure, and whether access was later revoked.</p>
<p>For the transfer example, a useful evidence design would connect the instruction, its authorisation, the settlement result, and any subsequent disclosure. The reviewer’s access to that evidence is itself part of the privacy design.</p>
<p>Keep the claims narrow. A record that a proxy denied a request establishes what happened at that proxy. It cannot establish that an administrator did not read a database through another path. A time-limited grant stops later authorised access; it cannot recall a copy already delivered to its recipient.</p>
<p>Those limits decide where operational controls, cryptography, and evidence must work together.</p>
<h2 id="follow-the-information-across-the-road">Follow the information across the road <a class="plink" href="#follow-the-information-across-the-road">§</a></h2>
<p>Interoperability adds another observer. A bridge, messaging service, counterparty network, or reconciliation system may receive information protected inside the original environment.</p>
<p>Return to the transfer. Write down what leaves the sender’s boundary: an instruction, an asset identifier, an amount, a recipient, a proof, or some smaller statement. Then identify who receives each item, who can verify it, and what happens if the destination cannot complete the operation.</p>
<p>Using the same RPC format on both sides does not answer these settlement and disclosure questions. Interface compatibility helps applications connect. The cross-network protocol still has to define the meaning and validity of the result.</p>
<p>That is the practical test of the <a href="/institutional-privacy/">institutional privacy thesis</a>: preserve the private room while making the road usable. A design review should leave behind a map of readers, a map of data leaving each boundary, the statements counterparties can verify, and the evidence an authorised reviewer can obtain.</p>
<p>The recordings are in the <a href="/talks/" class="sec-link">talks archive</a>. The next unresolved boundary is <a href="/notes/privacy-from-operators/">privacy from operators</a>.</p>]]></content:encoded>
</item>
<item>
<title>Stateful vs stateless ZK proving</title>
<link>https://255c.org/notes/stateful-vs-stateless-zk-proving/</link>
<guid isPermaLink="true">https://255c.org/notes/stateful-vs-stateless-zk-proving/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Sat, 22 Aug 2026 00:00:00 +0000</pubDate>
<description>Every zk L2 stands on its prover. Each batch of transactions needs a cryptographic proof that the execution was correct — L1 verifies the proof, not the transactions. So proving capacity decides your throughput and your costs. Proving needs state. To re-execute a batch, the prover has to see every account and storage slot the batch touches. And state is big — gigabytes on a young chain, terabytes…</description>
<content:encoded><![CDATA[<p>Every zk L2 stands on its prover. Each batch of transactions needs a cryptographic proof that the execution was correct — L1 verifies the proof, not the transactions. So proving capacity decides your throughput and your costs.</p>
<p>Proving needs state. To re-execute a batch, the prover has to see every account and storage slot the batch touches. And state is big — gigabytes on a young chain, terabytes on a busy one. Anything that has to hold it becomes expensive to run, and worse, expensive to copy.</p>
<p>There are two ways to connect the prover to the state. The naive one: plug the prover into the node’s state database and let it read as it goes. That is <strong>stateful proving</strong>. The other: have the node hand over a <strong>witness</strong> — a self-contained slice of state, exactly what the batch touches, verifiable against the state root. That is <strong>stateless proving</strong>.</p>
<p>Ethereum asked the same question about its own nodes in 2020, in the Eth 1.x project — research on improving state management in the execution layer. I was working on it back then. Inside zk proving, the same question played out the same way.</p>
<h2 id="before-stateful-proving">Before: stateful proving <a class="plink" href="#before-stateful-proving">§</a></h2>
<p>The Hermez prover in its research era read the state as it went. So it sat coupled to a state database. Cozy, and hard to move.</p>
<p>The costs are the same costs stateful Ethereum has:</p>
<ul>
<li><em>Coupling.</em> The prover inherits the node’s internals — storage layout, access paths, caching. Change the client and you are rebuilding the prover.</li>
<li><em>State.</em> The proving side has to hold it and maintain it.</li>
<li><em>Scaling.</em> More provers means replicating the state.</li>
<li><em>Performance.</em> State access leaks into proving time.</li>
</ul>
<h2 id="after-witness-in-proof-out">After: witness in, proof out <a class="plink" href="#after-witness-in-proof-out">§</a></h2>
<p>With cdk-erigon — the zkEVM client our team at <a href="https://gateway.fm"><svg class="gw-mark" viewBox="0 0 30 32" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M26.141 3.85529L0 17.2381V21.5347L26.1789 8.1325L26.141 3.85529Z" fill="#8950FA"/><path d="M18.8265 0L18.8645 4.38789L0 14.0455V9.63816L18.8265 0Z" fill="#8950FA"/><path d="M14.876 17.1115L19.0724 14.9632L29.12 20.1071V24.4036L14.876 17.1115Z" fill="#8950FA"/><path d="M29.12 9.81943V16.9145L22.1905 13.3669L29.12 9.81943Z" fill="#8950FA"/><path d="M11.7579 18.7078L26.141 26.0712L14.56 32L0.176939 24.6366L4.44343 22.4525L14.6284 27.6666L17.7465 26.0703L7.56154 20.8562L11.7579 18.7078Z" fill="#8950FA"/></svg>Gateway</a> builds — the model flipped. The node produces a witness, the exact slice of state a batch touches. The prover consumes it. It does not know or care how the node stores state.</p>
<p>Proving becomes almost a pure function: batch plus witness in, proof out. No state database on the proving side. Provers scale out like any stateless worker.</p>
<figure tabindex="0"><img src="/static/img/witness-proving-flow.svg" alt="Before: the prover reads state as it executes. After: the witness travels with the batch, and the prover is a pure funct" width="688" height="300" loading="lazy" /><figcaption>Before: the prover reads state as it executes. After: the witness travels with the batch, and the prover is a pure function.</figcaption></figure>
<h2 id="the-numbers-came-first">The numbers came first <a class="plink" href="#the-numbers-came-first">§</a></h2>
<p>None of this was a guess. In 2020, as part of Ethereum Foundation stateless research, I measured witnesses on mainnet and published the raw data:</p>
<ul>
<li><em>Trie shape.</em> Binary tries shrink witnesses versus hexary ones — <a href="/writing/stateless-ethereum-binary-tries/">the experiment</a>, <a href="https://github.com/mandrigin/ethereum-mainnet-bin-tries-data">the data</a>. <span class="badge">Jan 2020</span></li>
<li><em>Sync.</em> Witnesses pre-build caches as blocks arrive during initial sync — <a href="/writing/semi-stateless-initial-sync/">the experiment and its corrected measurement scope</a>. <span class="badge">Feb 2020</span></li>
<li><em>Overhead.</em> Witness-resolution measurements with a 1,000,000-node cache — <a href="https://github.com/mandrigin/ethereum-mainnet-resolver-witness-stats">the data</a>. <span class="badge">Feb 2020</span></li>
<li><em>Formats.</em> Opcode witnesses versus the key-value format, blocks 5,000,000–8,000,000, seventeen days of compute — <a href="/writing/kv-witness/">KV-Witness</a>, <a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data">the data</a>. <span class="badge">Jul 2020</span></li>
</ul>
<p>The archives are still up. Anyone can re-run them. Bring seventeen days.</p>
<h2 id="the-flip-is-in-the-commit-logs">The flip is in the commit logs <a class="plink" href="#the-flip-is-in-the-commit-logs">§</a></h2>
<p>This retrospective was first published on August 22, 2026. January 31, 2024 is the implementation milestone described below; an earlier version of this page used that milestone as its publication date. The date was corrected on September 5, 2026.</p>
<p>You can watch it happen in both halves at once:</p>
<ul>
<li>cdk-erigon grew SMT witness generation on January 17, 2024 (<a href="https://github.com/0xPolygon/cdk-erigon/pull/50">#50</a>). <code>eth_getWitness</code> and the witness spec followed the same week.</li>
<li>Three days later the prover gained its first witness decoder (<code>src/prover/witness.cpp</code>, Jan 20).</li>
<li>Stateless batch proving merged on January 31, 2024 — <a href="https://github.com/0xPolygon/zkevm-prover/pull/765">PR #765</a>, from a branch literally named <code>erigon_witness</code>.</li>
</ul>
<p>Everything before that in the prover’s history is coupled to its state database.</p>
<p>This was not a solo act. The node half — witness generation, <code>eth_getWitness</code>, the spec — was our engineers at Gateway. The prover half was <a href="https://github.com/0xPolygonHermez">Polygon’s team</a>. Two teams, one seam, eleven days.</p>
<h2 id="the-same-spec-carried-across">The same spec, carried across <a class="plink" href="#the-same-spec-carried-across">§</a></h2>
<p>The first-generation format has a formal spec. I wrote it — the <a href="https://github.com/ethereum/portal-network-specs/blob/5141f46bb7c79b212a702522f1c70e528262b477/witness.md">Block Witness Formal Specification</a> for stateless Ethereum. First commit: <span class="badge">Mar 26, 2020</span></p>
<p>Four years later, the person who added the witness spec to cdk-erigon was also me — <a href="https://github.com/0xPolygon/cdk-erigon/pull/59">#59</a>, the same week the prover learned to decode it. <span class="badge">Jan 2024</span> <a href="https://github.com/0xPolygon/cdk-erigon/blob/zkevm/turbo/trie/WITNESS.md">It lives in the tree today</a>.</p>
<p><a href="/writing/kv-witness/">KV-Witness</a> was my proposed second generation. Production picked gen one — the one I specified. Not on merit: that code already existed, and nobody had time to debug a new format. I lost the argument with myself and won it anyway.</p>
<figure tabindex="0"><img src="/static/img/witness-opcode-format.svg" alt="The first-generation format. A witness is a small program: a stack machine executes the opcode tape and rebuilds the par" width="688" height="300" loading="lazy" /><figcaption>The first-generation format. A witness is a small program: a stack machine executes the opcode tape and rebuilds the partial trie — touched state as data, everything untouched as a hash.</figcaption></figure>
<p>Stateless Ethereum never shipped on L1. Its core mechanism ships every day inside the rollups we build at <a href="https://gateway.fm">Gateway</a>.</p>
<h2 id="where-the-idea-shows-up">Where the idea shows up <a class="plink" href="#where-the-idea-shows-up">§</a></h2>
<ul>
<li><strong><a href="https://github.com/ethereum/portal-network-specs/blob/5141f46bb7c79b212a702522f1c70e528262b477/witness.md">Block Witness Formal Specification</a></strong> <span class="badge">2020</span> — the gen-1 spec, written for stateless Ethereum.</li>
<li><strong><a href="https://github.com/0xPolygon/cdk-erigon/blob/zkevm/turbo/trie/WITNESS.md">The witness spec in cdk-erigon</a></strong> <span class="badge">2024</span> — the same lineage, added for the stateless prover.</li>
<li><strong><a href="/writing/kv-witness/">KV-Witness</a></strong> — the 2020 second-generation proposal: what a key-value shape buys over opcodes.</li>
<li><strong><a href="/writing/semi-stateless-initial-sync/">Semi-Stateless Initial Sync</a></strong> and <strong><a href="/writing/stateless-ethereum-binary-tries/">Binary Tries</a></strong> — the mainnet experiments behind the numbers above.</li>
<li><strong><a href="https://github.com/0xPolygon/cdk-erigon">cdk-erigon</a></strong> — the witness-based pipeline in production rollups.</li>
</ul>]]></content:encoded>
</item>
<item>
<title>Private doors and interoperable roads</title>
<link>https://255c.org/notes/private-doors-interoperable-roads/</link>
<guid isPermaLink="true">https://255c.org/notes/private-doors-interoperable-roads/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Tue, 18 Aug 2026 00:00:00 +0000</pubDate>
<description>Listening back to the conversation with Ben, one analogy I think captures the broader problem well: A financial market needs doors and it needs roads. Doors are a useful way to think about institutional privacy. They create boundaries around sensitive information, while defining who gets access, under what conditions, and what can leave the room. Technically, that starts to look like private…</description>
<content:encoded><![CDATA[<p>Listening back to the conversation with Ben, one analogy I think captures the broader problem well:</p>
<p>A financial market needs doors and it needs roads.</p>
<p>Doors are a useful way to think about institutional privacy. They create boundaries around sensitive information, while defining who gets access, under what conditions, and what can leave the room. Technically, that starts to look like private state, selective disclosure, policy-bound access and proofs that something is valid without exposing everything underneath.</p>
<p>But a market made only of private rooms does not function. It also needs roads: the interoperability layer that allows value, instructions and proofs to move between institutions, networks and markets without requiring everyone to operate inside the same environment.</p>
<p>That is the broader tension we get into in this podcast: how do we give institutions the privacy they require without recreating the same fragmented financial silos onchain?</p>
<p>Better rails matter. But so does the market structure we build on top of them.</p>
<h2 id="where-the-idea-shows-up">Where the idea shows up <a class="plink" href="#where-the-idea-shows-up">§</a></h2>
<ul>
<li><strong><a href="https://www.youtube.com/watch?v=nvaJwCy44tQ">Privacy, Ethereum, and the Future of On-Chain Finance</a></strong> — the conversation with Ben Schiller: privacy architectures beyond permissioned blockchains, zero-knowledge proofs, the AggLayer, and the risk of recreating financial silos on new rails.</li>
<li><strong><a href="https://gateway.fm/open-privacy-suite/">Open Privacy Suite</a></strong> — the “doors” part, in built form: identity-aware policy, selective disclosure and audit evidence over standard JSON-RPC.</li>
<li><strong><a href="/writing/regenesis-explained/">ReGenesis Explained</a></strong> — from 2020, an earlier version of the same concern at the protocol layer: state-storage centralization pushes infrastructure toward a few big operators, and what to do about it.</li>
</ul>
<p>Privacy without interoperability gives you isolated rooms — modernized technology without modernizing the financial system. Interoperability without privacy gives you transparency nobody with sensitive positions will accept. The useful work is in holding both at once.</p>]]></content:encoded>
</item>
<item>
<title>Apps without shame</title>
<link>https://255c.org/notes/apps-without-shame/</link>
<guid isPermaLink="true">https://255c.org/notes/apps-without-shame/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Sat, 07 Feb 2026 00:00:00 +0000</pubDate>
<description>Streaks did not make me consistent. They made me quit. At some point I was tracking everything, everywhere. Every app wanted a log, a chart, a chain not to break. The tracking became its own job. I got overwhelmed — and stopped following all of it, the good habits included. That is the failure mode no dashboard shows. The streak works on you right up until it collapses the whole practice. The…</description>
<content:encoded><![CDATA[<p>Streaks did not make me consistent. They made me quit.</p>
<p>At some point I was tracking everything, everywhere. Every app wanted a log, a chart, a chain not to break. The tracking became its own job. I got overwhelmed — and stopped following all of it, the good habits included.</p>
<p>That is the failure mode no dashboard shows. The streak works on you right up until it collapses the whole practice.</p>
<p>The mechanics are not there for you anyway. Streaks, badges, guilt notifications — that is growth hacking, aimed at your willpower.</p>
<p>So I refused all of it. The app has one job: tell you when the moment arrives. A reminder. A kitchen timer.</p>
<h2 id="interfast">Interfast <a class="plink" href="#interfast">§</a></h2>
<p>I built <a href="https://github.com/mandrigin/interfast">Interfast</a> this way in February 2026. An intermittent-fasting app that does not track you — a private local scheduler instead of a tracker.</p>
<p>Fasting doesn’t need streaks, charts, or badges. The only hard part is knowing when each biological milestone hits. So that is the whole app.</p>
<p>No account. No cloud. Nothing to keep up. Break a fast and the app has no opinion about it. You cannot disappoint a kitchen timer.</p>
<p>And it did what the streaks never did: I still use it.</p>
<blockquote>
<p><strong>UPD (August 2026):</strong> it happened again. Marco Arment shipped <a href="https://marco.org/2026/08/14/unforgetful">Unforgetful</a> — the same stance, applied to reminders. Persistent notifications until the thing is actually done. Flexible snoozing. A deliberately simple interface. No gamification anywhere.</p>
<p></p>
<p>Different domain, same refusal: the app works for you, not on you. When two people independently build the same refusal, it is not a feature gap. It is a thesis.</p>
</blockquote>
<h2 id="where-the-idea-shows-up">Where the idea shows up <a class="plink" href="#where-the-idea-shows-up">§</a></h2>
<ul>
<li><strong><a href="https://github.com/mandrigin/interfast">Interfast</a></strong> — fasting as a private local scheduler. “Closer to a kitchen timer than a wellness app.”</li>
<li><strong><a href="https://marco.org/2026/08/14/unforgetful">Unforgetful</a></strong> — Marco Arment’s reminders app, August 2026: persistent, simple, respectful.</li>
<li><strong><a href="https://github.com/mandrigin/leflac">LE FLAC</a></strong> — the same refusal in a music player: no network permission, no accounts, no telemetry.</li>
<li><strong><a href="/projects/" class="sec-link">Projects</a></strong> — the rest of the tools built with this bias.</li>
</ul>]]></content:encoded>
</item>
<item>
<title>“Work Is Work” by Coda Hale</title>
<link>https://255c.org/writing/work-is-work/</link>
<guid isPermaLink="true">https://255c.org/writing/work-is-work/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Wed, 12 Aug 2020 00:00:00 +0000</pubDate>
<description>image by Paul Albertella “Work Is Work (in Which Results Diminish)” is an article from Coda Hale. Its main topic is that scaling teams is hard . Internal tooling, training, and services must be developed and fielded to ensure that all members are able to work on problems of continuously increasing impact. The ceaseless pursuit of force multipliers is the only possible route to superlinear…</description>
<content:encoded><![CDATA[<figure tabindex="0"><img src="/static/img/1024_1*1hwAUhB5ijdHjaE7ox_7jw.jpeg" alt="image by [Paul Albertella](https://www.flickr.com/photos/paulspace/)" width="1024" height="447" loading="lazy" /><figcaption>image by <a href="https://www.flickr.com/photos/paulspace/">Paul Albertella</a></figcaption></figure>
<p>“<a href="https://codahale.com/work-is-work/">Work Is Work (in Which Results Diminish)</a>” is an article from <a href="https://codahale.com/about/">Coda Hale</a>.</p>
<p>Its main topic is that <strong><em>scaling teams is hard</em></strong>.</p>
<blockquote>
<p>Internal tooling, training, and services must be developed and fielded to ensure that all members are able to work on problems of continuously increasing impact. The ceaseless pursuit of force multipliers is the only possible route to superlinear productivity improvements as an organization grows.</p>
</blockquote>
<p>I absolutely agree. When adding more people to the organization, the best thing you can do is to make them work on something that improves productivity of everyone else. Being it a good CI system, internal frameworks, documentation, etc.</p>
<p>Code is smartly using <a href="https://en.wikipedia.org/wiki/Queueing_theory">queueing theory</a> to explain managerial issues:</p>
<blockquote>
<p>As with writing highly-concurrent applications, building high-performing organizations requires a careful and continuous search for shared resources, and developing explicit strategies for mitigating their impact on performance.</p>
</blockquote>
<blockquote>
<p>At some point, adding new members can cause the organization’s overall productivity to decrease instead of increase, as the increase in wait time due to contention is greater than the increase in work capacity. (This is the organizational version of the latency spikes we see as servers become overloaded.)</p>
</blockquote>
<blockquote>
<p>While the consultants can indeed move quickly in a low-contention environment, integrating their work product back into the contended resources often has the effect of ballooning […] how long a critical section is held. This produces a quadratic spike in wait times which increases utilization which in turn produces a superlinear spike in wait times.</p>
</blockquote>
<blockquote>
<p>The more distance between those designing the organization and the work being done, the greater the risk of unmanaged points of contention. Top-down organizational methods can lead to subdivisions which seem like parallel efforts when listed on a slide but which are, in actuality, highly interdependent and interlocking.</p>
</blockquote>
<blockquote>
<p>Staffing highly sequential efforts as if they were entirely parallel leads to catastrophe.</p>
</blockquote>
<blockquote>
<p>[…] the total time spent communicating will grow quadratically as the work capacity of the organization grows linearly.</p>
</blockquote>
<blockquote>
<p>[…] pair-wise communications don’t need to be formal, planned, or even well-known in order to have costs. <strong>Neither your employee handbook nor your calendar are accurate depictions of how work in the organization is done.</strong></p>
</blockquote>
<p>Informal communication is often forgotten about.</p>
<p>Of course, one of the tools that can help with this is applying microservices. I personally think that <strong><em>microservices architecture solves leadership problems, not technical</em></strong>. Though, it also should be done right.</p>
<blockquote>
<p>The key word there is <strong>independent</strong>. Slicing your shit up into a hundred microservices will not help you if everyone needs to change ten of them to get anything done.</p>
</blockquote>
<p>There are solutions, with some of those I do agree wholeheartedly.</p>
<blockquote>
<p>To avoid that, organization leaders should keep the development of a product portfolio as an explicit goal. Feature or product ideas which are complimentary to the organization’s overall business strategy but don’t naturally coexist with the main product can be developed as separate products by independent teams.</p>
</blockquote>
<blockquote>
<p>… tooling, libraries, and frameworks can be developed by force multiplier teams to reduce both time-to-market of new products…</p>
</blockquote>
<p>This is the one point that I disagree with. Trying to do the whole portfolio on a unified “framework”, makes this framework and the team behind it the bottleneck of the organization. You can and likely will end up with “<em>having to change ten of them</em>”, just like the author pointed out earlier.</p>
<p>If you are building everything in the same way, you are missing out on some innovation that new approaches and new technologies can bring to your other products.</p>
<blockquote>
<p>removing a feature from a product involves the same contention and coherence costs as adding a feature</p>
</blockquote>
<p>100% that! A lot of people for some reason think that adding a feature is harder than removing it. <strong>For non-trivial features it is not true</strong>. You can break half of the product by trying to remove the traces of a feature.</p>
<p><strong>Remainders of old features will haunt the codebase forever</strong>, making it is less secure, harder to change and harder to onboard new people on.</p>
<blockquote>
<p>Synchronous meetings should be reserved for low-latency collaboration on complex issues; likewise, collaboration should be reserved for synchronous meetings.</p>
</blockquote>
<p>In the ideal world, yes.</p>
<blockquote>
<p>Companies are groups of people being compensated for having to spend some of their finite lifetimes not being with their partners, children, pets, or super weird hobbies.</p>
</blockquote>
<p>One more important view point there.</p>]]></content:encoded>
</item>
<item>
<title>KV-Witness</title>
<link>https://255c.org/writing/kv-witness/</link>
<guid isPermaLink="true">https://255c.org/writing/kv-witness/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Tue, 14 Jul 2020 00:00:00 +0000</pubDate>
<description>an alternative approach to block witnesses Update (2026): the opcode-based first-generation format this post argues with is used in stateless ZK proving: cdk-erigon generates it and the zkevm prover consumes it. The linked implementation history dates to January 2024. KV-Witness below is the proposed second generation. The full story: Stateful vs stateless ZK proving. There is currently a…</description>
<content:encoded><![CDATA[<h3 id="an-alternative-approach-to-block-witnesses">an alternative approach to block witnesses <a class="plink" href="#an-alternative-approach-to-block-witnesses">§</a></h3>
<blockquote>
<p><strong>Update (2026):</strong> the opcode-based first-generation format this post argues with is used in stateless ZK proving: cdk-erigon generates it and the zkevm prover consumes it. The linked implementation history dates to January 2024. KV-Witness below is the proposed second generation. The full story: <a href="/notes/stateful-vs-stateless-zk-proving/">Stateful vs stateless ZK proving</a>.</p>
</blockquote>
<p>There is currently a proposed format for block witnesses in <a href="https://blog.ethereum.org/2019/12/30/eth1x-files-state-of-stateless-ethereum/">Stateless Ethereum</a>, that has a spec <a href="https://github.com/ethereum/portal-network-specs/blob/5141f46bb7c79b212a702522f1c70e528262b477/witness.md">in a GitHub repo</a>. It is based on opcodes. You can imagine a tiny programming language with just a few commands that generate a <a href="https://medium.com/@jgm.orinoco/understanding-sparse-merkle-multiproofs-9b9f049e8f08">Merkle Multiproof</a>.</p>
<p>This post researches an alternative approach to block witness construction. It is based on a list of keys and values and has a simpler semantics.</p>
<p>In this post I will try to answer the following questions:</p>
<ul>
<li>What is the KV witness format and how it is different from currently proposed (opcode-based) Witness format?</li>
<li>What are the pros and cons of the KV comparing to OP?</li>
<li>How efficient this format is in terms of network bandwidth?</li>
</ul>
<h2 id="requirements">Requirements <a class="plink" href="#requirements">§</a></h2>
<p>Any block witness must satisfy the following requirements:</p>
<ul>
<li><em>Correctness.</em> We should be able to run any block from Ethereum mainnet using this format.</li>
<li><em>Efficiency.</em> We should use the minimum network footprint to transfer this witness.</li>
<li><em>Merkelization.</em> The witness format must support <a href="https://medium.com/ewasm/evm-bytecode-merklization-2a8366ab0c90">Code Merkelization</a>.</li>
<li><em>Arity-agnostic</em>. The witness format must support both <a href="https://medium.com/@mandrigin/stateless-ethereum-binary-tries-experiment-b2c035497768">hexary and binary Merkle Tries</a>.</li>
</ul>
<h2 id="semantics">Semantics <a class="plink" href="#semantics">§</a></h2>
<p>Witness format I describe in this part of the post is <a href="https://stackoverflow.com/questions/17930267/what-is-the-difference-between-syntax-and-semantics-in-programming-languages">semantics</a>. I’m not talking about the exact byte layout here.</p>
<p>Later on, I will touch more on the exact binary format of the witness that was used for testing.</p>
<figure tabindex="0"><img src="/static/img/668_1*UfdyOFiGHaeldq_Rj7ovVw.png" alt="KV-Witness" width="668" height="477" loading="lazy" /><figcaption>KV-Witness</figcaption></figure>
<pre><code>witness ::= header, body, proofs
header ::= version : byte, trie_arity : byte
body ::= array of [ { type: byte key : []byte, value : []byte } ]
proofs ::= map { &lt;type&gt;: [ { prefix : []byte, hash : []byte } ] }</code></pre>
<h3 id="witness-body">Witness body <a class="plink" href="#witness-body">§</a></h3>
<p>Witness body conists of 2 elements:</p>
<ul>
<li>Data.</li>
</ul>
<p>The key can be: an account address, a storage key or a code key and the value is an account, a storage item or a code chunk respectively. <strong><em>This part of the witness body is completely agnostic to the arity of a Merkle Trie that is used to validate its correctness. Moreover, if we use something else for correctness check this part won’t change.</em></strong></p>
<ul>
<li>Proof(s).</li>
</ul>
<p>The key is the Merkle path and the value is a hash. The proof is dependent on the trie arity and will be different for hex and bin tries. <strong><em>This semantics allows including multiple proofs with different types in the same witness. So, we can theoretically make a witness that supports both hex and bin tries.</em></strong></p>
<p>body is sorted lexicographically by key, making sure that:</p>
<ul>
<li>shorter keys are earlier in the list (so we are rebuilding a trie from top to bottom);</li>
<li>when keys are equal (that could happen for account and code) <em>account</em> always goes first.</li>
</ul>
<h3 id="parsing-algorithm">Parsing Algorithm <a class="plink" href="#parsing-algorithm">§</a></h3>
<ul>
<li>Validate witness version and the proof arity (make sure that the witness proof arity matches the trie arity that that block requires).</li>
<li>Validate the witness hash (if canonical witness is there).</li>
<li>Create an empty trie of the right arity.</li>
<li>Go though the data, just insert data into this trie in the order it comes (witness should be lexicographically sorted).</li>
<li>Insert proofs into the trie.</li>
<li>Validate root hash (should match the root hash of the <strong><em>previous</em></strong> block).</li>
</ul>
<h2 id="pros-cons">Pros &amp; Cons <a class="plink" href="#pros-cons">§</a></h2>
<p>Here is the list of pros and cons comparing KV-Witness vs <a href="https://github.com/ethereum/portal-network-specs/blob/5141f46bb7c79b212a702522f1c70e528262b477/witness.md">the current opcode-based witness format</a>.</p>
<h3 id="pros"><strong>Pros</strong> <a class="plink" href="#pros">§</a></h3>
<ul>
<li>It matches the flat DB structure, can be inserted immediately if the canonical witness hash is valid (no need to verify Merkle Root).</li>
<li>It can be used for snapshot sync.</li>
<li>The witness data is independent from the validity proof method we choose: Merkle Tries or Polynomial Commitments or something else.</li>
</ul>
<h3 id="cons"><strong>Cons</strong> <a class="plink" href="#cons">§</a></h3>
<ul>
<li>Potentially higher network footprint on binary tries due to byte alignment (e.g. the proof key 0b01, that is 2 bits will take a byte of storage space).</li>
<li>Potentially slower witness parsing.</li>
</ul>
<h2 id="network-efficiency-research">Network Efficiency Research <a class="plink" href="#network-efficiency-research">§</a></h2>
<h3 id="kv-witness-example-implementation">KV Witness Example Implementation <a class="plink" href="#kv-witness-example-implementation">§</a></h3>
<p>We need to be able to prove the correctness of the format. It should be able to run on all blocks of Ethereum Mainnet.</p>
<p>To do that, I have implemented this witness format in a branch of turbo-geth repository: <a href="https://github.com/ledgerwatch/turbo-geth/tree/kv-witness-research">kv-witness-research</a>.</p>
<p>This implementation was tested in Google Cloud on Ethereum mainnet blocks from 5.000.000–8.000.000.</p>
<h3 id="how-to-repeat-the-experiment">How to repeat the experiment? <a class="plink" href="#how-to-repeat-the-experiment">§</a></h3>
<p>You need at least 200GB of free space and least 32gbs of RAM (the code is a PoC and isn’t optimized much).</p>
<p>1) clone kv-witness-research branch of turbo-geth (commit aa6b4dc609b3d871c778597a71ac08601f17de53</p>
<p>2) (took 1 day in my case) sync block headers and bodies for mainnet: go run ./cmd/geth --syncmode staged --datadir ~/stateless-chaindata/</p>
<p>3) (took 17 days in my case) run stateless prototype on this data</p>
<pre><code>go run ./cmd/state stateless --blockSource ~/stateless-chaindata/geth/chaindata --statefile ~/kv_witness_statefile --witnessInterval 5000000 --statsfile ~/stats_kv_witness.csv 2&gt;&amp;1 | tee debug.log</code></pre>
<p>That way, in stats_kv_witness.csv you should obtain the same stats as I have in this document.</p>
<h3 id="witness-binary-format">Witness binary format <a class="plink" href="#witness-binary-format">§</a></h3>
<p>The witness starts with a single-byte header that contains version: header.</p>
<p>Then, there is a witness body that consists of the size (1-4 bytes dependent on the number of witness elements) and the elements themselves.</p>
<p>Each element starts with a single-byte type, followed by key field that is a byte array of arbitrary size prefixed by the size byte (just like body itself) followed by the actual data.</p>
<p>Data depends on what type of element is there:</p>
<ul>
<li>for storage leafs it is a byte array of arbitrary size refixed by the size bytes;</li>
<li>for code leafs it is a byte array of arbitrary size prefixed by the size bytes too;</li>
<li>for proofs it is a fixed-size 32 byte hash value w/o any size prefix;</li>
</ul>
<p>For accounts it is more complicated, but basically it is</p>
<ul>
<li>flags byte (mask that tells if account elements don’t have their default values)</li>
<li>nonce, 8 bytes (if nonce != 0)</li>
<li>balance (if balance != 0), byte array of arbitrary size, prefixed by its size;</li>
<li>storage root hash (if not empty root hash), 32 bytes, byte array of fixed size;</li>
<li>code hash (if code not empty), 32 bytes, byte array of fixed size.</li>
</ul>
<p>In the end we get something like this: this: [&lt;header&gt; &lt;witness_elements_count&gt; &lt;element1_type&gt; &lt;element1_key_size&gt; &lt;element1_key_byte1&gt; … &lt;element1_value_size&gt; … &lt;element2_type&gt; …]</p>
<figure tabindex="0"><img src="/static/img/721_1*y2Qvb5ttuYa6jUT-gLP77A.png" alt="KV-Witness" width="721" height="784" loading="lazy" /><figcaption>KV-Witness</figcaption></figure>
<p><strong>Optimization: Key prefix deduplication</strong></p>
<p>Key is a Merkle path whose elements use 4 bits for a hexary trie and 1 bit for a binary trie. A key can therefore occupy a non-integer number of bytes: for example, 12 bits is 1.5 bytes, requiring 2 whole bytes when byte-aligned.</p>
<p><em>Editorial correction — September 5, 2026: the original example incorrectly said that 12 bits was “8,5 bytes.” A nibble is always 4 bits; a binary-trie path element uses 1 bit.</em></p>
<p>The key is encoded as []byte, where it is aligned by byte (so a key with a len between 4 and 5 bytes will always be 5 bytes). Also, an additional “mask” byte is added to the beginning that shows which bits are “active” in the last byte.</p>
<ul>
<li>a key 0xFF (1 byte): [00001000 11111111] &lt;== 8 significant bits</li>
<li>a key 0b11(2 bits): [00000010 11000000] &lt;== 2 significant bits</li>
<li>a key 0b10(2 bits): [00000010 10000000] &lt;== 2 significant bits</li>
<li>a key 0b_10101010_01010101_1101(2 bytes 4 bits): [11110000 10101010 01010101 11010000]</li>
</ul>
<p>Then, we can add a simple optimization that allows us to mitigate repeating prefixes in both data and proofs.</p>
<p><strong><em>To increase compression efficiency, we will intermix both data and proof in the same ordered map.</em></strong></p>
<figure tabindex="0"><img src="/static/img/709_1*8BiVp3Gj7k6O51047s9svg.png" alt="Data and proof are together sorted lexicographically" width="709" height="792" loading="lazy" /><figcaption>Data and proof are together sorted lexicographically</figcaption></figure>
<p>The highest 4 bits of a header byte mean a byte offset of a previous key.</p>
<p>Since in our semantics the keys are sorted, we can use the first 4 bytes describe the followng cases:</p>
<ul>
<li>the key is the same as the previous one, the whole key can then be reduced to 1 byte: [10000000]</li>
<li>the key doesn’t share any bytes with the previous one ([0000xxxx xxxxxxxx …])</li>
<li>the key shares up to 14 prefix bytes with the previous one ([????xxxx xxxxxxxx …]): ??? is big-endian encoded number 1 (001) to 14 (1110).</li>
<li>the key shares 15 or more bytes with the previous one ([1111xxxx ???????? xxxxxxxx …]): where ???????? is an addition to 15.</li>
<li>for 15 bytes it will be [1111xxxx 00000000 … ] (15 + 0)</li>
<li>for 16 bytes it will be [1111xxxx 00000001 … ] (15 + 1)</li>
<li>for 32 byte it will be [1111xxxx 00010001 … ] (15 + 17)</li>
</ul>
<figure tabindex="0"><img src="/static/img/709_1*EWoJyKYvmcYHbycJYBxiQQ.png" alt="KV-Witness Compression. The number in parenthesis tells how many bits to reuse from the previous key." width="709" height="792" loading="lazy" /><figcaption>KV-Witness Compression. The number in parenthesis tells how many bits to reuse from the previous key.</figcaption></figure>
<h3 id="network-efficienty-research-results">Network Efficienty Research Results <a class="plink" href="#network-efficienty-research-results">§</a></h3>
<p><em>Raw data for the results is available in this GitHub repo: </em><a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data"><em>https://github.com/mandrigin/ethereum-mainnet-kv-witness-data</em></a></p>
<p>To give a comprehensive image in terms of network efficiency, we compare 3 types of witnesses, all of them are running on hexary tries:</p>
<p>1) <strong>Opcode witness</strong>, the <a href="https://github.com/ethereum/portal-network-specs/blob/5141f46bb7c79b212a702522f1c70e528262b477/witness.md">existing one</a>. (Data is from <a href="https://github.com/mandrigin/ethereum-mainnet-bin-tries-data">my previous experiments</a>).</p>
<p>2) <strong>KV Witness(uncompressed)</strong>: no key prefix deduplication.</p>
<p>3) <strong>KV Witness(compressed)</strong>: key prefix deduplication is included.</p>
<p>Tests were conducted on blocks <strong>5.000.000–8.000.000.</strong>Absolute size comparison**</p>
<figure tabindex="0"><img src="/static/img/1024_1*tTU-r9uWqL6rfEc9B6kwoQ.png" alt="Absolute size comparison. Compressed KV witness behaves pretty much like the opcode witness." width="1024" height="309" loading="lazy" /><figcaption>Absolute size comparison. Compressed KV witness behaves pretty much like the opcode witness.</figcaption></figure>
<p><strong>Quantile analysis</strong></p>
<figure tabindex="0"><img src="/static/img/1024_1*iP0QawRnb_fB5w8fE6UPgg.png" alt="" width="1024" height="291" loading="lazy" /></figure>
<h3 id="verified-comparison-september-5-2026">Verified comparison — September 5, 2026 <a class="plink" href="#verified-comparison-september-5-2026">§</a></h3>
<p>This table adds a numerical comparison to the original charts. It recalculates the archived <code>BlockWitnessSize</code> values for <strong>2,997,799 unique mainnet blocks</strong>, <strong>5,002,202–8,000,000 inclusive</strong>, the complete shared interval within the original experiment’s 5,000,000–8,000,000 range. All three formats use hexary tries. “Compressed” means the key-prefix deduplication described above; no extra compression or key-size adjustment is applied here.</p>
<div class="table-scroll" role="region" tabindex="0" aria-label="Table: Format, Mean (MiB), Median (MiB), 95th percentile (MiB), 99th percentile (MiB)"><table>
<thead><tr><th scope="col">Format</th><th scope="col">Mean (MiB)</th><th scope="col">Median (MiB)</th><th scope="col">95th percentile (MiB)</th><th scope="col">99th percentile (MiB)</th></tr></thead><tbody>
<tr><td>Opcode</td><td>1.1601</td><td>1.2099</td><td>1.9913</td><td>2.2150</td></tr>
<tr><td>KV, compressed</td><td>1.0655</td><td>1.1076</td><td>1.8389</td><td>2.0487</td></tr>
<tr><td>KV, uncompressed</td><td>1.4121</td><td>1.4707</td><td>2.4414</td><td>2.7384</td></tr>
</tbody></table></div>
<p>On this matched sample, compressed KV witnesses have an <strong>8.15% smaller mean size than opcode witnesses</strong>, and a <strong>24.55% smaller mean than uncompressed KV witnesses</strong>. These percentages compare arithmetic means, rather than averaging per-block percentage differences. They measure serialized witness size in this historical implementation, not parsing speed or present-day rollup costs.</p>
<p>Sources: <a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data/blob/ab170bf6da6719bbc441cd30a92c990cbbc455d7/stats_opcode.csv">opcode CSV</a>, <a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data/blob/ab170bf6da6719bbc441cd30a92c990cbbc455d7/stats_kv_compressed.csv">compressed KV CSV</a>, and <a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data/blob/ab170bf6da6719bbc441cd30a92c990cbbc455d7/stats_kv_uncompressed.csv">uncompressed KV CSV</a>. Each downloaded file was checked against its Git LFS SHA-256. The calculation matches by block number and removes repeated entries with identical witness sizes: one repeated row in the compressed file and two in the uncompressed file, within this interval. There are no missing blocks in the resulting comparison.</p>
<p>To reproduce the table, select that inclusive interval, keep one <code>BlockWitnessSize</code> per block, and divide bytes by <strong>1,048,576</strong>. Compute the arithmetic mean and linearly interpolated quantiles of the sorted sizes. The byte totals before conversion are 3,646,563,098,859 for opcode, 3,349,198,609,461 for compressed KV, and 4,438,857,983,117 for uncompressed KV. The <a href="/tools/verify_witness_stats.py">recalculation script</a> records the input hashes and exact calculations. The original <a href="https://github.com/mandrigin/ethereum-mainnet-kv-witness-data/blob/ab170bf6da6719bbc441cd30a92c990cbbc455d7/percentile.py">plotting script</a> also divides by 1,024² but labels the axis “MB”; the table uses the corresponding unit, <strong>MiB</strong>. The original charts and publication date are retained.</p>
<h2 id="conclusion">Conclusion <a class="plink" href="#conclusion">§</a></h2>
<p>Key prefix deduplication does provide significant improvements to the KV witness. With it enabled, we have almost the same numbers between these two formats.</p>
<p>The KV Witness has a couple of advantages.</p>
<p>The main one is its simplicity. It is much easier to make a spec for a data format, essentially a dictionary, then a more complicated almost-programming-language approach.</p>
<p>The second advantage is that proof is semantically separate from the data, so when we want to change trie arity (from hexary to binary) or when we want to change the proof mechanics completely, it is will require less changes with the KV-Witness approach.</p>
<p>I think it is definitely a worthy contender for the witness spec standard.</p>]]></content:encoded>
</item>
<item>
<title>ReGenesis Explained</title>
<link>https://255c.org/writing/regenesis-explained/</link>
<guid isPermaLink="true">https://255c.org/writing/regenesis-explained/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Sun, 28 Jun 2020 00:00:00 +0000</pubDate>
<description>The amount of money locked in DeFi apps surpassed $1.500.000.000; DApps are being announced almost every day. At that rate, Ethereum can become a victim of its own success. One of the struggles on the infrastructure layer is boundless state growth. A couple of days ago Alexey published an an article at EthResearch forums with an interesting idea on how to help with exactly that. He called it…</description>
<content:encoded><![CDATA[<p>The amount of money locked in DeFi apps surpassed $1.500.000.000; DApps are being announced almost every day. At that rate, Ethereum can become a victim of its own success. One of the struggles on the infrastructure layer is boundless state growth.</p>
<p>A couple of days ago <a href="https://twitter.com/realLedgerwatch">Alexey</a> published an an <a href="https://ethresear.ch/t/regenesis-resetting-ethereum-to-reduce-the-burden-of-large-blockchain-and-state/7582">article at EthResearch forums</a> with an interesting idea on how to help with exactly that. He called it <strong><em>ReGenesis</em></strong>.</p>
<p>The idea is relatively simple and might look very radical at the first sight: <strong><em>let’s nuke all the state we have locally at deterministic schedule (say, every 1.000.000 blocks), keep the root hash of the latest block and then begin rebuilding the state from scratch until the next 1.000.000 blocks passes and next state extinction event happens</em></strong>.</p>
<figure tabindex="0"><img src="/static/img/1024_1*gEy7w62hVTREJH2pnjO7GA.png" alt="ReGenesis: Reseting state every N blocks. State grows, witnesses shrink. Until the next ReGenesis." width="1024" height="163" loading="lazy" /><figcaption>ReGenesis: Reseting state every N blocks. State grows, witnesses shrink. Until the next ReGenesis.</figcaption></figure>
<p>To understand, why this idea might work and is worth researching, one needs some context and explanation.</p>
<p>This is what this post is exactly about.</p>
<h2 id="current-state-of-affairs">Current State of Affairs <a class="plink" href="#current-state-of-affairs">§</a></h2>
<ul>
<li><strong>Centralisation of state storage.</strong></li>
</ul>
<p>It is very easy to send a transaction in Ethereum, to do that you don’t really need much state or anything. Transaction senders aren’t motivated to keep any state whatsoever.</p>
<p>If you are running an infrastructure node (a miner, or an exchange), at the other hand, you need to make sure that you have all the state possible to be able to validate the transaction and to propagate it further. Even more so if you are a miner.</p>
<p>That way, we have incentivies to centralize storage of the current state in infrastructure nodes who usually are being runned by bigger entities: Infura, big miners, exchanges, etc.</p>
<ul>
<li><strong>Stage Growth Continues Unbounded.</strong></li>
</ul>
<p>That is it, “current state” bucket in <a href="https://github.com/ledgerwatch/turbo-geth">Turbo-Geth</a> is about 40 GB at the time of writing and keeps growing.</p>
<p>The problem here is not the state size itself, but it uncapped growth. Sure, we might try to hope that fast SSD drives capacity is growing faster than the blockchain state.</p>
<p>We were lucky here so far, but being lucky isn’t a viable long-term strategy.</p>
<ul>
<li><strong>Stateless Ethereum Gas Repricing is hard.</strong></li>
</ul>
<p><a href="https://blog.ethereum.org/2020/01/28/eth1x-files-the-stateless-ethereum-tech-tree/">Stateless Ethereum</a> initiative has a very tricky job to price block witnesses. Those witnesses are produced by miners and it is difficult to predict when sending a transaction how big the block witness would be.</p>
<p>That way, it requires to somehow infere the witness price from smart contract behaviour without breaking existing smart contracts.</p>
<p>There were a couple of proposals there, notably <a href="https://ethresear.ch/t/oil-adding-a-second-fuel-source-to-the-evm-pre-eip/7394">Oil</a>, but it is a hard problem to solve.</p>
<h2 id="running-transactions-post-regenesis">Running transactions post-ReGenesis <a class="plink" href="#running-transactions-post-regenesis">§</a></h2>
<p>Okay, we all got the idea, you nuke all the current state except the root hash. Disk size goes 40GB → 32 bytes.</p>
<p>Amazing, disk space saved.</p>
<p>But how do I send transactions?</p>
<p>Stateless Ethereum comes to the rescue. To be able to run your transaction, you need to provide a witness. The witness consists of the state of used accounts, code and storage as well as Merkle proofs to be able to validate the root hash (more on witnesses and Stateless Ethereum <a href="https://github.com/ethereum/stateless-ethereum-specs">here</a>).</p>
<p>There is one difference between ReGenesis and Stateless Ethereum though. To explain that I would like to introduce 2 pieces of terminology: <strong><em>explicit</em></strong> state and <strong><em>implicit</em></strong> state.</p>
<p>Say, you are running a geth node now. Whenever you peer sends you a new block N, it assumes that you already have all the state needed to validate all transactions in this block, that you have synced to the block N-1.</p>
<figure tabindex="0"><img src="/static/img/1024_1*CulRHD7j638uDbQYBO-7ZA.png" alt="Today’s Ethereum: We imply that both nodes have all the state needed." width="1024" height="613" loading="lazy" /><figcaption>Today’s Ethereum: We imply that both nodes have all the state needed.</figcaption></figure>
<p>That is <strong><em>100% implicit state</em></strong>. Your peer implied that you already have the state and didn’t add to the block anything.</p>
<p>In Stateless Ethereum, when you run a node, and your peers send you a new block N, they assume that you have no implicit state whatsoever. They just include everything you can possibly need to run this block in the block itself. It is a Block Witness.</p>
<figure tabindex="0"><img src="/static/img/1024_1*XDRamQg57ZurGY6-6b6O9g.png" alt="Stateless Ethereum: We provide all state as explicitly." width="1024" height="613" loading="lazy" /><figcaption>Stateless Ethereum: We provide all state as explicitly.</figcaption></figure>
<p>Your peer is sending you <strong><em>explicit state</em></strong>.</p>
<p>ReGenesis does something in between.</p>
<p>Let’s imagine ReGenesis has happened at the block 10.000.000. Right now the chain head is at the block 10.001.000. We can assume that any ReGenesis node has implicit state for everything between blocks 10m and 10,001m. Every account, every storage entry and every contract that was used in these blocks already exist on every node and don’t require a witness. That can reduce witness size substantially, as we saw in the <a href="https://medium.com/@mandrigin/semi-stateless-initial-sync-experiment-897cc9c330cb">semi-stateless sync experiment</a>.</p>
<figure tabindex="0"><img src="/static/img/1024_1*dxlo0fecsgySvMrWpOuDEg.png" alt="ReGenesis: Block 1 provides some information that does not exist on the Node1." width="1024" height="629" loading="lazy" /><figcaption>ReGenesis: Block 1 provides some information that does not exist on the Node1.</figcaption></figure>
<figure tabindex="0"><img src="/static/img/1024_1*KAA-bFEpn287XYawDMSgNQ.png" alt="ReGenesis: the state from Block 1 is merged to Node 1’s implicit state." width="1024" height="613" loading="lazy" /><figcaption>ReGenesis: the state from Block 1 is merged to Node 1’s implicit state.</figcaption></figure>
<p>If you, as a transaction senders need to send a new transaction to the network that is currently at the block 10.001.000, you need to follow these steps:</p>
<ul>
<li>create a transaction that you want;</li>
<li>take a look at the implicit state that was generated since the last ReGenesis;</li>
<li>create explicit state for the entries that are NOT inlcluded in implicit state, package it as a transacton witness (we will discuss what it is a bit later on);</li>
<li>send the transaction with the witness to the network;</li>
</ul>
<h2 id="wait-that-will-require-transaction-senders-to-have-some-state-even-after-regenesis">Wait. That will require Transaction Senders to have some state even after ReGenesis! <a class="plink" href="#wait-that-will-require-transaction-senders-to-have-some-state-even-after-regenesis">§</a></h2>
<p>Yes.</p>
<p>If you want to send a transaction after ReGenesis, you might need some pre-ReGenesis state information to be able to generate a witness.</p>
<p>Though, for most DApps, that means that they need to store state of a minor subset of contracts and accounts they actually use (plus a Merkle Proof of course).</p>
<p>That makes this optimization a bit less dramatic to them. On the bright side, potentially shifts incentives to decentralise the data storage.</p>
<h2 id="transaction-witnesses">Transaction Witnesses <a class="plink" href="#transaction-witnesses">§</a></h2>
<p>As you have probably noticed, I’ve mentioned transaction witnesses before.</p>
<h3 id="transactional-witnesses-vs-block-witnesses">Transactional Witnesses vs. Block Witnesses <a class="plink" href="#transactional-witnesses-vs-block-witnesses">§</a></h3>
<figure tabindex="0"><img src="/static/img/1024_1*hbpKhaChSSpHRPoNluYAkQ.png" alt="A single combined block witness." width="1024" height="715" loading="lazy" /><figcaption>A single combined block witness.</figcaption></figure>
<p>Instead of having a witness for the whole block (a block witness), we have a witness per transaction.</p>
<figure tabindex="0"><img src="/static/img/1024_1*ov1lw76iJ05LZfBsIj7_YA.png" alt="Transaction Witnesses" width="1024" height="715" loading="lazy" /><figcaption>Transaction Witnesses</figcaption></figure>
<p>Transaction witnesses contain explicit state for all accounts, storage entries and code used in this transaction. They also contain a <a href="https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/">Merkle Proof</a> to ensure we can verify the state.</p>
<figure tabindex="0"><img src="/static/img/1024_1*8CyTUiCoEWBcby81snTyIQ.png" alt="Block Witnesses are generated by a miner. We need a tricky gas pricing to compensate them." width="1024" height="908" loading="lazy" /><figcaption>Block Witnesses are generated by a miner. We need a tricky gas pricing to compensate them.</figcaption></figure>
<p>Transaction witnesses have one important benefit. They are generated on the sender and are sent with the transaction. Hence, we know their size immediately and it is obvious how to price them. We don’t need EVM repricing.</p>
<figure tabindex="0"><img src="/static/img/1024_1*kOQqoWXOXKn9yNAmEo7VvA.png" alt="Transaction Witnesses are generated by senders create witnesses, much easier to compensate." width="1024" height="781" loading="lazy" /><figcaption>Transaction Witnesses are generated by senders create witnesses, much easier to compensate.</figcaption></figure>
<p>One potential downside of using transaction witnesses is the data duplication. If say, all transactions in the block will be between same accounts, transaction witnesses will contain duplicate data.</p>
<p>Another downside is a bit more complicated algorithm of applying those witnesses.</p>
<p>Block witnesses are generated on a miner. The miner knows the exact ordering of transactions to include, so the witness always contains up-to-date data.</p>
<p>Transaction witnesses that are sent from a sender. There should be an intelligent “merging” of the witness with implicit state generated by previous transactions in the block.</p>
<p>But the whole idea of ReGenesis would need it, so it isn’t that big of a deal.</p>
<h3 id="why-cant-we-use-transactional-witnesses-right-now">Why can’t we use transactional witnesses right now? <a class="plink" href="#why-cant-we-use-transactional-witnesses-right-now">§</a></h3>
<p>A short answer a mix of Dynamic State Access and potential front-running transactions by malicious agents.</p>
<p>A longer answer is as follows.</p>
<p>In Stateless Ethereum you need to provide the full state for this transaction, we assume that the recipient has no state whatsoever. If your transaction uses Dynamic State Access, that means that which parts of the storage your code reads depends on values in other parts of the code.</p>
<p>That opens the possibility for the following theoretical DoS attack.</p>
<p>Alice has her smart contract reading either state entry A or B based on the storage value K. Bob can change this value K. Bob can frontrun his transactions before Alice.</p>
<p>That way if Alice provides a proof that contains A, Bob can change K before Alice’s transaction, so her transaction fails. If she provides a proof for B, he can again stop the transaction.</p>
<p>In this simple case, Alice can of course just provide both A and B, but if the address is determined by a uint64 or something similar Alice might have to include the full state in a proof to avoid this attack, which is impossible.</p>
<p>Of course, this attack is theoretical. But there might be more attacks possible in a similar manner. Moreover with the current amount of money in DApps, we need to be very careful not to break anything.</p>
<h3 id="how-does-regenesis-help-with-mitigating-that">How does ReGenesis help with mitigating that? <a class="plink" href="#how-does-regenesis-help-with-mitigating-that">§</a></h3>
<p>Deterministic nature of ReGenesis helps to determine how much state the node does have. For the state, that we are sure exists on the node, we need no proof.</p>
<p>To mitigate the attack we need to be sure that <strong><em>the proof that we provide gets included in the state no matter if the transaction fails due to insufficient state or succeeds</em></strong>.</p>
<p>So, in the scenario described before.</p>
<p>When Alice sends a transaction with the proof with the path A, but Bob makes sure that the value at the address K is such that the Alice’s contract has to go to the path B.</p>
<p>Alice’s transaction fails, but it adds everything that the path A needs to the node’s implicit state.</p>
<p>Now Alice can re-send the transaction, this time providing the proof for the path B. Bob cannot stop this transaction by this switch anymore, because if he changes the variable at K such that is goes to the path A again, it is too late, it is in the implicit state, so the transaction can go there without any proof. For B, there is a proof.</p>
<h2 id="conclusion">Conclusion <a class="plink" href="#conclusion">§</a></h2>
<p>Okay, so let’s recap the idea and its key points:</p>
<ul>
<li>every N blocks, we just remove all state, keeping only the root hash;</li>
<li>this event should be relatively rare, maybe each 1.000.000 blocks, maybe each 10.000.000 blocks or something;</li>
<li>to send a transaction, the sender will need to provide explicit state (as a Transaction Witness);</li>
<li>the sender pays gas for the transaction witness inclusion based on the witness size;</li>
<li>to achieve that, the sender will have to keep some pre-ReGenesis state for contracts/accounts it is interested in;</li>
<li>if the transaction fails due to insufficient explicit state, we add the provides state as implicit and we won’t require it on the next send;</li>
<li>there is a smart merging mechanism to merge explicit state from the transaction proof with implicit state of a node after running previous transactions in the block.</li>
</ul>
<p>As we can see, after zooming out and seeing a bigger picture, ReGenesis approach can <em>potentially</em>:</p>
<ul>
<li>shift the incentives balance between Transaction Senders and Infrastructure nodes to achieve higher decentralization of state storage;</li>
<li>limit state growth to growth between ReGenesis events (with a few caveats);</li>
<li>allow to use Transaction Witnesses and simplify gas pricing for each witness;</li>
</ul>
<p>Of course, a lot of these things should be tested, challenged and proved first. I think it is an interesting and very promising area of research that brings a surprising amount of potential benefits.</p>]]></content:encoded>
</item>
<item>
<title>Semi-Stateless Initial Sync Experiment</title>
<link>https://255c.org/writing/semi-stateless-initial-sync/</link>
<guid isPermaLink="true">https://255c.org/writing/semi-stateless-initial-sync/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Wed, 12 Feb 2020 00:00:00 +0000</pubDate>
<description>Editorial correction — September 5, 2026: the original conclusion said “around 0.4 MB” per block. Recalculating the archived CSV reproduces the published mean as 0.037598 MiB per recorded witness entry , about 39,424 bytes. The old plots label binary megabytes as MB, and the archive does not contain a row for every block. The verification below documents the units, sample and limits; the original…</description>
<content:encoded><![CDATA[<blockquote>
<p><strong>Editorial correction — September 5, 2026:</strong> the original conclusion said “around 0.4 MB” per block. Recalculating the archived CSV reproduces the published mean as <strong>0.037598 MiB per recorded witness entry</strong>, about 39,424 bytes. The old plots label binary megabytes as MB, and the archive does not contain a row for every block. The <a href="#verified-measurements-september-5-2026">verification below</a> documents the units, sample and limits; the original publication date is unchanged.</p>
</blockquote>
<figure tabindex="0"><img src="/static/img/1024_1*A1zUVYXI9ObrUyYKjCkk4w.png" alt="" width="1024" height="552" loading="lazy" /></figure>
<pre><code>Raw data and scripts for the experiment: https://github.com/mandrigin/ethereum-mainnet-resolver-witness-stats</code></pre>
<h2 id="how-semi-stateless-sync-works">How semi-stateless sync works <a class="plink" href="#how-semi-stateless-sync-works">§</a></h2>
<p>One of the possible ideas to speed up the initial sync process it to use block witnesses to pre-build the cache trie to avoid slow state access. That will cost additional disk space and network bandwidth but potentially can significantly speed up the sync process.</p>
<p>How will that work? Basically, to run each block, we need some data in a Merkle trie. Before the block execution we already have some nodes there, but it might not be enough to run the block. Normally, this data will be taken from the state db and then added to the trie while the transactions are being executed. That might be slow because of the disk access/db lookups.</p>
<p>So we have 3 types of a flow here:</p>
<p><strong>1)Normal flow (as currently in Ethereum nodes)</strong></p>
<ul>
<li>Before the block B is executed, we have a trie T1.</li>
<li>As we execute the block, we add missing bits and pieces to the trie, making it T1’, T1'', etc. Every time we miss some information, we look it up from the database (slow).</li>
<li>After the block B is executed we have the trie T2 that has all the account states to run the block B.</li>
<li>We keep T2 for the future resolutions.</li>
</ul>
<p><strong>2)Stateless flow</strong></p>
<ul>
<li>Before the block B is executed, we don’t have a trie and we have a witness W to reconstruct the trie required to run this block.</li>
<li>We execute W and get the trie T2.</li>
<li>We execute the block B on T2, no DB lookups needed.</li>
<li>We throw away T2 after the block is executed.</li>
</ul>
<p><strong>3)Semi-stateless flow (this experiment)</strong></p>
<ul>
<li>Before the block B is executed, we have a trie T1 and witnesses W1, W2, … enough to convert T1 into T2.</li>
<li>We execute W1, W2, etc on T1, and get the trie T2. No DB lookups needed.</li>
<li>We execute the block B on T2, no DB lookups needed.</li>
<li>We keep T2 for the future resolutions.</li>
</ul>
<p>Semi-stateless (3) flow on initial sync potentially gives most of the benefits<em>†</em> of the stateless flow (2), but should require less data to sync due to reusing trie cache.</p>
<p><em>†</em> parallel block execution will be limited to some extent with semi-stateless approach.</p>
<p>So, to test the Semi-Stateless approach, we need to measure 2 things:</p>
<ul>
<li>how much additional space/bandwidth is required for this approach; is it any better than the fully stateful approach?</li>
<li>how much faster does it make the initial sync.</li>
</ul>
<p>In this article, we will focus <strong>on the disk space.</strong></p>
<h3 id="setting-up-the-experiment">Setting up the experiment <a class="plink" href="#setting-up-the-experiment">§</a></h3>
<ul>
<li>Max size of the trie (Merkle trie): <strong>1.000.000 </strong>nodes. When the number of nodes exceeds this value, the LRU nodes will be evicted to free up the memory. This way we can keep the used RAM under control.</li>
<li>The partial witnesses are stored in a db (<a href="https://github.com/ledgerwatch/bolt">our fork of boltdb</a>). Each entry has the following structure:</li>
</ul>
<pre><code>key: [12]byte // block number + max number of nodes in the trie
value: []byte // witnessses, serialized as described in https://github.com/ledgerwatch/turbo-geth/blob/master/docs/programmers_guide/witness_format.md</code></pre>
<ul>
<li>We don’t store the contract code in the witnesses (that is a limitation of the current architecture).</li>
</ul>
<p>How the data was collected (required a synced turbo-geth).</p>
<pre><code>(in the turbo-geth repository)</code></pre>
<pre><code>make state</code></pre>
<pre><code>./build/bin/state stateless \
     — chaindata ~/nvme1/mainnet/mainnet/geth/chaindata \
     — statefile semi_stateless.statefile \
     — snapshotInterval 1000000 \
     — snapshotFrom 10000000 \
     — statsfile new_witness.stats.compressed.2.csv \
     — witnessDbFile semi_stateless_witnesses.db \
     — statelessResolver \
     — triesize 1000000 \</code></pre>
<h2 id="experiment-results">Experiment Results <a class="plink" href="#experiment-results">§</a></h2>
<h3 id="total-storage">Total Storage <a class="plink" href="#total-storage">§</a></h3>
<p>Witnesses DB (bolt db) to sync 6.169.246 blocks from scratch takes 99Gb</p>
<h3 id="quantile-analysis">Quantile analysis <a class="plink" href="#quantile-analysis">§</a></h3>
<pre><code>python quantile-analysis.py cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*r6s2Miu98nekDIw5Q3KjgQ.png" alt="" width="1024" height="444" loading="lazy" /></figure>
<pre><code>mean   0.038 MB
median 0.028 MB
p90    0.085 MB
p95    0.102 MB
p99    0.146 MB
max    2.350 MB</code></pre>
<h3 id="verified-measurements-september-5-2026">Verified measurements — September 5, 2026 <a class="plink" href="#verified-measurements-september-5-2026">§</a></h3>
<p>The table below recalculates <code>witnessesSize</code> from the <a href="https://github.com/mandrigin/ethereum-mainnet-resolver-witness-stats/blob/9accc939c223831ba505367e4f6ac6bdccfaabf8/cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv">archived CSV</a>, selecting <code>blockNum &gt;= 3000000</code>. That selects <strong>2,395,470 recorded entries</strong>, from block <strong>3,000,079 through 6,169,246</strong>, all with <code>maxTrieSize = 1000000</code>. The entries’ sizes sum to 94,438,666,501 bytes. A MiB is 1,048,576 bytes; quantiles use linear interpolation between sorted observations.</p>
<div class="table-scroll" role="region" tabindex="0" aria-label="Table: Statistic, Size (MiB)"><table>
<thead><tr><th scope="col">Statistic</th><th scope="col">Size (MiB)</th></tr></thead><tbody>
<tr><td>Mean</td><td>0.037598</td></tr>
<tr><td>Median</td><td>0.028214</td></tr>
<tr><td>90th percentile</td><td>0.085464</td></tr>
<tr><td>95th percentile</td><td>0.101974</td></tr>
<tr><td>99th percentile</td><td>0.146458</td></tr>
<tr><td>Maximum</td><td>2.352358</td></tr>
</tbody></table></div>
<p>These reproduce the <a href="https://github.com/mandrigin/ethereum-mainnet-resolver-witness-stats/blob/9accc939c223831ba505367e4f6ac6bdccfaabf8/README.md">repository’s reported results</a>. Its README describes a 3,000,000–6,000,000 range, but the <a href="https://github.com/mandrigin/ethereum-mainnet-resolver-witness-stats/blob/9accc939c223831ba505367e4f6ac6bdccfaabf8/quantile-analysis.py">analysis script</a> accepts a lower bound only. Restricting the same file to block 6,000,000 gives 2,227,185 entries and a different mean, 0.035739 MiB. The original rounded readout above is retained with its original labels; use the verified table when citing these results.</p>
<p>This is a historical sample of serialized partial witnesses, without contract code. Missing block numbers are not counted as zero-size witnesses. The figures therefore describe recorded entries, not an average network cost across every block, a complete storage requirement, or a measured sync-speed improvement. The <a href="/tools/verify_witness_stats.py">recalculation script</a> checks the archived file hashes and reproduces the table.</p>
<h3 id="full-data">Full Data <a class="plink" href="#full-data">§</a></h3>
<pre><code>python absolute_values_plot.py cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv</code></pre>
<p>Witnesses sizes for blocks from 1 to 6100.000, capped at 1.0 MB. Sliding avg 1024.</p>
<figure tabindex="0"><img src="/static/img/1024_1*EDf7uct__tfXM5l5BppCBg.png" alt="" width="1024" height="296" loading="lazy" /></figure>
<h3 id="normalized-data-after-ddoses">Normalized Data (after DDoSes) <a class="plink" href="#normalized-data-after-ddoses">§</a></h3>
<pre><code>absolute_values_plot.py cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv 3000000</code></pre>
<p>Witnesses sizes after DDoS values, sliding avg 1024.</p>
<figure tabindex="0"><img src="/static/img/1024_1*vpph855bId7E0fWZA9SqEA.png" alt="" width="1024" height="768" loading="lazy" /></figure>
<h3 id="ddos-zoom-in">DDos Zoom In <a class="plink" href="#ddos-zoom-in">§</a></h3>
<pre><code>python ddos_zoom.py cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv</code></pre>
<p>Zoomed in section to DDoSes influence on witnesses sizes (raw data).</p>
<figure tabindex="0"><img src="/static/img/1024_1*QEGQffIoMRmN5RPl-ib4jA.png" alt="" width="1024" height="334" loading="lazy" /></figure>
<p>We can see that due to the DDoSes around blocks 2.3M-2.5M and 2.65M-2.75M the sizes of witnesses are significantly bigger.</p>
<h3 id="full-vs-semi">Full vs Semi <a class="plink" href="#full-vs-semi">§</a></h3>
<pre><code>python full_vs_semi.py cache_1_000_000/semi_stateless_witnesses.db.stats.1.csv</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*A-1fr0HA67naaQkbDM6W7w.png" alt="" width="1024" height="570" loading="lazy" /></figure>
<p>Full Witness sizes are adjusted for missing codes components.</p>
<p>As we see from this chart, using the semi-stateless approach saves quite a lot of data if we compare it to the full stateless approach.</p>
<h2 id="conclusion">Conclusion <a class="plink" href="#conclusion">§</a></h2>
<p>The verified mean is <strong>0.037598 MiB per recorded witness entry</strong> for the sample described above. The original “around 0.4 MB” conclusion was incorrect. The comparison with full witnesses suggests that keeping a trie cache can reduce witness data; <a href="/writing/stateless-ethereum-binary-tries/">the earlier experiment</a> provides the full-witness context.</p>
<p>This remains a proposal for accelerating initial sync. The data-volume comparison is against fully stateless witnesses; sync speed still needs to be measured. The original final sentence said “fully stateful” where the comparison called for “fully stateless,” also corrected on September 5, 2026.</p>]]></content:encoded>
</item>
<item>
<title>Stateless Ethereum: Binary Tries Experiment</title>
<link>https://255c.org/writing/stateless-ethereum-binary-tries/</link>
<guid isPermaLink="true">https://255c.org/writing/stateless-ethereum-binary-tries/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Fri, 03 Jan 2020 00:00:00 +0000</pubDate>
<description>data &amp; scripts for this article are in a github repo: https://github.com/mandrigin/ethereum-mainnet-bin-tries-data What is Stateless Ethereum? If you are already familiar with what Stateless Ethereum &amp; Block Witnesses are, skip to the next part. To run blocks and validate transaction, Ethereum nodes need to know the current state of the blockchain — all accounts &amp; contracts balances and storages.…</description>
<content:encoded><![CDATA[<blockquote>
<p>data &amp; scripts for this article are in a github repo: <a href="https://github.com/mandrigin/ethereum-mainnet-bin-tries-data">https://github.com/mandrigin/ethereum-mainnet-bin-tries-data</a></p>
</blockquote>
<h2 id="what-is-stateless-ethereum">What is Stateless Ethereum? <a class="plink" href="#what-is-stateless-ethereum">§</a></h2>
<p><em>If you are already familiar with what Stateless Ethereum &amp; Block Witnesses are, skip to the next part.</em></p>
<p>To run blocks and validate transaction, Ethereum nodes need to know the current state of the blockchain — all accounts &amp; contracts balances and storages. This data is typically stored in the DB and is loaded into a Merkle trie when needed (to be able to verify hashes).</p>
<p>Stateless Ethereum clients work a bit differently. As the name implies, they don’t use a disk DB to run blocks (they might keep a full state though). Instead, they rely on <strong><em>block witnesses</em></strong> — a special piece of data, distributed together with a block, using which, a client can recreate a Merkle subtree, sufficient to execute all transactions inside the received block.</p>
<p>You can read more in depth about stateless clients in this article: <a href="https://blog.ethereum.org/2019/12/30/eth1x-files-state-of-stateless-ethereum/">https://blog.ethereum.org/2019/12/30/eth1x-files-state-of-stateless-ethereum/</a></p>
<p>Of course, distributing block witnesses means that the stateless nodes will use more traffic than regular nodes.</p>
<figure tabindex="0"><img src="/static/img/1024_1*MeBN8JBgQSM9Wk7_zznZsg.png" alt="witness size chart (block 5.000.000–8.500.000)" width="1024" height="259" loading="lazy" /><figcaption>witness size chart (block 5.000.000–8.500.000)</figcaption></figure>
<p>There are a couple of ideas floating around on how to reduce the size of witnesses: using Validity / Computational Integrity Proofs (including but not limited to Zero-Knowledge), adding some compression, etc. One of the areas is switching Ethereum from hexary Merkle tries to the binary ones.</p>
<p>That is what this article is exploring. Let’s go.</p>
<h2 id="why-binary-tries">Why Binary Tries? <a class="plink" href="#why-binary-tries">§</a></h2>
<p>One great property of Merkle tries is that you can validate the root hash even if you don’t have the full trie. In order to do that, every missing, but not empty path in the trie should be replaced with an appropriate hash value.</p>
<p>What is the problem with the hex tries?</p>
<p>Imagine that the full trie is filled with data (nodes have almost no nil children). To validate a single block we only need a relatively small percentage of nodes. So, we need to replace all the other paths with hashes to make this trie verifiable.</p>
<p>Each hash is something that adds more data to the block witness footprint.</p>
<p>If we switch to binary tries we can theoretically mitigate this issue because each node only has 2 children, so at most one of them will be replaced with a hash. (To paraphrase it, that means that we can “cut” the Merkle paths earlier, because our granularity is 1 bit instead of 4 bits in a hex trie).</p>
<p>That should cut the witness sizes significantly.</p>
<p>Let’s look at an example.</p>
<p>Imagine, that to run our block we only need one account: <strong>Acc1</strong> with the path <strong>3B (0011 1011)</strong>. The tries are fully packed (nodes have no <strong>nil</strong> children).</p>
<p>Representations of the subtries that we need to be able to run our imaginary block are on the drawings below (in both hex and bin form).</p>
<figure tabindex="0"><img src="/static/img/460_1*KPyXN2WkH04SZGp58adnqA@2x.jpeg" alt="" width="460" height="1026" loading="lazy" /></figure>
<figure tabindex="0"><img src="/static/img/729_1*tZhCtx-bBxCLRlu229VHBg@2x.jpeg" alt="bin trie (left) | hex trie (right)" width="729" height="601" loading="lazy" /><figcaption>bin trie (left) | hex trie (right)</figcaption></figure>
<p>The binary trie might look a bit more intimidating, but if that’s because I didn’t want to draw all the hash nodes in the hex trie.</p>
<p>So let’s count.</p>
<ul>
<li>To produce a binary trie, the witness needs to contain 8 hashes, 7 branch nodes and 1 account node. That is 16 block witness elements.</li>
<li>To produce a hexary trie we need just one branch node, one account node and 15*2 = 30 hashes. That is 32 hash elements.</li>
</ul>
<p>So, assuming that hashes and branches take the same amount of space in the block witness (they don’t, hashes are bigger), in our case the bin trie require a witness twice as small than the hex trie needs. Sounds cool.</p>
<p>That’s the theory.</p>
<p>Let’s see now how it works in practice. Let’s dive into the wilderness of the Ethereum mainnet.</p>
<h2 id="setting-up-the-experiment">Setting Up The Experiment <a class="plink" href="#setting-up-the-experiment">§</a></h2>
<p>First things first: how do we validate if the produced block witness is usable?</p>
<p>To test that, we use the witness to produce a Merkle subtrie, run all the block’s transactions on it and validate the result. As long as all the transactions are executed successfully (there is enough gas, they have the same traces, etc), we can be sure that this witness is at least sufficient.</p>
<figure tabindex="0"><img src="/static/img/1024_1*BVnqt4IQ_rMteE0NspoYSA.png" alt="How we test (from [https://github.com/ledgerwatch/turbo-geth/blob/master/cmd/state/stateless/stateless.go](https://githu" width="1024" height="933" loading="lazy" /><figcaption>How we test (from <a href="https://github.com/ledgerwatch/turbo-geth/blob/master/cmd/state/stateless/stateless.go">https://github.com/ledgerwatch/turbo-geth/blob/master/cmd/state/stateless/stateless.go</a>)</figcaption></figure>
<p>Secondly, we need some baseline data. For that, we got stats on the witness sizes using hex tries for the blocks 5.000.000–8.500.000 to compare and stored them in a gargantual csv file.</p>
<p>Our first attempt was to take a hex trie after a block is executed and convert it to a binary one just before extracting the witness from it.</p>
<p>This approach has some benefits: it is easier to implement, also it is trivial to validate that hex-to-bin conversion.</p>
<p>Unfortunately, we ran into two problems, one of them was critical.</p>
<p>First of all, as it turned out, hex tries contain more account nodes than similar binary tries. So, if we are converting them later, we don’t get the exact witnesses as it would be if we just had binary tries from the start.</p>
<p>Why is that?</p>
<p>That is due to a fact that hex tries always grow their height in 1/2 byte intervals. Bin tries grow in just 1 bit interval, that makes it possible to have tries with key length with odd number of bits.</p>
<p>In practice, there are some additional EXTENSION nodes in the witnesses and they are ever so slightly bigger. But even for big blocks (~5000 transactions) this difference was quite small comparing to the witness size (&lt; 5%).</p>
<p>What was critical is the performance. With the growth of the trie, the conversion was slower and slower.</p>
<p>To put it in numbers, on our Google Compute Engine VM, the processing speed was around 0.16 block/second. That is less than 10 blocks per minute. To process 1.000.000 blocks we need more than 3 months. Oops.</p>
<p>So, we decided to go with a more complicated approach and built an experimental branch that uses binary tries natively. That means, that we replaced all hex tries in turbo-geth codebase with bin tries, so the blocks always run on binary tries.</p>
<p>On the downside, a few hashes checks had to be ignored (block root hash, and sometimes account storage hashes due to a limitation of our blockchain snapshots mechanism).</p>
<p>But the main verification mechanism stayed the same: we should be able to execute blocks using bin tries and subtries generated from witnesses.</p>
<p>Let’s talk about keys.</p>
<p>For simplicity, we encode keys very inefficiently: 1 byte per nibble; 1 byte per bit of a key. That simplified the code changes <em>a lot, </em>but<em> </em>the<em> </em>"keys” component of the block witness (see <a href="https://medium.com/@akhounov/data-from-the-ethereum-stateless-prototype-8c69479c8abc">this article</a> to learn what a witness consists of) is 8 times bigger than it should be, if we used bitsets (as we should).</p>
<p><strong>So, for the further analysis I will assume that all keys are optimal (they encode 1 bit of information using 1 bit of memory).</strong></p>
<h2 id="hex-vs-bin-results">Hex vs. Bin: Results <a class="plink" href="#hex-vs-bin-results">§</a></h2>
<p>I ran the analysis on 2m blocks from the Ethereum mainnet in 2 intervals.</p>
<h3 id="blocks-50000006500000">blocks 5.000.000–6.500.000 <a class="plink" href="#blocks-50000006500000">§</a></h3>
<p>I will also provide commands to repeat the experiment using python scripts in the github repo: <a href="https://github.com/mandrigin/ethereum-mainnet-bin-tries-data">https://github.com/mandrigin/ethereum-mainnet-bin-tries-data</a></p>
<p>First, let’s analyze or dataset a bit.</p>
<pre><code>python percentile.py hex-witness-raw.csv bin-stats-5m-6.5m.csv 5000000 6500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*CoNwfILjAfHnWilDQk8WCg.png" alt="[a box plot](https://en.wikipedia.org/wiki/Box_plot), with the box between P25-P75 and whiskers between P1-P99" width="1024" height="321" loading="lazy" /><figcaption><a href="https://en.wikipedia.org/wiki/Box_plot">a box plot</a>, with the box between P25-P75 and whiskers between P1-P99</figcaption></figure>
<p>Now let’s make some cool charts!</p>
<pre><code>python xy-scatter-plot.py hex-witness-raw.csv bin-stats-5m-6.5m.csv 5000000 6500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*OeVmZa14ZzE2yMaybQgj1g.png" alt="XY scatter-plot (adjusted for optimal keys)" width="1024" height="572" loading="lazy" /><figcaption>XY scatter-plot (adjusted for optimal keys)</figcaption></figure>
<p>As we see here, the size of binary witnesses is always better with binary tries.</p>
<p>Let’s plot another parameter, and divide our binary witness sizes to hex witness sizes to see what kind of improvement we can get.</p>
<pre><code>python size-improvements-plot.py hex-witness-raw.csv bin-stats-5m-6.5m.csv 5000000 6500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*FvUHVt0hZuhWZew-dNcQ2Q.png" alt="size of binary witness / size of hex witness (the smaller the better) across blocks" width="1024" height="269" loading="lazy" /><figcaption>size of binary witness / size of hex witness (the smaller the better) across blocks</figcaption></figure>
<p>To understand this chart better, we can also print average, mean and percentile values like before.</p>
<p>mean = 0.51 = improvement 49%</p>
<p>p95 = 0.58 = improvement 42%</p>
<p>p99 = 0.61 = improvement 39%</p>
<p>What does it mean in practice?</p>
<p>For <strong>99%</strong> of the blocks you will get <strong>at least 39%</strong> improvements in the witness size.</p>
<p>For <strong>95%</strong> of the blocks you will get <strong>at least 42%</strong> improvements in the witness size.</p>
<p>On average, you will get 49% improvements of the witness size.</p>
<p>Let’s also see the absolute values of witnesses. To make them readable, let’s pick a sliding average of 1024 blocks.</p>
<pre><code>python absolute-values-plot.py hex-witness-raw.csv bin-stats-5m-6.5m.csv 5000000 6500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*SDmJC-MqYRmxfjy8qKm0EQ.png" alt="Witnesses sizes in MB across the timeline" width="1024" height="533" loading="lazy" /><figcaption>Witnesses sizes in MB across the timeline</figcaption></figure>
<p>Now, let’s repeat everything for the newer blocks.</p>
<h3 id="blocks-80000008500000">blocks 8.000.000–8.500.000 <a class="plink" href="#blocks-80000008500000">§</a></h3>
<pre><code>python percentile.py hex-witness-raw.csv bin-stats-8m-9m.csv 8000000 8500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*v_ktGhCj0EbA3hqHOidAyQ.png" alt="[a box plot](https://en.wikipedia.org/wiki/Box_plot), with the box between P25-P75 and whiskers between P1-P99" width="1024" height="283" loading="lazy" /><figcaption><a href="https://en.wikipedia.org/wiki/Box_plot">a box plot</a>, with the box between P25-P75 and whiskers between P1-P99</figcaption></figure>
<p>Now the XY scatter-plot</p>
<pre><code>python xy-scatter-plot.py hex-witness-raw.csv bin-stats-8m-9m.csv 8000000 8500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*RxhZ0VNlHyJZVSLo_Ndrgg.png" alt="" width="1024" height="768" loading="lazy" /></figure>
<p>…and size improvements</p>
<pre><code>python size-improvements-plot.py hex-witness-raw.csv bin-stats-8m-9m.csv 8000000 8500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*Io8zLlBK5xpUEwE61YJ48Q.png" alt="size of binary witness / size of hex witness (the smaller the better) across blocks" width="1024" height="267" loading="lazy" /><figcaption>size of binary witness / size of hex witness (the smaller the better) across blocks</figcaption></figure>
<p>mean = 0.53 = 47% improvements</p>
<p>p95 = 0.61 = 39% improvements</p>
<p>p99 = 0.66 = 34% improvements</p>
<p>And, finally, let’s plot witness sizes</p>
<pre><code>python absolute-values-plot.py hex-witness-raw.csv bin-stats-8m-9m.csv 8000000 8500000 adjust</code></pre>
<figure tabindex="0"><img src="/static/img/1024_1*9QJ9IeWjk86nTPSqgi_5aQ.png" alt="Witnesses sizes in MB across the timeline" width="1024" height="294" loading="lazy" /><figcaption>Witnesses sizes in MB across the timeline</figcaption></figure>
<h2 id="conclusion">Conclusion <a class="plink" href="#conclusion">§</a></h2>
<p>After running our tests on the real Ethereum mainnet data, we can see that indeed, switching to binary tries will give some significant improment for binary witness generation (bin witnesses are 47–49% smaller on average).</p>
<p>One more outcome is that this improvement isn’t as dramatic as the theoretical best case scenario. Possibly it is due to the real data layout in the mainnet blocks.</p>
<p>Probably, by analyzing some edge cases (where bin tries gave the least improvement) we can come up to more ways to improve block witnesses size.</p>
<p>Feel free to play with the raw data and scripts in the GitHub repo: <a href="https://github.com/mandrigin/ethereum-mainnet-bin-tries-data">https://github.com/mandrigin/ethereum-mainnet-bin-tries-data</a></p>]]></content:encoded>
</item>
<item>
<title>Mobile Energy Efficiency BoK</title>
<link>https://255c.org/writing/mobile-energy-efficiency-bok/</link>
<guid isPermaLink="true">https://255c.org/writing/mobile-energy-efficiency-bok/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Tue, 01 Jan 2019 00:00:00 +0000</pubDate>
<description>Happy New Year everyone! While working at Status, I put together a small guide on testing energy efficiency of a mobile app. Of course, some of the parts there are Status-specific, but there is enough information useful for the general public. Here is it: https://github.com/status-im/energy-efficient-bok. Sections of this BoK that have the most interesting parts are: Dev Guide — a short document…</description>
<content:encoded><![CDATA[<p>Happy New Year everyone!</p>
<p>While working at <a href="https://status.im">Status</a>, I put together a small guide on testing energy efficiency of a mobile app.</p>
<p>Of course, some of the parts there are Status-specific, but there is enough information useful for the general public.</p>
<p>Here is it: <a href="https://github.com/status-im/energy-efficient-bok">https://github.com/status-im/energy-efficient-bok</a>.</p>
<p>Sections of this BoK that have the most interesting parts are:</p>
<p>* <a href="https://github.com/status-im/energy-efficient-bok/blob/master/ENERGY_GUIDE_DEV.md">Dev Guide</a> — a short document describing what affects energy efficiency and how to test it in development.</p>
<p>* <a href="https://github.com/status-im/energy-efficient-bok/blob/master/QA_Android.md">Using Battery Historian</a> — how to use <a href="https://developer.android.com/studio/profile/battery-historian">Battery Historian</a> to test energy efficiency on Android.</p>
<p>* <a href="https://github.com/status-im/energy-efficient-bok/blob/master/QA.md#introduction">Testing and interpreting results</a>.</p>
<p>Special shoutout to <a href="https://github.com/lukaszfryc">Lukasz</a> for helping putting this BoK together.</p>]]></content:encoded>
</item>
<item>
<title>Ethereum node services explained</title>
<link>https://255c.org/writing/ethereum-node-services/</link>
<guid isPermaLink="true">https://255c.org/writing/ethereum-node-services/</guid>
<dc:creator>Igor Mandrigin</dc:creator>
<pubDate>Wed, 02 May 2018 00:00:00 +0000</pubDate>
<description>I did a short explanation about how https://status.im interacts with Ethereum. I think it is a decent explanation about how Ethereum RPC APIs work and how to tweak them.</description>
<content:encoded><![CDATA[<p>I did a short explanation about how <a href="https://status.im">https://status.im</a> interacts with Ethereum. I think it is a decent explanation about how Ethereum RPC APIs work and how to tweak them.</p>]]></content:encoded>
</item>
</channel>
</rss>