polaris icon indicating copy to clipboard operation
polaris copied to clipboard

feat(txpool): Nonce cache

Open calbera opened this issue 1 year ago • 4 comments

similar, but simpler impl of #350

calbera avatar Apr 21 '23 21:04 calbera

@davidterpay just for ref

itsdevbear avatar Apr 21 '23 22:04 itsdevbear

Codecov Report

Merging #571 (ad16e90) into main (5bf5173) will decrease coverage by 0.69%. The diff coverage is 8.98%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #571      +/-   ##
==========================================
- Coverage   63.79%   63.11%   -0.69%     
==========================================
  Files         100      100              
  Lines        4259     4316      +57     
==========================================
+ Hits         2717     2724       +7     
- Misses       1444     1494      +50     
  Partials       98       98              
Impacted Files Coverage Δ
cosmos/x/evm/plugins/txpool/mempool/mempool.go 0.00% <0.00%> (ø)
cosmos/x/evm/plugins/txpool/plugin.go 0.00% <0.00%> (ø)
eth/core/chain_reader.go 0.00% <0.00%> (ø)
eth/core/chain_subscriber.go 0.00% <0.00%> (ø)
eth/core/state/statedb.go 56.25% <ø> (+1.14%) :arrow_up:
cosmos/x/evm/plugins/state/plugin.go 74.18% <50.00%> (-0.82%) :arrow_down:
cosmos/x/evm/keeper/host.go 100.00% <100.00%> (ø)
eth/core/state/journal/suicides.go 100.00% <100.00%> (ø)

codecov[bot] avatar Apr 22 '23 00:04 codecov[bot]

current version is the logic used by geth’s light client txpool. now have to support pending and queued txs from geths core txpool

calbera avatar Apr 22 '23 00:04 calbera

Light client doesn't support queued

itsdevbear avatar Apr 22 '23 00:04 itsdevbear

image Also adding support for the .Error check, I think we should do this (as Geth does) whenever accessing anything that could have caused an error (nonce, balance specifically)

calbera avatar Apr 25 '23 18:04 calbera

Also we are now exposing the state plugin to be read from multiple threads, so do we need to lock there?

calbera avatar Apr 25 '23 19:04 calbera

This PR should just introduce read-only changes, namely enabling RPC methods: GetPoolNonce, SubscribeNewTxsEvent

calbera avatar Apr 25 '23 21:04 calbera

@corduroybera can u make ticket bls

itsdevbear avatar Apr 27 '23 12:04 itsdevbear

So I don’t think we need to merge this one. Implementing it via geth’s txpool provides more features and more testing, we just have to configure it correctly

calbera avatar Apr 27 '23 13:04 calbera

I still think that approach is hood, but if you can find a way to make it seamless I'm on board.

If anything we should build a wrapper that lives in the eth folder.

itsdevbear avatar Apr 27 '23 14:04 itsdevbear

I was originally doing a wrapper in eth/core/ but I realized there’s no need for it. It works without the wrapper. Either you have the geth TxPool in the blockchain object or you have the plug-in import it directly. The former involves ugly duplication of state

calbera avatar Apr 27 '23 14:04 calbera

Here its in the blockchain: https://github.com/berachain/polaris/pull/580/files#diff-732b1d3ebcc7a1ce9c153310d8f40fbd45cbc54b72627b3d298727e6643cf318

Here is the (unused) wrapper PolarisTxPool: https://github.com/berachain/polaris/pull/580/files#diff-f2bae00423d965dd5d83cb38ea73ba24ca6560730a3b1abc828ffa9eec2f441b

calbera avatar Apr 27 '23 14:04 calbera