Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang ethereum client: github.com/ethereum/go-ethereum cannot subscribe to log events via websocket #654

Closed
nikolas-digitalBabylon opened this issue Apr 6, 2020 · 3 comments · Fixed by #826
Assignees
Labels
bug Something isn't working

Comments

@nikolas-digitalBabylon
Copy link

nikolas-digitalBabylon commented Apr 6, 2020

Description

As a golang application Developer, I want subscribe to smart-contract event logs via websocket api so that i receive push events

Acceptance Criteria

  • Besu RPC node is compatible with ethereum golang client websocket API

Steps to Reproduce (Bug)

  1. Import github.com/ethereum/go-ethereum eth client
  2. Try to create a subscription for smart contract log events with the client reaching the Besu ws port

Expected behavior:
Application should receive push events as emitted by deployed smart contracts

Actual behavior:
Application Besu node returns an error upon subscription

Frequency:
Always

Versions

  • Software version:
    Modified sample network from commit b9bfa831194763f18cc99deca235ffe754b66aae , Date: Mon Jan 27 18:52:10 2020 +1000

  • Docker Version: 19.03.8

  • OS: Latest Ubuntu LTS (18.04).

  • golang ethereum client: github.com/ethereum/go-ethereum v1.9.12

Additional Information

Capturing the websocket packages transmitted with the standard golang ethereum client reveals a payload of:
{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["logs",{"address":["0xb9a219631aed55ebc3d998f17c3840b7ec39c0cc"],"fromBlock":"0x0","toBlock":"latest","topics":null}]}\n to which the Besu node responds with {"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"Invalid Request"}}

I implemented an own client that submits {"id":123,"method":"eth_subscribe","params":["logs",{"address":"0xb9a219631aed55ebc3d998f17c3840b7ec39c0cc"}]}\n and works as expected. I can then receive and decode events.

One important difference to notice, is that the standard ethereum client transmits an array of contract addresses.

@shemnon
Copy link
Contributor

shemnon commented Apr 6, 2020

My instinct says we are not playing well with the null "topics" argument. Thanks for the JSON-RPC, this will help a lot.

@timbeiko timbeiko added the bug Something isn't working label Apr 6, 2020
@timbeiko timbeiko added this to the Chupacabra Sprint 62 milestone Apr 8, 2020
@shemnon
Copy link
Contributor

shemnon commented Apr 8, 2020

The problem was different. geth does not follow it's own published spec for this API (https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB#logs or https://geth.ethereum.org/docs/rpc/pubsub) and includes fromBlock and toBlock in the subscription arguments. Only address and topics are documented.

@RatanRSur
Copy link
Contributor

Thanks for the bug report and repro! The fix should be in the master branch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants