-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a client for BankForks #10728
Add a client for BankForks #10728
Conversation
47483f4
to
1029c69
Compare
Codecov Report
@@ Coverage Diff @@
## master #10728 +/- ##
========================================
Coverage 81.9% 82.0%
========================================
Files 318 323 +5
Lines 74872 75267 +395
========================================
+ Hits 61371 61732 +361
- Misses 13501 13535 +34 |
31e5e36
to
d526216
Compare
@jstarry, can you evaluate |
c14ccf4
to
45a4d37
Compare
@garious looks pretty good. It's cool that The only wasm blocker that I found was |
We could use / create something like https://github.com/tomaka/wasm-timer |
997d575
to
9e6224c
Compare
1d9ae59
to
7ba3d79
Compare
8588820
to
eb9236a
Compare
Hey @garious I tried out your branch and was able to get it working in the browser using a ws transport 🎉 As I pointed out before, the main big hurdle is the lack of support of
There were a few other issues:
|
@ryoqun, Right now queries to get specific account state on a |
|
I'll rebase on #11188. More code review comments? |
7bdde17
to
df11ba7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I'm definitely in favour of tarpc
let signature = transaction.signatures.get(0).cloned().unwrap_or_default(); | ||
let info = | ||
TransactionInfo::new(signature, serialize(&transaction).unwrap(), last_valid_slot); | ||
self.transaction_sender.send(info).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we send the transaction through the preflight checker first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jstarry @mvines, so I nearly added this feature today, but am now thinking there's some good reasons not to. Unlike jsonrpc, I'd like for BanksServer to be lightweight enough that every validator could run it, and not be too concerned about a DoS. The only errors that simulate_transaction
can detect are InsufficientFundsForTransactionFee and SigVerifyFailed. Both of those can be done client-side. The other thing simulating can do is find program errors without paying for the transaction fee - why should the RPC node eat that cost, when otherwise the user would pay the transaction fee, which pays for signature verification and running the program?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public RPC nodes are not voting. The DOS vector and the cost they eat doesn't have impact on security. admins can sandbox them without performance impact on consensus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeyakovenko, not talking about DOSing the cluster, just the RPC node. It's a UX issue, not a security issue.
self, | ||
_: Context, | ||
transaction: Transaction, | ||
commitment: CommitmentLevel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The web3 SDK uses confirmation counts to confirm transactions now. I think we should have the BanksClient
follow that example. The confirmations
in TransactionStatus
represent the number of cluster confirmations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll think on this. Personally, I'd prefer to subscribe to a stream of events.
chan.respond_with(server.serve()).execute() | ||
}) | ||
// Max 10 channels. | ||
.buffer_unordered(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that only 10 concurrent requests are allowed? Seems like it should be quite a bit higher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we'll want to tune everything in this function. I think that can be a separate PR though.
async fn send_transaction(&mut self, transaction: Transaction) -> io::Result<()>; | ||
async fn get_recent_blockhash(&mut self) -> io::Result<Hash>; | ||
async fn get_fees(&mut self) -> io::Result<(FeeCalculator, Hash, Slot)>; | ||
async fn process_transaction_with_commitment( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we replace commitment
with confirmations
in send_and_confirm_transaction
, then I propose we default process_transaction
to 0 or 1 confirmation(s).
Then we could have:
send_transaction
execute_transaction
/process_transaction
which waits for 0 or 1 confirmation(s)settle_transaction
which waits for MAX confirmations- [optional]
confirm_transaction
for user-specified confirmations
cc @aeyakovenko
Transaction has been replicated by turbine across the cluster, or settled.
Do we need to query specifically for local finality? Tag @carllin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in favor as well
@jstarry @aeyakovenko makes sense to me. Seems like on the scale of finality, with local finality one one end and MAX on the other, not sure practically what most clients would feel safe with. >33% seems like a good enough number to make rollback impossible. For the execution receipts, feel free to add to the issue here: #11116 |
I don't like these APIs where the client attempts to pick one and only one event. We should be exposing the data, not interpreting it. In this case, it's an event stream. Instead of returning a value, we should be passing in a client-side object that gets notified each time a relevant event occurs. @jstarry From what I can tell, tarpc may not work well for this case. In their pubsub example, the caller needs to provide an address for the server to connect to. That wouldn't allow a client to sit behind a firewall. Also, it lets the server pick the upstream stream transport, which is weird. It's possible tarpc needs some rework to allow for upstream communication via the same transport. |
@jstarry, @aeyakovenko, @CriesofCarrots, perhaps there should be a |
@@ -46,11 +46,28 @@ impl CommitmentConfig { | |||
|
|||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash)] | |||
#[serde(rename_all = "camelCase")] | |||
/// An attribute of a slot. It describes how finalized a block is at some point in time. For example, a slot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CriesofCarrots @jstarry, how's this look? I don't know if we've ever stated "commitment level means ...". I found it quite difficult to describe - maybe a red flag that I got it wrong.
@garious I just took a look as well and I agree. |
@garious As for streams of events for something like finality, I also think it would be useful. I think the primary use case would end up being a progress indicator. The progress could indicate number of confirmations or X% of stake that has confirmed. This is functionality that we don't have in the current RPC API so I think it can come later
If clients want to get notified for both execution and settlement for a given transaction, they can send two requests.
I'm second guessing exposing |
a629db0
to
9c0c76a
Compare
@jstarry, fyi, new https://github.com/google/tarpc/blob/master/tarpc/examples/pubsub.rs that shares the client connection |
3a6fb8f
to
201e3e4
Compare
Also: * Use BanksClient in solana-tokens
201e3e4
to
4184460
Compare
What do you all think about merging this one as-is? On its current trajectory, it's an improvement over RpcClient for some Rust CLI tooling and obsoletes BankClient. But also, with 1.3 out the door, we have plenty of time to make it even better before it goes into production. |
sgtm! Honestly I've not reviewed but it's gotta be an improvement. How could it not be :) |
Cherry-picked from solana-labs#10728, but without the changes to solana-tokens
Cherry-picked from #10728, but without the changes to solana-tokens
Problems
Summary of Changes