feat: restructure RPC service#710
Conversation
f1ed7d8 to
5b054c7
Compare
| GetTransactionCommitments(ctx context.Context, txnHash common.Hash) ([]*bidderapiv1.Commitment, error) | ||
| GetBalance(ctx context.Context, account common.Address) (*big.Int, error) | ||
| AddBalance(ctx context.Context, account common.Address, amount *big.Int) error | ||
| GetCurrentNonce(ctx context.Context, account common.Address) uint64 |
There was a problem hiding this comment.
This would return a cached nonce from the db right? For nonces, seems it'd be safer to always obtain them via query to the eth node
There was a problem hiding this comment.
This will only return cached nonce if there are queued transactions for the user. If there are no queued transactions it proxies the RPC to the underlying L1 RPC.
| server.RegisterHandler("eth_getBlockNumber", h.handleGetBlockNumber) | ||
| server.RegisterHandler("eth_chainId", h.handleChainID) | ||
| server.RegisterHandler("eth_getBlockNumber", func(ctx context.Context, params ...any) (json.RawMessage, bool, error) { | ||
| blockNumber := h.blockTracker.LatestBlockNumber() |
There was a problem hiding this comment.
in blocktracker.go, the block number is polled every 500 ms. Our blocktime could be significantly shorter than this. So this rpc handler could return a block number that's 1,2,3 blocks behind etc. Imo we should poll more often in the block tracker, or use ws events instead
There was a problem hiding this comment.
This is polling L1 blocks not settlement chain blocks. The RPC is for L1 networks basically.
|
|
||
| // Wait for block number to be updated to confirm transaction. If failed | ||
| // we will retry the bid process till user cancels the operation | ||
| included, err := t.blockTracker.CheckTxnInclusion(ctx, txn.Hash(), result.blockNumber) |
There was a problem hiding this comment.
Seems like implementation of blockTracker.CheckTxnInclusion could be simplified. Instead of waiting for a block to be sealed, calling BlockByNumber, then iterating through every tx, we could just check eth_getTransactionReceipt
There was a problem hiding this comment.
This function is called only in the cases when we dont have enough commitments (if all providers didnt commit for opted in block) or if it is not opted in block and we got some commitments. The function essentially checks only the block which we bid on to see if we can find the transaction. getTransactionReceipt doesnt have block number param afaik. This is still a stand-in. There should potentially be more checks here, for eg querying relay to see if one of the providers that gave us the commitment actually built the block. For now its simply checks for block transactions.
Describe your changes
Issue ticket number and link
Fixes # (issue)
Checklist before requesting a review