Truthcoin Talk 2.0

Prediction Markets => Outside Work => Topic started by: zack on May 29, 2014, 10:18:04 PM

Title: Blockchain for building upon
Post by: zack on May 29, 2014, 10:18:04 PM
######## edit
This very popular thread has a lot of links in it that point to unmaintained code.
My efforts to build truthcoin are happening here now: https://github.com/BumblebeeBat/FlyingFox

I used what I learned from slasher when I built FlyingFox. slasher was a prototype.
########

https://github.com/zack-bitcoin/slasher

I made this small cryptocurrency specifically for building things like truthcoin out of it. It is a pure POS currency like blackcoin, but does not use any bitcoin code. It is all python that I wrote.

New transaction types can be quickly added by editing the transactions.py file.
I am trying to figure out all the transactions for implementing truthcoin, here is what I have so far:

1) create a jury.
Creates some money. The holders of this money collectively vote on decisions. If they vote well, the money grows, if they vote bad, it shrinks. Juries might specialize for topic. Maybe one group of jurors only does basketball games, another deals with politics, etc. They can all have different fees as well.

2) offer a decision to the jury.
Decisions have text explaining "Obama will win the presidential election" and a date that it expires, like 2 weeks after the election. When it expires, the jury comes to consensus about the outcome.

3) jury votes to accept a decision, or to reject it.
Juries don't want to deal with vague sounding decisions that are hard to decide on. They don't want to have to drive far, or waste much time learning something new.

4) juries vote on the outcome of a decision after it expires.

5) anyone can create a new prediction market.
(in ethereum speak, a prediction market is a type of "contract")
The prediction market depends on a bunch of undecided decisions that juries have agreed to.
The PM sells at least 2 types of tokens, one type will eventually be declared a winner, and it will be worth 1 truthcoin. all the other types go to zero.
Each PM only accepts one type of money. Either truthcoins, or one type of token.

6) anyone can buy tokens from any prediction market.

7) anyone can sell tokens to the prediction market they purchased it from.
*not always true. The author of a PM can choose to disallow this feature. disallowing the selling of tokens is useful in the case of funding public goods.

8) the ability to spend truthcoins, to spend the tokens that you buy from PMs, and to spend the juror money.

Does this seem like sufficient transaction types for the entire truthcoin? or am I missing something?
Title: Re: Blockchain for building upon
Post by: psztorc on May 29, 2014, 11:37:34 PM
I'm currently in the process of fleshing this out a little more:
https://github.com/psztorc/Truthcoin/tree/master/docs/Development%20Plans

"1) create a jury" sounds like "create a branch", that's good because I haven't updated that part on my page, as branching may get a little more confusing.

Quote from: zack on May 29, 2014, 10:18:04 PM
7) anyone can sell tokens to the prediction market they purchased it from.
*not always true. The author of a PM can choose to disallow this feature. disallowing the selling of tokens is useful in the case of funding public goods.
Thank you for actually reading the papers... :D

Quote from: zack on May 29, 2014, 10:18:04 PM
The PM sells at least 2 types of tokens, one type will eventually be declared a winner, and it will be worth 1 truthcoin. all the other types go to zero.
Each PM only accepts one type of money. Either truthcoins, or one type of token.
This doesn't seem right to me. You might want to check my excel sheet demoing the market scoring rules, someone has already tried this in Etherium: http://www.mintchalk.com/c/37101
Title: Re: Blockchain for building upon
Post by: zack on May 29, 2014, 11:48:44 PM
For example, if we had a token which says "This token is worth 1 truthcoin is BTC/USD is between 600 and 630 tomorrow".

You could use that token as input for a market which sells these 2 types of tokens:
1) "This token is worth 1 truthcoin is BTC/USD is between 600 and 615 tomorrow"
2) "This token is worth 1 truthcoin is BTC/USD is between 615 and 630 tomorrow"

Every market's token possibility must be mutually exclusive. The sum of the token possibilities is the input possibility.
Title: Re: Blockchain for building upon
Post by: zack on May 29, 2014, 11:54:57 PM
http://blog.oddhead.com/2006/10/30/implementing-hansons-market-maker/

I have been using this explanation of LMSR.

If there were 5 possibilities, then the initial investment is B*ln(5) and the cost function=B*ln(e^(x_1/B)+e^(x_2/b)+...+e^(x_5/b))
Title: Re: Blockchain for building upon
Post by: psztorc on May 30, 2014, 12:03:03 AM
Oh, yes, you are correct. Where I got confused is where you said "worth 1 Truthcoin". Truthcoin were originally the 'shares' and not the 'coins'.

There's going to be severe confusion unless I do something...I'll have to think about this.
Title: Re: Blockchain for building upon
Post by: zack on May 30, 2014, 12:04:34 AM
Yeah, I am pretty bad with nomenclature.
If we can get some defined terms somewhere, I will try to stick to them.
Title: Re: Blockchain for building upon
Post by: psztorc on May 30, 2014, 12:43:36 AM
No one has ever understood the terms, so even though it is a major risk to swap out definitions, I think this will be manageable: http://forum.truthcoin.info/index.php/topic,15.0.html
Title: Re: Blockchain for building upon
Post by: zack on June 01, 2014, 07:01:18 AM


https://github.com/zack-bitcoin/truthcoin #### edit, work is happening here now: https://github.com/BumblebeeBat/FlyingFox ####

I implemented the 4 of the 8 transactions. Haven't done any testing, or added the new transactions to the gui.

The part I tried writing has to do with giving out votecoins to a group of people, and giving them decisions, and having them vote to accept decisions, and having them vote to reach consensus on the outcomes of these decisions.

I did not use clever statistics. Probably someone else has a much better way of doing this.
I fear that my code is going to be undecipherable, so I will give a short explanation here.

When the pool of votecoin holders is created, a number 'x' is defined. It is between 0 and 1.
When the votecoin holders are voting on whether or not to accept a potential decision. holders sign either to accept, or deny, one at a time. We keep a running total of how much of the votecoins want it either way. If at any time ((the amount of votecoins that accept the decision)-(amount of votecoins that deny the decision))/(total number of votecoins in the pool) > x, then the decision is accepted into the pool of decisions.

Alternatively, if that fraction was <-x, the decision is thrown out, or if 40% of votecoin holders want to get rid of it, then it is thrown out.

voting to decide on the outcome of the decision works identically, and with the same constant x.
Title: Re: Blockchain for building upon
Post by: psztorc on June 01, 2014, 04:34:05 PM
Quote from: zack on June 01, 2014, 07:01:18 AM
I did not use clever statistics. Probably someone else has a much better way of doing this.
I fear that my code is going to be undecipherable, so I will give a short explanation here.

When the pool of votecoin holders is created, a number 'x' is defined. It is between 0 and 1.
When the votecoin holders are voting on whether or not to accept a potential decision. holders sign either to accept, or deny, one at a time. We keep a running total of how much of the votecoins want it either way. If at any time ((the amount of votecoins that accept the decision)-(amount of votecoins that deny the decision))/(total number of votecoins in the pool) > x, then the decision is accepted into the pool of decisions.

Alternatively, if that fraction was <-x, the decision is thrown out, or if 40% of votecoin holders want to get rid of it, then it is thrown out.

voting to decide on the outcome of the decision works identically, and with the same constant x.

Are you aware that in https://github.com/psztorc/Truthcoin/tree/master/pylib I have python versions of many of the functions?

The latest versions are in R/S+ which are here https://github.com/psztorc/Truthcoin/tree/master/lib
Title: Re: Blockchain for building upon
Post by: zack on June 01, 2014, 07:13:42 PM
In the consensus.py file, you have a matrix called VotesUM.
What information is being stored in this matrix?

When I am finding consensus, there are many people with votecoins, and each person can vote in 4 ways:
1) not voting
2) yes
3) no
4) undecided

your matrix only holds 1's and 0's, so I guess it isn't storing the votes?
Title: Re: Blockchain for building upon
Post by: psztorc on June 01, 2014, 07:23:30 PM
VotesUM is "unmasked" and sets up for the masked array which stores the votes.

not voting = nan
yes = 1
no = 0
undecided ("unresolvable") = .5

I've done almost no testing of the python version, vs. the R version. Also, only the R version can handle continuous outcomes.

Sorry, I like my full time job a lot! Also, this beautiful weather makes it hard to code.
Title: Re: Blockchain for building upon
Post by: zack on June 01, 2014, 07:30:52 PM
So we need to keep an array of the outcomes of every decision that this pool of voters has ever voted on?
What happens when I send my votecoins to someone else? My old entries in the matrix are weighted by how much money I had before, and new entries are weighted by how much money I have now?

Do we need to recompute old balances in the blockchain, or record every balance of every user in every block?

I am working on implementing truthcoin full-time.
Title: Re: Blockchain for building upon
Post by: psztorc on June 01, 2014, 08:47:11 PM
Quote from: zack on June 01, 2014, 07:30:52 PM
So we need to keep an array of the outcomes of every decision that this pool of voters has ever voted on?
No, just those maturing this period. I attempt to explain this on page 8 of Whitepaper 1.2, section "Operationalized Coordination Using SVD". Also, there is a discussion here (https://bitcointalk.org/index.php?topic=475054.0;all) among a few people who seem to get the idea.

Quote from: zack on June 01, 2014, 07:30:52 PM
I am working on implementing truthcoin full-time.
Cool! This part (the consensus mechanism) is that magic that makes it all possible (where it wasn't possible before), so please ask as many questions as you need. However, the FAQ and whitepaper are the best reference.
Title: Re: Blockchain for building upon
Post by: zack on June 03, 2014, 08:39:39 PM
Having reflected on the whitepaper more deeply, I will once again try to derive the set of transaction types for the consensus mechanism.

1) create pool of votecoin holders
* a list of public keys, and how many votecoins is allocated to each public key.
* how often do we vote on decisions

2) propose a decision
* which pool of votecoin holders are you proposing to
* text of the decision
* Which set of decisions will this be included with? This is the expiration date.

3) votecoin holder vote
there are many decisions, looks something like: [0, 0, 1, 0.5, 1, 1, 0]
This makes votecoins temporarily disappear. (to stop people from voting and spending simultaneously.)
* sha256([0, 0, 1, 0.5, 1, 1, 0] + secret nonce)

4) reveal votecoin holder's vote
Voters cannot reveal until the expiration is passed.
Once the first person reveals, it is no longer possible to vote.
* [0, 0, 1, 0.5, 1, 1, 0]
* secret nonce

5) SVD consensus
This cannot happen until the proper time. Every voter needs enough time to reveal.
One person submits this transaction once per set of decisions.
uses R factory function to compute the results from the Decisions-Voters matrix. After this transaction is buried deep enough in the blockchain, people downloading the chain will not have to re-compute SVD.
The votecoin holders get their votecoins back (including votecoin holders who never decrypted their votes??)
* consensus results of each decision.
* New allocation of votecoins.
Title: Re: Blockchain for building upon
Post by: psztorc on June 04, 2014, 10:09:51 PM
This mostly looks good. Remember that I have a few of my own here: https://github.com/psztorc/Truthcoin/tree/master/docs/Development%20Plans

Also, I would check the "Timeline" on page 6. You are right that, in the Altcoin-version, preceding this there will need to be a 'create branch'.

Between 2 and 3, there is "propose a market", and of course "buy" and "sell".

3) I was thinking would go like:

Using {Pub1, Priv1}, where Pub1 owns some Votecoins.

By default (by not submitting anything), they have submitted a Ballot completely of NAs (or nan's).

1. input Ballot info: [0, 0, 1, 0.5, 1, 1, 0]
2. generate new keypair: (Pub2, Priv2)
3. unsigned_Ballot = { [0, 0, 1, 0.5, 1, 1, 0], Pub2 }
4. Encrypt the ballot
5. Sign the Encrypted Ballot
6. Broadcast the Ballot.
7. Upon inclusion, Pub1 has essentially "spent" their Votecoins (which they will get back later [this is 'RowBonus']), they can no longer be transferred anywhere.
8. The chain's participation scalar increases by the quantity of Votecoins (essentially, they have been 'sent' here).


Then step 4:
After a number of blocks have passed, the 'vote broadcast' phase is over. If you didn't vote, you're stuck having submit a Ballot of NAs.
Voters reveal Priv1.
If you don't reveal, you are stuck with a Ballot of NA.

Then, the 'RowBonus' from Factory, transfers those new Votecoin coin-values to each Voter's Pub2.

Items 3) and 4) are where I would most appreciate the input/critique of a Diehard Skeptic like gmaxwell (if anyone knows him). We should perhaps not waste his time until there is something more specific to audit, though.
Title: Re: Blockchain for building upon
Post by: zack on June 20, 2014, 07:26:29 PM
https://github.com/zack-bitcoin/Truthcoin-POW #### edit: work is happening here now: https://github.com/BumblebeeBat/FlyingFox  ####

It supports:
multisig addresses
creating new pools of votecoins
sending the votecoins to other users
proposing decisions
encrypted vote on decisions
decrypt votes
SVD consensus
web-browser as GUI for everything above ^^^
Prediction markets
buying/selling shares on prediction markets

Next goal:
GUI support for creating prediction markets and trading shares
Title: Re: Blockchain for building upon
Post by: martinBrown on June 25, 2014, 12:31:38 AM
Not sure if its working... What's going on here?

(http://i.imgur.com/lg6eTCn.png)


Then I got this when I tried the latest commit (with the consensus stuff):

(http://i.imgur.com/RNhfwzA.png)
Title: Re: Blockchain for building upon
Post by: psztorc on June 25, 2014, 05:30:54 PM
Hey, very exciting! Thanks for your hard work.

Re: SVD consensus, I tried to rewrite it in python, awhile ago (it is in pylib), but that version is old. The R stuff is always the latest and greatest.

I will probably try to, separately, code the latest SVD in python, and then we can compare notes.
Title: Re: Blockchain for building upon
Post by: zack on June 27, 2014, 10:24:25 PM
martinBrown, when you updated to latest commit, it was working the way I expect it to.
It is a POW blockchain right now, so you have to wait an average of 30 seconds for each block.

SVD consensus
I am using the R code you wrote. Python has a library for running R code, https://pypi.python.org/pypi/rpy2
on ubuntu I think it is: sudo apt-get install python-rpy2
Title: Re: Blockchain for building upon
Post by: zack on July 10, 2014, 04:28:19 PM
Blocktime is an average of 5 seconds now, so you don't have to be so patient.
I also updated the readme a bit to make it easier to tell what is going on.

For now, there is a 20-block cycle.
1-10: votecoin-holders may give encrypted votes on decisions. (in the final version of truthcoin, this step will take   1000+ blocks)
11-15: votecoin-holders may decrypt their votes
16-20: if there are at least 3 votecoin-holders, and at least 5 decisions they have voted on, then we can do SVD to come to consensus   about these decisions.
Title: Re: Blockchain for building upon
Post by: psztorc on July 10, 2014, 05:43:40 PM
I get a syntax error upon the importing:

transactions.py line 252

if len(tx['states']p)!=len(tx['states_combinatory'])+1:
Title: Re: Blockchain for building upon
Post by: zack on July 10, 2014, 07:40:50 PM
Quote from: psztorc on July 10, 2014, 05:43:40 PM
I get a syntax error upon the importing:

transactions.py line 252

if len(tx['states']p)!=len(tx['states_combinatory'])+1:

I just fixed it. You have to re-download to see my changes.
Title: Re: Blockchain for building upon
Post by: psztorc on July 10, 2014, 11:53:12 PM
Cool, I got a node to run.

I had to go to http://localhost:8700 (not 8701) to see anything, and even then I could only see my wallet and balance. I used an old Ubuntu 13.10, will update later today.

I didn't see how to create a jury, or give myself money.
Title: Re: Blockchain for building upon
Post by: zack on July 11, 2014, 03:43:00 AM
You can't make a jury till you have enough money. You have to mine at least one block.

If it still doesn't work, copy/paste the error message in the terminal to me.
old ubuntu should be fine, I think this would work on mac/windows too.
Title: Re: Blockchain for building upon
Post by: psztorc on July 11, 2014, 10:58:52 PM
How do I mine a block? I want to try it out!
Title: Re: Blockchain for building upon
Post by: zack on July 12, 2014, 12:47:43 AM
When I start the program by running: "python workers.py"
It mines 3 blocks within the first 10 seconds.

I am feeling un-confident about explaining how to use the software via forum posts.

I think the quickest way to do this is for us to used a shared desktop. http://www.teamviewer.com/en/index.aspx
I will PM you with more details.
Title: Re: Blockchain for building upon
Post by: zack on July 12, 2014, 12:50:30 AM
oh! I think I know why your money isn't going above 0.

The web-page doesn't automatically update when you mine new blocks. There is a button that says "refresh".
If you click it, you can see how much more money you mined since the last refresh.
Once you have non-zero money, you can create a branch or ask an existing branch a decision.
Title: Re: Blockchain for building upon
Post by: zack on August 10, 2014, 09:25:16 PM
The GUI in a browser was pretty annoying to me, so I redid it as a shell interface.
It should be ready in the next couple of days, so I want people to make addresses.
I need at least 4 other people's addresses in order to make a voting pool big enough for us to do the SVD.
I will also give some free coins to everyone who goes to the trouble of making an address.

In the file "custom.py" you need to change the line that says "brainwallet = 'brain wallet' "
the 'brain wallet' part should be replaced with your password of choice.

The command "my_address" will tell you your address.

I don't have windows to test with.
Title: Re: Blockchain for building upon
Post by: psztorc on August 11, 2014, 12:05:18 AM
Of course I will do it.
Title: Re: Blockchain for building upon
Post by: zack on August 20, 2014, 12:41:48 AM
The testnet is running.
We can make bets and do SVD and everything.

It is POW blockchain by SHA256.
It uses the the same elliptic curve as bitcoin to secure addresses.

https://github.com/zack-bitcoin/Truthcoin-POW #### edit: work is happening here now: https://github.com/BumblebeeBat/FlyingFox ####
Title: Re: Blockchain for building upon
Post by: zack on August 21, 2014, 12:04:05 AM
I took down testnet last night.
Users were complaining of how annoying the dependence on getch is.
I rewrote a bunch of stuff to get rid of getch, and plan on re-launching the testnet tonight or tomorrow.
Title: Re: Blockchain for building upon
Post by: psztorc on August 21, 2014, 12:38:50 AM
I'm sorry to have missed it. I am trying to get version 1.3 of the Whitepaper out ASAP, but I am also very busy at my day job.

I think it may be done within 24 hours, though. I am excited because I think it may be the last version. Moreover, it switches to the Altcoin implemenation (probably WAY easier for people to understand), standardizes the language, and clarifies the Two Coins, better figures, etc.

But that has really been consuming my free time. After that I'm excited to look at this.
Title: Re: Blockchain for building upon
Post by: zack on August 21, 2014, 06:46:05 AM
I took out getch, and everything seems to work, so I re-launched the testnet.
Title: Re: Blockchain for building upon
Post by: Max on September 02, 2014, 01:40:58 PM
Can Truthcoin be coded in Serpent upon Ethereum ??
And if yes, why to bother with making own blockchains ?
Obviously Ethereum is more advanced tech than Bitcoin-likes.  ;)
Title: Re: Blockchain for building upon
Post by: zack on September 02, 2014, 03:06:35 PM
Quote from: Max on September 02, 2014, 01:40:58 PM
Can Truthcoin be coded in Serpent upon Ethereum ??
Yes, truthcoin could be put onto ethereum instead of having it's own blockchain.
I think it is much easier to program in python instead of Serpent.
After we get the first version working in python, it is highly probable that we will port it to ethereum.

Quote from: Max on September 02, 2014, 01:40:58 PM
And if yes, why to bother with making own blockchains ?

1) a POS blockchain would have gas fees hundreds of times smaller than ethereum.
2) python is a lot easier to program in than serpent, fore example I use a large hashtable to store the blockchain, instead of having to pack everything into byte arrays.
3) I don't want to start over from scratch if Ethereum should die.

Quote from: Max on September 02, 2014, 01:40:58 PM
Obviously Ethereum is more advanced tech than Bitcoin-likes.  ;)

The blockchain I wrote is not a copy of bitcoin. Whatever you are trying to say is not "obvious" to me.
Title: Re: Blockchain for building upon
Post by: Max on September 02, 2014, 03:44:12 PM
Thanks for detailed answer.  :)

I meant that ETH will have blockchain more compact 5 - 10 times,
than BTC-likes.
Yes, Ethereum is yet to be delivered.
But being written in Golang and if it will take off,
it will become big competitor to Truthcoin,
when somebody will  construct proper contracts.
Maybe it is something to keep in mind ?!

So far i see the one of the biggest problems with PMs : poor liquidity.
If there will be more PM platforms liquidity on any of them will be poorer  :-\
Title: Re: Blockchain for building upon
Post by: zack on September 02, 2014, 04:09:37 PM
That is why truthcoin uses LMSR market maker prediction market. It has infinite liquidity.
LMSR markets function properly even if there is only one person betting.

Liquidity is a topic for a different thread.
Title: Re: Blockchain for building upon
Post by: psztorc on September 03, 2014, 02:51:13 PM
Max, you are indeed derailing this thread, which is about zack's blockchain.

There are already individuals working on an Ethereum version, namely martinBrown.

I don't see Ethereum and Truthcoin as competitors. If Ethereum were to implement Truthcoin as an Eth-contract, then that Eth-contract would compete with any Truthcoin blockchain(s). In the original whitepaper of January, I mentioned that Truthcoin may require Ethereum in order to exist.

Separately, I think that Ethereum, while hyped today, will not be very popular in the future. In fact, I believe that it is possible that Truthcoin will be the second of two blockchains (http://forum.truthcoin.info/index.php/topic,90.0.html), and that programmers will stop using Blockchains once they exist for money, namespaces, and data. If you'd like to discuss please post in the relevant thread.
Title: Re: Blockchain for building upon
Post by: Max on September 04, 2014, 03:02:52 PM
Hmm, i like your evaluating visions of how to develop Truthcoin.
My respect, psztorc !
I wish to trade some good and safe PM as soon as possible  ;)
Good luck with Truthcoin project !

Actually i should be reading this also :)
http://forum.truthcoin.info/index.php/topic,27.0.html

Title: Re: Blockchain for building upon
Post by: martinBrown on September 05, 2014, 03:15:16 PM
Quote from: psztorc on September 03, 2014, 02:51:13 PM
There are already individuals working on an Ethereum version, namely martinBrown.

somnicule (http://forum.truthcoin.info/index.php/topic,103.msg292.html#msg292) as (http://www.mintchalk.com/c/37101) well (http://www.mintchalk.com/c/25298).


Quote from: psztorc on September 03, 2014, 02:51:13 PM
If Ethereum were to implement Truthcoin as an Eth-contract, then that Eth-contract would compete with any Truthcoin blockchain(s).
[...]
If you'd like to discuss please post in the relevant thread.

Maybe not. Discussion continued here. (http://forum.truthcoin.info/index.php/topic,90.msg551.html#msg551)
Title: Re: Blockchain for building upon
Post by: psztorc on September 12, 2014, 07:31:29 PM
I'm going to be taking a close look at the newest version of this on Sunday...very much looking forward to it!
Title: Re: Blockchain for building upon
Post by: zack on September 13, 2014, 04:21:47 PM
On Sunday, it is my expectation that you will be able to do this list of things:
1) it should be able to connect to networking computer. if so, then you will automatically start downloading blocks within 15 seconds of turning it on.
2) mine a block and earn the reward in truthcoin.
3) spend truthcoin.
4) create a jury to own votecoins
5) spend the votecoins
6) ask the jury a decision
7) secret vote on the decision
8) reveal how you voted on the decision

I am not so good with user interfaces. I am not sure the right way to accept input for making prediction markets, so we cannot test these so well yet:
1) create a prediction market from a decision
2) buy/sell shares
3) SVD consensus to pay money to the winning share-holders
If you are willing to edit the python file, you might still be able to test them out.

If you make a list of what you want changed, then I will know what to do.
There are lots of places where I am unsure of vocabulary.
Title: Re: Blockchain for building upon
Post by: psztorc on September 15, 2014, 03:01:53 PM
Ok, it seemed cool but it was very difficult to tell what was going on from the terminal.

[1] You've misspelled: unzip mater.zip it should be 'master.zip'

[2] The reliance on rpy2 is crazy..it relies on a specific version of R, and it is so difficult to update R from within Ubuntu, that in order to do this I just VirtualBoxed a new Ubuntu. There's no reason to call the R code at all now that the python has been updated, if you're doing it in python.

I need to spend more time looking at it, trying to make a transaction. I think you should make a little 'demo' with functions for people to run.
Title: Re: Blockchain for building upon
Post by: zack on September 15, 2014, 09:08:57 PM
I just found out that the R code was already ported to python
This is great

I am sad that you were unable to get to the help system.
If you ask for help about any command, it gives an example of how to use that command.

I am not sure what you mean by 'demo'
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 16, 2014, 07:18:56 PM
Quote from: zack on September 15, 2014, 09:08:57 PM

I am not sure what you mean by 'demo'

well, just a list list of "demo" commands. Sure you can look them up in the help but directly running a demo is often the easiest way to get started.

I did not managed to run it. I also used a fresh Ubuntu but pip (and other methods) fail to install numpy. Numpy is awesome but I guess I can not count the hours I spend compiling it...

One small mistake in your installation description:

sudo apt-get update
sudo apt-get install python-leveldb
pip install -r requirements.txt
wget https://github.com/zack-bitcoin/Truthcoin-POW/archive/master.zip
unzip master.zip
cd Truthcoin-POW-master


pip install -r requirements.txt should be the last step.

And by the way: if you don't read the whole forum it is relative hard to find this thread and the https://github.com/zack-bitcoin/Truthcoin-POW. Maybe Zack, you should start a new thread "Python implementation" in the Development section.
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 12:29:41 AM
is there a easy option that I am connected to the network? (is the network running?) And if not - does the client start creating its own blockchain?

I am running it now for a few hours and turned mining on.
The blockcount command returned in the beginning 0 and now -1.
Title: Re: Blockchain for building upon
Post by: zack on September 17, 2014, 01:37:02 AM
I am glad you ran "blockcount"!

I have done updates since you posted that, I think I may have fixed your problems?
I just ran it, and I quickly downloaded the 8 blocks that have already been mined.

To see how connected I am, I run:
./truthd DB
and I look under the part that says "peers_ranked"
It looks like[[[192.241.212.114, 8900], 30], [['127.0.0.1', 8900], 30]]

The entrees are [[IP-address, port_number] average_amount_of_time_it_takes_to_talk_to_this_peer]

I set up this IP: 192.241.212.114 for networking purposes.


Starting a new thread is a good idea
Title: Re: Blockchain for building upon
Post by: zack on September 17, 2014, 02:37:30 AM
The bottleneck in development for this project is currently the lack of beta testers. I need more people to do what Paul and koeppelmann just did. I need to be shown bugs that I can reproduce.
I created a new scoreboard, to keep track of who points out bugs to me, in the order that it happens.
Bug-finders are so important, I cannot express how much I appreciate this service.

Hopefully the bug-finders will be given some of the pre-mine of cashcoins or votecoins.

Here is the new thread: http://forum.truthcoin.info/index.php/topic,142.0.html
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 06:52:24 AM
I played around with it - I will look deeper into it tomorrow, however some quick remarks:

Could get python threads.py get started on my mac. However when I tried to use thuthd.py it gave me:

response was: {'error': 'cannot connect: 127.0.0.1'}
truthcoin is probably off. Use command: "python threads.py" to turn it on. (you may need to reboot it a couple times to get it working)


any idea? How can I test what is running?

On ubuntu everything worked as expected. I could mine and was rewarded some coins.
However - I could not spend them.

./truthd.py spend 100 113dARdhbwSrbohSWoahQhKEyDZcoas

returned "None" and it did not changed my balance.

However, I started to write down what I did - mainly to get an overview for myself: http://piratepad.net/3o3xK3yje0


One thing from an architecture perspective I already noticed: running threads.py is comperable of running a bitcoin/truthcoin node?
Why does the node hold your private key? Wouldn't it be better to have it as slim as possible? You wallet/brainwallet/privatekeys obv. needs to be stored somehow on the disk - but it does not need to be in the running node. If you create a transaction for example you run the function and then pass the signed transaction to the node?
Just an idea...
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 07:05:23 AM
this might be of interest for you:


martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance
17900000
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py spend 1000 113dARdhbwSrbohSWoahQhKEyDZcoas
None
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance
truthcoin api main failure : (<type 'exceptions.TypeError'>, TypeError("'int' object is not iterable",), <traceback object at 0x7f5701471b48>)

Title: Re: Blockchain for building upon
Post by: zack on September 17, 2014, 12:31:45 PM
Quote from: koeppelmann on September 17, 2014, 07:05:23 AM
this might be of interest for you:


martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance
17900000
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py spend 1000 113dARdhbwSrbohSWoahQhKEyDZcoas
None
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance
truthcoin api main failure : (<type 'exceptions.TypeError'>, TypeError("'int' object is not iterable",), <traceback object at 0x7f5701471b48>)


I did not know about it till you showed me! It is fixed now.

I am not sure what is wrong with the mac. maybe my networking.py is wrong?
I don't have a mac to reproduce the bugs from, so I cannot add you to the scoreboard for mac bugs. Koeppelmann has the highest score so far, he is helping a lot.

I think that you are right about storing the private key. I tried fixed how private key is stored.

Thanks again for your help koeppelmann, you are making a big difference.
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 07:01:29 PM
Ok, still trying to get it running on a mac, I added to the code


while not DB['stop']:
        print DB
        time.sleep(0.5)


the result was (after some time):

{'stop': False, 'diffLength': '0', 'db': <leveldb.LevelDB object at 0x1b047a0>, 'mine': False, 'heart_queue': <multiprocessing.queues.Queue object at 0x1b044f0>, 'txs': [], 'peers_ranked': [[['192.241.212.114', 8900], 29.993509628926837], [['127.0.0.1', 8900], 29.998638870532321]], 'suggested_blocks': <multiprocessing.queues.Queue object at 0x1b045f0>, 'brainwallet': 'brain wallet', 'suggested_txs': <Queue.Queue instance at 0x1b0b058>, 'memoized_votes': {}, 'length': -1, 'privkey': 'fdbb564cabcd074b4f74d8cfba6e1f5f86dc43f048e8d9b57d1dbc06a2b31338', 'pubkey': '04664ecaa807d7e9c73cfc64b141a56c36a0ba5048843db3592310a6d4dc68c262f62a4053a53a2a622020a91fd4d9c55b64becf0b918cbbd34f1cf5ae0ab815c4', 'address': '11btWMfgyCi66nxiJMivmkdDVxDZpKj'}



At least it is running and it seems to have a connection to 192.241.212.114, but length (blockcount, right?) is 0.

BTW. for very simple problems skype is maybe a quicker solution than a forum... My Name in Skype: MartinK13
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 07:34:21 PM
I did the same on the ubuntu version and noticed that the output is here slightly different:

{'stop': False, 'diffLength': u'567114dc969a8517611af56a65ee172b10e9cca65a00b3ecd9315c7dd98fe926cfd6a18', 'db': <leveldb.LevelDB object at 0x7f858f55cea0>, 'mine': False, 'heart_queue': <multiprocessing.queues.Queue object at 0x7f858e089690>, 'txs': [], 'privkey': 'e72d48e99ef82b4f29efccf0eb6587b0fa3b6684e275423a141e0698f54b2016', 'suggested_blocks': <multiprocessing.queues.Queue object at 0x7f858e0897d0>, 'suggested_txs': <Queue.Queue instance at 0x7f858e08ab00>, 'memoized_votes': {}, 'length': 835, 'peers_ranked': [[['192.241.212.114', 8900], 29.999999773843584]], 'pubkey': '04ba9d76d0f8c62633c7a377e98e944e4f2e4d46f843236b19587f60c37f36c6342be23e2f33e51e910893926687b9fee25b2af329aca5b7fe9986c86c145c78ff', 'address': '113dARdhbwSrbohSWoahQhKEyDZcoas'}


Here is no 127.0.0.1 peer. And the ubuntu and the mac node do not find each other...
Title: Re: Blockchain for building upon
Post by: zack on September 17, 2014, 07:37:15 PM
Until I am able to use a mac, there is not much hope of getting this to work on a mac. I am sorry.

I like forums because I am able to deal with them and program at the same time. When I live-chat, it ruins my ability to code.

If I was to live-chat, I wouldn't use skype, because it is proprietary. I would use an XMPP like pidgin, hopefully with OTR.

In regard to the missing 127.0.0.1 peer. I just updated the code a bunch. removing that peer was part of the update.
Hopefully it is possible to create prediction markets, and buy shares from them.
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 17, 2014, 08:37:18 PM
sending money works. Even in cases it should better not :)

martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance
29098990
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py spend 29098991 115nxUddLmxijWskiz5znHxk1KdMZpS
added tx: {'count': 292, 'signatures': ['G30U3NyCn6iJf5i7c9MK+po2GUlOehi5waDOH18Jz0sK5K8WOkKecSAQqIVAt8eDxFwhPtiN78OYLkepjjEz5qo='], 'to': u'115nxUddLmxijWskiz5znHxk1KdMZpS', 'amount': 29098991, 'pubkeys': ['04ba9d76d0f8c62633c7a377e98e944e4f2e4d46f843236b19587f60c37f36c6342be23e2f33e51e910893926687b9fee25b2af329aca5b7fe9986c86c145c78ff'], 'type': 'spend'}
martin@martin-VirtualBox:~/Truthcoin-POW-master$ ./truthd.py my_balance-1001
Title: Re: Blockchain for building upon
Post by: zack on September 17, 2014, 08:50:00 PM
Good one!
Thank you very much.

I already fixed your bug.
Title: Re: Blockchain for building upon
Post by: koeppelmann on September 18, 2014, 06:26:21 PM
Just loaded the latest version.

martin@martin-VirtualBox:~/Truthcoin-POW-master$ python threads.py
You need to define either "pubkey" or "brain_wallet" in the file custom.py   If you want to make a new pubkey using the brain_wallet "brain_wallet_42", use the command: ./truthd new_address brain_wallet_42
martin@martin-VirtualBox:~/Truthcoin-POW-master$ python truthd.py new_address test
brain: test
privkey: c2a9068dc7c0830a2c7c95f82b0438eb4740ea39f1b023b515cf9dd0ddd803f3
pubkey: 04b91be1f1a46d5f061960eace4cc21f00971b47a4d5e4a23e413893c3650db56c26f21c1df4c13071c85dca14ea69a968221f06dd87aa84dea621e2c4510efd9b
address: 115MtZACq3ZtW7dezpwE4bXGPgxnWsj
martin@martin-VirtualBox:~/Truthcoin-POW-master$ python threads.py
You need to define either "pubkey" or "brain_wallet" in the file custom.py   If you want to make a new pubkey using the brain_wallet "brain_wallet_42", use the command: ./truthd new_address brain_wallet_42


From the output of the threads.py I would expect that the command
python truthd.py new_address
would set a brainwallet string. This seems not to work. Or does it only work if threads are running? And I can only change the brainwallet phrase with it?
Title: Re: Blockchain for building upon
Post by: zack on September 18, 2014, 06:54:45 PM
you need to manually copy/paste the pubkey that you generated into the file custom.py
Alternatively, you can put your brainwallet into the file custom.py

This steps seems overly complex right now, I have an idea on how to simplify it.

When you run: "python threads.py" I will have it immediately ask you for either a pubkey, or a brainwallet.

Once again, thank you so much for the help. You are making a big difference for this project.

OK, I finished fixing the bug.
Title: Re: Blockchain for building upon
Post by: psztorc on September 18, 2014, 11:23:27 PM
Thanks for your help, Martin!
Title: Re: Blockchain for building upon
Post by: zack on September 19, 2014, 01:23:36 AM
ok, I created a demo.
https://github.com/zack-bitcoin/Truthcoin-POW/blob/master/demo

Starting from an empty blockchain, this goes through the steps of
1) creating votecoins
2) asking the votecoin-holders a decision
3) creating a prediction market based on that decision
4) buying shares in the prediction market