-
Notifications
You must be signed in to change notification settings - Fork 29
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
Create converter to/from numerical and string properties #34
Comments
Issue Status: 1. Open 2. Started 3. Submitted 4. Done This issue now has a funding of 280.0 DAI (280.0 USD @ $1.0/DAI) attached to it as part of the Centrifuge fund.
|
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work has been started. These users each claimed they can complete the work by 3 weeks, 3 days ago. 1) stefanhans has been approved to start work. I've forked it and tested it. Next, I will analyze and play around a bit to get a deeper understanding especially from already implemented protobuf types etc. Then, I can start the first implementation or I have questions. Let's see. Currently, I've scheduled to work at two days a week on it. But, I can change that if needed. Learn more on the Gitcoin Issue Details page. |
I have analyzed and played around a bit...
Calling
returns
Am I on the right track? |
Yes, this looks good. Now the only thing that is missing are all the other edge cases, like nesting & repeated fields ;) |
valid conversions?
valid conversions?
or
|
For starters, I think you are using uint64 instead of uint32 for protobuf tag numbers. Additionally, phone is a repeated field in your example. This means that Additionally it looks like you are off by one. Phone's tag number is 13, not 12. For repeated fields, we are using a uint64 as an array index. So valid tags are:
I would recommend you check out the javascript implementation of this, it shows you all the different cases and rules: https://github.com/centrifuge/precise-proofs-js/blob/master/src/PropertyTransformHelper.js |
There is
at the core of the converter, isn't it? We walk through the protobuffer message type via reflect to convert the path of the structure to the matching node, right? This leads us to the bijective function of the converter. But this is not sufficient. There are other pieces of code using the converter output, right? |
These properties are built by iterating over all of the fields in an instance of the struct. So this works only when the exact instance of the struct is available. The converter must work solely by having access to the Protobuf struct, not an instance of it. This should example should make it clear:
Without an instance of the struct, you wouldn't know what the length of |
Thx, I'll work on tomorrow. |
Test for all used types and nested combinations finished (100% coverage) Generalized test "only a message type needed" mostly written - during that I've found combinations not covered Problems with the dev environment and protobuffer i.e. under examples/documents:
I will reset the whole environment and try to fix it first - next week |
@stefanhans Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!
Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days |
Hi there, I will continue my work tomorrow. @lucasvo Are you online at slack tomorrow afternoon? |
I had found a bug in the converter and I've decided to change to TDD. So, I've worked on a testing environment, i.e. tests which
It is a bit frustrating to find some missing cases (or little bugs), create or edit message types, add test cases, and to change already tested functions. Imho, without appropriate testing it would be very likely to have a buggy converter - if the converter must be able to work with every possible message type. Today is the last day of the bounty. Please give me feedback if you agree on my approach and if I should go on. |
I think the approach is good, the one thing that would be great is if you could use the existing example.proto messages to build the test cases. The rest of the library is built with it, those should be used as well for the converter of creating new ones. To generate the go bindings, check out the |
Hi Lucas,
I've not covered all test cases 😰 But I'm getting closer.
I've tried to solve the environment problem and came up
- having a fresh clone "github.com/centrifuge/precise-proofs"
- changed the import "proofs/proto/proof.proto"; to import "
github.com/centrifuge/precise-proofs/proofs/proto/proof.proto";
Next week I will
- finish the GetLiteralPaths which provides all literal properties of a
message type for the forward backward conversion tests
- then I debug the two converter functions
- finally we should test the special binary properties "[0 0 0 0 0 0 0 0]"
Cheers, Stefan
and 👋
please have a look if the syntax is correct:
PATH: documentspb.ExampleOfSimpleStruct 0: "Sstring"
PATH: documentspb.ExampleOfSimpleStruct 1: "Sint32"
PATH: documentspb.ExampleOfSimpleStruct 2: "Sbytes"
PATH: documentspb.ExampleOfSimpleStruct 3: "Sstruct"
PATH: documentspb.ExampleOfSimpleStruct 4: "Sstruct.VSstring"
PATH: documentspb.ExampleOfSimpleStruct 5: "Sstruct.VSint32"
PATH: documentspb.SimpleEntry 0: "entry_key"
PATH: documentspb.SimpleEntry 1: "entry_value"
PATH: documentspb.TwoLevelItem 0: "valueA"
PATH: documentspb.TwoLevelItem 1: "valueA.valueA"
PATH: documentspb.TwoLevelItem 2: "valueB"
PATH: documentspb.NestedRepeatedDocument 0: "valueA"
PATH: documentspb.NestedRepeatedDocument 1: "valueB"
PATH: documentspb.NestedRepeatedDocument 2: "valueC[0]"
PATH: documentspb.NestedRepeatedDocument 3: "valueC[0].valueA"
PATH: documentspb.NestedRepeatedDocument 4: "valueD"
PATH: documentspb.NestedRepeatedDocument 5: "valueD.valueA"
PATH: documentspb.NestedRepeatedDocument 6: "valueD.valueA.valueA"
PATH: documentspb.NestedRepeatedDocument 7: "valueD.valueB"
PATH: documentspb.Integers 0: "valueA"
PATH: documentspb.Integers 1: "valueB"
PATH: documentspb.Integers 2: "valueC"
PATH: documentspb.Integers 3: "valueD"
PATH: documentspb.Integers 4: "valueE"
PATH: documentspb.Integers 5: "valueF"
PATH: documentspb.Integers 6: "valueG"
PATH: documentspb.Integers 7: "valueH"
PATH: documentspb.Integers 8: "valueI"
PATH: documentspb.Integers 9: "valueJ"
PATH: documentspb.ExampleDocument 0: "valueA"
PATH: documentspb.ExampleDocument 1: "valueB"
PATH: documentspb.ExampleDocument 2: "value1"
PATH: documentspb.ExampleDocument 3: "value2"
PATH: documentspb.ExampleDocument 4: "value_bytes1"
PATH: documentspb.ExampleDocument 5: "ValueCamelCased"
PATH: documentspb.ExampleDocument 6: "value_not_ignored"
PATH: documentspb.ExampleDocument 7: "value_ignored"
PATH: documentspb.ExampleDocument 8: "value_not_hashed"
PATH: documentspb.ExampleDocument 9: "enum_type"
PATH: documentspb.SimpleItem 0: "valueA"
PATH: documentspb.Entry 0: "entry_key"
PATH: documentspb.Entry 1: "valueA"
PATH: documentspb.Entry 2: "valueB"
PATH: documentspb.Entry 3: "valueC"
PATH: documentspb.LongDocument 0: "value0"
PATH: documentspb.LongDocument 1: "value1"
PATH: documentspb.LongDocument 2: "value2"
PATH: documentspb.LongDocument 3: "value3"
PATH: documentspb.LongDocument 4: "value4"
PATH: documentspb.LongDocument 5: "value5"
PATH: documentspb.LongDocument 6: "value6"
PATH: documentspb.LongDocument 7: "value7"
PATH: documentspb.LongDocument 8: "value8"
PATH: documentspb.LongDocument 9: "value9"
PATH: documentspb.LongDocument 10: "valueA"
PATH: documentspb.LongDocument 11: "valueB"
PATH: documentspb.LongDocument 12: "valueC"
PATH: documentspb.LongDocument 13: "valueD"
PATH: documentspb.LongDocument 14: "valueE"
PATH: documentspb.InvalidHashedFieldDocument 0: "value"
PATH: documentspb.ExampleOfVerySimpleStruct 0: "VSstring"
PATH: documentspb.ExampleOfVerySimpleStruct 1: "VSint32"
PATH: documentspb.ExampleOfRecursiveStruct 0: "RSstring"
PATH: documentspb.ExampleOfRecursiveStruct 1: "RSstruct"
PATH: documentspb.AllFieldTypesSalts 0: "string_value"
PATH: documentspb.AllFieldTypesSalts 1: "time_stamp_value"
PATH: documentspb.RepeatedItem 0: "valueA[0]"
PATH: documentspb.RepeatedItem 1: "valueA[0].valueA"
PATH: documentspb.RepeatedItem 2: "valueB"
PATH: documentspb.SimpleEntries 0: "entries[0]"
PATH: documentspb.SimpleEntries 1: "entries[0].entry_key"
PATH: documentspb.SimpleEntries 2: "entries[0].entry_value"
PATH: documentspb.BytesKeyEntries 0: "entries[0]"
PATH: documentspb.BytesKeyEntries 1: "entries[0].address"
PATH: documentspb.BytesKeyEntries 2: "entries[0].value"
PATH: documentspb.AllFieldTypes 0: "string_value"
PATH: documentspb.AllFieldTypes 1: "time_stamp_value"
PATH: documentspb.AllFieldTypes 2: "time_stamp_value.seconds"
PATH: documentspb.AllFieldTypes 3: "time_stamp_value.nanos"
PATH: documentspb.Entries 0: "entries[0]"
PATH: documentspb.Entries 1: "entries[0].entry_key"
PATH: documentspb.Entries 2: "entries[0].valueA"
PATH: documentspb.Entries 3: "entries[0].valueB"
PATH: documentspb.Entries 4: "entries[0].valueC"
PATH: documentspb.BytesKeyEntry 0: "address"
PATH: documentspb.BytesKeyEntry 1: "value"
PATH: documentspb.TwoLevelRepeatedDocument 0: "valueA"
PATH: documentspb.TwoLevelRepeatedDocument 1: "valueB[0]"
PATH: documentspb.TwoLevelRepeatedDocument 2: "valueB[0].valueA[0]"
PATH: documentspb.TwoLevelRepeatedDocument 3:
"valueB[0].valueA[0].valueA"
PATH: documentspb.TwoLevelRepeatedDocument 4: "valueB[0].valueB"
╭
…On Wed, Jan 23, 2019 at 8:06 PM Lucas Vogelsang ***@***.***> wrote:
I think the approach is good, the one thing that would be great is if you
could use the existing example.proto messages to build the test cases. The
rest of the library is built with it, those should be used as well for the
converter of creating new ones.
To generate the go bindings, check out the go:generate instruction:
https://github.com/centrifuge/precise-proofs/blob/master/examples/documents/documents.go#L3
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#34 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIQmAv-leyiujK_G4SRVkq8l6jnNYwaTks5vGLK9gaJpZM4ZBkwo>
.
|
@stefanhans Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!
Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days |
Currently, I'm sick, but I will continue to work on Friday, latest. |
I did some work today. I'm still a bit sick. It was not very effective 😞 Concerning the message type NestedMap, are this all literal properties? "value[0]" |
I do exclude recursion and return an error, e.g.
|
Did you already submit a "WiP PR"? That's usually easiest to see what the status is so far. |
Not yet. I did not want to spam with my code before I'm sure how to design the converter. Actually, I did a fresh start after ending up with a too much confusing design. Maybe I'm overdoing it. But if the code is not maintainable before it's done, I hesitate to finish it anyhow. Especially, if I do not know how far I have to go still. |
We should create a helper that can take a binary property and convert it to a literal property without having an instance of the message available but only the type. The converter needs to be smart enough to concatenate nested fields and repeated fields.
Acceptance Criteria:
string
, a protobuf autogenerated struct type and returns the compact property as[]byte
[]byte
, a protobuf autogenerated struct type and returns a literal property asstring
For more info on literal types and it's implementation see
#29
The text was updated successfully, but these errors were encountered: