Skip to content

Commit 6c6c26e

Browse files
authored
Add builtins crate (#3866)
* init builtins crate * port over migration configs * port over prototypes * port over builtins list * runtime: remove unnecessary dependencies * update crate comment * add some more doc comments
1 parent 2705f5e commit 6c6c26e

File tree

16 files changed

+594
-491
lines changed

16 files changed

+594
-491
lines changed

Cargo.lock

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ members = [
2525
"bench-tps",
2626
"bloom",
2727
"bucket_map",
28+
"builtins",
2829
"builtins-default-costs",
2930
"cargo-registry",
3031
"clap-utils",
@@ -442,6 +443,7 @@ solana-bn254 = { path = "curves/bn254", version = "=2.2.0" }
442443
solana-borsh = { path = "sdk/borsh", version = "=2.2.0" }
443444
solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=2.2.0" }
444445
solana-bucket-map = { path = "bucket_map", version = "=2.2.0" }
446+
solana-builtins = { path = "builtins", version = "=2.2.0" }
445447
solana-builtins-default-costs = { path = "builtins-default-costs", version = "=2.2.0" }
446448
agave-cargo-registry = { path = "cargo-registry", version = "=2.2.0" }
447449
solana-clap-utils = { path = "clap-utils", version = "=2.2.0" }

builtins/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "solana-builtins"
3+
description = "Solana builtin programs"
4+
documentation = "https://docs.rs/solana-builtins"
5+
version = { workspace = true }
6+
authors = { workspace = true }
7+
repository = { workspace = true }
8+
homepage = { workspace = true }
9+
license = { workspace = true }
10+
edition = { workspace = true }
11+
12+
[features]
13+
dev-context-only-utils = []
14+
15+
[dependencies]
16+
solana-address-lookup-table-program = { workspace = true }
17+
solana-bpf-loader-program = { workspace = true }
18+
solana-compute-budget-program = { workspace = true }
19+
solana-config-program = { workspace = true }
20+
solana-feature-set = { workspace = true }
21+
solana-loader-v4-program = { workspace = true }
22+
solana-program-runtime = { workspace = true }
23+
solana-pubkey = { workspace = true }
24+
solana-sdk-ids = { workspace = true }
25+
solana-stake-program = { workspace = true }
26+
solana-system-program = { workspace = true }
27+
solana-vote-program = { workspace = true }
28+
solana-zk-elgamal-proof-program = { workspace = true }
29+
solana-zk-token-proof-program = { workspace = true }
30+
31+
[lints]
32+
workspace = true

builtins/src/core_bpf_migration.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use solana_pubkey::Pubkey;
2+
3+
/// Identifies the type of built-in program targeted for Core BPF migration.
4+
/// The type of target determines whether the program should have a program
5+
/// account or not, which is checked before migration.
6+
#[allow(dead_code)] // Remove after first migration is configured.
7+
#[derive(Debug, PartialEq)]
8+
pub enum CoreBpfMigrationTargetType {
9+
/// A standard (stateful) builtin program must have a program account.
10+
Builtin,
11+
/// A stateless builtin must not have a program account.
12+
Stateless,
13+
}
14+
15+
/// Configuration for migrating a built-in program to Core BPF.
16+
#[derive(Debug, PartialEq)]
17+
pub struct CoreBpfMigrationConfig {
18+
/// The address of the source buffer account to be used to replace the
19+
/// builtin.
20+
pub source_buffer_address: Pubkey,
21+
/// The authority to be used as the BPF program's upgrade authority.
22+
///
23+
/// Note: If this value is set to `None`, then the migration will ignore
24+
/// the source buffer account's authority. If it's set to any `Some(..)`
25+
/// value, then the migration will perform a sanity check to ensure the
26+
/// source buffer account's authority matches the provided value.
27+
pub upgrade_authority_address: Option<Pubkey>,
28+
/// The feature gate to trigger the migration to Core BPF.
29+
/// Note: This feature gate should never be the same as any builtin's
30+
/// `enable_feature_id`. It should always be a feature gate that will be
31+
/// activated after the builtin is already enabled.
32+
pub feature_id: Pubkey,
33+
/// The type of target to replace.
34+
pub migration_target: CoreBpfMigrationTargetType,
35+
/// Static message used to emit datapoint logging.
36+
/// This is used to identify the migration in the logs.
37+
/// Should be unique to the migration, ie:
38+
/// "migrate_{builtin/stateless}_to_core_bpf_{program_name}".
39+
pub datapoint_name: &'static str,
40+
}

0 commit comments

Comments
 (0)