COMP90088: Cryptocurrencies and decentralised ledgers Semester 1 2022
Assignment due: 2022-04-07 22:00
Introduction
In class we discussed a number of mining strategies. In this project you will explore three of these strategies in more detail. You may work with a partner or by yourself.
Copyright By PowCoder代写 加微信 powcoder
Simulating the Bitcoin network
We will use a simplified model of the Bitcoin network to simulate mining and propagation of blocks. You do not need to understand all the details of the simulation but the most important points are:
1. The simulation proceeds in discrete iterations where each iteration consists of a mining round and propagation round.
2. No proof of work is actually performed. Instead, in each mining round every miner i independently draws a random real number from 𝐸𝑥𝑝[h𝑎𝑠h𝑅𝑎𝑡𝑒𝑖] and the miner with the
lowest number mines a block. The probability of mining a block in each iteration for a miner 𝑖 is thus:
∑ h𝑎𝑠h𝑅𝑎𝑡𝑒𝑗
3. With small probability a second block gets mined at the same time (by the miner who drew the second smallest number). With even smaller probability a third block is mined and so on. All blocks mined in this mining round are considered ready for the next propagation round.
4. If a miner s decides to broadcast a block during the propagation round, they draw a transmission time for each other miner r from 𝐸𝑥𝑝[𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝑠 * 𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝑟]. If two miners 𝑠1and 𝑠2
broadcast a block to 𝑟 in the same round then the probability of 𝑠1’s block arriving first is: 𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝑠
𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝑠 +𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑖𝑣𝑖𝑡𝑦𝑠 12
5. If a miner upon receiving a block wants to broadcast a new block, they draw a set of transmission times for the other agents as in 4, but delayed by the current time. Consequently there exists a first mover advantage in block propagation.
6. The simulation ends at a randomized time, using an exponential distribution. That is, any given mining round has a fixed probability of being the end of the simulation. Miners are unaware of when the simulation will end.
7. The longest blockchain presented by any miner at the end of the simulation (whether its blocks are propagated or not) is taken to be the canonical ledger from which overall mining profits are calculated.
Each of these tasks is worth an equal amount of marks.
1. Implement the MajorityMiner class (extending the Miner interface) which performs a 51% attack if it is capable. This simulation framework does not enable double spending, but a majority miner can still extract a disproportionate share of block rewards. The network may have some natural churn, so your status as a majority miner may change.
2. Implement the SelfishMiner class which performs a temporary block withholding attack if profitable. This strategy is outlined in Chapter 5 (Section 5.5) of the NBFMG textbook.
3. Implement the FeeSnipingMiner class which forks the blockchain to try stealing unusually valuable blocks when profitable. That is, when a block with an unusually large transaction fee is mined, your miner should temporarily reject that block and try to re-mine a longer fork where it keeps the large transaction fee for itself. It is up to you to calculate when doing so is profitable.
Getting started
1. Download the code from https://github.com/jcb82/miningPlayground and import it into your favorite IDE. You can use Maven to download the required dependencies. Please be sure not to fork the code into a publicly available repository that your classmates can see.
2. Familiarise yourself with the starter code. You should especially look at the Miner interface. All your miners should implement this interface. Look at the JavaDoc that explains what each function does. You should also study the CompliantMiner class which executes the default protocol behavior. Your miners will override functions in this class.
3. Your goal in all parts is to maximise your expected profit relative to the other miners.
4. The class MiningSimulation provides a set of tests that your Miners should pass. The revenue goals should be achievable with standard implementations but feel free to try to
surpass them.
5. To run the tests, you can run the class MiningSimulation as a JUnit test. You may want to
comment out tests you aren’t currently working on to speed your debug cycle up.
6. The BitcoinNetwork class may help you understand how the mining process is simulated.
Submission
Create a .zip file of your submission and upload it through the LMS. Your submission should contain only the code for your miners: MajorityMiner.java, SelfishMiner.java, FeeSnipingMiner.java. If you worked with a partner, please indicate this clearly in a README file (only one submission is necessary).
We will be testing your miners against the unit tests in the original starter code and some additional unit tests. If you modified any of the starter code outside of the three miner classes, be sure that they still work in the original environment.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com