Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Is storage value of Option<()> supported? #5986

@xlc

Description

@xlc

We have few storage value with double map X, Y => Option<()> type to simulate an unordered set.

However I found out the .iter(key1) is not able to iterate all the values for key1.
Using getStorage RPC is able to read that storage did exists. getKeys is not able to iterate as the key wasn't exists.

Seems like the trie db is not able to distinguish between a non-exist key and an exist key with no value in some cases?

Change the type to Option<bool> works around the issue for me.

Example code:

https://github.com/laminar-protocol/laminar-chain/blob/f53fb6044ffa431993e4467f320f93af1b042ce2/modules/margin-protocol/src/lib.rs#L79

https://github.com/laminar-protocol/laminar-chain/blob/f53fb6044ffa431993e4467f320f93af1b042ce2/modules/margin-protocol/src/lib.rs#L667

This is not able to iterate.

The interesting thing is it works in unit test so we wasn't able to catch this issue before. Maybe something to do with low level db? The in memory db is able to handle but the real rocks db is not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    I3-bugThe node fails to follow expected behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions