-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix!: pss target length verification #384
Conversation
3d6b884
to
7e07ecd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks :)
The only downside about this fix is that it is breaking 😒 But honestly the other work (directory streaming and fetch refactor) are also breaking so I guess we should just go with 2.0 release. |
66ce720
to
ac1063c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using makeMaxTarget
in the test may make the PSS tests to run longer and use more CPU than necessary. In general for testing PSS it would be enough to assume the shortest possible target length.
You are right, but that is not the scope of this PR. I was only reproducing the current state which was passing the whole address which then got truncated with the original I have created an issue about this improvement and I will work on it in the future. |
Okay, I see.
I also opened one long time ago, you may want to close either as duplicate. |
Thanks for the info! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't completely get the API allows any length of target, but the BeeJS restricts it to 4-length hex string. Because we don't expose/support the direct use of modules as we discussed, by design you even cannot get around this limitation in this form, meanwhile you bring a utility function usage to the workflow. it seems more unconvenient for me with zero yield compare to the previous version.
|
||
/** | ||
* Utility function that for given strings/reference takes the most specific | ||
* target that Bee node will except. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not the bee accept any length of target? then why we allow to pass any length address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. You might got this impression from Bee-js usage of PSS before this patch, which silently sliced the target to max. allowed length without user's knowledge. This patch impose correct validation and tools for the user to have predictable behavior.
@nugaon Bee API also has the same restrictions. It will return Bad Request for target exceeding the limit. See https://github.com/ethersphere/bee/blob/master/pkg/api/pss.go#L29 (btw. there the limit is 3 bytes = 6 hex chars, but this was bumped only after Bee 1.1.0 release, so it is not propagated to Bee-js for now and I will change it once release cycle will begin). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as everybody is satisfied with this then we can roll it out, though from my side a jsdoc about this splitting would have been enough
Closes #380
Most of the validation was already in place from my earlier validation work, I was just asserting wrong values 😅
Breaking changes
bee.pssSend()
now throws error if the specified target exceeds maximal value. UseUtils.makeMaxTarget()
that will give you the max target that Bee accepts.