Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Error while using zeroEx.exchange.subscribe: received log with same block number but index newer than previous index #693

Closed
mohoff opened this issue Jun 12, 2018 · 10 comments
Assignees

Comments

@mohoff
Copy link
Contributor

mohoff commented Jun 12, 2018

Hi 0x team,
might have found a bug that is described below. Thanks for investigating! Looking forward to v2 :)

Expected Behavior

Trying to listen to events emitted from Exchange.sol by using the 0x.js library and its zeroEx.exchange.subscribe method. I think it should callback every time an event is emitted.

Current Behavior

Subscription seems successful but once the first event is received my script fails with:

Error: received log with same block number but index newer than previous index
    at ensureOrder (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:140:15)
    at /home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:91:21
    at step (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:32:23)
    at Object.next (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:13:53)
    at /home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:3:12)
    at addNewLogsToHead (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:80:12)
    at Object.<anonymous> (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:51:42)
    at step (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:32:23)
    at Object.next (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:13:53)
    at fulfilled (/home/mo/dev/0x-openrelay-playground/node_modules/0x.js/node_modules/ethereumjs-blockstream/output/source/log-reconciler.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Steps to Reproduce (for bugs)

The code:

const eventName = 'LogFill'
const tokenPair = web3.utils.sha3(
        '0xe41d2489571d322189246dafa5ebde1f4699f498',  // ZRX contract on mainnet
        '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'   // WETH contract on mainnet
)

zeroEx.exchange.subscribe(
    eventName,
    indexFilterValues,
    async (err, decodedLogEvent) => {
        if (err) {
            console.log(err)
            return;
        } else {
            console.log(decodedLogEvent)
        }
    }
)

Context

see intro

Your Environment

Package Version
0x.js 0.37.2
web3 1.0.0-beta.34
Network
mainnet
@fabioberger fabioberger assigned LogvinovLeon and dekz and unassigned LogvinovLeon Jun 13, 2018
@LogvinovLeon
Copy link
Contributor

Seems like an ethereumjs-blockstream issue to me. How ofter does that happen? Do you use infura?

@mohoff
Copy link
Contributor Author

mohoff commented Jun 13, 2018

Thanks for your reply! I get this every time I'm running my script on the first log received.
Yes, using Infura with a subprovider setup (mnemonic wallet subprovider for signing, the rest with Infura via RPC subprovider.

I opened an issue in their repo: ethereumjs/ethereumjs-blockstream#17

@mohoff
Copy link
Contributor Author

mohoff commented Jun 13, 2018

So from the discussion in ethereumjs/ethereumjs-blockstream#17, it looks like you need to update the ethereumjs-blockstream version you are including in 0x.js. Apparently, this got fixed in v4.0.0. Also [email protected] (latest) depends on [email protected].

EDIT: [email protected] doesn't fix it.

@mohoff
Copy link
Contributor Author

mohoff commented Jun 13, 2018

Apparently a duplicate of ethereumjs/ethereumjs-blockstream#10, which you opened some time ago, @LogvinovLeon .

So looks like zeroEx.exchange.subscribe doesn't work currently on any non-testrpc net.

@MicahZoltu
Copy link

I think Augur setup a bounty to get Geth/Parity to fix their JSON-RPC API so this can be fixed. I'm not sure what the status of that is though.

@MicahZoltu
Copy link

MicahZoltu commented Jun 13, 2018

@MicahZoltu
Copy link

I think I have a way to fix this without Geth/Parity adding the desired RPC method. Will try to get a new version out today.

@MicahZoltu
Copy link

I believe I have a fix ready for ethereumjs-blockstream that addresses this issue. Going to wait a few days before merging and releasing though as I want to review the change after some time to forget it. If this is something critical that needs a fix ASAP let me know and I can consider moving up the timetable.

@MicahZoltu
Copy link

Issue is fixed (mostly) in ethereumjs-blockstream v5.0.0. Note that ethereumjs/ethereumjs-blockstream#10 is still not fixed and can't be without https://eips.ethereum.org/EIPS/eip-234 being implemented.

@fabioberger
Copy link
Contributor

Fixed in latest version of our libraries.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants