jblock
January 17, 2022, 2:33pm
1
Hello there,
We stepped into a problem in infura’s JSON-RPC implementation.
Just a case problem but quite anoying as the best web3 rust packages decided it’ll be a won't fix
as it doesn’t respect the JSON-RPC specifications.
opened 08:28AM - 05 Nov 21 UTC
Hi, I'm trying to subscribe to events in a contract:
```rust
let ws = web… 3::transports::WebSocket::new("mynode").await?;
let web3 = web3::Web3::new(ws);
let contract = Contract::from_json(
web3.eth(),
hex!("4e68Ccd3E89f51C3074ca5072bbAC773960dFa36").into(),
include_bytes!("../contracts/uniswap_v3_pool.json"),
)?;
filter = FilterBuilder::default()
.address(vec![contract.address()])
.from_block(BlockNumber::Latest)
.build();
let mut evsub = web3ws.eth_subscribe().subscribe_logs(filter).await?;
println!("Sub id {:?}", evsub.id());
loop {
let r = evsub.next().await;
match r {
Some(ev) => println!("{:?}", ev?),
None => ()
}
}
```
And everytime an event happens (checking on etherscan) I receive a response from unknown request
```
[2021-11-05T08:14:40Z DEBUG web3::transports::ws] [1] Calling: {"jsonrpc":"2.0","method":"eth_subscribe","params":["logs",{"address":"0x4e68ccd3e89f51c3074ca5072bbac773960dfa36","fromBlock":"latest"}],"id":1}
Sub id SubscriptionId("0x10ff0e1299f046edb86e5c774741102fa889ab7e15dd")
[2021-11-05T08:14:58Z WARN web3::transports::ws] Got response for unknown request (id: 0)
[2021-11-05T08:15:32Z WARN web3::transports::ws] Got response for unknown request (id: 0)
```
The same is happening when I try to run the examples subscribing to new heads.
I know my node connection is working because I can fetch past events and I receive the correct data
```rust
let logs = web3ws.eth().logs(filter).await?;
println!("Got {:?} logs", logs.len());
for l in logs {
let event: (Address, Address, U256, U256, U256, u128, i32) = Detokenize::from_tokens(
contract
.abi()
.event("Swap")?
.parse_log(ethabi::RawLog {topics: l.topics.clone(), data: l.data.0.clone()})?
.params
.into_iter()
.map(|x| x.value)
.collect::<Vec<_>>())?;
println!("event {:?} ", event);
}
```
```
event (0xe592427a0aece92de3edee1f18e0157c05861564, 0xe592427a0aece92de3edee1f18e0157c05861564, 320000000000000000, 115792089237316195423570985008687907853269984665640564039457584007911902018681, 4914607075100445747082281, 10392763788743888306, -193768)
```
Any idea of what could be happening?
Thanks.
paritytech:master
← MrCasCode:capital-letters-jsonrpc
opened 09:42AM - 06 Nov 21 UTC
Some providers send a non-standard typing, so add an alias to allow decoding cap… ital version
The exact same calls works fine with you concurrent api alchemy
.
Would Infura fix this issue ? Is there a schedule to communicate about this problem ? Or do we have to find a workaround before production ?
Best regards.
hi @jblock let me talk to our team about this and get back.
1 Like
jblock
January 20, 2022, 8:13am
3
Hello @traian.vila , any news from the team ? It’s a real blocker here, and I suppose it’ll be a blocker for all the Rust devs community.
Yes, we will address this, no ETA yet but I’ll make sure that our team is aware of the urgency. Thanks !
1 Like
hi @jblock , this should be fixed.
1 Like
jblock
January 25, 2022, 2:32pm
6
It is indeed working fine now !
GG, thanks !
1 Like