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

protobuffer inconsistency #21

Open
joticajulian opened this issue May 30, 2023 · 1 comment
Open

protobuffer inconsistency #21

joticajulian opened this issue May 30, 2023 · 1 comment

Comments

@joticajulian
Copy link
Owner

Let's say we have the following proto:

message test {
   uint64 a = 1 [jstype = JS_STRING];
   repeated uint64 b = 2 [jstype = JS_STRING];
}

and we want to encode the message

{a: 10, b: [54, 55, 56]}

koilib (protobuffers.js) encodes it as:

hex value: 08 0a 12 03 36 37 38

However, as-proto encodes it as:

hex value: 08 0a 10 36 10 37 10 38

This inconsistency makes the contracts exit with transaction reverted: module exited due to trap because as-proto is not able to decode the data created in koilib.

By looking to the documentation it seems that as-proto is using the correct encoding https://protobuf.dev/programming-guides/encoding/#optional.

Verify this and report the issue to the corresponding library.

@joticajulian
Copy link
Owner Author

Note: This issue is solved by using a nested message in the repeated field.

Example:

message mynumber {
   uint64 value = 1 [jstype = JS_STRING];
}

message test {
   uint64 a = 1 [jstype = JS_STRING];
   repeated mynumber b = 2;
}

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

1 participant