Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

now fetching operatorId dynamically in economicCollector #54

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

samlaf
Copy link
Collaborator

@samlaf samlaf commented Oct 24, 2023

Motivation

eigenDA team was running into errors because the economicCollector was fetching operatorId from the eigenda registry coordinator in its constructor, which is initialized before the node starts. When the operator is registered at node start, it only registers in the start() function, which happens after, so the economicCollector never gets updated with the operatorId and hence keeps erroring on the collect call.

Solution

This PR moves fetching the operatorId into the collector. This adds 1 round trip latency to the node on every collect (every ~15sec), but at least this will fix this problem. Another solution might be to cache the operatorId after one of the collect calls gets the operatorId, but this could break if we later allow the operatorId to change.

Open questions

@samlaf samlaf force-pushed the samlaf/fix-economic-collector branch from b2bde68 to 7d096fb Compare October 24, 2023 03:11
Copy link

@jianoaix jianoaix left a comment

Choose a reason for hiding this comment

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

It looks reasonable to cache the operatorID, as it's something extremely rare (and difficult) to change?

for quorumIdx, quorumNum := range quorumNums {
// TODO: this is stupid.. when AVSs scale to have 5K operators we'll be running through a bunch of operators
// we should instead just call registryCoordinator.getQuorumBitmapIndicesByOperatorIdsAtBlockNumber
// and stakeRegistry.getStakeForOperatorIdForQuorumAtBlockNumber directly

Choose a reason for hiding this comment

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

Why don't we do these two per-operator fetches?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I was lazy at the time. Fixed: 858ae16

@samlaf samlaf force-pushed the samlaf/fix-economic-collector branch from 7d096fb to 973343f Compare October 24, 2023 18:24
@samlaf
Copy link
Collaborator Author

samlaf commented Oct 24, 2023

It looks reasonable to cache the operatorID, as it's something extremely rare (and difficult) to change?

changed to cache: 5b942b6
@shrimalmadhur @jianoaix should be good to go.

@@ -110,6 +108,17 @@ func (ec *Collector) Describe(ch chan<- *prometheus.Desc) {
// ch <- ec.delegatedShares
}

func (ec *Collector) cacheOperatorIdIfNotCached() error {
Copy link
Collaborator

@shrimalmadhur shrimalmadhur Oct 24, 2023

Choose a reason for hiding this comment

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

cacheOperatorIdIfNotCached - it's a weird name. don't cache already mean if some key is not present it would cache it? just cacheOperatorId should be a good name for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in this case because we only cache the very first time this is called. If it's already cached we don't update the cache.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe maybeCacheOperator? or cacheOperatorIfNeeded? feel free to find another name, but I don't think cacheOperatorId works

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to initOperatorId as we discussed on slack: fa42170

Choose a reason for hiding this comment

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

IMO just something like getOperatorID() will be good. The cache is internal detail/optimization that the caller doesn't need to care about.

shrimalmadhur
shrimalmadhur previously approved these changes Oct 24, 2023
@@ -110,6 +108,17 @@ func (ec *Collector) Describe(ch chan<- *prometheus.Desc) {
// ch <- ec.delegatedShares
}

func (ec *Collector) cacheOperatorIdIfNotCached() error {

Choose a reason for hiding this comment

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

IMO just something like getOperatorID() will be good. The cache is internal detail/optimization that the caller doesn't need to care about.

@samlaf samlaf merged commit 71ec295 into master Oct 25, 2023
3 checks passed
@samlaf samlaf deleted the samlaf/fix-economic-collector branch October 25, 2023 01:56
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.

3 participants