We see some lease and cancel lease txs, but all cancel lease txs are cancelling only first lease tx (4X85MhqxukwaPqJC4sSSeN3ptSYHbEca7KgiYtUa2ECX). How does a node calculate zero here?
Moreover, if these cancel tx duplicates seem wrong, why a legal lease tx canceled from 3N65xeNsETsQT6NncwpufwVAkTpiabRRpUm?
In the early days of leasing we had several bugs with it, like one could cancel the same lease twice.
There were more, you can find relative examples in tests. To revert unlawful mining balance changes, all leases were canceled at some point, and minig power was reset for each miner. Hence patch, cancelling all leases
Another patch I remember was relative to leasing funds that were leased to an account.
The rest details depend on what you are actually trying to achieve.
if you look into blockdiffer, you’ll see three different patches applied at certain heights:
The issue that you are struggling with is different.
You are looking at account which, if I remember correctly, cancelled a lease which another account performed, multiple times. This is one bizzare instersection of bugs, and we have to support it in consensus for that time:
Here, it’s canceller, not the leaser, who decreased lease-out.
Now, if your goal is to process waves blockchain with your code, you’ll have to reimplement all these issues, probably by writing tests.
What exact block or transaction are you struggling with?