From c1ec11dd1da97fa1630ce1666152734eb2cf4686 Mon Sep 17 00:00:00 2001 From: gghidini Date: Wed, 4 Oct 2017 10:58:23 -0500 Subject: [PATCH] [#2114] Report on experiment within HTNL Web page itself --- test/bug-2114/README.md | 24 +++- test/bug-2114/website/public/index.html | 176 +++++++++++++++++++++++- 2 files changed, 198 insertions(+), 2 deletions(-) diff --git a/test/bug-2114/README.md b/test/bug-2114/README.md index b5c89793eb89..27c09d6a1ba0 100644 --- a/test/bug-2114/README.md +++ b/test/bug-2114/README.md @@ -1,3 +1,25 @@ # Bug 2114 -This directory contains Ethereum contracts and Web pages attempting to demonstrate the bug described [https://github.com/MetaMask/metamask-extension/issues/2114#issuecomment-333174005](https://github.com/MetaMask/metamask-extension/issues/2114#issuecomment-333174005), namely that events are silently filtered somewhere between the Infura JSON RPC API and the MetaMask Chrome plugin in the browser. +This directory contains Ethereum contracts and Web page attempting to demonstrate the bug described [https://github.com/MetaMask/metamask-extension/issues/2114#issuecomment-333174005](https://github.com/MetaMask/metamask-extension/issues/2114#issuecomment-333174005), namely that events are silently filtered somewhere between the Infura JSON RPC API and the MetaMask Chrome plugin in the browser. + +To run the demo, change directory into the website root, and then start the HTTP server w/: +``` +$ npm start + +> bug-2114@0.0.1 start /metamask-extension/test/bug-2114/website +> serve -s public + + + ┌─────────────────────────────────────────────────┐ + │ │ + │ Serving! │ + │ │ + │ - Local: http://localhost:5000 │ + │ - On Your Network: http://:5000 │ + │ │ + │ Copied local address to clipboard! │ + │ │ + └─────────────────────────────────────────────────┘ + + +``` diff --git a/test/bug-2114/website/public/index.html b/test/bug-2114/website/public/index.html index 4f2c014a6500..b8014613534f 100644 --- a/test/bug-2114/website/public/index.html +++ b/test/bug-2114/website/public/index.html @@ -1,11 +1,184 @@ + + -

Bug 2114

+

Demo MetaMask issue 2114

+

+ Attempt to demo problem reported in + + https://github.com/MetaMask/metamask-extension/issues/2114#issuecomment-333174005 + , + namely that events are silently filtered somewhere between + the Infura JSON RPC API and the MetaMask Chrome plugin in the browser. +

+

+ I deployed a simple event-firing contract at + + https://rinkeby.etherscan.io/address/0x46105b226398ab00adbaca1489e35a17fd382bdb + . + (Solidity source code in the contract subdirectory in this repo.) +

+

+ For these experiments, I'm using: +

    +
  • + MetaMask 3.10.8 +
  • +
  • + Chrome Version 60.0.3112.113 (Official Build) (64-bit) +
  • +
  • + Web3.js 0.18.4 +
  • +
+

+

+ Contract fired two events upon processing transactions I sent: +

    +
  1. + + https://rinkeby.etherscan.io/tx/0x5a532f188338de65c7c39bbae619b9bd11cfe1810baeadaa5cf9a0d189034194#eventlog + +
  2. +
  3. + + https://rinkeby.etherscan.io/tx/0x0763212ed21c3924cfb992e1f02f5c8d87ced05e89591caba3be9f1b92a3c704#eventlog + +
  4. +
+

+

+ The DApp in this Web page watches the events on the contract, but + the Infura-backed MetaMask Chrome plugin NEVER calls back. +

+

+ On top of that, no error is fired. Earlier versions of MetaMask would fire: +

+        Error: Gateway timeout. The request took too long to process.
+          This can happen when querying logs over too wide a block range.
+          at Object.InvalidResponse (errors.js:35)
+          at requestmanager.js:86
+          at inpage.js:209
+          at inpage.js:8205
+      
+

+

+ Follow the logs in the console for details. +

+

+ MetaMask DOES NOT call back even when I filter down to the block where + the event was fired (e.g., with +

{fromBlock: 1002589, toBlock: 1002589}
+ for the first event. (One can reproduce by editing the source code in + the script element in this HTML Web page and then reload--without + re-starting the HTTP server) +

+

+ The event logs DO exist on the Infura endpoint: +

+        $ curl -X POST -s --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0xf4c5d", "toBlock": "0xf4c5d"}],"id":74}' https://rinkeby.infura.io | jq .
+        {
+          "jsonrpc": "2.0",
+          "id": 74,
+          "result": [
+            { ... },
+            {
+              "address": "0x46105b226398ab00adbaca1489e35a17fd382bdb",
+              "topics": [
+                "0x6cb3ef98ecf9979af0c5a4c4d73f1235106be2c0e6932586f7bba2c05ea6c672",
+                "0x000000000000000000000000560c7cb958f235f7772ced2af64a0b5eba4d32e5"
+              ],
+              "data": "0x",
+              "blockNumber": "0xf4c5d",
+              "transactionHash": "0x5a532f188338de65c7c39bbae619b9bd11cfe1810baeadaa5cf9a0d189034194",
+              "transactionIndex": "0x1",
+              "blockHash": "0x1a5b5eedfb49d4732e84311f71ca92d8dc66a6b85cc9e753d4ba3c99e89f70e5",
+              "logIndex": "0x1",
+              "removed": false
+            }
+          ]
+        }
+      
+
+        $ curl -X POST -s --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0xf4cb1", "toBlock": "0xf4cb1"}],"id":74}' https://rinkeby.infura.io | jq .
+        {
+          "jsonrpc": "2.0",
+          "id": 74,
+          "result": [
+            {
+              "address": "0x46105b226398ab00adbaca1489e35a17fd382bdb",
+              "topics": [
+                "0x6cb3ef98ecf9979af0c5a4c4d73f1235106be2c0e6932586f7bba2c05ea6c672",
+                "0x000000000000000000000000560c7cb958f235f7772ced2af64a0b5eba4d32e5"
+              ],
+              "data": "0x",
+              "blockNumber": "0xf4cb1",
+              "transactionHash": "0x0763212ed21c3924cfb992e1f02f5c8d87ced05e89591caba3be9f1b92a3c704",
+              "transactionIndex": "0x1",
+              "blockHash": "0x42bffea3561ddbe1ad54e3d31fcf062b98dc19caaa8ac46fa4276433047139b1",
+              "logIndex": "0x0",
+              "removed": false
+            }
+          ]
+        }
+      
+

+

+ Mist (0.9.0) DOES call back w/ the events: +

+        You're connected to Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.3
+        (index):77 Loaded contract at: 0x46105b226398ab00adbaca1489e35a17fd382bdb
+        (index):78 Waiting for callbacks w/ contract events...
+        (index):84 Event: {
+          "address": "0x46105b226398ab00adbaca1489e35a17fd382bdb",
+          "blockNumber": 1002589,
+          "transactionHash": "0x5a532f188338de65c7c39bbae619b9bd11cfe1810baeadaa5cf9a0d189034194",
+          "transactionIndex": 1,
+          "blockHash": "0x1a5b5eedfb49d4732e84311f71ca92d8dc66a6b85cc9e753d4ba3c99e89f70e5",
+          "logIndex": 1,
+          "removed": false,
+          "event": "LogEvent",
+          "args": {
+            "sender": "0x560c7cb958f235f7772ced2af64a0b5eba4d32e5"
+          }
+        }
+        (index):84 Event: {
+          "address": "0x46105b226398ab00adbaca1489e35a17fd382bdb",
+          "blockNumber": 1002673,
+          "transactionHash": "0x0763212ed21c3924cfb992e1f02f5c8d87ced05e89591caba3be9f1b92a3c704",
+          "transactionIndex": 1,
+          "blockHash": "0x42bffea3561ddbe1ad54e3d31fcf062b98dc19caaa8ac46fa4276433047139b1",
+          "logIndex": 0,
+          "removed": false,
+          "event": "LogEvent",
+          "args": {
+            "sender": "0x560c7cb958f235f7772ced2af64a0b5eba4d32e5"
+          }
+        }
+      
+ One can view the console on Mist by right-clicking on the DApp Web page and then + clicking on Open Developer Tools. +