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

refactor: move tx_template from bdk_chain to bdk_testenv #1800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tvpeter
Copy link
Contributor

@tvpeter tvpeter commented Jan 14, 2025

Description

This PR implements the following changes:

  • moves TxTemplate from crates/chain/tests/common/mod.rs to testenv.
  • refactors init_graph function and TxTemplate struct to use Cow
  • redoes the canonical benchmark tests introduced by Introduce O(n) canonicalization algorithm #1670 using TxTemplates

Closes #1754

Notes to the reviewers

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@tvpeter tvpeter force-pushed the test/move-txtemplate-to-testenv branch 3 times, most recently from 8b81584 to 12181bb Compare January 21, 2025 10:30
@tvpeter tvpeter marked this pull request as ready for review January 21, 2025 10:34
@tvpeter tvpeter force-pushed the test/move-txtemplate-to-testenv branch from 12181bb to 13b87ac Compare January 23, 2025 11:53
@tvpeter tvpeter force-pushed the test/move-txtemplate-to-testenv branch from 13b87ac to dd47a8b Compare January 28, 2025 07:39
Copy link
Contributor

@oleonardolima oleonardolima left a comment

Choose a reason for hiding this comment

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

Thanks for working on this one, so far it's looking good.

Please update the commit messages to follow conventional commits, i.e: `refactor: move `tx_template` from `bdk_chain` to `bdk_testenv`


[dev-dependencies]
bdk_testenv = { path = "." }
rand = "0.8"
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC this dependency is currently being used only for tx_template mod, right?

As it's only available when miniscript feature is being used, it'd be best to make this one an optional dependency tied to that feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is currently only being used in the tx_template mod.

Comment on lines 27 to 29
pub inputs: Vec<TxInTemplate>,
pub outputs: Vec<TxOutTemplate>,
pub anchors: Vec<A>,
Copy link
Contributor

Choose a reason for hiding this comment

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

@tvpeter Any reason/tradeoff on using Vec, instead of Cow<'_, Tx..>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at it again, there is no trade-off. Thank you for the feedback. I will update it, as Cow seems more efficient.

- refactor tx_template struct and init_graph
to use Cow pointer
- move `tx_template` from `chain/tests/common` to
`testenv/src`
- update `chain/tests` files to use `tx_template`
from `testenv`
- update deps in `chain/cargo.toml` and
`testenv/cargo.toml`
- update imports in `testenv/src/lib.rs`
- refactor canonical benchmarks in `chain/benches`
 to use tx_template

[Ticket: 1754]
@tvpeter tvpeter force-pushed the test/move-txtemplate-to-testenv branch from dd47a8b to 657ffd8 Compare January 29, 2025 08:57
@tvpeter tvpeter changed the title test(chain):move txtemplate to testenv refactor: move tx_template from bdk_chain to bdk_testenv Jan 29, 2025
@tvpeter tvpeter requested a review from oleonardolima January 29, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Move TxTemplate to bdk_testenv and make it better
2 participants