create account

Steem Witness Scheduling Algorithm by dantheman

View this thread on: hive.blogpeakd.comecency.com
· @dantheman ·
$63.37
Steem Witness Scheduling Algorithm
The Steem witness scheduling algorithm is designed to pick 21 witnesses to sign the next 21 blocks. There are three ways that an witness can be selected:

1. Be in the top 19 by total approval voting
2. Be the next in line in the POW queue
3. Be the witness with the lowest virtual_scheduled_time

If a witness is any where in the POW queue they are excluded from being selected by one of the other two methods.

If a witness is in the top 19 by total approval voting, they are excluded from being selected by virtual_scheduled_time.

Every 21 blocks is considered a “round” and this algorithm is executed at the start of each round.

## Understanding Virtual Time

Imagine a very long race track such that even the fastest possible car takes 1000 seconds to complete a lap. Imagine that a witness’ votes are its speed. The *virtual_scheduled_time* is the time at which a witness will complete its lap and get added to a round.

Every time a witness completes a lap, they are scheduled to produce a block. The witness with the lowest
*virtual_scheduled_time* is next one to be included in a round. When they are scheduled, the global
*current_virtual_time* is updated.

Every time a witness’ vote changes, their position on the race track is updated based upon the virtual time elapsed since their last update and their velocity (votes) over that same time period. Once their new position and velocity are adjusted a new *virtual_scheduled_time* is calculated. 

## Updating the Witness Schedule

The first step is to iterate over witnesses sorted by total vote and add them to the active set until the active set reaches 19.  If any witness is in the POW queue they are skipped during this phase.  For each of these witnesses their virtual_scheduled_time is set to “infinity” or the maximum allowed so that they are not selected by subsequent steps.

The second step is to fetch the witness with the lowest *virtual_scheduled_time* that isn’t in the POW queue. Virtual scheduled time starts out initialized at infinity for miners and new witnesses and only gets set to something lower when there are votes.

Once the witness is identified, the current virtual time is set to its scheduled time. Its virtual position gets reset to 0 (start of lap) and it is assigned a new virtual scheduled time based upon its velocity (aka votes).

At this point the network has assigned 20 of 21 witnesses.

If there are at least 21 POW witnesses in the queue (and there should always be) then the top POW worker is popped by setting the pow_worker property to 0 and decreasing the num_pow_witnesses.  pow_worker represents the total cumulative pow work measured as the sum of queue length at the time each POW is solved. A value of 0 is reserved to mean “unscheduled”, otherwise all witnesses are guaranteed to be sorted by this field. 

By fetching the lowest pow_worker greater than 0 ( index.upper_bound(0) ) we can find the POW worker that should be included in the block.

## Shuffling Active Set

After 21 witnesses have been selected, they are shuffled using the block time as a seed to a random number generator.

## Potential Future Improvements

This algorithm makes the assumption that all witnesses with votes are "active" and ready to produce blocks. A witness should have to prove they are online within the 24 hours before they get scheduled. This would maximize network reliability.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
👎  ,
properties (23)
authordantheman
permlinksteem-witness-scheduling-algorithm
categorysteem
json_metadata{}
created2016-04-23 07:58:24
last_update2016-04-23 07:58:24
depth0
children11
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value31.686 HBD
curator_payout_value31.685 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,387
author_reputation240,292,002,602,347
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id659
net_rshares-3,767,045,928,042
author_curate_reward""
vote details (54)
@abit ·
With this block_num based scheduling algorithm, if a witness missed its block in a round, the first one in the shuffled list will get chance to produce one more block?
properties (22)
authorabit
permlinkre-dantheman-steem-witness-scheduling-algorithm-20160424t214912249z
categorysteem
json_metadata{}
created2016-04-24 21:49:12
last_update2016-04-24 21:49:12
depth1
children2
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length167
author_reputation141,171,499,037,785
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id747
net_rshares0
@dantheman ·
Yes
properties (22)
authordantheman
permlinkre-abit-re-dantheman-steem-witness-scheduling-algorithm-20160424t214912249z-20160520t173018009z
categorysteem
json_metadata{}
created2016-05-20 17:30:18
last_update2016-05-20 17:30:18
depth2
children1
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3
author_reputation240,292,002,602,347
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id9,910
net_rshares0
@bunny ·
missed block should assign to running witness (20-21)in the queue  in order to attract more miners
👍  
properties (23)
authorbunny
permlinkre-dantheman-re-abit-re-dantheman-steem-witness-scheduling-algorithm-20160601t193719651z
categorysteem
json_metadata{}
created2016-06-01 19:37:15
last_update2016-06-01 19:37:15
depth3
children0
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length98
author_reputation2,975,000,206,258
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id20,893
net_rshares334,384,303
author_curate_reward""
vote details (1)
@hannixx42 ·
This never made sense to me.
properties (22)
authorhannixx42
permlinkre-dantheman-steem-witness-scheduling-algorithm-20160615t043148465z
categorysteem
json_metadata{"tags":["steem"]}
created2016-06-15 04:31:48
last_update2016-06-15 04:31:48
depth1
children0
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation7,032,565,034,352
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,683
net_rshares0
@smooth ·
$4.68
I downvoted the post not because I disagree with the post or think it is not a quality post but because I do not think that the interests of Steem are served by every platform or devteam update or request for community feedback pulling thousands of dollars from the reward pools that go to ordinary users. The reward consensus algorithm also disproportionately rewards these posts since they are the only thing that 100% of Steem users have in common (aside from being human, etc.).
👍  , , ,
properties (23)
authorsmooth
permlinkre-dantheman-steem-witness-scheduling-algorithm-20160617t031856000z
categorysteem
json_metadata{"tags":["steem"]}
created2016-06-17 03:18:57
last_update2016-06-17 03:18:57
depth1
children6
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value2.338 HBD
curator_payout_value2.339 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length482
author_reputation260,342,945,372,716
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,879
net_rshares5,918,296,612,286
author_curate_reward""
vote details (4)
@eeks ·
$0.74
This is a reply to an old post but this is an important and prescient point.  For Steemit's long term health, these types of posts shouldn't get huge votes.  They uniformly go up to similar people for similar content.  It's useful and important but if the rewards get siloed on these posts, it's bad for the ecosystem.  Thanks.
👍  ,
properties (23)
authoreeks
permlinkre-smooth-re-dantheman-steem-witness-scheduling-algorithm-20160720t194652074z
categorysteem
json_metadata{"tags":["steem"]}
created2016-07-20 19:47:09
last_update2016-07-20 19:47:09
depth2
children0
last_payout2016-08-21 18:43:18
cashout_time1969-12-31 23:59:59
total_payout_value0.557 HBD
curator_payout_value0.182 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length327
author_reputation21,536,775,583,000
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id227,679
net_rshares440,933,129,336
author_curate_reward""
vote details (2)
@sorin.cristescu ·
$0.43
I think you are wrong in this reasoning. Which wouldn't be a problem if in this particular case you were not wrong (according to me) in a way that is detrimental to your stated objectives ! Which is a bit of a paradox. You are not simply wrong, you are 180° wrong. You take an action that you think advances toward an objective. That action could "perfect", or "quite good" or "not that good" or "not good" ...

But here your action is "100% terrible" - it's the worst thing one could have done given your objectives (serving the interests of Steem)

Curious if you notice this comment and if you could be bothered to listen to the "why I believe that"
👍  
properties (23)
authorsorin.cristescu
permlinkre-smooth-re-dantheman-steem-witness-scheduling-algorithm-20180503t213600271z
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2018-05-03 21:36:03
last_update2018-05-03 21:36:03
depth2
children4
last_payout2018-05-10 21:36:03
cashout_time1969-12-31 23:59:59
total_payout_value0.322 HBD
curator_payout_value0.104 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length652
author_reputation256,499,027,348,823
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id53,714,596
net_rshares77,605,270,722
author_curate_reward""
vote details (1)
@smooth ·
$0.04
I notice your comment but I'm not particularly interested in rehashing an issue from two years ago, particularly given significant differences in how the platform operates now compared to then.
👍  , ,
properties (23)
authorsmooth
permlinkre-sorincristescu-re-smooth-re-dantheman-steem-witness-scheduling-algorithm-20180504t093026300z
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2018-05-04 09:30:27
last_update2018-05-04 09:30:27
depth3
children3
last_payout2018-05-11 09:30:27
cashout_time1969-12-31 23:59:59
total_payout_value0.034 HBD
curator_payout_value0.003 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length193
author_reputation260,342,945,372,716
root_title"Steem Witness Scheduling Algorithm"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id53,804,357
net_rshares7,041,730,779
author_curate_reward""
vote details (3)