Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 4 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ members = [
"perf",
"validator",
"genesis",
"genesis-programs",
"gossip",
"install",
"keygen",
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ serde_derive = "1.0.103"
serde_json = "1.0.56"
solana-account-decoder = { path = "../account-decoder", version = "1.4.0" }
solana-banks-server = { path = "../banks-server", version = "1.4.0" }
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "1.4.0" }
solana-clap-utils = { path = "../clap-utils", version = "1.4.0" }
solana-client = { path = "../client", version = "1.4.0" }
solana-faucet = { path = "../faucet", version = "1.4.0" }
solana-genesis-programs = { path = "../genesis-programs", version = "1.4.0" }
solana-ledger = { path = "../ledger", version = "1.4.0" }
solana-logger = { path = "../logger", version = "1.4.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "1.4.0" }
Expand Down
44 changes: 44 additions & 0 deletions core/src/builtins.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use solana_runtime::{
bank::{Builtin, Builtins, Entrypoint},
feature_set,
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};

/// Builtin programs that are always available
fn genesis_builtins(cluster_type: ClusterType) -> Vec<Builtin> {
let builtins = if cluster_type != ClusterType::MainnetBeta {
vec![
solana_bpf_loader_deprecated_program!(),
solana_bpf_loader_program!(),
]
} else {
// Remove this `else` block and the `cluster_type` argument to this function once
// `feature_set::bpf_loader2_program::id()` is active on Mainnet Beta
vec![solana_bpf_loader_deprecated_program!()]
};

builtins
.into_iter()
.map(|b| Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)))
.collect()
}

/// Builtin programs activated dynamically by feature
fn feature_builtins() -> Vec<(Builtin, Pubkey)> {
let builtins = vec![(
solana_bpf_loader_program!(),
feature_set::bpf_loader2_program::id(),
)];

builtins
.into_iter()
.map(|(b, p)| (Builtin::new(&b.0, b.1, Entrypoint::Loader(b.2)), p))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare_builtin should probably be a struct so we don't have reference it via tuple indexes. If agreed we can do it a different PR

Copy link
Copy Markdown
Contributor

@jackcmay jackcmay Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just expand out the map to:
.map(|((name, id, entrypoint), p)| (Builtin::new(&b.name, b.id, Entrypoint::Loader(b.entrypoint)), p))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare_builtin should probably be a struct so we don't have reference it via tuple indexes. If agreed we can do it a different PR

Yeah I agree that'll be much nicer. I didn't want to take on that churn in this PR

.collect()
}

pub(crate) fn get(cluster_type: ClusterType) -> Builtins {
Builtins {
genesis_builtins: genesis_builtins(cluster_type),
feature_builtins: feature_builtins(),
}
}
4 changes: 4 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
//! command-line tools to spin up validators and a Rust library
//!

#[macro_use]
extern crate solana_bpf_loader_program;

pub mod accounts_background_service;
pub mod accounts_hash_verifier;
pub mod banking_stage;
pub mod bigtable_upload_service;
pub mod broadcast_stage;
mod builtins;
pub mod cache_block_time_service;
pub mod cluster_info_vote_listener;
pub mod commitment_service;
Expand Down
1 change: 1 addition & 0 deletions core/src/test_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl TestValidator {
&Pubkey::new_rand(),
42,
bootstrap_validator_lamports,
solana_sdk::genesis_config::ClusterType::Development,
);
genesis_config.rent.lamports_per_byte_year = 1;
genesis_config.rent.exemption_threshold = 1.0;
Expand Down
2 changes: 2 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::{
broadcast_stage::BroadcastStageType,
builtins,
cache_block_time_service::{CacheBlockTimeSender, CacheBlockTimeService},
cluster_info::{ClusterInfo, Node},
cluster_info_vote_listener::VoteTracker,
Expand Down Expand Up @@ -791,6 +792,7 @@ fn new_banks_from_ledger(
new_hard_forks: config.new_hard_forks.clone(),
frozen_accounts: config.frozen_accounts.clone(),
debug_keys: config.debug_keys.clone(),
additional_builtins: Some(builtins::get(genesis_config.cluster_type)),
..blockstore_processor::ProcessOptions::default()
};

Expand Down
2 changes: 2 additions & 0 deletions core/tests/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ mod tests {
vec![accounts_dir.path().to_path_buf()],
&[],
None,
None,
);
bank0.freeze();
let mut bank_forks = BankForks::new(bank0);
Expand Down Expand Up @@ -143,6 +144,7 @@ mod tests {
CompressionType::Bzip2,
old_genesis_config,
None,
None,
)
.unwrap();

Expand Down
25 changes: 0 additions & 25 deletions genesis-programs/Cargo.toml

This file was deleted.

Loading