Hi Poinsot,
Started to review a bit the code branch on inquisition, and while doing so I was specifically
thinking about the proposed 2500 sigops limit, and how it weights on a multi-dimensional matrix
of a full-node performace (e.g fees, CPU time, disk space, etc).
Currently, in a simple model, a DoS adversary could constitute a 1-MB (it's pre-segwit acoutning)
transaction with 80_000 sigops from a 1-sat UTXO. A full-node to validate that would have to SHA256
the 1MB tx 80_000 times, thus the O(n^2) "bad" complexity.
Assuming the novel per-tx 2500 sigops limit, still a simple DoS adversary could constitute 32 * 32_150
virtual bytes tx (it's still a 1 MB block) spending from _32_ 1-sat UTXOs. A full-node to validate that
would have to fetch the 32 UTXOs.
This is the 1 UTXO from 32 UTXOs trade-off, I would like to draw awareness on, as fair the O(n^2)
complexity is "bad" but quid of the UTXO memory fetches if there are not in your high-hierarchy cache
and they have to be fetched from RAM, or even worst from disk (i7 core have RAM bigger than the current
UTXO set, not necessarily all range of RasPi).
From the viewpoint of a defending full-node, sure I can limit the number of per-tx sigops, but if an
adversary can achieve the same DoS efficiency now that more than UTXOs have to be fetched to validate
the same per-block total number of sigops, it's a legitimate wonder about the efficiency limit, and
more interestingly if there wouldn't be a better value to be selected.
So it's a bit my interrogation about this 2500 proposal, if worst-case transactions samples binding
to the 2500 limit have been crafted to maximize the number of UTXOs fetches. One can make the hypothesis
that UTXO fetches are "free", but I don't think it's necessarily true, while on the other hand modern ISAs
have dedicated hashing instructions.
Current BIP54 is a bit silent if full-node performance metrics like CPU cycles, IO disk operations or
bandwidth consumptions have been weighted in to select the proposed 2500 value of the limit. This would
be a fair point to modify BIP54 to say that the new sigops limit is only aimed to mitigate CPU DoS
and that others dimensions like memory management have not been emperically observed to be downgraded.
Best,
Antoine
OTS hash: 975674252060994d92eecd63a924e7530623ee737e33c5646d382f0f8c04ec74