Is there a max size of a mapping?

I want to use an EnumerableMap from OpenZeppelin to map addresses to uin256s. Is there a maximum size of this mapping that I need to keep in mind? If I plan on storing a maxing of 2500 values in the mapping, do I have anything to worry about?

No, you can map every possible key to some value.

In fact, every possible key IS already mapped to the zero value by default.

Yes, but it is more of a theoretical issue than a practical one:

  • EnumerableMap uses EnumerableSet
  • EnumerableSet uses an array
  • The length of an array is limited to 64 bits
  • Hence an array can store at most 2^64-1 items
  • Hence EnumerableSet can manage at most 2^64-1 items
  • Hence EnumerableMap can manage at most 2^64-1 items
1 Like

Thank you so much, @barakman !

1 Like