Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TEE with Multi-Chain Support

This test is meant to prove how a VOID App can source its events from multiple blockchains. This is done through the Node, which is configured to observe events from two separate EVM chains. In production, every component of this test would run inside a TEE, including the Node itself, along with the clients for the EVM chains being observed. The Node, inside the TEE, produces attestations that are then trusted on-chain when performing withdrawals out of the App.

Test Explanation

The test scenario consists of two users interacting with the App. User1 first deposits some of TokenA (the native chain asset) and TokenB (a standard ERC-20 token) into the App from Chain1. User2 then deposits some of only TokenA from Chain2. User1 then adds liquidity to an AMM pool consisting of the two tokens.

The main body of the test consists of User2 using the AMM pool to swap TokenA for TokenB, submitting their swap transactions on Chain2. After a couple of swaps, User2 then continues to withdraw a little bit of both TokenA and TokenB on Chain1. User2 is able to finalize their withdrawal by submitting a proof to Chain1 which then releases the tokens. The proof consists of a Merkle proof demonstrating the withdrawal occurred, along with an ECDSA signature from the oracle running with the Node. In production, the Node and oracle would be running in a TEE to maintain security. This swap and withdrawal process is then repeated 10 times.

Finally, to cover all capabilities of the App, the final action is User1 removing all their liquidity, submitting their transaction on Chain1.

Things to Note

  • The cost of making a transaction for the VOID App is very cheap (around 28,000 gas no matter how complex the transaction)
    • 4x cheaper than a typical on-chain swap (est. 110,000 gas)
    • 5x cheaper than a typical on-chain NFT sale (est. 140,000 gas)
  • The cost of withdrawing is more expensive because it requires two transactions but is still relatively inexpensive
    • Around 36,000 gas to submit the withdrawal
    • Another 105,000 gas to finalize the withdrawal

Run the Test

1) Setup

Before running the test, make sure your machine is set up and ready to go. Refer to the Setup Guide for how to set everything up with dependencies, etc.

2) Start the EVMs

The first thing to do is start two local EVM chains that will hold the VOID App contracts and where users will submit their transactions. Run the following script twice to start up two local EVM chains and deploy copies of the contracts to each.

sh ./run-evm.sh
sh ./run-evm.sh

3) Start the Node

Next, we need to start the App Node. This Node will observe App transactions being submitted on both EVM chains and compute the resulting state of the App. Users use this node to get information about the state of the App in real-time. To start the Node, run the following script.

sh ./run-node.sh

4) Run the Test

We now have everything we need to simulate users making transactions and interacting with the VOID App. Run the test with the following script.

sh ./e2e-test.sh