-
Notifications
You must be signed in to change notification settings - Fork 94
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
SIMD-0201: Create a Cluster Sysvar #201
Open
blockiosaurus
wants to merge
4
commits into
solana-foundation:main
Choose a base branch
from
blockiosaurus:blockiosaurus/create-cluster-sysvar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
simd: "0201" | ||
title: Create Cluster Sysvar | ||
authors: | ||
- [email protected] | ||
category: Standard | ||
type: Core | ||
status: Review | ||
created: 2024-11-22 | ||
feature: | ||
--- | ||
|
||
## Summary | ||
|
||
There should be a natively accessible Sysvar (like Rent or Clock) that provides | ||
Cluster details in order to determine the specific SVM environment. | ||
|
||
## Motivation | ||
|
||
It is currently not possible to determine which cluster a Solana program is | ||
executing on from within the program itself. This makes dynamic behavior based | ||
on different SVM environments difficult without requiring multiple builds of a | ||
single protocol. Native determination of the SVM cluster would improve DevEx and | ||
diminish opportunities to introduce bugs by allowing more dynamic program execution. | ||
|
||
## Alternatives Considered | ||
|
||
- **SDK Abstraction** - It would be possible but difficult to maintain separate | ||
SDKs per cluster or dynamic resolution based on genesis hash | ||
|
||
## New Terminology | ||
|
||
**ClusterDetails** - The sysvar structure which provides the relevant details | ||
for a program to determine which cluster it's executing on. | ||
|
||
## Detailed Design | ||
|
||
The following Cluster type and ClusterDetails struct would provide sufficient | ||
details for a program to properly determine the environment on which it's | ||
executing. String tags are included because using genesis hash alone is | ||
insufficient for clusters that don't guarantee permanence such as devnet, | ||
testnet, or roll-ups. | ||
|
||
```rust | ||
/// The cluster type, usually the first three with an optional named | ||
/// field for more diverse clusters (alt-devnets, roll-ups). | ||
#[repr(C)] | ||
pub enum ClusterType: { | ||
mainnet, | ||
devnet, | ||
testnet, | ||
other(String), | ||
} | ||
|
||
#[repr(C)] | ||
pub struct ClusterDetails { | ||
/// The genesis hash for the cluster, guaranteed for mainnet but | ||
/// possibly variable for other cluster types. | ||
pub genesis_hash: Hash, | ||
/// A named tag for the SVM chain on which the program is executing. | ||
pub blockchain: String, | ||
/// Cluster Type | ||
pub cluster_type: ClusterType, | ||
} | ||
``` | ||
|
||
## Impact | ||
|
||
Dynamic determination of cluster would allow programs to perform better | ||
validation of cluster-specific feature such as variable protocol fees, | ||
irreplicable PDAs or derivations, or variable features across different blockchains. | ||
|
||
## Security Considerations | ||
|
||
Certain named fields could be invalidated due to changes to the underlying SVM | ||
runtime. Program developers should be sure to validate and fail gracefully if | ||
unexpected changes occur. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would advocate for a static layout here. Can we accomplish the stated goal with IDs? Something like:
I guess that introduces the problem of where to "register" chain IDs, but I think we were going to have that problem anyway, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be nice to have the cluster identifier be typed but that could easily be accomplished with helpers in the SDK.
I think the static type makes sense. The chain ID is really for continuity for Devnet resets and debugging so relying on an external registry also works!