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

Add migration from v0.2.0 to v0.2.1 #468

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,15 @@ pub struct ChannelActorState {
#[serde_as(as = "Option<PubNonceAsBytes>")]
pub last_committed_remote_nonce: Option<PubNonce>,

// While building a CommitmentSigned message, we use the latest remote nonce (the `last_committed_remote_nonce` above)
// to partially sign the commitment transaction. This nonce is also needed for the RevokeAndAck message
// returned from the peer. We need to save this nonce because the counterparty may send other nonces during
// the period when our CommitmentSigned is sent and the counterparty's RevokeAndAck is received.
// This field is used to keep the nonce used by the unconfirmed CommitmentSigned. When we receive a
// RevokeAndAck from the peer, we will use this nonce to validate the RevokeAndAck message.
#[serde_as(as = "Option<PubNonceAsBytes>")]
pub last_commitment_signed_remote_nonce: Option<PubNonce>,

Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you change the order here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because this is the right order. Previous comments were actually placed near to the wrong fields.

// While handling peer's CommitmentSigned message, we will build a RevokeAndAck message,
// and reply this message to the peer. The nonce used to build the RevokeAndAck message is
// an older one sent by the peer. We will read this nonce from the field `last_committed_remote_nonce`
Expand All @@ -3026,15 +3035,6 @@ pub struct ChannelActorState {
// While reestablishing the channel, we need to use the old nonce to build the RevokeAndAck message.
// This is why we need to save the old nonce in this field.
#[serde_as(as = "Option<PubNonceAsBytes>")]
pub last_commitment_signed_remote_nonce: Option<PubNonce>,

// While building a CommitmentSigned message, we use the latest remote nonce (the `last_committed_remote_nonce` above)
// to partially sign the commitment transaction. This nonce is also needed for the RevokeAndAck message
// returned from the peer. We need to save this nonce because the counterparty may send other nonces during
// the period when our CommitmentSigned is sent and the counterparty's RevokeAndAck is received.
// This field is used to keep the nonce used by the unconfirmed CommitmentSigned. When we receive a
// RevokeAndAck from the peer, we will use this nonce to validate the RevokeAndAck message.
#[serde_as(as = "Option<PubNonceAsBytes>")]
pub last_revoke_and_ack_remote_nonce: Option<PubNonce>,

// The latest commitment transaction we're holding,
Expand Down
3 changes: 3 additions & 0 deletions src/store/db_migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ impl DbMigrate {
pub fn new(db: Arc<DB>) -> Self {
let mut migrations = Migrations::default();
migrations.add_migration(Arc::new(DefaultMigration::new()));
migrations.add_migration(Arc::new(
super::migrations::v20250112205923::MyMigration::new(),
));
DbMigrate { migrations, db }
}

Expand Down
2 changes: 2 additions & 0 deletions src/store/migrations/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// following new migration should be added here ...
// pub(crate) mod sample;

pub(crate) mod v20250112205923;
Loading
Loading