Can Miners Really Tackle the Knapsack Problem?

18 replies 55 views
sage23Senior Member
Posts: 4 · Reputation: 1996
#1Feb 2, 2019, 02:17 AM
Do miners really use tools like Gurobi to solve the knapsack problem for picking the most profitable transactions? I'm just curious about how honest miners maximize their profits.
6 Reply Quote Share
whale420Senior Member
Posts: 727 · Reputation: 853
#2Feb 2, 2019, 02:54 AM
Knapsack problem? Never heard of that before. Did some digging and it seems to relate to block sizes. But with Bitcoin, you can't just pick and choose transactions to include while mining, right? Unless you’re a pool with a ton of hashrate.
0 Reply Quote Share
cobra51Newbie
Posts: 100 · Reputation: 31
#3Feb 2, 2019, 07:31 AM
Not sure how they do it, honestly. Each miner has unique software, and it’s tough to know what’s going on. You can check the usual implementations, but it’s hard to validate since you can’t access the same mempool as the miners.
2 Reply Quote Share
Posts: 44 · Reputation: 168
#4Feb 2, 2019, 09:27 AM
Interesting point! The 100 kvB limit is there to help miners make this decision. When transactions get too close to the block size, figuring out the best combo of transactions becomes a real headache.
5 Reply Quote Share
jakecobraFull Member
Posts: 326 · Reputation: 622
#5Feb 2, 2019, 11:01 AM
Yep, I bet most pools rely on Bitcoin Core's getblocktemplate function, which is pretty straightforward. It just sorts by fee rates and considers CPFP transactions. You can find more about it on GitHub if you're interested.
3 Reply Quote Share
gang2015Member
Posts: 682 · Reputation: 62
#6Feb 2, 2019, 03:51 PM
Right, but getblocktemplate is just a basic method. Finding the perfect solution is tough since it’s NP-hard. You can’t always know what the best set of transactions is.
6 Reply Quote Share
jakecobraFull Member
Posts: 326 · Reputation: 622
#7Feb 2, 2019, 07:44 PM
Good point about the sigops cost. Miners have to keep that under control too. If they don’t, they could end up with an invalid block, like what happened with F2Pool last year.
4 Reply Quote Share
grimgangFull Member
Posts: 32 · Reputation: 355
#8Feb 2, 2019, 08:02 PM
I hadn’t heard about that F2Pool incident before, but it makes sense. They’re known for censoring transactions, so if they messed up the code, it’s kind of poetic justice.
3 Reply Quote Share
cobra51Newbie
Posts: 100 · Reputation: 31
#9Feb 3, 2019, 10:29 AM
Knapsack problem is all about maximizing value. Miners can definitely boost profits by selecting high-fee transactions based on size.
0 Reply Quote Share
Posts: 110 · Reputation: 19
#10Feb 3, 2019, 04:05 PM
Yeah, but the greedy approach can be hit or miss. The challenge is figuring out which transactions fit into a limited block size. There’s more to it than just picking the highest fees.
2 Reply Quote Share
jakecobraFull Member
Posts: 326 · Reputation: 622
#11Feb 3, 2019, 07:51 PM
Forget sigops for a sec. If we ignore dependencies, a simple greedy method is to sort transactions by fee rate and take the highest ones. If it fills the block just right, you’ve got an optimal solution.
0 Reply Quote Share
cobra51Newbie
Posts: 100 · Reputation: 31
#12Feb 3, 2019, 10:31 PM
Not every pool operates the same. Some are transparent about their methods, while others are secretive. Unless you remove transactions from your mempool, you can't prep a set beforehand.
3 Reply Quote Share
jakecobraFull Member
Posts: 326 · Reputation: 622
#13Feb 4, 2019, 02:41 AM
I get your point, but wouldn’t running a solver even after getting a solution from getblocktemplate be beneficial? It could find something better while the other one runs.
1 Reply Quote Share
cobra51Newbie
Posts: 100 · Reputation: 31
#14Feb 4, 2019, 04:01 AM
F2Pool and Ocean pools really stand out. F2Pool's got a political agenda, and Ocean's got their own quirks. Other pools with acceleration services also have some sketchy selections.
2 Reply Quote Share
jakecobraFull Member
Posts: 326 · Reputation: 622
#15Feb 4, 2019, 04:38 AM
I thought it was just MARA doing that. Kinda sad to see others following suit. But yeah, delays in block mining can cause transactions to be missed too.
4 Reply Quote Share
Posts: 110 · Reputation: 19
#16Feb 4, 2019, 08:32 PM
I’ve been checking mempool health indicators: Kano.is is at 99.92%, while Oceanpool is lagging behind at 87.66%. Not sure how much that tells us, though.
4 Reply Quote Share
Posts: 110 · Reputation: 19
#17Feb 5, 2019, 12:17 AM
100 blocks of backlog isn’t that big, really. A regular ILP solver can find optimal solutions pretty fast, at least compared to the time needed for new block templates.
0 Reply Quote Share
gang2015Member
Posts: 682 · Reputation: 62
#18Feb 5, 2019, 01:55 AM
Saw that recent merge about the new cluster-based mempool algorithm. Changes are coming!
2 Reply Quote Share
Posts: 3523 · Reputation: 35
#19Feb 5, 2019, 04:52 AM
Yeah, and it’s been looked at by 0xB10C. Wild that F2Pool didn’t update their software after their first invalid block incident. You’d think they’d be more careful.
3 Reply Quote Share

Related topics