{"action":"created","comment":{"url":"https://api.github.com/repos/cryptape/cita-vm/pulls/comments/238209194","pull_request_review_id":180692200,"id":238209194,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODIwOTE5NA==","diff_hunk":"@@ -0,0 +1,116 @@\n+extern crate hex;\n+\n+use ethereum_types::*;\n+use std::u64;\n+\n+#[inline]\n+pub fn to_word_size(size: u64) -> u64 {\n+    if size > u64::MAX - 31 {\n+        return u64::MAX >> 5 + 1;\n+    }\n+    return (size + 31) >> 5;\n+}\n+\n+#[inline]\n+pub fn mem_gas_cost(size: u64, memory_gas: u64) -> u64 {\n+    let size = to_word_size(size);\n+    size * memory_gas + ((size * size) >> 9)\n+}\n+\n+#[inline]\n+pub fn get_sign(value: U256) -> (U256, bool) {\n+    let U256(arr) = value;\n+    let sign = arr[3].leading_zeros() == 0;","path":"evm/src/common.rs","position":23,"original_position":23,"commit_id":"a2389bb0de315d969a054cf8afb31df2584625e4","original_commit_id":"a2389bb0de315d969a054cf8afb31df2584625e4","user":{"login":"u2","id":161756,"node_id":"MDQ6VXNlcjE2MTc1Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/161756?v=4","gravatar_id":"","url":"https://api.github.com/users/u2","html_url":"https://github.com/u2","followers_url":"https://api.github.com/users/u2/followers","following_url":"https://api.github.com/users/u2/following{/other_user}","gists_url":"https://api.github.com/users/u2/gists{/gist_id}","starred_url":"https://api.github.com/users/u2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/u2/subscriptions","organizations_url":"https://api.github.com/users/u2/orgs","repos_url":"https://api.github.com/users/u2/repos","events_url":"https://api.github.com/users/u2/events{/privacy}","received_events_url":"https://api.github.com/users/u2/received_events","type":"User","site_admin":false},"body":"@yangby-cryptape ","created_at":"2018-12-03T10:15:12Z","updated_at":"2018-12-03T10:15:13Z","html_url":"https://github.com/cryptape/cita-vm/pull/9#discussion_r238209194","pull_request_url":"https://api.github.com/repos/cryptape/cita-vm/pulls/9","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/comments/238209194"},"html":{"href":"https://github.com/cryptape/cita-vm/pull/9#discussion_r238209194"},"pull_request":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/9"}},"in_reply_to_id":238169361},"pull_request":{"url":"https://api.github.com/repos/cryptape/cita-vm/pulls/9","id":235243438,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1MjQzNDM4","html_url":"https://github.com/cryptape/cita-vm/pull/9","diff_url":"https://github.com/cryptape/cita-vm/pull/9.diff","patch_url":"https://github.com/cryptape/cita-vm/pull/9.patch","issue_url":"https://api.github.com/repos/cryptape/cita-vm/issues/9","number":9,"state":"open","locked":false,"title":"Interpreter","user":{"login":"mohanson","id":12387889,"node_id":"MDQ6VXNlcjEyMzg3ODg5","avatar_url":"https://avatars3.githubusercontent.com/u/12387889?v=4","gravatar_id":"","url":"https://api.github.com/users/mohanson","html_url":"https://github.com/mohanson","followers_url":"https://api.github.com/users/mohanson/followers","following_url":"https://api.github.com/users/mohanson/following{/other_user}","gists_url":"https://api.github.com/users/mohanson/gists{/gist_id}","starred_url":"https://api.github.com/users/mohanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohanson/subscriptions","organizations_url":"https://api.github.com/users/mohanson/orgs","repos_url":"https://api.github.com/users/mohanson/repos","events_url":"https://api.github.com/users/mohanson/events{/privacy}","received_events_url":"https://api.github.com/users/mohanson/received_events","type":"User","site_admin":false},"body":"代码量较大, 建议 review 从以下几步入手\r\n\r\n1. 执行单元测试与集成测试\r\n\r\n```sh\r\ncd cita-vm && git submodule update --init && cargo test\r\ncd cita-vm/evm && cargo test\r\n```\r\n同时可以阅读 cita-vm/tests/interpreter_test.rs 了解 Interpreter 是如何初始化和执行的.\r\n\r\n2. 阅读 cita-vm/evm/src/interpreter.rs 文件内的 Interpreter.run 函数. run 是 interpreter 的主函数, 分为比较独立的几部分, 代码量虽然很长, 但大部分都是 match/case 分支. 阅读的时候可以折叠相关 match 代码, 这样条理会非常清楚. run 内部包含独立的 6 个 STEP 如下:\r\n\r\n![](http://api.accu.cc:81/coco.png)\r\n","created_at":"2018-12-02T07:36:57Z","updated_at":"2018-12-03T10:15:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6bff76698a8a7d927833f115337cd7ca7f9ccb4b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cryptape/cita-vm/pulls/9/commits","review_comments_url":"https://api.github.com/repos/cryptape/cita-vm/pulls/9/comments","review_comment_url":"https://api.github.com/repos/cryptape/cita-vm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cryptape/cita-vm/issues/9/comments","statuses_url":"https://api.github.com/repos/cryptape/cita-vm/statuses/a2389bb0de315d969a054cf8afb31df2584625e4","head":{"label":"mohanson:interpreter","ref":"interpreter","sha":"a2389bb0de315d969a054cf8afb31df2584625e4","user":{"login":"mohanson","id":12387889,"node_id":"MDQ6VXNlcjEyMzg3ODg5","avatar_url":"https://avatars3.githubusercontent.com/u/12387889?v=4","gravatar_id":"","url":"https://api.github.com/users/mohanson","html_url":"https://github.com/mohanson","followers_url":"https://api.github.com/users/mohanson/followers","following_url":"https://api.github.com/users/mohanson/following{/other_user}","gists_url":"https://api.github.com/users/mohanson/gists{/gist_id}","starred_url":"https://api.github.com/users/mohanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohanson/subscriptions","organizations_url":"https://api.github.com/users/mohanson/orgs","repos_url":"https://api.github.com/users/mohanson/repos","events_url":"https://api.github.com/users/mohanson/events{/privacy}","received_events_url":"https://api.github.com/users/mohanson/received_events","type":"User","site_admin":false},"repo":{"id":157656331,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc2NTYzMzE=","name":"cita-vm","full_name":"mohanson/cita-vm","private":false,"owner":{"login":"mohanson","id":12387889,"node_id":"MDQ6VXNlcjEyMzg3ODg5","avatar_url":"https://avatars3.githubusercontent.com/u/12387889?v=4","gravatar_id":"","url":"https://api.github.com/users/mohanson","html_url":"https://github.com/mohanson","followers_url":"https://api.github.com/users/mohanson/followers","following_url":"https://api.github.com/users/mohanson/following{/other_user}","gists_url":"https://api.github.com/users/mohanson/gists{/gist_id}","starred_url":"https://api.github.com/users/mohanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohanson/subscriptions","organizations_url":"https://api.github.com/users/mohanson/orgs","repos_url":"https://api.github.com/users/mohanson/repos","events_url":"https://api.github.com/users/mohanson/events{/privacy}","received_events_url":"https://api.github.com/users/mohanson/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mohanson/cita-vm","description":null,"fork":true,"url":"https://api.github.com/repos/mohanson/cita-vm","forks_url":"https://api.github.com/repos/mohanson/cita-vm/forks","keys_url":"https://api.github.com/repos/mohanson/cita-vm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mohanson/cita-vm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mohanson/cita-vm/teams","hooks_url":"https://api.github.com/repos/mohanson/cita-vm/hooks","issue_events_url":"https://api.github.com/repos/mohanson/cita-vm/issues/events{/number}","events_url":"https://api.github.com/repos/mohanson/cita-vm/events","assignees_url":"https://api.github.com/repos/mohanson/cita-vm/assignees{/user}","branches_url":"https://api.github.com/repos/mohanson/cita-vm/branches{/branch}","tags_url":"https://api.github.com/repos/mohanson/cita-vm/tags","blobs_url":"https://api.github.com/repos/mohanson/cita-vm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mohanson/cita-vm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mohanson/cita-vm/git/refs{/sha}","trees_url":"https://api.github.com/repos/mohanson/cita-vm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mohanson/cita-vm/statuses/{sha}","languages_url":"https://api.github.com/repos/mohanson/cita-vm/languages","stargazers_url":"https://api.github.com/repos/mohanson/cita-vm/stargazers","contributors_url":"https://api.github.com/repos/mohanson/cita-vm/contributors","subscribers_url":"https://api.github.com/repos/mohanson/cita-vm/subscribers","subscription_url":"https://api.github.com/repos/mohanson/cita-vm/subscription","commits_url":"https://api.github.com/repos/mohanson/cita-vm/commits{/sha}","git_commits_url":"https://api.github.com/repos/mohanson/cita-vm/git/commits{/sha}","comments_url":"https://api.github.com/repos/mohanson/cita-vm/comments{/number}","issue_comment_url":"https://api.github.com/repos/mohanson/cita-vm/issues/comments{/number}","contents_url":"https://api.github.com/repos/mohanson/cita-vm/contents/{+path}","compare_url":"https://api.github.com/repos/mohanson/cita-vm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mohanson/cita-vm/merges","archive_url":"https://api.github.com/repos/mohanson/cita-vm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mohanson/cita-vm/downloads","issues_url":"https://api.github.com/repos/mohanson/cita-vm/issues{/number}","pulls_url":"https://api.github.com/repos/mohanson/cita-vm/pulls{/number}","milestones_url":"https://api.github.com/repos/mohanson/cita-vm/milestones{/number}","notifications_url":"https://api.github.com/repos/mohanson/cita-vm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mohanson/cita-vm/labels{/name}","releases_url":"https://api.github.com/repos/mohanson/cita-vm/releases{/id}","deployments_url":"https://api.github.com/repos/mohanson/cita-vm/deployments","created_at":"2018-11-15T05:22:02Z","updated_at":"2018-11-19T10:26:56Z","pushed_at":"2018-12-03T07:23:52Z","git_url":"git://github.com/mohanson/cita-vm.git","ssh_url":"git@github.com:mohanson/cita-vm.git","clone_url":"https://github.com/mohanson/cita-vm.git","svn_url":"https://github.com/mohanson/cita-vm","homepage":null,"size":65,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cryptape:master","ref":"master","sha":"11b9e7e2364deb0548e1081f52c016857757373b","user":{"login":"cryptape","id":17726310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzI2MzEw","avatar_url":"https://avatars0.githubusercontent.com/u/17726310?v=4","gravatar_id":"","url":"https://api.github.com/users/cryptape","html_url":"https://github.com/cryptape","followers_url":"https://api.github.com/users/cryptape/followers","following_url":"https://api.github.com/users/cryptape/following{/other_user}","gists_url":"https://api.github.com/users/cryptape/gists{/gist_id}","starred_url":"https://api.github.com/users/cryptape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cryptape/subscriptions","organizations_url":"https://api.github.com/users/cryptape/orgs","repos_url":"https://api.github.com/users/cryptape/repos","events_url":"https://api.github.com/users/cryptape/events{/privacy}","received_events_url":"https://api.github.com/users/cryptape/received_events","type":"Organization","site_admin":false},"repo":{"id":156328858,"node_id":"MDEwOlJlcG9zaXRvcnkxNTYzMjg4NTg=","name":"cita-vm","full_name":"cryptape/cita-vm","private":false,"owner":{"login":"cryptape","id":17726310,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzI2MzEw","avatar_url":"https://avatars0.githubusercontent.com/u/17726310?v=4","gravatar_id":"","url":"https://api.github.com/users/cryptape","html_url":"https://github.com/cryptape","followers_url":"https://api.github.com/users/cryptape/followers","following_url":"https://api.github.com/users/cryptape/following{/other_user}","gists_url":"https://api.github.com/users/cryptape/gists{/gist_id}","starred_url":"https://api.github.com/users/cryptape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cryptape/subscriptions","organizations_url":"https://api.github.com/users/cryptape/orgs","repos_url":"https://api.github.com/users/cryptape/repos","events_url":"https://api.github.com/users/cryptape/events{/privacy}","received_events_url":"https://api.github.com/users/cryptape/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cryptape/cita-vm","description":null,"fork":false,"url":"https://api.github.com/repos/cryptape/cita-vm","forks_url":"https://api.github.com/repos/cryptape/cita-vm/forks","keys_url":"https://api.github.com/repos/cryptape/cita-vm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cryptape/cita-vm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cryptape/cita-vm/teams","hooks_url":"https://api.github.com/repos/cryptape/cita-vm/hooks","issue_events_url":"https://api.github.com/repos/cryptape/cita-vm/issues/events{/number}","events_url":"https://api.github.com/repos/cryptape/cita-vm/events","assignees_url":"https://api.github.com/repos/cryptape/cita-vm/assignees{/user}","branches_url":"https://api.github.com/repos/cryptape/cita-vm/branches{/branch}","tags_url":"https://api.github.com/repos/cryptape/cita-vm/tags","blobs_url":"https://api.github.com/repos/cryptape/cita-vm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cryptape/cita-vm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cryptape/cita-vm/git/refs{/sha}","trees_url":"https://api.github.com/repos/cryptape/cita-vm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cryptape/cita-vm/statuses/{sha}","languages_url":"https://api.github.com/repos/cryptape/cita-vm/languages","stargazers_url":"https://api.github.com/repos/cryptape/cita-vm/stargazers","contributors_url":"https://api.github.com/repos/cryptape/cita-vm/contributors","subscribers_url":"https://api.github.com/repos/cryptape/cita-vm/subscribers","subscription_url":"https://api.github.com/repos/cryptape/cita-vm/subscription","commits_url":"https://api.github.com/repos/cryptape/cita-vm/commits{/sha}","git_commits_url":"https://api.github.com/repos/cryptape/cita-vm/git/commits{/sha}","comments_url":"https://api.github.com/repos/cryptape/cita-vm/comments{/number}","issue_comment_url":"https://api.github.com/repos/cryptape/cita-vm/issues/comments{/number}","contents_url":"https://api.github.com/repos/cryptape/cita-vm/contents/{+path}","compare_url":"https://api.github.com/repos/cryptape/cita-vm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cryptape/cita-vm/merges","archive_url":"https://api.github.com/repos/cryptape/cita-vm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cryptape/cita-vm/downloads","issues_url":"https://api.github.com/repos/cryptape/cita-vm/issues{/number}","pulls_url":"https://api.github.com/repos/cryptape/cita-vm/pulls{/number}","milestones_url":"https://api.github.com/repos/cryptape/cita-vm/milestones{/number}","notifications_url":"https://api.github.com/repos/cryptape/cita-vm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cryptape/cita-vm/labels{/name}","releases_url":"https://api.github.com/repos/cryptape/cita-vm/releases{/id}","deployments_url":"https://api.github.com/repos/cryptape/cita-vm/deployments","created_at":"2018-11-06T05:07:24Z","updated_at":"2018-11-21T12:01:24Z","pushed_at":"2018-12-03T07:23:54Z","git_url":"git://github.com/cryptape/cita-vm.git","ssh_url":"git@github.com:cryptape/cita-vm.git","clone_url":"https://github.com/cryptape/cita-vm.git","svn_url":"https://github.com/cryptape/cita-vm","homepage":null,"size":33,"stargazers_count":5,"watchers_count":5,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":1,"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":4,"open_issues":1,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/9"},"html":{"href":"https://github.com/cryptape/cita-vm/pull/9"},"issue":{"href":"https://api.github.com/repos/cryptape/cita-vm/issues/9"},"comments":{"href":"https://api.github.com/repos/cryptape/cita-vm/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cryptape/cita-vm/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/cryptape/cita-vm/statuses/a2389bb0de315d969a054cf8afb31df2584625e4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"u2"}}