Author

Topic: [ANN][Library][v0.4.0] PyBC Generic Blockchain Library (and coin!) (Read 7227 times)

hero member
Activity: 900
Merit: 1000
Crypto Geek

Im right there with you , any multisig or " atomic exchange" is great,  innovation is great, but does Python provide a effective advantage over C++ ?

I understand , I think , that assembly is more work for superior results , but , dam did you see that OS boot ?

Im not saying use this , I was just trying to make a point , or ask a question .

I've heard c++ tends to be quicker but you know...
 I don't really see it that much personally. Computers are pretty quick anyway these days. Google for compiled python program vs c++ speed?

 Python is a very nice language, I know that much. By balance it is the most in use of these more readble \"higher level"? languages. The most established of these. You have many libraries at your fingertips. Electrum is coded in python, so easy to install cross platform with pip. Gentoo linux is python.

 I did a quick search:
http://blog.udacity.com/2012/05/learning-to-program-why-python.html
Quote
Language Interoperability, Documentation System, Hierarchical Module System, Available Libraries, Testing Framework, Readability,

 It's a language that has often motivated me to try to learn how to program but even this wasn't enough to get me past my stupidity.
hero member
Activity: 798
Merit: 1000
‘Try to be nice’
I'm not a coder, {let me say that first}

but can I ask , why Python ?

I'm not a coder either.

Here's a good reason - rapid prototyping. Assembly language is a nice example. I had a friend learning assembly at school. Suffice to say... it's very very slow to knock up ideas...
the best way to approach the problem (bear in mind I'm not a programmer) that I've seen in practice is a library call written in a .dll/.so written in assembly where speed is required.

This system is the best development I've seen for cryptocurrencies in a long while. Hopefully multisig can be added - or a way to exchange value through different coins/blockchains? aka - no more exchanges.

Im right there with you , any multisig or " atomic exchange" is great,  innovation is great, but does Python provide a effective advantage over C++ ?

I understand , I think , that assembly is more work for superior results , but , dam did you see that OS boot ?

Im not saying use this , I was just trying to make a point , or ask a question .
hero member
Activity: 900
Merit: 1000
Crypto Geek
I'm not a coder, {let me say that first}

but can I ask , why Python ?

I'm not a coder either.

Here's a good reason - rapid prototyping. Assembly language is a nice example. I had a friend learning assembly at school. Suffice to say... it's very very slow to knock up ideas...
the best way to approach the problem (bear in mind I'm not a programmer) that I've seen in practice is a library call written in a .dll/.so written in assembly where speed is required.

This system is the best development I've seen for cryptocurrencies in a long while. Hopefully multisig can be added - or a way to exchange value through different coins/blockchains? aka - no more exchanges.
hero member
Activity: 798
Merit: 1000
‘Try to be nice’
I'm not a coder, {let me say that first}

but can I ask , why Python ?

is this a "just becasue you can" exercise ?

I like this innovation , but for example does Python provide a say , Security benefit in any manner conceptual, argumentative or abstract ?

and if so , shoot with some or all.


**

I mean for example why not , say assembly language?

these people made an OS http://kolibrios.org/en/

that boots in seconds - with FASM assembly language.
full member
Activity: 141
Merit: 100
So it turns out when we get to around 10k blocks, the coin system starts to slow down. I suspect it's because it has to copy the State (which includes a list of every unspent output) for every new block, and I'm going to try to change that when I get a chance. In the mean time, try not to need to download the blockchain for the toy coin.
full member
Activity: 141
Merit: 100
Another new release!

It turns out the way I got the state of the blockchain in the past to verify fork blocks was a huge bottleneck, so I fixed it by adding some caching logic. I've also added some more queuing and deferring to prevent the client from locking up while verifying a batch of downloaded blocks.

Hence 0.4.

There's actually a reasonable 3,843-block blockchain going, on which I will pay 50 coins to anyone who posts their address and is running a client to receive them. Eventually.
full member
Activity: 141
Merit: 100
Hello all!

I've decided to make this the official thread. I had another thread for 0.2, but that seemed like it could get spammy pretty fast.

Anyway, I have a new version out, 0.3.1, which can actually handle the blockchain of 3,722 blocks that you guys have mined, and download it at a reasonable speed without deadlocking halfway through.

Be sure to use the script in the first post or something similar to upgrade your wallet file to the new corruption-resistant SQLite-based format.

I didn't bother with an upgrader script for stored blockchains; just re-download them from an old-version peer.

Also be aware that pybc_coinserver and pybc_cointk have two new arguments: a required argument for a persistent peer database, and an optional --host argument to enable announcement of an internet-visible host name or address to the network periodically.

Let me know if there are any issues.
sr. member
Activity: 425
Merit: 262
Nice software component.
hero member
Activity: 905
Merit: 1001
very good work! i am excited how far this development will go
legendary
Activity: 1806
Merit: 1090
Learning the troll avoidance button :)
Hmm interesting enough
legendary
Activity: 1512
Merit: 1000
Wow ! Congratulations! Really nice to see some real innovation Smiley.
full member
Activity: 196
Merit: 100
...To my knowledge, this toy coin is the first altcoin not based on the Bitcoin source (if we don't count Ripple)...

Depends on your definition of "alt coin".
full member
Activity: 141
Merit: 100
New in 0.4: not locking up while downloading blocks, and much more efficient fork switching.


This new release is compatible with old blockchain data and peers, but not the stored wallet or blockchain files.

To update to 0.4:

Code:
pip install --upgrade --user pybc

If you want to keep your private key(s) from 0.2 or earlier, you can (probably) use this script to import them:
Code:
#!/usr/bin/env python2.7
"""
Script to import a Wallet to the 0.3+ format.

PyBC must be installed in a place where it can be imported.
The old wallet should be named keys.wallet.old.
The new wallet should be named keys.wallet.new.

"""

import shelve
from pybc.sqliteshelf import SQLiteShelf

old_wallet = shelve.open("keys.wallet.old")

new_wallet = SQLiteShelf("keys.wallet.new", table="wallet")

for key, value in old_wallet:
    new_wallet[key] = value
    
old_wallet.close()
new_wallet.close()

What is this?

I've been working on a Python module, PyBC, that implements a peer-to-peer distributed blockchain (as in Bitcoin or any altcoin) with easily definable rules for block validity. On top of this library, I have implemented a (very simple) altcoin: PyBC Coin. To my knowledge, this toy coin is the first altcoin not based on the Bitcoin source (if we don't count Ripple), and the only SHA-512-based altcoin.

The library is available from a couple of places:

PyPI

BitBucket

To play around with PyBC Coin, assuming you have pip and .local/bin is in your PATH, run:

Code:
pip install --user pybc

pybc_cointk blockchain.blocks keys.wallet seen.peers

You can use the GUI to get a base64 receiving address and your current balance, and send and receive (indivisible) coins. If you want to generate blocks, use the --generate option. Specify another peer to connect to with the --peer_host and --peer_port options. The default port is 8008, and can be changed with the --port option. If you specify a host name or IP with the --host option, you will announce yourself to your peers.

The toy currency is currently set to retarget every 10 blocks to a generation rate of a minute per block. The generation reward is 50 indivisible coins forever, and the transaction fee that all the miners charge by default is 1 coin. Naturally, this can all be changed around fairly easily.

Hopefully this library will eventually be useful for the rapid development and prototyping of altcoins. Make your own currency, no compiling needed! It's also intended to be useful for non-currency blockchains.

Does anyone have any design suggestions, or ideas on how to mitigate the fairly obvious opportunities for low-difficulty-block or transaction or peer flooding attacks that the library currently has?

Would anyone be kind enough to run a publicly-accessible pybc_coinserver node for larger-scale testing? If so, please post here. The UI code needs substantial revisions, but what constitutes a valid block is unlikely to change in a backwards-incompatible way, so if you think my test currency is going to be the next Bictoin you can get a head start on mining.

I'm very excited to see the first serious altcoin based on this library. Also, please send BitBucket pull requests; the whole thing is MIT licensed, and contributions are accepted under the same license.

Jump to: