Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
b55dafa1dd
chore: bump async from 2.6.3 to 2.6.4 in /docs
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: async
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-15 08:43:21 +00:00
49 changed files with 5688 additions and 7799 deletions

46
Cargo.lock generated
View File

@ -177,9 +177,9 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.53"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
dependencies = [
"proc-macro2 1.0.32",
"quote 1.0.10",
@ -631,7 +631,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
dependencies = [
"camino",
"cargo-platform",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_json",
]
@ -935,9 +935,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.4"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
checksum = "fdbfe11fe19ff083c48923cf179540e8cd0535903dc35e178a1fdeeb59aef51f"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -3759,7 +3759,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.7",
"semver 1.0.6",
]
[[package]]
@ -3940,9 +3940,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.7"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
dependencies = [
"serde",
]
@ -4565,7 +4565,7 @@ dependencies = [
"num-traits",
"pretty-hex",
"reqwest",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_derive",
"serde_json",
@ -4621,7 +4621,7 @@ dependencies = [
"humantime",
"indicatif",
"pretty-hex",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_json",
"solana-account-decoder",
@ -4664,7 +4664,7 @@ dependencies = [
"rayon",
"reqwest",
"rustls",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_derive",
"serde_json",
@ -5074,7 +5074,7 @@ dependencies = [
"lazy_static",
"nix",
"reqwest",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_yaml",
"solana-clap-utils",
@ -5559,7 +5559,7 @@ dependencies = [
"num-traits",
"parking_lot 0.12.0",
"qstring",
"semver 1.0.7",
"semver 1.0.6",
"solana-sdk",
"thiserror",
"uriparse",
@ -7239,9 +7239,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -7249,9 +7249,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b"
dependencies = [
"bumpalo",
"lazy_static",
@ -7276,9 +7276,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [
"quote 1.0.10",
"wasm-bindgen-macro-support",
@ -7286,9 +7286,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [
"proc-macro2 1.0.32",
"quote 1.0.10",
@ -7299,9 +7299,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
[[package]]
name = "web-sys"

View File

@ -148,18 +148,6 @@ all_test_steps() {
# Full test suite
command_step stable ". ci/rust-version.sh; ci/docker-run.sh \$\$rust_stable_docker_image ci/test-stable.sh" 70
# Docs tests
if affects \
.rs$ \
^ci/rust-version.sh \
^ci/test-docs.sh \
; then
command_step doctest "ci/test-docs.sh" 15
else
annotate --style info --context test-docs \
"Docs skipped as no .rs files were modified"
fi
wait_step
# BPF test suite

View File

@ -1 +0,0 @@
test-stable.sh

View File

@ -30,7 +30,7 @@ JOBS=$((JOBS>NPROC ? NPROC : JOBS))
echo "Executing $testName"
case $testName in
test-stable)
_ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
_ "$cargo" stable test --jobs "$JOBS" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
;;
test-stable-bpf)
# Clear the C dependency files, if dependency moves these files are not regenerated
@ -130,10 +130,6 @@ test-wasm)
done
exit 0
;;
test-docs)
_ "$cargo" stable test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
exit 0
;;
*)
echo "Error: Unknown test: $testName"
;;

View File

@ -18,7 +18,7 @@ console = "0.15.0"
humantime = "2.0.1"
indicatif = "0.16.2"
pretty-hex = "0.2.1"
semver = "1.0.7"
semver = "1.0.6"
serde = "1.0.136"
serde_json = "1.0.79"
solana-account-decoder = { path = "../account-decoder", version = "=1.11.0" }

View File

@ -23,7 +23,7 @@ log = "0.4.14"
num-traits = "0.2"
pretty-hex = "0.2.1"
reqwest = { version = "0.11.10", default-features = false, features = ["blocking", "rustls-tls", "json"] }
semver = "1.0.7"
semver = "1.0.6"
serde = "1.0.136"
serde_derive = "1.0.103"
serde_json = "1.0.79"

View File

@ -11,7 +11,7 @@ edition = "2021"
[dependencies]
async-mutex = "1.4.0"
async-trait = "0.1.53"
async-trait = "0.1.52"
base64 = "0.13.0"
bincode = "1.3.3"
bs58 = "0.4.0"
@ -33,7 +33,7 @@ rand_chacha = "0.2.2"
rayon = "1.5.1"
reqwest = { version = "0.11.10", default-features = false, features = ["blocking", "rustls-tls", "json"] }
rustls = { version = "0.20.2", features = ["dangerous_configuration"] }
semver = "1.0.7"
semver = "1.0.6"
serde = "1.0.136"
serde_derive = "1.0.103"
serde_json = "1.0.79"

View File

@ -20,10 +20,10 @@ use {
};
// Should be non-zero
static MAX_CONNECTIONS: usize = 1024;
static MAX_CONNECTIONS: usize = 64;
#[derive(Clone)]
pub enum Connection {
enum Connection {
Udp(Arc<UdpTpuConnection>),
Quic(Arc<QuicTpuConnection>),
}
@ -117,14 +117,14 @@ impl ConnectionCacheStats {
}
}
struct ConnectionMap {
struct ConnMap {
map: LruCache<SocketAddr, Connection>,
stats: Arc<ConnectionCacheStats>,
last_stats: AtomicInterval,
use_quic: bool,
}
impl ConnectionMap {
impl ConnMap {
pub fn new() -> Self {
Self {
map: LruCache::new(MAX_CONNECTIONS),
@ -140,7 +140,7 @@ impl ConnectionMap {
}
lazy_static! {
static ref CONNECTION_MAP: Mutex<ConnectionMap> = Mutex::new(ConnectionMap::new());
static ref CONNECTION_MAP: Mutex<ConnMap> = Mutex::new(ConnMap::new());
}
pub fn set_use_quic(use_quic: bool) {
@ -346,7 +346,6 @@ mod tests {
#[test]
fn test_connection_cache() {
solana_logger::setup();
// Allow the test to run deterministically
// with the same pseudorandom sequence between runs
// and on different platforms - the cryptographic security

View File

@ -11,20 +11,15 @@ use {
itertools::Itertools,
lazy_static::lazy_static,
log::*,
quinn::{
ClientConfig, Endpoint, EndpointConfig, IdleTimeout, NewConnection, VarInt, WriteError,
},
quinn::{ClientConfig, Endpoint, EndpointConfig, NewConnection, WriteError},
quinn_proto::ConnectionStats,
solana_sdk::{
quic::{
QUIC_KEEP_ALIVE_MS, QUIC_MAX_CONCURRENT_STREAMS, QUIC_MAX_TIMEOUT_MS, QUIC_PORT_OFFSET,
},
quic::{QUIC_MAX_CONCURRENT_STREAMS, QUIC_PORT_OFFSET},
transport::Result as TransportResult,
},
std::{
net::{SocketAddr, UdpSocket},
sync::{atomic::Ordering, Arc},
time::Duration,
},
tokio::runtime::Runtime,
};
@ -168,13 +163,7 @@ impl QuicClient {
let mut endpoint = RUNTIME.block_on(create_endpoint);
let mut config = ClientConfig::new(Arc::new(crypto));
let transport_config = Arc::get_mut(&mut config.transport).unwrap();
let timeout = IdleTimeout::from(VarInt::from_u32(QUIC_MAX_TIMEOUT_MS));
transport_config.max_idle_timeout(Some(timeout));
transport_config.keep_alive_interval(Some(Duration::from_millis(QUIC_KEEP_ALIVE_MS)));
endpoint.set_default_client_config(config);
endpoint.set_default_client_config(ClientConfig::new(Arc::new(crypto)));
Self {
endpoint,

View File

@ -59,7 +59,6 @@ pub mod sigverify;
pub mod sigverify_shreds;
pub mod sigverify_stage;
pub mod snapshot_packager_service;
pub mod staked_nodes_updater_service;
pub mod stats_reporter_service;
pub mod system_monitor_service;
mod tower1_7_14;
@ -74,7 +73,6 @@ pub mod verified_vote_packets;
pub mod vote_simulator;
pub mod vote_stake_tracker;
pub mod voting_service;
pub mod warm_quic_cache_service;
pub mod window_service;
#[macro_use]

View File

@ -1,76 +0,0 @@
use {
solana_gossip::cluster_info::ClusterInfo,
solana_runtime::bank_forks::BankForks,
std::{
collections::HashMap,
net::IpAddr,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
};
const IP_TO_STAKE_REFRESH_DURATION: Duration = Duration::from_secs(5);
pub struct StakedNodesUpdaterService {
thread_hdl: JoinHandle<()>,
}
impl StakedNodesUpdaterService {
pub fn new(
exit: Arc<AtomicBool>,
cluster_info: Arc<ClusterInfo>,
bank_forks: Arc<RwLock<BankForks>>,
shared_staked_nodes: Arc<RwLock<HashMap<IpAddr, u64>>>,
) -> Self {
let thread_hdl = Builder::new()
.name("sol-sn-updater".to_string())
.spawn(move || {
let mut last_stakes = Instant::now();
while !exit.load(Ordering::Relaxed) {
let mut new_ip_to_stake = HashMap::new();
Self::try_refresh_ip_to_stake(
&mut last_stakes,
&mut new_ip_to_stake,
&bank_forks,
&cluster_info,
);
let mut shared = shared_staked_nodes.write().unwrap();
*shared = new_ip_to_stake;
}
})
.unwrap();
Self { thread_hdl }
}
fn try_refresh_ip_to_stake(
last_stakes: &mut Instant,
ip_to_stake: &mut HashMap<IpAddr, u64>,
bank_forks: &RwLock<BankForks>,
cluster_info: &ClusterInfo,
) {
if last_stakes.elapsed() > IP_TO_STAKE_REFRESH_DURATION {
let root_bank = bank_forks.read().unwrap().root_bank();
let staked_nodes = root_bank.staked_nodes();
*ip_to_stake = cluster_info
.tvu_peers()
.into_iter()
.filter_map(|node| {
let stake = staked_nodes.get(&node.id)?;
Some((node.tvu.ip(), *stake))
})
.collect();
*last_stakes = Instant::now();
} else {
sleep(Duration::from_millis(1));
}
}
pub fn join(self) -> thread::Result<()> {
self.thread_hdl.join()
}
}

View File

@ -13,7 +13,6 @@ use {
find_packet_sender_stake_stage::FindPacketSenderStakeStage,
sigverify::TransactionSigVerifier,
sigverify_stage::SigVerifyStage,
staked_nodes_updater_service::StakedNodesUpdaterService,
},
crossbeam_channel::{bounded, unbounded, Receiver, RecvTimeoutError},
solana_gossip::cluster_info::ClusterInfo,
@ -29,9 +28,7 @@ use {
vote_sender_types::{ReplayVoteReceiver, ReplayVoteSender},
},
solana_sdk::signature::Keypair,
solana_streamer::quic::{spawn_server, MAX_STAKED_CONNECTIONS, MAX_UNSTAKED_CONNECTIONS},
std::{
collections::HashMap,
net::UdpSocket,
sync::{atomic::AtomicBool, Arc, Mutex, RwLock},
thread,
@ -65,7 +62,6 @@ pub struct Tpu {
tpu_quic_t: thread::JoinHandle<()>,
find_packet_sender_stake_stage: FindPacketSenderStakeStage,
vote_find_packet_sender_stake_stage: FindPacketSenderStakeStage,
staked_nodes_updater_service: StakedNodesUpdaterService,
}
impl Tpu {
@ -136,23 +132,13 @@ impl Tpu {
let (verified_sender, verified_receiver) = unbounded();
let staked_nodes = Arc::new(RwLock::new(HashMap::new()));
let staked_nodes_updater_service = StakedNodesUpdaterService::new(
exit.clone(),
cluster_info.clone(),
bank_forks.clone(),
staked_nodes.clone(),
);
let tpu_quic_t = spawn_server(
let tpu_quic_t = solana_streamer::quic::spawn_server(
transactions_quic_sockets,
keypair,
cluster_info.my_contact_info().tpu.ip(),
packet_sender,
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_IP,
staked_nodes,
MAX_STAKED_CONNECTIONS,
MAX_UNSTAKED_CONNECTIONS,
)
.unwrap();
@ -222,7 +208,6 @@ impl Tpu {
tpu_quic_t,
find_packet_sender_stake_stage,
vote_find_packet_sender_stake_stage,
staked_nodes_updater_service,
}
}
@ -251,7 +236,6 @@ impl Tpu {
self.banking_stage.join(),
self.find_packet_sender_stake_stage.join(),
self.vote_find_packet_sender_stake_stage.join(),
self.staked_nodes_updater_service.join(),
];
self.tpu_quic_t.join()?;
let broadcast_result = self.broadcast_stage.join();

View File

@ -25,7 +25,6 @@ use {
sigverify_stage::SigVerifyStage,
tower_storage::TowerStorage,
voting_service::VotingService,
warm_quic_cache_service::WarmQuicCacheService,
},
crossbeam_channel::{bounded, unbounded, Receiver, RecvTimeoutError},
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierLock,
@ -79,7 +78,6 @@ pub struct Tvu {
accounts_hash_verifier: AccountsHashVerifier,
cost_update_service: CostUpdateService,
voting_service: VotingService,
warm_quic_cache_service: WarmQuicCacheService,
drop_bank_service: DropBankService,
transaction_cost_metrics_service: TransactionCostMetricsService,
}
@ -285,9 +283,6 @@ impl Tvu {
bank_forks.clone(),
);
let warm_quic_cache_service =
WarmQuicCacheService::new(cluster_info.clone(), poh_recorder.clone(), exit.clone());
let (cost_update_sender, cost_update_receiver) = unbounded();
let cost_update_service =
CostUpdateService::new(blockstore.clone(), cost_model.clone(), cost_update_receiver);
@ -361,7 +356,6 @@ impl Tvu {
accounts_hash_verifier,
cost_update_service,
voting_service,
warm_quic_cache_service,
drop_bank_service,
transaction_cost_metrics_service,
}
@ -396,7 +390,6 @@ impl Tvu {
self.accounts_hash_verifier.join()?;
self.cost_update_service.join()?;
self.voting_service.join()?;
self.warm_quic_cache_service.join()?;
self.drop_bank_service.join()?;
self.transaction_cost_metrics_service.join()?;
Ok(())

View File

@ -1,70 +0,0 @@
// Connect to future leaders with some jitter so the quic connection is warm
// by the time we need it.
use {
rand::{thread_rng, Rng},
solana_client::connection_cache::send_wire_transaction,
solana_gossip::cluster_info::ClusterInfo,
solana_poh::poh_recorder::PohRecorder,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
thread::{self, sleep, Builder, JoinHandle},
time::Duration,
},
};
pub struct WarmQuicCacheService {
thread_hdl: JoinHandle<()>,
}
// ~50 seconds
const CACHE_OFFSET_SLOT: i64 = 100;
const CACHE_JITTER_SLOT: i64 = 20;
impl WarmQuicCacheService {
pub fn new(
cluster_info: Arc<ClusterInfo>,
poh_recorder: Arc<Mutex<PohRecorder>>,
exit: Arc<AtomicBool>,
) -> Self {
let thread_hdl = Builder::new()
.name("sol-warm-quic-service".to_string())
.spawn(move || {
let slot_jitter = thread_rng().gen_range(-CACHE_JITTER_SLOT, CACHE_JITTER_SLOT);
let mut maybe_last_leader = None;
while !exit.load(Ordering::Relaxed) {
if let Some(leader_pubkey) = poh_recorder
.lock()
.unwrap()
.leader_after_n_slots((CACHE_OFFSET_SLOT + slot_jitter) as u64)
{
if maybe_last_leader
.map_or(true, |last_leader| last_leader != leader_pubkey)
{
maybe_last_leader = Some(leader_pubkey);
if let Some(addr) = cluster_info
.lookup_contact_info(&leader_pubkey, |leader| leader.tpu)
{
if let Err(err) = send_wire_transaction(&[0u8], &addr) {
warn!(
"Failed to warmup QUIC connection to the leader {:?}, Error {:?}",
leader_pubkey, err
);
}
}
}
}
sleep(Duration::from_millis(200));
}
})
.unwrap();
Self { thread_hdl }
}
pub fn join(self) -> thread::Result<()> {
self.thread_hdl.join()
}
}

12
docs/package-lock.json generated
View File

@ -3275,9 +3275,9 @@
}
},
"node_modules/async": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"dependencies": {
"lodash": "^4.17.14"
}
@ -18239,9 +18239,9 @@
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ=="
},
"async": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": {
"lodash": "^4.17.14"
}

View File

@ -2267,9 +2267,9 @@ async-limiter@~1.0.0:
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==
async@^2.6.2:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
version "2.6.4"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==
dependencies:
lodash "^4.17.14"

View File

@ -13,30 +13,14 @@ import {
import { Cluster, useCluster } from "providers/cluster";
import { useTokenRegistry } from "providers/mints/token-registry";
import { TokenInfoMap } from "@solana/spl-token-registry";
import { Connection } from "@solana/web3.js";
import { getDomainInfo, hasDomainSyntax } from "utils/name-service";
interface SearchOptions {
label: string;
options: {
label: string;
value: string[];
pathname: string;
}[];
}
export function SearchBar() {
const [search, setSearch] = React.useState("");
const searchRef = React.useRef("");
const [searchOptions, setSearchOptions] = React.useState<SearchOptions[]>([]);
const [loadingSearch, setLoadingSearch] = React.useState<boolean>(false);
const [loadingSearchMessage, setLoadingSearchMessage] =
React.useState<string>("loading...");
const selectRef = React.useRef<StateManager<any> | null>(null);
const history = useHistory();
const location = useLocation();
const { tokenRegistry } = useTokenRegistry();
const { url, cluster, clusterInfo } = useCluster();
const { cluster, clusterInfo } = useCluster();
const onChange = (
{ pathname }: ValueType<any, false>,
@ -49,54 +33,7 @@ export function SearchBar() {
};
const onInputChange = (value: string, { action }: InputActionMeta) => {
if (action === "input-change") {
setSearch(value);
}
};
React.useEffect(() => {
searchRef.current = search;
setLoadingSearchMessage("Loading...");
setLoadingSearch(true);
// builds and sets local search output
const options = buildOptions(
search,
cluster,
tokenRegistry,
clusterInfo?.epochInfo.epoch
);
setSearchOptions(options);
// checking for non local search output
if (hasDomainSyntax(search)) {
// if search input is a potential domain we continue the loading state
domainSearch(options);
} else {
// if search input is not a potential domain we can conclude the search has finished
setLoadingSearch(false);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [search]);
// appends domain lookup results to the local search state
const domainSearch = async (options: SearchOptions[]) => {
setLoadingSearchMessage("Looking up domain...");
const connection = new Connection(url);
const searchTerm = search;
const updatedOptions = await buildDomainOptions(
connection,
search,
options
);
if (searchRef.current === searchTerm) {
setSearchOptions(updatedOptions);
// after attempting to fetch the domain name we can conclude the loading state
setLoadingSearch(false);
setLoadingSearchMessage("Loading...");
}
if (action === "input-change") setSearch(value);
};
const resetValue = "" as any;
@ -107,9 +44,13 @@ export function SearchBar() {
<Select
autoFocus
ref={(ref) => (selectRef.current = ref)}
options={searchOptions}
options={buildOptions(
search,
cluster,
tokenRegistry,
clusterInfo?.epochInfo.epoch
)}
noOptionsMessage={() => "No Results"}
loadingMessage={() => loadingSearchMessage}
placeholder="Search for blocks, accounts, transactions, programs, and tokens"
value={resetValue}
inputValue={search}
@ -124,7 +65,6 @@ export function SearchBar() {
onInputChange={onInputChange}
components={{ DropdownIndicator }}
classNamePrefix="search-bar"
isLoading={loadingSearch}
/>
</div>
</div>
@ -247,7 +187,7 @@ function buildTokenOptions(
if (matchedTokens.length > 0) {
return {
label: "Tokens",
options: matchedTokens.slice(0, 10).map(([id, details]) => ({
options: matchedTokens.map(([id, details]) => ({
label: details.name,
value: [details.name, details.symbol, id],
pathname: "/address/" + id,
@ -256,39 +196,6 @@ function buildTokenOptions(
}
}
async function buildDomainOptions(
connection: Connection,
search: string,
options: SearchOptions[]
) {
const domainInfo = await getDomainInfo(search, connection);
const updatedOptions: SearchOptions[] = [...options];
if (domainInfo && domainInfo.owner && domainInfo.address) {
updatedOptions.push({
label: "Domain Owner",
options: [
{
label: domainInfo.owner,
value: [search],
pathname: "/address/" + domainInfo.owner,
},
],
});
updatedOptions.push({
label: "Name Service Account",
options: [
{
label: search,
value: [search],
pathname: "/address/" + domainInfo.address,
},
],
});
}
return updatedOptions;
}
// builds local search options
function buildOptions(
rawSearch: string,
cluster: Cluster,
@ -380,7 +287,6 @@ function buildOptions(
});
}
} catch (err) {}
return options;
}

View File

@ -1,9 +1,6 @@
import { PublicKey, Connection } from "@solana/web3.js";
import {
getFilteredProgramAccounts,
getHashedName,
getNameAccountKey,
getNameOwner,
NAME_PROGRAM_ID,
performReverseLookup,
} from "@bonfida/spl-name-service";
@ -14,48 +11,10 @@ import { Cluster, useCluster } from "providers/cluster";
const SOL_TLD_AUTHORITY = new PublicKey(
"58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"
);
export interface DomainInfo {
name: string;
address: PublicKey;
}
export const hasDomainSyntax = (value: string) => {
return value.length > 4 && value.substring(value.length - 4) === ".sol";
};
async function getDomainKey(
name: string,
nameClass?: PublicKey,
nameParent?: PublicKey
) {
const hashedDomainName = await getHashedName(name);
const nameKey = await getNameAccountKey(
hashedDomainName,
nameClass,
nameParent
);
return nameKey;
}
// returns non empty wallet string if a given .sol domain is owned by a wallet
export async function getDomainInfo(domain: string, connection: Connection) {
const domainKey = await getDomainKey(
domain.slice(0, -4), // remove .sol
undefined,
SOL_TLD_AUTHORITY
);
try {
const registry = await getNameOwner(connection, domainKey);
return registry && registry.registry.owner
? {
owner: registry.registry.owner.toString(),
address: domainKey.toString(),
}
: null;
} catch {
return null;
}
}
async function getUserDomainAddresses(
connection: Connection,

View File

@ -23,7 +23,7 @@ indicatif = "0.16.2"
lazy_static = "1.4.0"
nix = "0.23.1"
reqwest = { version = "0.11.10", default-features = false, features = ["blocking", "rustls-tls", "json"] }
semver = "1.0.7"
semver = "1.0.6"
serde = { version = "1.0.136", features = ["derive"] }
serde_yaml = "0.8.23"
solana-clap-utils = { path = "../clap-utils", version = "=1.11.0" }

View File

@ -892,7 +892,7 @@ pub fn confirm_slot(
) -> result::Result<(), BlockstoreProcessorError> {
let slot = bank.slot();
let slot_entries_load_result = {
let (entries, num_shreds, slot_full) = {
let mut load_elapsed = Measure::start("load_elapsed");
let load_result = blockstore
.get_slot_entries_with_shred_info(slot, progress.num_shreds, allow_dead_slots)
@ -906,35 +906,6 @@ pub fn confirm_slot(
load_result
}?;
confirm_slot_entries(
bank,
slot_entries_load_result,
timing,
progress,
skip_verification,
transaction_status_sender,
replay_vote_sender,
transaction_cost_metrics_sender,
entry_callback,
recyclers,
)
}
#[allow(clippy::too_many_arguments)]
fn confirm_slot_entries(
bank: &Arc<Bank>,
slot_entries_load_result: (Vec<Entry>, u64, bool),
timing: &mut ConfirmationTiming,
progress: &mut ConfirmationProgress,
skip_verification: bool,
transaction_status_sender: Option<&TransactionStatusSender>,
replay_vote_sender: Option<&ReplayVoteSender>,
transaction_cost_metrics_sender: Option<&TransactionCostMetricsSender>,
entry_callback: Option<&ProcessCallback>,
recyclers: &VerifyRecyclers,
) -> result::Result<(), BlockstoreProcessorError> {
let slot = bank.slot();
let (entries, num_shreds, slot_full) = slot_entries_load_result;
let num_entries = entries.len();
let num_txs = entries.iter().map(|e| e.transactions.len()).sum::<usize>();
trace!(
@ -3909,108 +3880,4 @@ pub mod tests {
8
);
}
fn confirm_slot_entries_for_tests(
bank: &Arc<Bank>,
slot_entries: Vec<Entry>,
slot_full: bool,
prev_entry_hash: Hash,
) -> result::Result<(), BlockstoreProcessorError> {
confirm_slot_entries(
bank,
(slot_entries, 0, slot_full),
&mut ConfirmationTiming::default(),
&mut ConfirmationProgress::new(prev_entry_hash),
false,
None,
None,
None,
None,
&VerifyRecyclers::default(),
)
}
#[test]
fn test_confirm_slot_entries() {
const HASHES_PER_TICK: u64 = 10;
const TICKS_PER_SLOT: u64 = 2;
let collector_id = Pubkey::new_unique();
let GenesisConfigInfo {
mut genesis_config,
mint_keypair,
..
} = create_genesis_config(10_000);
genesis_config.poh_config.hashes_per_tick = Some(HASHES_PER_TICK);
genesis_config.ticks_per_slot = TICKS_PER_SLOT;
let genesis_hash = genesis_config.hash();
let slot_0_bank = Arc::new(Bank::new_for_tests(&genesis_config));
assert_eq!(slot_0_bank.slot(), 0);
assert_eq!(slot_0_bank.tick_height(), 0);
assert_eq!(slot_0_bank.max_tick_height(), 2);
assert_eq!(slot_0_bank.last_blockhash(), genesis_hash);
assert_eq!(slot_0_bank.get_hash_age(&genesis_hash), Some(0));
let slot_0_entries = entry::create_ticks(TICKS_PER_SLOT, HASHES_PER_TICK, genesis_hash);
let slot_0_hash = slot_0_entries.last().unwrap().hash;
confirm_slot_entries_for_tests(&slot_0_bank, slot_0_entries, true, genesis_hash).unwrap();
assert_eq!(slot_0_bank.tick_height(), slot_0_bank.max_tick_height());
assert_eq!(slot_0_bank.last_blockhash(), slot_0_hash);
assert_eq!(slot_0_bank.get_hash_age(&genesis_hash), Some(1));
assert_eq!(slot_0_bank.get_hash_age(&slot_0_hash), Some(0));
let slot_2_bank = Arc::new(Bank::new_from_parent(&slot_0_bank, &collector_id, 2));
assert_eq!(slot_2_bank.slot(), 2);
assert_eq!(slot_2_bank.tick_height(), 2);
assert_eq!(slot_2_bank.max_tick_height(), 6);
assert_eq!(slot_2_bank.last_blockhash(), slot_0_hash);
let slot_1_entries = entry::create_ticks(TICKS_PER_SLOT, HASHES_PER_TICK, slot_0_hash);
let slot_1_hash = slot_1_entries.last().unwrap().hash;
confirm_slot_entries_for_tests(&slot_2_bank, slot_1_entries, false, slot_0_hash).unwrap();
assert_eq!(slot_2_bank.tick_height(), 4);
assert_eq!(slot_2_bank.last_blockhash(), slot_1_hash);
assert_eq!(slot_2_bank.get_hash_age(&genesis_hash), Some(2));
assert_eq!(slot_2_bank.get_hash_age(&slot_0_hash), Some(1));
assert_eq!(slot_2_bank.get_hash_age(&slot_1_hash), Some(0));
// Check that slot 2 transactions can use any previous slot hash, including the
// hash for slot 1 which is just ticks.
let slot_2_entries = {
let to_pubkey = Pubkey::new_unique();
let mut prev_entry_hash = slot_1_hash;
let mut remaining_entry_hashes = HASHES_PER_TICK;
let mut entries: Vec<Entry> = [genesis_hash, slot_0_hash, slot_1_hash]
.into_iter()
.map(|recent_hash| {
let tx =
system_transaction::transfer(&mint_keypair, &to_pubkey, 1, recent_hash);
remaining_entry_hashes = remaining_entry_hashes.checked_sub(1).unwrap();
next_entry_mut(&mut prev_entry_hash, 1, vec![tx])
})
.collect();
entries.push(next_entry_mut(
&mut prev_entry_hash,
remaining_entry_hashes,
vec![],
));
entries.push(next_entry_mut(
&mut prev_entry_hash,
HASHES_PER_TICK,
vec![],
));
entries
};
let slot_2_hash = slot_2_entries.last().unwrap().hash;
confirm_slot_entries_for_tests(&slot_2_bank, slot_2_entries, true, slot_1_hash).unwrap();
assert_eq!(slot_2_bank.tick_height(), slot_2_bank.max_tick_height());
assert_eq!(slot_2_bank.last_blockhash(), slot_2_hash);
assert_eq!(slot_2_bank.get_hash_age(&genesis_hash), Some(3));
assert_eq!(slot_2_bank.get_hash_age(&slot_0_hash), Some(2));
assert_eq!(slot_2_bank.get_hash_age(&slot_1_hash), Some(1));
assert_eq!(slot_2_bank.get_hash_age(&slot_2_hash), Some(0));
}
}

View File

@ -1199,7 +1199,6 @@ pub fn mock_process_instruction(
transaction_accounts: Vec<TransactionAccount>,
instruction_accounts: Vec<AccountMeta>,
sysvar_cache_override: Option<&SysvarCache>,
feature_set_override: Option<Arc<FeatureSet>>,
expected_result: Result<(), InstructionError>,
process_instruction: ProcessInstructionWithContext,
) -> Vec<AccountSharedData> {
@ -1219,9 +1218,6 @@ pub fn mock_process_instruction(
if let Some(sysvar_cache) = sysvar_cache_override {
invoke_context.sysvar_cache = Cow::Borrowed(sysvar_cache);
}
if let Some(feature_set) = feature_set_override {
invoke_context.feature_set = feature_set;
}
let result = invoke_context
.push(
&preparation.instruction_accounts,

View File

@ -9,7 +9,7 @@ version = "1.11.0"
[dependencies]
assert_matches = "1.5.0"
async-trait = "0.1.53"
async-trait = "0.1.52"
base64 = "0.13.0"
bincode = "1.3.3"
chrono-humanize = "0.2.1"

174
programs/bpf/Cargo.lock generated
View File

@ -136,13 +136,13 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.53"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -277,8 +277,8 @@ dependencies = [
"borsh-derive-internal",
"borsh-schema-derive-internal",
"proc-macro-crate",
"proc-macro2 1.0.36",
"syn 1.0.91",
"proc-macro2 1.0.24",
"syn 1.0.67",
]
[[package]]
@ -287,9 +287,9 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -298,9 +298,9 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -346,9 +346,9 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -597,9 +597,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.4"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
checksum = "fdbfe11fe19ff083c48923cf179540e8cd0535903dc35e178a1fdeeb59aef51f"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@ -733,9 +733,9 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -873,9 +873,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f86b50932a01e7ec5c06160492ab660fb19b6bb2a7878030dd6cd68d21df9d4d"
dependencies = [
"enum-ordinalize",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -923,9 +923,9 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -936,9 +936,9 @@ checksum = "0b166c9e378360dd5a6666a9604bb4f54ae0cac39023ffbac425e917a2a04fef"
dependencies = [
"num-bigint",
"num-traits",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -1103,9 +1103,9 @@ version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -1763,9 +1763,9 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a7d5f7076603ebc68de2dc6a650ec331a062a13abaa346975be747bbfa4b789"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -1818,9 +1818,9 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -1869,9 +1869,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -1952,9 +1952,9 @@ checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82"
dependencies = [
"Inflector",
"proc-macro-error",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -2028,9 +2028,9 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -2108,9 +2108,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
"version_check",
]
@ -2120,7 +2120,7 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"version_check",
]
@ -2136,9 +2136,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.36"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid 0.2.0",
]
@ -2221,7 +2221,7 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
]
[[package]]
@ -2484,7 +2484,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.7",
"semver 1.0.6",
]
[[package]]
@ -2581,9 +2581,9 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdbda6ac5cd1321e724fa9cee216f3a61885889b896f073b8f82322789c5250e"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -2630,9 +2630,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.7"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
[[package]]
name = "semver-parser"
@ -2664,9 +2664,9 @@ version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -3336,7 +3336,7 @@ dependencies = [
"humantime",
"indicatif",
"pretty-hex",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_json",
"solana-account-decoder",
@ -3376,7 +3376,7 @@ dependencies = [
"rayon",
"reqwest",
"rustls",
"semver 1.0.7",
"semver 1.0.6",
"serde",
"serde_derive",
"serde_json",
@ -3487,20 +3487,20 @@ version = "1.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceac6e8ad1a784c92ff5f3d6ad68a8d664d389b08055b674c38b2b9abb69e6d4"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustc_version 0.2.3",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
name = "solana-frozen-abi-macro"
version = "1.11.0"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustc_version 0.4.0",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -3728,7 +3728,7 @@ dependencies = [
"num-traits",
"parking_lot",
"qstring",
"semver 1.0.7",
"semver 1.0.6",
"solana-sdk",
"thiserror",
"uriparse",
@ -3844,10 +3844,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84710ce45a21cccd9f2b09d8e9aad529080bb2540f27b1253874b6e732b465b9"
dependencies = [
"bs58 0.3.1",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustversion",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -3855,10 +3855,10 @@ name = "solana-sdk-macro"
version = "1.11.0"
dependencies = [
"bs58 0.4.0",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustversion",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -4133,11 +4133,11 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.91"
version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"unicode-xid 0.2.0",
]
@ -4148,9 +4148,9 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
"unicode-xid 0.2.0",
]
@ -4195,9 +4195,9 @@ version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee42b4e559f17bce0385ebf511a7beb67d5cc33c12c96b7f4e9789919d9c10f"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -4263,9 +4263,9 @@ version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -4357,9 +4357,9 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -4465,9 +4465,9 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
]
[[package]]
@ -4678,9 +4678,9 @@ checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9"
[[package]]
name = "wasm-bindgen"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -4688,16 +4688,16 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
"wasm-bindgen-shared",
]
@ -4715,9 +4715,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [
"quote 1.0.6",
"wasm-bindgen-macro-support",
@ -4725,22 +4725,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.80"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
[[package]]
name = "web-sys"
@ -4896,9 +4896,9 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdff2024a851a322b08f179173ae2ba620445aef1e838f0c196820eade4ae0c7"
dependencies = [
"proc-macro2 1.0.36",
"proc-macro2 1.0.24",
"quote 1.0.6",
"syn 1.0.91",
"syn 1.0.67",
"synstructure",
]

View File

@ -1326,7 +1326,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
expected_result,
super::process_instruction,
)
@ -1588,7 +1587,6 @@ mod tests {
vec![(program_id, program_account.clone())],
Vec::new(),
None,
None,
Err(InstructionError::ProgramFailedToComplete),
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
invoke_context
@ -2854,7 +2852,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
expected_result,
super::process_instruction,
)

View File

@ -169,7 +169,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
expected_result,
super::process_instruction,
)

View File

@ -538,7 +538,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
sysvar_cache_override,
None,
expected_result,
super::process_instruction,
)
@ -1924,8 +1923,7 @@ mod tests {
fn test_authorize_delegated_stake() {
let authority_address = solana_sdk::pubkey::new_rand();
let stake_address = solana_sdk::pubkey::new_rand();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let stake_lamports = 42;
let stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&StakeState::Initialized(Meta::auto(&stake_address)),
@ -2123,8 +2121,7 @@ mod tests {
vote_account_2
.set_state(&VoteStateVersions::new_current(vote_state))
.unwrap();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let stake_lamports = 42;
let stake_address = solana_sdk::pubkey::new_rand();
let mut stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
@ -2940,9 +2937,8 @@ mod tests {
fn test_withdraw_stake_before_warmup() {
let recipient_address = solana_sdk::pubkey::new_rand();
let stake_address = solana_sdk::pubkey::new_rand();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let total_lamports = stake_lamports + 33;
let stake_lamports = 42;
let total_lamports = 100;
let stake_account = AccountSharedData::new_data_with_space(
total_lamports,
&StakeState::Initialized(Meta::auto(&stake_address)),
@ -3292,8 +3288,7 @@ mod tests {
#[test]
fn test_deactivate() {
let stake_address = solana_sdk::pubkey::new_rand();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let stake_lamports = 42;
let stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&StakeState::Initialized(Meta::auto(&stake_address)),
@ -4403,7 +4398,6 @@ mod tests {
],
Ok(()),
);
transaction_accounts[0] = (stake_address, accounts[0].clone());
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
@ -6078,7 +6072,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
Ok(()),
|first_instruction_account, invoke_context| {
super::process_instruction(first_instruction_account, invoke_context)?;
@ -6201,13 +6194,6 @@ mod tests {
Err(InstructionError::NotEnoughAccountKeys),
),
] {
let mut feature_set = FeatureSet::all_enabled();
if !is_feature_enabled {
feature_set.deactivate(
&feature_set::add_get_minimum_delegation_instruction_to_stake_program::id(),
);
}
mock_process_instruction(
&id(),
Vec::new(),
@ -6215,9 +6201,19 @@ mod tests {
transaction_accounts.clone(),
instruction_accounts.clone(),
None,
Some(Arc::new(feature_set)),
expected_result,
super::process_instruction,
if is_feature_enabled {
|first_instruction_account, invoke_context| {
super::process_instruction(first_instruction_account, invoke_context)
}
} else {
|first_instruction_account, invoke_context| {
let mut feature_set = FeatureSet::all_enabled();
feature_set.deactivate(&feature_set::add_get_minimum_delegation_instruction_to_stake_program::id());
invoke_context.feature_set = Arc::new(feature_set);
super::process_instruction(first_instruction_account, invoke_context)
}
},
);
}
}

View File

@ -203,7 +203,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
expected_result,
super::process_instruction,
)
@ -222,9 +221,11 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
Some(std::sync::Arc::new(FeatureSet::default())),
expected_result,
super::process_instruction,
|first_instruction_account: usize, invoke_context: &mut InvokeContext| {
invoke_context.feature_set = std::sync::Arc::new(FeatureSet::default());
super::process_instruction(first_instruction_account, invoke_context)
},
)
}

View File

@ -7175,8 +7175,6 @@ impl AccountsDb {
timings.report();
}
self.accounts_index.log_secondary_indexes();
IndexGenerationInfo {
accounts_data_len: accounts_data_len.load(Ordering::Relaxed),
}

View File

@ -1408,22 +1408,6 @@ impl<T: IndexValue> AccountsIndex<T> {
}
}
/// log any secondary index counts, if non-zero
pub(crate) fn log_secondary_indexes(&self) {
if !self.program_id_index.index.is_empty() {
info!("secondary index: {:?}", AccountIndex::ProgramId);
self.program_id_index.log_contents();
}
if !self.spl_token_mint_index.index.is_empty() {
info!("secondary index: {:?}", AccountIndex::SplTokenMint);
self.spl_token_mint_index.log_contents();
}
if !self.spl_token_owner_index.index.is_empty() {
info!("secondary index: {:?}", AccountIndex::SplTokenOwner);
self.spl_token_owner_index.log_contents();
}
}
pub(crate) fn update_secondary_indexes(
&self,
pubkey: &Pubkey,

View File

@ -93,8 +93,8 @@ use {
account_utils::StateMut,
clock::{
BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND,
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
SECONDS_PER_DAY,
INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES,
MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY,
},
ed25519_program,
epoch_info::EpochInfo,
@ -1252,6 +1252,12 @@ pub struct Bank {
pub fee_structure: FeeStructure,
}
impl Default for BlockhashQueue {
fn default() -> Self {
Self::new(MAX_RECENT_BLOCKHASHES)
}
}
struct VoteWithStakeDelegations {
vote_state: Arc<VoteState>,
vote_account: AccountSharedData,
@ -3724,10 +3730,6 @@ impl Bank {
.collect()
}
pub fn get_hash_age(&self, hash: &Hash) -> Option<u64> {
self.blockhash_queue.read().unwrap().get_hash_age(hash)
}
pub fn check_hash_age(&self, hash: &Hash, max_age: usize) -> Option<bool> {
self.blockhash_queue
.read()
@ -6852,7 +6854,7 @@ pub(crate) mod tests {
solana_sdk::{
account::Account,
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT, MAX_RECENT_BLOCKHASHES},
clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT},
compute_budget::ComputeBudgetInstruction,
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
feature::Feature,

View File

@ -2,9 +2,7 @@
use solana_sdk::sysvar::recent_blockhashes;
use {
serde::{Deserialize, Serialize},
solana_sdk::{
clock::MAX_RECENT_BLOCKHASHES, fee_calculator::FeeCalculator, hash::Hash, timing::timestamp,
},
solana_sdk::{fee_calculator::FeeCalculator, hash::Hash, timing::timestamp},
std::collections::HashMap,
};
@ -31,12 +29,6 @@ pub struct BlockhashQueue {
max_age: usize,
}
impl Default for BlockhashQueue {
fn default() -> Self {
Self::new(MAX_RECENT_BLOCKHASHES)
}
}
impl BlockhashQueue {
pub fn new(max_age: usize) -> Self {
Self {

View File

@ -208,72 +208,14 @@ Every highest_root >= 432k * 2 + 80 and < 432k * 3 + 80 is this same result
*/
/// specify a slot
/// and keep track of epoch info for that slot
/// The idea is that algorithms often iterate over a storage slot or over a max/bank slot.
/// The epoch info for that slot will be fixed for many pubkeys, so save the calculated results.
/// There are 2 slots required for rent collection algorithms. Some callers have storage slot fixed
/// while others have max/bank slot fixed. 'epoch_info' isn't always needed, so it is optionally
/// specified by caller and only used by callee if necessary.
#[allow(dead_code)]
#[derive(Default, Copy, Clone)]
pub struct SlotInfoInEpoch {
/// the slot
slot: Slot,
/// possible info about this slot
epoch_info: Option<SlotInfoInEpochInner>,
}
/// epoch info for a slot
#[allow(dead_code)]
#[derive(Default, Copy, Clone)]
pub struct SlotInfoInEpochInner {
/// epoch of the slot
epoch: Epoch,
/// partition index of the slot within the epoch
partition_index: PartitionIndex,
/// number of slots in this epoch
slots_in_epoch: Slot,
}
#[allow(dead_code)]
impl SlotInfoInEpoch {
/// create, populating epoch info
pub fn new(slot: Slot, epoch_schedule: &EpochSchedule) -> Self {
let mut result = Self::new_small(slot);
result.epoch_info = Some(result.get_epoch_info(epoch_schedule));
result
}
/// create, without populating epoch info
pub fn new_small(slot: Slot) -> Self {
SlotInfoInEpoch {
slot,
..SlotInfoInEpoch::default()
}
}
/// get epoch info by returning already calculated or by calculating it now
pub fn get_epoch_info(&self, epoch_schedule: &EpochSchedule) -> SlotInfoInEpochInner {
if let Some(inner) = &self.epoch_info {
*inner
} else {
let (epoch, partition_index) = epoch_schedule.get_epoch_and_slot_index(self.slot);
SlotInfoInEpochInner {
epoch,
partition_index,
slots_in_epoch: epoch_schedule.get_slots_in_epoch(epoch),
}
}
}
}
impl ExpectedRentCollection {
#[allow(dead_code)]
/// 'account' is being loaded from 'storage_slot' in 'bank_slot'
/// adjusts 'account.rent_epoch' if we skipped the last rewrite on this account
pub fn maybe_update_rent_epoch_on_load(
account: &mut AccountSharedData,
storage_slot: &SlotInfoInEpoch,
bank_slot: &SlotInfoInEpoch,
storage_slot: Slot,
bank_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
pubkey: &Pubkey,
@ -299,8 +241,8 @@ impl ExpectedRentCollection {
/// returns None if the account is up to date
fn get_corrected_rent_epoch_on_load(
account: &AccountSharedData,
storage_slot: &SlotInfoInEpoch,
bank_slot: &SlotInfoInEpoch,
storage_slot: Slot,
bank_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
pubkey: &Pubkey,
@ -314,15 +256,14 @@ impl ExpectedRentCollection {
return None;
}
// grab epoch infno for bank slot and storage slot
let bank_info = bank_slot.get_epoch_info(epoch_schedule);
let (current_epoch, partition_from_current_slot) =
(bank_info.epoch, bank_info.partition_index);
let storage_info = storage_slot.get_epoch_info(epoch_schedule);
epoch_schedule.get_epoch_and_slot_index(bank_slot);
let (storage_epoch, storage_slot_partition) =
(storage_info.epoch, storage_info.partition_index);
let partition_from_pubkey =
Bank::partition_from_pubkey(pubkey, bank_info.slots_in_epoch);
epoch_schedule.get_epoch_and_slot_index(storage_slot);
let partition_from_pubkey = Bank::partition_from_pubkey(
pubkey,
epoch_schedule.get_slots_in_epoch(current_epoch),
);
let mut possibly_update = true;
if current_epoch == storage_epoch {
// storage is in same epoch as bank
@ -347,13 +288,13 @@ impl ExpectedRentCollection {
.contains_key(pubkey)
};
let rent_epoch = account.rent_epoch();
if possibly_update && rent_epoch == 0 && current_epoch > 1 {
if rewrites_skipped_this_pubkey_this_slot() {
return Some(next_epoch);
} else {
// we know we're done
return None;
}
if possibly_update
&& rent_epoch == 0
&& current_epoch > 1
&& !rewrites_skipped_this_pubkey_this_slot()
{
// we know we're done
return None;
}
// if an account was written >= its rent collection slot within the last epoch worth of slots, then we don't want to update it here
@ -1167,87 +1108,77 @@ pub mod tests {
one run without skipping slot 8470, once WITH skipping slot 8470
*/
for new_small in [false, true] {
for rewrite_already in [false, true] {
// starting at epoch = 0 has issues because of rent_epoch=0 special casing
for epoch in 1..4 {
for partition_index_bank_slot in
partition_from_pubkey - 1..=partition_from_pubkey + 2
{
let bank_slot =
slots_per_epoch * epoch + first_normal_slot + partition_index_bank_slot;
if storage_slot > bank_slot {
continue; // illegal combination
}
rent_collector.epoch = epoch_schedule.get_epoch(bank_slot);
let first_slot_in_max_epoch = bank_slot - bank_slot % slots_per_epoch;
assert_eq!(
(epoch, partition_index_bank_slot),
epoch_schedule.get_epoch_and_slot_index(bank_slot)
);
assert_eq!(
(epoch, 0),
epoch_schedule.get_epoch_and_slot_index(first_slot_in_max_epoch)
);
account.set_rent_epoch(1);
let rewrites = Rewrites::default();
if rewrite_already {
if partition_index_bank_slot != partition_from_pubkey {
// this is an invalid test occurrence.
// we wouldn't have inserted pubkey into 'rewrite_already' for this slot if the current partition index wasn't at the pubkey's partition idnex yet.
continue;
}
rewrites.write().unwrap().insert(pubkey, Hash::default());
}
let expected_new_rent_epoch =
if partition_index_bank_slot > partition_from_pubkey {
if epoch > account.rent_epoch() {
Some(rent_collector.epoch)
} else {
None
}
} else if partition_index_bank_slot == partition_from_pubkey
&& rewrite_already
{
let expected_rent_epoch = rent_collector.epoch;
if expected_rent_epoch == account.rent_epoch() {
None
} else {
Some(expected_rent_epoch)
}
} else if partition_index_bank_slot <= partition_from_pubkey
&& epoch > account.rent_epoch()
{
let expected_rent_epoch = rent_collector.epoch.saturating_sub(1);
if expected_rent_epoch == account.rent_epoch() {
None
} else {
Some(expected_rent_epoch)
}
} else {
None
};
let get_slot_info = |slot| {
if new_small {
SlotInfoInEpoch::new_small(slot)
} else {
SlotInfoInEpoch::new(slot, &epoch_schedule)
}
};
let new_rent_epoch =
ExpectedRentCollection::get_corrected_rent_epoch_on_load(
&account,
&get_slot_info(storage_slot),
&get_slot_info(bank_slot),
&epoch_schedule,
&rent_collector,
&pubkey,
&rewrites,
);
assert_eq!(new_rent_epoch, expected_new_rent_epoch);
for rewrite_already in [false, true] {
// starting at epoch = 0 has issues because of rent_epoch=0 special casing
for epoch in 1..4 {
for partition_index_bank_slot in
partition_from_pubkey - 1..=partition_from_pubkey + 2
{
let bank_slot =
slots_per_epoch * epoch + first_normal_slot + partition_index_bank_slot;
if storage_slot > bank_slot {
continue; // illegal combination
}
rent_collector.epoch = epoch_schedule.get_epoch(bank_slot);
let first_slot_in_max_epoch = bank_slot - bank_slot % slots_per_epoch;
assert_eq!(
(epoch, partition_index_bank_slot),
epoch_schedule.get_epoch_and_slot_index(bank_slot)
);
assert_eq!(
(epoch, 0),
epoch_schedule.get_epoch_and_slot_index(first_slot_in_max_epoch)
);
account.set_rent_epoch(1);
let rewrites = Rewrites::default();
if rewrite_already {
if partition_index_bank_slot != partition_from_pubkey {
// this is an invalid test occurrence.
// we wouldn't have inserted pubkey into 'rewrite_already' for this slot if the current partition index wasn't at the pubkey's partition idnex yet.
continue;
}
rewrites.write().unwrap().insert(pubkey, Hash::default());
}
let expected_new_rent_epoch = if partition_index_bank_slot
> partition_from_pubkey
{
if epoch > account.rent_epoch() {
Some(rent_collector.epoch)
} else {
None
}
} else if partition_index_bank_slot == partition_from_pubkey && rewrite_already
{
let expected_rent_epoch = rent_collector.epoch;
if expected_rent_epoch == account.rent_epoch() {
None
} else {
Some(expected_rent_epoch)
}
} else if partition_index_bank_slot <= partition_from_pubkey
&& epoch > account.rent_epoch()
{
let expected_rent_epoch = rent_collector.epoch.saturating_sub(1);
if expected_rent_epoch == account.rent_epoch() {
None
} else {
Some(expected_rent_epoch)
}
} else {
None
};
let new_rent_epoch = ExpectedRentCollection::get_corrected_rent_epoch_on_load(
&account,
storage_slot,
bank_slot,
&epoch_schedule,
&rent_collector,
&pubkey,
&rewrites,
);
assert_eq!(new_rent_epoch, expected_new_rent_epoch);
}
}
}

View File

@ -1,6 +1,5 @@
use {
dashmap::{mapref::entry::Entry::Occupied, DashMap},
log::*,
solana_sdk::{pubkey::Pubkey, timing::AtomicInterval},
std::{
collections::HashSet,
@ -224,19 +223,4 @@ impl<SecondaryIndexEntryType: SecondaryIndexEntry + Default + Sync + Send>
vec![]
}
}
/// log top 20 (owner, # accounts) in descending order of # accounts
pub fn log_contents(&self) {
let mut entries = self
.index
.iter()
.map(|entry| (entry.value().len(), *entry.key()))
.collect::<Vec<_>>();
entries.sort_unstable();
entries
.iter()
.rev()
.take(20)
.for_each(|(v, k)| info!("owner: {}, accounts: {}", k, v));
}
}

View File

@ -531,7 +531,6 @@ mod tests {
transaction_accounts,
instruction_accounts,
None,
None,
expected_result,
process_instruction,
)

View File

@ -38,19 +38,6 @@ example_helloworld() {
spl() {
(
# Mind the order!
PROGRAMS=(
token/program
token/program-2022
token/program-2022-test
associated-token-account/program
feature-proposal/program
governance/addin-mock/program
governance/program
memo/program
name-service/program
stake-pool/program
)
set -x
rm -rf spl
git clone https://github.com/solana-labs/solana-program-library.git spl
@ -58,15 +45,10 @@ spl() {
./patch.crates-io.sh "$solana_dir"
for program in "${PROGRAMS[@]}"; do
$cargo_test_bpf --manifest-path "$program"/Cargo.toml
done
# TODO better: `build.rs` for spl-token-cli doesn't seem to properly build
# the required programs to run the tests, so instead we run the tests
# after we know programs have been built
$cargo build
$cargo test
$cargo_build_bpf
$cargo_test_bpf
)
}

View File

@ -29,7 +29,6 @@ struct Config<'a> {
offline: bool,
verbose: bool,
workspace: bool,
jobs: Option<String>,
}
impl Default for Config<'_> {
@ -52,7 +51,6 @@ impl Default for Config<'_> {
offline: false,
verbose: false,
workspace: false,
jobs: None,
}
}
}
@ -547,10 +545,6 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m
if config.verbose {
cargo_build_args.push("--verbose");
}
if let Some(jobs) = &config.jobs {
cargo_build_args.push("--jobs");
cargo_build_args.push(jobs);
}
if let Some(args) = &config.cargo_args {
for arg in args {
cargo_build_args.push(arg);
@ -799,15 +793,6 @@ fn main() {
.alias("all")
.help("Build all BPF packages in the workspace"),
)
.arg(
Arg::new("jobs")
.short('j')
.long("jobs")
.takes_value(true)
.value_name("N")
.validator(|val| val.parse::<usize>().map_err(|e| e.to_string()))
.help("Number of parallel jobs, defaults to # of CPUs"),
)
.get_matches_from(args);
let bpf_sdk: PathBuf = matches.value_of_t_or_exit("bpf_sdk");
@ -842,7 +827,6 @@ fn main() {
offline: matches.is_present("offline"),
verbose: matches.is_present("verbose"),
workspace: matches.is_present("workspace"),
jobs: matches.value_of_t("jobs").ok(),
};
let manifest_path: Option<PathBuf> = matches.value_of_t("manifest_path").ok();
build_bpf(config, manifest_path);

View File

@ -24,7 +24,6 @@ struct Config {
offline: bool,
verbose: bool,
workspace: bool,
jobs: Option<String>,
}
impl Default for Config {
@ -43,7 +42,6 @@ impl Default for Config {
offline: false,
verbose: false,
workspace: false,
jobs: None,
}
}
}
@ -118,10 +116,6 @@ fn test_bpf_package(config: &Config, target_directory: &Path, package: &cargo_me
if config.verbose {
cargo_args.push("--verbose");
}
if let Some(jobs) = &config.jobs {
cargo_args.push("--jobs");
cargo_args.push(jobs);
}
let mut build_bpf_args = cargo_args.clone();
if let Some(bpf_sdk) = config.bpf_sdk.as_ref() {
@ -300,15 +294,6 @@ fn main() {
.alias("all")
.help("Test all BPF packages in the workspace"),
)
.arg(
Arg::new("jobs")
.short('j')
.long("jobs")
.takes_value(true)
.value_name("N")
.validator(|val| val.parse::<usize>().map_err(|e| e.to_string()))
.help("Number of parallel jobs, defaults to # of CPUs"),
)
.arg(
Arg::new("extra_cargo_test_args")
.value_name("extra args for cargo test and the test binary")
@ -334,7 +319,6 @@ fn main() {
offline: matches.is_present("offline"),
verbose: matches.is_present("verbose"),
workspace: matches.is_present("workspace"),
jobs: matches.value_of_t("jobs").ok(),
..Config::default()
};

View File

@ -198,10 +198,6 @@ impl Parse for RespanInput {
respan_using: ident.span(),
})
}
TokenTree::Ident(i) => Ok(RespanInput {
to_respan,
respan_using: i.span(),
}),
val => Err(syn::Error::new_spanned(
val,
"expected None-delimited group",

View File

@ -69,9 +69,9 @@ pub fn sol_memcmp(s1: &[u8], s2: &[u8], n: usize) -> i32 {
/// Memset
///
/// @param s - Slice to be set
/// @param c - Repeated byte to set
/// @param n - Number of bytes to set
/// @param s1 - Slice to be compared
/// @param s2 - Slice to be compared
/// @param n - Number of bytes to compare
#[inline]
pub fn sol_memset(s: &mut [u8], c: u8, n: usize) {
#[cfg(target_arch = "bpf")]

View File

@ -3,6 +3,3 @@ pub const QUIC_PORT_OFFSET: u16 = 6;
// that seems to maximize TPS on GCE (higher values don't seem to
// give significant improvement or seem to impact stability)
pub const QUIC_MAX_CONCURRENT_STREAMS: usize = 2048;
pub const QUIC_MAX_TIMEOUT_MS: u32 = 2_000;
pub const QUIC_KEEP_ALIVE_MS: u64 = 1_000;

View File

@ -3,12 +3,12 @@ use {
futures_util::stream::StreamExt,
pem::Pem,
pkcs8::{der::Document, AlgorithmIdentifier, ObjectIdentifier},
quinn::{Endpoint, EndpointConfig, IdleTimeout, IncomingUniStreams, ServerConfig, VarInt},
quinn::{Endpoint, EndpointConfig, IncomingUniStreams, ServerConfig},
rcgen::{CertificateParams, DistinguishedName, DnType, SanType},
solana_perf::packet::PacketBatch,
solana_sdk::{
packet::{Packet, PACKET_DATA_SIZE},
quic::{QUIC_MAX_CONCURRENT_STREAMS, QUIC_MAX_TIMEOUT_MS},
quic::QUIC_MAX_CONCURRENT_STREAMS,
signature::Keypair,
timing,
},
@ -18,7 +18,7 @@ use {
net::{IpAddr, SocketAddr, UdpSocket},
sync::{
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, RwLock,
Arc, Mutex,
},
thread,
time::{Duration, Instant},
@ -29,9 +29,6 @@ use {
},
};
pub const MAX_STAKED_CONNECTIONS: usize = 2000;
pub const MAX_UNSTAKED_CONNECTIONS: usize = 500;
/// Returns default server configuration along with its PEM certificate chain.
#[allow(clippy::field_reassign_with_default)] // https://github.com/rust-lang/rust-clippy/issues/6527
fn configure_server(
@ -58,8 +55,6 @@ fn configure_server(
config.max_concurrent_uni_streams(MAX_CONCURRENT_UNI_STREAMS.into());
config.stream_receive_window((PACKET_DATA_SIZE as u32).into());
config.receive_window((PACKET_DATA_SIZE as u32 * MAX_CONCURRENT_UNI_STREAMS).into());
let timeout = IdleTimeout::from(VarInt::from_u32(QUIC_MAX_TIMEOUT_MS));
config.max_idle_timeout(Some(timeout));
// disable bidi & datagrams
const MAX_CONCURRENT_BIDI_STREAMS: u32 = 0;
@ -404,9 +399,6 @@ pub fn spawn_server(
packet_sender: Sender<PacketBatch>,
exit: Arc<AtomicBool>,
max_connections_per_ip: usize,
staked_nodes: Arc<RwLock<HashMap<IpAddr, u64>>>,
max_staked_connections: usize,
max_unstaked_connections: usize,
) -> Result<thread::JoinHandle<()>, QuicServerError> {
let (config, _cert) = configure_server(keypair, gossip_host)?;
@ -424,8 +416,6 @@ pub fn spawn_server(
let mut last_datapoint = Instant::now();
let connection_table: Arc<Mutex<ConnectionTable>> =
Arc::new(Mutex::new(ConnectionTable::default()));
let staked_connection_table: Arc<Mutex<ConnectionTable>> =
Arc::new(Mutex::new(ConnectionTable::default()));
while !exit.load(Ordering::Relaxed) {
const WAIT_FOR_CONNECTION_TIMEOUT_MS: u64 = 1000;
let timeout_connection = timeout(
@ -451,21 +441,10 @@ pub fn spawn_server(
let remote_addr = connection.remote_address();
let mut connection_table_l =
if staked_nodes.read().unwrap().contains_key(&remote_addr.ip()) {
let mut connection_table_l =
staked_connection_table.lock().unwrap();
let num_pruned =
connection_table_l.prune_oldest(max_staked_connections);
stats.num_evictions.fetch_add(num_pruned, Ordering::Relaxed);
connection_table_l
} else {
let mut connection_table_l = connection_table.lock().unwrap();
let num_pruned =
connection_table_l.prune_oldest(max_unstaked_connections);
stats.num_evictions.fetch_add(num_pruned, Ordering::Relaxed);
connection_table_l
};
let mut connection_table_l = connection_table.lock().unwrap();
const MAX_CONNECTION_TABLE_SIZE: usize = 5000;
let num_pruned = connection_table_l.prune_oldest(MAX_CONNECTION_TABLE_SIZE);
stats.num_evictions.fetch_add(num_pruned, Ordering::Relaxed);
if let Some((last_update, stream_exit)) = connection_table_l
.try_add_connection(
@ -505,7 +484,6 @@ mod test {
super::*,
crossbeam_channel::unbounded,
quinn::{ClientConfig, NewConnection},
solana_sdk::quic::QUIC_KEEP_ALIVE_MS,
std::{net::SocketAddr, time::Instant},
};
@ -536,20 +514,17 @@ mod test {
.with_safe_defaults()
.with_custom_certificate_verifier(SkipServerVerification::new())
.with_no_client_auth();
let mut config = ClientConfig::new(Arc::new(crypto));
let transport_config = Arc::get_mut(&mut config.transport).unwrap();
let timeout = IdleTimeout::from(VarInt::from_u32(QUIC_MAX_TIMEOUT_MS));
transport_config.max_idle_timeout(Some(timeout));
transport_config.keep_alive_interval(Some(Duration::from_millis(QUIC_KEEP_ALIVE_MS)));
config
ClientConfig::new(Arc::new(crypto))
}
#[test]
fn test_quic_server_exit() {
let (t, exit, _receiver, _server_address) = setup_quic_server();
let s = UdpSocket::bind("127.0.0.1:0").unwrap();
let exit = Arc::new(AtomicBool::new(false));
let (sender, _receiver) = unbounded();
let keypair = Keypair::new();
let ip = "127.0.0.1".parse().unwrap();
let t = spawn_server(s, &keypair, ip, sender, exit.clone(), 1).unwrap();
exit.store(true, Ordering::Relaxed);
t.join().unwrap();
}
@ -565,43 +540,16 @@ mod test {
.unwrap()
}
#[test]
fn test_quic_timeout() {
solana_logger::setup();
let (t, exit, receiver, server_address) = setup_quic_server();
let runtime = rt();
let _rt_guard = runtime.enter();
let conn1 = make_client_endpoint(&runtime, &server_address);
let total = 30;
let handle = runtime.spawn(async move {
for i in 0..total {
let mut s1 = conn1.connection.open_uni().await.unwrap();
s1.write_all(&[0u8]).await.unwrap();
s1.finish().await.unwrap();
info!("done {}", i);
std::thread::sleep(Duration::from_millis(1000));
}
});
let mut received = 0;
loop {
if let Ok(_x) = receiver.recv_timeout(Duration::from_millis(500)) {
received += 1;
info!("got {}", received);
}
if received >= total {
break;
}
}
runtime.block_on(handle).unwrap();
exit.store(true, Ordering::Relaxed);
t.join().unwrap();
}
#[test]
fn test_quic_server_block_multiple_connections() {
solana_logger::setup();
let (t, exit, _receiver, server_address) = setup_quic_server();
let s = UdpSocket::bind("127.0.0.1:0").unwrap();
let exit = Arc::new(AtomicBool::new(false));
let (sender, _receiver) = unbounded();
let keypair = Keypair::new();
let ip = "127.0.0.1".parse().unwrap();
let server_address = s.local_addr().unwrap();
let t = spawn_server(s, &keypair, ip, sender, exit.clone(), 1).unwrap();
let runtime = rt();
let _rt_guard = runtime.enter();
@ -630,19 +578,7 @@ mod test {
let keypair = Keypair::new();
let ip = "127.0.0.1".parse().unwrap();
let server_address = s.local_addr().unwrap();
let staked_nodes = Arc::new(RwLock::new(HashMap::new()));
let t = spawn_server(
s,
&keypair,
ip,
sender,
exit.clone(),
2,
staked_nodes,
10,
10,
)
.unwrap();
let t = spawn_server(s, &keypair, ip, sender, exit.clone(), 2).unwrap();
let runtime = rt();
let _rt_guard = runtime.enter();
@ -688,38 +624,16 @@ mod test {
t.join().unwrap();
}
fn setup_quic_server() -> (
std::thread::JoinHandle<()>,
Arc<AtomicBool>,
crossbeam_channel::Receiver<PacketBatch>,
SocketAddr,
) {
#[test]
fn test_quic_server_multiple_writes() {
solana_logger::setup();
let s = UdpSocket::bind("127.0.0.1:0").unwrap();
let exit = Arc::new(AtomicBool::new(false));
let (sender, receiver) = unbounded();
let keypair = Keypair::new();
let ip = "127.0.0.1".parse().unwrap();
let server_address = s.local_addr().unwrap();
let staked_nodes = Arc::new(RwLock::new(HashMap::new()));
let t = spawn_server(
s,
&keypair,
ip,
sender,
exit.clone(),
1,
staked_nodes,
MAX_STAKED_CONNECTIONS,
MAX_UNSTAKED_CONNECTIONS,
)
.unwrap();
(t, exit, receiver, server_address)
}
#[test]
fn test_quic_server_multiple_writes() {
solana_logger::setup();
let (t, exit, receiver, server_address) = setup_quic_server();
let t = spawn_server(s, &keypair, ip, sender, exit.clone(), 1).unwrap();
let runtime = rt();
let _rt_guard = runtime.enter();

View File

@ -4,6 +4,7 @@
/deploy
/doc
/lib
/module.flow.js
/.eslintrc.js
/test/.eslintrc.js
/test/dist

11
web3.js/.flowconfig Normal file
View File

@ -0,0 +1,11 @@
[ignore]
[include]
[libs]
[lints]
[options]
[strict]

View File

@ -1,2 +1,3 @@
test/dist
module.flow.js
declarations

View File

@ -94,11 +94,10 @@ Example scripts for the Solana Program Library:
- [Token Program Examples](https://github.com/solana-labs/solana-program-library/tree/master/token/js/examples)
## Flow Support (Discontinued)
## Flow
Flow types are no longer supported in new releases. The last release with Flow support is v1.37.2 and its
[Flow library definition](https://flow.org/en/docs/libdefs/) is provided at
https://unpkg.com/@solana/web3.js@v1.37.2/module.flow.js.
A [Flow library definition](https://flow.org/en/docs/libdefs/) is provided at
https://unpkg.com/@solana/web3.js@latest/module.flow.js.
Download the file and add the following line under the [libs] section of your project's `.flowconfig` to
activate it:

View File

@ -63,6 +63,8 @@
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-prettier": "^4.0.0",
"esm": "^3.2.25",
"flow-bin": "^0.150.0",
"flowgen": "^1.13.0",
"http-server": "^14.0.0",
"mocha": "^8.2.1",
"mockttp": "^2.0.1",
@ -4960,6 +4962,15 @@
"node": ">=0.1.90"
}
},
"node_modules/commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"dev": true,
"engines": {
"node": ">= 6"
}
},
"node_modules/common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
@ -6901,6 +6912,50 @@
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
"dev": true
},
"node_modules/flow-bin": {
"version": "0.150.1",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.150.1.tgz",
"integrity": "sha512-YSAB7pJejm+8gTpucaQKrvD+Dvu1RdsAA+L/Vofn0AH1DS+vE2hBeUN+v2pcs5YJU0gjQUw9qO7j3w6KaaCglQ==",
"dev": true,
"bin": {
"flow": "cli.js"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/flowgen": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/flowgen/-/flowgen-1.17.0.tgz",
"integrity": "sha512-cV0ASM71xDIDlEmejjNlVXmXtGOPsbzCm9dtmd4Kbn5y2+onax1W9s1NFZH0c18PuGSfbWjkQdSzbWcHjX/poQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.16.7",
"@babel/highlight": "^7.16.7",
"commander": "^6.1.0",
"lodash": "^4.17.20",
"prettier": "^2.5.1",
"shelljs": "^0.8.4",
"typescript": "~4.4.4",
"typescript-compiler": "^1.4.1-2"
},
"bin": {
"flowgen": "lib/cli/index.js"
}
},
"node_modules/flowgen/node_modules/typescript": {
"version": "4.4.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
@ -7923,6 +7978,15 @@
"node": ">= 0.4"
}
},
"node_modules/interpret": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
"integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
"dev": true,
"engines": {
"node": ">= 0.10"
}
},
"node_modules/into-stream": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/into-stream/-/into-stream-6.0.0.tgz",
@ -10926,7 +10990,6 @@
},
"node_modules/npm/node_modules/debug/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"dev": true,
"inBundle": true,
"license": "MIT"
@ -12868,7 +12931,6 @@
},
"node_modules/npm/node_modules/string-width/node_modules/strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"dev": true,
"inBundle": true,
"license": "MIT",
@ -14612,6 +14674,18 @@
"node": ">=8.10.0"
}
},
"node_modules/rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"dev": true,
"dependencies": {
"resolve": "^1.1.6"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/redent": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz",
@ -15312,6 +15386,23 @@
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
"dev": true
},
"node_modules/shelljs": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz",
"integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==",
"dev": true,
"dependencies": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
},
"bin": {
"shjs": "bin/shjs"
},
"engines": {
"node": ">=4"
}
},
"node_modules/shiki": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz",
@ -16513,6 +16604,12 @@
"node": ">=4.2.0"
}
},
"node_modules/typescript-compiler": {
"version": "1.4.1-2",
"resolved": "https://registry.npmjs.org/typescript-compiler/-/typescript-compiler-1.4.1-2.tgz",
"integrity": "sha1-uk99si2RU0oZKdkACdzhYety/T8=",
"dev": true
},
"node_modules/uglify-js": {
"version": "3.15.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.3.tgz",
@ -20841,6 +20938,12 @@
"dev": true,
"optional": true
},
"commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"dev": true
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
@ -22369,6 +22472,36 @@
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
"dev": true
},
"flow-bin": {
"version": "0.150.1",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.150.1.tgz",
"integrity": "sha512-YSAB7pJejm+8gTpucaQKrvD+Dvu1RdsAA+L/Vofn0AH1DS+vE2hBeUN+v2pcs5YJU0gjQUw9qO7j3w6KaaCglQ==",
"dev": true
},
"flowgen": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/flowgen/-/flowgen-1.17.0.tgz",
"integrity": "sha512-cV0ASM71xDIDlEmejjNlVXmXtGOPsbzCm9dtmd4Kbn5y2+onax1W9s1NFZH0c18PuGSfbWjkQdSzbWcHjX/poQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.16.7",
"@babel/highlight": "^7.16.7",
"commander": "^6.1.0",
"lodash": "^4.17.20",
"prettier": "^2.5.1",
"shelljs": "^0.8.4",
"typescript": "~4.4.4",
"typescript-compiler": "^1.4.1-2"
},
"dependencies": {
"typescript": {
"version": "4.4.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==",
"dev": true
}
}
},
"follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
@ -23127,6 +23260,12 @@
"side-channel": "^1.0.4"
}
},
"interpret": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
"integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
"dev": true
},
"into-stream": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/into-stream/-/into-stream-6.0.0.tgz",
@ -25300,7 +25439,6 @@
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"bundled": true,
"dev": true
}
@ -26751,7 +26889,6 @@
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"bundled": true,
"dev": true,
"requires": {
@ -28150,6 +28287,15 @@
"picomatch": "^2.2.1"
}
},
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"dev": true,
"requires": {
"resolve": "^1.1.6"
}
},
"redent": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz",
@ -28700,6 +28846,17 @@
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
"dev": true
},
"shelljs": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz",
"integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==",
"dev": true,
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
}
},
"shiki": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz",
@ -29638,6 +29795,12 @@
"integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==",
"dev": true
},
"typescript-compiler": {
"version": "1.4.1-2",
"resolved": "https://registry.npmjs.org/typescript-compiler/-/typescript-compiler-1.4.1-2.tgz",
"integrity": "sha1-uk99si2RU0oZKdkACdzhYety/T8=",
"dev": true
},
"uglify-js": {
"version": "3.15.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.3.tgz",

View File

@ -33,15 +33,18 @@
],
"files": [
"/lib",
"/module.flow.js",
"/src"
],
"scripts": {
"build": "npm run clean; cross-env NODE_ENV=production rollup -c; npm run type:gen",
"build": "npm run clean; cross-env NODE_ENV=production rollup -c; npm run type:gen; npm run flow:gen; npm run flow:check",
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
"clean": "rimraf ./coverage ./lib",
"codecov": "set -ex; npm run test:cover; cat ./coverage/lcov.info | codecov",
"dev": "cross-env NODE_ENV=development rollup -c",
"doc": "set -ex; typedoc --treatWarningsAsErrors",
"flow:check": "flow check-contents < module.flow.js",
"flow:gen": "flowgen lib/index.d.ts -o module.flow.js",
"type:gen": "./scripts/typegen.sh",
"lint": "set -ex; npm run pretty; eslint . --ext .js,.ts",
"lint:fix": "npm run pretty:fix && eslint . --fix --ext .js,.ts",
@ -110,6 +113,8 @@
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-prettier": "^4.0.0",
"esm": "^3.2.25",
"flow-bin": "^0.150.0",
"flowgen": "^1.13.0",
"http-server": "^14.0.0",
"mocha": "^8.2.1",
"mockttp": "^2.0.1",

View File

@ -1,6 +1,6 @@
import bs58 from 'bs58';
import {Buffer} from 'buffer';
import crossFetch from 'cross-fetch';
import fetch from 'cross-fetch';
import {
type as pick,
number,
@ -814,11 +814,9 @@ function createRpcClient(
url: string,
useHttps: boolean,
httpHeaders?: HttpHeaders,
customFetch?: typeof crossFetch,
fetchMiddleware?: FetchMiddleware,
disableRetryOnRateLimit?: boolean,
): RpcClient {
const fetch = customFetch ? customFetch : crossFetch;
let agentManager: AgentManager | undefined;
if (!process.env.BROWSER) {
agentManager = new AgentManager(useHttps);
@ -2110,8 +2108,6 @@ export type ConnectionConfig = {
wsEndpoint?: string;
/** Optional HTTP headers object */
httpHeaders?: HttpHeaders;
/** Optional custom fetch function */
fetch?: typeof crossFetch;
/** Optional fetch middleware callback */
fetchMiddleware?: FetchMiddleware;
/** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
@ -2204,7 +2200,6 @@ export class Connection {
let wsEndpoint;
let httpHeaders;
let fetch;
let fetchMiddleware;
let disableRetryOnRateLimit;
if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
@ -2215,7 +2210,6 @@ export class Connection {
commitmentOrConfig.confirmTransactionInitialTimeout;
wsEndpoint = commitmentOrConfig.wsEndpoint;
httpHeaders = commitmentOrConfig.httpHeaders;
fetch = commitmentOrConfig.fetch;
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
}
@ -2227,7 +2221,6 @@ export class Connection {
url.toString(),
useHttps,
httpHeaders,
fetch,
fetchMiddleware,
disableRetryOnRateLimit,
);

File diff suppressed because it is too large Load Diff