-
Notifications
You must be signed in to change notification settings - Fork 1k
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
StorageKey - why use WriteBytesWithGrouping()? #793
Comments
I think the same as you, should be a regular write |
It is for "Find()". See #200 |
Thanks 😞 I don't see this changing anymore for This would mean updating |
I always wanted to know this! hahaha :) |
It's a client thing. Neo-python doesn't use it and |
It has to do with the way the length is encoded. I had to deal with this in some of the plugins I wrote. It should be able to get the length from LevelDB though and not need to encode the length into the key. I didn’t deep dive to fix it, but it should be fixable for NEO 3.0. As long as the storage engine can save and report key length; which it can, there isn’t a good reason to do what is being done. |
* fix issue neo-project#791 * follow up * follow up * add example
May I ask to reopen this bug? I think the issue is still relevant for NEO 3, but now with #1383 changes it has deeper impact for node compatibility. In neo-go we also have implemented a simpler key serialization scheme without grouping and it works fine (some conversion is needed to compare our 2.0 state with neo-storage-audit, but that's a minor annoyance affecting just that --- state change dumps), but now if MPT is to be added using this scheme then we will have to either change the key serialization format or make conversions for MPT calculations. None of these options make me happy as I think it should be trivial to fix it in C# code (and simplify C# code at the same time). |
Yes, we should create a standard. Could you share your |
We just don't do any grouping, we append byte representation of the key to the scripthash, like this: And it works for |
Please check this thread #199 the problem for us is |
Exactly! |
I've seen that, but we do not use
Well, if it's just to make this Update: I see I mean, from pure DB design perspective (especially given that after #1383 every implementation will have to deal with this format one way or another) this doesn't seem to be necessary to do the job, so making this transformation a standard required for proper MPT implementation doesn't seem to be a good solution to me, there should be some room for more efficient implementations. |
OK, so we have stream-based What I'm thinking about is that every stream has an end, one way or another. So I can't see anything preventing us from creating a Pros:
Cons:
What do you think? |
Network stream hasn't an end. |
Luckily we're not dealing with networking in this particular case. I do understand that it makes Also, again, it's one thing for an implementation to have whatever encoding scheme it wants to and it's completely another thing to standardize something at the protocol level. So what I'm really concerned about is MPT calculation (which is soon to be a part of the protocol), I think it'd be nice to have simpler encoding used for it even if |
I'm doing an audit between
neo-python
andneo-cli
and encountered an issue with one of the storage keys. Specifically blocks131179
of TestNet reports a new storage item added beingThe key can be broken down into:
2170e2e4a128ba6b287b14c1ad4be8d03bbf04f0
313131313131313131313131313131310031313131313131313131
00000000000006
(to create 16 byte alignment)if you look closely at the key value you'll see there is a
00
inserted after 16 bytes. The actual key (as can be seen in the screenshot) does not have this00
byte.This deviation is caused by
WriteBytesWithGrouping()
in the code belowneo/neo/Ledger/StorageKey.cs
Lines 43 to 46 in 55ffca9
My question is;
Why are we using this method for serialization instead of a normal
write
?It gives unexpected behaviour when you use it (like done here in the StatesDumper plugin):
I believe the key should be the real key, not some modified form.
The text was updated successfully, but these errors were encountered: