cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
17 stars 37 forks source link

Type input indices as `uint64` #209

Closed guidanoli closed 6 months ago

guidanoli commented 6 months ago

📚 Context

The EVM word is 256 bits long. That is why uint256 is so ubiquitous in Solidity. Outside the EVM, however, 256-bit unsigned integers are not that common to find. In some cases, 256 bits may be a bit too much. UNIX timestamps, for example, will overflow with 32-bit signed integers in 2038, and with 32-bit unsigned integers in 2106. Input indices don't need 256 bits. The Ethereum blockchain, for example, haven't even reached $2^{32}$ yet.

✔️ Solution

Type input indices as uint64.

:brain: Rationale

We assume applications won't receive more than $2^{64}$ inputs. With this, we can save on-chain space and avoid uint256 in off-chain components.