Skip to content

Conversation

@buck54321
Copy link
Member

There are 2 options here

The (*rpcclient).bestHeader method was not optimized to reduce rpc calls. I've given two options to make it better.

  1. We don't need provide a block number to HeaderByNumber. The arg is a *big.Int and if we pass nil, it is parsed to "latest" which has a special meaning for geth. This is the first commit.
  2. The load of getting a header is large. We could still call BlockNumber, but only call HeaderByNumber if the tip height has changed. This is the second commit.

@chappjc
Copy link
Member

chappjc commented Feb 6, 2023

With #2105, I think we're good without the cache in the second commit.

I think your use of the nil arg in #2104 is good.

Seems like we already have all the bases covered in those.

@chappjc
Copy link
Member

chappjc commented Feb 6, 2023

Still, I don't see a problem with the cache commit. It could make the difference when RPCs really need to be light 🤷

@chappjc chappjc added this to the 0.6 milestone Feb 6, 2023
@buck54321
Copy link
Member Author

bestHeader is called once per market on startup via (Swapper).ChainsSynced -> (*baseBackend).Synced. It's also still called in FeeRate, but it's not clear to my why we even have that method on eth, since it's not really used by the feeFetcher. I guess just cause it's part of the Backend interface.

Anyway, no cache needed, I think. Closing.

@buck54321 buck54321 closed this Feb 8, 2023
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