Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs audit #85

Merged
merged 20 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/concepts/block-building.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If your SUAPP is intended to produce blocks, be they partial or full, you'll fir
function newBuilder() internal view returns (string memory)
```

This function starts a new builder instance within a Kettle. The basic idea is that session ids (the `string` returned by the `newBuilder()` precompile) provide programmatic control when building blocks, one outcome of which is simulating transactions more efficiently. Opening a session enables you to build block iteratively, rather than having to re-run all your simulations each time you receive a new transaction or bundle.
This function starts a new builder instance within a Kettle. The basic idea is that session ids (the `string` returned by the `newBuilder()` precompile) provide programmatic control when building blocks, one outcome of which is simulating transactions more efficiently. Opening a session enables you to build blocks iteratively, rather than having to re-run all your simulations each time you receive a new transaction or bundle.

:::info

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/confidential-computation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import List from '@site/src/components/List/List.tsx';

Confidential computation enables you to handle orderflow privately and securely.

In SUAVE, we achieve this with [Kettles](/technical/specs/rigil/kettle#confidential-computation) performing compute offchain, but according to smart contracts written onchain. In this way, offchain compute is not constrained by chain consensus. The Kettles will eventually run in [TEEs](https://www.youtube.com/watch?v=ek-bu4aoh0A), which provide both enhanced privacy (no-one, not even the host OS, can see unencrypted data) and integrity (you can be sure the correct code, and only that code, is running at all times).
In SUAVE, we achieve this with [Kettles](/technical/specs/rigil/kettle#confidential-computation) performing compute offchain, but according to smart contracts written onchain. In this way, offchain compute is not constrained by chain consensus. The Kettles will eventually run in [TEEs](https://www.youtube.com/watch?v=ek-bu4aoh0A), which provide both **enhanced privacy** (no-one, not even the host OS, can see unencrypted data) and **integrity** (you can be sure the correct code, and only that code, is running at all times).

## How It Works

Expand Down
30 changes: 10 additions & 20 deletions docs/concepts/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,20 @@ keywords:
- concepts
---

import List from '@site/src/components/List/List.tsx';
import DocCardList from '@theme/DocCardList';

SUAVE gives you, an application developer, a way to:
Each of the pages in this section describes one of the ways in which SUAVE extends Solidity and gives you, a MEV application developer, unique advantages.

<List>
<DocCardList />

Define private compute
In brief, SUAVE enables you to:

Store private data
- 🛠 Build blocks on other chains

Build blocks on other chains
- 🧑‍💻 Define private compute

<div>
- 🕵️‍♀️ Store private data

Interface with many different MEV components, meaning that you can

<List>

Plug into existing MEV infra: i.e sending bundles to block builders, relays, validators or sequencers

Build totally new MEV infra: i.e. create unique SUAPPs on SUAVE

</List>

</div>

</List>
- 🧩 Interface with many different MEV components, meaning that you can
- ⚡ Plug into existing MEV infra: i.e sending bundles to block builders, relays, validators or sequencers
- 🤖 Build totally new MEV infra: i.e. create unique SUAPPs on SUAVE
2 changes: 1 addition & 1 deletion docs/resources/forge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In order to make interacting with these precompiles easier, we maintain a reposi
The easiest way to start creating your own contracts with Forge is to clone the [Suapp Examples repo](https://github.com/flashbots/suapp-examples/), as it comes with `suave-std` already set up as a submodule, as well as a series of examples that use both Forge and the Golang SDK.

```bash
git clone [email protected]:flashbots/suave-std.git && cd suapp-examples
git clone [email protected]:flashbots/suapp-examples.git && cd suapp-examples
```

```bash
Expand Down
8 changes: 5 additions & 3 deletions docs/tutorials/build-suapps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ cd src/ && bun link

1. Confidential Compute Requests on SUAVE do not work with wallets that implement the EIP-1193 Javascript API. Therefore, we use the unsafe `eth_sign` method to sign CCRs, which does work, but requires that you enable this functionality in wallets like MetaMask.
1. To do so in MetaMask, go to "Settings" -> "Advanced" -> scroll to bottom -> switch Eth_sign requests on.
2. Both templates assume that you are running SUAVE locally.
3. No tests are included for the contracts, as it is not trivial to test new precompiles and different transaction types (i.e. CCRs) in `forge` at this time.
2. Both templates below assume that you are running SUAVE locally.
3. No tests are included for the contracts at this time.

## Typescript Template

Expand Down Expand Up @@ -72,7 +72,9 @@ This template uses the same MEV-Share example contract we worked with using the

## Next Template

This template comes with a more extensive frontend framework, which uses Next (in typescript) and therefore depends on React. You can get it running by first cloning the repo and installing its dependencies. Make sure you have previously built and symlinked suave-viem for this to work:
This template comes with a more extensive frontend framework, which uses Next (in typescript) and therefore depends on React. You can get it running by first cloning the repo and installing its dependencies.

Make sure you have previously built and symlinked suave-viem for this to work:

```bash
git clone [email protected]:andytudhope/build-a-suapp-next-ts.git \
Expand Down
8 changes: 5 additions & 3 deletions docs/tutorials/confidential-compute-requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ The [Typescript template](https://github.com/flashbots/suave-viem/tree/main/exam

In this case, we need to:

1. Craft a transaction on your chosen domain and sign it.
1. Craft a transaction on Goerli and sign it.
2. Append relevant details like the `decryptionCondition`, `kettleAddress`, `contract` and `chainId`.
3. Use a helper function like `toConfidentialRequest` to (i) place our signed transaction in `confidentialInputs` and (ii) replace the `data` field with a call to the appropriate method in the specified SUAVE contract.
3. Use a helper function like `toConfidentialRequest` to
1. place our signed transaction in `confidentialInputs` and
2. replace the `data` field with a call to the appropriate method in the specified SUAVE contract.

The [code which achieves this can be found here](https://github.com/flashbots/suave-viem/blob/main/examples/suave-web-demo/src/suave.ts) and looks like this:

Expand Down Expand Up @@ -187,7 +189,7 @@ The [**SUAPP Examples repo**](https://github.com/flashbots/suapp-examples) uses

:::

In particular, we can look at the [private order-flow auction example](https://github.com/flashbots/suapp-examples/blob/main/examples/app-ofa-private/main.go) to understand how to use the Golang SDK to craft more complex kinds of CCRs.
Let's look at the [private order-flow auction example](https://github.com/flashbots/suapp-examples/blob/main/examples/app-ofa-private/main.go) to understand how to use the Golang SDK to craft more complex kinds of CCRs.

The flow of this example is similar to the Typescript MEVShare demo directly above. However, we'll use it to demonstrate a full e2e flow with CCRs:

Expand Down
56 changes: 22 additions & 34 deletions docs/tutorials/deploy-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Transaction hash: 0x9ae80af40bdafbc706108446dbbf7761a59f5bf544b46c97b9b0851dddaa

### Locally

You can follow the exact same method as above to deploy contracts to your local SUAVE devnet. You just need to have SUAVE running and use the pre-funded account we have setup for you:
You can follow the exact same method as above to deploy contracts to your local SUAVE devnet. You need to [have SUAVE running](/tutorials/run-suave) and use the pre-funded account we have setup for you:

```bash
forge create --rpc-url http://localhost:8545 --legacy \
Expand All @@ -81,25 +81,6 @@ Deployed to: 0xcbdF0322Cd79212e10b0dB72D775aE05B99c1796
Transaction hash: 0x9ae80af40bdafbc706108446dbbf7761a59f5bf544b46c97b9b0851dddaa3927
```

## Deploy with Remix

:::warning

This method is quick, but limited. You can deploy contracts using Remix and an injected web3 provider. However, you cannot send Confidential Compute Requests to those contracts from providers like MetaMask, so it is difficult to interact with your contracts once deployed.

:::

Follow these steps to deploy a contract via Remix:

1. Add the Rigil RPC to your MetaMask or equivalent wallet and connect to it:

<RPCButton />

2. Ensure you have rETH from the [Rigil ETH Faucet](https://faucet.rigil.suave.flashbots.net)
3. Go to the [Remix IDE](http://remix.ethereum.org/) and navigate to the bottom icon on the right-hand menu: "Deploy and Run Transactions".
4. Open the dropdown "Environment" menu and select "Injected Provider - MetaMask". It should show `Custom (16813125) network` directly below that field if this works correctly.
5. Write (or import) your contracts in the File Explorer tab, compile them, and deploy them as you usually would.

## SUAPP Examples

First, clone and set up the [SUAPP examples repo](https://github.com/flashbots/suapp-examples/):
Expand All @@ -120,23 +101,11 @@ You can compile the contracts in the repo with:
forge build
```

<details>
<summary>What is Forge?</summary>
<div>
<div>
<div>
`forge` is a part of the smart contract development toolchain we use in our examples, which you can learn more about in our [next tutorial](/tutorials/deploy-contracts). If you do not have it installed, you can do so quickly with:
<pre>curl -L https://foundry.paradigm.xyz | bash</pre>
</div>
</div>
</div>
</details>

### Locally

Now we can deploy and transact with any of the example contracts.

The `framework/framework.go` file defaults to your [local SUAVE devnet](/tutorials/run-suave). If you have that running, just `cd` into the relevant directory and run the `main.go` file. For instance, to deploy and transact with the example contract which demonstrates how updating state works for normal vs confidential requests, you can run:
Once you have [SUAVE running locally](/tutorials/run-suave), `cd` into the relevant directory and run the `main.go` file. For instance, to deploy and transact with the example contract which demonstrates how updating state works for normal vs confidential requests, you can run:

```bash
cd examples/onchain-state && go run main.go
Expand All @@ -149,7 +118,7 @@ You should see this message printed in your terminal if successful:
2. Send a confidential request that modifies the state
```

The `framework.go` and all of the `main.go` files use the Golang SDK, which you can read more about in our [developer guides](/resources/golang-sdk).
The `framework.go` and all of the `main.go` files use the Golang SDK, which you can read more about in our [resources section](/resources/golang-sdk).

### To Rigil

Expand Down Expand Up @@ -178,3 +147,22 @@ You should again see output like this logged in your terminal:
1. Send a confidential request that cannot modify the state
2. Send a confidential request that modifies the state
```

## Deploy with Remix

:::warning

This method is quick, but limited. You can deploy contracts using Remix and an injected web3 provider. However, you cannot send Confidential Compute Requests to those contracts from providers like MetaMask, so it is difficult to interact with your contracts once deployed.

:::

Follow these steps to deploy a contract via Remix:

1. Add the Rigil RPC to your MetaMask or equivalent wallet and connect to it:

<RPCButton />

2. Ensure you have rETH from the [Rigil ETH Faucet](https://faucet.rigil.suave.flashbots.net)
3. Go to the [Remix IDE](http://remix.ethereum.org/) and navigate to the bottom icon on the right-hand menu: "Deploy and Run Transactions".
4. Open the dropdown "Environment" menu and select "Injected Provider - MetaMask". It should show `Custom (16813125) network` directly below that field if this works correctly.
5. Write (or import) your contracts in the File Explorer tab, compile them, and deploy them as you usually would.
16 changes: 7 additions & 9 deletions docs/tutorials/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ keywords:

import DocCardList from '@theme/DocCardList';

SUAVE is focused on delivering credible, confidential computation that enables you to build better mechanisms.
:::info

SUAVE is focused on delivering credible, confidential computation that enables you to build better mechanisms. SUAVE enables anyone to build and deploy MEV applications, on a decentralized network, which were not possible until today.

:::

## What can I do with SUAVE?

1. **Deploy more expressive smart contracts.**

- Contracts on SUAVE follow the same rules as on Ethereum, with the added advantage of being able to access additional precompiles available to serve any MEV application. We call this "builder solidity".
- Contracts on SUAVE follow the same rules as on Ethereum, with the added advantage of being able to access additional precompiles available to serve any SUAPP.

2. **Compute confidentially**.
- Builder solidity lets you request confidential computation, where your transaction data is encrypted to specific actors. Public contracts with verifiable logic, combined with confidential data, means that SUAVE can be seen as an open marketplace for mechanisms we can all inspect, collaborate on, and compete with to produce the most efficient MEV applications, while nevertheless protecting everyone's privacy.

:::info

SUAVE enables anyone to build and deploy MEV applications, on a decentralized network, which were not possible until today.

:::
- Public contracts with verifiable logic, combined with confidential data, means that SUAVE can be seen as an open marketplace for mechanisms we can all inspect, collaborate on, and compete with to produce the most efficient MEV applications, while nevertheless protecting everyone's privacy.

## In this section

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/run-suave.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ make suave
Now you have a `suave` binary in `./build/bin/`:

```bash
./build/bin/suave --version
./build/bin/suave-geth --version
```

Start the local devnet with:

```bash
./build/bin/suave --suave.dev
./build/bin/suave-geth --suave.dev
```

<details>
Expand Down
18 changes: 5 additions & 13 deletions docs/tutorials/suave-standard-library.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ keywords:
- solidity
---

import List from '@site/src/components/List/List.tsx';

[suave-std](https://github.com/flashbots/suave-std) is a collection of Solidity contracts and libraries to help you create Suapps. It is included as a submodule in the [SUAPP Examples](https://github.com/flashbots/suapp-examples/) repo, which we used in the previous tutorial.

In this tutorial, we will be diving deeper into the different capabilities offered by `suave-std`.
Expand All @@ -20,21 +18,15 @@ In this tutorial, we will be diving deeper into the different capabilities offer

:::

The core functionalities that `suave-std` will help you handle include:

<List>

transaction parsing and construction

JSON object decoding and encoding

convenience wrapper around precompiles
Some functionalities that `suave-std` will help you handle include:

</List>
- 💱 Transaction parsing and construction
- 🔧 JSON object decoding and encoding
- ♾️ A wrapper for all the precompiles to make calling any of them more convenient

## Transactions

One such example of this is encoding and decoding transactions from other chains, which you may need to do when matching different transactions in an order flow auction, or turning bundles into (partial) blocks in a block building contract, or weaving together different transactions on different chains for your unique use case.
Encoding and decoding transactions from other chains is often necessary when matching different transactions in an order flow auction, or turning bundles into (partial) blocks in a block building contract, or weaving together different transactions on different chains for your unique use case.

Having to encode and decode such transactions is a pain, which is exactly the sort of scenario where `suave-std` can help:

Expand Down
Loading