-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add support for engine_exchangeCapabilities #12224
Changes from 5 commits
28c830b
a449f79
a867df2
19daf8d
0761920
101c9f6
defa4b7
3b0b218
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,20 @@ import ( | |
"go.opencensus.io/trace" | ||
) | ||
|
||
var ( | ||
supportedEngineEndpoints = []string{ | ||
NewPayloadMethod, | ||
NewPayloadMethodV2, | ||
ForkchoiceUpdatedMethod, | ||
ForkchoiceUpdatedMethodV2, | ||
GetPayloadMethod, | ||
GetPayloadMethodV2, | ||
ExchangeTransitionConfigurationMethod, | ||
GetPayloadBodiesByHashV1, | ||
GetPayloadBodiesByRangeV1, | ||
} | ||
) | ||
|
||
const ( | ||
// NewPayloadMethod v1 request string for JSON-RPC. | ||
NewPayloadMethod = "engine_newPayloadV1" | ||
|
@@ -53,6 +67,8 @@ const ( | |
GetPayloadBodiesByHashV1 = "engine_getPayloadBodiesByHashV1" | ||
// GetPayloadBodiesByRangeV1 v1 request string for JSON-RPC. | ||
GetPayloadBodiesByRangeV1 = "engine_getPayloadBodiesByRangeV1" | ||
// ExchangeCapabilities request string for JSON-RPC. | ||
ExchangeCapabilities = "engine_exchangeCapabilities" | ||
// Defines the seconds before timing out engine endpoints with non-block execution semantics. | ||
defaultEngineTimeout = time.Second | ||
) | ||
|
@@ -278,6 +294,35 @@ func (s *Service) ExchangeTransitionConfiguration( | |
return nil | ||
} | ||
|
||
func (s *Service) ExchangeCapabilities(ctx context.Context) ([]string, error) { | ||
if !features.Get().EnableOptionalEngineMethods { | ||
return nil, errors.New("optional engine methods not enabled") | ||
} | ||
ctx, span := trace.StartSpan(ctx, "powchain.engine-api-client.ExchangeCapabilities") | ||
defer span.End() | ||
|
||
result := &pb.ExchangeCapabilities{} | ||
err := s.rpcClient.CallContext(ctx, &result, ExchangeCapabilities, supportedEngineEndpoints) | ||
|
||
var unsupported []string | ||
for _, s1 := range supportedEngineEndpoints { | ||
supported := false | ||
for _, s2 := range result.SupportedMethods { | ||
if s1 == s2 { | ||
supported = true | ||
break | ||
} | ||
} | ||
if !supported { | ||
unsupported = append(unsupported, s1) | ||
} | ||
} | ||
if len(unsupported) != 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A unit test checking the log would be nice |
||
log.Warnf("Please update, detected the following unsupported engine methods: %s", unsupported) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
return result.SupportedMethods, handleRPCError(err) | ||
} | ||
|
||
// GetTerminalBlockHash returns the valid terminal block hash based on total difficulty. | ||
// | ||
// Spec code: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 guess we should also include
ExchangeCapabilities
itself.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.
In the spec it says "The engine_exchangeCapabilities method MUST NOT be returned in the response list.". So I removed it from the list of our own supported ones as well.
Would it be better to include it?