Skip to content

Commit f64231a

Browse files
somnergyGiulio2002
andauthored
engineapi: Fix engine_getClientVersionV1 (erigontech#13358) (erigontech#13370)
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 erigontech#13358 --------- Co-authored-by: Giulio <[email protected]>
1 parent 22711fa commit f64231a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

turbo/engineapi/engine_api_methods.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,18 @@ func (e *EngineServer) GetClientVersionV1(ctx context.Context, callerVersion *en
159159
if callerVersion != nil {
160160
e.logger.Info("[GetClientVersionV1] Received request from" + callerVersion.String())
161161
}
162-
commitBytes := [4]byte{}
163-
c := []byte(params.GitCommit)
164-
if len(c) >= 4 {
165-
copy(commitBytes[:], c[0:4])
162+
commitString := params.GitCommit
163+
if len(commitString) >= 8 {
164+
commitString = commitString[:8]
165+
} else {
166+
commitString = "00000000" // shouldn't be triggered
166167
}
167168
result := make([]engine_types.ClientVersionV1, 1)
168169
result[0] = engine_types.ClientVersionV1{
169170
Code: params.ClientCode,
170171
Name: params.ClientName,
171-
Version: params.Version,
172-
Commit: commitBytes,
172+
Version: params.VersionWithCommit(params.GitCommit),
173+
Commit: "0x" + commitString,
173174
}
174175
return result, nil
175176
}

turbo/engineapi/engine_types/jsonrpc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ type GetPayloadResponse struct {
9393
}
9494

9595
type ClientVersionV1 struct {
96-
Code string `json:"code" gencodec:"required"`
97-
Name string `json:"name" gencodec:"required"`
98-
Version string `json:"version" gencodec:"required"`
99-
Commit [4]byte `json:"commit" gencodec:"required"`
96+
Code string `json:"code" gencodec:"required"`
97+
Name string `json:"name" gencodec:"required"`
98+
Version string `json:"version" gencodec:"required"`
99+
Commit string `json:"commit" gencodec:"required"`
100100
}
101101

102102
func (c ClientVersionV1) String() string {

0 commit comments

Comments
 (0)