{"action":"created","comment":{"url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/comments/91664935","pull_request_review_id":12170620,"id":91664935,"diff_hunk":"@@ -1070,6 +1172,21 @@ object Machine extends MachineAPI {\n     val Running = Value(\"Running\")\n   }\n \n+  /** Possible sync-related states of the computer */\n+  private object SyncState extends Enumeration {\n+    /** The computer is in the Insecure state. It is asynchronous and, unless \"*\" is whitelisted, cannot leave this state without a reboot. */\n+    val Insecure = Value(\"Insecure\")\n+\n+    /** The computer is in the Insecure state, and is synchronous. This state is only permitted if \"*\" is whitelisted, and will decay to Insecure if \"*\" is removed from the whitelist. */\n+    val InsecureSync = Value(\"InsecureSync\")\n+\n+    /** The computer is in the Secure state, and is currently asynchronous. */\n+    val SecureAsync = Value(\"SecureAsync\")\n+\n+    /** The computer is in the Secure state, and is currently synchronous. */\n+    val SecureSync = Value(\"SecureSync\")\n+  }\n+\n   /** Signals are messages sent to the Lua state from Java asynchronously. */","path":"src/main/scala/li/cil/oc/server/machine/Machine.scala","position":209,"original_position":209,"commit_id":"bc5d05f4adc944a9190cc135a5ef8e4f0da79d37","original_commit_id":"bc5d05f4adc944a9190cc135a5ef8e4f0da79d37","user":{"login":"payonel","id":6590223,"avatar_url":"https://avatars.githubusercontent.com/u/6590223?v=3","gravatar_id":"","url":"https://api.github.com/users/payonel","html_url":"https://github.com/payonel","followers_url":"https://api.github.com/users/payonel/followers","following_url":"https://api.github.com/users/payonel/following{/other_user}","gists_url":"https://api.github.com/users/payonel/gists{/gist_id}","starred_url":"https://api.github.com/users/payonel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/payonel/subscriptions","organizations_url":"https://api.github.com/users/payonel/orgs","repos_url":"https://api.github.com/users/payonel/repos","events_url":"https://api.github.com/users/payonel/events{/privacy}","received_events_url":"https://api.github.com/users/payonel/received_events","type":"User","site_admin":false},"body":"I have some opinions about the naming of values here and the joining of two orthagonal ideas. I would prefer two separate enums, Insecure/Secure and Async/Sync\r\nAlso, I would prefer Untrusted/Trusted in place of Insecure/Secure\r\nI would like you to genuinely consider this separation of enums as it would simplfy the code. Give some consideration for the name change as I feel it makes it more clear. ","created_at":"2016-12-09T06:28:26Z","updated_at":"2016-12-09T06:30:38Z","html_url":"https://github.com/MightyPirates/OpenComputers/pull/2168#discussion_r91664935","pull_request_url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168","_links":{"self":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/comments/91664935"},"html":{"href":"https://github.com/MightyPirates/OpenComputers/pull/2168#discussion_r91664935"},"pull_request":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168"}}},"pull_request":{"url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168","id":97246359,"html_url":"https://github.com/MightyPirates/OpenComputers/pull/2168","diff_url":"https://github.com/MightyPirates/OpenComputers/pull/2168.diff","patch_url":"https://github.com/MightyPirates/OpenComputers/pull/2168.patch","issue_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/2168","number":2168,"state":"open","locked":false,"title":"Admin-controllable synchronous execution support","user":{"login":"SolraBizna","id":427857,"avatar_url":"https://avatars.githubusercontent.com/u/427857?v=3","gravatar_id":"","url":"https://api.github.com/users/SolraBizna","html_url":"https://github.com/SolraBizna","followers_url":"https://api.github.com/users/SolraBizna/followers","following_url":"https://api.github.com/users/SolraBizna/following{/other_user}","gists_url":"https://api.github.com/users/SolraBizna/gists{/gist_id}","starred_url":"https://api.github.com/users/SolraBizna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SolraBizna/subscriptions","organizations_url":"https://api.github.com/users/SolraBizna/orgs","repos_url":"https://api.github.com/users/SolraBizna/repos","events_url":"https://api.github.com/users/SolraBizna/events{/privacy}","received_events_url":"https://api.github.com/users/SolraBizna/received_events","type":"User","site_admin":false},"body":"OpenComputers computers execute in worker threads separate from the world thread. 99.9% of the time, this is a _very_ good thing. Sometimes, however, precise tick-perfect timing is needed. Nuclear reactor controllers, note block playback engines, and Endergenic Generators are all examples of things where tick jitter can have negative consequences. (Obviously, some of these have higher stakes than others.)\r\n\r\nThis PR adds the ability for computers to request synchronous execution, and be executed on the world thread. Since doing this across the board would be suicidal, it also adds features that allow admins to control where it can be used.\r\n\r\nThese changes were inspired by @gamax92 's experiment earlier today, and guided by feedback in \\#oc. @gamax92 was _incredibly_ helpful in tracking down almost every change that needed to be made. Skye requested the `microcontrollerOnly` option.\r\n\r\nDefaults\r\n========\r\n\r\nUnless specifically configured otherwise, no computer is ever Secure, and a Secure boot is required to be synchronous. With an unchanged configuration, the only change from this PR is the ability for computers to voluntarily shorten their own execution timeout.\r\n\r\nSecure Boot\r\n===========\r\n\r\nThere is a new option in the configuration file, `computer.sync.whitelist`. When a computer first boots up, if its architecture name or EEPROM checksum is in that whitelist, it boots into a Secure state. Otherwise, it boots into an Insecure state. This allows admins to strictly control what code is given the dangerous powers this PR adds. (If the config setting `computer.sync.microcontrollerOnly` is true, only Microcontrollers can be Secure.)\r\n\r\nSecure computers are allowed to request synchronous operation. If the config setting `computer.sync.allowOverrideTimeout` is true, Secure computers can also increase their execution timeout. (Both Secure and Insecure computers can _decrease_ it, regardless of this config option.)\r\n\r\nA Secure computer may enter the Insecure state at will with `component.computer.giveUpSyncPrivileges()`. Once it is Insecure, the only way for it to become Secure again is to reboot with a whitelisted architecture or EEPROM. This would allow \"secure bootloaders\" to pass Secure status only to trusted code.\r\n\r\nWhitelisting a specific EEPROM is useful if the admin has vetted it as being \"safe\"; either a bootloader that only boots admin-signed code, or a self-contained \"safe\" program on its own. Whitelisting a specific architecture is useful if the architecture in question has its own lag-friendly execution caps. (With OC-ARM, for instance, four computers configured to run at 100x the normal clock rate, running busy looping test programs, only added ~8 milliseconds to each tick.) Either way, the computer doesn't _actually_ become synchronous until synchronous operation is requested.\r\n\r\nSynchronous Operation\r\n======================\r\n\r\nComputers may request synchronous operation with `component.computer.setSyncMode(true)`. Secure computers may always request synchronous operation. Insecure computers may also do so if the (dangerous!) config setting `computer.sync.insecure` is true.\r\n\r\nA synchronous computer is executed on the world thread rather than in a worker thread. This means that it can respond to events in the world with tick-perfect timing. This _also_ means it can horribly lag the world if its execution takes too long, which is why the Secure Boot feature is there.\r\n\r\nComputers that wish to do so can return to asynchronous operation with `component.computer.setSyncMode(false)`. If a computer is in synchronous mode and `computer.sync.insecure` is false and `component.computer.giveUpSyncPrivileges()` is called, that will also cause it to become asynchronous.\r\n\r\nCustom Timeouts\r\n===============\r\n\r\nTo help mitigate potential timeout-related problems, this PR also adds a `computer.setCustomTimeout` function to `machine.lua`. Normally, only _shorter_ timeouts than the configured default are honored; this allows synchronous computers to voluntarily limit their world-lagging potential. If the config option `computer.sync.allowOverrideTimeout` is set, Secure computers can also _lengthen_ the timeout. They should only do this when the alternative is oblivion; e.g. nuclear reactor control computers.","created_at":"2016-12-09T03:39:53Z","updated_at":"2016-12-09T06:30:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51113b44f035d87bee7980d25f6f7ab0cfbe06db","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168/commits","review_comments_url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168/comments","review_comment_url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/2168/comments","statuses_url":"https://api.github.com/repos/MightyPirates/OpenComputers/statuses/bc5d05f4adc944a9190cc135a5ef8e4f0da79d37","head":{"label":"SolraBizna:sync","ref":"sync","sha":"bc5d05f4adc944a9190cc135a5ef8e4f0da79d37","user":{"login":"SolraBizna","id":427857,"avatar_url":"https://avatars.githubusercontent.com/u/427857?v=3","gravatar_id":"","url":"https://api.github.com/users/SolraBizna","html_url":"https://github.com/SolraBizna","followers_url":"https://api.github.com/users/SolraBizna/followers","following_url":"https://api.github.com/users/SolraBizna/following{/other_user}","gists_url":"https://api.github.com/users/SolraBizna/gists{/gist_id}","starred_url":"https://api.github.com/users/SolraBizna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SolraBizna/subscriptions","organizations_url":"https://api.github.com/users/SolraBizna/orgs","repos_url":"https://api.github.com/users/SolraBizna/repos","events_url":"https://api.github.com/users/SolraBizna/events{/privacy}","received_events_url":"https://api.github.com/users/SolraBizna/received_events","type":"User","site_admin":false},"repo":{"id":75965633,"name":"OpenComputers","full_name":"SolraBizna/OpenComputers","owner":{"login":"SolraBizna","id":427857,"avatar_url":"https://avatars.githubusercontent.com/u/427857?v=3","gravatar_id":"","url":"https://api.github.com/users/SolraBizna","html_url":"https://github.com/SolraBizna","followers_url":"https://api.github.com/users/SolraBizna/followers","following_url":"https://api.github.com/users/SolraBizna/following{/other_user}","gists_url":"https://api.github.com/users/SolraBizna/gists{/gist_id}","starred_url":"https://api.github.com/users/SolraBizna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SolraBizna/subscriptions","organizations_url":"https://api.github.com/users/SolraBizna/orgs","repos_url":"https://api.github.com/users/SolraBizna/repos","events_url":"https://api.github.com/users/SolraBizna/events{/privacy}","received_events_url":"https://api.github.com/users/SolraBizna/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SolraBizna/OpenComputers","description":"Fork of the OpenComputers mod for Minecraft. Working on synchronous computing.","fork":true,"url":"https://api.github.com/repos/SolraBizna/OpenComputers","forks_url":"https://api.github.com/repos/SolraBizna/OpenComputers/forks","keys_url":"https://api.github.com/repos/SolraBizna/OpenComputers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SolraBizna/OpenComputers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SolraBizna/OpenComputers/teams","hooks_url":"https://api.github.com/repos/SolraBizna/OpenComputers/hooks","issue_events_url":"https://api.github.com/repos/SolraBizna/OpenComputers/issues/events{/number}","events_url":"https://api.github.com/repos/SolraBizna/OpenComputers/events","assignees_url":"https://api.github.com/repos/SolraBizna/OpenComputers/assignees{/user}","branches_url":"https://api.github.com/repos/SolraBizna/OpenComputers/branches{/branch}","tags_url":"https://api.github.com/repos/SolraBizna/OpenComputers/tags","blobs_url":"https://api.github.com/repos/SolraBizna/OpenComputers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SolraBizna/OpenComputers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SolraBizna/OpenComputers/git/refs{/sha}","trees_url":"https://api.github.com/repos/SolraBizna/OpenComputers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SolraBizna/OpenComputers/statuses/{sha}","languages_url":"https://api.github.com/repos/SolraBizna/OpenComputers/languages","stargazers_url":"https://api.github.com/repos/SolraBizna/OpenComputers/stargazers","contributors_url":"https://api.github.com/repos/SolraBizna/OpenComputers/contributors","subscribers_url":"https://api.github.com/repos/SolraBizna/OpenComputers/subscribers","subscription_url":"https://api.github.com/repos/SolraBizna/OpenComputers/subscription","commits_url":"https://api.github.com/repos/SolraBizna/OpenComputers/commits{/sha}","git_commits_url":"https://api.github.com/repos/SolraBizna/OpenComputers/git/commits{/sha}","comments_url":"https://api.github.com/repos/SolraBizna/OpenComputers/comments{/number}","issue_comment_url":"https://api.github.com/repos/SolraBizna/OpenComputers/issues/comments{/number}","contents_url":"https://api.github.com/repos/SolraBizna/OpenComputers/contents/{+path}","compare_url":"https://api.github.com/repos/SolraBizna/OpenComputers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SolraBizna/OpenComputers/merges","archive_url":"https://api.github.com/repos/SolraBizna/OpenComputers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SolraBizna/OpenComputers/downloads","issues_url":"https://api.github.com/repos/SolraBizna/OpenComputers/issues{/number}","pulls_url":"https://api.github.com/repos/SolraBizna/OpenComputers/pulls{/number}","milestones_url":"https://api.github.com/repos/SolraBizna/OpenComputers/milestones{/number}","notifications_url":"https://api.github.com/repos/SolraBizna/OpenComputers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SolraBizna/OpenComputers/labels{/name}","releases_url":"https://api.github.com/repos/SolraBizna/OpenComputers/releases{/id}","deployments_url":"https://api.github.com/repos/SolraBizna/OpenComputers/deployments","created_at":"2016-12-08T18:46:56Z","updated_at":"2016-12-08T18:48:19Z","pushed_at":"2016-12-09T02:59:55Z","git_url":"git://github.com/SolraBizna/OpenComputers.git","ssh_url":"git@github.com:SolraBizna/OpenComputers.git","clone_url":"https://github.com/SolraBizna/OpenComputers.git","svn_url":"https://github.com/SolraBizna/OpenComputers","homepage":"http://oc.cil.li","size":51429,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master-MC1.7.10"}},"base":{"label":"MightyPirates:master-MC1.7.10","ref":"master-MC1.7.10","sha":"21be185fe9bd59dc50bfe2b167eb981a93898842","user":{"login":"MightyPirates","id":6106698,"avatar_url":"https://avatars.githubusercontent.com/u/6106698?v=3","gravatar_id":"","url":"https://api.github.com/users/MightyPirates","html_url":"https://github.com/MightyPirates","followers_url":"https://api.github.com/users/MightyPirates/followers","following_url":"https://api.github.com/users/MightyPirates/following{/other_user}","gists_url":"https://api.github.com/users/MightyPirates/gists{/gist_id}","starred_url":"https://api.github.com/users/MightyPirates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MightyPirates/subscriptions","organizations_url":"https://api.github.com/users/MightyPirates/orgs","repos_url":"https://api.github.com/users/MightyPirates/repos","events_url":"https://api.github.com/users/MightyPirates/events{/privacy}","received_events_url":"https://api.github.com/users/MightyPirates/received_events","type":"Organization","site_admin":false},"repo":{"id":14930360,"name":"OpenComputers","full_name":"MightyPirates/OpenComputers","owner":{"login":"MightyPirates","id":6106698,"avatar_url":"https://avatars.githubusercontent.com/u/6106698?v=3","gravatar_id":"","url":"https://api.github.com/users/MightyPirates","html_url":"https://github.com/MightyPirates","followers_url":"https://api.github.com/users/MightyPirates/followers","following_url":"https://api.github.com/users/MightyPirates/following{/other_user}","gists_url":"https://api.github.com/users/MightyPirates/gists{/gist_id}","starred_url":"https://api.github.com/users/MightyPirates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MightyPirates/subscriptions","organizations_url":"https://api.github.com/users/MightyPirates/orgs","repos_url":"https://api.github.com/users/MightyPirates/repos","events_url":"https://api.github.com/users/MightyPirates/events{/privacy}","received_events_url":"https://api.github.com/users/MightyPirates/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MightyPirates/OpenComputers","description":"Home of the OpenComputers mod for Minecraft.","fork":false,"url":"https://api.github.com/repos/MightyPirates/OpenComputers","forks_url":"https://api.github.com/repos/MightyPirates/OpenComputers/forks","keys_url":"https://api.github.com/repos/MightyPirates/OpenComputers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MightyPirates/OpenComputers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MightyPirates/OpenComputers/teams","hooks_url":"https://api.github.com/repos/MightyPirates/OpenComputers/hooks","issue_events_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/events{/number}","events_url":"https://api.github.com/repos/MightyPirates/OpenComputers/events","assignees_url":"https://api.github.com/repos/MightyPirates/OpenComputers/assignees{/user}","branches_url":"https://api.github.com/repos/MightyPirates/OpenComputers/branches{/branch}","tags_url":"https://api.github.com/repos/MightyPirates/OpenComputers/tags","blobs_url":"https://api.github.com/repos/MightyPirates/OpenComputers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MightyPirates/OpenComputers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MightyPirates/OpenComputers/git/refs{/sha}","trees_url":"https://api.github.com/repos/MightyPirates/OpenComputers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MightyPirates/OpenComputers/statuses/{sha}","languages_url":"https://api.github.com/repos/MightyPirates/OpenComputers/languages","stargazers_url":"https://api.github.com/repos/MightyPirates/OpenComputers/stargazers","contributors_url":"https://api.github.com/repos/MightyPirates/OpenComputers/contributors","subscribers_url":"https://api.github.com/repos/MightyPirates/OpenComputers/subscribers","subscription_url":"https://api.github.com/repos/MightyPirates/OpenComputers/subscription","commits_url":"https://api.github.com/repos/MightyPirates/OpenComputers/commits{/sha}","git_commits_url":"https://api.github.com/repos/MightyPirates/OpenComputers/git/commits{/sha}","comments_url":"https://api.github.com/repos/MightyPirates/OpenComputers/comments{/number}","issue_comment_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/comments{/number}","contents_url":"https://api.github.com/repos/MightyPirates/OpenComputers/contents/{+path}","compare_url":"https://api.github.com/repos/MightyPirates/OpenComputers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MightyPirates/OpenComputers/merges","archive_url":"https://api.github.com/repos/MightyPirates/OpenComputers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MightyPirates/OpenComputers/downloads","issues_url":"https://api.github.com/repos/MightyPirates/OpenComputers/issues{/number}","pulls_url":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls{/number}","milestones_url":"https://api.github.com/repos/MightyPirates/OpenComputers/milestones{/number}","notifications_url":"https://api.github.com/repos/MightyPirates/OpenComputers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MightyPirates/OpenComputers/labels{/name}","releases_url":"https://api.github.com/repos/MightyPirates/OpenComputers/releases{/id}","deployments_url":"https://api.github.com/repos/MightyPirates/OpenComputers/deployments","created_at":"2013-12-04T17:11:24Z","updated_at":"2016-12-09T01:47:16Z","pushed_at":"2016-12-09T03:39:54Z","git_url":"git://github.com/MightyPirates/OpenComputers.git","ssh_url":"git@github.com:MightyPirates/OpenComputers.git","clone_url":"https://github.com/MightyPirates/OpenComputers.git","svn_url":"https://github.com/MightyPirates/OpenComputers","homepage":"oc.cil.li","size":78810,"stargazers_count":464,"watchers_count":464,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":178,"mirror_url":null,"open_issues_count":242,"forks":178,"open_issues":242,"watchers":464,"default_branch":"master-MC1.7.10"}},"_links":{"self":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168"},"html":{"href":"https://github.com/MightyPirates/OpenComputers/pull/2168"},"issue":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/2168"},"comments":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/issues/2168/comments"},"review_comments":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168/comments"},"review_comment":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/pulls/2168/commits"},"statuses":{"href":"https://api.github.com/repos/MightyPirates/OpenComputers/statuses/bc5d05f4adc944a9190cc135a5ef8e4f0da79d37"}}}}
{"actor":{"display_login":"payonel"}}