Skip to content

Commit a5649d1

Browse files
authored
fix package spec (#109)
1 parent b2d503c commit a5649d1

File tree

21 files changed

+7277
-660
lines changed

21 files changed

+7277
-660
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ jobs:
7676
sudo apt install protobuf-compiler
7777
7878
- name: Run clippy
79-
run: cargo clippy --all-targets --tests --features "examples yellowstone-grpc" -- -Dwarnings
79+
run: cargo clippy --all-targets --tests --all-features -- -Dwarnings
8080

8181
- name: Test build
8282
run: |
83-
cargo build --features "examples yellowstone-grpc"
83+
cargo build --all-features

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.vscode
33
config-gentx-test.yml
44
.local
5-
.env
5+
.env
6+
target

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ members = [
33
"apps/jet",
44
"crates/tpu-client",
55
]
6+
exclude = [
7+
"examples/jet-tpu-sender",
8+
]
69
resolver = "2"
710

811
[workspace.package]
@@ -105,7 +108,7 @@ tonic-prost-build = "0.14.0"
105108
vergen = "9.0.1"
106109
tikv-jemallocator = "0.6.1"
107110
libc = "0.2.177"
108-
yellowstone-jet-tpu-client = { path = "crates/tpu-client", version = "0.1.0" }
111+
yellowstone-jet-tpu-client = { path = "crates/tpu-client", version = "0.1.0-rc1" }
109112

110113
[workspace.lints.clippy]
111114
clone_on_ref_ptr = "deny"

apps/jet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ tracing-subscriber = { workspace = true, features = ["ansi", "env-filter", "json
8585
uuid = { workspace = true, features = ["v4", "serde"] }
8686
yellowstone-grpc-client = { workspace = true }
8787
yellowstone-grpc-proto = { workspace = true }
88-
yellowstone-jet-tpu-client = { workspace = true, features = ["prometheus", "bytes", "yellowstone-grpc"] }
88+
yellowstone-jet-tpu-client = { workspace = true, features = ["prometheus", "yellowstone-grpc", "shield"] }
8989
yellowstone-shield-store = { workspace = true }
9090
tokio-util = { workspace = true }
9191
tikv-jemallocator = { workspace = true }

apps/jet/src/bin/jet.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ async fn run_jet(
348348
Arc::new(IgnorantLeaderPredictor)
349349
};
350350

351+
let (gateway_callback_tx, gateway_response_source) = tokio::sync::mpsc::unbounded_channel();
351352
let TpuSenderSessionContext {
352353
identity_updater: gateway_identity_updater,
353354
driver_tx_sink: gateway_tx_sink,
354-
driver_response_source: gateway_response_source,
355355
driver_join_handle: gateway_join_handle,
356356
} = quic_gateway_spawner.spawn(
357357
initial_identity.insecure_clone(),
@@ -360,6 +360,7 @@ async fn run_jet(
360360
peer_idle_eviction_grace_period: config.quic.connection_idle_eviction_grace,
361361
}),
362362
connection_predictor,
363+
Some(gateway_callback_tx),
363364
);
364365

365366
let ah = tg.spawn(async move {

apps/jet/src/bin/lite-jet.rs

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use {
88
},
99
solana_commitment_config::CommitmentConfig,
1010
solana_keypair::Keypair,
11-
solana_pubkey::Pubkey,
1211
solana_rpc_client::http_sender::HttpSender,
1312
std::{
1413
collections::HashMap,
@@ -43,11 +42,14 @@ use {
4342
transactions::SendTransactionRequest,
4443
util::WaitShutdown,
4544
},
46-
yellowstone_jet_tpu_client::yellowstone_grpc::sender::{
47-
Blocklist, Endpoints, NewYellowstoneTpuSender, YellowstoneTpuSender,
48-
create_yellowstone_tpu_sender,
45+
yellowstone_jet_tpu_client::{
46+
core::{TpuSenderResponse, TpuSenderResponseCallback},
47+
yellowstone_grpc::sender::{
48+
Endpoints, NewYellowstoneTpuSender, ShieldBlockList, YellowstoneTpuSender,
49+
create_yellowstone_tpu_sender_with_callback,
50+
},
4951
},
50-
yellowstone_shield_store::{PolicyStore, PolicyStoreTrait},
52+
yellowstone_shield_store::PolicyStore,
5153
};
5254

5355
#[cfg(not(target_env = "msvc"))]
@@ -194,18 +196,45 @@ async fn run_jet(
194196
grpc: config.upstream.grpc.endpoint.clone(),
195197
grpc_x_token: config.upstream.grpc.x_token.clone(),
196198
};
199+
#[derive(Clone)]
200+
struct LoggingCallback;
201+
202+
impl TpuSenderResponseCallback for LoggingCallback {
203+
fn call(&self, response: TpuSenderResponse) {
204+
use std::io::Write;
205+
let mut stdout = std::io::stdout();
206+
match response {
207+
TpuSenderResponse::TxSent(info) => {
208+
writeln!(
209+
&mut stdout,
210+
"Transaction {} send to {}",
211+
info.tx_sig, info.remote_peer_identity
212+
)
213+
.expect("writeln");
214+
}
215+
TpuSenderResponse::TxFailed(info) => {
216+
writeln!(&mut stdout, "Transaction failed: {}", info.tx_sig).expect("writeln");
217+
}
218+
TpuSenderResponse::TxDrop(info) => {
219+
for (txn, _) in info.dropped_tx_vec {
220+
writeln!(&mut stdout, "Transaction dropped: {}", txn.tx_sig)
221+
.expect("writeln");
222+
}
223+
}
224+
}
225+
}
226+
}
197227
let NewYellowstoneTpuSender {
198228
sender,
199229
related_objects_jh,
200-
response,
201-
} = create_yellowstone_tpu_sender(
230+
} = create_yellowstone_tpu_sender_with_callback(
202231
Default::default(),
203232
initial_identity.insecure_clone(),
204233
tpu_sender_endpoints,
234+
LoggingCallback,
205235
)
206236
.await
207237
.expect("yellowstone-tpu-sender");
208-
drop(response); // drop response handle, we don't need it
209238

210239
let ah = tg.spawn(async move {
211240
related_objects_jh
@@ -225,7 +254,12 @@ async fn run_jet(
225254
proxy_preflight_check: false,
226255
};
227256

228-
let ah = tg.spawn(tpu_sender_loop(scheduler_out, sender, shield_policy_store));
257+
let ah = tg.spawn(tpu_sender_loop(
258+
scheduler_out,
259+
sender,
260+
shield_policy_store,
261+
jet_cancellation_token.child_token(),
262+
));
229263

230264
tg_name_map.insert(ah.id(), "tpu_sender_loop".to_string());
231265

@@ -386,22 +420,12 @@ pub async fn tpu_sender_loop(
386420
mut incoming: UnboundedReceiver<Arc<SendTransactionRequest>>,
387421
mut tpu_sender: YellowstoneTpuSender,
388422
shield: Option<PolicyStore>,
423+
cancellation_token: CancellationToken,
389424
) {
390-
struct ShieldBlocklist<'a> {
391-
shield: &'a PolicyStore,
392-
policies: &'a [Pubkey],
393-
}
394-
395-
impl Blocklist for ShieldBlocklist<'_> {
396-
fn is_blocked(&self, account: &Pubkey) -> bool {
397-
self.shield
398-
.snapshot()
399-
.is_allowed(self.policies, account)
400-
.unwrap_or(true)
401-
}
402-
}
403-
404425
while let Some(request) = incoming.recv().await {
426+
if cancellation_token.is_cancelled() {
427+
break;
428+
}
405429
let request = Arc::unwrap_or_clone(request);
406430
let SendTransactionRequest {
407431
signature,
@@ -411,13 +435,14 @@ pub async fn tpu_sender_loop(
411435
policies,
412436
} = request;
413437

414-
let blocklist = shield.as_ref().map(|shield| ShieldBlocklist {
415-
shield,
416-
policies: &policies,
438+
let blocklist = shield.as_ref().map(|shield| ShieldBlockList {
439+
policy_store: shield,
440+
shield_policy_addresses: &policies,
441+
default_return_value: false,
417442
});
418443

419444
let result = tpu_sender
420-
.send_txn_with_blocklist(signature, wire_transaction, blocklist)
445+
.send_txn_fanout_with_blocklist(signature, wire_transaction, 2, blocklist)
421446
.await;
422447
if let Err(e) = result {
423448
tracing::error!(

apps/jet/src/transactions.rs

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -751,21 +751,10 @@ impl TransactionFanout {
751751
let lewis_handler = self.lewis_handler.clone();
752752
let extra_fwd = Arc::clone(&self.extra_fwd);
753753

754-
enum WireContainer {
755-
Bytes(Bytes),
756-
SharedVec(Arc<Vec<u8>>),
757-
}
758-
759754
let send_fut = async move {
760755
let next_leaders = leader_schedule_service.leader_lookahead(leader_fwd);
761756
let current_slot = leader_schedule_service.get_current_slot();
762-
763-
let txn_wire = if tx.wire_transaction.len() == tx.wire_transaction.capacity() {
764-
WireContainer::Bytes(Bytes::from(tx.wire_transaction))
765-
} else {
766-
WireContainer::SharedVec(Arc::new(tx.wire_transaction))
767-
};
768-
757+
let txn_wire = Bytes::from_owner(tx.wire_transaction);
769758
for dest in next_leaders.iter() {
770759
if !policy_store_service.is_allowed(&tx.policies, dest)? {
771760
// Report skip to Lewis
@@ -776,14 +765,7 @@ impl TransactionFanout {
776765
tracing::trace!("transaction {signature} is not allowed to be sent to {dest}");
777766
continue;
778767
}
779-
let tpu_txn = match &txn_wire {
780-
WireContainer::Bytes(b) => {
781-
TpuSenderTxn::from_bytes(tx.signature, *dest, b.clone())
782-
}
783-
WireContainer::SharedVec(v) => {
784-
TpuSenderTxn::from_shared_vec(tx.signature, *dest, Arc::clone(v))
785-
}
786-
};
768+
let tpu_txn = TpuSenderTxn::from_bytes(tx.signature, *dest, txn_wire.clone());
787769
tpu_sink
788770
.send(tpu_txn)
789771
.await
@@ -795,15 +777,7 @@ impl TransactionFanout {
795777
// We don't send it twice.
796778
continue;
797779
}
798-
// We don't apply policy here.
799-
let tpu_txn = match &txn_wire {
800-
WireContainer::Bytes(b) => {
801-
TpuSenderTxn::from_bytes(tx.signature, *extra, b.clone())
802-
}
803-
WireContainer::SharedVec(v) => {
804-
TpuSenderTxn::from_shared_vec(tx.signature, *extra, Arc::clone(v))
805-
}
806-
};
780+
let tpu_txn = TpuSenderTxn::from_bytes(tx.signature, *extra, txn_wire.clone());
807781

808782
tpu_sink
809783
.send(tpu_txn)

crates/tpu-client/Cargo.toml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,42 @@ authors.workspace = true
66
license.workspace = true
77
homepage.workspace = true
88
repository.workspace = true
9+
description = "Triton One Yellowstone Jet TPU Client"
10+
keywords = ["yellowstone", "solana", "rpc", "tpu", "quic"]
911
readme = "README.md"
12+
publish = true
13+
exclude = ["src/bin/*"]
14+
15+
[[bin]]
16+
name = "test-managed-schedule"
17+
path = "src/bin/test-managed-schedule.rs"
18+
publish = false
19+
20+
[[bin]]
21+
name = "test-tpu-info"
22+
path = "src/bin/test-tpu-info.rs"
23+
publish = false
24+
25+
[[bin]]
26+
name = "test-tpu-send"
27+
path = "src/bin/test-tpu-send.rs"
28+
publish = false
29+
30+
[[bin]]
31+
name = "test-slot-tracker"
32+
path = "src/bin/test-slot-tracker.rs"
1033
publish = false
1134

1235
[features]
13-
default = ["yellowstone-grpc", "bytes"]
36+
default = ["yellowstone-grpc"]
1437
prometheus = ["dep:prometheus"]
15-
bytes = ["dep:bytes"]
1638
examples = [
1739
"dep:dotenvy",
1840
"dep:tracing-subscriber",
1941
"dep:clap",
2042
"dep:solana-system-interface",
2143
"dep:solana-transaction",
44+
"dep:solana-hash",
2245
"dep:bincode",
2346
"yellowstone-grpc",
2447
]
@@ -35,7 +58,7 @@ base64 = { workspace = true }
3558
bincode = { workspace = true, optional = true }
3659
bs58 = { workspace = true }
3760
borsh = { workspace = true }
38-
bytes = { workspace = true, optional = true }
61+
bytes = { workspace = true }
3962
clap = { workspace = true, features = ["cargo", "derive", "env"], optional = true }
4063

4164
derive_more = { workspace = true, features = ["display"] }
@@ -64,6 +87,7 @@ solana-client = { workspace = true }
6487
solana-clock = { workspace = true }
6588
solana-commitment-config = { workspace = true }
6689
solana-epoch-info = { workspace = true }
90+
solana-hash = { workspace = true, optional = true }
6791
solana-instruction = { workspace = true }
6892
solana-keypair = { workspace = true }
6993
solana-message = { workspace = true }

0 commit comments

Comments
 (0)