-
Notifications
You must be signed in to change notification settings - Fork 198
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
[SocketRegistry] get operator socket #863
Conversation
3bc6e95
to
baa2bbd
Compare
@@ -223,6 +222,15 @@ func (n *Node) Start(ctx context.Context) error { | |||
return fmt.Errorf("failed to register the operator: %w", err) | |||
} | |||
} else { | |||
registeredSocket, err := n.Transactor.GetOperatorSocket(ctx, n.Config.ID) | |||
// Error out if registration on-chain is a requirement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that we can replace indexed operator info after testing here?
1360bc8
to
f7c7d8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're adding these checks to ensure there's no discrepancy.
Are these check some temporary measure or going to stay here forever?
|
||
// check operator socket registration against the indexed state | ||
for operatorID, operatorInfo := range operators { | ||
socket, err := s.chainState.GetOperatorSocket(context.Background(), currentBlock, operatorID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this make extra N RPC calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there's no multicast call available from the contract unfortunately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pschork how often is scanOperatorsHostInfo
called? I believe we have some cronjob?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called every 12hrs, but the dataAPI is public, so anyone can call it on demand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 should we add authentication to this method so not everyone can call it? (for future improvement)
@@ -619,3 +640,9 @@ func (t *Reader) GetReservationWindow(ctx context.Context) (uint32, error) { | |||
// contract is not implemented yet | |||
return 0, nil | |||
} | |||
|
|||
func (t *Reader) GetOperatorSocket(ctx context.Context, operatorId core.OperatorID) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenever we call this, should we check if the string is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I don't think the check is necessary, we will return whatever the contract returns with an empty string. Although this is a local optimization we can make, if we expect the input operator id is ever empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm should we just place that check in this method? i.e. return error if result is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the result is empty, then the check against the expected operator socket would fail. Is there a reason we want to handle it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to check for empty string here
node/node.go
Outdated
registeredSocket, err := n.Transactor.GetOperatorSocket(ctx, n.Config.ID) | ||
// Error out if registration on-chain is a requirement | ||
if err != nil { | ||
n.Logger.Warn("failed to get operator socket: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warnf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
node/node.go
Outdated
n.Logger.Warn("failed to get operator socket: %w", err) | ||
} | ||
if registeredSocket != socket { | ||
n.Logger.Warn("registered socket %s does not match expected socket %s", registeredSocket, socket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warnf
I think the checks are temporary and should be removed once we are confident we don't need the indexed operator state for the socket |
dcca6c2
to
7714367
Compare
Why are these changes needed?
Check on-chain socket registry state with indexed operator info
Checks