1

I know that mapping use addresses, based on a hash of key + position of mapping storage variable

keccak256(bytes32(variable_address) + bytes32(key))

And I want to know where variable would be stored if this address is already used?? Yes, possibility of hash collision is really low, but it is still possible.

2

The other value will simply be overwritten in the case of a hash collision. By just writing to a mapping, your program will not notice that there was a hash collision.

The size of the virtual address space of the state variable storage is 2^256 * 32 bytes.

The chance of a hash collision is not just 'really low' it is astronomically low.

The chance is about 0.00... (70 more zeroes here) ... 001%. You are more likely to win the jackpot in a national lottery 8 times in a row. There are other things to worry about in life than hash collisions.

This resource may help you learn more:

http://solidity.readthedocs.io/en/develop/miscellaneous.html#layout-of-state-variables-in-storage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.