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

Subscribe pending logs via SubscribeFilterLogs does not work #1815

Closed
sirgarfieldc opened this issue Aug 11, 2023 · 1 comment
Closed

Subscribe pending logs via SubscribeFilterLogs does not work #1815

sirgarfieldc opened this issue Aug 11, 2023 · 1 comment

Comments

@sirgarfieldc
Copy link

sirgarfieldc commented Aug 11, 2023

in the original GETH for ETH L1, one could subscribe to logs emitted by pending transaction with this snippet below

localSub, err := provider.SubscribeFilterLogs(
		context.Background(),
		ethereum.FilterQuery{
			FromBlock: big.NewInt(-1),
			ToBlock:   big.NewInt(-1),
		},
		localCh,
)

I have looked through the code base of this bsc fork. It looks like this functionality should be supported

if from == rpc.PendingBlockNumber && to == rpc.PendingBlockNumber {

Trying to do

localSub, err := provider.SubscribeFilterLogs(
		context.Background(),
		ethereum.FilterQuery{
			FromBlock: big.NewInt(-2),
			ToBlock:   big.NewInt(-2),
		},
		localCh,
)

produces this error

2023/08/11 14:25:20 failed to SubscribeFilterLogs. err=invalid argument 1: hex string without 0x prefix

Upon investigation it looks like there is a discrepancy here

pending := big.NewInt(-1)

backend used -2 to represent pendingBlock but ethclient still uses -1.

I have done this modification

pending := big.NewInt(int64(rpc.PendingBlockNumber))

After the modification, err=invalid argument 1: hex string without 0x prefix no longer shows up but there is no pending Log coming out of the channel.

Questions:
Does Subscribe pending logs via SubscribeFilterLogs work in bsc fork ? If yes, how to properly do it ? If not, why not ? (looks like backend supports it )

@0xLyon
Copy link

0xLyon commented Sep 8, 2023

Hi there, unfortunately this is not currently available and you will have to use the solution suggested here for now:
#1787 (comment)

You can see more details as to why and the PR that are still required to be merged in order to allow for the mentioned subscription for pending transaction to be available:
#1783 (comment)

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

No branches or pull requests

3 participants