<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://athenavm.github.io//feed.xml" rel="self" type="application/atom+xml" /><link href="https://athenavm.github.io//" rel="alternate" type="text/html" /><updated>2025-03-04T12:12:51+00:00</updated><id>https://athenavm.github.io//feed.xml</id><title type="html">Athena VM</title><subtitle>Athena VM is a modern blockchain operating system for running programs (a.k.a. smart contracts) in a manner that&apos;s performant, deterministic, and efficiently provable.</subtitle><entry><title type="html">February 2025 Project Update</title><link href="https://athenavm.github.io//updates/2025/03/04/february-project-update.html" rel="alternate" type="text/html" title="February 2025 Project Update" /><published>2025-03-04T00:00:00+00:00</published><updated>2025-03-04T00:00:00+00:00</updated><id>https://athenavm.github.io//updates/2025/03/04/february-project-update</id><content type="html" xml:base="https://athenavm.github.io//updates/2025/03/04/february-project-update.html"><![CDATA[<p>This month’s update breaks away from the usual pattern, as we’ve done more design and less development work this month.
Specifically, we’ve fleshed out Athena’s initial featureset - the “Minimum Viable Product”.</p>

<p>We’ve mapped the potential solutions on the following axes:</p>

<p><img src="/assets/2025_03_04/image1.png" alt="design axes" style="display: block; margin: 0 auto; width: 50%;" /></p>

<p>Eventually we’ve settled on a solution that sacrifices some decentralization of the Athena rollup to maximize simplicity
(minimizing time to market), without hurting upgradeability to the Athena’s final form.</p>

<h2 id="the-spacemesh-athena-stack">The Spacemesh-Athena Stack</h2>

<p><img src="/assets/2025_03_04/image2.png" alt="high level design" /></p>

<p>You may remember this graphic from previous updates. Today we’re going to focus on the 3 main roles involved in the
eventual Spacemesh stack:</p>

<p><img src="/assets/2025_03_04/image3.png" alt="individual components" /></p>

<p><strong>Smeshers</strong> are what we already have on the network today. They’re in charge of running base-layer consensus:
constructing blocks of base-layer transactions and taking part in consensus protocols to enshrine these blocks, and the
order of transactions in them, in history.</p>

<p><strong>Relays</strong> will be a new way to participate in the Spacemesh ecosystem. They’ll maintain their own mempool of Athena
transactions and create bundles of those transactions to be included in base-layer blocks. Relays cover the storage cost
of including their bundles in blocks and they get paid within Athena. The margin between the base layer storage fee and
the fee they collect from transactions is their profit.</p>

<p><strong>Executors</strong> will be responsible for Athena transaction execution. Since Athena will start out as an optimistic rollup,
they will have to post some stake and gain execution fees from Athena transactions.</p>

<p>Executors will eventually have their own eligibility mechanism (like Hare and Tortoise have today). Relays will need to
maintain a gossip network to propagate transactions and have a fee-sharing mechanism. These are just a few examples of
the complexities involved in building a decentralized system like this.</p>

<h2 id="forward-looking-simplifications">Forward Looking Simplifications</h2>

<p>To be able to ship Athena as quickly as possible, while keeping the path open to the end-game described above, we’ve
decided to sacrifice some of the initial decentralization of Athena itself (base layer remains fully decentralized).</p>

<p>The launch version of Athena will have a single relay that can collect storage fees within Athena to cover the base
layer storage fee. This allows us to delay implementing the fee-sharing solution and relay-coordination, while also
allowing us to expose a single relay endpoint for sending transactions to the relay with no need for an additional
peer-to-peer network. Spacemesh will operate this initial relay. Users can still choose to submit Athena transactions
using their own relay, covering the base-layer storage fee themselves - contributing to the permissionlessness of the
network. So nobody is able to censor transactions, but using the Spacemesh-operated relay is a mere convenience.</p>

<p>There will also be a single pre-authorized executor node on launch day, operated by Spacemesh. This allows us to delay
implementing the executor eligibility mechanism as well as on-chain dispute resolution and slashing. We will still
provide the software for anyone to easily run a “shadow executor” and validate the output of the single executor.
Executors perform a deterministic algorithm, as they execute transactions in the order they appear in blocks generated
by the smeshers (which include bundles submitted by relays). They then publish the resulting global state. If the single
executor “cheats” and reports the wrong state, the shadow executor will detect this. While there won’t be an on-chain
malfeasance proof or monetary slashing, if Spacemesh is caught cheating it will ruin our reputation and achieve nothing.</p>

<p><img src="/assets/2025_03_04/image4.png" alt="simplified individual components" /></p>

<p>The rest of the design remains as initially planned and there’s a clear path for us to upgrade from the initial version
to the ultimate end-game.</p>

<h2 id="looking-ahead">Looking Ahead</h2>

<p>We plan to start prototyping the individual components (the relay and the executor) as soon as we release atx-merge and
node-split. We hope to have the basic minium implementation ready as fast as possible, run a devnet and iterate from
there adding more features and security guardrails iteratively.</p>

<h2 id="contributing">Contributing</h2>

<p>Athena is being built fully in the open, and the codebase is fully open source and permissively licensed. If you’re
interested in contributing, take a look at the list of issues tagged <code class="language-plaintext highlighter-rouge">Help Wanted</code> and <code class="language-plaintext highlighter-rouge">Good First Issue</code> on
<a href="https://github.com/athenavm">GitHub</a>.</p>

<hr />

<p>Thank you for your continued support and interest in Athena. As always, we welcome your feedback and encourage you to
experiment with the devnet. Please to follow the project on <a href="https://github.com/athenavm">GitHub</a> and
<a href="https://x.com/hashtag/athenavm">X</a>, and to join the conversation in the
<a href="https://discord.com/invite/yVhQ7rC">#athena-vm</a> channel on our Discord to stay up to date with our developments.</p>

<p>Stay tuned for more updates next month!</p>]]></content><author><name></name></author><category term="updates" /><summary type="html"><![CDATA[This month’s update breaks away from the usual pattern, as we’ve done more design and less development work this month. Specifically, we’ve fleshed out Athena’s initial featureset - the “Minimum Viable Product”.]]></summary></entry><entry><title type="html">January 2025 Project Update</title><link href="https://athenavm.github.io//updates/2025/02/04/january-project-update.html" rel="alternate" type="text/html" title="January 2025 Project Update" /><published>2025-02-04T00:00:00+00:00</published><updated>2025-02-04T00:00:00+00:00</updated><id>https://athenavm.github.io//updates/2025/02/04/january-project-update</id><content type="html" xml:base="https://athenavm.github.io//updates/2025/02/04/january-project-update.html"><![CDATA[<p>We’re kicking off 2025 with exciting progress on Athena!
This month, we launched the first public devnet, implemented the PROXY method, and introduced new token-related smart contracts.
Let’s dive into the details.</p>

<h2 id="first-public-devnet-released">First Public Devnet Released</h2>

<p>We’re thrilled to announce the release of Athena’s first public devnet!
Developers can now test, experiment, and implement smart contracts on Athena.
This is a Proof of Concept (PoC) where AthenaVM replaces the Spacemesh VM on L1.
However, in the final design, AthenaVM will work alongside the genesis VM—more details on that will come in future updates.</p>

<p>If you’re interested in testing it out, we welcome you to deploy your own contracts and explore its capabilities.
Your feedback will be invaluable in refining the system!</p>

<p>To join the network, please follow the guide located <a href="https://docs.spacemesh.io/docs/experimental/athena-devnet">here</a>.</p>

<h2 id="proxy-method-implemented">PROXY Method Implemented</h2>

<p>A major milestone this month was the implementation of the <code class="language-plaintext highlighter-rouge">PROXY</code> method, now integrated into the single-signature wallet.
This method enables one contract to call another while handling transaction fees and
optionally transferring funds to the target contract.
Importantly, the transaction is always signed by the principal wallet, ensuring clear authorization.</p>

<p>This feature has already proven useful in implementing token-related smart contracts—see the next section for details!</p>

<h2 id="token-mint-and-token-wallet-contracts">Token Mint and Token Wallet Contracts</h2>

<p>To demonstrate Athena’s capabilities, we implemented two new example smart contracts: a <strong>Token Mint</strong> and a <strong>Token Wallet</strong>.
These contracts allow users to create and exchange custom tokens.</p>

<ul>
  <li><strong>Token Mint Contract:</strong> Governs the creation of a specific token.
Every instance of a mint contract defines a new, unique token.
Users exchange SMH for these tokens, which are then stored in a token wallet.</li>
  <li><strong>Token Wallet Contract:</strong> Manages token balances and enables transfers between accounts.
A single wallet can hold multiple tokens, each identified by the address of the mint account that created them.</li>
</ul>

<p>We recorded a video explaining how these contracts work:</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/coDYrlq9J1Q?si=1qDEvWFf8oNQglL2" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<h3 id="how-users-exchange-smh-for-tokens">How Users Exchange SMH for Tokens</h3>

<p>The process of exchanging SMH for a token involves three contracts working together:</p>

<ol>
  <li>The user creates a transaction invoking the <code class="language-plaintext highlighter-rouge">PROXY</code> method on a wallet contract that holds SMH.
The <code class="language-plaintext highlighter-rouge">PROXY</code> method ensures that the wallet pays all transaction fees and forwards a method call to another contract while transferring SMH to the called account.</li>
  <li>The recipient contract in this case is the <strong>mint contract</strong>, where the user is purchasing tokens.
The <code class="language-plaintext highlighter-rouge">PROXY</code> method calls the <code class="language-plaintext highlighter-rouge">BUY</code> method in the mint contract, transferring SMH funds to it.</li>
  <li>The mint contract verifies the received SMH, checks the available token supply,
and transfers the appropriate number of tokens to the <strong>token wallet contract</strong> by calling its <code class="language-plaintext highlighter-rouge">RECEIVE</code> method.</li>
  <li>The token wallet contract, rather than the mint, is responsible for maintaining token balances.
When the <code class="language-plaintext highlighter-rouge">RECEIVE</code> method is called, the wallet contract increases its balance by the specified token amount.</li>
</ol>

<p>Below is a diagram illustrating how one can purchase tokens using these contracts:</p>

<p><img src="/assets/mint_diagram.png" alt="buying tokens" /></p>

<p>The code of these contracts is available on GitHub:
<a href="https://github.com/athenavm/athena/blob/ed3f44443690e3d302f6defa48fb5f71d9ba6a25/examples/token/mint/src/main.rs"><code class="language-plaintext highlighter-rouge">MINT</code></a>
and
<a href="https://github.com/athenavm/athena/blob/ed3f44443690e3d302f6defa48fb5f71d9ba6a25/examples/token/wallet/src/main.rs"><code class="language-plaintext highlighter-rouge">WALLET</code></a>.</p>

<h2 id="looking-ahead">Looking Ahead</h2>

<ul>
  <li>We will continue refining the devnet and addressing early feedback from developers.</li>
  <li>We are working hard on finalizing the AthenaVM architecture and moving from the PoC to a final solution.</li>
</ul>

<h2 id="contributing">Contributing</h2>

<p>Athena is being built fully in the open, and the codebase is fully open source and permissively licensed.
If you’re interested in contributing, take a look at the list of issues tagged <code class="language-plaintext highlighter-rouge">Help Wanted</code> and <code class="language-plaintext highlighter-rouge">Good First Issue</code> on <a href="https://github.com/athenavm">GitHub</a>.</p>

<hr />

<p>Thank you for your continued support and interest in Athena.
As always, we welcome your feedback and encourage you to experiment with the devnet.
Please to follow the project on <a href="https://github.com/athenavm">GitHub</a> and <a href="https://x.com/hashtag/athenavm">X</a>,
and to join the conversation in the <a href="https://discord.com/invite/yVhQ7rC">#athena-vm</a> channel on our Discord
to stay up to date with our developments.</p>

<p>Stay tuned for more updates next month!</p>]]></content><author><name></name></author><category term="updates" /><summary type="html"><![CDATA[We’re kicking off 2025 with exciting progress on Athena! This month, we launched the first public devnet, implemented the PROXY method, and introduced new token-related smart contracts. Let’s dive into the details.]]></summary></entry><entry><title type="html">December Project Update</title><link href="https://athenavm.github.io//2025/01/09/december-project-update.html" rel="alternate" type="text/html" title="December Project Update" /><published>2025-01-09T00:00:00+00:00</published><updated>2025-01-09T00:00:00+00:00</updated><id>https://athenavm.github.io//2025/01/09/december-project-update</id><content type="html" xml:base="https://athenavm.github.io//2025/01/09/december-project-update.html"><![CDATA[<h1 id="december-project-update">December Project Update</h1>

<p>As we reflect on the final month of 2024, we wanted to share the progress made on Athena during December. Despite the shortened month due to the holiday season, we managed to achieve some significant milestones.</p>

<h2 id="multisig-wallet-ported-to-athena">Multisig Wallet Ported to Athena</h2>

<p>The multisig wallet contract from the go-spacemesh genesis VM has been successfully ported to Athena (<a href="https://github.com/spacemeshos/go-spacemesh/pull/6528">PR #6528</a>). This wallet allows transactions to be signed by multiple keys, offering enhanced functionality and flexibility for users.</p>

<h2 id="deployment-method-and-testnet-testing">Deployment Method and Testnet Testing</h2>

<p>We’re excited to announce that the <code class="language-plaintext highlighter-rouge">DEPLOY</code> method has been implemented and tested on the testnet. This enables the deployment of new smart contracts, marking a critical step forward for Athena.</p>

<p>Here we deploy the new multisig template. It received an address calculated from the hash of the code: <code class="language-plaintext highlighter-rouge">atest1rq5c736k86szfe50mslwukxrh457xxjl6klsl2q7ay5pv</code>:
<img src="/assets/tx_deploy.png" alt="" /></p>

<p>And it is spawned at address <code class="language-plaintext highlighter-rouge">atest1qqqqqqqg0khlwxhgcyr9ja5qn2fwx64d8jxah7sxmytpp</code>:
<img src="/assets/tx_spawn_multisig.png" alt="" /></p>

<h2 id="enhancing-vm-reliability">Enhancing VM Reliability</h2>

<p>A major focus this month was improving the reliability of the VM. During testing, we identified and resolved several vulnerabilities that could crash the VM when executing crafted programs. While this is a solid start, there are still areas where improvements are needed, and we will continue to address these issues to make the VM robust against potentially malicious code.</p>

<h2 id="optimizing-contract-binary-size">Optimizing Contract Binary Size</h2>

<p>Another highlight is the significant reduction in contract binary size. For instance, we trimmed the basic wallet contract from 148 kiB to 48 kiB by eliminating the need for the ELF symbol table section. This improvement is part of <a href="https://github.com/athenavm/athena/pull/264">PR #264</a>. There’s still a lot to be done to further minimize binary sizes. This is important because the size of a contract template affects its cost as well as general efficiency of the VM.</p>

<h2 id="performance-enhancements">Performance Enhancements</h2>

<p>We’ve also made strides in improving the performance of smart contracts. By optimizing the data transfer between the VM and guest programs, we halved the gas costs for the singlesig wallet. You can check out the details in <a href="https://github.com/athenavm/athena/pull/267">PR #267</a>.</p>

<h2 id="looking-ahead">Looking Ahead</h2>

<h3 id="vm-robustness">VM Robustness</h3>

<p>Our top priority remains making the VM more reliable and robust. As it will execute user-deployed contracts, potentially malicious, ensuring it doesn’t crash under any circumstances is critical. Work on this front will continue in the coming weeks.</p>

<h3 id="public-testnet-launch">Public Testnet Launch</h3>

<p>We’re gearing up to release the first public testnet in January! This testnet will allow users to spawn contracts, send funds, and deploy new smart contracts. Please note that this is a proof-of-concept (PoC) integration replacing the genesis VM on L1. It is far from the final solution, and we’re actively working on finalizing the design.</p>

<p>We want to set expectations: the testnet may not be fully reliable due to potential bugs, and nodes could crash. We appreciate your understanding and look forward to your feedback as we refine Athena further.</p>

<h3 id="proxy-method-implementation">PROXY Method Implementation</h3>

<p>Lastly, work is ongoing to implement the <code class="language-plaintext highlighter-rouge">PROXY</code> method, which will enable contracts to call other contracts, unlocking powerful composability features.</p>

<h2 id="contributing">Contributing</h2>

<p>As always, we encourage you to follow the project on <a href="https://github.com/athenavm">Github</a> and <a href="https://x.com/hashtag/athenavm">X</a>, and to join the conversation in the <code class="language-plaintext highlighter-rouge">#athena-vm</code> channel <a href="https://chat.spacemesh.io/">on our Discord</a>.</p>

<p>Athena is being built fully in the open and the codebase is fully open source and permissively licensed. If you’re interested in contributing, take a look at the list of issues tagged <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22">Help Wanted</a> and <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22">Good First Issue</a>.</p>

<hr />

<p>Thank you for your continued support and interest in Athena. We wish you all a happy and prosperous New Year. Stay tuned for more updates in January!</p>]]></content><author><name></name></author><summary type="html"><![CDATA[December Project Update]]></summary></entry><entry><title type="html">November Project Update</title><link href="https://athenavm.github.io//2024/12/11/november-project-update.html" rel="alternate" type="text/html" title="November Project Update" /><published>2024-12-11T00:00:00+00:00</published><updated>2024-12-11T00:00:00+00:00</updated><id>https://athenavm.github.io//2024/12/11/november-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/12/11/november-project-update.html"><![CDATA[<h1 id="november-athena-update">November Athena update</h1>

<p>November was all about finishing up the remaining initial integration work, and shipping the initial, alpha testnet.</p>

<h2 id="tldr">Tldr</h2>

<p>A month ago, the initial integration work had just been completed and we were just working on getting the tests to pass. That work was completed in early November. The rest of the month was spent on three parallel work streams: 1. code reviewing the initial integration work, 2. launching the first testnet, and 3. adding support for Athena transactions and the Athena testnet to the Spacemesh web wallet.</p>

<p>As of today, the second and third are done, and we’ve made great progress on the first.</p>

<h2 id="testnet">Testnet</h2>

<p>The launch wasn’t without a few hiccups, but our devops team successfully launched the first Athena testnet in mid-November. As mentioned many times before, this initial testnet only allows two types of transactions: spawning a wallet and sending coins. We’re excited to report that these transactions are running successfully on the testnet.</p>

<p>We are working on adding support for more kinds of transactions, in particular, deploying new programs. This work work is very much R&amp;D and requires doing some breaking changes in the process. This is why we haven’t released a public testnet yet. We plan to create a public network once we moreless stabilize the format of transactions.</p>

<h2 id="wallet-and-explorer">Wallet and Explorer</h2>

<p>A testnet isn’t just the invisible, backend infrastructure—Athena itself, the go-spacemesh integration, the testnet configuration, etc. It also needs a frontend. Our frontends are the <a href="https://wallet.spacemesh.io/">Spacemesh web wallet</a> and the <a href="https://explorer-devnet-athena.spacemesh.network/overview">Testnet explorer</a>.</p>

<p>These needed to be updated to support the Athena transaction format, which is a bit different than the OG Spacemesh transaction format. This work was done in November, and you can now make Athena testnet transactions using the web wallet, and see these transactions in the explorer.</p>

<p>The explorer can already parse and show Athena transactions executed on the testnet. Below are a few screenshots from the explorer showing TXs and accounts</p>

<h4 id="spawn-transaction">Spawn transaction</h4>

<p><img src="/assets/tx_spawn.png" alt="" /></p>

<h4 id="spend-transaction">Spend transaction</h4>

<p><img src="/assets/tx_spend.png" alt="" /></p>

<p><img src="/assets/account_received_spend.png" alt="" /></p>

<h4 id="coinbase-receiving-rewards-for-smeshing">Coinbase receiving rewards for smeshing</h4>

<p><img src="/assets/account_rewards.png" alt="" /></p>

<h2 id="whats-next">What’s Next</h2>

<p>While the initial integration work is done and the testnet is running, much work remains to continue to develop Athena to be more useful and production-ready. The code review of the integration work is ongoing, and the code has already been cleaned up considerably. The next major feature that’s being added to Athena is the ability for users to deploy their own programs. This will make Athena much more useful and much more interesting. We hope to include this in the next testnet release.</p>

<p>You can track progress towards future releases on the <a href="https://github.com/athenavm/athena/milestones">Github milestones</a> page.</p>

<h2 id="contributing">Contributing</h2>

<p>As always, we encourage you to follow the project on <a href="https://github.com/athenavm">Github</a> and <a href="https://x.com/hashtag/athenavm">X</a>, and to join the conversation in the <code class="language-plaintext highlighter-rouge">#athena-vm</code> channel <a href="https://chat.spacemesh.io/">on our Discord</a>.</p>

<p>Athena is being built fully in the open and the codebase is fully open source and permissively licensed. If you’re interested in contributing, take a look at the list of issues tagged <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22">Help Wanted</a> and <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22">Good First Issue</a>.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[November Athena update]]></summary></entry><entry><title type="html">October Project Update</title><link href="https://athenavm.github.io//2024/10/31/october-project-update.html" rel="alternate" type="text/html" title="October Project Update" /><published>2024-10-31T00:00:00+00:00</published><updated>2024-10-31T00:00:00+00:00</updated><id>https://athenavm.github.io//2024/10/31/october-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/10/31/october-project-update.html"><![CDATA[<p>October was an exceptionally productive month and we made great progress on the Athena project, something which is immediately obvious on the <a href="https://github.com/athenavm/athena/releases">Athena releases page</a>. We merged a remarkable 84 pull requests in the past month. Read on to learn more about what we’ve accomplished, what we’re working now, the current project status, and what comes next.</p>

<h1 id="tldr">Tldr</h1>

<p>I can now say with confidence that we have everything we need on <a href="https://github.com/orgs/athenavm/projects/2/views/1">the Athena side</a> to complete the initial integration work with go-spacemesh, and to launch the initial Athena testnet. This month we completed the last missing pieces of the puzzle, including implementing <a href="https://github.com/athenavm/athena/pull/147">method selectors</a>, the <a href="https://github.com/athenavm/athena/issues/128"><code class="language-plaintext highlighter-rouge">MaxSpend</code></a> and <a href="https://github.com/athenavm/athena/issues/129"><code class="language-plaintext highlighter-rouge">Verify</code></a> interface methods, as well as finalizing the <a href="https://github.com/athenavm/athena/issues/131">Athena payload</a> and <a href="https://github.com/athenavm/athena/issues/172">transaction encoding</a>.</p>

<p>The initial <a href="https://github.com/spacemeshos/go-spacemesh/pull/6380"><code class="language-plaintext highlighter-rouge">go-spacemesh</code> integration work</a> is also finished, and we’re just working on getting the tests to pass. We don’t expect this to take more than a few more days, and once that’s done, there will be a code review process and then we’ll launch the initial testnet.</p>

<h1 id="testnet">Testnet</h1>

<p>While the completion of this initial integration work, and the launch of the first Athena testnet, is of course a huge milestone and should be celebrated, it’s important to remind the community that the initial testnet will be extremely limited in terms of functionality, and that there’s still a large amount of work to be done before Athena is ready for a mainnet launch.</p>

<p>The initial testnet will include only a single template, the <a href="https://github.com/athenavm/athena/blob/main/examples/wallet/program/src/main.rs">single sig wallet template</a>, and will only allow simple coin transfers. The primary goal of this initial testnet is just to test that everything is working end-to-end: that you can join and sync the testnet, create, sign, and broadcast an Athena transaction, and that state updates are happening correctly.</p>

<p>If all goes well with the initial phase of the testnet, we plan to roll out a number of additional features in further phases, such as event logs, better gas metering, multisig, and cross-contract calls. Most importantly, we’ll add the ability for users to deploy their own template code.</p>

<p>For a sneak peak of what we plan to add, check out the recently-updated <a href="https://github.com/athenavm/athena/milestones">Athena project milestones</a>.</p>

<h1 id="vm">VM</h1>

<p>In addition to the testnet-critical features described above, we made a huge amount of progress cleaning up and improving the Athena codebase over the past month, and implementing other features that will be required for future testnet iterations. Some notable improvements include:</p>

<ul>
  <li>Massive <a href="https://github.com/athenavm/athena/pull/122">cleanup of tests</a></li>
  <li>Improving <a href="https://github.com/athenavm/athena/pull/139">object serialization</a></li>
  <li>Improving <a href="https://github.com/athenavm/athena/pull/150">memory management</a> and fixing a number of memory-related bugs</li>
  <li>Removing <a href="https://github.com/athenavm/athena/pull/159">compiled test programs</a></li>
  <li>Adding support for the <a href="https://github.com/athenavm/athena/pull/175"><code class="language-plaintext highlighter-rouge">CALL</code> host call to return data</a></li>
  <li>Adding our first precompile: <a href="https://github.com/athenavm/athena/pull/182"><code class="language-plaintext highlighter-rouge">ed25519</code> signature verification</a></li>
</ul>

<h1 id="integration">Integration</h1>

<p>The main blocker for launching the initial testnet is finishing the <a href="https://github.com/spacemeshos/go-spacemesh/pull/6380"><code class="language-plaintext highlighter-rouge">go-spacemesh</code> integration work</a>. This work initially proceeded slowly due to the need for a lot of context switching: we’d make some progress, then realize that we needed to add something else to Athena to facilitate the integration work. Adding that would take a few days, then we’d switch back to the intregration work. But the work is moving much more quickly now that we have everything we need on the Athena side.</p>

<p>I mentioned <a href="https://www.athenavm.org/2024/09/30/september-project-update.html#scoping">last month</a> that we weren’t sure whether we wanted to attempt to deliver a production-ready integration, or whether we instead wanted to write “throwaway code” in the interest of shipping a testnet as soon as possible. After further discussion we decided on the latter course of action. We’re now working on Athena in a parallel go-spacemesh branch that we don’t intend ever to merge into production. We made this decision for three reasons (and please note that these apply to the <em>host integration</em> work for Athena in go-spacemesh, <em>not</em> to the main VM, which we do expect eventually to be used in production):</p>

<ol>
  <li>Expediency, as discussed. It will allow us to deliver a testnet much more quickly than if we had to thoroughly review everything, write thorough tests for everything, and generally do everything in production-ready fashion.</li>
  <li>Uncertainty. A lot of the details about the later phases of Athena, most notably the rollup design and the ZK design, are still up in the air at this point in time. We don’t feel that we can write final, production-ready Athena host code until more of these questions have been answered.</li>
  <li>Once we have more confidence about these questions, we intend to rewrite the host code anyway. Having done this once already will undoubtedly result in much better design and implementation the second time around.</li>
</ol>

<p>Since we chose to perform the integration work as quickly as possible, this necessarily means making as few changes as possible to the existing go-spacemesh data structures and logic. While still faster than the alternative, the integration work has taken longer than expected because it required deeper changes to go-spacemesh than we initially anticipated.</p>

<p>The Spacemesh mainnet VM, known as the “genesis VM” or “genvm”, is designed and implemented in a way that’s fundamentally incompatible with many aspects of the Athena design. The implementation makes a lot of assumptions that aren’t valid in the context of Athena, such as that templates can interact with the blockchain state in an extremely limited way, and that state changes from one transaction don’t have much impact upon later transactions. Refactoring the related code has turned into a big project, but the work is nearly done and there is a light at the end of the tunnel.</p>

<h1 id="whats-next">What’s Next</h1>

<p>We’re working diligently to finish this integration work. As mentioned above, this requires getting existing tests to pass fully, and a code review process. This will take a few days. In parallel, we’ll begin putting together the testnet infrastructure, and we’ll prepare other parts of the infrastructure for the testnet launch, including the node API, explorer, and web wallet. What’s more, in parallel to the testnet effort, we’ll continue working on improvements on the VM side to bring more features online in future testnets, as described above.</p>

<h1 id="updates-and-contributions">Updates and Contributions</h1>

<p>As always, we encourage you to follow the project on <a href="https://github.com/athenavm">Github</a> and <a href="https://x.com/hashtag/athenavm">X</a>, and to join the conversation in the <code class="language-plaintext highlighter-rouge">#athena-vm</code> channel <a href="https://chat.spacemesh.io/">on our Discord</a>.</p>

<p>Athena is being built fully in the open and the codebase is fully open source and permissively licensed. If you’re interested in contributing, take a look at the list of issues tagged <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22">Help Wanted</a> and <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22">Good First Issue</a>.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[October was an exceptionally productive month and we made great progress on the Athena project, something which is immediately obvious on the Athena releases page. We merged a remarkable 84 pull requests in the past month. Read on to learn more about what we’ve accomplished, what we’re working now, the current project status, and what comes next.]]></summary></entry><entry><title type="html">September Project Update</title><link href="https://athenavm.github.io//2024/09/30/september-project-update.html" rel="alternate" type="text/html" title="September Project Update" /><published>2024-09-30T20:06:33+00:00</published><updated>2024-09-30T20:06:33+00:00</updated><id>https://athenavm.github.io//2024/09/30/september-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/09/30/september-project-update.html"><![CDATA[<p>The month of September flew by in a blur. While there wasn’t as much steady progress on Athena during September due to travel and time off, we nevertheless achieved some significant milestones and continue to make good progress towards the next big milestone: launching the initial, proof of concept Athena testnet.</p>

<h2 id="tldr">Tldr</h2>

<p>Everything we need to launch the initial, proof of concept Athena testnet is now in place on the Athena side. We merged a <a href="https://github.com/athenavm/athena/pull/74">major update</a> that includes the <a href="https://github.com/athenavm/athena/issues/75">remainder</a> of the <a href="https://github.com/athenavm/athena/issues/28">initial set of host functions</a>, a <a href="https://github.com/athenavm/athena/issues/54">SDK</a> and <a href="https://rettig.substack.com/p/technical-challenges-in-athena-part?open=false#%C2%A7thing-its-just-rust">procedural macros</a> used for writing Athena programs, and some other nice features such as the ability for a program to have <a href="https://github.com/athenavm/athena/issues/73">multiple entry points</a>.</p>

<p>The other big piece of news this month is that two additional developers have joined the Athena project. It took a few weeks but they’re now up to speed and have begun to make <a href="https://github.com/athenavm/athena/pulls?q=is%3Apr+is%3Aclosed+-author%3Alrettig+">major contributions</a> to Athena.</p>

<p>We also have a final proof of concept Spacemesh wallet template <a href="https://github.com/athenavm/athena/blob/main/examples/wallet/program/src/main.rs">implemented in Athena Rust</a>. For now it implements only two of the proposed <a href="https://community.spacemesh.io/t/proposed-athena-design/433#type-2-wallet-call-5">four wallet methods</a>, <code class="language-plaintext highlighter-rouge">spawn</code> and <code class="language-plaintext highlighter-rouge">send</code>, but this is sufficient for the initial testnet.</p>

<p>If work on the <a href="https://github.com/athenavm/athena">Athena Rust code</a> appears to have slowed, it’s only because we now have everything we need for the testnet, and we’re totally focused on finishing the initial integration with go-spacemesh in order to launch the testnet.</p>

<h2 id="integration">Integration</h2>

<p>Up to now, all of the work on Athena occurred in an hermetic, self-contained fashion. To the extent that we’ve tested the host API, we did so using a very simplistic <a href="https://github.com/athenavm/athena/blob/6bdceaab5cf3bf9f44c42ecfda3abb4ec08002f2/interface/src/lib.rs#L393-L418">mock host implementation</a>. As I <a href="https://www.athenavm.org/2024/08/19/august-project-update.html#testnet">mentioned last month</a>, the goal of this phase of the project is to package up everything that’s been done so far and get it running on a proof of concept Athena testnet. Doing so requires integrating the Athena VM into go-spacemesh (the host).</p>

<p>This work is off to a good start, but it’s a big project. First of all, it requires rewriting the existing Spacemesh VM code to replace the monolithic “genesis VM” and make it modular. The initial portion of this work is <a href="https://github.com/spacemeshos/go-spacemesh/pull/6180">complete</a>, but there’s a lot of work remaining to expand the existing Spacemesh VM API to encompass all of Athena’s functionality. Secondly, it requires expanding the Spacemesh account model to make it compatible with Athena: for instance, in addition to what’s already present in the Spacemesh account model, Athena accounts contain storage items.</p>

<h2 id="database">Database</h2>

<p>For now, in the interest of launching the Athena testnet as soon as possible, we’ll implement this in a straightforward, naive fashion: storage items will just be stored as an array or map under the Spacemesh account data type, using the existing account database table. However, it’s highly likely that we’ll need to redesign and rewrite this portion of the integration in the future since the IO associated with state access is one of the major bottlenecks on blockchain throughput for projects like Ethereum, and also to add support for light client proofs. We’re inspired by the pioneering prior work being done by projects like <a href="https://erigon.tech/">Erigon</a> and <a href="https://docs.monad.xyz/technical-discussion/execution/monaddb">Monad</a> in this respect, and as with the rest of Athena, we’ll make use of existing, mature designs and implementations wherever possible, rather than reinventing the wheel.</p>

<h2 id="scoping">Scoping</h2>

<p>In complete transparency, we don’t know exactly how much work remains to finish this initial integration work. In addition to the changes to the account model, just described, we’ll likely need to change a bunch of other aspects of go-spacemesh including the node API, the transaction format, and the pipeline that constructs and processes blocks and transactions. (Fortunately, Athena does <em>not</em> impact <em>most</em> of go-spacemesh, including things like networking and consensus.)</p>

<p>go-spacemesh is a complex, largely monolithic codebase and Athena integration requires making deep changes. There’s also a key question of how much time and effort we want to invest in doing things “the right way,” and producing an integration that has a chance of eventually making it into production, versus writing throwaway code in the interest of shipping the Athena testnet as soon as possible. There’s a big difference between maintaining a parallel Athena branch of go-spacemesh versus merging changes one by one into go-spacemesh in production. The most important part of this phase is finishing this scoping and design, a task that’s underway as we speak.</p>

<p>Now that we have multiple core developers working on Athena and the integration, we also have to prioritize the work relative to <a href="https://x.com/teamspacemesh/status/1839657165155406004">other critical ongoing tasks</a>.</p>

<p>In the best case, I expect this integration work to take a few days to a few weeks. In the worst case, it could take weeks to months. We’ll have much more clarity on the remaining steps and timeframe in the near future, and we’ll continue to keep the community updated.</p>

<h2 id="whats-next">What’s Next</h2>

<p>Next month is all about scoping, planning, and integration, integration, integration. We hope to share more concrete plans on the launch of the initial, proof of concept Athena testnet soon. Watch this space!</p>]]></content><author><name></name></author><category term="athena" /><category term="update" /><summary type="html"><![CDATA[The month of September flew by in a blur. While there wasn’t as much steady progress on Athena during September due to travel and time off, we nevertheless achieved some significant milestones and continue to make good progress towards the next big milestone: launching the initial, proof of concept Athena testnet.]]></summary></entry><entry><title type="html">August Project Update</title><link href="https://athenavm.github.io//2024/08/19/august-project-update.html" rel="alternate" type="text/html" title="August Project Update" /><published>2024-08-20T02:25:33+00:00</published><updated>2024-08-20T02:25:33+00:00</updated><id>https://athenavm.github.io//2024/08/19/august-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/08/19/august-project-update.html"><![CDATA[<p>I’m about to take off for a short summer holiday, but I owe you an Athena project update before that. In the past few weeks we finished the third phase, Blockchain Integration, and kicked off work on the fourth phase. The goal of this phase is to launch an Athena testnet.</p>

<h2 id="tldr">Tldr</h2>

<p>In the last phase we successfully added <a href="https://github.com/athenavm/athena/blob/main/vm/hostfunctions/src/lib.rs">several host functions</a> that allow Athena programs to read and write state, call other programs, and send coins. After that we began working on the very concrete goal of launching a barebones Athena testnet to allow users to begin testing what’s been built so far, while we continue to improve Athena and work on the remaining phases (mainly rollup design and ZK) in parallel. We made some important progress on upgrading the Athena Rust toolchain. Another Spacemesh developer has joined the project, and he made some big improvements to the FFI bindings which will make it much easier to integrate Athena into go-spacemesh. Finally, while rewriting the first, existing Spacemesh template, the single sig wallet template, in Athena, we realized there are still a few missing features which we’re currently working on.</p>

<h2 id="toolchain">Toolchain</h2>

<p>The Rust toolchain has been a headache since the beginning of the Athena project, as I <a href="https://rettig.substack.com/i/147359339/thing-rust-toolchain">previously wrote about</a>. The first toolchain release was based on Rust 1.78.0 and included a <a href="https://github.com/athenavm/rustc-rv32e-toolchain/blob/v0.2.0/patches/rust.patch">fairly large patch</a> for compatibility with our RV32E instruction set. It only supported linux-amd64. I previously tried to upgrade to a more recent Rust release but kept running into problems due to <a href="https://github.com/athenavm/rustc-rv32e-toolchain/issues/1#issuecomment-2156233834">other</a> <a href="https://github.com/athenavm/rustc-rv32e-toolchain/issues/6">people’s</a> <a href="https://github.com/athenavm/rustc-rv32e-toolchain/pull/8#issuecomment-2294022934">bugs</a>. While Rust and LLVM feature experimental support for RISC-V in general, and RV32E specifically, “experimental” unfortunately means that not everything works out of the box on every platform/architecture.</p>

<p>Since then we’ve made several improvements to the toolchain, and this work is ongoing. Firstly, we succeeded in upgrading to Rust 1.80.0 which includes some nice <a href="https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html">new language features</a>. The patch is smaller, but it also includes a new, <a href="https://github.com/athenavm/rustc-rv32e-toolchain/blob/v0.3.0/patches/llvm.patch">small LLVM patch</a> to work around yet another toolchain issue. I’m pretty sure I know how to remove this patch, and work on this is <a href="https://github.com/athenavm/rustc-rv32e-toolchain/pull/8">ongoing</a>. Secondly, with the <a href="https://github.com/athenavm/rustc-rv32e-toolchain/releases/tag/v0.3.0">latest release</a>, we’ve successfully added macOS support (only Apple Silicon for now).</p>

<p>One of the things that makes working on the toolchain so hard is that it takes &gt; 30 minutes to compile locally, and up to two hours to compile when using Github Actions runners. This makes feedback loops incredibly slow: it takes hours to see the effects of a small change to the configuration. So we’ve also been working on finding faster runners that are still affordable. We successfully added support for <a href="https://runs-on.com/">RunsOn</a>, which is great for Linux runners, but have been unable to find better runners for Windows or Mac. If you are aware of a solution, please let us know.</p>

<h2 id="missing-pieces">Missing Pieces</h2>

<p>One of the great things about having a very concrete goal like integrating Athena into go-spacemesh and launching a testnet is that it immediately reveals things that are still missing. The first step in the integration is rewriting the existing Spacemesh templates for Athena.</p>

<p>As a recap, programs (smart contracts) in Spacemesh are split into two parts: a template and a program. (The terminology isn’t finalized and we’re open to suggestions for improvements.) You can think of a template like a class definition in an object oriented programming language—or, in more concrete terms, like an uninstantiated Rust struct. The act of placing a new template on chain is called “deploying.” Once this is done, a user can send a spawn transaction to spawn an instance of a template that they control, i.e., that contains their state. The first and most important template is the single sig wallet template, and the only initialization state associated with this template is the public key that controls it.</p>

<p>Templates in Spacemesh today are implemented natively in Go (which is why we sometimes refer to them as precompiles). They’re implemented in multiple pieces and the code is fairly complicated. Templates will be much cleaner in Athena: a template is just a single, ordinary Rust struct. And thanks to account abstraction, templates control their own serialization/deserialization, authentication, etc.</p>

<p>The first Athena template, the single sig wallet template, is more or less done, and the bulk of the work in this phase has been filling in the missing pieces in Athena around it to make it work. This includes a “spawn” host call, and the ability to save a serialized program instance to chain and restore it on a subsequent call. Getting this working without the use of a custom toolchain required some fairly complex Rust procedural macros, something else I <a href="https://rettig.substack.com/i/147861802/thing-its-just-rust">wrote about recently</a>. We also needed to add the ability to call into an Athena binary in <a href="https://github.com/athenavm/athena/issues/73">multiple places</a>—i.e., to add a form of function dispatch.</p>

<h2 id="wallet-template">Wallet Template</h2>

<p>As mentioned, the wallet template is the first canonical Athena program. It’s the analogue of an Ethereum “externally owned account” (EOA), i.e., an account controlled by a single keypair, under the Spacemesh model of account abstraction. The vast majority of transactions flowing through Athena will pass through this template, or another template modeled after it, for a long time, so it’s important that we get it right.</p>

<p>The wallet template implements four methods: spawn, deploy, send, and call. These are the core primitives for the Athena VM transaction and account model. Spawn takes a public key and spawns a new wallet program owned by that key, as mentioned above. Deploy deploys a new template, i.e., new code to the blockchain. Send sends coins to another account, and call allows the wallet owner to call a function on another program. For more on this design, see the <a href="https://community.spacemesh.io/t/proposed-athena-design/433">Athena design document</a>.</p>

<p>You can find the prototype code for the single sig wallet template <a href="https://github.com/athenavm/athena/blob/vmsdk/examples/wallet/program/src/main.rs">here</a>.</p>

<h2 id="testnet">Testnet</h2>

<p>As previously mentioned, the concrete goal of this phase is to launch an initial, prototype Athena testnet so that we can begin dogfooding the things we’ve been designing and building for months. While a number of things are still up in the air, the outlines of the testnet are now taking shape. It’s likely that the first testnet will feature only a single template, the single sig wallet template described above. We probably won’t have a “deploy” feature and won’t allow users to deploy their own templates in the initial version. It’ll probably look and feel a lot like the single sig wallet template that’s live on the Spacemesh mainnet today, i.e., it’ll just be a cryptocurrency where you spawn a wallet and send coins to someone else’s wallet. The important thing, however, is that all of this will be happening on Athena, so it’ll function as an end to end test of everything we’ve built so far.</p>

<p>There will be multiple generations of testnets and we’ll fix bugs and add functionality over time. Once we’ve tested the single sig wallet, we’ll likely roll out a multisig wallet, and then we’ll switch on a “deploy” feature that will allow users to deploy their own programs. That’s when the fun will really begin.</p>

<p>We’re very hopeful that we can get the initial testnet running by the end of September. Please bear in mind that, while the testnet represents a major step forward on the Athena roadmap and on the goal towards launching Athena in production on mainnet, even after the testnet is up and running, there will still be a lot of work required to get Athena into production on mainnet.</p>

<h2 id="host-integration">Host Integration</h2>

<p>The other missing piece of the puzzle is integrating Athena into go-spacemesh in order to launch the testnet. For now, we’ll implement Athena as an alternative VM, next to the existing “genesis VM.” This means that it’ll be possible to run go-spacemesh with either VM, and for the purposes of the testnet, we’ll run it with Athena switched on. In other words, the testnet will run Athena as its only, layer one VM.</p>

<p>This isn’t how Athena will work when we ultimately roll it out on Spacemesh in production. As we originally described, Athena will be implemented as a “sovereign rollup” that runs on top of the existing Spacemesh layer one VM. Athena transactions will be sequenced together into bundles and the existing Spacemesh VM and miners will provide data availability to Athena.</p>

<p>But it’ll take time to finalize and implement that design, and in the meantime we’ll be able to have fun building and testing applications on the Athena testnet.</p>

<h2 id="whats-next">What’s Next</h2>

<p>There are still a number of important tasks in flight in this phase. We have a prototype of the single sig wallet template, but it still needs to be peer reviewed, tested, and merged. We have a prototype of the “spawn” host call working, but this also needs peer review and testing. We need to finalize the v0.3.0 toolchain, including hopefully removing the LLVM patch. Then we need to finish the go-spacemesh integration. As mentioned, we have a second developer working on the project now, and we’ll soon have a third, so we expect that development will speed up, but all of this will still take some time.</p>]]></content><author><name></name></author><category term="athena" /><category term="update" /><summary type="html"><![CDATA[I’m about to take off for a short summer holiday, but I owe you an Athena project update before that. In the past few weeks we finished the third phase, Blockchain Integration, and kicked off work on the fourth phase. The goal of this phase is to launch an Athena testnet.]]></summary></entry><entry><title type="html">July Project Update</title><link href="https://athenavm.github.io//2024/07/20/july-project-update.html" rel="alternate" type="text/html" title="July Project Update" /><published>2024-07-20T23:25:33+00:00</published><updated>2024-07-20T23:25:33+00:00</updated><id>https://athenavm.github.io//2024/07/20/july-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/07/20/july-project-update.html"><![CDATA[<p>We’re overdue for another Athena project update. Lots has happened over the past month. I was hoping that the current phase, Blockchain Integration, would be finished in time for this update. We’re not quite there yet, but we’re close.</p>

<h1 id="tldr">Tldr<a id="tldr"></a></h1>

<p>The first two project updates appeared at the completion of the first two phases: <a href="https://www.athenavm.org/athena/update/2024/05/09/project-update.html">Initial R&amp;D</a>, and <a href="https://www.athenavm.org/athena/update/2024/06/14/june-project-update.html">VM Prototype</a>. These phases are now visible in the <a href="https://github.com/athenavm/athena?tab=readme-ov-file#progress">project README</a>, and there’s a <a href="https://github.com/orgs/athenavm/projects/1">project board</a> tracking this phase. This phase isn’t quite finished, largely due to travel for EthCC. The good news is that I gave the <a href="https://ethcc.io/archive/Athena-Rises">first talk on Athena</a>, had a lot of good conversations about the project, and received a lot of good feedback.</p>

<p>This phase is going well and the first few host functions are in place—including the hard ones! The FFI, which was the hardest part of this phase, is complete and <a href="https://github.com/athenavm/athena/blob/main/ffi/ffitest/src/lib.rs">has been tested</a>. We have basic gas metering and the ability to read and write account state. Most importantly, we have our <a href="https://github.com/athenavm/athena/blob/main/tests/recursive_call/src/main.rs">first prototype smart contract</a>! It performs an end to end test that includes reading and writing account state, and calling back into itself recursively. This means that Athena is no longer just a RISC-V VM: with the addition of these features it’s a blockchain VM that now runs smart contracts that can call one another.</p>

<h1 id="ffi">FFI<a id="ffi"></a></h1>

<p>Our goal is for Athena to compile to a library that can be used in <em>any</em> blockchain node implementation. The first of these will, of course, be go-spacemesh. But Athena is written in Rust and go-spacemesh is, obviously, written in Go. Wut do?</p>

<p>Enter FFI. FFI stands for <a href="https://en.wikipedia.org/wiki/Foreign_function_interface">foreign function interface</a>. It’s the means by which programs written in one language can interface <em>in process</em> with a program written in a different language (i.e., without communicating over an API). The Athena FFI, known as <a href="https://github.com/athenavm/athena/blob/main/ffi/athcon/athcon.h">athcon</a> (for “Athena connector”), lays out a common language (the technical term for this is <a href="https://en.wikipedia.org/wiki/Application_binary_interface">ABI</a>) spoken both by Athena itself as well as by any host node that interfaces with it. It includes basic types such as account address, status codes, revision numbers, capabilities, and messages (an internal representation of a transaction). It also includes the <em>host interface,</em> which lays out the set of host functions that allow Athena and the programs running on it to interface with the blockchain (see next section).</p>

<p>It took a long time to design this interface since it needs to be simple, generic, and as blockchain-agnostic as possible. We intend for Athena to work not only in Spacemesh but in the context of other blockchains as well! Abstracting away the underlying specificities of Spacemesh, or of any blockchain, into a clean API is not a simple exercise.</p>

<p>Athcon lays out a <em>host</em> and a <em>VM.</em> The host is the blockchain node implementation, the thing that knows about accounts, addresses, balances, and code. The VM is Athena, i.e., the thing that <em>runs</em> that code in the context of the host. Today, there’s only one host in the Spacemesh ecosystem, go-spacemesh, but in the future there will hopefully be many full node implementations written in many languages, and it’s important that any of them can run Athena. By the same token, for now Athena is the only full VM in the Spacemesh ecosystem, but we could imagine a future with multiple VMs. Just as athcon plugs into any host, it should also plug into any future VM. (Athcon is based on an Ethereum ecosystem project known as <a href="https://evmc.ethereum.org/">EVM-C</a>, the “EVM Connector”, which provides a similar interface between multiple Ethereum node implementations and multiple Ethereum VMs including EVM and Ewasm.)</p>

<p>Note that, while the purpose of the FFI is to make Athena usable in any programming language, in fact designing the Athena FFI was a useful exercise regardless of other languages. This is because a C interface is by definition constraining, using only C types and C function syntax as it does. When you build a component of a program in the same language, you can be lazy: you tend to pass around more data than you need, you may not think thoroughly about memory management or the lifecycle of particular data elements, you may expose internal methods and properties unnecessarily, etc. And you can make changes and updates as often as you like, without needing to worry about compatibility issues.</p>

<p>By contrast, the FFI needs to be extremely slim. It needs to be rigorous and well-defined, and it can use only basic C types and functions since it needs to work in any language and any environment. What’s more, you need to be extremely thoughtful about memory and lifecycle management, since you don’t get this for free the way you do when working with native types and data structures. And you can’t easily make changes since this will cause downstream incompatibilities.</p>

<p>By building the Athcon interface, I realized that, like designing any API, SDK, or data interchange format, wrapping your functionality in a clean FFI is probably always a good exercise. As one example of why this matters regardless of language or execution context, many of the Athena tests—which are of course also written in Rust—use the FFI for testing. Those tests can be cleaner and simpler than they would be without the FFI. Athcon is the <a href="https://www.oilshell.org/blog/2022/02/diagrams.html">narrow waist</a> of Athena.</p>

<h1 id="host-functions">Host Functions<a id="host-functions"></a></h1>

<p>What separates any old VM from a blockchain execution environment, or a smart contract engine? The answer is a set of host functions (plus gas metering, for which see below). “Host function” is a term from embedded programming. It refers to functionality provided by the “host”—which in our case is the node, i.e., go-spacemesh—to the execution environment, i.e., the running smart contract. Without host functions, a smart contract is just a simple program that cannot read from or write to the blockchain. In the same way that system calls (“syscalls”) allow a program running on your computer to do interesting things like read from and write to files on the hard drive, send and receive data over the network, display information on the screen, etc., host functions allow the running program to interface with the blockchain: to read and write contract state, to deploy a new smart contract, to send coins, to call into a another smart contract, etc.</p>

<p>One of the main goals of this phase of the Athena project is to implement an initial, straightforward set of host functions. This will allow simple smart contracts to run on Athena. The first such smart contract, which is a test that writes some data to storage and then reads back the same data, can be found <a href="https://github.com/athenavm/athena/blob/bf587defaa1e0816ab3d4417ab85a4382280f086/tests/host/src/main.rs">here</a> and it looks like this:</p>

<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nd">#![no_main]</span>

<span class="nn">athena_vm</span><span class="p">::</span><span class="nd">entrypoint!</span><span class="p">(</span><span class="n">main</span><span class="p">);</span>

<span class="k">pub</span> <span class="k">fn</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
<span class="err">  </span><span class="c1">// use 32-bit words</span>
<span class="err">  </span><span class="k">let</span> <span class="k">mut</span> <span class="n">key</span> <span class="o">=</span> <span class="p">[</span><span class="mi">2u32</span><span class="p">;</span> <span class="mi">8</span><span class="p">];</span>
<span class="err">  </span><span class="k">let</span> <span class="k">mut</span> <span class="n">key2</span> <span class="o">=</span> <span class="p">[</span><span class="mi">2u32</span><span class="p">;</span> <span class="mi">8</span><span class="p">];</span>

<span class="err">  </span><span class="c1">// expected output value</span>

<span class="err">  </span><span class="c1">// [1u8; 32] i.e. 32 x 1-bytes</span>
<span class="err">  </span><span class="c1">// we convert [u8; 32] into [u32; 8] where each u32 is a 4 byte chunk</span>
<span class="err">  </span><span class="c1">// 0x01010101 == 16843009</span>

<span class="err">  </span><span class="k">let</span> <span class="n">value</span> <span class="o">=</span> <span class="p">[</span><span class="mi">16843009u32</span><span class="p">;</span> <span class="mi">8</span><span class="p">];</span>

<span class="err">  </span><span class="c1">// result will be written to key, overwriting input value</span>
<span class="err">  </span><span class="k">unsafe</span> <span class="p">{</span> <span class="nn">athena_vm</span><span class="p">::</span><span class="nn">host</span><span class="p">::</span><span class="nf">write_storage</span><span class="p">(</span><span class="n">key</span><span class="nf">.as_mut_ptr</span><span class="p">(),</span> <span class="n">value</span><span class="nf">.as_ptr</span><span class="p">())</span> <span class="p">};</span>
<span class="err">  </span><span class="nd">assert_eq!</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">[</span><span class="mi">0u32</span><span class="p">;</span> <span class="mi">8</span><span class="p">],</span> <span class="s">"write_storage failed"</span><span class="p">);</span>

<span class="err">  </span><span class="c1">// result will be written to key, overwriting input value</span>
<span class="err">  </span><span class="k">unsafe</span> <span class="p">{</span> <span class="nn">athena_vm</span><span class="p">::</span><span class="nn">host</span><span class="p">::</span><span class="nf">read_storage</span><span class="p">(</span><span class="n">key2</span><span class="nf">.as_mut_ptr</span><span class="p">())</span> <span class="p">};</span>
<span class="err">  </span><span class="nd">assert_eq!</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">key2</span><span class="p">,</span> <span class="s">"read_storage failed"</span><span class="p">);</span>
<span class="err">  </span><span class="nd">println!</span><span class="p">(</span><span class="s">"success"</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>

<p>The host functions here are the <code class="language-plaintext highlighter-rouge">athena_vm::host::write_storage</code> and <code class="language-plaintext highlighter-rouge">athena_vm::host::read_storage</code> which, as the names suggest, allow a running smart contract to write a storage item, which will be stored permanently on the blockchain, and to read a storage item, respectively. For now, this code is pretty low level and requires the use of <code class="language-plaintext highlighter-rouge">unsafe</code> Rust, requires passing raw pointers, etc., but this will become cleaner and easier as Athena matures. We’ll provide an SDK that hides these details. For a more complicated example, see this <a href="https://github.com/athenavm/athena/blob/19f2ff6f7a4bae22f4c84f98d03271b3ec418443/tests/recursive_call/src/main.rs">recursive host call test</a> using Fibonacci.</p>

<p>You can see the full, <a href="https://github.com/athenavm/athena/issues/28">initial set of host functions</a> we’ll implement. This list will grow over time as Athena matures. Three have already been implemented; the hardest of these was the <a href="https://github.com/athenavm/athena/issues/5"><code class="language-plaintext highlighter-rouge">call</code> host function</a>, which allows a running smart contract to call out to another, external smart contract. This is tricky because it introduces recursion: the VM needs to pause the current execution frame, construct a new VM message, pass this over the FFI boundary into the host, then the host needs to call back into the VM to perform the call, the results of which are unwound through the same process in reverse. In a sense, implementing <code class="language-plaintext highlighter-rouge">call</code> is really the capstone of this entire phase since it requires testing all of the other blockchain-related functionality (host functions, the host-VM interface, message passing, etc.) end to end. I expect the remaining host functions won’t take very long, and then we can declare this phase, too, completed.</p>

<h1 id="what-about-accounts">What About Accounts?<a id="what-about-accounts"></a></h1>

<p>The astute reader may have noticed that we’re talking about reading and writing account state, but we haven’t actually announced the Athena account model yet. Isn’t this contradictory? Well, yes and no.</p>

<p>No, because we can actually abstract a lot of this complexity away from Athena. This is another upside of the Host-VM pattern described above. Details such as how an account is implemented under the hood are the concern of the host, not of Athena. Athena uses a host-provided “host function” to request that data be written to, or read from, an account (and as far as Athena is concerned, an account is just an opaque bytestring). Athena doesn’t actually need to know anything about how an account is implemented or how the host fulfills this request (or fails to). The goal is for Athena to be as unopinionated about its <em>execution context</em> as possible. In the context of the blockchain, this means being agnostic as to which chain it’s running on, whether it’s running at layer one or layer two, etc. This both limits complexity and also ensures that Athena will run lots of places.</p>

<p>Yes, because there are limits to how far we can take this abstraction (and because all <a href="https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/">abstraction boundaries are leaky</a>). This works pretty well for simple functions, but it may not work so well when we get to more complex functions. Even for simple functions, we’ve made some assumptions. Reading and writing state currently assumes that state is a key-value store where keys and values are each 256-bit words, and that an account can only access its own state. That seems like a reasonable starting point because it’s <a href="https://www.evm.codes/#54?fork=cancun">how EVM works</a>, but we might decide to take things in a different direction with Athena in the future.</p>

<p>Another good example is deploying new programs (smart contracts). The Spacemesh layer one account model is based on templates, which are like classes, and individual accounts, which are instances of those templates. This works differently than it does in EVM. While we haven’t finalized the Athena account model, we’re leaning towards using the Spacemesh L1 account model in Athena, which means Athena <em>may</em> need to be more opinionated about things like how new code is deployed. Note that Athena also supports features and capabilities that can be switched on and off, so even if we add support for Spacemesh-style templates, it doesn’t mean that Athena won’t work in an execution environment without these.</p>

<p>We’re also seriously considering adding <a href="https://move-language.github.io/move/structs-and-resources.html">Move-style resources</a> and <a href="https://move-book.com/reference/abilities.html">abilities</a> to Athena. That’s another example of something that Athena might need to understand.</p>

<h1 id="gas-metering">Gas Metering<a id="gas-metering"></a></h1>

<p>The other missing piece of the puzzle is gas metering. We need to be able not only to execute smart contract code safely and securely, and to allow smart contracts to interact with the blockchain via host functions, but we of course also need to perform gas metering to ensure that running smart contracts don’t consume more resources than they’re able to pay for.</p>

<p>Since one of the main goals of this phase of Athena is to keep things simple, for now we’re doing braindead simple gas metering. Each instruction has an identical cost, and we simply meter each executed instruction as we go. In practice, it’s of course not actually the case that every instruction has the same cost! Complex instructions, especially cryptographic operations, as well as instructions that write to permanent storage, are more expensive and should charge more gas. See, for example, <a href="https://www.evm.codes/">this list of EVM opcodes</a> and the associated gas fees, many of which are dynamic and depend on, e.g., the amount of data read or written. We’ll implement more sophisticated gas metering in the future.</p>

<p>This sort of metering is pretty straightforward in an interpreter, which is how Athena works for now. In the future, if we decide to move to compiled code, we’ll need a more sophisticated approach such as injecting gas metering into the bytecode to be compiled. Fortunately our friends in the Polkadot ecosystem have made a lot of progress towards <a href="https://hackmd.io/@pepyakin/By7783Wo5">even more sophisticated</a> forms of gas metering, something we’re playing close attention to.</p>

<p>But this simplistic gas metering is good enough for now.</p>

<h1 id="talk">Talk<a id="talk"></a></h1>

<p>The other thing that happened this month was the EthCC conference week in Brussels. I attended and gave <a href="https://ethcc.io/archive/Athena-Rises">a talk on Athena</a>, the very first such talk (of hopefully many). I also had the opportunity to meet folks from the RiscZero team, and to meet with other RISC-V stakeholders. As expected and as I confirmed in person last week, the awareness and popularity of RISC-V is growing, especially as a better engine for blockchain programmability. I was pleasantly surprised how many people were aware of it, probably in large part due to marketing efforts on the part of RiscZero and other stakeholders. I pitched the Athena design, both the low-level VM design as well as the “<a href="https://tezos.stackexchange.com/questions/5835/rollup-qa-why-are-tezos-enshrined-rollup-better-than-ethereum-smart-contract">enshrined</a> <a href="https://www.reddit.com/r/ethereum/comments/vrx9xe/comment/if7auu7/?context=3">rollup</a>” design, to a number of smart founders and developers throughout the course of the week. I asked all of them to poke holes in the design, and none poked any very large holes, which is reassuring and validating. (The biggest questions involved how we intend to prove Athena execution in ZK. There are indeed a number of outstanding questions about this phase of Athena, but these are problems for a later day.)</p>

<p>I’ll be attending, and hopefully speaking about Athena at, Solana Breakpoint in Singapore in September, as well as Ethereum Devcon in Bangkok in November. If you intend to be at either event, let me know!</p>

<h1 id="whats-next">What’s Next<a id="whats-next"></a></h1>

<p>The rest of this month is all about finishing up those remaining host functions, then packaging up what’s been done so far as a dynamic library so go-spacemesh can use it. We’ve already done this with dependencies like <a href="https://github.com/spacemeshos/spacemesh-sdk">spacemesh-sdk</a> and <a href="https://github.com/spacemeshos/post-rs">post-rs</a>, both of which are written in Rust, and which <a href="https://github.com/spacemeshos/smcli">smcli</a> and <a href="https://github.com/spacemeshos/go-spacemesh/">go-spacemesh</a> depend on, respectively. So I don’t expect this part to take too long, although linking against foreign dependencies can <a href="https://github.com/spacemeshos/smcli/blob/develop/Makefile">sometimes be difficult</a>, especially when it comes to supporting different platforms.</p>

<p>After that, we move onto the fun work of integrating the prototype into go-spacemesh and launching it on a testnet so we can start playing with it! Back to work.</p>]]></content><author><name></name></author><category term="athena" /><category term="update" /><summary type="html"><![CDATA[We’re overdue for another Athena project update. Lots has happened over the past month. I was hoping that the current phase, Blockchain Integration, would be finished in time for this update. We’re not quite there yet, but we’re close.]]></summary></entry><entry><title type="html">June Project Update</title><link href="https://athenavm.github.io//2024/06/14/june-project-update.html" rel="alternate" type="text/html" title="June Project Update" /><published>2024-06-14T23:25:33+00:00</published><updated>2024-06-14T23:25:33+00:00</updated><id>https://athenavm.github.io//2024/06/14/june-project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/06/14/june-project-update.html"><![CDATA[<p>It’s been a while since the last Athena project update. A lot of progress has been made since then so it seems about time for another update.</p>

<h2 id="tldr">Tldr</h2>

<p>In the last update I introduced <a href="https://www.athenavm.org/athena/update/2024/05/09/project-update.html#stages">four phases</a> to the Athena project. The first phase, the initial research phase, was finished around the time the last update was published, a month ago. The second phase, the low level design and implementation phase, is <a href="https://github.com/athenavm/athena">now done</a> as well. While there were plenty of hiccups, this phase went much more quickly and smoothly than expected due to the magic of open source software (more on this below). We now have a working VM that fully implements our target instruction set, RV32IM (as well as the “EM” variant, more on this below as well). And, yes, it runs Doom (<a href="https://youtu.be/5rnGihyBPS0">almost</a>!).</p>

<p>I think it makes sense to add another phase to the Athena roadmap, the phase we’re now moving into: the integration phase. This is where the fun really begins. The VM can run programs but it doesn’t yet do anything blockchain- or Spacemesh-related. In other words, those programs can’t do interesting things like read or write account state, send coins, etc.. The next phase involves adding blockchain-specific functionality such as gas metering, host functions, and cross-contract calls. It also involves defining <a href="https://github.com/athenavm/athena/blob/45c7db1e307205ae93f780ac6ce94fd17928ac97/ffi/athcon/athcon.h">an interface</a> and “packaging up” Athena into a format that will allow go-spacemesh to interface with it (since Athena is written in Rust and go-spacemesh is written in Go).</p>

<p>At the end of this third phase, with luck, we’ll have a functional prototype blockchain VM running on a testnet and it’ll be possible to deploy and run simple smart contracts. Here’s what the overall Athena roadmap looks like and where we stand today:</p>

<ul>
  <li>
    <p>Phase 0: Initial Research (complete)</p>
  </li>
  <li>
    <p>Phase 1: VM Prototype (complete)</p>
  </li>
  <li>
    <p>Phase 2: Blockchain integration (in progress)</p>
  </li>
  <li>
    <p>Phase 3: Mechanism design</p>
  </li>
  <li>
    <p>Phase 4: Succinctness</p>
  </li>
</ul>

<p>Read on for more details on what’s been done and what comes next.</p>

<h2 id="open-source-magic">Open Source Magic</h2>

<p>As mentioned above, the second phase of Athena came together much more quickly than I anticipated. This is due to the magic of open source software and of permissionless innovation. We’re standing on the shoulders of giants, and by leaning into existing code we were able to pull together a fully-functional VM that meets our needs very quickly rather than reinventing the wheel. Two projects in particular deserve our gratitude.</p>

<p>The first is <a href="https://github.com/succinctlabs/sp1">SP1</a> from Succinct Labs. You may recall SP1 from the <a href="https://www.athenavm.org/athena/update/2024/05/09/project-update.html#whats-been-done-so-far">previous update</a> where I described it as a general-purpose, RISC-V zkVM that we intend Athena to target when we reach the ZK phase. It turns out that we were able to extract the SP1 RISC-V VM (without any of the ZK proving components) and use it as our <a href="https://github.com/athenavm/athena/tree/main/core">core VM</a>. We’re grateful for the work done by the Succinct Labs on this important public goods infrastructure, and we’re especially grateful that their code is extraordinarily clean and well structured.</p>

<p>The second is <a href="https://github.com/koute/polkavm">PolkaVM</a>, a project in the Polkadot ecosystem that shares many goals with Athena, including to build a modern, secure, performant RISC-V blockchain VM. Athena’s Rust toolchain (more below) is based on the PolkaVM Rust toolchain. (Unlike Athena, however, natively targeting ZK execution is not one of PolkaVM’s goals.)</p>

<p>It goes without saying that Athena is fully <a href="https://github.com/athenavm">open source</a> and <a href="https://github.com/athenavm/athena?tab=readme-ov-file#license">permissively licensed</a> under the same terms as these projects!</p>

<h2 id="rust-toolchain">Rust Toolchain</h2>

<p>One of our goals for Athena is to use mainline Rust so that developing an Athena application simply means developing in the Rust language that developers are already familiar with, with the tools they’re already familiar with. We want Athena code to be compatible with all existing Rust tooling, including IDEs, debuggers, profilers, and indeed the entire, powerful, mature <a href="https://llvm.org/">LLVM toolchain</a>.</p>

<p>Under the hood the Athena VM is based on the RISC-V ISA. One of the nice things about RISC-V is that it’s modular: there are <a href="https://en.wikipedia.org/wiki/RISC-V#Design">many variants</a> but the core instruction set is simple and fixed. RISC-V also offers the option of using 32 registers (the standard RV32I base) or 16 registers (RV32E, where “E” stands for “embedded”). There are multiple benefits to choosing RV32E, including the fact that it makes cross-compliation to underlying hardware easier (since most physical machines running Athena code implement amd64 which uses 16 registers). Another reason to prefer RV32E is that, in order to prove Athena execution in zero knowledge, Athena programs will need to be <a href="https://community.spacemesh.io/t/succint-proofs-of-risc-v-transactions-using-a-black-box-riscv-zkvm/416">wrapped in low-level runtime code</a> that handles things like system calls and gas metering. By using only 16 registers and reserving the rest for this runtime code, we expect the integration task to be simpler.</p>

<p>While experimental support was <a href="https://github.com/llvm/llvm-project/commit/3ac9fe69f70a2b3541266daedbaaa7dc9c007a2a">recently added</a> to LLVM (and thus to Rust, which depends on LLVM) for RV32E, this support is incomplete and, in particular, mainline Rust doesn’t yet include a <code class="language-plaintext highlighter-rouge">riscv32em</code> target. For now we therefore have no choice but to maintain <a href="https://github.com/athenavm/rustc-rv32e-toolchain">our own Rust toolchain</a> for Athena as a fork of Rust with <a href="https://github.com/athenavm/rustc-rv32e-toolchain/blob/main/patches/rust.patch">a few small patches</a> (creating this toolchain was by far the hardest part of this phase of Athena). For now, Athena users will need to download this toolchain before compiling and running Athena code, a task that is fully automated by the Athena tooling. We’re hopeful that this requirement will disappear in the fullness of time as full RISC-V support is added to Rust, and we’ll help advocate for this as well.</p>

<h2 id="try-it-out">Try It Out</h2>

<p>You can already compile and run programs on Athena (with the caveat that, as mentioned above, these programs don’t do anything blockchain-specific yet). For now it’s only guaranteed to work on Ubuntu 22.04 or newer; it may work on other UNIX and Linux variants but is untested. It wouldn’t require a lot of work to get it running on macOS; we could use <a href="https://github.com/athenavm/rustc-rv32e-toolchain/issues/4">some help</a> with this. We hope to eventually add Windows support but this will take time.</p>

<p>All you need to do is run the following commands to download and install Athena and its toolchain:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&gt; curl -L https://install.athenavm.org | bash &amp;&amp; athup
</code></pre></div></div>

<p>You can then create a barebones test application and run it with the following commands:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&gt; cargo athena new fibonacci
&gt; cd fibonacci/script
&gt; cargo run
</code></pre></div></div>

<p>Here’s what a complete, barebones Athena application looks like. <a href="https://www.athenavm.org/athena/update/2024/05/09/project-update#developer-experience">As promised</a>—it’s just Rust! You can expect to see more sophisticated examples soon as we add the blockchain-related functionality described above.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#![no_main]
athena_vm::entrypoint!(main);

pub fn main() {
    println!("Hello, world!");
}
</code></pre></div></div>

<h2 id="whats-next">What’s Next</h2>

<p>As mentioned above, the next phase is the “blockchain integration” phase where we add blockchain-specific functionality to the Athena VM. This includes things like reading and writing account state, deploying new programs/contracts, sending coins, gas metering, and cross-contract calls. It’ll also involve integrating the Athena codebase into the go-spacemesh codebase and launching a testnet that runs the new VM.</p>

<p>This phase of the design is <a href="https://community.spacemesh.io/t/athena-blockchain-design-and-integration/424">shaping up here</a>, for those who are curious to follow along or contribute. You can also follow progress on <a href="https://github.com/orgs/athenavm/projects/1/views/1">this project board</a> and <a href="https://github.com/athenavm/athena/pull/21">this pull request</a>.</p>

<h2 id="get-involved">Get Involved</h2>

<p>The Athena project lives on GitHub and there are a number of open issues tagged as <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22">Help Wanted</a> and <a href="https://github.com/athenavm/athena/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22">Good First Issue</a>. Contributions are welcome! Whether you’re an experienced Rust or VM developer, or are curious and want to learn, there’s lots you can do to help. If you’re not already on our Discord, please <a href="https://discord.gg/spacemesh">join using this link</a> and join the active conversation in the #athena-vm channel.</p>

<h2 id="ecosystem">Ecosystem</h2>

<p>To restate the obvious: Athena is first and foremost being designed and built by the Spacemesh team as the Spacemesh VM. As we <a href="https://spacemesh.io/blog/introducing-athena/">mentioned before</a>, Athena features a novel design that’s somewhere between a traditional L1 VM and a L2 rollup: a subset of Spacemesh nodes, known as Executors, are responsible for maintaining the Athena state on a day to day basis, relieving Spacemesh L1 miners of this responsibility. However, Spacemesh L1 miners are aware of Athena and, when necessary, can step in to adjudicate disputes that may arise under the optimistic design.</p>

<p>However, over the long term, we hope and expect that Athena will grow beyond the single, existing Spacemesh mainnet. In the same way that there are now dozens (if not hundreds) of production EVM-based blockchains, we’re intentionally designing and building Athena in such a way that it can be useful for lots of other projects and communities. A simple, secure, RISC-V-based VM that’s natively performant and can also natively target ZK is a powerful primitive with lots of potentially exciting use cases. We had to design Athena because, 15 years after the launch of the first blockchain, there is still no such tool today! While we like Move, for example, the language, VM, account model, and other aspects of the Move VM are tightly coupled (rather than modular) so it unfortunately <a href="https://www.athenavm.org/athena/update/2024/05/09/project-update#platform-independence">wasn’t an option</a> for Spacemesh.</p>

<p>As Athena matures and use cases beyond Spacemesh mainnet emerge, we expect this to benefit the Spacemesh project and ecosystem as well. It’ll lead to additional resources and to more developers working on Athena, which will in turn benefit Spacemesh. It’ll also mean that smart contracts and tooling developed for Spacemesh will work out of the box with other chains that adopt Athena. It’s a win-win.</p>

<p>A great example here is <a href="https://libp2p.io/">libp2p</a>, which powers our networking stack. Historically, most blockchains implemented a bespoke networking stack. We initially did the same at Spacemesh. However, over time, we began to understand the challenges associated with maintaining a bespoke stack and the benefits of adopting a global standard became clear. At the same time, libp2p matured as a project, and we saw that it made sense to adopt infrastructure that has the support of Protocol Labs, Ethereum, and <a href="https://github.com/libp2p/go-libp2p?tab=readme-ov-file#notable-users">many other projects</a>. One way to think of Athena is as the libp2p of the VM world. This is the reason Athena lives in its own <a href="https://github.com/athenavm">Github organization</a> and has its own <a href="https://www.athenavm.org/">domain name</a>: just as libp2p grew out of the IPFS and Protocol Labs ecosystem, we expect that as Athena matures it’ll grow beyond just the Spacemesh ecosystem and we want to make it as friendly as possible for other projects to adopt it and contribute to Athena.</p>]]></content><author><name></name></author><category term="athena" /><category term="update" /><summary type="html"><![CDATA[It’s been a while since the last Athena project update. A lot of progress has been made since then so it seems about time for another update.]]></summary></entry><entry><title type="html">Project Update</title><link href="https://athenavm.github.io//2024/05/09/project-update.html" rel="alternate" type="text/html" title="Project Update" /><published>2024-05-09T22:25:33+00:00</published><updated>2024-05-09T22:25:33+00:00</updated><id>https://athenavm.github.io//2024/05/09/project-update</id><content type="html" xml:base="https://athenavm.github.io//2024/05/09/project-update.html"><![CDATA[<p>It’s been a couple of months since we announced the Athena project and a month since the last update. I’ve spent the past few weeks doing research into best practices and the state of the art in blockchain VM and zkVM design, tooling, programming language design, etc. across a number of ecosystems including EVM, Move, Solana, Bitcoin, NEAR, and Cairo (I previously wrote a little bit about some of the <a href="https://rettig.substack.com/p/blockchain-devex-battle">initial experimentation</a>). I want to take the opportunity to update the community about how the Athena project is going: what has and has not changed from the goals and plans we originally announced, what’s been done, what we’re working on right now, and where we go from here.</p>

<h2 id="goals">Goals</h2>

<p>We previously shared <a href="https://spacemesh.io/blog/introducing-athena/">eight goals</a> for Athena: incentive compatibility and security, simplicity, decentralization, scalability, ZK compatibility, avoiding vendor lockin, developer experience, and developer safety. I want to zoom in on a subset of those goals that I’m especially focused on right now and discuss some of the tradeoffs among them, and to add one new goal.</p>

<h3 id="developer-experience">Developer Experience</h3>

<p>It’s difficult to measure developer experience since it’s by definition highly subjective. As one common example, some developers prefer frameworks, languages, and tools that are <a href="https://hackernoon.com/opinionated-or-not-choosing-the-right-framework-for-the-job-6x1u2ga0">highly opinionated</a> and reduce the number of decisions they make; others prefer more degrees of freedom at the cost of higher complexity and more security risks. There’s no one-size-fits-all solution for all developers, teams, and use cases. Our goal as infrastructure designers and developers is therefore to pick a reasonable compromise and to build a system that allows both kinds of experiences to be built on top, to the extent possible.</p>

<p>One such choice we have to make with Athena is whether to align ourselves more closely with a more opinionated, blockchain-specific programming language and toolchain such as EVM or Move versus aligning more closely with a non-blockchain-specific language and toolchain, the most obvious of which is Rust. There are advantages and disadvantages to each choice, but I think it makes more sense to place ourselves firmly within the Rust ecosystem, especially if we’re able to do so with mainline Rust and LLVM (as opposed to a bespoke fork of Rust like <a href="https://solana.stackexchange.com/questions/12530/whats-the-benefit-of-using-platform-tools-compared-to-rusts-upstream-bpfel-unk">other projects</a> have chosen). While languages and tooling in blockchain-specific ecosystems like EVM, Move, and Cairo have matured a lot, the reality is that they’ll never come close to the maturity and wide choices available of tooling available in a “global” developer ecosystem like Rust and LLVM, which is at least an order of magnitude greater (probably more).</p>

<p>The blockchain technical community is big and important, but it’s not as big or important as the broader universe of developers, and to appeal to and attract the largest possible number of developers we must design and deliver tools that are as familiar to developers as possible. We didn’t state so explicitly but I’ll do it now: one of the main goals for Athena is to attract millions of non-blockchain developers and we’ll be much better able to do that with Rust and LLVM than with Solidity, Move, or another bespoke programming language.</p>

<p>The plan is still for Athena smart contracts to be written in idiomatic, standard Rust, to include at least partial support for the Rust standard library, to be compiled using mainline Rust and a mainline LLVM target, and to support all existing LLVM tooling including compiler, debugger, optimizations, etc.</p>

<h3 id="performance">Performance</h3>

<p>Performance wasn’t on the original list of goals but it’s sort of implied under “scalability.” There are several dimensions to performance and ensuring that Athena is as performant as possible imposes several constraints on its design space. For one thing the target bytecode should as small as possible so that Athena programs don’t impose an undue storage burden on Spacemesh L1 miners. It should also be possible to compile programs using <a href="https://docs.rust-embedded.org/book/intro/no-std.html"><code class="language-plaintext highlighter-rouge">no-std</code></a> to product artifacts that are as small as possible.</p>

<p>Recall that Athena programs need to run in two different but related contexts: initially, during the optimistic phase, Executors will directly execute Athena programs (and Spacemesh Miners will as well in case they need to adjudicate a dispute), and later on Provers will run them through ZK circuits to generate succinct ZK proofs of faithful execution. It’s therefore important that Athena be as performant as possible in <em>both</em> execution contexts, which is a unique challenge and a unique goal of this project.</p>

<p>While it’s not possible to perfectly and completely optimize for both of these competing goals simultaneously, we still think RISC-V is an excellent choice and serves both execution paths well. RISC-V is a simple, performant, well-designed instruction set that performs well compared to alternatives including Wasm and Solana rBPF. We need to do some additional benchmarking but the reports we’ve seen from others are <a href="https://github.com/koute/polkavm/blob/master/BENCHMARKS.md">promising</a>. In particular to optimize the direct execution path, RISC-V is a good choice because the instruction set is simple, is based on an actual hardware ISA (unlike Wasm), and by carefully choosing the RISC-V subset we support (in particular, a recent “embedded” variant that uses only 16 registers) we can expect very good performance. It should be possible to compile Athena code to RISC-V bytecode, to perform some initial optimizations (a process that happens offchain), and then to store the result on chain. Executors will subsequently take this RISC-V bytecode, promote it to native code and execute it at near-native speed.</p>

<h3 id="succinctness">Succinctness</h3>

<p>But that’s not all! Today there’s not <a href="https://github.com/risc0/risc0">one</a>, not <a href="https://github.com/succinctlabs/sp1">two</a>, but in fact <a href="https://github.com/a16z/jolt">three</a> independent tools that support efficiently generating succinct proofs (i.e., ZK proofs) for vanilla RISC-V code (and others that <a href="https://github.com/NilFoundation/zkLLVM">look promising</a>). These tools are at varying degrees of maturity but they’re maturing rapidly; we’ve tested them and studied their code and believe that they’ll work well for our use case. The fact that these projects are open source, that each is designed and implemented independently and that each is based on a different circuit design is reassuring.</p>

<p>While we’re not primarily focused on succinctness or proving efficiency at this stage it’s still important to ensure that Provers will be able to efficiently generate execution proofs in the future when we begin the transition from optimistic to ZK. While there are slight differences among the precise instruction set supported by each of these tools, and in particular among their use of syscalls, we’re confident that we can design a program format that can be proven by any of these tools with minimal translation.</p>

<p>While it’s possible to prove the execution of Ethereum transactions using these tools (and they’ve produced <a href="https://github.com/risc0/zeth">proofs</a> of <a href="https://github.com/succinctlabs/sp1-reth">concept</a> to this effect), doing so is inherently inefficient since it effectively requires writing a <em>separate</em> Ethereum execution client, compiling that client to RISC-V, and then running it inside the ZK circuit (which means EVM smart contract code is running inside a VM that’s running inside a zkVM—yes, you read that correctly). This leads to one of the <strong>boldest, most novel goals of Athena: to produce smart contract program code that can be run <em>natively</em> inside a RISC-V execution circuit</strong>, i.e., without adding an extra layer of indirection. As far as we’re aware Athena is the first ever attempt to do this and it should make proving Athena execution at least two orders of magnitude faster and cheaper than doing the equivalent with EVM.</p>

<h3 id="platform-independence">Platform Independence</h3>

<p>It’s just as important to speak to the paths not taken. We took a good, long look at two ecosystems in particular: Move and Cairo. Both have a lot going for them and I have many good things to say about both. Starkware recently open sourced both the <a href="https://github.com/starkware-libs/stone-prover">current Cairo prover</a> as well as an exciting, <a href="https://github.com/starkware-libs/stwo">next-generation prover</a> based on a novel technology known as <a href="https://eprint.iacr.org/2024/278">Circle STARKs</a>. Cairo has matured rapidly from an <a href="https://perama-v.github.io/cairo/examples/first_application/">obscure domain-specific ZK language</a> to something that looks and feels a lot <a href="https://www.cairo-lang.org/cairo-v2-6-0-is-out/">like modern Rust</a>. In fact, Cairo now looks quite a bit like Move and I doubt that’s an accident. In my estimation the Move language and VM are mature and exceptionally well-designed. Move addresses many of the shortcomings of EVM. The syntax for writing smart contracts in Move is concise and intuitive. The <a href="https://move-language.github.io/move/structs-and-resources.html">resource and ownership model</a> (inspired by Rust itself) makes a lot of sense and, in particular, it means that common smart contract patterns can be expressed in code that’s an <a href="https://medium.com/@kklas/smart-contract-development-move-vs-rust-4d8f84754a8f">order of magnitude simpler</a> than, say, in Solana.</p>

<p>Unfortunately unlike Cairo Move does not currently have good ZK support and this is a big reason we’re not considering it. We looked and were unable to find any successful attempts to succinctly prove execution of Move code efficiently. And while Cairo is designed to be ZK friendly it relies on a custom circuit and a custom language and VM and we believe <a href="https://a16zcrypto.com/posts/article/faqs-on-jolts-initial-implementation/#section--8">the future is general purpose circuits</a> like those designed for RISC-V.</p>

<p>On top of these issues, platform independence and avoiding vendor lockin are big reasons to develop something new. While there are currently two dominant, well-funded projects in the Move ecosystem, support for Move is constrained to one small corner of the (already-small) blockchain ecosystem. Move also relies heavily upon <a href="https://github.com/Zellic/move-prover-examples">formal verification</a> for correct execution, expertise that our team lacks. Cairo, while it has the backing of another well-funded project, is even more obscure than Move. If either Move or Cairo were to be abandoned or replaced by their respective patrons we’d be “left holding the bag” and unable to independently maintain the necessary infrastructure.</p>

<p>By contrast, Rust, LLVM, and RISC-V are universal standards, as universal as you can get in computing. We can confidently build Athena in the Rust ecosystem and know that we won’t be left holding anyone’s bags in the future.</p>

<h3 id="compartmentalization">Compartmentalization</h3>

<p>Something quickly became obvious while doing this research: with respect to our plans and goals for Athena and the tools we’ll use to achieve them, we’re standing on the shoulders of giants in a very big way. In particular, building something like Athena even two or three years ago would’ve cost $100M and required a huge team including compiler and programming language experts, cryptographers and ZK experts, protocol designers and mechanism design experts, etc. We have some of this expertise on our team but not all of it, and Spacemesh has nowhere near that many resources at its disposal. Nevertheless Athena is achievable today due to some massive breakthroughs and advances, and thanks to wonders of open source software and research. In particular ZK technology has made enormous advances in recent years and the emergence of the abovementioned tools that allow proving RISC-V code efficiently using a general-purpose circuit is a key enabling technology. (AI tools that have helped me get up to speed on a lot of these topics also feel like a superpower and deserve our gratitude!)</p>

<p>Given these limitations it’s as important to define what Athena is <em>not</em> as what it is. Athena is <em>not</em> a novel ZK circuit design. We’re not ZK experts and we’re not hand-writing circuits for Athena; instead, we’re black-boxing this aspect of the Athena design and relying on the work of others. Nor is Athena intended to reinvent the wheel with respect to a best-in-class blockchain account and data model. Experts have spent a lot of money and done a lot of the heavy lifting for us already, and as a result the Athena design will be heavily informed and inspired by the design of projects like Move in this regard.</p>

<p>We will rely on existing code and ideas as much as possible in the design and engineering process for Athena in order to limit its complexity, and we’ll give credit where credit is due for ideas and code that we utilize!</p>

<h2 id="whats-been-done-so-far">What’s Been Done So Far</h2>

<p>The deterministic VM, programmability, embedded computing, and zero knowledge space is big, much bigger than I anticipated when I began this research. The first few weeks of research were exciting but also exhausting because every day I learned about three new tools I needed to study and the list of topics to explore kept getting longer and longer. It took a few weeks but I did finally get through the entire queue. I want to share a snapshot of what I explored, what I learned, and trends that I see.</p>

<p>In rollups, I looked at the evolving design of projects like <a href="https://taiko.xyz/">Taiko</a> which is planning to use not only RiscZero for proving but also SGX, and which is considering a <a href="https://taiko.mirror.xyz/e_5GeGGFJIrOxqvXOfzY6HmWcRjCjRyG0NQF1zbNpNQ">long list of other candidates</a>. I studied Optimism’s plan to <a href="https://github.com/ethereum-optimism/ecosystem-contributions/issues/61">use ZK proving</a> to replace its current, <a href="https://x.com/EdFelten/status/1783847133461860839">flawed</a> dispute resolution mechanism. I took a very close look at Arbitrum <a href="https://docs.arbitrum.io/stylus/stylus-gentle-introduction">Stylus</a>, which is Wasm-based, including its Rust SDK and the design that allows multiple, independent VMs to talk to one another, which is unique as far as I know. I studied how Stylus <a href="https://docs.arbitrum.io/stylus/stylus-gentle-introduction#activation">validates</a> contract code before execution.</p>

<p>In the zkVM and ZK space I looked at existing and emerging zkEVMs including the ones from zkSync, Scroll, Polygon, and EF. As mentioned I spent a lot of time looking at <a href="https://github.com/risc0/risc0/">RiscZero</a> and <a href="https://github.com/succinctlabs/sp1/">SP1</a> and at their proof-of-concept Ethereum engines, <a href="https://github.com/risc0/zeth">zeth</a> and <a href="https://github.com/succinctlabs/sp1-reth">sp1-reth</a>. I also looked into the <a href="https://blog.succinct.xyz/succinct-network/">prover</a> <a href="https://www.risczero.com/bonsai">markets</a> being <a href="https://nil.foundation/proof-market">created</a> by the same projects, which we may want to consider using when Athena upgrades to a succinct design. I’m excited about the progress being made on <a href="https://a16zcrypto.com/posts/article/introducing-lasso-and-jolt/">Lasso and Jolt</a>, and about the potential of improvements like <a href="https://vitalik.eth.limo/general/2024/04/29/binius.html">Binius</a>. I looked at a novel tool called <a href="https://www.powdr.org/">Powdr</a> for designing modular zkVMs, and attempts to do <a href="https://www.zkmove.net/">Move in ZK</a>. I studied recursive proving and techniques like batching and <a href="https://www.risczero.com/blog/continuations">continuations</a>.</p>

<p>In the VM space more generally I studied the Solana VM, the Move VM (Diem, Aptos, and Sui), the NEAR VM, the Stacks VM, and emerging projects on Bitcoin including ordinals, inscriptions, and runes. I developed, tested, and deployed code in each of these ecosystems, and in EVM, using modern tooling. I studied how each system addresses hard problems like state expiry/state rent. I explored wackier, more out-of-the-box VM designs including <a href="https://urbit.org/">Urbit</a>, which I was already familiar with, and <a href="https://ao.arweave.dev/">ao</a>, which I was not (no stone left unturned!). I studied proposed extensions to RISC-V including <a href="https://community.spacemesh.io/t/succint-proofs-of-risc-v-transactions-using-a-black-box-riscv-zkvm/416/5?u=lane">CHERI-RISC-V</a> which would provide additional memory safety guarantees. Most useful of all, I spent a lot of time understanding the prior work done on <a href="https://forum.polkadot.network/t/announcing-polkavm-a-new-risc-v-based-vm-for-smart-contracts-and-possibly-more/3811/">PolkaVM</a> in the Polkadot ecosystem: that project is about a year ahead of Athena and, while it has <a href="https://github.com/koute/polkavm?tab=readme-ov-file#design-goals">different goals</a>, it strongly validates many of the ideas proposed for Athena.</p>

<p>There are two important outcomes from all of this preliminary work. First, I can say with confidence that there’s nothing out there that ticks all of the boxes that Athena does (a developer-friendly VM based on a modern, non-domain specific programming language and toolchain that runs at near-native speeds and also natively targets an efficient zkVM). Second, I still believe that our proposed design is the best choice. In other words, I stand by everything we said in our previous <a href="https://spacemesh.io/blog/introducing-athena/">Athena announcement</a>.</p>

<h2 id="stages">Stages</h2>

<p>Athena is obviously a large, ambitious project. As I indicated at the top of this post the preliminary research phase is now complete and it’s time to start the next phase, which involves developing a proof of concept implementation. Ongoing work will proceed in four mostly independent, mostly parallelizable stages.</p>

<h3 id="low-level-design">Low Level Design</h3>

<p>Basically everything I wrote above is low level design. This includes programming language and SDK design, core architecture including word size and register count, choice of instruction set and syscall regime including IO, bytecode artifact format, compiler and linker toolchain, and how to handle cross-contract calls/the call stack. It includes precompiles. It includes the strategy for compilation, interpretation (if appropriate), and execution more generally including verification of smart contract code and gas metering. It includes benchmarking all of these things.</p>

<h3 id="high-level-design">High Level Design</h3>

<p>The high level design builds upon the low level design but also allows abstraction and “black boxing” of the low level VM. It includes the design of the account model, how code and state are stored and updated, and how they’re permissioned. This is likely to include concepts like account abstraction and resources.</p>

<h3 id="mechanism-design">Mechanism Design</h3>

<p>The mechanism design is basically the design of the rollup-like architecture that powers Athena. It includes each of the <a href="https://spacemesh.io/blog/introducing-athena/">Athena roles</a>—relay, miner, executor, prover—and the incentives and game theory that ensures that the entire system runs in a secure and efficient fashion.</p>

<h3 id="succinctness-1">Succinctness</h3>

<p>Succinctness involves the “ZK rollup” design that Athena will transition to over time. It involves questions including which proving system we use, how to parameterize the various tradeoffs involved in proving (required compute and memory, proving time, proof size), and how to handle edge cases like what happens if a proof is missing or after a reorg.</p>]]></content><author><name></name></author><category term="athena" /><category term="update" /><summary type="html"><![CDATA[It’s been a couple of months since we announced the Athena project and a month since the last update. I’ve spent the past few weeks doing research into best practices and the state of the art in blockchain VM and zkVM design, tooling, programming language design, etc. across a number of ecosystems including EVM, Move, Solana, Bitcoin, NEAR, and Cairo (I previously wrote a little bit about some of the initial experimentation). I want to take the opportunity to update the community about how the Athena project is going: what has and has not changed from the goals and plans we originally announced, what’s been done, what we’re working on right now, and where we go from here.]]></summary></entry></feed>