I understand from here that the space for mapping() is drawn from a size of 2^256 * 32 bytes storage, which provides a 1 chance in 10^69 of overwrites. If I'm working with contracts on the order of 10^100, is there a bigMapping() function that could be used for bigger map spaces?

I'm imagining an implementation like this https://mikemcl.github.io/bignumber.js/ for arbitrary precision.

  • What do you mean by "If I'm working with contracts on the order of 10^100?" – Rob Hitchens - B9lab Nov 13 '18 at 20:00
  • I'd like to have 10^100 elements in my map. – Mittenchops Nov 13 '18 at 20:01
  • 1
    You really don't want to do that. It's simply too many to be sensible. If you would like to store a reasonable quantity of very precise numbers, or even very complex objects, that would be feasible. – Rob Hitchens - B9lab Nov 13 '18 at 20:44
  • I understand it is not conventional, but suppose I mean exactly this and do have a sense to it. It's not possible in solidity is the answer? – Mittenchops Nov 13 '18 at 20:58
  • 1
    You could use two contracts which will give you 2^256*32 + 2^256*32 = 2^257*32 bytes of storage. Unfortunatelly you cannot use 2^256 contracts because contracts are indexed by address which is only 20 bytes. The maximum total storage by Ethereum is then 2^160 * 2^257*32 = 2^416*32 bytes. But you could deploy another blockchains! – Ismael Nov 13 '18 at 21:47

The limitation of 2^256 storage spaces is a hard limit. It's the limit that the EVM allows, the opcodes for storage simply can't accept parameters larger than it.

That aside, I can't think of any reason why you would need even close to 2^256 storage slots. 2^256 is 3.7 × 10^66 terabytes of storage. Even if you had a use for all that storage it would take 2.9 * 10^74 blocks at current gas limit to fill and the transaction fees would be many, many orders of magnitude more than there exists eth.

  • Unfortunately, that is the bounds of the (sparse) space I am in fact dealing with. – Mittenchops Mar 15 at 18:38
  • don't use a blockchain – flygoing Mar 15 at 18:51
  • I'm amazed at the resistance I keep seeing in this space for anyone doing something other than exactly what is prescribed. I've met more open-minded .NET programmers. – Mittenchops Mar 15 at 22:18
  • I'm not being closed minded, I'm telling you it's mathematically, physically, and financially impossible to store as much data as you claim you need on the Ethereum blockchain. If you need to store even a GB of data, I would tell you you're looking at the wrong technology, and you're telling me you need to store 10s of orders of magnitude more than that – flygoing Mar 16 at 1:12
  • It actually isn’t impossible. There are bigInteger libraries in a number of languages, including JavaScript, and they are very possible. In addition to not being mathematically or physically impossible, storing a single number of size uint256+1 is also not financially impossible. It could be represented at the cost of 2 uint256 values. My question and comment were about a sparsely populated space, drawn from a big space, not densely storing GBs fully populating It. – Mittenchops Mar 16 at 4:57

Your Answer

