solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.33k stars 4.35k forks source link

Need high level specifications for standalone SVM #34196

Open pgarg66 opened 1 year ago

pgarg66 commented 1 year ago

Problem

Standalone SVM project's goal is to extract reusable code out of Solana transaction processing pipeline into its own crate (and eventually to its own GitHub repo). The project needs a high level specifications writeup to define the following.

anoushk1234 commented 1 year ago

@pgarg66 @dmakarov As discussed I've collected a list of applications from multiple ecosystem teams that they are interested in, this would help us define the spec and API.

Applications:

riptl commented 1 year ago

Modified SVM (SVM+) An SVM type with all the current functionality and extended instructions for custom use cases. This would form a superset of the current SVM.

The SVM+ idea seems like a recipe for disaster. A large part of the current mainnet functionality is deprecated or redundant, and highly complex to replicate in external environments. The vote/stake programs are unlikely to be used in custom app chains, yet they introduce unbounded memory use. Which makes them unsuitable for the four other use cases named above. An SVM+ cannot be correctly specified before the entire mainnet protocol is specified first too, so it's not practical either.

The only production SVM so far (Pythnet) does the opposite instead by removing most of the current functionality. I suggest standardizing a "Solana Base Runtime", which is the minimum scaffold required for any SVM. (Slot context, blocks, generic transaction processing, and the system program)

pgarg66 commented 1 year ago

SVM+ seems out of scope for the current issue. It might be best to create a new issue for SVM+ to discuss its merits and potential implementation.

SOELTH commented 1 year ago

We should specify the specs of the existing implementation first. After that we should do everything we can to simplify the implementation. Only then should we start thinking about (conservatively) adding complexity where needed, imo.

pgarg66 commented 1 year ago

I believe some clarification might be useful here. The goal is not to reimplement SVM. The current transaction processing code in Solana validator client was not designed to be used outside the client. The code is intertwined with the non-tx processing code. We are attempting to split the code and put an interface on top of it. This will establish a cleaner boundary between tx processing code (SVM) and non-SVM code.

This issue is to track the creation of a spec for the interface of SVM. The current code doesn't have a well defined API, and it's impossible to create a spec for it.

It's also understood that some clients of SVM could reuse other Solana code blocks, while other clients might want to implement their own. If there's enough interest to split those code blocks, it's best to create their individual issues at some point of time. Just so that the discussions can continue even after this issue is closed.

anoushk1234 commented 1 year ago

Modified SVM (SVM+) An SVM type with all the current functionality and extended instructions for custom use cases. This would form a superset of the current SVM.

The SVM+ idea seems like a recipe for disaster. A large part of the current mainnet functionality is deprecated or redundant, and highly complex to replicate in external environments. The vote/stake programs are unlikely to be used in custom app chains, yet they introduce unbounded memory use. Which makes them unsuitable for the four other use cases named above. An SVM+ cannot be correctly specified before the entire mainnet protocol is specified first too, so it's not practical either.

The only production SVM so far (Pythnet) does the opposite instead by removing most of the current functionality. I suggest standardizing a "Solana Base Runtime", which is the minimum scaffold required for any SVM. (Slot context, blocks, generic transaction processing, and the system program)

The ideas listed were only to guage interest from ecosystem teams and not something we should implement.

if it is hard to define a spec currently then I think we should first make a minimal SVM i.e the minimum amount of individual components required to execute transactions and be compatible with mainnet-beta while being separated from the validator, similar to the Minimal-AccountsDB where someone tried to implement it within 300 LOC. This might help gain clarity on what a spec looks like. We don't need to re-implement the SVM, just extract the important components out and put it all together.