Skip to content

Conversation

@samkim-crypto
Copy link

@samkim-crypto samkim-crypto commented Mar 26, 2024

Problem

The keygen cli uses clap-v3 and solana-clap-v3-utils, but still uses deprecated functions from clap-v2.

Summary of Changes

Replaced deprecated clap-v2 functions with clap-v3 functions. I organized the changes so that each commit is associated with different commands.

This PR removes all the deprecated functions for all commands except for the grind command. The grind command seems like it will need a bit more structural changes, so I will make the changes in a follow-up PR.

The first and last commits here adds and removes the deprecated feature from clap-v3. If this feature is set, then clap-v3 warns on the use of deprecated functions. I removed this feature since the grind command is not yet updated.

Fixes #

@samkim-crypto samkim-crypto marked this pull request as ready for review March 27, 2024 07:46
Comment on lines 74 to 82
let source = if matches.try_contains_id("keypair")? {
Cow::Borrowed(matches.get_one::<SignerSource>("keypair").unwrap())
} else if !config.keypair_path.is_empty() {
&config.keypair_path
Cow::Owned(SignerSource::parse(&config.keypair_path)?)
} else {
let mut path = dirs_next::home_dir().expect("home directory");
path.extend([".config", "solana", "id.json"]);
path.to_str().unwrap()
Cow::Owned(SignerSource::parse(path.to_str().unwrap())?)
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not obvious to me: why is the Cow wrapping necessary? If this will be a common need, it's unfortunate ergonomics.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is unfortunate ergonomics. The issue is that matches.get_one::<SignerSource>("keypair").unwrap() gives a reference &SignerSource while SignerSource::parse(...).unwrap() gives a fully owned SignerSource. Returning &SignerSource::parse(...).unwrap() is not possible since the owned type will be freed out of scope.

The alternative would be to define an owned variable outside of the if statement, set it to SignerSource::parse(...).unwrap(), and return a reference to it. I thought this was less elegant than using Cow at first, but it seems like it could be cleaner, so I made the change. Please take a look.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I agree the current version is a little cleaner.
It's actually odd to me that ArgMatches::get_one returns a reference instead of an owned object. I suppose I should read the clap code to see why.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.8%. Comparing base (30eecd6) to head (1e08ec4).
Report is 20 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master     #438     +/-   ##
=========================================
- Coverage    81.9%    81.8%   -0.1%     
=========================================
  Files         840      841      +1     
  Lines      228107   228265    +158     
=========================================
+ Hits       186851   186931     +80     
- Misses      41256    41334     +78     

@samkim-crypto samkim-crypto merged commit b1919bd into anza-xyz:master Mar 28, 2024
OliverNChalk pushed a commit to OliverNChalk/agave that referenced this pull request Nov 11, 2025
This change includes all of the following changes as well:

---

Author: kirill lykov <[email protected]>
Date:   Tue May 28 20:20:39 2024 +0200

Add transaction bench client (anza-xyz#339)

New client application that sends transactions using TPU protocol.

First, this client creates accounts necessary for the transaction
generation.

Second, it generates transactions executing specified program and sends
them to the upcoming leaders.

Contrary to other clients, it doesn't use the `TpuClient` and the
`ConnectionCache` to interact with validators, but uses an alternative
client network layer implementation.

---

Author: Alex Peng <[email protected]>
Date:   Tue Jun 4 02:31:16 2024 -0500

transaction-bench: fix underflow in ensure_authority_balance (anza-xyz#341)

---

Author: kirill lykov <[email protected]>
Date:   Fri Jul 26 10:02:39 2024 +0200

add 3 tests for client network component (anza-xyz#365)

This PR is the first in a series of PR introducing integration tests for
client network component.
It introduces the following changes:

* add first basic integration test

* add test_connection_denied_until_allowed

* add test for connection pruning

* retry connecting when pruned

* Introduce IoErrorWithPartialEq to check that QuicError is as expected

---

Author: kirill lykov <[email protected]>
Date:   Mon Aug 5 18:30:09 2024 +0200

Handle error with connection properly (anza-xyz#383)

When one of the connections fails to open, we stop the whole client.
It doesn't work on testnet because there most of the nodes drop TPU
traffic despite of saying through gossip that it is allowed (need to
ping foundation on that).

---

Author: kirill lykov <[email protected]>
Date:   Thu Aug 8 22:25:54 2024 +0200

Read/write for AccountsFile to use on testnet (anza-xyz#381)

Only the `transaction-bench/src/network/` and `transaction-bench/tests`
parts of this change was merge in.

Illia Bobyr: Migrated to quinn 0.11 and refactored the tests a bit.

---

Author: kirill lykov <[email protected]>
Date:   Sat Aug 17 15:10:19 2024 +0200

Handle instruction error in client-test-program (anza-xyz#411)

Due to upstream changes errors are not propagated properly anymore when
calling try_from_slice. This PR fixes the problem exactly the same way
as in anza-xyz#387

---

Author: kirill lykov <[email protected]>
Date:   Tue Aug 20 10:01:36 2024 +0200

Add structure to collect statistics about send txs erros (anza-xyz#367)

There is no way to check why certain packets have not been delivered.
By propagating this information to the caller, we can use it not only in
the client code but also in tests.
This change Introduces a structure which accumulates relevant counters
per node IP and returns this information to the client code.

Illia Bobyr: Migrated to quinn 0.11 and refactored a bit.

Refactored-by: Illia Bobyr <[email protected]>

---

Author: kirill lykov <[email protected]>
Date:   Mon Aug 26 18:37:07 2024 +0200

Add rate limiting test to client (anza-xyz#368)

This PR introduces integration test to check that when rate-limiting has
happen we increment correct counters on client side.

---

Author: kirill lykov <[email protected]>
Date:   Tue Aug 27 16:34:57 2024 +0200

Improve stream sending (anza-xyz#372)

* stop using multistream connection

* add throttling test

* remove stream's finish call. It will be called when stream is dropped
  anyways, but if we call finish explicitly we will wait for ACK, so the
  behavior will be like if we had RW=1 tx. This change makes a x1000
  difference on a connection with high latency.

Illia Bobyr: Migrated to quinn 0.11, added cancellation in order to
support clean shutdown, and refactored the tests a bit.

Refactored-by: Illia Bobyr <[email protected]>

---

Author: kirill lykov <[email protected]>
Date:   Thu Sep 5 18:54:01 2024 +0200

use testing_utilities (anza-xyz#427)

We use modified copy-pasted code from streamer to setup server/client in
integration tests for network component.

Later original code was updated to be reusable.

This PR removes old copy-pasted code and uses modified streamer's
testing_utilities code.

---

Author: kirill lykov <[email protected]>
Date:   Tue Sep 10 12:06:08 2024 +0200

Move leader updater to network and add documentation (anza-xyz#426)

---

Author: kirill lykov <[email protected]>
Date:   Tue Sep 10 16:30:34 2024 +0200

Add documentaiton to network code (anza-xyz#425)

---

Author: kirill lykov <[email protected]>
Date:   Tue Sep 10 20:58:04 2024 +0200

Don't ignore `test_no_host` (anza-xyz#435)

---

Author: kirill lykov <[email protected]>
Date:   Wed Sep 11 20:34:09 2024 +0200

Address Illia's comments (anza-xyz#438)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants