diff --git a/cmd/rpcdaemon/commands/engine_api_test.go b/cmd/rpcdaemon/commands/engine_api_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a209b8469b661cb05c8c3c051ff6206191355c31 --- /dev/null +++ b/cmd/rpcdaemon/commands/engine_api_test.go @@ -0,0 +1,18 @@ +package commands + +import ( + "testing" + + "github.com/ledgerwatch/erigon-lib/gointerfaces" + "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" + "github.com/ledgerwatch/erigon/common" + "github.com/stretchr/testify/assert" +) + +// Test case for https://github.com/ethereum/execution-apis/pull/217 responses +func TestZeroLatestValidHash(t *testing.T) { + payloadStatus := remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})} + json := convertPayloadStatus(&payloadStatus) + assert.Equal(t, "INVALID", json["status"]) + assert.Equal(t, common.Hash{}, json["latestValidHash"]) +} diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 40b2689be6abc4b7eb6164391c0017e2eee507e1..bb2e639ca908a5b3dc96c2eb74425723380814fc 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -336,7 +336,7 @@ func (s *EthBackendServer) EngineNewPayloadV1(ctx context.Context, req *types2.E } if parentTd != nil && parentTd.Cmp(s.config.TerminalTotalDifficulty) < 0 { log.Warn("[NewPayload] TTD not reached yet", "height", header.Number, "hash", common.Hash(blockHash)) - return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: &types2.H256{}}, nil + return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})}, nil } tx.Rollback() @@ -456,7 +456,7 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r if td != nil && td.Cmp(s.config.TerminalTotalDifficulty) < 0 { log.Warn("[ForkChoiceUpdated] TTD not reached yet", "forkChoice", forkChoice) return &remote.EngineForkChoiceUpdatedReply{ - PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: &types2.H256{}}, + PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})}, }, nil }