-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Using blake2_128_concat
instead of blake2_256
for storage key in pallet-contracts
child storage
#7724
Comments
CC @athei |
I agree with you. Contracts should also make use of transparent hashing. We re-hash the key to prevent attackers to unbalance the trie. But transparent hashing should achieve the same goal because the attacker cannot choose the prefix.
I would assume that the source is already a hash. To discover the "real" source would require that this is also a transparent hash, right? But the keys supplied to pallet contracts must be 32 byte in size. So I don't know how this could work out. |
Emmm, you are right. I forget the All in all, the 3rd parites client requirement is that, if using some method to get a raw key, then the 3rd parties could parse the raw way through metadata to get the source key. Like in runtime, when export the states for a block height, it's all raw keys and values, then we could parse the raw key to get the information which module and storage the key belongs to. This is very useful for substrate-archive to parse data and something else like statistics application. But it seems be impossible under current |
Yes. In order to make this work we also need to change That would also make |
@Robbepop I think we should make this happen. Having transparent hashing for contract storage would allow for a much better UX when using a generic block explorer. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Closed in favor of #11029 |
Currently,
pallet-contracts
module usingblake2_256
rather thanblake2_128_concat
for hashing a contract storage key:substrate/frame/contracts/src/storage.rs
Lines 47 to 49 in 445fa2d
and
substrate/frame/contracts/src/storage.rs
Lines 71 to 72 in 445fa2d
then in runtime, all storages already have used
xxx_concat
(likeblake2_128_concat
) hash to replacexxx
(likeblake2_256
) to let a storage key contains the source information. In this way, the third parties could parse the hashed key to get the source key information.I think
pallet-contracts
also needs this feature, thus, I advice maybe we need to change theblake2_256
hash toblake2_128_concat
, or design another hash way to let the hash contains the source key information.Maybe using
blake2_128_concat
instead ofblake2_256
is a simple way.Thanks.
The text was updated successfully, but these errors were encountered: