{"action":"created","issue":{"url":"https://api.github.com/repos/Loopring/protocol/issues/285","repository_url":"https://api.github.com/repos/Loopring/protocol","labels_url":"https://api.github.com/repos/Loopring/protocol/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/Loopring/protocol/issues/285/comments","events_url":"https://api.github.com/repos/Loopring/protocol/issues/285/events","html_url":"https://github.com/Loopring/protocol/pull/285","id":313534208,"number":285,"title":"Optimized wallet address fetching","user":{"login":"Brechtpd","id":7032473,"avatar_url":"https://avatars3.githubusercontent.com/u/7032473?v=4","gravatar_id":"","url":"https://api.github.com/users/Brechtpd","html_url":"https://github.com/Brechtpd","followers_url":"https://api.github.com/users/Brechtpd/followers","following_url":"https://api.github.com/users/Brechtpd/following{/other_user}","gists_url":"https://api.github.com/users/Brechtpd/gists{/gist_id}","starred_url":"https://api.github.com/users/Brechtpd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brechtpd/subscriptions","organizations_url":"https://api.github.com/users/Brechtpd/orgs","repos_url":"https://api.github.com/users/Brechtpd/repos","events_url":"https://api.github.com/users/Brechtpd/events{/privacy}","received_events_url":"https://api.github.com/users/Brechtpd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-12T00:22:11Z","updated_at":"2018-04-12T16:36:56Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/Loopring/protocol/pulls/285","html_url":"https://github.com/Loopring/protocol/pull/285","diff_url":"https://github.com/Loopring/protocol/pull/285.diff","patch_url":"https://github.com/Loopring/protocol/pull/285.patch"},"body":"This saves about ~4500 gas. \r\n\r\nThis optimization doesn't fetch the wallet address when it's the same wallet as the one of the order before in the ring. Of course the effectiveness of this optimization depends how the orders are made, but (at least for now) I think there's a high chance of this happening.\r\n\r\nThere's different ways this could be exploited. The current implementation cannot optimize a case like this: WalletA WalletB WalletA. Wallet addresses could be temporarily cached in a different way to exploit scenario's like this, though I'm not sure if that's worth it.\r\n\r\nLet me know if you think this is worth doing."},"comment":{"url":"https://api.github.com/repos/Loopring/protocol/issues/comments/380868319","html_url":"https://github.com/Loopring/protocol/pull/285#issuecomment-380868319","issue_url":"https://api.github.com/repos/Loopring/protocol/issues/285","id":380868319,"user":{"login":"Orangem21","id":13641419,"avatar_url":"https://avatars0.githubusercontent.com/u/13641419?v=4","gravatar_id":"","url":"https://api.github.com/users/Orangem21","html_url":"https://github.com/Orangem21","followers_url":"https://api.github.com/users/Orangem21/followers","following_url":"https://api.github.com/users/Orangem21/following{/other_user}","gists_url":"https://api.github.com/users/Orangem21/gists{/gist_id}","starred_url":"https://api.github.com/users/Orangem21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Orangem21/subscriptions","organizations_url":"https://api.github.com/users/Orangem21/orgs","repos_url":"https://api.github.com/users/Orangem21/repos","events_url":"https://api.github.com/users/Orangem21/events{/privacy}","received_events_url":"https://api.github.com/users/Orangem21/received_events","type":"User","site_admin":false},"created_at":"2018-04-12T16:36:56Z","updated_at":"2018-04-12T16:36:56Z","author_association":"NONE","body":"```\r\n            //batch[p + 4] = bytes32(state.lrcReward);\r\n            //batch[p + 5] = bytes32(state.lrcFee);\r\n            // Check if the order wallet id is the same as the one of the order before\r\n\r\n            if(i > 0 && order.walletId == orders[i-1].order.walletId) {\r\n                if(batch[p] == batch[p-7]){\r\n                    batch[(p - 7) + 5] = bytes32(state.lrcFee + uint(batch[(p - 7) + 5]));\r\n                    batch[p + 5] = bytes32(0);\r\n                    batch[(p - 7) + 4] = bytes32(state.lrcReward + uint(batch[(p - 7) + 4]));\r\n                    batch[p + 4] = bytes32(0);\r\n                }else{\r\n                    batch[p + 5] = bytes32(state.lrcFee);\r\n                    batch[p + 4] = bytes32(state.lrcReward);\r\n                }\r\n                batch[p + 6] = batch[(p-7) + 6];\r\n            } else {\r\n                batch[p + 5] = bytes32(state.lrcFee);\r\n                batch[p + 4] = bytes32(state.lrcReward);\r\n                batch[p + 6] = bytes32((order.walletId != 0) ? NameRegistry(nameRegistryAddress).getFeeRecipientById(order.walletId) : 0x0);\r\n            }\r\n            p += 7;\r\n```"}}
{"actor":{"display_login":"Orangem21"}}