Why the change in BlockByHeightArgs from U64 to U32?

Hey all,

noticing a change in BlockByHeightArgs in fuel-core-client schema, from U64 in v0.20.4 to U32 in v0.21.0+

I can see the comment as:
“void possible truncation of higher bits. It may invalidate the code that truncated higher bits causing different behavior on 32-bit vs. 64-bit systems. The change affects some endpoints that now require lesser integers.”

and the PR:

Just curious why we expect only up to a 32 bit number here, surely we expect the node to accumulate over 2^32 blocks over time?

from:

#[derive(cynic::QueryVariables, Debug)]
pub struct BlockByHeightArgs {
    pub height: Option<U64>,
}

to:

#[derive(cynic::QueryVariables, Debug)]
pub struct BlockByHeightArgs {
    pub height: Option<U32>,
}

in this commit:

Hi there!
32 bits is generally sufficient to store block height for most blockchains.

2^32 ~= 4.3 billion. At one block per second, that would still be 136 years until an overflow would occur, and we can upgrade the network at that time if needed.

Ok cool, just checking it was an intentional change.

rough calcualtion:

beta-4 testnet height is currently 13138944 and since its announcement on the fuel blog is ~133 days. That’s about 3M blocks/ month. which means to get to ~4B blocks would take 119 years. I think were probably good :slight_smile:

((2^32)/(13138994/(133/30.41)))/12 = 119.138 years

in saying that, if mainnet is 5x the tx volume, its ~20 years. But i doubt there would be the same schema framework in that time.

1 Like