Skip to content

Commit

Permalink
make solana-metrics optional in vote and stake programs (#4425)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey authored Jan 13, 2025
1 parent f1a2143 commit 73080ab
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ solana-send-transaction-service = { path = "send-transaction-service", version =
solana-short-vec = { path = "sdk/short-vec", version = "=2.2.0" }
solana-shred-version = { path = "sdk/shred-version", version = "=2.2.0" }
solana-stable-layout = { path = "sdk/stable-layout", version = "=2.2.0" }
solana-stake-program = { path = "programs/stake", version = "=2.2.0" }
solana-stake-program = { path = "programs/stake", version = "=2.2.0", default-features = false }
solana-storage-bigtable = { path = "storage-bigtable", version = "=2.2.0" }
solana-storage-proto = { path = "storage-proto", version = "=2.2.0" }
solana-streamer = { path = "streamer", version = "=2.2.0" }
Expand Down Expand Up @@ -619,7 +619,7 @@ solana-udp-client = { path = "udp-client", version = "=2.2.0" }
solana-validator-exit = { path = "sdk/validator-exit", version = "=2.2.0" }
solana-version = { path = "version", version = "=2.2.0" }
solana-vote = { path = "vote", version = "=2.2.0" }
solana-vote-program = { path = "programs/vote", version = "=2.2.0" }
solana-vote-program = { path = "programs/vote", version = "=2.2.0", default-features = false }
solana-wen-restart = { path = "wen-restart", version = "=2.2.0" }
solana-zk-elgamal-proof-program = { path = "programs/zk-elgamal-proof", version = "=2.2.0" }
solana-zk-keygen = { path = "zk-keygen", version = "=2.2.0" }
Expand Down
6 changes: 5 additions & 1 deletion programs/stake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ solana-program-runtime = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk = { workspace = true }
solana-type-overrides = { workspace = true }
solana-vote-program = { workspace = true }
solana-vote-program = { workspace = true, default-features = false }

[dev-dependencies]
assert_matches = { workspace = true }
Expand All @@ -30,6 +30,10 @@ solana-compute-budget = { workspace = true }
solana-logger = { workspace = true }
test-case = { workspace = true }

[features]
default = ["metrics"]
metrics = ["solana-vote-program/metrics"]

[lib]
crate-type = ["lib"]
name = "solana_stake_program"
Expand Down
4 changes: 3 additions & 1 deletion programs/vote/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [
solana-hash = { workspace = true }
solana-instruction = { workspace = true }
solana-keypair = { workspace = true }
solana-metrics = { workspace = true }
solana-metrics = { workspace = true, optional = true }
solana-packet = { workspace = true }
solana-program = { workspace = true }
solana-program-runtime = { workspace = true }
Expand Down Expand Up @@ -58,12 +58,14 @@ name = "solana_vote_program"
targets = ["x86_64-unknown-linux-gnu"]

[features]
default = ["metrics"]
frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"solana-program/frozen-abi",
"solana-program-runtime/frozen-abi"
]
metrics = ["dep:solana-metrics"]

[lints]
workspace = true
3 changes: 2 additions & 1 deletion programs/vote/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pub mod vote_processor;
pub mod vote_state;
pub mod vote_transaction;

#[macro_use]
#[cfg_attr(feature = "metrics", macro_use)]
#[cfg(feature = "metrics")]
extern crate solana_metrics;

#[cfg_attr(feature = "frozen-abi", macro_use)]
Expand Down
1 change: 1 addition & 0 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ fn check_and_filter_proposed_vote_state(
proposed_hash,
slot_hashes[slot_hashes_index].1
);
#[cfg(feature = "metrics")]
inc_new_counter_info!("dropped-vote-hash", 1);
return Err(VoteError::SlotHashMismatch);
}
Expand Down
1 change: 0 additions & 1 deletion svm/examples/Cargo.lock

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

0 comments on commit 73080ab

Please sign in to comment.