solang icon indicating copy to clipboard operation
solang copied to clipboard

Make `uint` default to `uint64` rather than `uint256`

Open seanyoung opened this issue 3 years ago • 4 comments

The default size for int and uint is currently 256 bits. This is very inefficient on all the chains we support.

We should change the default for solidity and yul.

How much contract breakage will we have? Is this a bad idea?

seanyoung avatar Jun 15 '22 15:06 seanyoung

On Wasm, pointers are 32 bit. Will this break stuff?

seanyoung avatar Jun 15 '22 15:06 seanyoung

In Solang, uint rr = uint(address(this)); works fine. How are we going to handle this on Solana, where addresses are 256-bit wide and uint is 64-bit wide?

LucasSte avatar Jun 16 '22 09:06 LucasSte

In Solang, uint rr = uint(address(this)); works fine. How are we going to handle this on Solana, where addresses are 256-bit wide and uint is 64-bit wide?

Of course it is possible to write code that breaks if we change the default type of uint and int. We should be concerned about actual existing code that people use that will break. To paraphrase, what will users complain about if we change this?

seanyoung avatar Jun 16 '22 10:06 seanyoung

I am not sure whether this is a good idea. As a Solidity compiler, we should stick to whatever is default in the Solidity language. I fear that by changing that we open a can of worms.

Based on the real world contracts I saw so far. The 256bit int types are used heavily. We'd have to spend a lot of time on analyzing all the implication stemming from changing that. And I'm sure there are unpredictable bad side effects in existing contracts if this is changed.

Yes, using this integer type should be avoided on the targets we support mainly for performance reasons, but I think we can just declare this to be a documentation issue.

xermicus avatar Jun 27 '23 09:06 xermicus