EIPs Explained

ERC-7694 · Draft · ERC · 2024-04-18

ERC-7694: Solana Storage Router

Adds a Solana target to the CCIP-Store storage router, so an Ethereum contract can tell clients to write data to a Solana program and later read it back through a CCIP-Read gateway.

What problem does it solve?

Storing data on Ethereum L1 is expensive. EIP-7700 (CCIP-Store) defines "storage routers": a contract reverts with a special error telling the client to write the data somewhere else, such as an L2 or an off-chain database. Reading it back uses EIP-3668 (CCIP-Read).

The authors argue that L2s and databases both have centralizing elements, and that a chain with its own independent consensus is an attractive alternative. ERC-7694 adds a fourth router pointing at Solana, so chain-agnostic protocols (ENS is the example given) can use Solana blockspace for storage.

How it works

Writing. Instead of storing a value, the Ethereum contract reverts with:

error StorageRoutedToSolana(bytes32 programId, bytes32 account);
  • programId: the Solana program (contract) address, hex-encoded.
  • account: the Solana manager wallet that is allowed to write on behalf of the user.

A client that understands this error converts the arguments to Solana types and sends the same call to the Solana program using a Solana wallet connected as account. The Solana program stores the data keyed by node and account.

Type mapping. The spec fixes a bijective mapping between EVM and SVM types, for example uint64 ↔ u64, bytes32 ↔ PubKey, bytes ↔ Vec<u8>, string ↔ String, address ↔ [u8; 20]. uint256 maps to a u256 that Solana programs typically implement via a Rust crate. Since Solana uses base58, hex bytes32 values are converted accordingly.

Reading. An Ethereum contract cannot query Solana directly, so an EIP-3668-compliant HTTP gateway reads the Solana program, converts the result back to EVM types, ABI-encodes it and returns it through the usual CCIP-Read OffchainLookup flow. Gateway URL arguments follow the /-delimited format from EIP-7700.

Sample code

A contract routing a write to Solana:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract SolanaRoutedRecords {
    error StorageRoutedToSolana(bytes32 programId, bytes32 account);

    mapping(bytes32 => bytes32) public solanaProgram;
    mapping(bytes32 => bytes32) public solanaManager;

    function setValue(bytes32 node, bytes32 key, bytes32 value) external {
        // Clients that support ERC-7694 catch this revert and replay
        // setValue(node, key, value) on the Solana program instead.
        revert StorageRoutedToSolana(solanaProgram[node], solanaManager[node]);
    }
}

Client side (pseudocode):

try { await contract.setValue(node, key, value); }
catch (e) {
  const { programId, account } = decodeStorageRoutedToSolana(e);
  // convert bytes32 -> PubKey, then call program.setValue(node, key, value)
  // with a Solana wallet whose public key equals `account`
}

Things to know

  • Status: Draft, and it depends on EIP-7700, which is also a Draft.
  • Clients must support both Ethereum and Solana wallets; a plain Ethereum wallet cannot complete the write.
  • Reads trust the HTTP gateway to translate Solana data faithfully, unless the application adds its own verification.
  • The spec's Security Considerations section is empty ("None"), so integrators should do their own review of gateway trust and manager-account authorization.
  • The earlier ERC-5559 (write deferral, Stagnant) explored the same revert-and-redirect pattern.

#cross-chain #solana #ccip #storage #ens

Details

Authors
Avneet Singh (@sshmatrix), 0xc0de4c0ffee (@0xc0de4c0ffee)
Status
Draft
Type
Standards Track / ERC
Created
2024-04-18
Requires

Machine-readable: Markdown · JSON