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

ICS4: Implement Packet Sequence Logic for upgrades #1062

Merged
merged 15 commits into from
Dec 20, 2023

Conversation

AdityaSripal
Copy link
Member

Closes: #1060
Closes: #1061

  • Add NextSequenceSend field to upgrade struct
  • Add path for counterpartyNextSequenceSend in private store
  • Correctly set packet recv and ack sequences if order has changed
  • Defensive check on RecvPacket
  • Comment detailing implementation details for pruning

@AdityaSripal AdityaSripal marked this pull request as ready for review December 18, 2023 16:50
Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thanks, @AdityaSripal. I left a bunch of naming suggestions that, I think, align closer with existing naming.

Also, shouldn't we do privateStore.set(counterpartyNext... with counterpartyUpgrade.nextPacketSend in chanUpgradeAck and chanUpgradeConfirm?

Co-authored-by: Carlos Rodriguez <[email protected]>
// the recv and ack sequences appropriately
if channel.order == "UNORDERED" && upgrade.fields.ordering == "ORDERED" {
selfNextSequenceSend = provableStore.get(nextSequenceSendPath(portIdentifier, channelIdentifier))
counterpartyNextSequenceSend = privateStore.get(counterpartyNextPacketSendSequencePath(portIdentifier, channelIdentifier))
Copy link
Contributor

@DimitrisJim DimitrisJim Dec 19, 2023

Choose a reason for hiding this comment

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

where do we set this though? (Ah, Carlos mentioned this in top comment #1062 (review))

Copy link
Contributor

Choose a reason for hiding this comment

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

above, it says to be set in the flushing handler but im not sure how that is possible... can we just fetch it from the stored counterparty upgrade?

Copy link
Contributor

Choose a reason for hiding this comment

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

that is what I was under the impression would happen 😅. We get it from counterparty upgrade and set it in store in openUpgradeHandshake (though the setting in store might be an implementation detail that shouldn't belong in spec) in order to use it after upgrade it complete.

#### CounterpartyNextSequenceSend Path

The chain must store the counterparty's next sequence send on `startFlushUpgradeHandshake`. This will be stored in the `counterpartyNextSequenceSend` path on the private store.

Copy link
Contributor

@charleenfei charleenfei Dec 19, 2023

Choose a reason for hiding this comment

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

is it possible to access the counterparty upgrade information for example OnChanUpgradeTry? I think the full counterparty upgrade is not set until WriteUpgradeAck / WriteUpgradeConfirm, at this point we only have the upgrade fields from the counterparty, not ie: next packet send

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, I think the spec is missing the call to privateStore.set(counterpartyNext... with counterpartyUpgrade.nextPacketSend that should happen in chanUpgradeAck and chanUpgradeConfirm. I mentioned that to @AdityaSripal this morning and he was going to look into it.

Copy link
Contributor

Choose a reason for hiding this comment

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

and we're also missing that key counterpartyNext... alltogether in the implementation. Adding it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're correct. Thanks, added the counterparty set now to ack and confirm

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you, @AdityaSripal.

Copy link
Contributor

@sangier sangier left a comment

Choose a reason for hiding this comment

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

Everything clicks for me! Thank you @AdityaSripal and all you guys for catching the issues! 💪

@AdityaSripal AdityaSripal merged commit 6dc5009 into main Dec 20, 2023
3 checks passed
@AdityaSripal AdityaSripal deleted the aditya/packet-sequence-logic branch December 20, 2023 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
5 participants