如何在操统课 Bitcoin 大作业组间比赛歇菜

… You may also reorder transactions within a block. However, please note that the ordering of transactions is very important and reversing the order may cause some transactions to become illegitimate, and you must ensure the sequence of transactions in every block is legitimate…

……

As a tradition of IIIS OS course, the final project includes a cross-testing phase in which students test each other’s implementation and find weird bugs. For this project, it contains two parts:

1. The mining test, where one server of each group runs against each other. In this mode, some clients will generate some “random” transactions, and your server is busy mining and compete with others.
1. You will get bonus points if you win the mining contest, e.g. at the end of the day your miner’s account balance is top 2 out of all groups. Think carefully! (Note that each block may contain ~50 mining fee.)

……

1. 只有挖矿能带来 miner account 的收益，因为其他的交易是（应该是这个测试专用）客户端生成的，为了保证公平肯定不会主动转入收益到矿机，即使是自己的客户端在运行，因为矿机的帐户名不能被预知，所以仍然不能给自己转账；
2. 挖矿的时候可以合理重排交易的顺序；
3. 一个区块的大小是有限的（在我们的作业中是 1 到 50 个交易），假设只能随机碰撞 SHA-256，优先把交易费高的交易放进待解区块更划算。

• 对每个节点创建一个钱包，$s$ 的初始余额是 2，$t$ 的初始余额是 0，其他节点对应的钱包初始余额是 1；
• 对每条边 $\left({u,v}\right)$ 创建一个交易，它从 $u$ 扣除 2 余额，支付 1 手续费并支付 1 余额给 $v$