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

Add ERC: Solana Storage Router #390

Merged
merged 64 commits into from
Nov 29, 2024
Merged
Changes from 6 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
73138f9
SolanaHandler: INIT
sshmatrix Apr 18, 2024
728186f
SolanaHandler: add explanation for account manager
sshmatrix Apr 18, 2024
70aa6f2
SolanaHandler: include datatype casting
sshmatrix Apr 18, 2024
b465a2f
SolanaHandler: add EIP number 7694
sshmatrix Apr 18, 2024
4e3a8f7
ERC-7694: Fix date
sshmatrix Apr 18, 2024
5688039
ERC-7694: Fix typo in EIP-5559 link
sshmatrix Apr 18, 2024
7a09d42
ERC-7694: Fix link to discussion
sshmatrix Apr 19, 2024
7113ddc
Language modification by reviewer
sshmatrix Apr 22, 2024
16b54a8
ERC-7694: Fix link to EIP-7700 draft
sshmatrix Apr 30, 2024
08f776a
ERC-7694: Complete list of type casting
sshmatrix May 3, 2024
a657d1a
ERC-7694: Update link to discussions
sshmatrix May 3, 2024
473c210
ERC-7694: Add flow chart
sshmatrix May 3, 2024
316c982
ERC-7694: Introduce CCIP-Store for readability and ease-of-reference
sshmatrix May 23, 2024
076cdfb
Merge branch 'master' into solanaHandler
sshmatrix May 23, 2024
c833eb4
Merge branch 'master' into solanaHandler
sshmatrix May 31, 2024
ae884aa
Merge branch 'master' into solanaHandler
sshmatrix Jun 12, 2024
a57b545
ERC-7694: SVG image and some of the requested changes
sshmatrix Jun 12, 2024
a96dc55
ERC-7694: Dark-theme compatible SVG
sshmatrix Jun 12, 2024
7da1bca
Merge branch 'master' into solanaHandler
sshmatrix Jun 17, 2024
008e6b2
ERC-7694: Fix abstract
sshmatrix Jun 17, 2024
b16c284
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Jun 17, 2024
b717642
Merge branch 'master' into solanaHandler
sshmatrix Jun 18, 2024
00afbec
ERC-7694: Better abstract language
sshmatrix Jun 18, 2024
4702210
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Jun 18, 2024
046c93b
Merge branch 'master' into solanaHandler
sshmatrix Jun 18, 2024
8bd1578
ERC-7694: SVG tuned to ethereum.org's dark theme
sshmatrix Jun 18, 2024
65b7354
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Jun 18, 2024
a48c61a
Merge branch 'master' into solanaHandler
sshmatrix Jun 19, 2024
a6c84e8
Merge branch 'master' into solanaHandler
sshmatrix Jun 19, 2024
9ef5b43
Merge branch 'master' into solanaHandler
sshmatrix Jun 20, 2024
77a9ba3
ERC-7694: Add Schema.svg for Solana
sshmatrix Jun 20, 2024
70c79df
ERC-7694: Add Schema.svg to text
sshmatrix Jun 20, 2024
eb24ea6
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Jun 20, 2024
8e14c00
Merge branch 'master' into solanaHandler
sshmatrix Jun 20, 2024
d7adefa
Merge branch 'master' into solanaHandler
sshmatrix Jun 20, 2024
580e6e1
Merge branch 'master' into solanaHandler
sshmatrix Jun 22, 2024
114a689
Merge branch 'master' into solanaHandler
sshmatrix Jun 24, 2024
a673ec6
Merge branch 'master' into solanaHandler
sshmatrix Jul 6, 2024
272bf7d
Merge branch 'master' into solanaHandler
sshmatrix Jul 8, 2024
f45cc07
Merge branch 'master' into solanaHandler
sshmatrix Jul 10, 2024
0af71d6
Merge branch 'master' into solanaHandler
sshmatrix Aug 1, 2024
bd87782
Merge branch 'master' into solanaHandler
sshmatrix Aug 14, 2024
a67bca9
Merge branch 'master' into solanaHandler
sshmatrix Sep 17, 2024
4b0c17e
ERC-7694: Optimise images for light theme
sshmatrix Sep 17, 2024
464937e
ERC-7694: CCIP-Read methods for Solana
sshmatrix Sep 17, 2024
8e7c077
ERC-7694: More image optimisations
sshmatrix Sep 17, 2024
0e0532d
Update ERCS/erc-7694.md
sshmatrix Sep 17, 2024
ff65fc4
Merge branch 'master' into solanaHandler
sshmatrix Sep 17, 2024
0e5039b
ERC-7694: Minor fixes
sshmatrix Sep 17, 2024
02e28fa
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Sep 17, 2024
cc231b9
Merge branch 'master' into solanaHandler
sshmatrix Sep 18, 2024
3ca02a9
Merge branch 'master' into solanaHandler
sshmatrix Sep 22, 2024
49098e1
ERC-7694: Add font files & refer in SVGs
sshmatrix Sep 27, 2024
f06cd7a
Merge branch 'master' into solanaHandler
sshmatrix Sep 27, 2024
f84a5e5
Merge branch 'solanaHandler' of https://github.com/namesys-eth/ERCs i…
sshmatrix Sep 27, 2024
f4a9241
ERC-7694: Add permissive fonts with licenses
sshmatrix Oct 3, 2024
0027565
Update ERCS/erc-7694.md
sshmatrix Oct 3, 2024
fc4de34
Merge branch 'master' into solanaHandler
sshmatrix Oct 3, 2024
62a85ea
ERC-7694: Purge old font files
sshmatrix Oct 3, 2024
3ec7f62
ERC-7694: Include font and license explicitly within SVG
sshmatrix Oct 12, 2024
4e18a9d
Merge branch 'master' into solanaHandler
sshmatrix Oct 12, 2024
02bc14d
Merge branch 'master' into solanaHandler
sshmatrix Oct 18, 2024
79d067f
Merge branch 'master' into solanaHandler
sshmatrix Nov 2, 2024
6c0e0f0
Merge branch 'master' into solanaHandler
sshmatrix Nov 26, 2024
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
110 changes: 110 additions & 0 deletions ERCS/erc-7694.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
eip: 7694
title: Solana storage handler for CCIP-Write
description: Cross-chain write deferral protocol incorporating storage handler for Solana
author: Avneet Singh (@sshmatrix), 0xc0de4c0ffee (@0xc0de4c0ffee)
discussions-to: https://ethereum-magicians.org/t/eip-7694-solana-storage-handler-for-ccip-write/19706
sshmatrix marked this conversation as resolved.
Show resolved Hide resolved
status: Draft
type: Standards Track
category: ERC
created: 2024-04-18
---
sshmatrix marked this conversation as resolved.
Show resolved Hide resolved

## Abstract
The following standard is an extension to the cross-chain write deferral protocol introducing storage handler for Solana.

## Motivation
[EIP-5559](./eip-5559) introduces two external handlers for deferring write operations to L2s and databases. This document extends that specification by introducing a third storage handler targeting Solana as the storage provider.

L2s and databases both have centralising catalysts in their stack. For L2s, this centralising agent is the shared security with Ethereum mainnet. In case of databases, the centralising agent is trivial; it is the physical server hosting the database. In light of this, a storage provider that relies on its own independent consensus mechanism is preferred. This specification instructs how the clients should treat write deferrals made to the Solana handler.

Solana is a cheap L1 solution that is fairly popular among Ethereum community and is widely supported alongside Ethereum by almost all wallet providers. There are several chain-agnostic protocols on Ethereum which could benefit from direct access to Solana blockspace; ENS is one such example where it can serve users of Solana via its chain-agnostic properties while also using Solana's own native storage. This development will encourage more cross-chain functionalities between Ethereum and Solana at core.
sshmatrix marked this conversation as resolved.
Show resolved Hide resolved

## Specification
A Solana storage handler `StorageHandledBySolana()` requires the hex-encoded `programId` and the manager `account` on the Solana blockchain. `programId` is equivalent to a contract address on Solana while `account` is the manager wallet on Solana handling write operations on behalf of `msg.sender`.

```solidity
// Revert handling Solana storage handler
error StorageHandledBySolana(
bytes32 programId,
bytes32 account
);

// Generic function in a contract
function setValue(
bytes32 node,
bytes32 key,
bytes32 value
) external {
// Get metadata from on-chain sources
(
bytes32 programId, // Program (= contract) address on Solana; hex-encoded
bytes32 account // Manager account on Solana; hex-encoded
) = getMetadata(node); // Arbitrary code
// programId = 0x37868885bbaf236c5d2e7a38952f709e796a1c99d6c9d142a1a41755d7660de3
// account = 0xe853e0dcc1e57656bd760325679ea960d958a0a704274a5a12330208ba0f428f
// Defer write call to Solana handler
revert StorageHandledBySolana(
programId,
account
);
};
```

Since Solana natively uses `base58` encoding in its virtual machine setup, `programId` values that are hex-encoded on EVM must be `base58`-decoded for usage on SVM. Clients implementing the Solana handler must call the Solana `programId` using a Solana wallet that is connected to `account` using the `base58`-decoded (and casted to appropriate datatype) calldata that it originally received.

```js
/* Pseudo-code to write to Solana program (= contract) */
// Decode all 'bytes32' types in EVM to 'PubKey' type in SVM
const [programId, account, node, key, value] = svmPubkey([programId, account, node, key, value])
// Instantiate program interface on Solana
const program = new program(programId, rpcProvider);
// Connect to Solana wallet
const wallet = useWallet();
// Call the Solana program using connected wallet with initial calldata
// [!] Only approved manager in the Solana program should call
if (wallet.publicKey === account) {
await program(wallet).setValue(node, key, value);
}
```

In the above example, EVM-specific `bytes32`-type variables `programId`, `account`, `node`, `key` and `value` must all be converted to SVM-specific `PubKey` type. The equivalent `setValue()` function in the Solana program is of the form

```rust
// Example function in Solana program
pub fn setValue(
ctx: Context,
node: PubKey,
key: PubKey,
value: PubKey
) -> ProgramResult {
// Code to verify PROGRAM_ID and rent exemption status
...
// Code for de-serialising, updating and re-serialising the data
...
// Write serialised data to account
// [!] Stored data must be mapped by node & account
...
}
```

Since EVM and SVM have differing architectures, it is important to define precise datatype castings from EVM to SVM. Some pre-existing custom but popular datatypes in SVM that equate to common EVM datatypes are:

| EVM | SVM |
|:---------------:|:------------:|
| `bytes32` | `PubKey` |
| `string` | `String` |

For other encoding-specific datatypes such as `bytesN` (`N < 32`) and `address` (`N = 20`), this specification requires that all such variables must be padded up to `bytes32`. Using this strategy, most current use-cases of `StorageHandledBySolana()` are accounted for.

## Rationale
`StorageHandledBySolana()` works in a similar fashion to `StorageHandledByL2()` in [EIP-5559](./eip-5559) in the sense that the client needs to be pointed to a certain contract on another chain by the revert event. Other than that, the only technical difference is casting between EVM and SVM datatypes.

## Backwards Compatibility
None.

## Security Considerations
None.

## Copyright
Copyright and related rights waived via [`CC0`](../LICENSE.md).
sshmatrix marked this conversation as resolved.
Show resolved Hide resolved
Loading