{"action":"created","issue":{"url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/458","repository_url":"https://api.github.com/repos/prysmaticlabs/prysm","labels_url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/458/labels{/name}","comments_url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/458/comments","events_url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/458/events","html_url":"https://github.com/prysmaticlabs/prysm/issues/458","id":355929680,"node_id":"MDU6SXNzdWUzNTU5Mjk2ODA=","number":458,"title":"Make State Immutable","user":{"login":"rawfalafel","id":202157,"node_id":"MDQ6VXNlcjIwMjE1Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/202157?v=4","gravatar_id":"","url":"https://api.github.com/users/rawfalafel","html_url":"https://github.com/rawfalafel","followers_url":"https://api.github.com/users/rawfalafel/followers","following_url":"https://api.github.com/users/rawfalafel/following{/other_user}","gists_url":"https://api.github.com/users/rawfalafel/gists{/gist_id}","starred_url":"https://api.github.com/users/rawfalafel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rawfalafel/subscriptions","organizations_url":"https://api.github.com/users/rawfalafel/orgs","repos_url":"https://api.github.com/users/rawfalafel/repos","events_url":"https://api.github.com/users/rawfalafel/events{/privacy}","received_events_url":"https://api.github.com/users/rawfalafel/received_events","type":"User","site_admin":false},"labels":[{"id":969536296,"node_id":"MDU6TGFiZWw5Njk1MzYyOTY=","url":"https://api.github.com/repos/prysmaticlabs/prysm/labels/Beacon%20Chain","name":"Beacon Chain","color":"e5f49a","default":false},{"id":802129904,"node_id":"MDU6TGFiZWw4MDIxMjk5MDQ=","url":"https://api.github.com/repos/prysmaticlabs/prysm/labels/Bug","name":"Bug","color":"ee0701","default":false},{"id":802129908,"node_id":"MDU6TGFiZWw4MDIxMjk5MDg=","url":"https://api.github.com/repos/prysmaticlabs/prysm/labels/Good%20First%20Issue","name":"Good First Issue","color":"7057ff","default":false},{"id":1041415954,"node_id":"MDU6TGFiZWwxMDQxNDE1OTU0","url":"https://api.github.com/repos/prysmaticlabs/prysm/labels/Refactor","name":"Refactor","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/prysmaticlabs/prysm/milestones/4","html_url":"https://github.com/prysmaticlabs/prysm/milestone/4","labels_url":"https://api.github.com/repos/prysmaticlabs/prysm/milestones/4/labels","id":3501481,"node_id":"MDk6TWlsZXN0b25lMzUwMTQ4MQ==","number":4,"title":"Backlog","description":"Stuff to do at some later date","creator":{"login":"prestonvanloon","id":7246818,"node_id":"MDQ6VXNlcjcyNDY4MTg=","avatar_url":"https://avatars1.githubusercontent.com/u/7246818?v=4","gravatar_id":"","url":"https://api.github.com/users/prestonvanloon","html_url":"https://github.com/prestonvanloon","followers_url":"https://api.github.com/users/prestonvanloon/followers","following_url":"https://api.github.com/users/prestonvanloon/following{/other_user}","gists_url":"https://api.github.com/users/prestonvanloon/gists{/gist_id}","starred_url":"https://api.github.com/users/prestonvanloon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestonvanloon/subscriptions","organizations_url":"https://api.github.com/users/prestonvanloon/orgs","repos_url":"https://api.github.com/users/prestonvanloon/repos","events_url":"https://api.github.com/users/prestonvanloon/events{/privacy}","received_events_url":"https://api.github.com/users/prestonvanloon/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":24,"state":"open","created_at":"2018-07-17T01:54:37Z","updated_at":"2018-10-04T01:16:45Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-08-31T10:38:39Z","updated_at":"2018-10-05T09:39:23Z","closed_at":null,"author_association":"COLLABORATOR","body":"Currently, `ActiveState` is [mutable](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/types/state.go#L195) in [various](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/types/state.go#L166) [ways](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/types/state.go#L179). The problem with mutability, especially in an inherently immutable object like `ActiveState`, is that it opens up the possibility of leaving the object in an inconsistent state. \r\n\r\nRefactor `ActiveState` so that the object is immutable by returning a new object rather than modifying the existing one. In addition, new objects should be created only one time per block. There's actually a [bug](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/blockchain/core.go#L537-L544) where `recentBlockHashes` are [modified](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/blockchain/service.go#L341) [twice](https://github.com/prysmaticlabs/prysm/blob/f0abbf6f2679d9606e71b0c9d37113a7a2300d3a/beacon-chain/blockchain/core.go#L283) during a new cycle. Bugs like these can be easily detected if the new state is created in one location.\r\n\r\nEdit: Once its immutable, we can make a small improvement to the `Hash` function. Since the hash can never change, we can compute it once during construction and reuse it. This lets us get rid of the need to handle the error condition in `Hash`."},"comment":{"url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/comments/427305242","html_url":"https://github.com/prysmaticlabs/prysm/issues/458#issuecomment-427305242","issue_url":"https://api.github.com/repos/prysmaticlabs/prysm/issues/458","id":427305242,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzMwNTI0Mg==","user":{"login":"nisdas","id":33201827,"node_id":"MDQ6VXNlcjMzMjAxODI3","avatar_url":"https://avatars2.githubusercontent.com/u/33201827?v=4","gravatar_id":"","url":"https://api.github.com/users/nisdas","html_url":"https://github.com/nisdas","followers_url":"https://api.github.com/users/nisdas/followers","following_url":"https://api.github.com/users/nisdas/following{/other_user}","gists_url":"https://api.github.com/users/nisdas/gists{/gist_id}","starred_url":"https://api.github.com/users/nisdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nisdas/subscriptions","organizations_url":"https://api.github.com/users/nisdas/orgs","repos_url":"https://api.github.com/users/nisdas/repos","events_url":"https://api.github.com/users/nisdas/events{/privacy}","received_events_url":"https://api.github.com/users/nisdas/received_events","type":"User","site_admin":false},"created_at":"2018-10-05T09:39:23Z","updated_at":"2018-10-05T09:39:23Z","author_association":"MEMBER","body":"@rawfalafel Is this resolved with @IvanTheGreatDev 's PR ?"}}
{"actor":{"display_login":"nisdas"}}