-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
84 lines (62 loc) · 3.81 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
How to run:
python BlockchainSimulator.py -c [CONTACT_FREQUENCY] -t [TRANSACTION_RATE] --RANDOM_TRANS [True or False] --RANDOM_WINNERS [True or False] --RANDOM_CONNECT [True or False] --RANDOM_START_CONNECT [True or False]
Or simply run any of the .bat file.
Simulator Concepts:
Number of nodes: 20
Time unit: 600s
Mining winners: the winners are randomly chosen. Only 3 winners at most within a time unit.
Winners always generate new block no matter whether the incomplete transaction list is empty.
Keywords:
RANDOM_TRANS: _RT, random transactions
RANDOM_WINNERS: _RW, random winner
RANDOM_CONNECTION_TIME: _RC, random connection time to Internet
RANDOM_START_CONNECTION_TIME: _RSC, random start connection time to Internet for each node. It is randomly generated at the beginning of the simulation, but won't be changed during the simulation.
CONTACT_FREQ: contact frequency, the idle time of the connection between a node and Internet.
TRANS_RATE: transaction generation rate, the average number of transaction generated by a single node within a time unit (600s).
Input files:
transactions.txt: the transaction records.
Transaction format: [time, sender, recipient, amount]
Max transaction time: 85000 seconds
The transaction senders and recipients are selected randomly from nodes pool.
Number of transactions:
transaction_1.txt: 2680
transaction_2.txt: 5360
transaction_3.txt: 8040
winners.txt: the winners. Max simulation time for winners: 1000000 seconds
Output files:
./Log:
filename format: [time]_[contact frequency]_[transaction rate]_[random transaction]_[random winner]_[random Internet connection time interval within a range]_[random start connecting to Internet time].txt
It displays all the blockchains exist in the simulator, and the owners for each blockchain.
Block difference section displays the blocks that different to other chain.
./Stats:
filename format: statistics_[random winner]_[random Internet connection time interval within a range]_[random start connecting to Internet time].csv
No keyword in the finame means the associate parameter is set to False.
Important ideas:
Block structure:
-Index: block index
-Transactions: the approved transaction list
-previous_hash: previous block hash value
-block generator: who genereates the current block
-time: the timestamp of when the block is generated
Mining: Unlike Bitcoin Blockchain, there is not a particular solution for minning puzzle. The winners are selected from the pre-generated winners.txt file. The chosen node will generate a new block and append it to the blockchain.
No more than 3 winners within a time unit. The mempool (pending transaction list) is emptied when a new block is generated without care about block size.
Resolve conflict:
-Nodes always update its blockchain to the longer one.
-The transactions that in the mempool will be removed if they are already in the longer chain
-The transactions in the approved transaction list are appended back to the mempool if they are not in the longer chain
Simulation stopping case: The simulation is stopped when all the nodes have an identical chain that covers all the transactions.
Procedures:
-While simulation time is not finish or nodes don't have an identical blockchain:
-Within a time slot:
- retrieve transactions from file (or randomly generate)
- retrieve winners from file (or randomly generate)
- winners generate new block
- LOOP through pair-wise nodes:
- if they are currently connecting to Internet:
- broadcast incomplete transactions
- resolve conflict
- Move to next time slot
- Write blockchain information and statistics into appropriate files
Mistakes:
Wrong understanding on 6 blocks convention. Need to fix the code (and the statistics recollection and graph generation etc......).
Statistics is stored under the path /Blockchain statistics backup/Blockchain DTN