Skip to content

Commit

Permalink
Consensus Separation: Separated GetPayload using an execution service (
Browse files Browse the repository at this point in the history
…#7933)

Miracoulously, hive tests pass first try. YIPPIE.

Also for the future, I added `--experimental.modular` which enables a
secondary engine API for consensus separation.

Now block building is responsibility of the execution module.
  • Loading branch information
Giulio2002 authored and AskAlexSharov committed Sep 6, 2023
1 parent 94fd17f commit 2c7cac9
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 402 deletions.
6 changes: 3 additions & 3 deletions cl/phase1/execution_client/execution_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/ledgerwatch/erigon/cl/cltypes"
"github.com/ledgerwatch/erigon/cl/phase1/execution_client/rpc_helper"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/turbo/engineapi"
"github.com/ledgerwatch/erigon/turbo/engineapi/engine_types"
)

const fcuTimeout = 12 * time.Second
Expand Down Expand Up @@ -155,7 +155,7 @@ func (ec *ExecutionClient) InsertBodies(bodies []*types.RawBody, blockHashes []l
BlockHash: gointerfaces.ConvertHashToH256(blockHashes[i]),
BlockNumber: blockNumbers[i],
Transactions: body.Transactions,
Withdrawals: engineapi.ConvertWithdrawalsToRpc(body.Withdrawals),
Withdrawals: engine_types.ConvertWithdrawalsToRpc(body.Withdrawals),
})
}
_, err := ec.client.InsertBodies(ec.ctx, &execution.InsertBodiesRequest{Bodies: grpcBodies})
Expand Down Expand Up @@ -246,6 +246,6 @@ func (ec *ExecutionClient) ReadBody(number uint64, blockHash libcommon.Hash) (*t
return &types.RawBody{
Transactions: resp.Body.Transactions,
Uncles: uncles,
Withdrawals: engineapi.ConvertWithdrawalsFromRpc(resp.Body.Withdrawals),
Withdrawals: engine_types.ConvertWithdrawalsFromRpc(resp.Body.Withdrawals),
}, nil
}
4 changes: 2 additions & 2 deletions cmd/erigon-el-mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ledgerwatch/erigon-lib/gointerfaces/execution"
types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/turbo/engineapi"
"github.com/ledgerwatch/erigon/turbo/engineapi/engine_types"
"github.com/ledgerwatch/erigon/turbo/services"

"github.com/ledgerwatch/erigon/core/rawdb"
Expand Down Expand Up @@ -201,7 +201,7 @@ func (e *Eth1Execution) GetBody(ctx context.Context, req *execution.GetSegmentRe
if err != nil {
return nil, err
}
rpcWithdrawals := engineapi.ConvertWithdrawalsToRpc(body.Withdrawals)
rpcWithdrawals := engine_types.ConvertWithdrawalsToRpc(body.Withdrawals)
unclesRpc := make([]*execution.Header, 0, len(body.Uncles))
for _, uncle := range body.Uncles {
unclesRpc = append(unclesRpc, HeaderToHeaderRPC(uncle))
Expand Down
6 changes: 4 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/ledgerwatch/erigon/turbo/builder"
"github.com/ledgerwatch/erigon/turbo/engineapi"
"github.com/ledgerwatch/erigon/turbo/engineapi/engine_helpers"
"github.com/ledgerwatch/erigon/turbo/execution/eth1"
"github.com/ledgerwatch/erigon/turbo/jsonrpc"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
Expand Down Expand Up @@ -568,15 +569,16 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
// intiialize engine backend
var engine *execution_client.ExecutionClientDirect

executionRpc := direct.NewExecutionClientDirect(eth1.NewEthereumExecutionModule(blockReader, chainKv, nil, backend.forkValidator, chainConfig, assembleBlockPOS, logger))
if config.ExperimentalConsensusSeparation {
log.Info("Using experimental Engine API")
engineBackendRPC := engineapi.NewEngineServerExperimental(ctx, logger, chainConfig, assembleBlockPOS, backend.chainDB, blockReader, backend.sentriesClient.Hd, config.Miner.EnabledPOS)
engineBackendRPC := engineapi.NewEngineServerExperimental(ctx, logger, chainConfig, executionRpc, backend.chainDB, blockReader, backend.sentriesClient.Hd, config.Miner.EnabledPOS)
backend.engineBackendRPC = engineBackendRPC
engine, err = execution_client.NewExecutionClientDirect(ctx,
engineBackendRPC,
)
} else {
engineBackendRPC := engineapi.NewEngineServer(ctx, logger, chainConfig, assembleBlockPOS, backend.chainDB, blockReader, backend.sentriesClient.Hd, config.Miner.EnabledPOS)
engineBackendRPC := engineapi.NewEngineServer(ctx, logger, chainConfig, executionRpc, backend.chainDB, blockReader, backend.sentriesClient.Hd, config.Miner.EnabledPOS)
backend.engineBackendRPC = engineBackendRPC
engine, err = execution_client.NewExecutionClientDirect(ctx,
engineBackendRPC,
Expand Down
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-20230723163836-9e08d02f75b8
github.com/ledgerwatch/erigon-lib v0.0.0-20230726204453-940c82dc2341
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 @@ -499,8 +499,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-20230723163836-9e08d02f75b8 h1:P8CdtNh0DDKhzTVnwuCQY1lg8Jn1N21nmSHGOl4Kjxo=
github.com/ledgerwatch/erigon-lib v0.0.0-20230723163836-9e08d02f75b8/go.mod h1:ZkH1giM9x/HgdvjWzeCiOIx2lLDo98T/uvmRkG6xet0=
github.com/ledgerwatch/erigon-lib v0.0.0-20230726204453-940c82dc2341 h1:uKE4wYKbBrzBdrEV7gB2hQZ+snGkMobooU6on1/MRpo=
github.com/ledgerwatch/erigon-lib v0.0.0-20230726204453-940c82dc2341/go.mod h1:k8pDfuQxOA2IJvgJVbw0iEmro2ri3jLUyDANMhPIbWk=
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
Loading

0 comments on commit 2c7cac9

Please sign in to comment.