Giter VIP home page Giter VIP logo

minemyname's Introduction

pset02 : NameChain

Mine your name into the blockchain. This pset will use a mock blockchain which you can mine blocks into.

Due on the last second of the month of February: 2018-02-28 23:59:59 EST

Warning: centralized server

There is a server component to this pset, which might go down or crash. This is not a decentralized network hardened by 9 years of open source improvements and worth hundreds of billions of dollars. It's a server I coded just for this pset. If it goes down, bug me on IRC and I'll try to fix it quickly so that you can increase your mining score.

The server, at hubris.media.mit.edu, should be up and running from the 20th to the 28th.

Server is back up on 2018-02-22 10:45 EST

Block specifications

Blocks are ASCII strings, with a maximum lenght of 100 characters. The block format is:

prevhash name nonce

prevhash: the ascii hexidecimal representation of the previous block hash. Must be lowercase and in hex; do not use raw bytes. example:

00000000c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b

name: the name you want to credit nameChain points to. Case sensitive. example:

miner2049

nonce: a random nonce to satisfy the work requirement. example:

TWFuI3GlzIGR

Note that names and nonces must be in the base64 character set:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

which is just caps, lowercase, numbers and + and /. Can't have spaces; spaces separate the 3 different elements of the block. This is to make everthing easy to run through terminals, let people use shell scripts and so on.

Client / Server connections

This pset has a server. It's not a real decentralized system, as that's too much work to deal with for this early assignment. There is a NameChain server which listens on a TCP port, and when a TCP connection is made to it, it sends the current blockchain tip. Connected clients can send a new block to it, which, if valid, will be appended to the end of the blockchain.

The server is hard-coded into the pset code and lives at hubris.media.mit.edu. It will probably go down for some time during this pset epoch, due to the fact that the DCI is moving to a new office this week. We'll try to minimize downtime.

The required work is 2^33, which is twice as difficult as the initial target for the Bitcoin network. (But nowhere near as difficult as the current Bitcoin target)

What to do:

A bunch is already written for you. The network functions are GetTipFromServer() and SendBlockToServer() and already implemented, so you don't have to deal with TCP.

You need to write the Mine() function, and then SendBlockToServer() once you have mined a block.

You may need to poll the server for new blocks occasionally so that you don't submit "stale" blocks, where someone else submitted a block before you did with the same parent. To not DDoS our server, please keep requests to 1 per second maximum.

Using go concurrency features is reccomended for this problem set. The amount of work required to find a block is fairly high, and if you're mining using only 1 CPU core you will be at a disadvantage compared to multi-threaded, multi-core miners.

Here is a simple tutorial on go channels; they're not too hard to use, even if you haven't done multi-threaded programming before. They allow you to pass messages between functions which are running at the same time. There are also other possible methods like sync.WaitGroup, or in fact it's quite possible to mine without any synchronization between threads at all.

There will be a "high score" ranking with the number of blocks in the chain made by each user. This is the same as getting more coins by mining more blocks. To get a high score, mine a bunch of blocks with the same name. We're using names instead of public keys which is not as decentralized but we know who you are already :)

The entire current blockchain can be downloaded from the server at port 6299. Example code:

$ nc hubris.media.mit.edu 6299

00000000722a3b3cabaac078bd4e15ce361312895cfef0494c9ffc75bedb82db adiabat 19579781213

This if if you want to check how the blockchain is progressing.

If there are other server features wanted, let me know and I can code them up. The server code is not public now, but I'll make it public after the assignment is over.

Having a server makes this pset somewhat more fragile so bear with us :) We hope this assignment is fun and people can optimize and speed up their code, while getting the basics of blockchain design.

minemyname

minemyname's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.