{"action":"created","issue":{"url":"https://api.github.com/repos/paritytech/substrate/issues/1264","repository_url":"https://api.github.com/repos/paritytech/substrate","labels_url":"https://api.github.com/repos/paritytech/substrate/issues/1264/labels{/name}","comments_url":"https://api.github.com/repos/paritytech/substrate/issues/1264/comments","events_url":"https://api.github.com/repos/paritytech/substrate/issues/1264/events","html_url":"https://github.com/paritytech/substrate/pull/1264","id":390736101,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4NDM0ODEy","number":1264,"title":"Include default values in storage metadata","user":{"login":"cheme","id":1726091,"node_id":"MDQ6VXNlcjE3MjYwOTE=","avatar_url":"https://avatars3.githubusercontent.com/u/1726091?v=4","gravatar_id":"","url":"https://api.github.com/users/cheme","html_url":"https://github.com/cheme","followers_url":"https://api.github.com/users/cheme/followers","following_url":"https://api.github.com/users/cheme/following{/other_user}","gists_url":"https://api.github.com/users/cheme/gists{/gist_id}","starred_url":"https://api.github.com/users/cheme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheme/subscriptions","organizations_url":"https://api.github.com/users/cheme/orgs","repos_url":"https://api.github.com/users/cheme/repos","events_url":"https://api.github.com/users/cheme/events{/privacy}","received_events_url":"https://api.github.com/users/cheme/received_events","type":"User","site_admin":false},"labels":[{"id":746560611,"node_id":"MDU6TGFiZWw3NDY1NjA2MTE=","url":"https://api.github.com/repos/paritytech/substrate/labels/A5-grumble","name":"A5-grumble","color":"fcdfc3","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-13T15:41:35Z","updated_at":"2018-12-19T12:03:27Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/paritytech/substrate/pulls/1264","html_url":"https://github.com/paritytech/substrate/pull/1264","diff_url":"https://github.com/paritytech/substrate/pull/1264.diff","patch_url":"https://github.com/paritytech/substrate/pull/1264.patch"},"body":"This PR solves #1256 by adding default value expression to the metadata struct.\r\n\r\nThe new field is called `default`, it serializes in between the type and the documentation.\r\n\r\nSimilarly to other metadatas, it is subject to additional spaces.\r\nThose are some sample of display I logged from substrate project:\r\n\r\n```\r\nDefault::default()\r\nSome ( 3 )\r\nNone\r\nSome ( 3 )\r\nSome ( 4 )\r\n3\r\nSome ( \"hello\" . into (  ) )\r\n\"map\" . into (  )\r\n\"pubmap\" . into (  )\r\nT :: Moment :: sa ( 5 )\r\nT :: BlockNumber :: sa ( 1000 )\r\nT :: Balance :: sa ( 21 )\r\nT :: Gas :: sa ( 175 )\r\nT :: Balance :: sa ( 1 )\r\n100\r\nT :: Gas :: sa ( 1_000_000 )\r\nSchedule :: default (  )\r\nruntime_primitives :: traits :: One :: one (  )\r\nT :: Balance :: sa ( 21 )\r\nT :: Gas :: sa ( 175 )\r\nT :: Balance :: sa ( 1 )\r\n100\r\nT :: Gas :: sa ( 1_000_000 )\r\nSchedule :: default (  )\r\nT :: BlockNumber :: sa ( 1000 )\r\n1\r\nT :: BlockNumber :: sa ( 1000 )\r\nT :: BlockNumber :: sa ( 5 )\r\nDEFAULT_MINIMUM_VALIDATOR_COUNT\r\nT :: BlockNumber :: sa ( 1000 )\r\nPerbill :: from_billionths ( 60 )\r\nPerbill :: from_millionths ( 1000 )\r\nT :: BlockNumber :: sa ( 1000 )\r\nDEFAULT_MINIMUM_VALIDATOR_COUNT\r\nT :: BlockNumber :: sa ( 1000 )\r\nPerbill :: from_billionths ( 60 )\r\nPerbill :: from_millionths ( 1000 )\r\nT :: BlockNumber :: sa ( 1000 )\r\nT :: Balance :: sa ( 21 )\r\nT :: Gas :: sa ( 135 )\r\nT :: Gas :: sa ( 175 )\r\nT :: Balance :: sa ( 1 )\r\n100\r\nPerbill :: from_billionths ( 60 )\r\nPerbill :: from_millionths ( 1000 )\r\nruntime_primitives :: traits :: One :: one (  )\r\n```\r\n@amaurymartiny , is this exploitable?\r\n\r\nSome things could be change, I see to two main things (please ask) :\r\n- For items without a default value I display `Default::default()`. I can change that to something else but it is the actual code called in such situation.\r\n- For items with optional value I do not do the type extraction : \r\n  so you got default value `Some ( 3 )` corresponding to a displayed type `u32` or also `None` corresponding to a displayed type `u32`. But you also got `100` corresponding to `u32`.\r\n  I can switch this to `Some ( 3 )` -> `3` and `None` -> `Default::default()` (but some corner case will not be that easy to change (optional default value not set through simple construction)).\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/paritytech/substrate/issues/comments/448570812","html_url":"https://github.com/paritytech/substrate/pull/1264#issuecomment-448570812","issue_url":"https://api.github.com/repos/paritytech/substrate/issues/1264","id":448570812,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODU3MDgxMg==","user":{"login":"cheme","id":1726091,"node_id":"MDQ6VXNlcjE3MjYwOTE=","avatar_url":"https://avatars3.githubusercontent.com/u/1726091?v=4","gravatar_id":"","url":"https://api.github.com/users/cheme","html_url":"https://github.com/cheme","followers_url":"https://api.github.com/users/cheme/followers","following_url":"https://api.github.com/users/cheme/following{/other_user}","gists_url":"https://api.github.com/users/cheme/gists{/gist_id}","starred_url":"https://api.github.com/users/cheme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheme/subscriptions","organizations_url":"https://api.github.com/users/cheme/orgs","repos_url":"https://api.github.com/users/cheme/repos","events_url":"https://api.github.com/users/cheme/events{/privacy}","received_events_url":"https://api.github.com/users/cheme/received_events","type":"User","site_admin":false},"created_at":"2018-12-19T12:03:27Z","updated_at":"2018-12-19T12:03:27Z","author_association":"CONTRIBUTOR","body":"After some testing (thanks @amaurymartiny ), it appears that the encoding got a superfluous length.\r\n\r\nIt is related to the fact that 'default' value field is not the encoded value of the default value but the encoding of the bytes value of the encoded value (thus an additional size of bytes array added).\r\n\r\nDue to static type limitation we do not have type info on `StorageFunctionMetadata` but simply the encoded value (through a cached function call). \r\n\r\nI could skip this inclusion but then I couldn't implement Decode for metadata in rust (which may not be an issue except for running tests)).\r\n\r\nThere is also the idea to make our rust metadata struct related to the type but we will totally break the initial design."}}
{"actor":{"display_login":"cheme"}}