-
Notifications
You must be signed in to change notification settings - Fork 195
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
Style: improve api clients comments #780
Conversation
// TODO: all of these should be private, to prevent users from using them directly, | ||
// which breaks encapsulation and makes it hard for us to do refactors or changes |
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.
this I personally think is a refactor worth doing... but it might break some client code... :\
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.
agree this should be private. From my experience, it is difficult to understand data semantics in each stage or encoding and decoding.
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.
Don't understand your comment, why are you mentioning data semantics here?
And are you saying I should change the fields to private right now? Are we not scared of breaking user code that might be using these?
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.
just from the developers' view, it tool me a while to understand the intermediate phases. If someone else would use it, I doubted it would be correct
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.
Note: we decided to do all the breaking changes in a future PR.
api/proto/disperser/disperser.proto
Outdated
// where the lower address has more significant bits. The integer must stay in the valid range to be interpreted | ||
// as a field element on the bn254 curve. The valid range is | ||
// 0 <= x < 21888242871839275222246405745257275088548364400416034343698204186575808495617 | ||
// containing slightly less than 254 bits and more than 253 bits. If any one of the 32 bytes chunk is outside the range, | ||
// the whole request is deemed as invalid, and rejected. | ||
// which is a 254 bit number (meaning the first 2 bits of each chunk must always be 00). |
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.
This isn't accurate though, 21888242871839275222246405745257275088548364400416034343698204186575808495617
is smaller than 2^254-1
(i.e. the original comment is accurate that it doesn't have 254 bits).
Also shall we not use chunk
here since it's easy to confuse with the encoding chunks (which will become more user visible in the future)?
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.
Took me a while to figure this one out haha. Doesn't matter that it's < 2^254-1, what matters is that it's > 2^253-1, and so actually needs 254 bits.
The number is 254 bits according to https://hackmd.io/@jpw/bn254 (which also explains why its called bn254 and not bn253). Here's also a python script showing that it's a 254 bit number:
number = 21888242871839275222246405745257275088548364400416034343698204186575808495617
binary_representation = bin(number)
# Count the number of bits (excluding the '0b' prefix)
bit_count = len(binary_representation) - 2
print(f"The number is: {number}")
print(f"Binary representation: {binary_representation}")
print(f"Number of bits: {bit_count}")
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.
What's a better word that you would recommend instead of chunk
? @bxue-l2 maybe you have an idea since you initially wrote this comment I believe?
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.
EDIT: based on bowen's comment below, I think I understand what you guys are saying now. Still think my comment is more accurate and the original one weird/wrong (a number cannot have more than 253 bits and less than 254 bits, it has a fixed number of bits, and could happen to have 254 bits).
Updated the comment order to reflect you guys' confusion, hopefully this helps: 6b78c52
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.
(meaning the first 2 bits of each chunk must always be 00)
Pedantically, this is not true. Disperser will happily encode & disperse a blob that does not prefix chunks with 00 as long as all 32 byte chunks are in range. The 00 chunk prefix is just the easiest way to achieve lossless chunk encode/decode at the expense of 1 byte per chunk.
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.
@pschork maybe wording is getting everyone confused? By "chunk" in here we are talking about 32byte field elements. If those are not prefixed by 00, then they are surely a number > the max allowed FE, and so therefore wouldn't be in range, right?
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.
When encoding, if your encoding chunk size is 32 bytes and the current chunk is within range, you don't need to pad it, but if given chunk exceeds the range then you need to truncate the chunk and pad it with zero to fit within range. The problem is when you do this, you won't be able to decode the encoded blob because you wont know which chunks were or were not padded (aka lossy encoding). For lossless encoding you set the encoding chunk size to 31 bytes and reserve the first 1 byte with \x00
so that, when decoding, you can identify the start of a chunk.
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.
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.
please avoid using chunk here, it'll quickly get overloaded and confusing.
I think we don't need to mention it's prefixed with 00 (it's not precise anyway), we just need to mention each 32 bytes should fall in that value range so it's a valid field element.
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.
// The total amount of time that the client will spend waiting for EigenDA to confirm a blob | ||
// Timeout used when making dispersals to the EigenDA Disperser | ||
// TODO: we should change this param as its name is quite confusing | ||
ResponseTimeout time.Duration |
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.
agree, how about DispersalTimeout?
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'm fine with doing that, but as I mentioned in the other comment #780 (comment), do we have a policy for these breaking changes? Or are we fine with just doing it now?
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.
Note: we decided to do all the breaking changes in a future PR.
// TODO: all of these should be private, to prevent users from using them directly, | ||
// which breaks encapsulation and makes it hard for us to do refactors or changes |
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.
agree this should be private. From my experience, it is difficult to understand data semantics in each stage or encoding and decoding.
dismissing because there's a lot of good comments that I need to address before we merge this.
@@ -78,12 +78,12 @@ message AuthenticationData { | |||
|
|||
message DisperseBlobRequest { |
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.
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.
method is now no longer used anymore, and could be deprecated
…orumID eventually
only need tracing-id key now since v2 will do idempotency using blobHeader Also realized using same key for idempotency and tracing doesn't make sense, since one might want different requests to be traced idependently but use the same idempotency key
795868e
to
5b39fe6
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.
lg
Small improvements to comments/docs for api clients.
Had some fun in the plane while reading the code.
Added some TODOs in a few places which might be worth checking through, perhaps we can solve some of them right away @bxue-l2