ERC-7694 Solana Storage Router
Draft · Other · created 2024-04-18
A standard that lets an Ethereum contract offload data-storage operations to the Solana blockchain and read the stored values back through a gateway.
Why it is needed
Storing data directly on Ethereum is expensive. For this reason, the existing standard, the Cross-Chain Storage Router Protocol (CCIP-Store, EIP-7700), defines three paths for offloading storage operations: other Ethereum L1 contracts, L2s, and external databases. However, these storage locations retain centralizing factors. For L2s, sharing security with the Ethereum mainnet acts as a centralizing catalyst, and for databases, the physical servers running them are themselves a point of centralization. There was no standardized way to delegate storage to an independent blockchain with its own consensus structure. Also, chain-agnostic Ethereum protocols like ENS that support Solana users had no defined procedure for using Solana's own storage space even if they wanted to. This standard fills that gap by adding Solana as a fourth storage router, letting Ethereum make use of a broader range of off-chain block space.
In depth
The fourth router of EIP-7700
CCIP-Store (EIP-7700) defines three external routers that send storage to L1 contracts, L2s, and databases. This standard adds a fourth router that uses Solana as a storage provider. The motivation is that, since L2s carry shared security with the Ethereum mainnet and databases carry their hosting server as centralizing catalysts, a storage provider that relies on its own independent consensus structure is preferable. Solana is cited as a low-cost L1 supported alongside Ethereum by multiple wallet providers, and chain-agnostic protocols like ENS are presented as an example of supporting Solana users while using Solana's own storage space.
Structure of the StorageRoutedToSolana revert
The router requires two bytes32 values. programId is the program address corresponding to a contract address on Solana, and account is the manager wallet that handles storage on Solana on behalf of msg.sender. Both are passed as hex encodings. The contract obtains this metadata through arbitrary on-chain code (such as getMetadata), then routes the call with revert StorageRoutedToSolana(programId, account). Per the Rationale, the mechanism is similar to CCIP-Store's StorageRoutedToL2(), sharing the idea of using a revert event to direct the client to a specific contract on another chain; the technical difference is only the type casting between EVM and SVM.
The client's write-handling procedure
Because Solana's virtual machine uses base58 encoding by default, a programId encoded in hex on the EVM must be decoded to base58 before being used on the SVM. A client implementing the router must, using the Solana wallet linked to account, base58-decode the originally received call data, convert it to the appropriate type, and then call the Solana programId. In the pseudocode, program.setValue is called only when wallet.publicKey matches account, with a note that only an authorized manager should be allowed to call it on the Solana program.
Table of type casting between EVM and SVM
Because the two virtual machines have different architectures, the standard requires bijective type casting. uint8 through uint128 map to u8, u16, u32, u64, u128; bytes1 through bytes16 map to fixed-length u8 arrays; bytes maps to Vec<u8>; string maps to String; and address maps to [u8; 20]. The key mapping is bytes32 to PubKey. There is a footnote that u256, which corresponds to uint256, is not provided natively by the SVM but is commonly implemented via Rust's u256 crate. The original text explains that this strategy handles most current use cases of StorageRoutedToSolana().
Reads via an EIP-3668 gateway
For an Ethereum contract to read data stored on Solana, an HTTP gateway compliant with EIP-3668 must translate it back into EVM format. The arguments passed in the gateway URL call follow the slash (/) delimited nested format defined in EIP-7700, with an example path of /<programId>/<node>/<key>/. The gateway converts the values parsed from the path into a PubKey and calls getValue on the Solana program; if a value exists it returns it as EVM bytes32, and if not (NOT_FOUND) it writes 0x0. The result is packed with abi.encode(["bytes"], [value]) and exported in data: format.
Requirements on the Solana program side
The example setValue function verifies the program ID and rent-exempt status, deserializes the data, updates it, then re-serializes and stores it in the account. The stored data must be mapped by node and account. The read-side getValue function verifies that the account belongs to the correct program ID, deserializes the account data, looks up the value by node and key, and returns it; if no value exists it raises a ProgramError::InvalidArgument error. The backward compatibility and security considerations sections are both listed as None.
A Proposal in Draft Stage
This document is a proposal in Draft status, created on April 18, 2024, and it presupposes EIP-3668 and EIP-7700. Since the content may still change, it is advisable to check the latest source text before implementing.