Coder Social home page Coder Social logo

Earned fees calculation about suez HOT 12 CLOSED

prusnak avatar prusnak commented on July 18, 2024
Earned fees calculation

from suez.

Comments (12)

prusnak avatar prusnak commented on July 18, 2024

Isn't the fee in fwdinghistory always the fee earned by my node?

If I do the suggested change, the earned_fees is around half of what lncli feereport shows as month_fee_sum. If I keep it unchanged, the numbers are almost the same (difference <100 sat).

from suez.

sipsorcery avatar sipsorcery commented on July 18, 2024

Isn't the fee in fwdinghistory always the fee earned by my node?

Yes, that's my understanding. But isn't the suez script counting the fee twice for each forward:

(snippet bwlow adjusted for brevity)

for fe in fwd_events:
	c1 = fe["chan_id_in"]
	c2 = fe["chan_id_out"]
	fee = int(fe["fee"])
	if not c1 in fees:
		fees[c1] = 0
	if not c2 in fees:
		fees[c2] = 0
	fees[c1] += fee  # Why record the fee against the incoming channel?
	fees[c2] += fee 

If I do the suggested change, the earned_fees is around half of what lncli feereport shows as month_fee_sum. If I keep it unchanged, the numbers are almost the same (difference <100 sat).

Very strange. In my case it's the opposite. lncli feereport is approx. half of what suez calculates. If I adjust the suez script to not record the forwarding fee against the incoming channel they are within 48 sats.

from suez.

prusnak avatar prusnak commented on July 18, 2024

My understanding is that one of the channels listed in fwd_events is mine, the other is not mine. I record both, because I don't know which is mine or not at this point. But later I look into the correct records, leaving not mine channels without access.

I might be wrong, though.

from suez.

prusnak avatar prusnak commented on July 18, 2024

I did a small refactor in 094e952, but that does not change functionality at all.

When I run bos forwards --days 30, it shows Earned In and Earned Out with total matching value in my table, so it seems node earns fees for both in and out channels.

bos = https://github.com/alexbosworth/balanceofsatoshis

from suez.

prusnak avatar prusnak commented on July 18, 2024

Btw, there will be always discrepancies when a channel was closed in the last 30 days - my table does not show closed channels at all, while lncli fee_report and lncli fwdinghistory take these into account.

from suez.

sipsorcery avatar sipsorcery commented on July 18, 2024

When I run bos forwards --days 30, it shows Earned In and Earned Out with total matching value in my table, so it seems node earns fees for both in and out channels.

I think bos does some kind of double entry book-keeping in the bos forwards table. The fact the Earned In total exactly matches the Earned Out table supports that likelihood.

I did see Alex Bosworth explain this to someone else, I think it was on the Telegram group. I'll see if I can dig up the explanation.

Btw, there will be always discrepancies when a channel was closed in the last 30 days - my table does not show closed channels at all, while lncli fee_report and lncli fwdinghistory take these into account.

Ah, I didn't even think of that. That could explain the 48 sat discrepancy I am getting. I'll see if I can double check that on my node somehow.

from suez.

sipsorcery avatar sipsorcery commented on July 18, 2024

Alex confirmed that the Earned In and Earned Out columns produced by bos forwards are using double entries. The total earned fees is Sum(Earned Out), (which is == Sum(Earned In)).

bos_forwards

from suez.

prusnak avatar prusnak commented on July 18, 2024

I have trouble understanding why all these 3 values are the same on my system:

  • month_fee_sum in lncli feereport
  • your script from the OP
  • earned fees total in suez table

from suez.

prusnak avatar prusnak commented on July 18, 2024

Argh, I get it now. I had one closed channel that earned approx 1/2 of the total fees, which confused me ...

Thanks

from suez.

sipsorcery avatar sipsorcery commented on July 18, 2024

How come lncli feereport shows approx the same value in month_fee_sum as in suez earned fees total?

That I can't explain, unless, as you alluded to, the fees from closed channels in the lncli feereport coincidentally match the value of your active channels.

For one of my nodes:

$ lncli feereport
"month_fee_sum": "2039"

$ suez
earned fees (sat) 3,998

$ bos forwards --days 30
sum(Earned Out)=2007

$ lncli fwdinghistory --start_time -30d --max_events 5000 | grep '"fee"' | sed -nr 's/."([0-9]+)./\1/p' | a
wk 'BEGIN {total=0;}{total+=$1;}END {print "Total: ",total}'

Total: 2007

from suez.

prusnak avatar prusnak commented on July 18, 2024

I believe I fixed the issue in a0d43b9 (by splitting into local and remote fees). Can you please confirm the numbers are now what you expect?

from suez.

sipsorcery avatar sipsorcery commented on July 18, 2024

I believe I fixed the issue in a0d43b9 (by splitting into local and remote fees). Can you please confirm the numbers are now what you expect?

Pretty close.

I have a discrepancy between the local fees (sat) total of 1991 and the remote fees (sat) total of 2007. A channel I closed in the last 30 days did earn a relay fee of 16. The closed channel does show up in bos forwards. Probably not that big a deal.

IMHO the local & remote fee columns do create a bit of confusion. I found the previous earned fees column more intuitive. There is only one relay fee for each lightning payment, which is the relay fee on the outgoing channel, so it's not as if there really is a local and remote component. This is purely personal preference though. The script now looks to be working well enough for me. Thanks for your work!

from suez.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.