Pages:
Author

Topic: 300 BTC Coding Contest: Distributed Exchange (MasterCoin Developer Thread) - page 24. (Read 129207 times)

hero member
Activity: 938
Merit: 1000
Graz: I noticed you fixed the rounding error; what was it in the end?

Zathras: Any details on the new parsing engine? Did it work?

Almost at 100% guys :}
sr. member
Activity: 449
Merit: 250
Masterchain, Mastercoin-Explorer and MyMastercoins are now fully synched (MSC).


Development should move faster now since we don't have any more Class A transaction for DEx.

sr. member
Activity: 449
Merit: 250
Bitoy a little summary for the work Graz, Zath and me have been doing this night/day:

  • We changed the date from which we started calculating the vesting development coins to the date the last block was accepted for the fundraiser. The new timestamp is: 1377993874
  • Our implementations should be 100% on consensus now but your engine appeared to have stopped working so we can't be 100% sure, also Zathras is still updating his blockchain with the new code.
  • Two new pull requests: Clarifications on the development Mastercoins and an update on the verification API to make it work for DEx consensus.


Ok will update dev coin calculations today. 

I update from blockchain.org every 30 minutes. Ill try to update more often ( but I'm very conscious that blockchain might block my IP address  Smiley.

hero member
Activity: 938
Merit: 1000
Bitoy a little summary for the work Graz, Zath and me have been doing this night/day:

  • We changed the date from which we started calculating the vesting development coins to the date the last block was accepted for the fundraiser. The new timestamp is: 1377993874
  • Our implementations should be 100% on consensus now but your engine appeared to have stopped working so we can't be 100% sure, also Zathras is still updating his blockchain with the new code.
  • Two new pull requests: Clarifications on the development Mastercoins and an update on the verification API to make it work for DEx consensus.
sr. member
Activity: 449
Merit: 250
I'm on ##mastercoin and #mastercoin, if Grazcoin has a problem with it we can use cryptocat as well but it won't have logs.

Bitoy already went to bed, but he never replied to my email so I can he won't be around.


Cryptocat doesn't work in ipad.   

I didn't get your email (in my gmail).   

I thought we are already synced but when I checked this morning.   Any changes in the formula?

1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P
MM=11063.84979076 
ME=11063.58647044



sr. member
Activity: 284
Merit: 250
I'm on ##mastercoin and #mastercoin, if Grazcoin has a problem with it we can use cryptocat as well but it won't have logs.

I am on channel mastercoin in cryptocat Smiley

sr. member
Activity: 266
Merit: 250
Figured I'd quickly post just before I hop in the shower - the P&D clarification - Tachikoma - yeah that's exactly what I was worried about (whether the simplification is too aggressive and may result in reference address ambiguity) but to be honest I would also be concerned if the order in which we tested the rules made a difference to how the transaction is interpreted.

I actually rewrote the engine already so I could run up a second test instance - I left it running last night but due to a bug with the new code it didn't complete so I don't yet have full comparison results (old way state vs revised way state).

I know you're not .NET but hopefully comments will make the logic easy enough to read - this was a massive code & logic simplification for the engine so I am hoping the testing shows no transactions with ambiguity and we can agree to keep it.  Just FYI really.  See you on IRC in about 10 Smiley

Code:
'/// non-multisig
                            'straight to p&d
                            'loop through outputs looking for data address
                            Dim dataaddressfound As Boolean = False
                            Dim dataaddress As String = ""
                            For i = 1 To outputs.Rows.Count
                                Dim rowbarray = ToByteArray(Trim(outputs.Rows(i - 1).Item("address")))
                                'test output for simple send bytes
                                If rowbarray(2) = 0 And rowbarray(3) = 0 And rowbarray(4) = 0 And rowbarray(5) = 0 And rowbarray(6) = 0 And rowbarray(7) = 0 And rowbarray(8) = 0 And (rowbarray(9) = 1 Or rowbarray(9) = 2) Then
                                    'check we have not already found the data address
                                    If dataaddressfound = True Then
                                        'more than one data address - drop tx
                                        Exit Function
                                    Else
                                        dataaddressfound = True
                                        dataaddress = outputs.Rows(i - 1).Item("address")
                                    End If
                                End If
                            Next
                            'identify reference address
                            'first test for exactly one output with data seqnum+1
                            Dim dataaddressseqnum As Integer = 9999
                            For i = 1 To outputs.Rows.Count
                                If outputs.Rows(i - 1).Item("address") = dataaddress Then dataaddressseqnum = outputs.Rows(i - 1).Item("seqnum")
                            Next
                            'sanity check - ensure we have a dataaddressseqnum
                            If dataaddressseqnum = 9999 Then Exit Function
                            'calc reference seqnum
                            Dim refseqnum As Integer = dataaddressseqnum + 1
                            'handle 255 to 0 case
                            If refseqnum = 256 Then refseqnum = 0
                            'see if we can find a single output with the reference seqnum
                            Dim refaddressfound As Boolean = False
                            Dim refaddress As String
                            For i = 1 To outputs.Rows.Count
                                If outputs.Rows(i - 1).Item("seqnum") = refseqnum Then
                                    'if we've already found one then this doesn't satisy 'single output with a seqnum +1 of the data address'
                                    If refaddressfound = True Then
                                        'exit without refaddress
                                        refaddressfound = False
                                        refaddress = ""
                                        Exit For
                                    Else
                                        refaddress = outputs.Rows(i - 1).Item("address")
                                        refaddressfound = True
                                    End If
                                End If
                            Next
                            'refaddress will be populated if we have found a single output with data seqnum+1
                            'if it's not populated move to second test (output amounts)
                            If refaddressfound = False And refaddress = "" Then
                                'here we test for a single output with the value the same as the exodus address (excluding data address)
                                For i = 1 To outputs.Rows.Count
                                    If outputs.Rows(i - 1).Item("amount") = exoamount And outputs.Rows(i - 1).Item("address") <> dataaddress Then
                                        'if we've already found one then this doesn't satisfy 'exactly two outputs with the same value as the data address'
                                        If refaddressfound = True Then
                                            'exit without refaddress
                                            refaddressfound = False
                                            refaddress = ""
                                            Exit For
                                        Else
                                            refaddress = outputs.Rows(i - 1).Item("address")
                                            refaddressfound = True
                                        End If
                                    End If
                                Next
                            End If
                            'see if we now have a dataaddress and refaddress, otherwise throw out tx
                            If dataaddress = "" Or refaddress = "" Then
                                Exit Function
                            Else
                                isvalidtx = True
                            End If

                            'decode transaction
...continues
hero member
Activity: 938
Merit: 1000
I'm on ##mastercoin and #mastercoin, if Grazcoin has a problem with it we can use cryptocat as well but it won't have logs.

Bitoy already went to bed, but he never replied to my email so I can he won't be around.

I somehow thought it was 8am where you were; next time we can do it two hours later and I will try to stay awake, I'm not great about staying awake though Wink

We have set the seconds in a year to 31556926 and I just implemented recalculations on block level so my balance should start syncing up!

I will see you on irc and we can talk more about other things Smiley
sr. member
Activity: 266
Merit: 250
Hey guys - ok I'm up (6:15am on a Sunday next time can we start a bit later? Tongue). 

Just jumping in the shower to try and wake myself up then we can get started Smiley  I have some notes on the posts over the last page or so - are we meeting up on IRC?

Thanks Smiley
Zathras
hero member
Activity: 938
Merit: 1000
sr. member
Activity: 449
Merit: 250
Yes Tachikoma, finally we are synched to the last msc.
11040.08115172

Grazcoin I think is just a block time away from synching 11039.54172323

( It's 2am here.  I'm going to zzzz =)

Edit
Grazcoin the difference is only 0.000000004.  Maybe you rounded to 7 digit instead of 8?
11040.7003806
11040.70038056
hero member
Activity: 938
Merit: 1000
Graz; difference between us is really small now.

Code:
     time_difference = (exodus_time.to_i - Mastercoin::END_TIME.to_i) / 31556926.0
      self.balance += ((1-(0.5**time_difference)) * BigDecimal.new("56316.23576222")).round(8)

Where exodus_time is the time from the latest block and Mastercoin::END_TIME is 1377993600.

Bitoy: We are actually synced up, so I guess we might both be wrong Wink

I'm stepping out to get some dinner; bbiab Smiley
sr. member
Activity: 449
Merit: 250
https://masterchest.info/consensus.aspx shows now -129.34% (negative number)
It seems like MyMastercoins is way out of sync.



Sorry accidentally pushed the "reset database" button.  It's now back    


For the Exodus Coins Generated I used the following formula

        Time1 = $Time of latest block in seconds
        dBlockDateTime = DateAdd(DateInterval.Second, Time1, New DateTime(1970, 1, 1, 0, 0, 0))

'Calculate number of seconds from September 1,2013 to Latest Block Time
        SecondsFromSept12013 = DateDiff(DateInterval.Second, #9/1/2013#, dBlockDateTime)

        Dim Gencoins As Double = (1 - (0.5 ^ (SecondsFromSept12013 / 31557600))) * 56316.23576222
        Gencoins = Round(Gencoins) to the nearest 8 decimal

Edit

OK will change   31557600 to 31556926

hero member
Activity: 938
Merit: 1000
Agreed; that's fine. I will make a pull request to add it to the spec.
sr. member
Activity: 284
Merit: 250
I'm on IRC now.

I think we need to pick a source and write down in the spec the source we use for the amount of seconds in a year.

I used: 60 * 60 * 24 * 365.25 but I guess we need to decide on the seconds amount. 

Why not just take the exact number and not an estimation?
http://wiki.answers.com/Q/How_many_seconds_are_there_in_a_year
31556926

hero member
Activity: 938
Merit: 1000
I'm on IRC now.

I think we need to pick a source and write down in the spec the source we use for the amount of seconds in a year.

I used: 60 * 60 * 24 * 365.25 but I guess we need to decide on the seconds amount. 
sr. member
Activity: 284
Merit: 250
Consensus is almost complete.


Consensus   Address                          MyMastercoins   Masterchain   Mastercoin-Explorer   Masterchest
181k55nxGuqDRpJx3iU43T4wJznf7ZazFN   0.043   0.043   0.043   
182osbPxCo88oaSX4ReJwUr9uAcchmJVaL   376.1846   376.1846   376.1846   376.2706
18ArFG8cPDT5P8NVdjFuSGjkybRTW8VBji   0.043   0.043   0.043   
1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P   11034.92330741   11035.15874017   10812.36900066   11034.92330741
1LjT88X7Zu8BdbqJw8vfRa83NJuzYL9kqm   60.12630845   60.12630845   60.12630845   10.00

Masterchain, mastercoin-explorer and mymastercoins are already synchronized except for the exodus address.

For the exodus address Mymastercoins recalculates based on the time of the latest block.
(Mymastercoins and masterchest has  the same balance)


BitBoy/Zathras -
Can you please give a link to the source code that calculates the available reward of exodus address?
I would like to compare and nail those differences.

sr. member
Activity: 284
Merit: 250
https://masterchest.info/consensus.aspx shows now -129.34% (negative number)
It seems like MyMastercoins is way out of sync.

sr. member
Activity: 284
Merit: 250

The reason I'm probably not matching is because I do it per second. I think we agreed somewhere in the thread Exodus should be calculated per on each block found using the block-date. I'm not doing that yet. I will be doing that during the coming hours so hopefully it should be online before the hackathon starts.

I will be in #mastercoin / ##mastercoin in a few minutes to work on the consensus stuff. If you are already available please drop by as well so we can discuss things there.

I don't think that calculating "per second" is the issue, since such a calculation would end up to a higher sum, and you have got a lower sum.

hero member
Activity: 938
Merit: 1000
Zathras's post about the P&D clarification.

Great post and it might solve our issues; I'm just afraid it might not solve all ambiguity. I think the P&D order is important because depending on what way you try to parse it first the recipient address might differ. I think the best way to see if your clarification holds up is to meet on IRC for the hackathon and discuss the remaining transactions and how the specs(-modifications) would answer them.

Consensus is nearing!
Let's close it today Smiley

masterchain.info and mastercoin-explorer.com have only one difference - the exodus address.
see https://masterchain.info/general/difference.json

at the moment the exodus address has different values on all 4 implementations:

11016.58589661 on MyMastercoins
11031.52547426 on Masterchain
10812.36900066 on Mastercoin-Explorer
11032.15274926 on Masterchest
         
Description of my calculation:
  • all_reward is 10% of the mastercoins sold during the bootstrap (total of 56316.23576245 MSC)
  • seconds_passed = last_block_timestamp - exodus_bootstrap_deadline
  • years = seconds_passed / seconds_in_one_year
  • part_available = 1 - 0.5 ** years
  • available_reward = all_reward * part_available

The constants are:
exodus_bootstrap_deadline = 1377993600
seconds_in_one_year=31556926

This calculation is also done for the validation of each simple send that exodus address sent (to verify that the amount does not exceed the balance at that moment).

masterchest gets a very close number to masterchain.
I suspect that the minor difference is due to the number of seconds in a year.

This commit is available here:
https://github.com/grazcoin/mastercoin-tools/commit/6e45b1dd7592e6094979044b82b1fc7b7132dd3b

The reason I'm probably not matching is because I do it per second. I think we agreed somewhere in the thread Exodus should be calculated per on each block found using the block-date. I'm not doing that yet. I will be doing that during the coming hours so hopefully it should be online before the hackathon starts.

I will be in #mastercoin / ##mastercoin in a few minutes to work on the consensus stuff. If you are already available please drop by as well so we can discuss things there.
Pages:
Jump to: