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

Adds necessary changes after #128 in suave-geth #77

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 assets/OFA-example-flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions specs/rigil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ If we consider a specific use case, like an order flow auction, the high-level s

![OFA example flow](/assets/OFA-example-flow.svg)

1. The user sends a Confidential Compute Request interacting with a SUAPP by calling its `newBid` function. Included in this request is also the user's L1 transaction as a confidential Input.
2. The Kettle will receive the transaction and process it. To do so it first runs the offchain logic associated with `newBid` which will extract the transaction's data and then return a callback:
1. The user sends a Confidential Compute Request interacting with a SUAPP by calling its `newTransaction` function. Included in this request is also the user's L1 transaction as a confidential Input.
2. The Kettle will receive the transaction and process it. To do so it first runs the offchain logic associated with `newTransaction` which will extract the transaction's data and then return a callback:
```go
return bytes.concat(this.emitHint.selector, abi.encode(hint));
return bytes.concat(this.emitDataRecord.selector, abi.encode(dataRecord));
```
which points to another function:
```go
function emitHint(Suave.Bid calldata bid, bytes memory hint) public {
emit HintEvent(bid.id, hint);
function emitDataRecord(Suave.DataRecord calldata dataRecord) public {
emit DataRecordEvent(dataRecord.id, dataRecord.decryptionCondition, dataRecord.allowedPeekers);
}
```
3. The callback is inserted into the calldata of a SUAVE transaction and then shipped off to the SUAVE mempool.
4. The transaction will get picked up, inserted in a SUAVE block, and propagated to SUAVE Kettles.
5. From here a searcher monitoring the chain and this specific OFA will see the log emitted and begin processing.
6. Once the searcher has a backrun crafted for the opportunity it will send it to the Kettle as a Confidential Compute Request with the backrun transaction in the confidential inputs.
7. The Kettle will receive and process the searcher's Confidential Compute Request based on the contracts logic. In this case, it will:
- Grab referenced User Transaction to be placed behind
7. The Kettle will receive and process the searcher's Confidential Compute Request based on the contract's logic. In this case, it will:
- Grab the referenced User Transaction to be placed behind
- Construct a bundle object with the two transactions
- Submit to domain-specific service for simulation and validation
8. From there, in this example, the MEVM will then forward the bundle to pre-configured off-SUAVE block builders, but could as easily also forward to onchain block builders.
Expand Down
11 changes: 5 additions & 6 deletions specs/rigil/confidential-data-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ type ConfidentialStoreEngine struct {
`ConfidentialStorageBackend` is the interface that a storage backend for the Confidential Storage Engine must implement.

```go

type ConfidentialStorageBackend interface {
InitializeBid(bid suave.Bid) error
Store(bid suave.Bid, caller common.Address, key string, value []byte) (suave.Bid, error)
Retrieve(bid suave.Bid, caller common.Address, key string) ([]byte, error)
FetchBidById(suave.BidId) (suave.Bid, error)
FetchBidsByProtocolAndBlock(blockNumber uint64, namespace string) []suave.Bid
InitRecord(record suave.DataRecord) error
Store(record suave.DataRecord, caller common.Address, key string, value []byte) (suave.DataRecord, error)
Retrieve(record suave.DataRecord, caller common.Address, key string) ([]byte, error)
FetchRecordByID(suave.DataId) (suave.DataRecord, error)
FetchRecordsByProtocolAndBlock(blockNumber uint64, namespace string) []suave.DataRecord
Stop() error
}
```
Expand Down
15 changes: 8 additions & 7 deletions specs/rigil/mevm.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ type SuaveExecutionBackend struct {
For more information on the capabilities exposed by the Confidential Data Store, see its related [🔗 spec](./confidential-data-store.md). The interface exposed to precompiles:

```go
type ConfidentialStore interface {
InitializeBid(bid types.Bid) (types.Bid, error)
Store(bidId suave.BidId, caller common.Address, key string, value []byte) (suave.Bid, error)
Retrieve(bid types.BidId, caller common.Address, key string) ([]byte, error)
FetchBidById(suave.BidId) (suave.Bid, error)
FetchBidsByProtocolAndBlock(blockNumber uint64, namespace string) []suave.Bid
type ConfidentialStorageBackend interface {
InitRecord(record suave.DataRecord) error
Store(record suave.DataRecord, caller common.Address, key string, value []byte) (suave.DataRecord, error)
Retrieve(record suave.DataRecord, caller common.Address, key string) ([]byte, error)
FetchRecordByID(suave.DataId) (suave.DataRecord, error)
FetchRecordsByProtocolAndBlock(blockNumber uint64, namespace string) []suave.DataRecord
Stop() error
}
```

Expand Down Expand Up @@ -111,7 +112,7 @@ Domain specific services which seek to be used by SUAVE must implement the metho
1. **Universal Access**: If a `ConfidentialComputeRequest` allows "any peeker", the function searches the `CallerStack` for a caller different from the precompile, granting access upon finding one.

2. **Restricted Access and Validation**:
- The function checks if the precompile is explicitly authorized to access bid data.
- The function checks if the precompile is explicitly authorized to access the data record.
- It then validates each caller in the `CallerStack` against the `AllowedPeekers` list. If an authorized caller is found, access is granted.

3. **Error Handling**:
Expand Down
26 changes: 12 additions & 14 deletions specs/rigil/precompiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ custom_edit_url: "https://github.com/flashbots/suave-specs/edit/main/specs/rigil
- [`ConfidentialInputs`](#confidentialinputs)
- [`ConfidentialStore`](#confidentialstore)
- [`ConfidentialRetrieve`](#confidentialretrieve)
- [`NewBid`](#newbid)
- [`FetchBids`](#fetchbids)
- [`NewDataRecord`](#newdatarecord)
- [`FetchDataRecords`](#fetchdatarecords)
- [`EthCall`](#ethcall)
- [`SimulateBundle`](#simulatebundle)
- [`ExtractHint`](#extracthint)
Expand Down Expand Up @@ -82,7 +82,7 @@ Address: `0x0000000000000000000000000000000042020000`
Handles the storage of data in the confidential store. Requires the caller to be part of the `AllowedPeekers` for the associated bid.

```solidity
function confidentialStore(BidId bidId, string memory key, bytes memory data1) internal view
function confidentialStore(DataId dataId, string memory key, bytes memory data1) internal view
```

### `ConfidentialRetrieve`
Expand All @@ -94,33 +94,31 @@ Address: `0x0000000000000000000000000000000042020001`
Retrieves data from the confidential store. Also mandates the caller's presence in the `AllowedPeekers` list.

```solidity
function confidentialRetrieve(BidId bidId, string memory key) internal view returns (bytes memory)
function confidentialRetrieve(DataId dataId, string memory key) internal view returns (bytes memory)
```

### `NewBid`
### `NewDataRecord`

[🔗 Implementation](https://github.com/flashbots/suave-geth/blob/b328d64689930a40eae0a6e834805f3feab6b58f/core/vm/contracts_suave.go#L237)

Address: `0x0000000000000000000000000000000042030000`

Initializes bids within the ConfidentialStore. `AllowedPeekers` specifies which addresses can "get" data. `AllowedStores` specifies which addresses can "set" data. Prior to storing data, all bids should undergo initialization via this precompile.
Initializes data records within the ConfidentialStore. `AllowedPeekers` specifies which addresses can "get" data. `AllowedStores` specifies which addresses can "set" data. Prior to storing data, all bids should undergo initialization via this precompile.

```solidity
function newBid(uint64 decryptionCondition, address[] memory allowedPeekers, address[] memory allowedStores, string memory bidType)
function newDataRecord(uint64 decryptionCondition, address[] memory allowedPeekers, address[] memory allowedStores, string memory dataType)
```

*Note: The name "Bid" is an artefact from early development. Bids represent a "Data Identifier" used when operating on confidential data and no longer have any relation to a bid in an auction. They are useful for coordinating confidential data without revealing it. For instance, a SUAVE transaction can emit logs on chain which reference the `bidId` from a Confidential Compute Request which future transactions can reference.*

### `FetchBids`
### `FetchDataRecords`

[🔗 Implementation](https://github.com/flashbots/suave-geth/blob/b328d64689930a40eae0a6e834805f3feab6b58f/core/vm/contracts_suave.go#L291)

Address: `0x0000000000000000000000000000000042030001`

Retrieves all bids correlating with a specified decryption condition.
Retrieves all data records correlating with a specified decryption condition.

```solidity
function fetchBids(uint64 cond, string memory namespace) internal view returns (Bid[] memory)
function fetchDataRecords(uint64 cond, string memory namespace) internal view returns (DataRecord[] memory)
```

### `EthCall`
Expand Down Expand Up @@ -181,7 +179,7 @@ Address: `0x0000000000000000000000000000000043200001`
Joins the user's transaction and with the backrun, and returns encoded mev-share bundle. The bundle is ready to be sent via `SubmitBundleJsonRPC`.

```solidity
function fillMevShareBundle(BidId bidId) internal view returns (bytes memory)
function fillMevShareBundle(DataId dataId) internal view returns (bytes memory)
```

### `BuildEthBlock`
Expand All @@ -193,7 +191,7 @@ Address: `0x0000000000000000000000000000000042100001`
Constructs an Ethereum block based on the provided `bidIds`. The construction follows the order of `bidId`s are given .

```solidity
function buildEthBlock(BuildBlockArgs memory blockArgs, BidId bidId, string memory namespace)
function buildEthBlock(BuildBlockArgs memory blockArgs, DataId dataId, string memory namespace)
```

### `SubmitEthBlockBidToRelay`
Expand Down