{"action":"created","comment":{"url":"https://api.github.com/repos/soramitsu/kagome/pulls/comments/311427538","pull_request_review_id":270919405,"id":311427538,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxMTQyNzUzOA==","diff_hunk":"@@ -0,0 +1,64 @@\n+/**\n+ * Copyright Soramitsu Co., Ltd. All Rights Reserved.\n+ * SPDX-License-Identifier: Apache-2.0\n+ */\n+\n+#ifndef KAGOME_BABE_LOTTERY_HPP\n+#define KAGOME_BABE_LOTTERY_HPP\n+\n+#include <boost/optional.hpp>\n+#include \"consensus/babe/common.hpp\"\n+#include \"crypto/crypto_types.hpp\"\n+\n+namespace kagome::consensus {\n+  /**\n+   * Interface for acquiring leadership information for the current Babe epoch.\n+   * It is expected to be used as follows:\n+   *    - first epoch is started, r (randomness) = 0\n+   *    - blocks are being accepted\n+   *    - when a block is finalized, submitVRFValue function is called for each\n+   *      block in the finalized chain up to the last finalized one (in the\n+   *      chronological order). The chain can be retrieved via calling\n+   *      BlockTree::longestPath() firstly and only then BlockTree::finalize(..)\n+   *    - at the end of the epoch, computeRandomness(..) is called, providing a\n+   *      randomness value for the new epoch\n+   *    - that value is then is used in slotsLeadership(..)\n+   *\n+   */\n+  struct BabeLottery {\n+    virtual ~BabeLottery() = default;\n+\n+    /**\n+     * Compute leadership for all slots in the given epoch\n+     * @param epoch structure; \"epoch_index\" MUST be set to the epoch to compute\n+     * randomness for\n+     * @param keypair of this node\n+     * @return vector of outputs; none means the peer was not chosen as a leader\n+     * for that slot, value contains VRF value and proof\n+     *\n+     * @note must be called exactly ONCE per epoch, when it gets changed","path":"core/consensus/babe/babe_lottery.hpp","position":39,"original_position":39,"commit_id":"f99d92f0114427d7d9517f9c07d394bbdfa9c3db","original_commit_id":"f99d92f0114427d7d9517f9c07d394bbdfa9c3db","user":{"login":"Harrm","id":9868343,"node_id":"MDQ6VXNlcjk4NjgzNDM=","avatar_url":"https://avatars2.githubusercontent.com/u/9868343?v=4","gravatar_id":"","url":"https://api.github.com/users/Harrm","html_url":"https://github.com/Harrm","followers_url":"https://api.github.com/users/Harrm/followers","following_url":"https://api.github.com/users/Harrm/following{/other_user}","gists_url":"https://api.github.com/users/Harrm/gists{/gist_id}","starred_url":"https://api.github.com/users/Harrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Harrm/subscriptions","organizations_url":"https://api.github.com/users/Harrm/orgs","repos_url":"https://api.github.com/users/Harrm/repos","events_url":"https://api.github.com/users/Harrm/events{/privacy}","received_events_url":"https://api.github.com/users/Harrm/received_events","type":"User","site_admin":false},"body":"What would happen if it's called more than once and can it be prevented in the code?","created_at":"2019-08-07T08:26:09Z","updated_at":"2019-08-07T08:31:57Z","html_url":"https://github.com/soramitsu/kagome/pull/206#discussion_r311427538","pull_request_url":"https://api.github.com/repos/soramitsu/kagome/pulls/206","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/comments/311427538"},"html":{"href":"https://github.com/soramitsu/kagome/pull/206#discussion_r311427538"},"pull_request":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/206"}}},"pull_request":{"url":"https://api.github.com/repos/soramitsu/kagome/pulls/206","id":304342018,"node_id":"MDExOlB1bGxSZXF1ZXN0MzA0MzQyMDE4","html_url":"https://github.com/soramitsu/kagome/pull/206","diff_url":"https://github.com/soramitsu/kagome/pull/206.diff","patch_url":"https://github.com/soramitsu/kagome/pull/206.patch","issue_url":"https://api.github.com/repos/soramitsu/kagome/issues/206","number":206,"state":"open","locked":false,"title":"Babe Lottery","user":{"login":"Akvinikym","id":16174976,"node_id":"MDQ6VXNlcjE2MTc0OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/16174976?v=4","gravatar_id":"","url":"https://api.github.com/users/Akvinikym","html_url":"https://github.com/Akvinikym","followers_url":"https://api.github.com/users/Akvinikym/followers","following_url":"https://api.github.com/users/Akvinikym/following{/other_user}","gists_url":"https://api.github.com/users/Akvinikym/gists{/gist_id}","starred_url":"https://api.github.com/users/Akvinikym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Akvinikym/subscriptions","organizations_url":"https://api.github.com/users/Akvinikym/orgs","repos_url":"https://api.github.com/users/Akvinikym/repos","events_url":"https://api.github.com/users/Akvinikym/events{/privacy}","received_events_url":"https://api.github.com/users/Akvinikym/received_events","type":"User","site_admin":false},"body":"\r\n### Description of the Change\r\n\r\nBabeLottery is an entity, which helps Babe production to deal with VRF-linked tasks, such as new randomness (seed) computation. One can read about the algorithms used in those processes [here](https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#2-normal-phase).\r\n\r\n### Benefits\r\n\r\nConvenient interface.\r\n","created_at":"2019-08-05T15:00:45Z","updated_at":"2019-08-07T08:31:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90a04fc8fdd4385b34a7c600f6fbaa962772b17d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"kamilsa","id":9370151,"node_id":"MDQ6VXNlcjkzNzAxNTE=","avatar_url":"https://avatars3.githubusercontent.com/u/9370151?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilsa","html_url":"https://github.com/kamilsa","followers_url":"https://api.github.com/users/kamilsa/followers","following_url":"https://api.github.com/users/kamilsa/following{/other_user}","gists_url":"https://api.github.com/users/kamilsa/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilsa/subscriptions","organizations_url":"https://api.github.com/users/kamilsa/orgs","repos_url":"https://api.github.com/users/kamilsa/repos","events_url":"https://api.github.com/users/kamilsa/events{/privacy}","received_events_url":"https://api.github.com/users/kamilsa/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/soramitsu/kagome/pulls/206/commits","review_comments_url":"https://api.github.com/repos/soramitsu/kagome/pulls/206/comments","review_comment_url":"https://api.github.com/repos/soramitsu/kagome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/soramitsu/kagome/issues/206/comments","statuses_url":"https://api.github.com/repos/soramitsu/kagome/statuses/f99d92f0114427d7d9517f9c07d394bbdfa9c3db","head":{"label":"soramitsu:feature/babe-lottery","ref":"feature/babe-lottery","sha":"f99d92f0114427d7d9517f9c07d394bbdfa9c3db","user":{"login":"soramitsu","id":20982409,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTgyNDA5","avatar_url":"https://avatars2.githubusercontent.com/u/20982409?v=4","gravatar_id":"","url":"https://api.github.com/users/soramitsu","html_url":"https://github.com/soramitsu","followers_url":"https://api.github.com/users/soramitsu/followers","following_url":"https://api.github.com/users/soramitsu/following{/other_user}","gists_url":"https://api.github.com/users/soramitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/soramitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soramitsu/subscriptions","organizations_url":"https://api.github.com/users/soramitsu/orgs","repos_url":"https://api.github.com/users/soramitsu/repos","events_url":"https://api.github.com/users/soramitsu/events{/privacy}","received_events_url":"https://api.github.com/users/soramitsu/received_events","type":"Organization","site_admin":false},"repo":{"id":148600712,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg2MDA3MTI=","name":"kagome","full_name":"soramitsu/kagome","private":false,"owner":{"login":"soramitsu","id":20982409,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTgyNDA5","avatar_url":"https://avatars2.githubusercontent.com/u/20982409?v=4","gravatar_id":"","url":"https://api.github.com/users/soramitsu","html_url":"https://github.com/soramitsu","followers_url":"https://api.github.com/users/soramitsu/followers","following_url":"https://api.github.com/users/soramitsu/following{/other_user}","gists_url":"https://api.github.com/users/soramitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/soramitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soramitsu/subscriptions","organizations_url":"https://api.github.com/users/soramitsu/orgs","repos_url":"https://api.github.com/users/soramitsu/repos","events_url":"https://api.github.com/users/soramitsu/events{/privacy}","received_events_url":"https://api.github.com/users/soramitsu/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/soramitsu/kagome","description":"Kagome - C++17 implementation of Polkadot Runtime Engine & libp2p","fork":false,"url":"https://api.github.com/repos/soramitsu/kagome","forks_url":"https://api.github.com/repos/soramitsu/kagome/forks","keys_url":"https://api.github.com/repos/soramitsu/kagome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/soramitsu/kagome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/soramitsu/kagome/teams","hooks_url":"https://api.github.com/repos/soramitsu/kagome/hooks","issue_events_url":"https://api.github.com/repos/soramitsu/kagome/issues/events{/number}","events_url":"https://api.github.com/repos/soramitsu/kagome/events","assignees_url":"https://api.github.com/repos/soramitsu/kagome/assignees{/user}","branches_url":"https://api.github.com/repos/soramitsu/kagome/branches{/branch}","tags_url":"https://api.github.com/repos/soramitsu/kagome/tags","blobs_url":"https://api.github.com/repos/soramitsu/kagome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/soramitsu/kagome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/soramitsu/kagome/git/refs{/sha}","trees_url":"https://api.github.com/repos/soramitsu/kagome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/soramitsu/kagome/statuses/{sha}","languages_url":"https://api.github.com/repos/soramitsu/kagome/languages","stargazers_url":"https://api.github.com/repos/soramitsu/kagome/stargazers","contributors_url":"https://api.github.com/repos/soramitsu/kagome/contributors","subscribers_url":"https://api.github.com/repos/soramitsu/kagome/subscribers","subscription_url":"https://api.github.com/repos/soramitsu/kagome/subscription","commits_url":"https://api.github.com/repos/soramitsu/kagome/commits{/sha}","git_commits_url":"https://api.github.com/repos/soramitsu/kagome/git/commits{/sha}","comments_url":"https://api.github.com/repos/soramitsu/kagome/comments{/number}","issue_comment_url":"https://api.github.com/repos/soramitsu/kagome/issues/comments{/number}","contents_url":"https://api.github.com/repos/soramitsu/kagome/contents/{+path}","compare_url":"https://api.github.com/repos/soramitsu/kagome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/soramitsu/kagome/merges","archive_url":"https://api.github.com/repos/soramitsu/kagome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/soramitsu/kagome/downloads","issues_url":"https://api.github.com/repos/soramitsu/kagome/issues{/number}","pulls_url":"https://api.github.com/repos/soramitsu/kagome/pulls{/number}","milestones_url":"https://api.github.com/repos/soramitsu/kagome/milestones{/number}","notifications_url":"https://api.github.com/repos/soramitsu/kagome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/soramitsu/kagome/labels{/name}","releases_url":"https://api.github.com/repos/soramitsu/kagome/releases{/id}","deployments_url":"https://api.github.com/repos/soramitsu/kagome/deployments","created_at":"2018-09-13T07:40:03Z","updated_at":"2019-08-02T09:20:57Z","pushed_at":"2019-08-05T15:00:46Z","git_url":"git://github.com/soramitsu/kagome.git","ssh_url":"git@github.com:soramitsu/kagome.git","clone_url":"https://github.com/soramitsu/kagome.git","svn_url":"https://github.com/soramitsu/kagome","homepage":"https://kagome.netlify.com","size":1634,"stargazers_count":21,"watchers_count":21,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":2,"watchers":21,"default_branch":"master"}},"base":{"label":"soramitsu:master","ref":"master","sha":"5446942fa9f0d8de6c8f1ac04d7d56769a9cf325","user":{"login":"soramitsu","id":20982409,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTgyNDA5","avatar_url":"https://avatars2.githubusercontent.com/u/20982409?v=4","gravatar_id":"","url":"https://api.github.com/users/soramitsu","html_url":"https://github.com/soramitsu","followers_url":"https://api.github.com/users/soramitsu/followers","following_url":"https://api.github.com/users/soramitsu/following{/other_user}","gists_url":"https://api.github.com/users/soramitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/soramitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soramitsu/subscriptions","organizations_url":"https://api.github.com/users/soramitsu/orgs","repos_url":"https://api.github.com/users/soramitsu/repos","events_url":"https://api.github.com/users/soramitsu/events{/privacy}","received_events_url":"https://api.github.com/users/soramitsu/received_events","type":"Organization","site_admin":false},"repo":{"id":148600712,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg2MDA3MTI=","name":"kagome","full_name":"soramitsu/kagome","private":false,"owner":{"login":"soramitsu","id":20982409,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTgyNDA5","avatar_url":"https://avatars2.githubusercontent.com/u/20982409?v=4","gravatar_id":"","url":"https://api.github.com/users/soramitsu","html_url":"https://github.com/soramitsu","followers_url":"https://api.github.com/users/soramitsu/followers","following_url":"https://api.github.com/users/soramitsu/following{/other_user}","gists_url":"https://api.github.com/users/soramitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/soramitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soramitsu/subscriptions","organizations_url":"https://api.github.com/users/soramitsu/orgs","repos_url":"https://api.github.com/users/soramitsu/repos","events_url":"https://api.github.com/users/soramitsu/events{/privacy}","received_events_url":"https://api.github.com/users/soramitsu/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/soramitsu/kagome","description":"Kagome - C++17 implementation of Polkadot Runtime Engine & libp2p","fork":false,"url":"https://api.github.com/repos/soramitsu/kagome","forks_url":"https://api.github.com/repos/soramitsu/kagome/forks","keys_url":"https://api.github.com/repos/soramitsu/kagome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/soramitsu/kagome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/soramitsu/kagome/teams","hooks_url":"https://api.github.com/repos/soramitsu/kagome/hooks","issue_events_url":"https://api.github.com/repos/soramitsu/kagome/issues/events{/number}","events_url":"https://api.github.com/repos/soramitsu/kagome/events","assignees_url":"https://api.github.com/repos/soramitsu/kagome/assignees{/user}","branches_url":"https://api.github.com/repos/soramitsu/kagome/branches{/branch}","tags_url":"https://api.github.com/repos/soramitsu/kagome/tags","blobs_url":"https://api.github.com/repos/soramitsu/kagome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/soramitsu/kagome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/soramitsu/kagome/git/refs{/sha}","trees_url":"https://api.github.com/repos/soramitsu/kagome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/soramitsu/kagome/statuses/{sha}","languages_url":"https://api.github.com/repos/soramitsu/kagome/languages","stargazers_url":"https://api.github.com/repos/soramitsu/kagome/stargazers","contributors_url":"https://api.github.com/repos/soramitsu/kagome/contributors","subscribers_url":"https://api.github.com/repos/soramitsu/kagome/subscribers","subscription_url":"https://api.github.com/repos/soramitsu/kagome/subscription","commits_url":"https://api.github.com/repos/soramitsu/kagome/commits{/sha}","git_commits_url":"https://api.github.com/repos/soramitsu/kagome/git/commits{/sha}","comments_url":"https://api.github.com/repos/soramitsu/kagome/comments{/number}","issue_comment_url":"https://api.github.com/repos/soramitsu/kagome/issues/comments{/number}","contents_url":"https://api.github.com/repos/soramitsu/kagome/contents/{+path}","compare_url":"https://api.github.com/repos/soramitsu/kagome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/soramitsu/kagome/merges","archive_url":"https://api.github.com/repos/soramitsu/kagome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/soramitsu/kagome/downloads","issues_url":"https://api.github.com/repos/soramitsu/kagome/issues{/number}","pulls_url":"https://api.github.com/repos/soramitsu/kagome/pulls{/number}","milestones_url":"https://api.github.com/repos/soramitsu/kagome/milestones{/number}","notifications_url":"https://api.github.com/repos/soramitsu/kagome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/soramitsu/kagome/labels{/name}","releases_url":"https://api.github.com/repos/soramitsu/kagome/releases{/id}","deployments_url":"https://api.github.com/repos/soramitsu/kagome/deployments","created_at":"2018-09-13T07:40:03Z","updated_at":"2019-08-02T09:20:57Z","pushed_at":"2019-08-05T15:00:46Z","git_url":"git://github.com/soramitsu/kagome.git","ssh_url":"git@github.com:soramitsu/kagome.git","clone_url":"https://github.com/soramitsu/kagome.git","svn_url":"https://github.com/soramitsu/kagome","homepage":"https://kagome.netlify.com","size":1634,"stargazers_count":21,"watchers_count":21,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":2,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/206"},"html":{"href":"https://github.com/soramitsu/kagome/pull/206"},"issue":{"href":"https://api.github.com/repos/soramitsu/kagome/issues/206"},"comments":{"href":"https://api.github.com/repos/soramitsu/kagome/issues/206/comments"},"review_comments":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/206/comments"},"review_comment":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/soramitsu/kagome/pulls/206/commits"},"statuses":{"href":"https://api.github.com/repos/soramitsu/kagome/statuses/f99d92f0114427d7d9517f9c07d394bbdfa9c3db"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Harrm"}}