News for hackers. Stuff that matters.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by jazzyjackson on Monday September 27, 2021 @05:19PM (#28676164)
My guess is Integer VS Float.

Take a typical $23 transaction fee, which comes out to ~0.00775756 ETH

Of course, everyone knows you don't want to do math as floating point, you want to use an integer representation. 1 ETH can be divided into 1e18 "Wei" or 1e9 "GigaWei".

So that 23 USD could be expressed an an integer "7757560", with the expectation that the decimal point would get moved 9 points <- thataway to become 0.00775756 ETH

If somewhere in your code you do some kind of money formatting that turns 7757560 GWEI into 7757.56 ETH, you've got your $23,000,000 USD mining fee.

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by xvilka on Monday September 27, 2021 @11:40PM (#28679060)
This is why in "classic" fintech they used so-called "decimal" fixed-point numbers for decades. To not use COBOL as an example let's check something more modern, e.g. Rust[1].

[1] https://github.com/paupino/rust-decimal

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by MichaelBurge on Tuesday September 28, 2021 @03:02AM (#28680068)
Ethereum uses integers to store transaction amounts internally. Integers are fixed-point already, so that library is completely irrelevant.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by xvilka on Tuesday September 28, 2021 @04:04AM (#28680367)
I didn't mean Ethereum itself, apparently the bug is in whatever code written at the higher level, inside the exchange or whatever service they use.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by jallen_dot_dev on Tuesday September 28, 2021 @07:51AM (#28681695)
This sounds about right but I think the mistake is a little bit simpler. In an eth transaction you don't actually specify the total fee, you specify the gas price. In the raw transaction it is measured in wei. But in UIs it is common to represent price in gwei (see e.g. https://ethgasstation.info/).

So instead of a bug in converting gwei to eth, I bet somebody thought they were specifying the raw price in wei but the input box assumes gwei and does a x1000000000.

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by ericwood on Wednesday September 29, 2021 @06:21PM (#28700751)
It looks like you were pretty much correct: https://blog.deversifi.com/23-7-million-dollar-ethereum-tran...
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by ajsharp on Monday September 27, 2021 @05:39PM (#28676359)
you win HN today, jazzy
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by csomar on Tuesday September 28, 2021 @06:51AM (#28681284)
But then, they should have basic "high mining" fees checks. My Trezor does have that.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by quotemstr on Monday September 27, 2021 @05:29PM (#28676260)
My position for ages now has been that it was a mistake to make floating point types first-class primitives in most programming languages. Integers and rationals should be the go-to types for most code most of the time. If you really need a IEEE float, you should reach into a library to get it.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by kevinpet on Monday September 27, 2021 @05:39PM (#28676364)
Well, this isn't very strong support for that position, because Ethereum doesn't support floating point, and yet here we are.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by jonny_eh on Monday September 27, 2021 @05:47PM (#28676439)
> Ethereum doesn't support floating point

The software that interacts with it does.

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by rightbyte on Monday September 27, 2021 @05:39PM (#28676360)
I think you mixed up the problem. Had they used floats they would have got a small rounding error, not a 23 million loss.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by mhh__ on Monday September 27, 2021 @05:40PM (#28676373)
So all companies will automatically include the float library and thus nothing will change
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by WillDaSilva on Monday September 27, 2021 @11:02PM (#28678836)
What you include as a first-class element in your languages, versus what is packed away in a library, will affect what developers do with your language.

For instance, Numpy provides array-language [1] capabilities to Python, but because it isn't a first-class element in the language Python is not thought of as an array language, and using it as one would be a bit clunky.

[1] https://en.wikipedia.org/wiki/Array_programming

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by webkike on Tuesday September 28, 2021 @01:35AM (#28679659)
If the only thing you use computers for is processing financial transactions then that position is defendable
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by abraae on Tuesday September 28, 2021 @02:19AM (#28679848)
Any number of sensors, measuring devices and other IoT stuff disagrees with you.
Re:Bitfinex just spent $23.7M in fees to make a single Ether... by MuffinFlavored on Monday September 27, 2021 @09:23PM (#28678221)
Dumb question on my end, I apologize.

How are rationals used to represent decimals?

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by dragonwriter on Monday September 27, 2021 @09:26PM (#28678246)
> How are rationals used to represent decimals?

Decimals are just the subset of rationals where the denominator is always a power of 10, so the representation and arithmetic operations are simple if you already have rational support (though if you need to preserve decimal results, you need approximation logic for division, since dividing two rationals with denominators that are powers of 10 may result in a rational with a denominator that is not a power of 10.)

Re:Bitfinex just spent $23.7M in fees to make a single Ether... by thaumasiotes on Monday September 27, 2021 @09:37PM (#28678310)
> though if you need to preserve decimal results, you need approximation logic for division, since dividing two rationals with denominators that are powers of 10 may result in a rational with a denominator that is not a power of 10.

This is also true for adding, subtracting, and multiplying, though in those cases it is always trivial to convert the result into a form where the denominator is a power of 10.