{"action":"created","comment":{"url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/comments/221178776","pull_request_review_id":159765908,"id":221178776,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTE3ODc3Ng==","diff_hunk":"@@ -38,19 +48,55 @@ Similar to the previous case, deposit transactions to the federation's multisig\n \n ### The cross chain is handled one block later by next leader\n \n-As time passes, a new block appears on chain A, and a new leader is elected (FM<sub>3</sub>). This new leader can now broadcast the transaction and we are back on the normal path (cf 1.).\n+As time passes, a new block appears on chain A, and a new leader is elected (FM<sub>3</sub>). This new leader can now broadcast the transaction and we are back on the normal path (cf 1.).  \n+\n+As described earlier every new leader must first check for previously unprocessed transfer and process those first before attending to the transfers on current block, if a few leaders are offline this can create a backlog of transfers.  \n+If a leader finds a previously unprocessed transfer and they dont have enough signatures to broadcst they must do nothing and wait for the other members to send over signatures.  \n+If not enough members are online to reach the minimum number of signature required by the multisig, then transfers will halt untill enough members come back online and broadcast signatures.\n \n ![The cross chain is handled one block later by next leader](../assets/cross-chain-transfers/leader-offline-2.svg)\n \n ### The leader comes back online\n \n When the leader comes back online, it will retrieve from its stores what was the last known block heights for which it had dealt with transfers, and resync its store from there while synching up its nodes. Partial transactions will then be added to the store and updated (or potentially completed) depending on their status on the chain B.  \n-The node will only be able to participate in cross chain transfers when it is fully synced again, and has access to the latest version of the utxos on each multisigs.\n+The node will only be able to participate in cross chain transfers when it is fully synced again, and has the correct view of the multisig utxos set.  \n+\n+A leader that is now synced and observing unprocessed previous transfers will start creating signatures for those transfers and broadcasting them to the other federation members.\n \n ![The leader comes back online](../assets/cross-chain-transfers/leader-offline-3.svg)\n \n ## 3) Building the chain B transaction deterministically\n \n-The main point of building transactions deterministically is to allow for each member to independently build the exact same transaction. This way the can uniquely identify transactions coming from other members and decide to match them with their own (to collect signatures, change their statuses when finding them on chain, or when recovering from a period offline).\n+There are two main reasons for building transactions deterministically.\n+1. To allow for each member to independently build the exact same transaction, and therefore ensure that the federation members will never need to sign a UTXO more than once. This is for security reasons.\n+2. To simplify the processes of sharing signaturs (a none determininstic approach means a leader needs to create a session for the transfer and coordinate with peers to sign it).  \n+\n+Assuming members are synced and have the same view of the multisig address (the collection of UTXOs) then using a predefined algorithem every member can generate the transfer transaction, sign with their key and broadcast to the other members (possibly its enought to only broadcast to the current leader).  \n+It may be that in order to use a multisig UTXO the algorithem will require it to be burried under enough blocks, to avoid reorgs and ensure that all member have the same view of the UTXO list.\n+\n+**The algorithm to select UTXOs:**\n+- The oldest UTXO first\n+- If a block has more than one UTXO, then first one in the list is first\n+- Outputs are sorted by destination address\n+- Change address (back to multisig), if any, is last.\n+- OP_RETURN of block hash of chain the transfer came from.\n+\n+A member that comes back online after a long perioud will need to sync both chains and also build the databse of transfer transactions, they should be able to do this simply by looking at the chains themselves.  \n+A member that came online will, once it is done syncing both its chains and has the correct views of the multisig UTXO lists, check all the unprocessed transfers, start building and signing corresponding transactions, and broadcast them to its peers. \n \n ![Building transactions](../assets/cross-chain-transfers/building-transaction.svg)\n+\n+**The algorithem to select the leader:**\n+\n+TODO:\n+either reuse the current mechanism : hash block hash with public keys of members and order them alphabetically to get a leader table\n+or have the leader take turn in a pre-established way based on height of block modulo federation size (somewhat similar to POA)\n+\n+## Considerations ## \n+\n+- What is the fee going to be on the transfer trx (to maintain determinism)","path":"Requirements/cross-chain-transfer.md","position":91,"original_position":91,"commit_id":"84cd01d93e05dd0526bc3a7a4954737bc3f2d429","original_commit_id":"84cd01d93e05dd0526bc3a7a4954737bc3f2d429","user":{"login":"zeptin","id":25860,"node_id":"MDQ6VXNlcjI1ODYw","avatar_url":"https://avatars2.githubusercontent.com/u/25860?v=4","gravatar_id":"","url":"https://api.github.com/users/zeptin","html_url":"https://github.com/zeptin","followers_url":"https://api.github.com/users/zeptin/followers","following_url":"https://api.github.com/users/zeptin/following{/other_user}","gists_url":"https://api.github.com/users/zeptin/gists{/gist_id}","starred_url":"https://api.github.com/users/zeptin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeptin/subscriptions","organizations_url":"https://api.github.com/users/zeptin/orgs","repos_url":"https://api.github.com/users/zeptin/repos","events_url":"https://api.github.com/users/zeptin/events{/privacy}","received_events_url":"https://api.github.com/users/zeptin/received_events","type":"User","site_admin":false},"body":"It can be a node policy or consensus rule that sidechain transactions made by the federation members do not require fees.\r\n\r\nFor the transfer back to the main chain, perhaps a simple voting protocol to agree on it based on their wallets' estimators. I'm not sure this can be made fully deterministic, as the transaction might be delayed and the acceptable fee amount could change. This can be problematic if the transaction is already constructed & signed with an inadequate fee, and not yet broadcasted.","created_at":"2018-09-28T08:36:10Z","updated_at":"2018-09-28T08:36:10Z","html_url":"https://github.com/stratisproject/FederatedSidechains/pull/117#discussion_r221178776","pull_request_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/comments/221178776"},"html":{"href":"https://github.com/stratisproject/FederatedSidechains/pull/117#discussion_r221178776"},"pull_request":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117","id":218803869,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4ODAzODY5","html_url":"https://github.com/stratisproject/FederatedSidechains/pull/117","diff_url":"https://github.com/stratisproject/FederatedSidechains/pull/117.diff","patch_url":"https://github.com/stratisproject/FederatedSidechains/pull/117.patch","issue_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/117","number":117,"state":"open","locked":false,"title":"Update cross-chain-transfer.md","user":{"login":"dangershony","id":7487930,"node_id":"MDQ6VXNlcjc0ODc5MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/7487930?v=4","gravatar_id":"","url":"https://api.github.com/users/dangershony","html_url":"https://github.com/dangershony","followers_url":"https://api.github.com/users/dangershony/followers","following_url":"https://api.github.com/users/dangershony/following{/other_user}","gists_url":"https://api.github.com/users/dangershony/gists{/gist_id}","starred_url":"https://api.github.com/users/dangershony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangershony/subscriptions","organizations_url":"https://api.github.com/users/dangershony/orgs","repos_url":"https://api.github.com/users/dangershony/repos","events_url":"https://api.github.com/users/dangershony/events{/privacy}","received_events_url":"https://api.github.com/users/dangershony/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-27T22:14:09Z","updated_at":"2018-09-28T08:36:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3b976b3a6157351b91bc54b490f88517a33fd6b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117/commits","review_comments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117/comments","review_comment_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/117/comments","statuses_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/statuses/84cd01d93e05dd0526bc3a7a4954737bc3f2d429","head":{"label":"stratisproject:dangershony-patch-1","ref":"dangershony-patch-1","sha":"84cd01d93e05dd0526bc3a7a4954737bc3f2d429","user":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"repo":{"id":136144492,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYxNDQ0OTI=","name":"FederatedSidechains","full_name":"stratisproject/FederatedSidechains","private":false,"owner":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stratisproject/FederatedSidechains","description":null,"fork":false,"url":"https://api.github.com/repos/stratisproject/FederatedSidechains","forks_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/forks","keys_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/teams","hooks_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/hooks","issue_events_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/events{/number}","events_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/events","assignees_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/assignees{/user}","branches_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/branches{/branch}","tags_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/tags","blobs_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/refs{/sha}","trees_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/statuses/{sha}","languages_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/languages","stargazers_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/stargazers","contributors_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/contributors","subscribers_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/subscribers","subscription_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/subscription","commits_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/commits{/sha}","git_commits_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/commits{/sha}","comments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/comments{/number}","issue_comment_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/comments{/number}","contents_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/contents/{+path}","compare_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/merges","archive_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/downloads","issues_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues{/number}","pulls_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls{/number}","milestones_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/milestones{/number}","notifications_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/labels{/name}","releases_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/releases{/id}","deployments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/deployments","created_at":"2018-06-05T08:21:50Z","updated_at":"2018-09-27T13:31:59Z","pushed_at":"2018-09-28T08:04:44Z","git_url":"git://github.com/stratisproject/FederatedSidechains.git","ssh_url":"git@github.com:stratisproject/FederatedSidechains.git","clone_url":"https://github.com/stratisproject/FederatedSidechains.git","svn_url":"https://github.com/stratisproject/FederatedSidechains","homepage":null,"size":2894,"stargazers_count":8,"watchers_count":8,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":28,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":9,"open_issues":28,"watchers":8,"default_branch":"master"}},"base":{"label":"stratisproject:master","ref":"master","sha":"066b124181509a62a6d3b2a1db854647f0ccfe9f","user":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"repo":{"id":136144492,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYxNDQ0OTI=","name":"FederatedSidechains","full_name":"stratisproject/FederatedSidechains","private":false,"owner":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stratisproject/FederatedSidechains","description":null,"fork":false,"url":"https://api.github.com/repos/stratisproject/FederatedSidechains","forks_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/forks","keys_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/teams","hooks_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/hooks","issue_events_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/events{/number}","events_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/events","assignees_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/assignees{/user}","branches_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/branches{/branch}","tags_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/tags","blobs_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/refs{/sha}","trees_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/statuses/{sha}","languages_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/languages","stargazers_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/stargazers","contributors_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/contributors","subscribers_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/subscribers","subscription_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/subscription","commits_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/commits{/sha}","git_commits_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/git/commits{/sha}","comments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/comments{/number}","issue_comment_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/comments{/number}","contents_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/contents/{+path}","compare_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/merges","archive_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/downloads","issues_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues{/number}","pulls_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls{/number}","milestones_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/milestones{/number}","notifications_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/labels{/name}","releases_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/releases{/id}","deployments_url":"https://api.github.com/repos/stratisproject/FederatedSidechains/deployments","created_at":"2018-06-05T08:21:50Z","updated_at":"2018-09-27T13:31:59Z","pushed_at":"2018-09-28T08:04:44Z","git_url":"git://github.com/stratisproject/FederatedSidechains.git","ssh_url":"git@github.com:stratisproject/FederatedSidechains.git","clone_url":"https://github.com/stratisproject/FederatedSidechains.git","svn_url":"https://github.com/stratisproject/FederatedSidechains","homepage":null,"size":2894,"stargazers_count":8,"watchers_count":8,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":28,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":9,"open_issues":28,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117"},"html":{"href":"https://github.com/stratisproject/FederatedSidechains/pull/117"},"issue":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/117"},"comments":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/stratisproject/FederatedSidechains/statuses/84cd01d93e05dd0526bc3a7a4954737bc3f2d429"}},"author_association":"NONE"}}
{"actor":{"display_login":"zeptin"}}