<?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/">
  <channel>
    <title>DEV Community: Vincent Boulianne</title>
    <description>The latest articles on DEV Community by Vincent Boulianne (@vincent_boulianne_44a71f6).</description>
    <link>https://dev.to/vincent_boulianne_44a71f6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4142426%2Fe08b9094-4199-42d2-88ca-9f5b65fd1303.png</url>
      <title>DEV Community: Vincent Boulianne</title>
      <link>https://dev.to/vincent_boulianne_44a71f6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vincent_boulianne_44a71f6"/>
    <language>en</language>
    <item>
      <title>Inside RustChain Attestation: How 6 Hardware Entropy Checks Enforce 1 CPU = 1 Vote Decentralization</title>
      <dc:creator>Vincent Boulianne</dc:creator>
      <pubDate>Fri, 25 Sep 2026 07:51:58 +0000</pubDate>
      <link>https://dev.to/vincent_boulianne_44a71f6/inside-rustchain-attestation-how-6-hardware-entropy-checks-enforce-1-cpu-1-vote-decentralization-a5l</link>
      <guid>https://dev.to/vincent_boulianne_44a71f6/inside-rustchain-attestation-how-6-hardware-entropy-checks-enforce-1-cpu-1-vote-decentralization-a5l</guid>
      <description>&lt;p&gt;By &lt;strong&gt;Vincent (@tivince82)&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Target Repository: &lt;a href="https://github.com/Scottcjn/Rustchain" rel="noopener noreferrer"&gt;Scottcjn/Rustchain&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Reference Code: &lt;code&gt;node/rip_200_round_robin_1cpu1vote.py&lt;/code&gt; and &lt;code&gt;miners/linux/fingerprint_checks.py&lt;/code&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Introduction: Beyond Hash Wars and Proof-of-Stake Oligarchies
&lt;/h2&gt;

&lt;p&gt;For over a decade, blockchain consensus has been caught in a binary trap:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proof-of-Work (PoW)&lt;/strong&gt; degenerates into an industrial arms race of high-wattage ASICs and massive server farms, creating immense carbon footprints and sending consumer electronics to landfills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof-of-Stake (PoS)&lt;/strong&gt; replaces physical energy with financial capital, inevitably consolidating voting power in the hands of major exchanges, venture funds, and wealthy validators.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;RustChain&lt;/strong&gt; introduces an alternative consensus paradigm rooted in the principle of &lt;strong&gt;1 CPU = 1 Vote&lt;/strong&gt; via deterministic round-robin rotation (&lt;code&gt;RIP-200&lt;/code&gt;). But enforcing "one CPU per vote" in an anonymous, permissionless network presents a classic distributed systems problem: &lt;strong&gt;How do you prevent a single modern server or cloud hypervisor from spinning up thousands of virtual machines to overwhelm the network?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In RustChain, the answer is not a synthetic hash puzzle. Instead, it is &lt;strong&gt;Physical Hardware Attestation&lt;/strong&gt;. In this deep dive, we examine how RustChain uses six sub-nanosecond physical entropy measurements to bind block production to real silicon, prevent virtualization attacks, and scale rewards through antiquity multipliers.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. The Attestation Architecture: The 6 Physical Entropy Checks
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;miners/linux/fingerprint_checks.py&lt;/code&gt;, every candidate node must execute six distinct physical hardware checks before submitting an attestation receipt to the &lt;code&gt;/attest/submit&lt;/code&gt; endpoint. These checks measure physical anomalies that are inherent to real semiconductor silicon but extremely difficult to simulate accurately inside a virtual machine or software emulator.&lt;/p&gt;
&lt;h3&gt;
  
  
  [1/6] Clock-Skew &amp;amp; Oscillator Drift (&lt;code&gt;clock_drift&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Physical quartz crystals on real motherboards experience natural manufacturing micro-imperfections and temperature-dependent drift. By comparing high-resolution system timers (&lt;code&gt;CLOCK_MONOTONIC_RAW&lt;/code&gt;) against sub-microsecond sleep intervals, the check measures the coefficient of variation ($CV$) and standard deviation of oscillator drift:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Extract from fingerprint_checks.py
&lt;/span&gt;&lt;span class="n"&gt;mean_ns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deltas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deltas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;stdev_ns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;mean_ns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;deltas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deltas&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;cv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stdev_ns&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;mean_ns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Synthetic clocks inside cloud hypervisors (such as KVM or QEMU) exhibit rigid, quantised stepping that fails the natural entropy threshold ($CV &amp;gt; 0.05$).&lt;/p&gt;

&lt;h3&gt;
  
  
  [2/6] Cache Timing Fingerprint (&lt;code&gt;cache_timing&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Real CPUs feature multi-tier memory hierarchies (L1, L2, L3) with strict physical latency differentials. By allocating memory buffers calibrated to exact architecture cache sizes and timing memory read operations via hardware cycles, the node establishes latency ratios:&lt;br&gt;
$$  ext{Ratio}_{L2/L1} = rac{  ext{Latency}(L2)}{  ext{Latency}(L1)}$$&lt;br&gt;
A physical x86 or ARM core demonstrates clear stepped delays between cache boundaries, whereas cloud instances with shared or virtualized memory produce anomalous latency profiles.&lt;/p&gt;
&lt;h3&gt;
  
  
  [3/6] SIMD Unit Identity (&lt;code&gt;simd_identity&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Nodes query hardware CPUID feature registers and verify vector execution units (&lt;code&gt;SSE&lt;/code&gt;, &lt;code&gt;AVX&lt;/code&gt;, &lt;code&gt;AVX-512&lt;/code&gt;, &lt;code&gt;NEON&lt;/code&gt;, or &lt;code&gt;AltiVec&lt;/code&gt;). The check validates that the instruction set reported in &lt;code&gt;/proc/cpuinfo&lt;/code&gt; matches true hardware execution behavior.&lt;/p&gt;
&lt;h3&gt;
  
  
  [4/6] Thermal Drift Entropy (&lt;code&gt;thermal_drift&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Semiconductor resistance shifts as temperature rises. The thermal drift test executes a compute-intensive matrix multiplication loop to heat the core slightly, comparing cycle counts between cold and warm states:&lt;br&gt;
$$  ext{Drift Ratio} = rac{    ext{Cold Avg}}{ ext{Hot Avg}}$$&lt;br&gt;
Physical CPUs exhibit subtle clock throttling and cycle drift, whereas software emulators report identical execution timings regardless of sustained load.&lt;/p&gt;
&lt;h3&gt;
  
  
  [5/6] Instruction Path Jitter (&lt;code&gt;instruction_jitter&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Physical pipeline execution experiences sub-nanosecond jitter across arithmetic, floating-point, and branch prediction units. By interleaving branch operations and calculating branch latency variance, the test verifies that instructions execute on real silicon pipeline stages.&lt;/p&gt;
&lt;h3&gt;
  
  
  [6/6] Anti-Emulation &amp;amp; Hypervisor Detection (&lt;code&gt;anti_emulation&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;The test scans system state for known hypervisor signatures, hypervisor CPUID bits (&lt;code&gt;hypervisor&lt;/code&gt; flag), synthetic DMI table strings (&lt;code&gt;QEMU&lt;/code&gt;, &lt;code&gt;VirtualBox&lt;/code&gt;, &lt;code&gt;VMware&lt;/code&gt;, &lt;code&gt;Xen&lt;/code&gt;), and invalid CPUID hypervisor leaves (&lt;code&gt;0x40000000&lt;/code&gt;). If &lt;code&gt;is_likely_vm&lt;/code&gt; evaluates to &lt;code&gt;true&lt;/code&gt;, the attestation is immediately rejected.&lt;/p&gt;


&lt;h2&gt;
  
  
  3. Dynamic Measurement Nonces: Mitigating Pre-Computation (&lt;code&gt;RIP-309&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Static attestation measurements could theoretically be recorded once on physical hardware and replayed by a bot farm. To prevent replay and collusion, RustChain implements &lt;strong&gt;RIP-309 Measurement Rotation&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Extract from node/rip_200_round_robin_1cpu1vote.py
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;derive_measurement_nonce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;previous_epoch_block_hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;seed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rip-309:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;previous_epoch_block_hash&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each epoch, the previous block hash acts as an unpredictable seed that dynamically re-ranks the active subset of required measurements. An attacker cannot pre-record sensor data because the exact test permutation and nonce requirements change with every block.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Economic Consensus: Round-Robin Rotation and Antiquity Multipliers
&lt;/h2&gt;

&lt;p&gt;Once a node's physical attestation is verified at &lt;code&gt;/attest/submit&lt;/code&gt;, it enters the deterministic block producer rotation for the epoch. Unlike Proof-of-Work, which concentrates power in high-power ASIC clusters, RustChain balances distribution using &lt;strong&gt;Antiquity Multipliers&lt;/strong&gt; (&lt;code&gt;ANTIQUITY_MULTIPLIERS&lt;/code&gt; in &lt;code&gt;node/rip_200_round_robin_1cpu1vote.py&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Release Era&lt;/th&gt;
&lt;th&gt;Base Multiplier&lt;/th&gt;
&lt;th&gt;Code Reference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Motorola 68000&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1979–1995&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;3.0x&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Line 188&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PowerPC G4&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2001–2004&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.5x&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Line 371&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Intel Sandy Bridge&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2011&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.1x&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Line 388&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modern Intel/AMD&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2020–2025&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.8x&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lines 410, 425&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Time-Decay Law
&lt;/h3&gt;

&lt;p&gt;To ensure long-term network sustainability while honoring legacy hardware, the vintage bonus decays linearly at 15% per blockchain year (&lt;code&gt;DECAY_RATE_PER_YEAR = 0.15&lt;/code&gt;, Line 471):&lt;/p&gt;

&lt;p&gt;$$  ext{Aged Bonus} = \max\left(0, (    ext{Multiplier} - 1.0)  imes (1 - 0.15  imes    ext{Chain Age})&lt;br&gt;
ight)$$&lt;br&gt;
$$  ext{Final Weight} = 1.0 +   ext{Aged Bonus}$$&lt;/p&gt;

&lt;p&gt;This guarantees that while older computers enjoy an initial economic incentive to participate and bootstrap decentralization, the network smoothly converges toward a balanced 1.0x baseline as the chain matures.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Conclusion
&lt;/h2&gt;

&lt;p&gt;RustChain's Proof-of-Antiquity consensus demonstrates that decentralized networks do not need to choose between environmental destruction and capital centralization. By grounding Sybil resistance in physical hardware anomalies and rewarding longevity over raw consumption, the protocol transforms neglected electronics into secure, verifiable nodes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Explore the RustChain Core Repository&lt;/strong&gt;: &lt;a href="https://github.com/Scottcjn/Rustchain" rel="noopener noreferrer"&gt;https://github.com/Scottcjn/Rustchain&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review Attestation Checks&lt;/strong&gt;: &lt;code&gt;miners/linux/fingerprint_checks.py&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Examine Round-Robin Consensus&lt;/strong&gt;: &lt;code&gt;node/rip_200_round_robin_1cpu1vote.py&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>cryptocurrency</category>
      <category>hardware</category>
      <category>programming</category>
    </item>
    <item>
      <title>Understanding Cross-Chain Accounting Drift: Fixing Layer 2 Reconciliation Invariants in RustChain</title>
      <dc:creator>Vincent Boulianne</dc:creator>
      <pubDate>Fri, 25 Sep 2026 07:05:22 +0000</pubDate>
      <link>https://dev.to/vincent_boulianne_44a71f6/understanding-cross-chain-accounting-drift-fixing-layer-2-reconciliation-invariants-in-rustchain-5629</link>
      <guid>https://dev.to/vincent_boulianne_44a71f6/understanding-cross-chain-accounting-drift-fixing-layer-2-reconciliation-invariants-in-rustchain-5629</guid>
      <description>&lt;p&gt;By &lt;strong&gt;Vincent (@tivince82)&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Target Repository: &lt;a href="https://github.com/Scottcjn/Rustchain" rel="noopener noreferrer"&gt;Scottcjn/Rustchain&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Reference Pull Request: &lt;a href="https://github.com/Scottcjn/Rustchain/pull/8517" rel="noopener noreferrer"&gt;Scottcjn/Rustchain#8517&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Introduction: The Challenge of Cross-Chain Reconciliation
&lt;/h2&gt;

&lt;p&gt;Cross-chain bridges represent some of the most critical infrastructure in modern decentralized ecosystems. They are tasked with locking native assets on a source chain while minting or releasing wrapped representations on a target network (such as Solana or Base). In RustChain's architecture, Layer 2 of the federation arc (specified in &lt;code&gt;FEDERATION_BRIDGED_SUPPLY_SPEC.md&lt;/code&gt;) provides continuous, per-epoch reconciliation snapshots.&lt;/p&gt;

&lt;p&gt;These snapshots serve two vital purposes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic State Attestation&lt;/strong&gt;: Every epoch, the node records a permanent snapshot containing &lt;code&gt;locked_in_rtc&lt;/code&gt;, &lt;code&gt;completed_in_rtc&lt;/code&gt;, &lt;code&gt;voided_in_rtc&lt;/code&gt;, and the canonical &lt;code&gt;bridged_supply_committed&lt;/code&gt;. This snapshot is cryptographically fingerprinted using a SHA-256 &lt;code&gt;state_hash&lt;/code&gt; over the canonical-JSON payload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Chain Drift Detection&lt;/strong&gt;: The Layer 2 reconciliation protocol allows automated checkers to compare RustChain's internal ledger against external destination ledgers, detecting discrepancies before they escalate into insolvency or consensus divergence.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, an accounting bug in the formula calculating &lt;code&gt;bridged_supply_committed&lt;/code&gt; introduced a silent, structural under-reporting flaw. In this deep dive, we explore how the defect occurred, how to reproduce it, and how the fix restores mathematical invariants across the federation.&lt;/p&gt;


&lt;h2&gt;
  
  
  2. The Accounting Architecture: Aggregate vs. Committed State
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;node/bridge_federation_routes.py&lt;/code&gt;, the function &lt;code&gt;_aggregate_bridge_state(conn)&lt;/code&gt; computes the current status of all bridge operations by aggregating the &lt;code&gt;bridge_transfers&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Extract from node/bridge_federation_routes.py
&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT status, COUNT(*), COALESCE(SUM(amount_rtc), 0.0) &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;FROM bridge_transfers GROUP BY status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;by_status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; 
             &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;

&lt;span class="c1"&gt;# "Locked in" = pending + locked + confirming
&lt;/span&gt;&lt;span class="n"&gt;locked_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;by_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pending&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;locked&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;confirming&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;completed_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;by_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;completed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;voided_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;by_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;voided&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;total_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the crucial domain definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;locked_in&lt;/code&gt;: Represents RTC that has been initiated but not yet finalized across the bridge. It explicitly sums only &lt;code&gt;("pending", "locked", "confirming")&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;completed_in&lt;/code&gt;: Represents transfers that have successfully finalized.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;voided_in&lt;/code&gt;: Represents transfers that were cancelled, rejected, or refunded. &lt;strong&gt;Voided transfers are never included in &lt;code&gt;locked_in&lt;/code&gt; or &lt;code&gt;completed_in&lt;/code&gt;.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. The Vulnerability: The Double-Subtraction Trap
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;node/bridge_reconciliation.py&lt;/code&gt;, the committed supply formula was defined as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Defective implementation in node/bridge_reconciliation.py
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_bridged_supply_committed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Per FEDERATION_BRIDGED_SUPPLY_SPEC.md section 3:
        bridged_supply_committed = locked_in + completed_in - voided_in
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;locked_in_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;completed_in_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;voided_in_rtc&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this is mathematically broken:
&lt;/h3&gt;

&lt;p&gt;Because &lt;code&gt;voided_in&lt;/code&gt; was &lt;strong&gt;already excluded&lt;/strong&gt; from &lt;code&gt;locked_in&lt;/code&gt; during the aggregate query in &lt;code&gt;_aggregate_bridge_state&lt;/code&gt;, subtracting &lt;code&gt;voided_in&lt;/code&gt; a second time constitutes a &lt;strong&gt;double-subtraction&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Consider a concrete economic scenario:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A user initiates a bridge transfer of 50 RTC (Status: &lt;code&gt;pending&lt;/code&gt;, then &lt;code&gt;voided&lt;/code&gt; due to timeout).&lt;/li&gt;
&lt;li&gt;Another user initiates and completes a transfer of 100 RTC (Status: &lt;code&gt;completed&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Active active transfers: 50 RTC (Status: &lt;code&gt;locked&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Actual committed bridge supply:&lt;/strong&gt; $100 \text{ RTC (completed)} + 50 \text{ RTC (locked)} = 150 \text{ RTC}$.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Formula result before fix:&lt;/strong&gt; $150 \text{ RTC} - 50 \text{ RTC (voided)} = 100 \text{ RTC}$.&lt;/p&gt;

&lt;p&gt;Even worse: if a network experiences a flurry of cancelled transfers where $\text{voided_in} &amp;gt; \text{locked_in} + \text{completed_in}$, the reported &lt;code&gt;bridged_supply_committed&lt;/code&gt; becomes &lt;strong&gt;negative&lt;/strong&gt;, violating non-negativity invariants and triggering false alerts in downstream automated audit watchers.&lt;/p&gt;

&lt;p&gt;Moreover, because the test suite in &lt;code&gt;node/tests/test_bridge_reconciliation.py&lt;/code&gt; hardcoded the erroneous value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Defective test assertion
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;snap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bridged_supply_committed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;pytest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;approx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;77.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 30 + 50 - 3 = 77
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test passed, giving a false sense of security while embedding an accounting error directly into regression gates.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Native Python Reproduction Harness
&lt;/h2&gt;

&lt;p&gt;The following standalone script demonstrates the discrepancy against SQLite in memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_simulation&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:memory:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
        CREATE TABLE bridge_transfers (
            id INTEGER PRIMARY KEY,
            amount_rtc REAL,
            status TEXT
        )
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Seed transfers: 30 locked, 50 completed, 3 voided
&lt;/span&gt;    &lt;span class="n"&gt;transfers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pending&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;20.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;locked&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;50.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;completed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;voided&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executemany&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;INSERT INTO bridge_transfers (amount_rtc, status) VALUES (?, ?)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transfers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# 1. Aggregate
&lt;/span&gt;    &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT status, SUM(amount_rtc) FROM bridge_transfers GROUP BY status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

    &lt;span class="n"&gt;locked_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pending&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;locked&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;completed_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;completed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;voided_in&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;voided&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 2. Defective Calculation
&lt;/span&gt;    &lt;span class="n"&gt;defective_committed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;locked_in&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;completed_in&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;voided_in&lt;/span&gt;

    &lt;span class="c1"&gt;# 3. Corrected Calculation
&lt;/span&gt;    &lt;span class="n"&gt;correct_committed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;locked_in&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;completed_in&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Locked In:    &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;locked_in&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; RTC&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Completed In: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;completed_in&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; RTC&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Voided In:    &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;voided_in&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; RTC&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Defective Calculation: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;defective_committed&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; RTC (Under-reported!)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Correct Calculation:   &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;correct_committed&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; RTC (Matches Reality)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;correct_committed&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mf"&gt;80.0&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Verification Successful: Correct committed supply is 80.0 RTC.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;run_simulation&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. The Remediation (PR #8517)
&lt;/h2&gt;

&lt;p&gt;The remediation in &lt;a href="https://github.com/Scottcjn/Rustchain/pull/8517" rel="noopener noreferrer"&gt;Scottcjn/Rustchain#8517&lt;/a&gt; addresses both the function implementation and test assertions:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Code Fix (&lt;code&gt;node/bridge_reconciliation.py&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt; def _bridged_supply_committed(state: Dict[str, Any]) -&amp;gt; float:
     """Per FEDERATION_BRIDGED_SUPPLY_SPEC.md section 3:
&lt;span class="gd"&gt;-        bridged_supply_committed = locked_in + completed_in - voided_in
&lt;/span&gt;&lt;span class="gi"&gt;+        bridged_supply_committed = locked_in + completed_in
&lt;/span&gt;     """
     return (
         float(state.get("locked_in_rtc", 0.0))
         + float(state.get("completed_in_rtc", 0.0))
&lt;span class="gd"&gt;-        - float(state.get("voided_in_rtc", 0.0))
&lt;/span&gt;     )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Test Verification (&lt;code&gt;node/tests/test_bridge_reconciliation.py&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt; def test_snapshot_bridged_supply_committed_formula(db_path):
     ...
     assert snap["locked_in_rtc"] == 30.0
     assert snap["completed_in_rtc"] == 50.0
     assert snap["voided_in_rtc"] == 3.0
&lt;span class="gd"&gt;-    assert snap["bridged_supply_committed"] == pytest.approx(77.0)
&lt;/span&gt;&lt;span class="gi"&gt;+    assert snap["bridged_supply_committed"] == pytest.approx(80.0)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running pytest across &lt;code&gt;node/tests/test_bridge_reconciliation.py&lt;/code&gt; yields &lt;strong&gt;19/19 passed in 0.62s (100% green)&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Key Takeaways for Distributed Systems Engineers
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Beware of Derived Quantities in Multi-Stage Aggregation&lt;/strong&gt;: When calculating metrics derived from lower-level aggregations, always verify whether filtered categories are already partitioned or mutually exclusive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid Affirming the Consequent in Unit Tests&lt;/strong&gt;: Writing a test assertion that checks &lt;code&gt;actual == expected_formula&lt;/code&gt; rather than verifying the underlying domain invariant can cement bugs into the test suite.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit Bridge Invariants Early&lt;/strong&gt;: In cross-chain protocols, reconciliation logic must remain strictly non-negative and monotonic with respect to finalized settlement events.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Resources &amp;amp; Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;RustChain Main Repository: &lt;a href="https://github.com/Scottcjn/Rustchain" rel="noopener noreferrer"&gt;https://github.com/Scottcjn/Rustchain&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Pull Request #8517: &lt;a href="https://github.com/Scottcjn/Rustchain/pull/8517" rel="noopener noreferrer"&gt;https://github.com/Scottcjn/Rustchain/pull/8517&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Official Documentation: &lt;a href="https://rustchain.org" rel="noopener noreferrer"&gt;https://rustchain.org&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>cryptocurrency</category>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
