You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
eth_subscriptionLogs with topics filter problemΒ #4030
When I'm subscribe to erigon node with topics filter - I must see transactions that corresponds to topics.
Actual behaviour
I see no any transactions at all, but they are (according to ETH/BSC explorer). If I don't use any filters (no topics) - I see all transactions, but I need only transactions with topics I'm interested in.
I'm running similar issues with my erigon node running on Ubuntu 22.04 on commit aa79853. If I only have one log subscription it works fine, but running multiple at once with different topic/address queries causes unexpected behaviour. I'm testing using go-ethereum with this simple program, which subscribes to logs with the option to filter by address 0xdac17f958d2ee523a2206206994597c13d831ec7 (USDT) using the flag -usdt, and the option to filter by topics ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"] (ERC20 Transfer event hash) using the flag -erc20
package main
import (
"context"
"flag"
"fmt"
"os"
ethereum "github.com/ethereum/go-ethereum"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
ethClient "github.com/ethereum/go-ethereum/ethclient"
)
const (
usdtAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7"
erc20TransferTopic0 = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
)
func main() {
websocketAddress := os.Getenv("ERIGON_WEBSOCKET_URL")
if websocketAddress == "" {
fmt.Println("Please set ERIGON_WEBSOCKET_URL environment variable")
return
}
client, err := ethClient.Dial(websocketAddress)
if err != nil {
fmt.Printf("Failed to connect to websocket: %v\n", err)
return
}
erc20, uniswap := parseCliArgs()
var filter ethereum.FilterQuery
if erc20 {
filter.Topics = [][]ethCommon.Hash{{ethCommon.HexToHash(erc20TransferTopic0)}}
}
if uniswap {
filter.Addresses = []ethCommon.Address{ethCommon.HexToAddress(usdtAddress)}
}
receivedLogs := make(chan types.Log)
subscription, err := client.SubscribeFilterLogs(context.Background(), filter, receivedLogs)
if err != nil {
fmt.Printf("Unable to create subscription: %v\n", err)
return
}
defer subscription.Unsubscribe()
fmt.Println("Subscription successful")
errChan := subscription.Err()
for {
select {
case log := <-receivedLogs:
fmt.Printf("Received log %d of block %d from address %s and topic0 %s\n",
log.Index,
log.BlockNumber,
log.Address.String(),
log.Topics[0].String(),
)
case err := <-errChan:
fmt.Printf("Subscription error encountered: %v\n", err)
return
}
}
}
// Parses command line flags, and returns whether or not to filter by the ERC20
// transfer topic 0 hash, and whether or not to filter by USDT address
func parseCliArgs() (bool, bool) {
erc20TransferFlag := flag.Bool("erc20", false, "Whether to filter logs by topic 0 hash "+erc20TransferTopic0)
usdtFlag := flag.Bool("usdt", false, "Whether to filter logs by address "+usdtAddress)
flag.Parse()
return *erc20TransferFlag, *usdtFlag
}
When I run this program multiple time concurrently, I get the following behaviour:
Running one with no flags and one with the -erc20 flag, neither receive any logs
Running one with no flags and one with the -usdt flag, neither receive any logs
Running one with no flags, one with the -erc20 flag, and one with both flags, the former two erroneously only receive logs from the usdt address
Running one with no flags, one with the -usdt flag, and one with both flags, the former two erroneously only receive logs with the erc20 transfer topic 0 hash
Running one with no flags, one with the -usdt flag, one with the -erc20 flag, and one with both flags, all four only receive logs with the erc20 transfer topic 0 hash from the usdt address
Running one with the -usdt flag, one with the -erc20 flag, and one with both flags, all behave as expected
Running one with no flags, and one with both flags, both behave as expected
I'm not sure this is fixed, as we continue to see this issue. I cannot use eth_getLogs with any filters (address, topics). I can only get the full bloom from a log range. It's not the end of the world as I can filter in the client, but it adds a lot of latency and bandwidth requirements which in turn make it lose its advantage against geth.
Ah I see the issue here, you need to open a websocket connection to erigon first then send your request via that. Subscriptions are only enabled via sockets.
You'll get back a subscription ID which you can then use to cancel the subscription in the future if you wish.
@hexoscott is this issue being actively worked on? we've been seeing this issue with eth_getLogs per #6598. is there any additional info i could provide which would be helpful?
I'm going to close this issue down, the problem mentioned above around eth_getLogs was initially an mdbx version issue from the looks of things which is now resolved, and a typo in a test file leading to inconsistent results. Chances are the mdbx fix will have resolved this issue?
If the issue still persists, please leave examples and information such as chain and anything else that would be helpful and I'll pick the thread back up.
Activity
AskAlexSharov commentedon Apr 30, 2022
I think subscription to logs not supported: https://github.com/ledgerwatch/erigon/tree/devel/cmd/rpcdaemon#rpc-implementation-status
eth_getLogs - works and fast
d-polikhranidi commentedon Apr 30, 2022
But subscription to logs without topics - works great
This works. But when I add
topicsto options it's shows nothing((AskAlexSharov commentedon Apr 30, 2022
Donβt know, maybe bug. Need somebody to check.
primalcs commentedon Jun 23, 2022
Could you please try
let options = { topics: [ '0x0000000000000000000000002faf487a4414fe77e2327f0bf4ae2a264a776ad2' ] };instead of
let options = { topics: [ null, '0x0000000000000000000000002faf487a4414fe77e2327f0bf4ae2a264a776ad2', null ] };?
dan-nathan commentedon Jun 29, 2022
I'm running similar issues with my erigon node running on Ubuntu 22.04 on commit aa79853. If I only have one log subscription it works fine, but running multiple at once with different topic/address queries causes unexpected behaviour. I'm testing using go-ethereum with this simple program, which subscribes to logs with the option to filter by address
0xdac17f958d2ee523a2206206994597c13d831ec7(USDT) using the flag-usdt, and the option to filter by topics["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"](ERC20 Transfer event hash) using the flag-erc20When I run this program multiple time concurrently, I get the following behaviour:
-erc20flag, neither receive any logs-usdtflag, neither receive any logs-erc20flag, and one with both flags, the former two erroneously only receive logs from the usdt address-usdtflag, and one with both flags, the former two erroneously only receive logs with the erc20 transfer topic 0 hash-usdtflag, one with the-erc20flag, and one with both flags, all four only receive logs with the erc20 transfer topic 0 hash from the usdt address-usdtflag, one with the-erc20flag, and one with both flags, all behave as expectedsamsondav commentedon Aug 8, 2022
This is a blocking bug for us to use Chainlink with Erigon. We require topic filtering on log streams.
revitteth commentedon Sep 16, 2022
Closing issue as fix is merged.
rcastellaj commentedon Sep 27, 2022
I'm not sure this is fixed, as we continue to see this issue. I cannot use eth_getLogs with any filters (address, topics). I can only get the full bloom from a log range. It's not the end of the world as I can filter in the client, but it adds a lot of latency and bandwidth requirements which in turn make it lose its advantage against geth.
hexoscott commentedon Sep 28, 2022
Hi @rcastellaj, could you send some examples over of what you're running and I can take another look, thanks.
drcliche commentedon Jan 26, 2023
@hexoscott This looks related to a similar issue with examples of usage and intermittent/different responses being generated: #6598
danieloadebimpe commentedon Feb 6, 2023
I don't believe this was fixed. As @samsondav said, this is required for chainlink.
I am running erigon v2.36.0 and I get the following error when trying to subscribe to a topic on goerli:
My system info:
Kernel -> Linux version 4.14.243-185.433.amzn2.x86_64
Distribution -> (gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC))
hexoscott commentedon Feb 6, 2023
I'm taking a look into this now, could you send me the flags you're using @danieloadebimpe please
danieloadebimpe commentedon Feb 6, 2023
@hexoscott
hexoscott commentedon Feb 6, 2023
Just a quick check that eth_subscribe is in your rules.json?
danieloadebimpe commentedon Feb 6, 2023
Yes, heres the file:
hexoscott commentedon Feb 6, 2023
Ah I see the issue here, you need to open a websocket connection to erigon first then send your request via that. Subscriptions are only enabled via sockets.
You'll get back a subscription ID which you can then use to cancel the subscription in the future if you wish.
An example sent via postman:
ca42 commentedon Feb 16, 2023
@hexoscott is this issue being actively worked on? we've been seeing this issue with eth_getLogs per #6598. is there any additional info i could provide which would be helpful?
hexoscott commentedon Feb 20, 2023
Hi @ca42, it is, but I'm juggling it with other issues. I'll be taking another look into this today.
hexoscott commentedon Feb 20, 2023
@ca42 - do you have any recent examples that are re-produceable? Could you let me know the chain as well.
hexoscott commentedon Feb 27, 2023
I'm going to close this issue down, the problem mentioned above around eth_getLogs was initially an mdbx version issue from the looks of things which is now resolved, and a typo in a test file leading to inconsistent results. Chances are the mdbx fix will have resolved this issue?
If the issue still persists, please leave examples and information such as chain and anything else that would be helpful and I'll pick the thread back up.