2

I'm having some trouble utilizing TPU client (I want to send my transactions directly to TPU leaders instead of RPC url). The language is TypeScript and the package I'm using is https://www.npmjs.com/package/tpu-client

To test the client I tried sending 3 transactions, transfer of a small amount of SOL to one of my wallets. I ran the code and it returned these 3 transaction signatures:

2mTnzG5ujQN4MPiRnDoPwzMRKSPkJBjGVLjn8KLXC9GJKiQmJVASoYn6ye3z3CC6nQKTLo9SVkREnjHzqaG6nNU
3FbK9RYtGgaGstsQmhEqiqt6E9LqgzwLRofGutT95Xr2nwQ9Qd9BjRkR5fzTN2vE2Sg2q6e5NJYGnsdCN17hqZ2N
2b2LBu9EAAucsPv5Xv8Q7GFQDTRnYFVndkMfh9Pudn4RLG8HEihSXTuo1hDq1g1eaVedjUpr1warxLFYkHm2aXaa

Feel free to look any of these up on https://explorer.solana.com/.

Then, 1 minute later I ran exactly same code and got these 3 signatures

29KKa2qZVeu26nNVy4V7j3UJx5Wok5LRLQvonADXKZ3T1ra1KmVxLB7o2emZjg8u633bjJhJfPP7FW6bsnS224oY
3hZ3p7RPVJEV6tVSun2FjLRhuKCn7LdSgVZs7JRXiVWZLXihWMWswUpQP7QhXnAuCN2noxeBGtSDjYwJzKgtMjVK
2V3PBuLGqDUynjAemJLoWMExTUs2cGrWAfToqKGYnQvhbhtXe5QTDNfPhzb4gZSFNSTcSwsAx75tJHLk8C81fgm8

however if you look them up you can see that they don't exist.

I did this a few more times and the result was identical, sometimes the transactions went through, sometimes they didn't. I find it extremely odd and I'm wondering if there's anyone here who would be able to help me.

I did some digging and I think it could be caused by outdated TPU client implementation, since the current official Rust implementation uses QUIC, however like I said I'm not sure if that's the reason why some of the transactions fail.

The code I'm running is:

const tpuConnection = await TpuConnection.load("https://api.mainnet-beta.solana.com", { commitment: "processed" });
var bh = await (await tpuConnection.getLatestBlockhash({commitment: "confirmed"}))
console.log(bh)
for(var i = 0; i < 3; i++) {
    let tx = new Transaction();
    tx.add(SystemProgram.transfer({
        fromPubkey: from.publicKey, //from is my wallet keypair
        lamports: ranmax(10000, 15000), //random amount of lamports between 10000 and 15000
        toPubkey: new PublicKey("6fixxgrowcL162MojthGHZf3Tt5dHy8zPjpEN1ULYXyE")
    }))
    tx.feePayer = from.publicKey
    tx.recentBlockhash = bh.blockhash
    tx.sign(from)
    const signature = await tpuConnection.sendRawTransaction(tx.serialize())
    console.log(signature)
}

Also, I'll happily reward volunteers with 0.5 SOL that decide to help me :) Just as a thank you.

Thanks

2 Answers 2

2

I did some digging and I think it could be caused by outdated TPU client implementation, since the current official Rust implementation uses QUIC, however like I said I'm not sure if that's the reason why some of the transactions fail.

This is exactly the problem. This package is old, and hasn't been updated since the cluster upgraded the TPU to use QUIC.

On mainnet, most validators have shut off their UDP ports for the TPU, so your client will keep spraying transactions until it gets lucky and finds a leader with an open UDP port.

This will be completely removed soon, so be sure to update that package or use the Rust TpuClient if you want to use QUIC and keep landing your transactions.

4
  • Thanks for your answer, it really helped, please reply with your SOL address so I can send the bounty :)
    – shlx
    Commented Mar 15, 2023 at 21:20
  • Don't mention it :-D please approve the answer if it's good, that's enough bounty
    – Jon C
    Commented Mar 15, 2023 at 22:45
  • There you go, thanks a lot!
    – shlx
    Commented Mar 16, 2023 at 14:37
  • @shlx did you find an other solution to use a TPU connection in JS?
    – Stefan D.
    Commented Feb 3 at 21:20
0

The only way I have had to launch tx using tpu is by using the rust library and linking to ts, here is the repo, hope it helps

https://github.com/nikola43/tpu_client

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.