llamanodes / web3-proxy

Fast loadbalancing and caching proxy for Ethereum or chains with similar JSON-RPC methods
https://llamanodes.com
GNU General Public License v3.0
153 stars 34 forks source link

unable to save accounting entry! err=BadRequest("Could not find rpc key in db") #133

Closed BlinkyStitt closed 1 year ago

BlinkyStitt commented 1 year ago

I'm seeing a lot of this in ski's logs:

eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")
eth_1       | [2023-06-17T06:59:41Z ERROR web3_proxy::stats::stat_buffer] unable to save accounting entry! err=BadRequest("Could not find rpc key in db")

The revelant code:

        let sender_balance: balance::Model = balance::Entity::find()
            .filter(balance::Column::UserId.eq(sender_rpc_entity.user_id))
            .one(txn)
            .await?
            .ok_or(Web3ProxyError::BadRequest(
                "Could not find rpc key in db".into(),
            ))?;

Instead of erring with a bad request, I think we should create an empty balance row.

BlinkyStitt commented 1 year ago

fixed: https://github.com/llamanodes/web3-proxy/commit/2f78e64c5d94dad36c1f9d1de0fccaf46ed495ae