Skip to content

fenilgmehta/CS765-Simulate-P2P-CryptoCurrency-Network

Repository files navigation

CS765-Simulate-P2P-CryptoCurrency-Network

Points to Note

  • Node == Peer == Miner all three mean the same
  • txn == transaction
  • Unit of time = seconds for everything
  • md5 hash function is used for speed - Can be updated to use any other hash function
  • GenesisBlock.prev_node_hash = -1
  • if a block with block_index < node.curr_block_index_max is received, then it is not dropped because:
    1. The received block can become ancestor of a block which forms a longer chain in future
    2. The block creator would not spend their time and computation power in creating and sending a block which does not create a longest chain
  • Transactions created are always assumed to be authentic in this simulation
    • In the real world, they are signed by the transaction creators (i.e. money senders)
  • mining reward is always the first transaction of any block, and sender is -1 only
    • Sender == -1 means money is created from thin air
    • If mining reward transaction is placed at any position other than index 0, then it is invalid
    • If id_sender for mining reward transaction is anything other than -1, then it is invalid
  • mining_reward_update_percent is used as follows: new_reward = old_reward (1 + mining_reward_update_percent / 100)
    • The above statement will be executed every mining_reward_update_block_time blocks
      • i.e. when longest_chain.index % mining_reward_update_block_time == 0
  • Empty blocks are valid
    • Sometimes bitcoin and ethereum have empty blocks
  • Any valid transaction created should enter the blockchain even if forks happen
    • We find the common ansestor between the tails of the fork with the help of block index
  • Simple Cache is implemented to optimize block validation and creation
  • It is assumed that no one will create time pass transactions where sender and receiver are the same
  • Clarifications specific to Assignment 2
    • The attacker is a single node
    • In case of more than one attacker nodes, they all will perform attack individually. They do NOT coordinate with each other and are unaware of the existence of other attackers
    • Each attacker assumes that all other people are honest (this assumption is not used by the attacker in any part of the attacking logic)
    • The attacker does not forward blocks generated/mined by other nodes

Execution Steps and Images

Assignment 1

cd src1
python simulator.py --config config.json --debug

Sample Execution Output Blockchain Visualization Execution with graph displayed Execution in progress

Assignment 2

cd src2
python simulator.py --config config.json --debug

References

About

Simulation of a P2P Cryptocurrency Network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages