Author

Topic: DNotes 2.0 - Staking, CRISP Interest, DNotes Pay - page 204. (Read 148848 times)

hero member
Activity: 938
Merit: 1000
www.multipool.us
Found the issue -- it's a floating point bug in GetBlockValue()


Thanks flound1129! That is correct, some blocks like 2103797 reward 20.36265624 rather than (25*math.pow(0.95,4)) 20.36265625. The mystery remains, why your node rejects it and all the others seem fine with it.

It's not really a mystery, pow(0.95,4)*25 at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L851-L853 evaluates to 20.362656249999997 on my system, which evaluates to False in the comparison at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L1431 when the coinbase transaction vtx[0].getValueOut() == 20.36265625 and thus the block is considered invalid.

Minor correction, since nSubsidy starts out as an int64, the math should be pow(0.95,4)*2500000000 == 2036265624.9999998, which is being cast back to an int64 type at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L853

Expected behavior when casting a floating point value to an int is that the number is truncated (not rounded).  See https://stackoverflow.com/questions/9695329/c-how-to-round-a-double-to-an-int

Patching main.cpp in the following manner (assuming rounding is the desired behavior) appears to fix the issue:

Code:
diff --git a/src/main.cpp b/src/main.cpp
index 4773964..48d7b3c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -850,7 +850,7 @@ int64 static GetBlockValue(int nHeight, int64 nFees)
        {
                int yearsElapsed = nHeight / 525949;
                double nReductionPercentage = pow(0.95,yearsElapsed);
-               nSubsidy = nSubsidy * nReductionPercentage;
+               nSubsidy = (int64) ((nSubsidy * nReductionPercentage)+0.5);
        }
     return nSubsidy + nFees;
 }


Appreciate it flound1129! There was 8 or so blocks that reported 20.36265624 reward after the reward change, all of the rest have been 20.36265625, and at the point where it was 20.36265625 is the block your node started rejecting blocks. There have been no other reports of incident since, so I assume the problem is isolated to your specific setup, or as for on the network your machine. The problem is to make changes to the block reward would require forking the network, which creates an even bigger problem and across the entire network. I'll have to check, but I don't believe this can be changed just on your side without impacting the rest of the network.

This doesn't change the block reward, it fixes the truncation.  Adding 0.5 is the recommended way to do this in c++.

Again, see https://stackoverflow.com/questions/9695329/c-how-to-round-a-double-to-an-int

nSubsidy is in satoshis.

I don't know whether this will result in the correct behavior across all platforms, so you should probably pass it to your devs and/or do some quick testing to make sure the returned number is still correct on your systems.

I'd also be happy with an official fix from the DNotes team.
legendary
Activity: 1932
Merit: 1111
DNotes
Found the issue -- it's a floating point bug in GetBlockValue()


Thanks flound1129! That is correct, some blocks like 2103797 reward 20.36265624 rather than (25*math.pow(0.95,4)) 20.36265625. The mystery remains, why your node rejects it and all the others seem fine with it.

It's not really a mystery, pow(0.95,4)*25 at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L851-L853 evaluates to 20.362656249999997 on my system, which evaluates to False in the comparison at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L1431 when the coinbase transaction vtx[0].getValueOut() == 20.36265625 and thus the block is considered invalid.

Minor correction, since nSubsidy starts out as an int64, the math should be pow(0.95,4)*2500000000 == 2036265624.9999998, which is being cast back to an int64 type at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L853

Expected behavior when casting a floating point value to an int is that the number is truncated (not rounded).  See https://stackoverflow.com/questions/9695329/c-how-to-round-a-double-to-an-int

Patching main.cpp in the following manner (assuming rounding is the desired behavior) appears to fix the issue:

Code:
diff --git a/src/main.cpp b/src/main.cpp
index 4773964..48d7b3c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -850,7 +850,7 @@ int64 static GetBlockValue(int nHeight, int64 nFees)
        {
                int yearsElapsed = nHeight / 525949;
                double nReductionPercentage = pow(0.95,yearsElapsed);
-               nSubsidy = nSubsidy * nReductionPercentage;
+               nSubsidy = (int64) ((nSubsidy * nReductionPercentage)+0.5);
        }
     return nSubsidy + nFees;
 }


Appreciate it flound1129! There was 8 or so blocks that reported 20.36265624 reward after the reward change, all of the rest have been 20.36265625, and at the point where it was 20.36265625 is the block your node started rejecting blocks. There have been no other reports of incident since, so I assume the problem is isolated to your specific setup, or as for on the network your machine. The problem is to make changes to the block reward would require forking the network, which creates an even bigger problem and across the entire network. I'll have to check, but I don't believe this can be changed just on your side without impacting the rest of the network.
hero member
Activity: 938
Merit: 1000
www.multipool.us
Found the issue -- it's a floating point bug in GetBlockValue()


Thanks flound1129! That is correct, some blocks like 2103797 reward 20.36265624 rather than (25*math.pow(0.95,4)) 20.36265625. The mystery remains, why your node rejects it and all the others seem fine with it.

It's not really a mystery, pow(0.95,4)*25 at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L851-L853 evaluates to 20.362656249999997 on my system, which evaluates to False in the comparison at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L1431 when the coinbase transaction vtx[0].getValueOut() == 20.36265625 and thus the block is considered invalid.

Minor correction, since nSubsidy starts out as an int64, the math should be pow(0.95,4)*2500000000 == 2036265624.9999998, which is being cast back to an int64 type at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L853

Expected behavior when casting a floating point value to an int is that the number is truncated (not rounded).  See https://stackoverflow.com/questions/9695329/c-how-to-round-a-double-to-an-int

Patching main.cpp in the following manner (assuming rounding is the desired behavior) appears to fix the issue:

Code:
diff --git a/src/main.cpp b/src/main.cpp
index 4773964..48d7b3c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -850,7 +850,7 @@ int64 static GetBlockValue(int nHeight, int64 nFees)
        {
                int yearsElapsed = nHeight / 525949;
                double nReductionPercentage = pow(0.95,yearsElapsed);
-               nSubsidy = nSubsidy * nReductionPercentage;
+               nSubsidy = (int64) ((nSubsidy * nReductionPercentage)+0.5);
        }
     return nSubsidy + nFees;
 }
legendary
Activity: 1932
Merit: 1111
DNotes
Found the issue -- it's a floating point bug in GetBlockValue()
  These are my favorite posts in support case type communiques. The one where the solution has been found.

And to follow up on a post above, how are things progressing towards the 2.0 launch overall? Quick shareholder, top-level summary por favor?

We are on track for having the wallet with invoicing and CRISP integrated for mid March. The actual launch date is TBA.

I had a great meeting with the Geneca's team this afternoon. Though the main discussion was about an objective review of our ecosystems and their effectiveness in achieving our overall missions in pursuit of our vision to gain mass adoption of DNotes, we also discussed about DNotes 2.0 launch. We are confident that our phase one and phase two delivery of the wallet with invoicing and CRISP integrated will be in Beta testing stage by March 18, 2018. The launch date will be announced as soon as both teams mutually agreed that the product has been rigorously tested. There is a high level of confidence that the launch date will take place in early April, 2018.

I have a lot of respect for Geneca. We are very fortunate to have an immensely capable team that aligns so well with our business philosophies and commitment to always strive to be best in class. At times, it takes a little longer and cost more. At the end, we always do what is best for DNotes.

Three of Geneca's project managers from their "Experience Team" were assigned to go over everything that we have done for DNotes over the last four years. On the second day, one of them commented that it would take "four years" to read all the contents we have created. They are extremely impressed but also make some great recommendations.






One of the recommendations Geneca proposed was changing the main headline and sub headline:
BRIDGING THE GAP BETWEEN THE CENTRALIZED AND DECENTRALIZED.
Enabling peer to peer transfer of digital assets around the globe.

To something that is easier to understand regardless of the experience and knowledge of the user. If anyone has any recommendations, it would be appreciated.
legendary
Activity: 1932
Merit: 1111
DNotes
Another question -- how are you planning for people to redeem coins in 2.0?  Will they simply load their existing DNotes wallets into the new client or is there some kind of transaction or swap that will take place?

It will be a 1:1 swap. DNotesVault is the recommended place to store your coins for participating in the swap without any further action, but there will be a manual process in place as well for those who don't use the DNotesVault.

How will people send their coins into the vault after PoW ends?


We will keep both networks running until the specified deadline to ensure there is plenty of time to participate. Any later comers can be handled on a case by case basis.

To elaborate a little on how the process will look.

The block reward will continue until the specified deadline, and all DNotes generated until then can be swapped. Beyond the deadline, we will create a fork with no reward, effectively creating a snapshot of the blockchain up to that point that we may maintain.
legendary
Activity: 1932
Merit: 1111
DNotes
Another question -- how are you planning for people to redeem coins in 2.0?  Will they simply load their existing DNotes wallets into the new client or is there some kind of transaction or swap that will take place?

It will be a 1:1 swap. DNotesVault is the recommended place to store your coins for participating in the swap without any further action, but there will be a manual process in place as well for those who don't use the DNotesVault.

How will people send their coins into the vault after PoW ends?


We will keep both networks running until the specified deadline to ensure there is plenty of time to participate. Any later comers can be handled on a case by case basis.
hero member
Activity: 938
Merit: 1000
www.multipool.us
Another question -- how are you planning for people to redeem coins in 2.0?  Will they simply load their existing DNotes wallets into the new client or is there some kind of transaction or swap that will take place?

It will be a 1:1 swap. DNotesVault is the recommended place to store your coins for participating in the swap without any further action, but there will be a manual process in place as well for those who don't use the DNotesVault.

How will people send their coins into the vault after PoW ends?
legendary
Activity: 1932
Merit: 1111
DNotes
Another question -- how are you planning for people to redeem coins in 2.0?  Will they simply load their existing DNotes wallets into the new client or is there some kind of transaction or swap that will take place?

It will be a 1:1 swap. DNotesVault is the recommended place to store your coins for participating in the swap without any further action, but there will be a manual process in place as well for those who don't use the DNotesVault.
legendary
Activity: 1932
Merit: 1111
DNotes
BTW, after patching that bug I am having another issue with block 2112868:

received block f92754272d97decab8f9
Difficulty Retarget - Gravity Well
PastRateAdjustmentRatio = 1.03675
Before: 1b6e0383 00000000006e0383000000000000000000000000000000000000000000000000
After: 1b6e041c 00000000006e041c54ba374cbaf4bff21d62b9cf6d6c186d49d80f66e461ae64
ERROR: FetchInputs() : 55e029f6c8 prev tx cd8c9bac39 index entry not found
InvalidChainFound: invalid block=f92754272d97decab8f9  height=2112868  work=1479669443777755434  date=02/27/18 23:13:05
InvalidChainFound:  current best=b5b2df16b6a852dc161a  height=2112867  work=1479666885287689994  date=02/27/18 23:10:39
ERROR: SetBestChain() : SetBestChainInner failed
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block c884546d406238eba489
Difficulty Retarget - Gravity Well
PastRateAdjustmentRatio = 1.03705
Before: 1b6e041c 00000000006e041c000000000000000000000000000000000000000000000000
After: 1b6dff50 00000000006dff50f9642ef50b6e7663ec33fe75a457dbe53e0fd8accd7b48ab
Postponing 1 reconnects



Glad to hear you got past it. So it's saying it didn't find the tx inputs (which are there https://chainz.cryptoid.info/note/tx.dws?cd8c9bac39f87eb87bdc16bd9c70256ae75ac26b9e15e326d30578768bd9980f.htm)?
Did it halt updating here? If so, close and restart or reindex?
hero member
Activity: 938
Merit: 1000
www.multipool.us
Another question -- how are you planning for people to redeem coins in 2.0?  Will they simply load their existing DNotes wallets into the new client or is there some kind of transaction or swap that will take place?
hero member
Activity: 938
Merit: 1000
www.multipool.us
BTW, after patching that bug I am having another issue with block 2112868:

received block f92754272d97decab8f9
Difficulty Retarget - Gravity Well
PastRateAdjustmentRatio = 1.03675
Before: 1b6e0383 00000000006e0383000000000000000000000000000000000000000000000000
After: 1b6e041c 00000000006e041c54ba374cbaf4bff21d62b9cf6d6c186d49d80f66e461ae64
ERROR: FetchInputs() : 55e029f6c8 prev tx cd8c9bac39 index entry not found
InvalidChainFound: invalid block=f92754272d97decab8f9  height=2112868  work=1479669443777755434  date=02/27/18 23:13:05
InvalidChainFound:  current best=b5b2df16b6a852dc161a  height=2112867  work=1479666885287689994  date=02/27/18 23:10:39
ERROR: SetBestChain() : SetBestChainInner failed
ERROR: AcceptBlock() : AddToBlockIndex failed
ERROR: ProcessBlock() : AcceptBlock FAILED
received block c884546d406238eba489
Difficulty Retarget - Gravity Well
PastRateAdjustmentRatio = 1.03705
Before: 1b6e041c 00000000006e041c000000000000000000000000000000000000000000000000
After: 1b6dff50 00000000006dff50f9642ef50b6e7663ec33fe75a457dbe53e0fd8accd7b48ab
Postponing 1 reconnects
hero member
Activity: 938
Merit: 1000
www.multipool.us
Found the issue -- it's a floating point bug in GetBlockValue()


Thanks flound1129! That is correct, some blocks like 2103797 reward 20.36265624 rather than (25*math.pow(0.95,4)) 20.36265625. The mystery remains, why your node rejects it and all the others seem fine with it.

It's not really a mystery, pow(0.95,4)*25 at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L851-L853 evaluates to 20.362656249999997 on my system, which evaluates to False in the comparison at https://github.com/DNotesCoin/DNotes/blob/master/src/main.cpp#L1431 when the coinbase transaction vtx[0].getValueOut() == 20.36265625 and thus the block is considered invalid.


legendary
Activity: 1610
Merit: 1060
Found the issue -- it's a floating point bug in GetBlockValue()
  These are my favorite posts in support case type communiques. The one where the solution has been found.

And to follow up on a post above, how are things progressing towards the 2.0 launch overall? Quick shareholder, top-level summary por favor?

We are on track for having the wallet with invoicing and CRISP integrated for mid March. The actual launch date is TBA.

I had a great meeting with the Geneca's team this afternoon. Though the main discussion was about an objective review of our ecosystems and their effectiveness in achieving our overall missions in pursuit of our vision to gain mass adoption of DNotes, we also discussed about DNotes 2.0 launch. We are confident that our phase one and phase two delivery of the wallet with invoicing and CRISP integrated will be in Beta testing stage by March 18, 2018. The launch date will be announced as soon as both teams mutually agreed that the product has been rigorously tested. There is a high level of confidence that the launch date will take place in early April, 2018.

I have a lot of respect for Geneca. We are very fortunate to have an immensely capable team that aligns so well with our business philosophies and commitment to always strive to be best in class. At times, it takes a little longer and cost more. At the end, we always do what is best for DNotes.

Three of Geneca's project managers from their "Experience Team" were assigned to go over everything that we have done for DNotes over the last four years. On the second day, one of them commented that it would take "four years" to read all the contents we have created. They are extremely impressed but also make some great recommendations.



legendary
Activity: 1932
Merit: 1111
DNotes
is there any way to earn dnotes without mining or buying? maybe a site with little jobs or something else? i like the project, but i have no the financial reserve to buy me coins. so i search ways to earn coins or token. the dnote community offer this option for people like me?

Welcome sabine80! Please feel free to email me at [email protected] and we can discuss further.
legendary
Activity: 1932
Merit: 1111
DNotes
Found the issue -- it's a floating point bug in GetBlockValue()
  These are my favorite posts in support case type communiques. The one where the solution has been found.

And to follow up on a post above, how are things progressing towards the 2.0 launch overall? Quick shareholder, top-level summary por favor?

We are on track for having the wallet with invoicing and CRISP integrated for mid March. The actual launch date is TBA.
legendary
Activity: 1932
Merit: 1111
DNotes
Found the issue -- it's a floating point bug in GetBlockValue()


Thanks flound1129! That is correct, some blocks like 2103797 reward 20.36265624 rather than (25*math.pow(0.95,4)) 20.36265625. The mystery remains, why your node rejects it and all the others seem fine with it.
member
Activity: 728
Merit: 14
is there any way to earn dnotes without mining or buying? maybe a site with little jobs or something else? i like the project, but i have no the financial reserve to buy me coins. so i search ways to earn coins or token. the dnote community offer this option for people like me?
full member
Activity: 207
Merit: 100
Found the issue -- it's a floating point bug in GetBlockValue()
  These are my favorite posts in support case type communiques. The one where the solution has been found.

And to follow up on a post above, how are things progressing towards the 2.0 launch overall? Quick shareholder, top-level summary por favor?
hero member
Activity: 938
Merit: 1000
www.multipool.us
Found the issue -- it's a floating point bug in GetBlockValue()
full member
Activity: 1078
Merit: 102
EU Prepared to Regulate Cryptocurrency Unless Risks Addressed

https://dcebrief.com/eu-prepared-to-regulate-cryptocurrency-unless-risks-addressed/
Jump to: