erasureprotocol / erasure-protocol

Information wants to be expensive
https://erasure.world/
MIT License
161 stars 27 forks source link

Factory uses bytes4 to track instanceTypes, this is unjustifiably restrictive #278

Open fulldecent opened 4 years ago

fulldecent commented 4 years ago

The Factory contract wants to track types of contracts. It does this using a bytes4 type. It seems this is inspired from the ERC-165 standard.

The baseline choice should be using a full 32 byte hash. The bytes4 costs more gas to store, retrieve and compare (EVM stores a whole word, Solidity handles truncation) also it has less collision resistance.

As an author of ERC-165 I think bytes4 is a bad choice here.

Recommendation: use a full word hash

References: Definition https://github.com/erasureprotocol/erasure-protocol/blob/4a3d98ce023a264a9f3c7ba62ef77a9207bba5fe/contracts/modules/Factory.sol#L20

thegostep commented 4 years ago

Change would require redeployment of registries, added for v2