Skip to content
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

Cli updates to release #432

Closed
wants to merge 12 commits into from
Closed

Cli updates to release #432

wants to merge 12 commits into from

Conversation

sapinb
Copy link
Contributor

@sapinb sapinb commented Oct 27, 2024

Description

Cherrypick cli related changes from main to release

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

Copy link

codecov bot commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 301 lines in your changes missing coverage. Please review.

Project coverage is 57.04%. Comparing base (a14d926) to head (c9886cd).
Report is 5 commits behind head on releases/0.1.0.

Files with missing lines Patch % Lines
bin/strata-cli/src/seed/password.rs 0.00% 53 Missing ⚠️
bin/strata-cli/src/signet.rs 0.00% 52 Missing ⚠️
bin/strata-cli/src/cmd/faucet.rs 0.00% 35 Missing ⚠️
bin/strata-cli/src/settings.rs 0.00% 23 Missing ⚠️
bin/strata-cli/src/seed.rs 0.00% 22 Missing ⚠️
bin/strata-cli/src/cmd/deposit.rs 0.00% 21 Missing ⚠️
bin/strata-cli/src/cmd/recover.rs 0.00% 17 Missing ⚠️
bin/strata-cli/src/main.rs 0.00% 17 Missing ⚠️
bin/strata-cli/src/cmd/send.rs 0.00% 15 Missing ⚠️
bin/strata-cli/src/cmd/drain.rs 0.00% 11 Missing ⚠️
... and 7 more
@@                Coverage Diff                 @@
##           releases/0.1.0     #432      +/-   ##
==================================================
- Coverage           57.16%   57.04%   -0.13%     
==================================================
  Files                 256      261       +5     
  Lines               27048    27638     +590     
==================================================
+ Hits                15462    15765     +303     
- Misses              11586    11873     +287     
Files with missing lines Coverage Δ
bin/strata-cli/src/cmd/mod.rs 0.00% <ø> (ø)
bin/strata-cli/src/cmd/reset.rs 0.00% <ø> (ø)
bin/strata-cli/src/constants.rs 100.00% <ø> (ø)
bin/strata-cli/src/net_type.rs 0.00% <ø> (ø)
bin/strata-client/src/extractor.rs 96.52% <ø> (ø)
bin/strata-cli/src/cmd/receive.rs 0.00% <0.00%> (ø)
bin/strata-cli/src/cmd/config.rs 0.00% <0.00%> (ø)
bin/strata-cli/src/cmd/change_pwd.rs 0.00% <0.00%> (ø)
bin/strata-cli/src/cmd/scan.rs 0.00% <0.00%> (ø)
bin/strata-cli/src/cmd/withdraw.rs 0.00% <0.00%> (ø)
... and 12 more

... and 19 files with indirect coverage changes

Copy link
Contributor

@Zk2u Zk2u left a comment

Choose a reason for hiding this comment

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

Wait for this to merge #423

@storopoli
Copy link
Member

We also need to update the private-docs cargo install command

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

We can bring #423 it's squash merged

@storopoli
Copy link
Member

I've brought #423 in a743f65.
Let's wait for CI

@storopoli storopoli requested a review from Zk2u October 28, 2024 14:19
storopoli
storopoli previously approved these changes Oct 28, 2024
Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK a743f65

storopoli and others added 5 commits October 28, 2024 11:20
* feat(strata-cli)!: add hash version and optional password

* feat(strata-cli): warn user about password strength
)

* fix(strata-cli): better warnings of low-entropy pass

* refactor(strata-cli): password warnings into a function
… refresh -> recover, config file + more (#382)

* feat: manual signet fee rates + full scan command

* fix: use `u64` for feerates + rename refresh to recover

* fix: disable faucet L2 functionality

* feat: add network + bridge pubkey settings & use config file from env var

* chore: remove all strata logic from faucet

* feat: add config command to show config file path

* fix: featuregate strata faucet code

* chore: rename `l2_http_endpoint` to `strata_endpoint`

* fix: patch featuregated to use `strata_endpoint`

* fix: remove password requirement from reset cmd

* chore: update bridge pubkey

* fix: drain command

* fix: "bridge-in" and "bridge-out" to "deposit" and "withdraw"

* chore: update withdraw cmd

* chore: updating comments.+ logs

* chore: comments

* chore: update bridge strata address

* chore: hide endpoints

* fix: printing config file location with no config

* fix: various fixes, recovery descriptor autocleanup

* fix: remove `seed_encryption_key` caching for `Password`

* feat: zeroize password

* chore: derive `Eq` as well as `PartialEq` on `NetworkType`

Co-authored-by: Jose Storopoli <jose@storopoli.io>

* fix(cli): feerate logic revamp

* chore(cli): fix clippy

---------

Co-authored-by: Jose Storopoli <jose@storopoli.io>
…423)

* feat: bitcoind wallet syncing

* feat: feerate + broadcast via `SyncBackend`

* feat:(cli) `SignetBackend`

* feat:(cli) `spawn_bitcoin_core` wrapper

* feat:(cli) trait based `SignetBackend`

* refactor:(cli) update `SignetBackend` to not use `&mut Wallet`

* doc: fix doclink

---------

Co-authored-by: Jose Storopoli <jose@storopoli.io>
storopoli and others added 6 commits October 28, 2024 11:24
* ci: update to bitcoin 28.0

* fix(btcio): non-breaking changes in GetBlockChainInfo

Shouldn't be a breaking change for us,
since we are not using any of the changed stuff.
See:
https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-28.0.md#updated-rpcs
It does not make sense to have this dep since we're already half-baking
our own custom types on top of it and using only a tiny minority of the
types as being the ones provided by bitcoind_json_rpc_types.
@storopoli storopoli mentioned this pull request Oct 28, 2024
13 tasks
@storopoli
Copy link
Member

Done in #437

@storopoli storopoli closed this Oct 28, 2024
@storopoli storopoli deleted the cli-updates-to-release branch October 28, 2024 15:11
Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

Panics should only be used when they'd be triggered as of an actual bug in our code, an assumption being violated. Not something that can be caused by some normal user error. See ticket.

l1w.sync(&esplora).await.unwrap();
let mut l1w =
SignetWallet::new(&seed, settings.network, settings.signet_backend.clone()).unwrap();
l1w.sync().await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this .unwrap().

Comment on lines +47 to 49
let l2w = StrataWallet::new(&seed, &settings.strata_endpoint).unwrap();
let _ = term.write_line("Getting balance...");
let balance = l2w.get_balance(l2w.default_signer_address()).await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix these .unwrap()s.

Comment on lines +51 to +57
let requested_strata_address =
strata_address.map(|a| StrataAddress::from_str(&a).expect("bad strata address"));
let mut l1w =
SignetWallet::new(&seed, settings.network, settings.signet_backend.clone()).unwrap();
let l2w = StrataWallet::new(&seed, &settings.strata_endpoint).unwrap();

l1w.sync(&esplora).await.unwrap();
l1w.sync().await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix these unwraps/expects.

Comment on lines 80 to 85
.expect("valid descriptor");

let mut temp_wallet = Wallet::create_single(desc.clone())
.network(NETWORK)
.network(settings.network)
.create_wallet_no_persist()
.expect("valid wallet");
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should fix these expects.

.signet_backend
.broadcast_tx(&tx)
.await
.expect("successful broadcast");
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this expect.


handle
.await
.expect("thread to be fine")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this expect.


handle
.await
.expect("thread to be fine")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this expect.

Comment on lines +176 to +187
WalletUpdate::SpkSync(update) => {
wallet.apply_update(update).expect("update to connect")
}
WalletUpdate::SpkScan(update) => {
wallet.apply_update(update).expect("update to connect")
}
WalletUpdate::NewBlock(ev) => {
let height = ev.block_height();
let connected_to = ev.connected_to();
wallet
.apply_block_connected_to(&ev.block, height, connected_to)
.expect("block to be added")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix these expects.

Comment on lines +327 to +328
#[derive(Debug)]
pub struct InvalidFee;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should split error types out into their own module, ideally.

Comment on lines +10 to +32
/// Wrapper around the built-in rusqlite db that allows
/// [`PersistedWallet`](crate::signet::PersistedWallet) to be shared across multiple threads by
/// lazily initializing per core connections to the sqlite db and keeping them in local thread
/// storage instead of sharing the connection across cores.
///
/// WARNING: [`set_data_dir`] **MUST** be called and set before using [`Persister`].
#[derive(Debug)]
pub struct Persister;

static DATA_DIR: OnceLock<PathBuf> = OnceLock::new();

/// Sets the data directory static for the thread local DB.
///
/// Must be called before accessing [`Persister`].
///
/// Can only be set once - will return whether value was set.
pub fn set_data_dir(data_dir: PathBuf) -> bool {
DATA_DIR.set(data_dir).is_ok()
}

thread_local! {
static DB: Rc<RefCell<Connection>> = RefCell::new(Connection::open(SignetWallet::db_path("default", DATA_DIR.get().expect("data dir to be set"))).unwrap()).into();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This data should be passed around as struct fields along with the data associated with it, not in globals/tls.

@delbonis delbonis restored the cli-updates-to-release branch October 28, 2024 16:48
@storopoli
Copy link
Member

@delbonis can you check #437? that was the one we merged.

@storopoli storopoli deleted the cli-updates-to-release branch October 28, 2024 16:49
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.

5 participants