Skip to content

Commit d33b06f

Browse files
committed
introduce engine_exchangeCapabilities
1 parent 72fa9b7 commit d33b06f

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

cmd/rpcdaemon/commands/engine_api.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"math/big"
88

99
"github.com/holiman/uint256"
10+
"github.com/ledgerwatch/log/v3"
11+
1012
libcommon "github.com/ledgerwatch/erigon-lib/common"
1113
"github.com/ledgerwatch/erigon-lib/gointerfaces"
1214
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
1315
types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
1416
"github.com/ledgerwatch/erigon-lib/kv"
15-
"github.com/ledgerwatch/log/v3"
1617

1718
"github.com/ledgerwatch/erigon/common"
1819
"github.com/ledgerwatch/erigon/common/hexutil"
@@ -388,6 +389,47 @@ func (e *EngineImpl) GetPayloadBodiesByRangeV1(ctx context.Context, start uint64
388389
return convertExecutionPayloadV1(apiRes), nil
389390
}
390391

392+
var ourCapabilities = []string{
393+
"engine_forkchoiceUpdatedV1",
394+
"engine_forkchoiceUpdatedV2",
395+
"engine_newPayloadV1",
396+
"engine_newPayloadV2",
397+
"engine_getPayloadV1",
398+
"engine_getPayloadV2",
399+
"engine_exchangeTransitionConfigurationV1",
400+
"engine_getPayloadBodiesByHashV1",
401+
"engine_getPayloadBodiesByRangeV1",
402+
}
403+
404+
func (e *EngineImpl) ExchangeCapabilities(fromCl []string) []string {
405+
missingOurs := compareCapabilities(fromCl, ourCapabilities)
406+
missingCl := compareCapabilities(ourCapabilities, fromCl)
407+
408+
if len(missingCl) > 0 || len(missingOurs) > 0 {
409+
log.Debug("ExchangeCapabilities mismatches", "cl_unsupported", missingCl, "erigon_unsupported", missingOurs)
410+
}
411+
412+
return ourCapabilities
413+
}
414+
415+
func compareCapabilities(from []string, to []string) []string {
416+
result := make([]string, 0)
417+
for _, f := range from {
418+
found := false
419+
for _, t := range to {
420+
if f == t {
421+
found = true
422+
break
423+
}
424+
}
425+
if !found {
426+
result = append(result, f)
427+
}
428+
}
429+
430+
return result
431+
}
432+
391433
func convertExecutionPayloadV1(response *remote.EngineGetPayloadBodiesV1Response) []*ExecutionPayloadBodyV1 {
392434
result := make([]*ExecutionPayloadBodyV1, len(response.Bodies))
393435
for idx, body := range response.Bodies {

0 commit comments

Comments
 (0)