{"action":"created","issue":{"url":"https://api.github.com/repos/CityOfZion/neo-python/issues/566","repository_url":"https://api.github.com/repos/CityOfZion/neo-python","labels_url":"https://api.github.com/repos/CityOfZion/neo-python/issues/566/labels{/name}","comments_url":"https://api.github.com/repos/CityOfZion/neo-python/issues/566/comments","events_url":"https://api.github.com/repos/CityOfZion/neo-python/issues/566/events","html_url":"https://github.com/CityOfZion/neo-python/issues/566","id":353064577,"node_id":"MDU6SXNzdWUzNTMwNjQ1Nzc=","number":566,"title":"MUL can be more computationally costly than what is reflected in its gas price","user":{"login":"udoprog","id":111092,"node_id":"MDQ6VXNlcjExMTA5Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/111092?v=4","gravatar_id":"","url":"https://api.github.com/users/udoprog","html_url":"https://github.com/udoprog","followers_url":"https://api.github.com/users/udoprog/followers","following_url":"https://api.github.com/users/udoprog/following{/other_user}","gists_url":"https://api.github.com/users/udoprog/gists{/gist_id}","starred_url":"https://api.github.com/users/udoprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/udoprog/subscriptions","organizations_url":"https://api.github.com/users/udoprog/orgs","repos_url":"https://api.github.com/users/udoprog/repos","events_url":"https://api.github.com/users/udoprog/events{/privacy}","received_events_url":"https://api.github.com/users/udoprog/received_events","type":"User","site_admin":false},"labels":[{"id":648322778,"node_id":"MDU6TGFiZWw2NDgzMjI3Nzg=","url":"https://api.github.com/repos/CityOfZion/neo-python/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-22T18:08:46Z","updated_at":"2018-10-14T13:12:02Z","closed_at":null,"author_association":"NONE","body":"### Current behavior\r\n\r\nCalling `MUL` with large operands will cause the VM to perform large computations that could prevent it from making progress.\r\n\r\n### Expected behavior\r\n\r\n`MUL` should have a relatively constant cost in computation to reflect its gas cost.\r\n\r\n### How to reproduce\r\n\r\nConsider calling the following contract:\r\n\r\n```python\r\ndef Main():\r\n    a = 10\r\n\r\n    while True:\r\n        a = a * a\r\n```\r\n\r\n24 iterations of this loop takes about 30 seconds for me to execute and costs ~0.5 gas.\r\nThis is an operation with relatively low gas cost but with a high computational cost.\r\nIt could possibly be used as a an inexpensive vehicle to cause VMs to be busy performing large computations.\r\n\r\nA similar contract that only performs a busy loop consumes around 500 gas.\r\n\r\nThis works because integers are arbitrarily large bignums, that has a variable cost for multiplication that depends on their size. And [the multiplication is currently performed regardless of operand sizes](https://github.com/CityOfZion/neo-python/blob/42e0bb41866d0b2c7aa3ee460a8f8ce3ae2f1f22/neo/VM/ExecutionEngine.py#L464).\r\n\r\nA solution could be to limit numeric types to 32 bytes, [as neo does](https://github.com/neo-project/neo/blob/master/neo/SmartContract/ApplicationEngine.cs#L225).\r\n\r\n### Your environment\r\n\r\nNot applicable"},"comment":{"url":"https://api.github.com/repos/CityOfZion/neo-python/issues/comments/429625368","html_url":"https://github.com/CityOfZion/neo-python/issues/566#issuecomment-429625368","issue_url":"https://api.github.com/repos/CityOfZion/neo-python/issues/566","id":429625368,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTYyNTM2OA==","user":{"login":"ixje","id":6625537,"node_id":"MDQ6VXNlcjY2MjU1Mzc=","avatar_url":"https://avatars0.githubusercontent.com/u/6625537?v=4","gravatar_id":"","url":"https://api.github.com/users/ixje","html_url":"https://github.com/ixje","followers_url":"https://api.github.com/users/ixje/followers","following_url":"https://api.github.com/users/ixje/following{/other_user}","gists_url":"https://api.github.com/users/ixje/gists{/gist_id}","starred_url":"https://api.github.com/users/ixje/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ixje/subscriptions","organizations_url":"https://api.github.com/users/ixje/orgs","repos_url":"https://api.github.com/users/ixje/repos","events_url":"https://api.github.com/users/ixje/events{/privacy}","received_events_url":"https://api.github.com/users/ixje/received_events","type":"User","site_admin":false},"created_at":"2018-10-14T13:12:02Z","updated_at":"2018-10-14T13:12:02Z","author_association":"MEMBER","body":"Thanks for reporting 👍 . Should be addressed in the development branch shortly."}}
{"actor":{"display_login":"ixje"}}