Skip to content

Commit b977367

Browse files
committed
Merge #391: docs(changeset): Add section on version compatibility
80c962b docs(changeset): Add section on version compatibility (valued mammal) e9bd912 fix(changeset): Add serde(default) attribute to locked_outpoints field (valued mammal) Pull request description: ### Description Partially addresses #234 by improving the documentation of `ChangeSet` by adding a version compatibility policy, clarifying what upgrade/downgrade paths are supported and how breaking changes should be handled. It also adds the `#[serde(default)]` attribute to `locked_outpoints` which is a newly added field in 3.0. In summary the policy says: - Changes to the `ChangeSet` data structure will correspond to a major version bump. - Version N can read/deserialize data written by N-1, i.e., one major version back, but this guarantee doesn't extend to version N-2 or earlier. - New fields introduced in version N must implement `Default` so that when deserializing, any missing fields are filled in with the default. - Version N-1 can deserialize version N data by ignoring unknown fields, with the caveat that not all features from version N will be available. - Outline a 3-version deprecation cycle ### Changelog notice Changed - Added `#[serde(default)]` to `ChangeSet::locked_outpoints` ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) ACKs for top commit: luisschwab: ACK 80c962b oleonardolima: ACK 80c962b Tree-SHA512: dec7197750ccbffaf3c8f99a82d8c9be40a88eb27c73b7fd33b07afe5af1e0d3496ed0a55efa2bcf3486ececfb44b25413bb3cbd40905fe9b2f76b6f938e8f2e
2 parents e2b4ad9 + 80c962b commit b977367

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

src/wallet/changeset.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,42 @@ type IndexedTxGraphChangeSet =
7676
///
7777
/// Existing fields may be extended in the future with additional sub-fields. New top-level fields
7878
/// are likely to be added as new features and core components are implemented. Existing fields may
79-
/// be removed in future versions of the library.
79+
/// be removed in future versions of the library following the deprecation policy below.
8080
///
81-
/// The authors reserve the right to make breaking changes to the [`ChangeSet`] structure in
82-
/// a major version release. API changes affecting the types of data persisted will display
83-
/// prominently in the release notes. Users are advised to look for such changes and update their
84-
/// application accordingly.
81+
/// ## Version Compatibility
82+
///
83+
/// Any change to the [`ChangeSet`] data structure MUST correlate with a major version bump per
84+
/// [Semantic Versioning]. We guarantee that version N can read and
85+
/// deserialize [`ChangeSet`] data written by version N-1 (one major version back), but this
86+
/// guarantee does NOT extend to version N-2 or earlier. New fields added in version N must
87+
/// implement [`Default`] so that when reading N-1 data, absent fields are populated with default
88+
/// values.
89+
///
90+
/// Limited forward compatibility is provided for downgrades: version N-1 will successfully
91+
/// deserialize version N data without errors by ignoring unknown fields. Users should be aware that
92+
/// features introduced in version N will not be available when downgrading to N-1, and that
93+
/// downgrading can result in loss of data if not backed up. For this reason we recommend carefully
94+
/// planning major upgrades and backing up necessary data to avoid compatibility issues.
95+
///
96+
/// Fields can be removed using a 3-version deprecation cycle: fields are marked deprecated in
97+
/// version N with a reason and instructions for migrating, the field is retained in version N+1
98+
/// for compatibility where it deserializes but may not be used, and finally removed in version
99+
/// N+2. This ensures the standard backwards compatibility guarantees while allowing the removal of
100+
/// deprecated fields.
101+
///
102+
/// ### Responsibilities
103+
///
104+
/// Library authors SHOULD test all upgrade paths using the persistence test suite and in CI.
105+
/// Library authors MUST document API changes prominently in the release notes and CHANGELOG,
106+
/// clearly mark deprecated fields including migration instructions, and follow the 3-version
107+
/// deprecation cycle before removing fields.
108+
///
109+
/// Users SHOULD back up wallet data before major version upgrades, test upgrades in non-production
110+
/// environments first, and monitor the release notes for warnings and updates. Users MUST complete
111+
/// migrations within the compatibility window, and not skip major versions (i.e. upgrade major
112+
/// versions sequentially).
113+
///
114+
/// ### Custom Persistence Implementations
85115
///
86116
/// The resulting interface is designed to give the user more control of what to persist and when
87117
/// to persist it. Custom implementations should consider and account for the possibility of
@@ -102,6 +132,7 @@ type IndexedTxGraphChangeSet =
102132
/// [`WalletPersister`]: crate::WalletPersister
103133
/// [`Wallet::staged`]: crate::Wallet::staged
104134
/// [`Wallet`]: crate::Wallet
135+
/// [Semantic Versioning]: <https://doc.rust-lang.org/cargo/reference/semver.html>
105136
#[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)]
106137
pub struct ChangeSet {
107138
/// Descriptor for recipient addresses.
@@ -117,6 +148,7 @@ pub struct ChangeSet {
117148
/// Changes to [`KeychainTxOutIndex`](keychain_txout::KeychainTxOutIndex).
118149
pub indexer: keychain_txout::ChangeSet,
119150
/// Changes to locked outpoints.
151+
#[serde(default)]
120152
pub locked_outpoints: locked_outpoints::ChangeSet,
121153
}
122154

0 commit comments

Comments
 (0)