{"action":"created","comment":{"url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/comments/75355131","id":75355131,"diff_hunk":"@@ -417,6 +471,13 @@ module.exports = class Interface {\n     const memory = new Uint8Array(this.module.exports.memory, offset, length)\n     memory.set(value)\n   }\n+\n+  takeGas (amount) {\n+    if (this.environment.gasLimit < amount) {\n+      throw new Error('Ran out of gas')\n+    }\n+    this.environment.gasLimit -= amount\n+  }","path":"interface.js","position":283,"original_position":283,"commit_id":"2d7d85a331dcdce8d730b2a33c26cbece16f07fb","original_commit_id":"2d7d85a331dcdce8d730b2a33c26cbece16f07fb","user":{"login":"axic","id":20340,"avatar_url":"https://avatars.githubusercontent.com/u/20340?v=3","gravatar_id":"","url":"https://api.github.com/users/axic","html_url":"https://github.com/axic","followers_url":"https://api.github.com/users/axic/followers","following_url":"https://api.github.com/users/axic/following{/other_user}","gists_url":"https://api.github.com/users/axic/gists{/gist_id}","starred_url":"https://api.github.com/users/axic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axic/subscriptions","organizations_url":"https://api.github.com/users/axic/orgs","repos_url":"https://api.github.com/users/axic/repos","events_url":"https://api.github.com/users/axic/events{/privacy}","received_events_url":"https://api.github.com/users/axic/received_events","type":"User","site_admin":false},"body":"I think `useGas` should have extra logic for safety checks because it can be invoked by a contract. `takeGas` on the other hand can only be invoked from *trusted* callers.\r\n\r\nEssentially this is removing the safety check overhead for the majority of the cases.","created_at":"2016-08-18T17:49:00Z","updated_at":"2016-08-18T17:49:00Z","html_url":"https://github.com/ewasm/ewasm-kernel/pull/30#discussion_r75355131","pull_request_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/comments/75355131"},"html":{"href":"https://github.com/ewasm/ewasm-kernel/pull/30#discussion_r75355131"},"pull_request":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30","id":81734152,"html_url":"https://github.com/ewasm/ewasm-kernel/pull/30","diff_url":"https://github.com/ewasm/ewasm-kernel/pull/30.diff","patch_url":"https://github.com/ewasm/ewasm-kernel/pull/30.patch","issue_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/30","number":30,"state":"open","locked":false,"title":"Calculate gas for every method","user":{"login":"axic","id":20340,"avatar_url":"https://avatars.githubusercontent.com/u/20340?v=3","gravatar_id":"","url":"https://api.github.com/users/axic","html_url":"https://github.com/axic","followers_url":"https://api.github.com/users/axic/followers","following_url":"https://api.github.com/users/axic/following{/other_user}","gists_url":"https://api.github.com/users/axic/gists{/gist_id}","starred_url":"https://api.github.com/users/axic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axic/subscriptions","organizations_url":"https://api.github.com/users/axic/orgs","repos_url":"https://api.github.com/users/axic/repos","events_url":"https://api.github.com/users/axic/events{/privacy}","received_events_url":"https://api.github.com/users/axic/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-17T23:23:46Z","updated_at":"2016-08-18T17:49:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd30e71af8bf7237cb60bfd1073acdd6b9271cdb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30/commits","review_comments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30/comments","review_comment_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/30/comments","statuses_url":"https://api.github.com/repos/ewasm/ewasm-kernel/statuses/2d7d85a331dcdce8d730b2a33c26cbece16f07fb","head":{"label":"ewasm:gas","ref":"gas","sha":"2d7d85a331dcdce8d730b2a33c26cbece16f07fb","user":{"login":"ewasm","id":20602854,"avatar_url":"https://avatars.githubusercontent.com/u/20602854?v=3","gravatar_id":"","url":"https://api.github.com/users/ewasm","html_url":"https://github.com/ewasm","followers_url":"https://api.github.com/users/ewasm/followers","following_url":"https://api.github.com/users/ewasm/following{/other_user}","gists_url":"https://api.github.com/users/ewasm/gists{/gist_id}","starred_url":"https://api.github.com/users/ewasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewasm/subscriptions","organizations_url":"https://api.github.com/users/ewasm/orgs","repos_url":"https://api.github.com/users/ewasm/repos","events_url":"https://api.github.com/users/ewasm/events{/privacy}","received_events_url":"https://api.github.com/users/ewasm/received_events","type":"Organization","site_admin":false},"repo":{"id":63121547,"name":"ewasm-kernel","full_name":"ewasm/ewasm-kernel","owner":{"login":"ewasm","id":20602854,"avatar_url":"https://avatars.githubusercontent.com/u/20602854?v=3","gravatar_id":"","url":"https://api.github.com/users/ewasm","html_url":"https://github.com/ewasm","followers_url":"https://api.github.com/users/ewasm/followers","following_url":"https://api.github.com/users/ewasm/following{/other_user}","gists_url":"https://api.github.com/users/ewasm/gists{/gist_id}","starred_url":"https://api.github.com/users/ewasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewasm/subscriptions","organizations_url":"https://api.github.com/users/ewasm/orgs","repos_url":"https://api.github.com/users/ewasm/repos","events_url":"https://api.github.com/users/ewasm/events{/privacy}","received_events_url":"https://api.github.com/users/ewasm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ewasm/ewasm-kernel","description":"This is a JS prototype of the eWASM kernel (WIP)","fork":false,"url":"https://api.github.com/repos/ewasm/ewasm-kernel","forks_url":"https://api.github.com/repos/ewasm/ewasm-kernel/forks","keys_url":"https://api.github.com/repos/ewasm/ewasm-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ewasm/ewasm-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ewasm/ewasm-kernel/teams","hooks_url":"https://api.github.com/repos/ewasm/ewasm-kernel/hooks","issue_events_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ewasm/ewasm-kernel/events","assignees_url":"https://api.github.com/repos/ewasm/ewasm-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ewasm/ewasm-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ewasm/ewasm-kernel/tags","blobs_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ewasm/ewasm-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ewasm/ewasm-kernel/languages","stargazers_url":"https://api.github.com/repos/ewasm/ewasm-kernel/stargazers","contributors_url":"https://api.github.com/repos/ewasm/ewasm-kernel/contributors","subscribers_url":"https://api.github.com/repos/ewasm/ewasm-kernel/subscribers","subscription_url":"https://api.github.com/repos/ewasm/ewasm-kernel/subscription","commits_url":"https://api.github.com/repos/ewasm/ewasm-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ewasm/ewasm-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ewasm/ewasm-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ewasm/ewasm-kernel/merges","archive_url":"https://api.github.com/repos/ewasm/ewasm-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ewasm/ewasm-kernel/downloads","issues_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ewasm/ewasm-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ewasm/ewasm-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ewasm/ewasm-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ewasm/ewasm-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/deployments","created_at":"2016-07-12T02:59:54Z","updated_at":"2016-08-08T07:40:17Z","pushed_at":"2016-08-18T16:41:07Z","git_url":"git://github.com/ewasm/ewasm-kernel.git","ssh_url":"git@github.com:ewasm/ewasm-kernel.git","clone_url":"https://github.com/ewasm/ewasm-kernel.git","svn_url":"https://github.com/ewasm/ewasm-kernel","homepage":"","size":148,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":5,"default_branch":"master"}},"base":{"label":"ewasm:master","ref":"master","sha":"f488805c0df12c74d2cb8ed0c5d0e439495676df","user":{"login":"ewasm","id":20602854,"avatar_url":"https://avatars.githubusercontent.com/u/20602854?v=3","gravatar_id":"","url":"https://api.github.com/users/ewasm","html_url":"https://github.com/ewasm","followers_url":"https://api.github.com/users/ewasm/followers","following_url":"https://api.github.com/users/ewasm/following{/other_user}","gists_url":"https://api.github.com/users/ewasm/gists{/gist_id}","starred_url":"https://api.github.com/users/ewasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewasm/subscriptions","organizations_url":"https://api.github.com/users/ewasm/orgs","repos_url":"https://api.github.com/users/ewasm/repos","events_url":"https://api.github.com/users/ewasm/events{/privacy}","received_events_url":"https://api.github.com/users/ewasm/received_events","type":"Organization","site_admin":false},"repo":{"id":63121547,"name":"ewasm-kernel","full_name":"ewasm/ewasm-kernel","owner":{"login":"ewasm","id":20602854,"avatar_url":"https://avatars.githubusercontent.com/u/20602854?v=3","gravatar_id":"","url":"https://api.github.com/users/ewasm","html_url":"https://github.com/ewasm","followers_url":"https://api.github.com/users/ewasm/followers","following_url":"https://api.github.com/users/ewasm/following{/other_user}","gists_url":"https://api.github.com/users/ewasm/gists{/gist_id}","starred_url":"https://api.github.com/users/ewasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ewasm/subscriptions","organizations_url":"https://api.github.com/users/ewasm/orgs","repos_url":"https://api.github.com/users/ewasm/repos","events_url":"https://api.github.com/users/ewasm/events{/privacy}","received_events_url":"https://api.github.com/users/ewasm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ewasm/ewasm-kernel","description":"This is a JS prototype of the eWASM kernel (WIP)","fork":false,"url":"https://api.github.com/repos/ewasm/ewasm-kernel","forks_url":"https://api.github.com/repos/ewasm/ewasm-kernel/forks","keys_url":"https://api.github.com/repos/ewasm/ewasm-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ewasm/ewasm-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ewasm/ewasm-kernel/teams","hooks_url":"https://api.github.com/repos/ewasm/ewasm-kernel/hooks","issue_events_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ewasm/ewasm-kernel/events","assignees_url":"https://api.github.com/repos/ewasm/ewasm-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ewasm/ewasm-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ewasm/ewasm-kernel/tags","blobs_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ewasm/ewasm-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ewasm/ewasm-kernel/languages","stargazers_url":"https://api.github.com/repos/ewasm/ewasm-kernel/stargazers","contributors_url":"https://api.github.com/repos/ewasm/ewasm-kernel/contributors","subscribers_url":"https://api.github.com/repos/ewasm/ewasm-kernel/subscribers","subscription_url":"https://api.github.com/repos/ewasm/ewasm-kernel/subscription","commits_url":"https://api.github.com/repos/ewasm/ewasm-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ewasm/ewasm-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ewasm/ewasm-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ewasm/ewasm-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ewasm/ewasm-kernel/merges","archive_url":"https://api.github.com/repos/ewasm/ewasm-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ewasm/ewasm-kernel/downloads","issues_url":"https://api.github.com/repos/ewasm/ewasm-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ewasm/ewasm-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ewasm/ewasm-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ewasm/ewasm-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ewasm/ewasm-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/ewasm/ewasm-kernel/deployments","created_at":"2016-07-12T02:59:54Z","updated_at":"2016-08-08T07:40:17Z","pushed_at":"2016-08-18T16:41:07Z","git_url":"git://github.com/ewasm/ewasm-kernel.git","ssh_url":"git@github.com:ewasm/ewasm-kernel.git","clone_url":"https://github.com/ewasm/ewasm-kernel.git","svn_url":"https://github.com/ewasm/ewasm-kernel","homepage":"","size":148,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":11,"forks":0,"open_issues":11,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30"},"html":{"href":"https://github.com/ewasm/ewasm-kernel/pull/30"},"issue":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/30"},"comments":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/ewasm/ewasm-kernel/statuses/2d7d85a331dcdce8d730b2a33c26cbece16f07fb"}}}}
{"actor":{"display_login":"axic"}}