Bitcoin Forum
October 06, 2024, 07:45:25 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 [2]
21  Economy / Services / Re: [Contest] - Win 2 BTC for the best retargeting algorithm. Python testbed inside! on: December 01, 2016, 08:49:34 PM
Indeed that's a good idea, here is my version, I count the number of full blocks, and divide the adjustment by 2^FullBlockCount. Also, I don't do it if there is only one block full before as it induces too much oscillations.

Code:
import datetime
import random
import numpy as np
import matplotlib.pyplot as plt

# sudo apt-get install python-tk
# pip2 install numpy matplotlib

def create_block(timestamp, num_pow):
return {'time_stamp' : timestamp, 'num_pow' : num_pow, 'first_work_factor':0}

def create_work(idx, factor, target):
return {'id': idx, 'base_executions_per_second' : factor, 'target' : target}

def addSecs(tm, secs):
    fulldate = tm + datetime.timedelta(seconds=secs)
    return fulldate

def randomDuration():
if do_not_randomize_block_times_but_do_always_60_sec:
return 60
else:
return int(random.uniform(25, 120))

current_time = datetime.datetime.now()

# experiment with the number of work packages
works_to_create = 3

generate_blocks = 100
current_height = 0
blockchain = []
work_packages = []
base_target = 0x000000ffffffffffffffffffffffffff
poisson_distribution = np.random.poisson(5, generate_blocks)
stretch_number_pows = True
do_not_randomize_block_times_but_do_always_60_sec = False
new_miner_every_xth_second = 10
how_many_miners_come_or_go = 70242
initial_miners = 199381

def currently_active_miners(current_height):
# get the current active number of miners in relation of blockchain height,
# but the number of miners increases by 1 every 10 blocks
increases = int(current_height/new_miner_every_xth_second) * how_many_miners_come_or_go
return initial_miners+increases

# for now, leave poisson distributed variable miner count out and assume only one miner
ret = poisson_distribution[current_height]
if ret > 0:
return ret
else:
return 1

def miner_pows_based_on_target(work, height, dur):
current_target = work["target"]
factor = (current_target / base_target) * 1.0*dur/60.0
actual_pow_mined = work["base_executions_per_second"]
# random jitter
actual_pow_mined = abs((actual_pow_mined - 1) + random.uniform(1,2)) * currently_active_miners(height)
actual_pow_mined = actual_pow_mined *factor
# rate limit to 20 pows per block
        if actual_pow_mined > 20:
            actual_pow_mined = 20
if actual_pow_mined < 0:
actual_pow_mined = 0
if actual_pow_mined == 0:
print "mined",actual_pow_mined,work["base_executions_per_second"]*factor,currently_active_miners(height)
return actual_pow_mined
def kimoto(x):
    return  1 + (0.7084 * pow(((x)/(144)), -1.228));
def retarget_work(block, x):
    targetI = x["target"]
    pastMass = 0
    counter = 0
    current_block = block
    current_block_timestamp = blockchain[current_block]["time_stamp"]
    adjustment = 0
    isFull = True
    fullCnt = 0
    isEmpty = True
    emptyCnt = 0
    while isFull or isEmpty:
        if isFull and blockchain[current_block]["num_pow"][x["id"]] == 20:
            fullCnt += 1
        else:
            isFull = False
        if isEmpty and blockchain[current_block]["num_pow"][x["id"]] == 0:
            emptyCnt += 1
        else:
            isEmpty = False
        current_block -= 1
        if current_block < 1:
            break
    current_block = block
    while True:
        counter += 1
        pastMass += blockchain[current_block]["num_pow"][x["id"]]
        seconds_passed = (current_block_timestamp - blockchain[current_block-1]["time_stamp"]).seconds
        current_block -= 1
        if seconds_passed < 1:
            seconds_passed = 1
        trs_per_second = float(pastMass) / float(seconds_passed)
        target_per_second = 10.0 / 60.0
        adjustment = target_per_second / trs_per_second
        kim = kimoto(pastMass * 30)
        #print("kim : " + str(kim) + " adjustment : " + str(adjustment))
        if adjustment > kim or adjustment < (1.0/kim):
            break
        if current_block < 1:
            break
    if fullCnt > 1:
        adjustment = adjustment / (1 << (fullCnt))
    if emptuCnt > 1:
        adjustment = adjustment * (1 << (emptyCnt))
    targetI = targetI * adjustment
    if targetI>base_target:
            targetI = base_target
    if x["id"] == 0:
            blockchain[block]["first_work_factor"] = adjustment
    x["target"] = targetI


def retarget_works(block):
for x in work_packages:
retarget_work(block,x)

# Here we create up to three different work objects
if works_to_create>=1:
work_packages.append(create_work(0, 20, base_target))
if works_to_create>=2:
work_packages.append(create_work(1, 60, base_target))
if works_to_create>=3:
work_packages.append(create_work(2, 35, base_target))

while current_height < generate_blocks:
dur = randomDuration()
current_time = addSecs(current_time,dur) # random block generation time
block_pows = {}
for x in work_packages:
num_pow = miner_pows_based_on_target(x, current_height, dur) # mine some POW depending on the current difficulty
block_pows[x["id"]] = num_pow
blockchain.append(create_block(current_time, block_pows))
retarget_works(current_height) # This retargeting method is the "critical part here"
current_height = current_height + 1


values = []
target_factors = []
ideal = []
for idx in range(len(blockchain)):
if idx == 0:
continue
x = blockchain[idx]
x_minus_one = blockchain[idx-1]
time_passed = (x["time_stamp"] - x_minus_one["time_stamp"]).seconds
strech_normalizer = time_passed / 60.0
if stretch_number_pows == False:
ideal.append(works_to_create*10*strech_normalizer)
else:
ideal.append(works_to_create*10)
sum_x = 0
for y in x["num_pow"]:
sum_x += x["num_pow"][y]
if stretch_number_pows == False:
values.append(sum_x)
else:
values.append(sum_x/strech_normalizer)
x = range(generate_blocks)[1:]
y = values

#fig = plt.figure()
ax0 = plt.subplot(211)
if stretch_number_pows:
ax0.set_ylabel('POW rate per 60s', color='b')
else:
ax0.set_ylabel('POWs per Block', color='b')
ax0.set_xlabel('Block height')
ax0.plot(x,y,'-o',x,ideal,'r--')
values = []
ideal = []
target_factors = []
for idx in range(len(blockchain)):
if idx == 0:
continue
x = blockchain[idx]
x_minus_one = blockchain[idx-1]
time_passed = (x["time_stamp"] - x_minus_one["time_stamp"]).seconds
strech_normalizer = time_passed / 60.0
if stretch_number_pows == False:
ideal.append(10*strech_normalizer)
else:
ideal.append(10)
sum_x = 0
sum_x += x["num_pow"][0]
#print "sumx",sum_x
if stretch_number_pows == False:
values.append(sum_x)
else:
values.append(sum_x/strech_normalizer)
x = range(generate_blocks)[1:]
y = values
plt.title('All Works: Total POWs')

ax1 = plt.subplot(212)
ax1.plot(x,y,'-o',x,ideal,'r--')
ax1.set_xlabel('Block Height')
# Make the y-axis label and tick labels match the line color.
if stretch_number_pows:
ax1.set_ylabel('POW rate per 60s', color='b')
else:
ax1.set_ylabel('POWs per Block', color='b')

for tl in ax1.get_yticklabels():
    tl.set_color('b')



ax2 = ax1.twinx()
ax2.set_ylim(0.4, 1.6)
ax2.bar(x,[x["first_work_factor"] for x in blockchain][1:],0.45,color='#deb0b0', alpha=0.2)
ax2.set_ylabel('Retargeting Factor', color='r')
for tl in ax2.get_yticklabels():
    tl.set_color('r')
plt.title('First Work: POWs + Retargeting Factor')

plt.show()

With random block time:



With fixed block time:

22  Economy / Services / Re: [Contest] - Win 2 BTC for the best retargeting algorithm. Python testbed inside! on: December 01, 2016, 02:35:08 PM
Okay I see, but like I said, this is due to the fact that we can't be aware there is that much miners on the network. All we see is 20 transactions per block. Because of this 20 transactions limit, we can't know how much transaction would have been really mined, so we can't know the hashing power of the network.
23  Economy / Services / Re: [Contest] - Win 2 BTC for the best retargeting algorithm. Python testbed inside! on: December 01, 2016, 01:45:20 PM
What do you mean by slow initialization ?
If I understand your code correctly, the huge spikes are due to the fact that in the beginning, the amount of miners is multiplied by 6, then by 2, then by 0.68, etc so you have this ripple effect, and you can't do much about the spikes, you have to wait for the re targeting to happen for them to be corrected.
24  Economy / Services / Re: [Contest] - Win 2 BTC for the best retargeting algorithm. Python testbed inside! on: December 01, 2016, 11:21:35 AM
Results when we randomize the block time:

25  Economy / Services / Re: [Contest] - Win 2 BTC for the best retargeting algorithm. Python testbed inside! on: December 01, 2016, 11:14:00 AM
The kimoto function was designed to take into account the few last blocks if the hashrate is changing too much in a short amount of time. The block mass needs to be quite high for kimoto to start having reasonable values (kimoto(144) = 1.7084), so a lot of blocks will be taken into account, even if you have a big change in mining power, which will slow down the adjustment.
So, I think you should increase the blockMass argument, few tests lead me to think that blockMass * 30 is a good choice, with this parameter, the amount of block to be taken into account (Assuming 10 transactions per block) will quickly decrease as the blockMass increases, and works OK in your case where there is a lot of sudden changes in the number of transaction per seconds, which I don't think would happen that much in production, well I don't really know because I haven't quite understood what you are trying to do.
Also, because we are limited to 20 trs/minwe don't know if the actual rate is 21 or 300, so in case of big spike, it will take time to readjust the difficulty.

Finally, do you want to adjust the difficulty at each blocks ?




Code:
def retarget_work_2(block, x):
    targetI = x["target"]
    pastMass = 0
    counter = 0
    current_block = block
    current_block_timestamp = blockchain[current_block]["time_stamp"]
    adjustment = 0
    while True:
        counter += 1
        pastMass += blockchain[current_block]["num_pow"][x["id"]]
        seconds_passed = (current_block_timestamp - blockchain[current_block-1]["time_stamp"]).seconds
        current_block -= 1
        if seconds_passed < 1:
            seconds_passed = 1
        trs_per_second = float(pastMass) / float(seconds_passed)
        target_per_second = 10.0 / 60.0
        adjustment = target_per_second / trs_per_second
        kim = kimoto(pastMass * 30)
        #print("kim : " + str(kim) + " adjustment : " + str(adjustment))
        if adjustment > kim or adjustment < (1.0/kim):
            print("kim : " + str(kim) + " 1/kim : " + str(1.0/kim) + " adj : " + str(adjustment))
            break
        if current_block < 1:
            break
    targetI = targetI * adjustment
    if targetI>base_target:
            targetI = base_target
    if x["id"] == 0:
            blockchain[block]["first_work_factor"] = adjustment
    x["target"] = targetI

26  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN] DECENT Announcement - Decentralizing Content Distribution on: September 11, 2016, 07:17:15 PM
Check the latest article about DECENT Network in Forbes!

Widespread adoption of blockchain technology is becoming a reality with growing trend of decentralized organizations:
http://www.forbes.com/sites/rogeraitken/2016/09/11/decent-crypto-investment-paves-way-to-decentralized-content-distribution-revolution/#4244bf1df942

Nice. There is a mistake in his article: "Specifically, the bonus (discount) is valid for the first 10 million DCT (DECENT)." lol


Lel, it should be more like "All the investors will benefit a 50% discount"
27  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN] DECENT Announcement - Decentralizing Content Distribution on: September 11, 2016, 05:12:32 PM
I don't know if you guys realized, but 90% of the fund will benefit the 50% bonus, what that means is that in the end, it will be like everyone had participated in the ico with a 0% bonus.
28  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [PRE-ANN] OPAIR | ICO - 15% Bonus ends in 7 days | New Blockchain Platform on: August 04, 2016, 07:15:18 PM


In start of the ico, the rules were accepted by all. Then by a suggestion of the community they decided to use an escrow for the future. They did not change the rules without asking anyone and to the detriment of investors, but just changed that rule for the future of the ICO for the community suggestion. And they established that the second phase will be escrow and refund to anyone who asks, because will be governed by the rules of escrow (SebastianJu). It is very clear to me.



Not extending escrow to ALL investors is obviously to the detriment of those investors who don't get it. The dev team changed the rules, that is obvious too, and not changing rules for all investors is very unfair. They have the chance to do the right thing and offer escrow to ALL investors. If they don't then their ICO continues to suffer from scam perception.

The devs didn't change the rules, they divided the ICO in two phases, the first one under certain conditions, and the second one under other conditions. It is then obvious that the btc given under the first conditions must stay under the first conditions, as the investors consented the first conditions, not the second. It would be wrong to assume every investor from the first ICO phase agree on the second conditions. You can't do whatever you want.

The devs changed the rules/conditions/terms, where in the original OP is any mention of phase 1 & phase 2?

It's so obvious they changed the terms of the ICO in response to criticism ... they should make same conditions for every investor, otherwise ask yourself why they wouldn't? If ALL funds are in escrow ALL investors will have 100% confidence a working network will be delivered.

I participated in phase 1 knowing there will be no escrow, and I have confidence in the project. Wait are you telling me there are people who invested without reading the conditions, and don't have confidence in the project ? What happened ? Someone put a gun on their head forcing them to invest ? That's crazy :/
29  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [PRE-ANN] OPAIR | ICO - 15% Bonus ends in 7 days | New Blockchain Platform on: August 04, 2016, 06:49:31 AM


In start of the ico, the rules were accepted by all. Then by a suggestion of the community they decided to use an escrow for the future. They did not change the rules without asking anyone and to the detriment of investors, but just changed that rule for the future of the ICO for the community suggestion. And they established that the second phase will be escrow and refund to anyone who asks, because will be governed by the rules of escrow (SebastianJu). It is very clear to me.



Not extending escrow to ALL investors is obviously to the detriment of those investors who don't get it. The dev team changed the rules, that is obvious too, and not changing rules for all investors is very unfair. They have the chance to do the right thing and offer escrow to ALL investors. If they don't then their ICO continues to suffer from scam perception.

The devs didn't change the rules, they divided the ICO in two phases, the first one under certain conditions, and the second one under other conditions. It is then obvious that the btc given under the first conditions must stay under the first conditions, as the investors consented the first conditions, not the second. It would be wrong to assume every investor from the first ICO phase agree on the second conditions. You can't do whatever you want.
30  Alternate cryptocurrencies / Announcements (Altcoins) / Re: | STRATIS | The first blockchain developed for businesses |Funded 915 BTC on: August 03, 2016, 07:19:53 PM
Stratis is going to be one of the best coins of 2016  Cheesy

You really have no use other than pumping coins and fuding other Sad
31  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [PRE-ANN] OPAIR | ICO - 20% Bonus ends in 4 days | New Blockchain Platform on: July 29, 2016, 11:26:14 AM
OP is going to be one of the first to actually orchestrate this ICO scam on your own really. You don't have any partner apart from those fictional  users on linkedin probably the ones you created yourself. Congrats to that in advance.

Says the user with a YoBit signature  Grin
32  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN][LISK] Lisk | ICO | Decentralized Application & Sidechain Platform on: April 23, 2016, 07:16:39 AM
Boa Noite Galera!!!
Lisk na Chameleon menos de 100k

Lisk na yobit mais de 400k
Comprando Lisk com mais de 50% abaixo do preço lá fora!
Aproveite!!!

#TeamChameleon

lisk on chameleon less than 100k

and lisk on yobit is 400k

was that you wanna mean?


but what is this chamelon? and why the price is so cheap? at least put this on bleutrade and maybe i will buy some

looks like new south american exchange.  site looks good but they never got back to me on any proof of their lisk holdings.

We have a smart contract that can be checked in the very exchange, with all trading data. It can be checked via the signing of the agreement blockchain as far as the terms. no link :
http://chameleonbit.trade/contract


Go Chameleon!

need more information? pm me, no problem Cheesy


There is bug every where in your website. Why are you still using php ? It will get hacked for sure and that will be again a bad thing for the crypto reputation. This is why we can't have nice things...
33  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN][LISK] Lisk | ICO | Decentralized Application & Sidechain Platform on: March 16, 2016, 03:03:49 PM
I'd like to see what the Devs are planning to use the funds for. What does the community think the top priorities are, in regards to how to spend the funds from this ico?

We definitly need to motivate people to create dapps, so maybe develop a framework like Truffle for ethereum

https://github.com/ConsenSys/truffle
34  Alternate cryptocurrencies / Announcements (Altcoins) / Re: [ANN][LISK] Lisk | ICO | Decentralized Application & Sidechain Platform on: March 14, 2016, 01:28:48 PM
2,4 BTC to 4000  Smiley Not including 832 BTC worth of XCR

4000 is massive Shocked what if doubles before the end? Tongue
The LISK ROI double.

Hey, why would the ROI double ? If I understand correctly, if the amount of BTC doubles, we will receive 2x less lisk, but the price of one lisk will be multiplied by two. So the ROI should stay the same no ?
Thanks  Smiley
Pages: « 1 [2]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!