{"action":"created","issue":{"url":"https://api.github.com/repos/rchain/rchain/issues/1439","repository_url":"https://api.github.com/repos/rchain/rchain","labels_url":"https://api.github.com/repos/rchain/rchain/issues/1439/labels{/name}","comments_url":"https://api.github.com/repos/rchain/rchain/issues/1439/comments","events_url":"https://api.github.com/repos/rchain/rchain/issues/1439/events","html_url":"https://github.com/rchain/rchain/pull/1439","id":358302608,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MDk5MzUw","number":1439,"title":"[WIP] Refactor casper code to avoid the usage of Option fields in proto classes","user":{"login":"itegulov","id":7879134,"node_id":"MDQ6VXNlcjc4NzkxMzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7879134?v=4","gravatar_id":"","url":"https://api.github.com/users/itegulov","html_url":"https://github.com/itegulov","followers_url":"https://api.github.com/users/itegulov/followers","following_url":"https://api.github.com/users/itegulov/following{/other_user}","gists_url":"https://api.github.com/users/itegulov/gists{/gist_id}","starred_url":"https://api.github.com/users/itegulov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itegulov/subscriptions","organizations_url":"https://api.github.com/users/itegulov/orgs","repos_url":"https://api.github.com/users/itegulov/repos","events_url":"https://api.github.com/users/itegulov/events{/privacy}","received_events_url":"https://api.github.com/users/itegulov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"guardbotmk3","id":33846152,"node_id":"MDQ6VXNlcjMzODQ2MTUy","avatar_url":"https://avatars1.githubusercontent.com/u/33846152?v=4","gravatar_id":"","url":"https://api.github.com/users/guardbotmk3","html_url":"https://github.com/guardbotmk3","followers_url":"https://api.github.com/users/guardbotmk3/followers","following_url":"https://api.github.com/users/guardbotmk3/following{/other_user}","gists_url":"https://api.github.com/users/guardbotmk3/gists{/gist_id}","starred_url":"https://api.github.com/users/guardbotmk3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardbotmk3/subscriptions","organizations_url":"https://api.github.com/users/guardbotmk3/orgs","repos_url":"https://api.github.com/users/guardbotmk3/repos","events_url":"https://api.github.com/users/guardbotmk3/events{/privacy}","received_events_url":"https://api.github.com/users/guardbotmk3/received_events","type":"User","site_admin":false},"assignees":[{"login":"guardbotmk3","id":33846152,"node_id":"MDQ6VXNlcjMzODQ2MTUy","avatar_url":"https://avatars1.githubusercontent.com/u/33846152?v=4","gravatar_id":"","url":"https://api.github.com/users/guardbotmk3","html_url":"https://github.com/guardbotmk3","followers_url":"https://api.github.com/users/guardbotmk3/followers","following_url":"https://api.github.com/users/guardbotmk3/following{/other_user}","gists_url":"https://api.github.com/users/guardbotmk3/gists{/gist_id}","starred_url":"https://api.github.com/users/guardbotmk3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardbotmk3/subscriptions","organizations_url":"https://api.github.com/users/guardbotmk3/orgs","repos_url":"https://api.github.com/users/guardbotmk3/repos","events_url":"https://api.github.com/users/guardbotmk3/events{/privacy}","received_events_url":"https://api.github.com/users/guardbotmk3/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2018-09-08T15:02:57Z","updated_at":"2018-09-15T10:57:47Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/rchain/rchain/pulls/1439","html_url":"https://github.com/rchain/rchain/pull/1439","diff_url":"https://github.com/rchain/rchain/pull/1439.diff","patch_url":"https://github.com/rchain/rchain/pull/1439.patch"},"body":"## Overview\r\nWorking with proto classes in their current can be quite tedious as you have to unwrap optional fields (e.g. body, header) which aren't actually optional after validating. The proposed solution is to generate safe proto classes based on their implementation provided by scalapb. This is done using a single macro `@GenerateSafe` which generates a safe version of the annotated class. All optional fields become non-optional in the safe version. Also, the underlying type is converted to its safe version. For example, the parameter `body: Option[Body]` in `BlockMessage` will be converted to `body: BodySafe`. This way we can ensure that the entire data structure is safe to work with, not only its immediate parameters. Along with the safe parameters, a handful of helper methods are generated for the safe version of a class: `toByteString`, `toByteArray`, `with<paramname>`.\r\n\r\nHowever, there are a few problems with the current implementation:\r\n\r\n1. ~~As it is impossible to generate non-eponymous top-level classes (e.g. `BodySafe` for `Body`) from an annotated class, I have decided to put a safe version of the class in the companion object. For example, the current implementation  generates `Body.BodySafe` for `Body`, but I might change it to just `Body.Safe` as the current version is redundant and really hard to work with right now.~~ **UPD**: Now generated classes are named like `Body.Safe` instead of `Body.BodySafe`.\r\n2. I know that the experience working with the codebase relying on macros can be less than pleasant. So I have implemented [an extension for IntelliJ IDEA Scala plugin](https://github.com/itegulov/rchain-idea). You shouldn't have any problems with macros if you are using ENSIME.\r\n\r\nAny feedback is welcome as it is a big change affecting most of the files in casper, block-storage and comm.\r\n   \r\n### Which JIRA issue does this PR relate to? If there is not a JIRA issue addressing this work, please create one now and add the link here.\r\nhttps://rchain.atlassian.net/browse/RHOL-572\r\n\r\n### Complete this checklist before you submit the PR\r\n- [ ] This PR contains no more than 200 lines of code, excluding test code.\r\n- [x] This PR meets [RChain development coding standards](https://rchain.atlassian.net/wiki/spaces/DOC/pages/28082177/Coding+Standards).\r\n- [x] You assigned one person to review this PR"},"comment":{"url":"https://api.github.com/repos/rchain/rchain/issues/comments/421552752","html_url":"https://github.com/rchain/rchain/pull/1439#issuecomment-421552752","issue_url":"https://api.github.com/repos/rchain/rchain/issues/1439","id":421552752,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTU1Mjc1Mg==","user":{"login":"goral09","id":5120801,"node_id":"MDQ6VXNlcjUxMjA4MDE=","avatar_url":"https://avatars2.githubusercontent.com/u/5120801?v=4","gravatar_id":"","url":"https://api.github.com/users/goral09","html_url":"https://github.com/goral09","followers_url":"https://api.github.com/users/goral09/followers","following_url":"https://api.github.com/users/goral09/following{/other_user}","gists_url":"https://api.github.com/users/goral09/gists{/gist_id}","starred_url":"https://api.github.com/users/goral09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goral09/subscriptions","organizations_url":"https://api.github.com/users/goral09/orgs","repos_url":"https://api.github.com/users/goral09/repos","events_url":"https://api.github.com/users/goral09/events{/privacy}","received_events_url":"https://api.github.com/users/goral09/received_events","type":"User","site_admin":false},"created_at":"2018-09-15T10:57:47Z","updated_at":"2018-09-15T10:57:47Z","author_association":"COLLABORATOR","body":"@itegulov how do I use the intellij plugin?"}}
{"actor":{"display_login":"goral09"}}