Skip to content

Commit

Permalink
engineapi: Fix engine_getClientVersionV1 (#13358) (#13370)
Browse files Browse the repository at this point in the history
For specs:

https://github.com/ethereum/execution-apis/blob/main/src/engine/identification.md#engine_getclientversionv1

The issue earlier was in json marshalling of strings returned by CL
clients. Since Git commits are already hex, no need to further hexlify
the string.
The commit string here won't have "0x" prefix - that's contentious, but,
going by the example given in the spec.
The version string doesn't have size limits, hence extending it to what
we would be using otherwise.

Cherry pick #13358

---------

Co-authored-by: Giulio <[email protected]>
  • Loading branch information
somnathb1 and Giulio2002 authored Jan 10, 2025
1 parent 233b803 commit d486491
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions turbo/engineapi/engine_api_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,18 @@ func (e *EngineServer) GetClientVersionV1(ctx context.Context, callerVersion *en
if callerVersion != nil {
e.logger.Info("[GetClientVersionV1] Received request from" + callerVersion.String())
}
commitBytes := [4]byte{}
c := []byte(params.GitCommit)
if len(c) >= 4 {
copy(commitBytes[:], c[0:4])
commitString := params.GitCommit
if len(commitString) >= 8 {
commitString = commitString[:8]
} else {
commitString = "00000000" // shouldn't be triggered
}
result := make([]engine_types.ClientVersionV1, 1)
result[0] = engine_types.ClientVersionV1{
Code: params.ClientCode,
Name: params.ClientName,
Version: params.Version,
Commit: commitBytes,
Version: params.VersionWithCommit(params.GitCommit),
Commit: "0x" + commitString,
}
return result, nil
}
Expand Down
8 changes: 4 additions & 4 deletions turbo/engineapi/engine_types/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ type GetPayloadResponse struct {
}

type ClientVersionV1 struct {
Code string `json:"code" gencodec:"required"`
Name string `json:"name" gencodec:"required"`
Version string `json:"version" gencodec:"required"`
Commit [4]byte `json:"commit" gencodec:"required"`
Code string `json:"code" gencodec:"required"`
Name string `json:"name" gencodec:"required"`
Version string `json:"version" gencodec:"required"`
Commit string `json:"commit" gencodec:"required"`
}

func (c ClientVersionV1) String() string {
Expand Down

0 comments on commit d486491

Please sign in to comment.