Skip to content
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

Removed GRPC layer from Engine API #7878

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
done
  • Loading branch information
Giulio2002 committed Jul 12, 2023
commit ca9054599d7645a104d495ef48a0ed905fc66ef2
3 changes: 1 addition & 2 deletions cl/phase1/execution_client/execution_client_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/gointerfaces/engine"
"github.com/ledgerwatch/erigon/cl/clparams"
"github.com/ledgerwatch/erigon/cl/cltypes"
"github.com/ledgerwatch/erigon/cl/phase1/execution_client/rpc_helper"
Expand Down Expand Up @@ -132,7 +131,7 @@ func (cc *ExecutionClientRpc) ForkChoiceUpdate(finalized libcommon.Hash, head li
SafeBlockHash: head,
FinalizedBlockHash: finalized,
}
forkChoiceResp := &engine.EngineForkChoiceUpdatedResponse{}
forkChoiceResp := &engine_types.ForkChoiceUpdatedResponse{}
log.Debug("[ExecutionClientRpc] Calling EL", "method", rpc_helper.ForkChoiceUpdatedV1)

err := cc.client.CallContext(cc.ctx, forkChoiceResp, rpc_helper.ForkChoiceUpdatedV1, forkChoiceRequest)
Expand Down
38 changes: 0 additions & 38 deletions cmd/rpcdaemon/rpcservices/engine_backend.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.19

require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230711075226-7764cf6d5583
github.com/ledgerwatch/erigon-lib v0.0.0-20230712010934-c5ae5e8b1baf
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2
github.com/ledgerwatch/log/v3 v3.8.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230711075226-7764cf6d5583 h1:nTaZdfIL4k7Bn6oq+zJUuRsVqCCKJmfyQ3DWOXedFUk=
github.com/ledgerwatch/erigon-lib v0.0.0-20230711075226-7764cf6d5583/go.mod h1:3+b/7PljXNCYYV0NrIwnYhj+Wh/9VewQdifSrkjbEd0=
github.com/ledgerwatch/erigon-lib v0.0.0-20230712010934-c5ae5e8b1baf h1:comImkESQq1O09Ady/T18lVeEZAcwbedB7YKGgojMCo=
github.com/ledgerwatch/erigon-lib v0.0.0-20230712010934-c5ae5e8b1baf/go.mod h1:LSJU3qNZELbklSKBDhigWPJEU/v9UI9SAJUA3b9v4d8=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2 h1:Ls2itRGHMOr2PbHRDA4g1HH8HQdwfJhRVfMPEaLQe94=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.8.0 h1:gCpp7uGtIerEz1jKVPeDnbIopFPud9ZnCpBLlLBGqPU=
Expand Down
114 changes: 48 additions & 66 deletions turbo/engineapi/engine_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package engineapi

import (
"context"
"math/big"
"testing"

"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon-lib/gointerfaces/engine"
types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/stretchr/testify/require"

"github.com/ledgerwatch/erigon/common/hexutil"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/turbo/engineapi/engine_types"
"github.com/ledgerwatch/erigon/turbo/stages/headerdownload"
Expand All @@ -29,53 +28,47 @@ var (

// Payloads
var (
mockPayload1 = &types2.ExecutionPayload{
ParentHash: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x2")),
BlockHash: gointerfaces.ConvertHashToH256(payload1Hash),
ReceiptRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x3")),
StateRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x4")),
PrevRandao: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
LogsBloom: gointerfaces.ConvertBytesToH2048(make([]byte, 256)),
ExtraData: make([]byte, 0),
BaseFeePerGas: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
mockPayload1 = &engine_types.ExecutionPayload{
ParentHash: libcommon.HexToHash("0x2"),
BlockHash: payload1Hash,
ReceiptsRoot: libcommon.HexToHash("0x3"),
StateRoot: libcommon.HexToHash("0x4"),
PrevRandao: libcommon.HexToHash("0x0b3"),
LogsBloom: make([]byte, 256),
BaseFeePerGas: (*hexutil.Big)(big.NewInt(0x0b3)),
BlockNumber: 100,
GasLimit: 52,
GasUsed: 4,
Timestamp: 4,
Coinbase: gointerfaces.ConvertAddressToH160(libcommon.HexToAddress("0x1")),
Transactions: make([][]byte, 0),
FeeRecipient: libcommon.HexToAddress("0x1"),
}
mockPayload2 = &types2.ExecutionPayload{
ParentHash: gointerfaces.ConvertHashToH256(payload1Hash),
BlockHash: gointerfaces.ConvertHashToH256(payload2Hash),
ReceiptRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x3")),
StateRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x4")),
PrevRandao: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
LogsBloom: gointerfaces.ConvertBytesToH2048(make([]byte, 256)),
ExtraData: make([]byte, 0),
BaseFeePerGas: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
mockPayload2 = &engine_types.ExecutionPayload{
ParentHash: payload1Hash,
BlockHash: payload2Hash,
ReceiptsRoot: libcommon.HexToHash("0x3"),
StateRoot: libcommon.HexToHash("0x4"),
PrevRandao: libcommon.HexToHash("0x0b3"),
LogsBloom: make([]byte, 256),
BaseFeePerGas: (*hexutil.Big)(big.NewInt(0x0b3)),
BlockNumber: 101,
GasLimit: 52,
GasUsed: 4,
Timestamp: 4,
Coinbase: gointerfaces.ConvertAddressToH160(libcommon.HexToAddress("0x1")),
Transactions: make([][]byte, 0),
FeeRecipient: libcommon.HexToAddress("0x1"),
}
mockPayload3 = &types2.ExecutionPayload{
ParentHash: gointerfaces.ConvertHashToH256(startingHeadHash),
BlockHash: gointerfaces.ConvertHashToH256(payload3Hash),
ReceiptRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x3")),
StateRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x4")),
PrevRandao: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
LogsBloom: gointerfaces.ConvertBytesToH2048(make([]byte, 256)),
ExtraData: make([]byte, 0),
BaseFeePerGas: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
mockPayload3 = &engine_types.ExecutionPayload{
ParentHash: startingHeadHash,
BlockHash: payload3Hash,
ReceiptsRoot: libcommon.HexToHash("0x3"),
StateRoot: libcommon.HexToHash("0x4"),
PrevRandao: libcommon.HexToHash("0x0b3"),
LogsBloom: make([]byte, 256),
BaseFeePerGas: (*hexutil.Big)(big.NewInt(0x0b3)),
BlockNumber: 51,
GasLimit: 52,
GasUsed: 4,
Timestamp: 4,
Coinbase: gointerfaces.ConvertAddressToH160(libcommon.HexToAddress("0x1")),
Transactions: make([][]byte, 0),
FeeRecipient: libcommon.HexToAddress("0x1"),
}
)

Expand All @@ -98,31 +91,31 @@ func TestMockDownloadRequest(t *testing.T) {
backend := NewEngineServer(ctx, logger, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, db, nil, hd, false)

var err error
var reply *engine.EnginePayloadStatus
var reply *engine_types.PayloadStatus
done := make(chan bool)

go func() {
reply, err = backend.EngineNewPayload(ctx, mockPayload1)
reply, err = backend.NewPayloadV1(ctx, mockPayload1)
done <- true
}()

hd.BeaconRequestList.WaitForRequest(true, false)
hd.PayloadStatusCh <- engine_types.PayloadStatus{Status: engine_types.SyncingStatus}
<-done
require.NoError(err)
require.Equal(reply.Status, engine.EngineStatus_SYNCING)
require.Equal(reply.Status, engine_types.SyncingStatus)
require.Nil(reply.LatestValidHash)

// If we get another request we don't need to process it with processDownloadCh and ignore it and return Syncing status
go func() {
reply, err = backend.EngineNewPayload(ctx, mockPayload2)
reply, err = backend.NewPayloadV1(ctx, mockPayload2)
done <- true
}()

<-done
// Same result as before
require.NoError(err)
require.Equal(reply.Status, engine.EngineStatus_SYNCING)
require.Equal(reply.Status, engine_types.SyncingStatus)
require.Nil(reply.LatestValidHash)

// However if we simulate that we finish reverse downloading the chain by updating the head, we just execute 1:1
Expand All @@ -132,14 +125,14 @@ func TestMockDownloadRequest(t *testing.T) {
_ = tx.Commit()
// Now we try to sync the next payload again
go func() {
reply, err = backend.EngineNewPayload(ctx, mockPayload2)
reply, err = backend.NewPayloadV1(ctx, mockPayload2)
done <- true
}()

<-done

require.NoError(err)
require.Equal(reply.Status, engine.EngineStatus_SYNCING)
require.Equal(reply.Status, engine_types.SyncingStatus)
require.Nil(reply.LatestValidHash)
}

Expand All @@ -157,11 +150,12 @@ func TestMockValidExecution(t *testing.T) {
backend := NewEngineServer(ctx, logger, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, db, nil, hd, false)

var err error
var reply *engine.EnginePayloadStatus
var reply *engine_types.PayloadStatus

done := make(chan bool)

go func() {
reply, err = backend.EngineNewPayload(ctx, mockPayload3)
reply, err = backend.NewPayloadV1(ctx, mockPayload3)
done <- true
}()

Expand All @@ -174,8 +168,8 @@ func TestMockValidExecution(t *testing.T) {
<-done

require.NoError(err)
require.Equal(reply.Status, engine.EngineStatus_VALID)
replyHash := gointerfaces.ConvertH256ToHash(reply.LatestValidHash)
require.Equal(reply.Status, engine_types.ValidStatus)
replyHash := reply.LatestValidHash
require.Equal(replyHash[:], payload3Hash[:])
}

Expand All @@ -193,11 +187,11 @@ func TestMockInvalidExecution(t *testing.T) {
backend := NewEngineServer(ctx, logger, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, db, nil, hd, false)

var err error
var reply *engine.EnginePayloadStatus
var reply *engine_types.PayloadStatus
done := make(chan bool)

go func() {
reply, err = backend.EngineNewPayload(ctx, mockPayload3)
reply, err = backend.NewPayloadV1(ctx, mockPayload3)
done <- true
}()

Expand All @@ -210,8 +204,8 @@ func TestMockInvalidExecution(t *testing.T) {
<-done

require.NoError(err)
require.Equal(reply.Status, engine.EngineStatus_INVALID)
replyHash := gointerfaces.ConvertH256ToHash(reply.LatestValidHash)
require.Equal(reply.Status, engine_types.InvalidStatus)
replyHash := reply.LatestValidHash
require.Equal(replyHash[:], startingHeadHash[:])
}

Expand All @@ -232,21 +226,9 @@ func TestNoTTD(t *testing.T) {
done := make(chan bool)

go func() {
_, err = backend.EngineNewPayload(ctx, &types2.ExecutionPayload{
ParentHash: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x2")),
BlockHash: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0xe6a580606b065e08034dcd6eea026cfdcbd3b41918d98b41cb9bf797d0c27033")),
ReceiptRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x4")),
StateRoot: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x4")),
PrevRandao: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
LogsBloom: gointerfaces.ConvertBytesToH2048(make([]byte, 256)),
ExtraData: make([]byte, 0),
BaseFeePerGas: gointerfaces.ConvertHashToH256(libcommon.HexToHash("0x0b3")),
BlockNumber: 51,
GasLimit: 52,
GasUsed: 4,
Timestamp: 4,
Coinbase: gointerfaces.ConvertAddressToH160(libcommon.HexToAddress("0x1")),
Transactions: make([][]byte, 0),
_, err = backend.NewPayloadV1(ctx, &engine_types.ExecutionPayload{
BlockHash: libcommon.HexToHash("0x809f6ec0f4fff2bcbb83d1a0c82f59200c531a5e220c68dd9603b17485375c40"),
BaseFeePerGas: (*hexutil.Big)(big.NewInt(0x0b3)),
})
done <- true
}()
Expand Down
60 changes: 0 additions & 60 deletions turbo/engineapi/types.go

This file was deleted.

Loading