1Hive / wiki-app

A decentralized wiki to store DAO documetns
0 stars 0 forks source link

Decide the format of IPFS hashes in Solidity #7

Open sembrestels opened 4 years ago

sembrestels commented 4 years ago

ENS uses a bytes to store IPFS hashes, meanwhile Quasar uses plain strings. Probably it is more convenient to store them in a string so this way it is easier to be shown by radspec.

pepoospina commented 4 years ago

I used two bytes32 entries and it saves 20-25% gas costs compared to a string. I understand bytes and string are equivalent in gas terms.

sembrestels commented 4 years ago

Splitting a CID in two parts is an interesting idea, thanks for sharing!

I wanted to follow the same approach used in EIP-1577 for future compatibility with ENS, but I think that it gives us more problems than benefits. It encodes the binary raw data of CID in bytes variables, so it costs a lot of gas and it's difficult to read from radspec.

Enconding a base58 CID in two bytes32 is cheaper in terms of gas, and can be represented in radspec using the @fromHex helper.

Sounds like a good way to go. I'll give it a try soon. Thanks @pepoospina.

pepoospina commented 4 years ago

Hey, just an update. I now use events instead of storage. It's hard to think of a scenario where you will have smart contracts reading the IPFS hash, isn't it?

Using events is much gas-cheap than storing bytes or strings.