-
Notifications
You must be signed in to change notification settings - Fork 23
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
Multicall rpc error check #64
Multicall rpc error check #64
Conversation
@jelias2 @danyalprout PTAL, will add unit tests if this approach makes sense |
proxyd/backend.go
Outdated
@@ -896,9 +897,11 @@ func (bg *BackendGroup) MulticallRequest(backend *Backend, rpcReqs []*RPCReq, wg | |||
} | |||
} | |||
|
|||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context) *BackendGroupRPCResponse { | |||
var finalResp *BackendGroupRPCResponse | |||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context, multicallRPCErrorCheck bool) *BackendGroupRPCResponse { |
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.
Isn't multicallRPCErrorCheck
a property on bg
? Probably don't need to pass it through
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.
yup make sense
proxyd/backend.go
Outdated
// check if any of the response is an RPC error | ||
var rpcError = false | ||
for _, rpcRes := range resp.RPCRes { | ||
// check if the ID is already in the success response |
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 think ID should be unique given it's part of the handleBatchRPC
flow. It's either the incoming message is a batch request (which should have unique IDs otherwise they wouldn't know how to process the response), or a single request.
@jelias2 would be good if you could help to confirm.
cc: @danyalprout
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.
Theres one key thing is that currently we don't allow batch requests in multicall at this point, so all IDs will be most likely 1
if bg.GetRoutingStrategy() == MulticallRoutingStrategy && isValidMulticallTx(rpcReqs) && !isBatch {
backendResp := bg.ExecuteMulticall(ctx, rpcReqs)
return backendResp.RPCRes, backendResp.ServedBy, backendResp.error
}
proxyd/backend.go
Outdated
@@ -896,9 +897,11 @@ func (bg *BackendGroup) MulticallRequest(backend *Backend, rpcReqs []*RPCReq, wg | |||
} | |||
} | |||
|
|||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context) *BackendGroupRPCResponse { | |||
var finalResp *BackendGroupRPCResponse | |||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context, multicallRPCErrorCheck bool) *BackendGroupRPCResponse { |
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.
yup make sense
proxyd/backend.go
Outdated
// add rpc error responses to success responses | ||
for id, rpcRes := range rpcResToCheck { | ||
if _, ok := successResp[id]; !ok { | ||
successResp[id] = rpcRes | ||
} | ||
} |
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.
Whats the goal here? Is it to add errored responses to the successful responses map that match the same ID?
If all the requests have a similar ID of 1, it may not work as intended
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.
Oh I see isValidMulticallTx()
now.
I think that should work then if it's just 1 request each time, it would just only go through the loop once per check.
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.
Just curious on the desired outcome/behvaior of this feature,
Given a request unique ID, does it intend to return the a success if it exists, otherwise it will return the error response.
If there is an error and a success for the same ID, will it overwrite the error with the success?
proxyd/backend.go
Outdated
@@ -896,9 +897,11 @@ func (bg *BackendGroup) MulticallRequest(backend *Backend, rpcReqs []*RPCReq, wg | |||
} | |||
} | |||
|
|||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context) *BackendGroupRPCResponse { | |||
var finalResp *BackendGroupRPCResponse | |||
func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx context.Context, multicallRPCErrorCheck bool) *BackendGroupRPCResponse { |
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.
Thoughts on making ProcessMulticallResponses and ProcessMulticallResponsesWithErrors two different functions?
@jelias2 sorry I should've made the PR description more clear. The motivation is that because we multicall However at proxyd level, an RPC error is not an actual error since it's still Let me know if the motivation makes sense |
So with this new design, what do you wish to return to the user if there is one success and one failure for the same request? If its all failures or all success, just return the appropriate success/failure Overall no qualms about the implementation, I would lean placing the processErrorMulticall in a separate function and clearly document the what the behavior is for the same request returned with different results |
if one success and one failure it'd return the success. |
@@ -931,6 +932,13 @@ func (bg *BackendGroup) ProcessMulticallResponses(ch chan *multicallTuple, ctx c | |||
finalResp = resp | |||
continue | |||
} | |||
|
|||
// Assuming multicall doesn't support batch | |||
if bg.multicallRPCErrorCheck && resp.RPCRes[0].IsError() { |
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.
@jelias2 is this ok? Assuming multicall doesn't support batch
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.
Correct multi-call assumes single rpc request, no batches allowed
proxyd/v4.10.0 includes the new changes |
Description
Add
bool
to have an option that for multiple success responses from multicall, choose the one that doesn't have rpc error.Tests
Added a unit test
Additional context
We observed that there are cases when different execution clients gave different responses, one with rpc success and one with rpc error, if the one with a rpc error returned first it'd return that. However in such case the rpc success one should be returned back to the user
Metadata