Skip to content

Commit

Permalink
fix: Avoid serialisation breaking changes when possible
Browse files Browse the repository at this point in the history
Obviously, there's not much we can do if an enum variant disappears or
is renamed, or if the data associated with it changes. But we can
usually avoid changing identifiers unnecessarily.

With this patch we ensure backwards compatibility in certain
scenarios which were broken with 7560cad and 2013ad4.
  • Loading branch information
luckysori committed Aug 4, 2023
1 parent 049388b commit 8dfff94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dlc-manager/src/channel/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ impl_dlc_writeable_enum!(
(6, RenewOffered, {(offered_contract_id, writeable), (counter_payout, writeable), (is_offer, writeable), (offer_next_per_update_point, writeable), (timeout, writeable)}),
(7, RenewAccepted, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (timeout, writeable), (own_payout, writeable)}),
(8, RenewConfirmed, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(9, RenewFinalized, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (accept_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(10, Closing, {(buffer_transaction, writeable), (contract_id, writeable), (is_initiator, writeable)}),
(10, RenewFinalized, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (accept_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(9, Closing, {(buffer_transaction, writeable), (contract_id, writeable), (is_initiator, writeable)}),
(11, CollaborativeCloseOffered, { (counter_payout, writeable), (offer_signature, writeable), (close_tx, writeable), (timeout, writeable) })
;;
);
Expand Down
22 changes: 11 additions & 11 deletions dlc-manager/src/subchannel/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ impl_dlc_writeable_enum!(SubChannelState,
(0, Offered),
(1, Accepted),
(2, Confirmed),
(3, Finalized),
(4, Signed),
(5, Closing),
(6, CloseOffered),
(7, CloseAccepted),
(8, CloseConfirmed),
(9, ClosedPunished)
(13, Finalized),
(3, Signed),
(4, Closing),
(5, CloseOffered),
(6, CloseAccepted),
(7, CloseConfirmed),
(8, ClosedPunished)
;;;
(10, OnChainClosed),
(11, CounterOnChainClosed),
(12, OffChainClosed),
(13, Rejected)
(9, OnChainClosed),
(10, CounterOnChainClosed),
(11, OffChainClosed),
(12, Rejected)
);

impl_dlc_writeable!(OfferedSubChannel, { (per_split_point, writeable) });
Expand Down

0 comments on commit 8dfff94

Please sign in to comment.