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

PacketStream depacketizer remove redundant buffer #105

Closed
t-wallet opened this issue Aug 19, 2024 · 3 comments
Closed

PacketStream depacketizer remove redundant buffer #105

t-wallet opened this issue Aug 19, 2024 · 3 comments

Comments

@t-wallet
Copy link
Collaborator

t-wallet commented Aug 19, 2024

This is a small optimization that saves a couple registers and multiplexers. But unfortunately it requires a proof. Steps:

  1. Prove that Mod headerBytes dataWidth > 0 => headerBytes + ( dataWidth - (Mod headerBytes dataWidth)) ~ dataWidth * DivRU headerBytes dataWidth
  2. Remove _fwdBuf from DepacketizerState and use the last dataWidth - Mod headerBytes dataWidth bytes of _parseBuf instead. Manually handle the case Mod headerBytes dataWidth ~ 0 because that case deviates from the rule, there are no bytes to buffer.
@rowanG077
Copy link
Member

You can do the nice "proof from nothing" I did once. You can also defer it to a runtime check similar to compareSNat by using sameNat.

@martijnbastiaan
Copy link
Member

@t-wallet
Copy link
Collaborator Author

Implemented in #85.

Thank you for the resources! clash-protocols now has its very own "haxioms" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants