Skip to content

Conversation

erikd
Copy link
Contributor

@erikd erikd commented Jul 23, 2020

No description provided.

This column is the sum of transactions outputs for the epoch. On
test networks (never been seen on mainnet) it is possible for this
sum to end up larger than the maximum positive value that can be
stored in a 64 bit signed integer ('Int64'). However, the output sum
was being stored store in a 64 bit unsigned integer ('Word64') but
the Persistent library does not correctly supported 'Word64'. Instead
it "casts" it from 'Word64' to 'Int64'. For values great that the
max positive value of an 'Int64' this results on the value wrapping
to negative and hence being rejected by the SQL domain constraint
which requres 'outsum >= 0'.

This solution switches 'outsum' in the Haskell world from 'Word64'
to 'Word128' which is incredibly unlikley to overflow given the
limitation on number of transactions per block and per epoch. On
the SQL side we use an PostgreSQL type of 'numeric (38, 0)'.

Closes: #197
@erikd erikd merged commit 9f6ab7a into master Jul 24, 2020
@iohk-bors iohk-bors bot deleted the erikd/word128-outsum branch July 24, 2020 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant