Relay Transaction call rejected on bsc

I am trying to use the relay server on Binance smart chain but I got the error below:

Rejected relayTransaction call with reason: Internal JSON-RPC error.
{
  "code": -32000,
  "message": "exceed maximum block range: 5000"
} RelayProvider.js:111
Error: Rejected relayTransaction call with reason: Internal JSON-RPC error.
{
  "code": -32000,
  "message": "exceed maximum block range: 5000"
}

I think the error is coming from the relay server. It appears that the Binance free RPC API won’t allow the querying of logs beyond 5000 blocks. Is there any solution to this?

I am also curious how the current Binance relay server was hosted. I went checked the relay codebase and I noticed that the relay server queries the log from block 1 before it starts. I am having a similar issue with the harmony network and I would like to know how this was solved on Binance.

1 Like

I think that this problem occured at the frontend inside getRelayInfoForManagers in relayClient/knownRelaysManager.js

I got past the above error when I changed the fromBlock and toBlock to what I have below:

const relayServerRegisteredEvents = await this.contractInteractor.getPastEventsForHub(topics, { fromBlock: 3793603, toBlock: 3797603 }, [ContractInteractor_1.RelayServerRegistered]);
 const relayManagerExitEvents = await this.contractInteractor.getPastEventsForStakeManager([ContractInteractor_1.StakeUnlocked, ContractInteractor_1.HubUnauthorized, ContractInteractor_1.StakePenalized], topics, { fromBlock: 3793603, toBlock: 3797603 });

But now, I get

Ping errors (1):
https://bsc1.relays.opengsn.org/gsn1 => timeout of 15000ms exceeded```

There is a problem with BSC network, in that they changed the rules for eth_getLogs: it can now query a block range of only 5000 blocks (roughly 4 hours).
GSN relies on eth_getLogs to find active Relayers, which means we need to use another method to find active relayers.
Unfortunately, I don’t know of any other decentralized way to find them.

On any other networks (mainnet, testnets, xdai and even test-bsc) there is no such limit (there is a limit on # of responses, but not on block range)

You can work around it by specifying a relayer directly (but then it means you can’t detect new relayers)
The currenlty active relayer is https://bsc2.relays.opengsn.org/gsn1
(bsc1 is an old relayer which was removed)

2 Likes

Do you have anything against querying blocks in batches? I saw a parameter [relayLookupWindowParts] to do this in /packages/provider/src/GSNConfigurator.ts.

And for the relay server, can we store the last block number queried in the file DB? This will prevent the querying of events log from block 0 each time the relay server starts.