Skip to content
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

Add BigNumber Type and syscalls for BPF programs #17082

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8fea0cc
Add BigNumber and syscalls
FrankC01 May 6, 2021
2cd8645
Removed extra whitespaces
FrankC01 May 6, 2021
03af751
Updated for review comments
FrankC01 May 11, 2021
440aa5e
Merge branch 'master' of https://github.com/solana-labs/solana
FrankC01 May 11, 2021
3035860
BPF test bignum
FrankC01 May 12, 2021
56e833d
Refresh
FrankC01 May 12, 2021
2b1f3e1
BigNumber BPF testing
FrankC01 May 12, 2021
a63450b
Merge remote-tracking branch 'upstream/master'
FrankC01 May 13, 2021
01ed0b9
Addressing white spaces and removed blake3 hash, hash-to-prime and ha…
FrankC01 May 13, 2021
61b56c0
Remove println statements
FrankC01 May 13, 2021
2d8b538
Fix check failures
FrankC01 May 13, 2021
2fffc0a
Fix unused var check failures
FrankC01 May 13, 2021
4ce98c8
Removed hkdf as hashes removed from bignum and correct BPF test
FrankC01 May 13, 2021
a1725b1
Removed hkdf ref
FrankC01 May 13, 2021
ff09a57
Fixes for Cargo.lock
FrankC01 May 13, 2021
952806b
Merge remote-tracking branch 'upstream/master'
FrankC01 May 14, 2021
1d13a79
Fixed BigNumToString syscall buffer overflow
FrankC01 May 14, 2021
6011f78
Fix formatting
FrankC01 May 14, 2021
477359b
Merge remote-tracking branch 'upstream/master'
FrankC01 May 14, 2021
919cdfc
Merge remote-tracking branch 'upstream/master'
FrankC01 May 15, 2021
ca1944e
BigNumber new and from_u32 using vectors instead of Box<BigNum>
FrankC01 May 15, 2021
f5eafc7
BigNumber::from_dec_str using vectors instead of Box
FrankC01 May 15, 2021
3168320
Merge remote-tracking branch 'upstream/master'
FrankC01 May 16, 2021
9b47c24
Merge branch 'master' into bignum-to-vec
FrankC01 May 16, 2021
fba2649
BigNumber::add implemented with vectors
FrankC01 May 16, 2021
cbd738b
Formatting
FrankC01 May 16, 2021
22107d0
BigNumber simple maths using vectors instead of Box
FrankC01 May 16, 2021
47c57b1
BigNumber complex maths-part1 using vector instead of Box
FrankC01 May 17, 2021
5495cc9
Merge remote-tracking branch 'upstream/master'
FrankC01 May 17, 2021
203e619
Merge branch 'master' into bignum-to-vec
FrankC01 May 17, 2021
5e2d397
BigNumber complete conversion to vector from Box
FrankC01 May 17, 2021
069c674
Remove println call
FrankC01 May 17, 2021
7e7bebb
Remove dead code
FrankC01 May 17, 2021
ed924a5
Replace Vec with vec macro as per clippy
FrankC01 May 17, 2021
b173d59
Modernize incrementing by 1
FrankC01 May 17, 2021
aaf90d8
Modernize boolean test
FrankC01 May 17, 2021
0c9258e
remove unused imports
FrankC01 May 17, 2021
0d8a51b
Added assertions to constructor tests
FrankC01 May 17, 2021
8d02300
Merge remote-tracking branch 'upstream/master'
FrankC01 May 18, 2021
af54cae
Fix logging to include sign and refine result allocations
FrankC01 May 18, 2021
35d5c62
Cleanup tests
FrankC01 May 18, 2021
4b7925c
Updated logging for non-bpf execution
FrankC01 May 18, 2021
176e4cc
Merge remote-tracking branch 'upstream/master'
FrankC01 May 19, 2021
bc7eb30
Doubled BigNumber syscall execution base units
FrankC01 May 19, 2021
4f96707
Merged with upstream
FrankC01 May 19, 2021
1f422ab
Fix deadcode errors
FrankC01 May 19, 2021
7a00993
Fix assertion expression
FrankC01 May 19, 2021
ed9cbd5
move Ancestors to its own module (#17316)
jeffwashington May 19, 2021
c20b27b
shink all in parallel on startup (#17308)
jeffwashington May 19, 2021
f1b4a0a
Fix typo (#17326)
ulrichstark May 19, 2021
b5302e7
add calc_stored_meta_us metric (#17318)
jeffwashington May 19, 2021
e7073ec
adds gossip metrics for number of staked nodes (#17330)
behzadnouri May 19, 2021
477898f
Optimize aligned memory used by the runtime (#17324)
jackcmay May 19, 2021
13b032b
removes manual trait impl for contact-info (#17332)
behzadnouri May 19, 2021
32ec834
generate_index inserts ideal initial data (#17247)
jeffwashington May 19, 2021
a544010
don't log shrink metrics on first call (#17328)
jeffwashington May 20, 2021
2ae57c1
Bump bpf-tools version to 1.9
dmakarov May 18, 2021
abe0064
syscall corrections
FrankC01 May 20, 2021
86c9814
Hard reset
FrankC01 May 20, 2021
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
32 changes: 23 additions & 9 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use rayon::prelude::*;
use solana_measure::measure::Measure;
use solana_runtime::{
accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts_index::{AccountSecondaryIndexes, Ancestors},
accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors,
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
use std::{env, fs, path::PathBuf};
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ solana-config-program = { path = "../programs/config", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" }
solana_rbpf = "=0.2.8"
solana_rbpf = "=0.2.9"
solana-remote-wallet = { path = "../remote-wallet", version = "=1.7.0" }
solana-sdk = { path = "../sdk", version = "=1.7.0" }
solana-stake-program = { path = "../programs/stake", version = "=1.7.0" }
Expand Down
23 changes: 12 additions & 11 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2564,7 +2564,7 @@ impl ClusterInfo {
thread_pool: &ThreadPool,
recycler: &PacketsRecycler,
response_sender: &PacketSender,
stakes: HashMap<Pubkey, u64>,
stakes: &HashMap<Pubkey, u64>,
feature_set: Option<&FeatureSet>,
epoch_time_ms: u64,
should_check_duplicate_instance: bool,
Expand Down Expand Up @@ -2637,13 +2637,13 @@ impl ClusterInfo {
self.stats
.packets_received_prune_messages_count
.add_relaxed(prune_messages.len() as u64);
let require_stake_for_gossip = self.require_stake_for_gossip(feature_set, &stakes);
let require_stake_for_gossip = self.require_stake_for_gossip(feature_set, stakes);
if require_stake_for_gossip {
for (_, data) in &mut pull_responses {
retain_staked(data, &stakes);
retain_staked(data, stakes);
}
for (_, data) in &mut push_messages {
retain_staked(data, &stakes);
retain_staked(data, stakes);
}
pull_responses.retain(|(_, data)| !data.is_empty());
push_messages.retain(|(_, data)| !data.is_empty());
Expand All @@ -2654,18 +2654,18 @@ impl ClusterInfo {
push_messages,
thread_pool,
recycler,
&stakes,
stakes,
response_sender,
require_stake_for_gossip,
);
self.handle_batch_pull_responses(pull_responses, thread_pool, &stakes, epoch_time_ms);
self.trim_crds_table(CRDS_UNIQUE_PUBKEY_CAPACITY, &stakes);
self.handle_batch_pull_responses(pull_responses, thread_pool, stakes, epoch_time_ms);
self.trim_crds_table(CRDS_UNIQUE_PUBKEY_CAPACITY, stakes);
self.handle_batch_pong_messages(pong_messages, Instant::now());
self.handle_batch_pull_requests(
pull_requests,
thread_pool,
recycler,
&stakes,
stakes,
response_sender,
require_stake_for_gossip,
);
Expand All @@ -2684,6 +2684,7 @@ impl ClusterInfo {
should_check_duplicate_instance: bool,
) -> Result<()> {
const RECV_TIMEOUT: Duration = Duration::from_secs(1);
const SUBMIT_GOSSIP_STATS_INTERVAL: Duration = Duration::from_secs(2);
let packets: Vec<_> = requests_receiver.recv_timeout(RECV_TIMEOUT)?.packets.into();
let mut packets = VecDeque::from(packets);
while let Ok(packet) = requests_receiver.try_recv() {
Expand Down Expand Up @@ -2714,13 +2715,13 @@ impl ClusterInfo {
thread_pool,
recycler,
response_sender,
stakes,
&stakes,
feature_set.as_deref(),
epoch_time_ms,
should_check_duplicate_instance,
)?;
if last_print.elapsed().as_millis() > 2000 {
submit_gossip_stats(&self.stats, &self.gossip);
if last_print.elapsed() > SUBMIT_GOSSIP_STATS_INTERVAL {
submit_gossip_stats(&self.stats, &self.gossip, &stakes);
*last_print = Instant::now();
}
Ok(())
Expand Down
14 changes: 12 additions & 2 deletions core/src/cluster_info_metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::crds_gossip::CrdsGossip;
use solana_measure::measure::Measure;
use solana_sdk::pubkey::Pubkey;
use std::{
collections::HashMap,
sync::{
atomic::{AtomicU64, Ordering},
RwLock,
Expand Down Expand Up @@ -116,15 +118,21 @@ pub(crate) struct GossipStats {
pub(crate) tvu_peers: Counter,
}

pub(crate) fn submit_gossip_stats(stats: &GossipStats, gossip: &RwLock<CrdsGossip>) {
let (table_size, purged_values_size, failed_inserts_size) = {
pub(crate) fn submit_gossip_stats(
stats: &GossipStats,
gossip: &RwLock<CrdsGossip>,
stakes: &HashMap<Pubkey, u64>,
) {
let (table_size, num_nodes, purged_values_size, failed_inserts_size) = {
let gossip = gossip.read().unwrap();
(
gossip.crds.len(),
gossip.crds.num_nodes(),
gossip.pull.purged_values.len(),
gossip.pull.failed_inserts.len(),
)
};
let num_nodes_staked = stakes.values().filter(|stake| **stake > 0).count();
datapoint_info!(
"cluster_info_stats",
("entrypoint", stats.entrypoint.clear(), i64),
Expand All @@ -142,6 +150,8 @@ pub(crate) fn submit_gossip_stats(stats: &GossipStats, gossip: &RwLock<CrdsGossi
("table_size", table_size as i64, i64),
("purged_values_size", purged_values_size as i64, i64),
("failed_inserts_size", failed_inserts_size as i64, i64),
("num_nodes", num_nodes as i64, i64),
("num_nodes_staked", num_nodes_staked as i64, i64),
);
datapoint_info!(
"cluster_info_stats2",
Expand Down
26 changes: 2 additions & 24 deletions core/src/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use solana_sdk::sanitize::{Sanitize, SanitizeError};
#[cfg(test)]
use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::timing::timestamp;
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
use std::net::{IpAddr, SocketAddr};

/// Structure representing a node on the network
#[derive(Serialize, Deserialize, Clone, Debug, AbiExample)]
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, AbiExample, Deserialize, Serialize)]
pub struct ContactInfo {
pub id: Pubkey,
/// gossip address
Expand Down Expand Up @@ -48,34 +47,13 @@ impl Sanitize for ContactInfo {
}
}

impl Ord for ContactInfo {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}

impl PartialOrd for ContactInfo {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl PartialEq for ContactInfo {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

impl Eq for ContactInfo {}

#[macro_export]
macro_rules! socketaddr {
($ip:expr, $port:expr) => {
std::net::SocketAddr::from((std::net::Ipv4Addr::from($ip), $port))
};
($str:expr) => {{
let a: std::net::SocketAddr = $str.parse().unwrap();
a
$str.parse::<std::net::SocketAddr>().unwrap()
}};
}
#[macro_export]
Expand Down
4 changes: 1 addition & 3 deletions core/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! CrdsValue enums.
//!
//! Merge strategy is implemented in:
//! impl PartialOrd for VersionedCrdsValue
//! fn overrides(value: &CrdsValue, other: &VersionedCrdsValue) -> bool
//!
//! A value is updated to a new version if the labels match, and the value
//! wallclock is later, or the value hash is greater.
Expand Down Expand Up @@ -66,8 +66,6 @@ pub enum CrdsError {
}

/// This structure stores some local metadata associated with the CrdsValue
/// The implementation of PartialOrd ensures that the "highest" version is always picked to be
/// stored in the Crds
#[derive(PartialEq, Debug, Clone)]
pub struct VersionedCrdsValue {
/// Ordinal index indicating insert order.
Expand Down
40 changes: 18 additions & 22 deletions core/src/crds_gossip_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,36 +753,32 @@ mod test {
#[test]
fn test_personalized_push_messages() {
let now = timestamp();
let mut rng = rand::thread_rng();
let mut crds = Crds::default();
let mut push = CrdsGossipPush::default();
let peer_1 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
0,
)));
assert_eq!(crds.insert(peer_1.clone(), now), Ok(None));
let peer_2 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
0,
)));
assert_eq!(crds.insert(peer_2.clone(), now), Ok(None));
let peer_3 = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&solana_sdk::pubkey::new_rand(),
now,
)));
let peers: Vec<_> = vec![0, 0, now]
.into_iter()
.map(|wallclock| {
let mut peer = ContactInfo::new_rand(&mut rng, /*pubkey=*/ None);
peer.wallclock = wallclock;
CrdsValue::new_unsigned(CrdsData::ContactInfo(peer))
})
.collect();
assert_eq!(crds.insert(peers[0].clone(), now), Ok(None));
assert_eq!(crds.insert(peers[1].clone(), now), Ok(None));
assert_eq!(
push.process_push_message(&mut crds, &Pubkey::default(), peer_3.clone(), now),
push.process_push_message(&mut crds, &Pubkey::default(), peers[2].clone(), now),
Ok(None)
);
push.refresh_push_active_set(&crds, &HashMap::new(), None, &Pubkey::default(), 0, 1, 1);

// push 3's contact info to 1 and 2 and 3
let new_msg = CrdsValue::new_unsigned(CrdsData::ContactInfo(ContactInfo::new_localhost(
&peer_3.pubkey(),
0,
)));
let mut expected = HashMap::new();
expected.insert(peer_1.pubkey(), vec![new_msg.clone()]);
expected.insert(peer_2.pubkey(), vec![new_msg]);
let expected: HashMap<_, _> = vec![
(peers[0].pubkey(), vec![peers[2].clone()]),
(peers[1].pubkey(), vec![peers[2].clone()]),
]
.into_iter()
.collect();
assert_eq!(push.active_set.len(), 3);
assert_eq!(push.new_push_messages(&crds, now), expected);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/cli/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ on your wallet type.
#### Paper Wallet

In a paper wallet, the keypair is securely derived from the seed words and
optional passphrase you entered when the wallet was create. To use a paper
optional passphrase you entered when the wallet was created. To use a paper
wallet keypair anywhere the `<KEYPAIR>` text is shown in examples or help
documents, enter the uri scheme `prompt://` and the program will prompt you to
enter your seed words when you run the command.
Expand Down
Loading