Skip to content

feat: restructure RPC service#710

Merged
aloknerurkar merged 25 commits intomainfrom
preconf-rpc.2
Jul 3, 2025
Merged

feat: restructure RPC service#710
aloknerurkar merged 25 commits intomainfrom
preconf-rpc.2

Conversation

@aloknerurkar
Copy link
Copy Markdown
Collaborator

@aloknerurkar aloknerurkar commented Jun 27, 2025

Describe your changes

  • Async transaction handling
  • Postgres Database integration instead of embedded DB
  • Add more RPC APIs
  • Added better unit tests for the transaction sending flow.

Issue ticket number and link

Fixes # (issue)

Checklist before requesting a review

  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation

@aloknerurkar aloknerurkar requested review from kant777 and shaspitz July 1, 2025 15:56
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aloknerurkar aloknerurkar merged commit 88ab9aa into main Jul 3, 2025
5 checks passed
@aloknerurkar aloknerurkar deleted the preconf-rpc.2 branch July 3, 2025 05:19
This was referenced Jul 15, 2025
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

Successfully merging this pull request may close these issues.

2 participants