Compare commits

...

60 Commits

Author SHA1 Message Date
terence tsao
bfdf0d3431 Merge branch 'kiln' of github.com:prysmaticlabs/prysm into kilnv2 2022-03-01 07:26:17 -08:00
terence tsao
229bd11c2b Merge branch 'kiln' of github.com:prysmaticlabs/prysm into kilnv2 2022-03-01 07:23:25 -08:00
terence tsao
7c55873f14 Update optimistic_sync.go 2022-02-28 06:59:22 -08:00
terence tsao
0db72dd544 Merge branch 'kiln' of github.com:prysmaticlabs/prysm into kilnv2 2022-02-28 06:50:58 -08:00
terence tsao
869dbe879f 1 2022-02-25 16:47:22 -08:00
terence tsao
e24da83fdb Merge branch 'renaming-randao' of github.com:prysmaticlabs/prysm into kilnv2 2022-02-25 16:17:40 -08:00
terence tsao
ac489d6a37 Merge branch 'use-transition-config' of github.com:prysmaticlabs/prysm into kilnv2 2022-02-25 16:15:29 -08:00
terence tsao
c67ec565f2 1 2022-02-25 16:15:20 -08:00
Raul Jordan
d84bef06bb incorrect prev randao 2022-02-25 16:52:02 -05:00
Raul Jordan
a54ea2c0f1 Merge branch 'develop' into use-transition-config 2022-02-25 19:17:42 +00:00
prylabs-bulldozer[bot]
1343f15408 Merge refs/heads/develop into renaming-randao 2022-02-25 19:08:46 +00:00
Raul Jordan
ba8cd91f05 bt 2022-02-25 13:59:46 -05:00
Raul Jordan
b508f4f84f bazel builds 2022-02-25 13:56:41 -05:00
Raul Jordan
7d1a870370 random name changes 2022-02-25 13:51:26 -05:00
Raul Jordan
2da580feb4 fix randao 2022-02-25 13:48:05 -05:00
Raul Jordan
892fac2f91 regen ssz 2022-02-25 12:46:53 -06:00
Raul Jordan
ad6eace10e regen 2022-02-25 12:46:22 -06:00
Raul Jordan
914693661c p header 2022-02-25 13:43:37 -05:00
Raul Jordan
1fa03923ca rename proto 2022-02-25 13:42:51 -05:00
Raul Jordan
a4edcd4cee gaz 2022-02-24 16:40:48 -05:00
Raul Jordan
6bdad1ac78 test 2022-02-24 16:35:22 -05:00
Raul Jordan
8df44db9e8 Merge branch 'develop' into use-transition-config 2022-02-24 20:09:02 +00:00
Raul Jordan
21e074406e Merge branch 'use-transition-config' of github.com:prysmaticlabs/prysm into use-transition-config 2022-02-24 12:06:49 -05:00
Raul Jordan
b26b001f7c err config check 2022-02-24 12:06:45 -05:00
Raul Jordan
9cf048c718 Merge branch 'develop' into use-transition-config 2022-02-24 16:29:57 +00:00
Raul Jordan
0e7835ee65 build 2022-02-24 11:22:55 -05:00
Raul Jordan
f9c319e95f gazelle 2022-02-24 11:20:35 -05:00
Raul Jordan
ca58ed9228 simplify status 2022-02-24 11:10:09 -05:00
Raul Jordan
ee81c0bdff fix up error handling and healthz 2022-02-24 11:08:30 -05:00
Raul Jordan
3c5045ae95 Merge branch 'develop' into use-transition-config 2022-02-24 09:26:59 -05:00
Raul Jordan
132810a622 Merge branch 'develop' into use-transition-config 2022-02-22 16:36:23 +00:00
Raul Jordan
e4b1005a5f Merge branch 'develop' into use-transition-config 2022-02-16 02:47:51 +00:00
Raul Jordan
aaca0dd4ee redundant 2022-02-15 21:47:44 -05:00
Raul Jordan
a20eec266b Merge branch 'use-transition-config' of github.com:prysmaticlabs/prysm into use-transition-config 2022-02-15 20:06:49 -05:00
Raul Jordan
046af2053a pass 2022-02-15 20:06:38 -05:00
Raul Jordan
2af5098f20 gaz 2022-02-15 19:04:35 -06:00
Raul Jordan
81212d3d87 conf 2022-02-15 20:04:20 -05:00
Raul Jordan
7367d711d8 check transition config in background 2022-02-15 19:28:32 -05:00
Raul Jordan
302b7fe953 check config differences 2022-02-15 19:27:39 -05:00
Raul Jordan
3dd6f5e56b check transition config 2022-02-15 19:07:19 -05:00
Raul Jordan
f5bc15445f gaz 2022-02-15 16:16:33 -06:00
Raul Jordan
56779cec58 Merge branch 'develop' into transition-config 2022-02-15 22:02:03 +00:00
Raul Jordan
9a1c310c26 rem log 2022-02-15 17:01:53 -05:00
Raul Jordan
86e2fd1c2d Merge branch 'transition-config' of github.com:prysmaticlabs/prysm into transition-config 2022-02-15 15:44:53 -05:00
Raul Jordan
657a239549 set to 0 2022-02-15 15:44:48 -05:00
Raul Jordan
83cb33e351 pb 2022-02-15 14:37:54 -06:00
Raul Jordan
1c86935ab7 fix up 2022-02-15 15:37:11 -05:00
Raul Jordan
791404541e client test 2022-02-15 15:15:32 -05:00
Raul Jordan
3d937297c4 config 2022-02-15 15:09:38 -05:00
Raul Jordan
5212bbbd8c gaz 2022-02-15 14:05:12 -06:00
Raul Jordan
5b615a7cf1 Merge branch 'develop' into transition-config 2022-02-15 20:05:01 +00:00
Raul Jordan
07e526c86c passing 2022-02-15 15:03:47 -05:00
Raul Jordan
444cf9309b use str 2022-02-15 13:51:01 -06:00
Raul Jordan
ea790c60f3 amend proto 2022-02-15 14:48:35 -05:00
Raul Jordan
b907c0f942 transition config messed up 2022-02-14 21:42:59 -05:00
Raul Jordan
eb07967a1b begin tests 2022-02-14 21:30:26 -05:00
Raul Jordan
224ec06cdc impl transition config 2022-02-14 21:12:56 -05:00
Raul Jordan
0f2a69f597 builds 2022-02-14 20:52:13 -05:00
Raul Jordan
3230787a62 gen pb 2022-02-14 19:45:15 -06:00
Raul Jordan
6d6eb6ca5b transition proto 2022-02-14 20:43:50 -05:00
16 changed files with 258 additions and 37 deletions

View File

@@ -30,8 +30,8 @@ func (*mockEngineService) GetPayload(context.Context, [8]byte) (*enginev1.Execut
return nil, nil
}
func (*mockEngineService) ExchangeTransitionConfiguration(context.Context, *enginev1.TransitionConfiguration) (*enginev1.TransitionConfiguration, error) {
return nil, nil
func (*mockEngineService) ExchangeTransitionConfiguration(context.Context, *enginev1.TransitionConfiguration) error {
return nil
}
func (*mockEngineService) LatestExecutionBlock(context.Context) (*enginev1.ExecutionBlock, error) {

View File

@@ -52,7 +52,7 @@ func WithChainStartFetcher(f powchain.ChainStartFetcher) Option {
}
// WithExecutionEngineCaller to call execution engine.
func WithExecutionEngineCaller(c v1.EngineCaller) Option {
func WithExecutionEngineCaller(c v1.Caller) Option {
return func(s *Service) error {
s.cfg.ExecutionEngineCaller = c
return nil

View File

@@ -85,7 +85,7 @@ type config struct {
WeakSubjectivityCheckpt *ethpb.Checkpoint
BlockFetcher powchain.POWBlockFetcher
FinalizedStateAtStartUp state.BeaconState
ExecutionEngineCaller enginev1.EngineCaller
ExecutionEngineCaller enginev1.Caller
}
// NewService instantiates a new block service instance that will

View File

@@ -5,6 +5,7 @@ go_library(
srcs = [
"block_cache.go",
"block_reader.go",
"check_transition_config.go",
"deposit.go",
"log.go",
"log_processing.go",
@@ -44,6 +45,7 @@ go_library(
"//monitoring/tracing:go_default_library",
"//network:go_default_library",
"//network/authorization:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//time:go_default_library",
"//time/slots:go_default_library",
@@ -54,6 +56,7 @@ go_library(
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
"@com_github_ethereum_go_ethereum//ethclient:go_default_library",
"@com_github_ethereum_go_ethereum//rpc:go_default_library",
"@com_github_holiman_uint256//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
@@ -69,6 +72,7 @@ go_test(
srcs = [
"block_cache_test.go",
"block_reader_test.go",
"check_transition_config_test.go",
"deposit_test.go",
"init_test.go",
"log_processing_test.go",
@@ -87,6 +91,8 @@ go_test(
"//beacon-chain/core/signing:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//beacon-chain/powchain/engine-api-client/v1:go_default_library",
"//beacon-chain/powchain/engine-api-client/v1/mocks:go_default_library",
"//beacon-chain/powchain/testing:go_default_library",
"//beacon-chain/powchain/types:go_default_library",
"//beacon-chain/state/stategen:go_default_library",

View File

@@ -0,0 +1,82 @@
package powchain
import (
"context"
"errors"
"math/big"
"time"
"github.com/holiman/uint256"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
"github.com/prysmaticlabs/prysm/config/params"
pb "github.com/prysmaticlabs/prysm/proto/engine/v1"
)
var (
checkTransitionPollingInterval = time.Second * 10
configMismatchLog = "Configuration mismatch between your execution client and Prysm. " +
"Please check your execution client and restart it with the proper configuration. If this is not done, " +
"your node will not be able to complete the proof-of-stake transition"
)
// Checks the transition configuration between Prysm and the connected execution node to ensure
// there are no differences in terminal block difficulty and block hash.
// If there are any discrepancies, we must log errors to ensure users can resolve
//the problem and be ready for the merge transition.
func (s *Service) checkTransitionConfiguration(ctx context.Context) {
if s.engineAPIClient == nil {
return
}
i := new(big.Int)
i.SetString(params.BeaconConfig().TerminalTotalDifficulty, 10)
ttd := new(uint256.Int)
ttd.SetFromBig(i)
cfg := &pb.TransitionConfiguration{
TerminalTotalDifficulty: ttd.Hex(),
TerminalBlockHash: params.BeaconConfig().TerminalBlockHash[:],
TerminalBlockNumber: big.NewInt(0).Bytes(), // A value of 0 is recommended in the request.
}
err := s.engineAPIClient.ExchangeTransitionConfiguration(ctx, cfg)
if err != nil {
if errors.Is(err, v1.ErrConfigMismatch) {
log.WithError(err).Fatal(configMismatchLog)
}
log.WithError(err).Error("Could not check configuration values between execution and consensus client")
}
// We poll the execution client to see if the transition configuration has changed.
// This serves as a heartbeat to ensure the execution client and Prysm are ready for the
// Bellatrix hard-fork transition.
ticker := time.NewTicker(checkTransitionPollingInterval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
err = s.engineAPIClient.ExchangeTransitionConfiguration(ctx, cfg)
s.handleExchangeConfigurationError(err)
}
}
}
// We check if there is a configuration mismatch error between the execution client
// and the Prysm beacon node. If so, we need to log errors in the node as it cannot successfully
// complete the merge transition for the Bellatrix hard fork.
func (s *Service) handleExchangeConfigurationError(err error) {
if err == nil {
// If there is no error in checking the exchange configuration error, we clear
// the run error of the service if we had previously set it to ErrConfigMismatch.
if errors.Is(s.runError, v1.ErrConfigMismatch) {
s.runError = nil
}
return
}
// If the error is a configuration mismatch, we set a runtime error in the service.
if errors.Is(err, v1.ErrConfigMismatch) {
s.runError = err
log.WithError(err).Error(configMismatchLog)
return
}
log.WithError(err).Error("Could not check configuration values between execution and consensus client")
}

View File

@@ -0,0 +1,59 @@
package powchain
import (
"context"
"errors"
"testing"
"time"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
"github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1/mocks"
"github.com/prysmaticlabs/prysm/testing/require"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func Test_checkTransitionConfiguration(t *testing.T) {
ctx := context.Background()
hook := logTest.NewGlobal()
m := &mocks.EngineClient{}
m.Err = errors.New("something went wrong")
srv := &Service{}
srv.engineAPIClient = m
checkTransitionPollingInterval = time.Millisecond
ctx, cancel := context.WithCancel(ctx)
go srv.checkTransitionConfiguration(ctx)
<-time.After(100 * time.Millisecond)
cancel()
require.LogsContain(t, hook, "Could not check configuration values")
}
func TestService_handleExchangeConfigurationError(t *testing.T) {
hook := logTest.NewGlobal()
t.Run("clears existing service error", func(t *testing.T) {
srv := &Service{isRunning: true}
srv.runError = v1.ErrConfigMismatch
srv.handleExchangeConfigurationError(nil)
require.Equal(t, true, srv.Status() == nil)
})
t.Run("does not clear existing service error if wrong kind", func(t *testing.T) {
srv := &Service{isRunning: true}
err := errors.New("something else went wrong")
srv.runError = err
srv.handleExchangeConfigurationError(nil)
require.ErrorIs(t, err, srv.Status())
})
t.Run("sets service error on config mismatch", func(t *testing.T) {
srv := &Service{isRunning: true}
srv.handleExchangeConfigurationError(v1.ErrConfigMismatch)
require.Equal(t, v1.ErrConfigMismatch, srv.Status())
require.LogsContain(t, hook, configMismatchLog)
})
t.Run("does not set service error if unrelated problem", func(t *testing.T) {
srv := &Service{isRunning: true}
srv.handleExchangeConfigurationError(errors.New("foo"))
require.Equal(t, true, srv.Status() == nil)
require.LogsContain(t, hook, "Could not check configuration values")
})
}

View File

@@ -14,6 +14,7 @@ go_library(
"//config/params:go_default_library",
"//proto/engine/v1:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_ethereum_go_ethereum//rpc:go_default_library",
"@com_github_golang_jwt_jwt_v4//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
@@ -28,6 +29,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//beacon-chain/powchain/engine-api-client/v1/mocks:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//encoding/bytesutil:go_default_library",

View File

@@ -12,6 +12,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/config/params"
@@ -42,9 +43,9 @@ type ForkchoiceUpdatedResponse struct {
PayloadId *pb.PayloadIDBytes `json:"payloadId"`
}
// EngineCaller defines a client that can interact with an Ethereum
// Caller defines a client that can interact with an Ethereum
// execution node's engine service via JSON-RPC.
type EngineCaller interface {
type Caller interface {
NewPayload(ctx context.Context, payload *pb.ExecutionPayload) ([]byte, error)
ForkchoiceUpdated(
ctx context.Context, state *pb.ForkchoiceState, attrs *pb.PayloadAttributes,
@@ -52,7 +53,7 @@ type EngineCaller interface {
GetPayload(ctx context.Context, payloadId [8]byte) (*pb.ExecutionPayload, error)
ExchangeTransitionConfiguration(
ctx context.Context, cfg *pb.TransitionConfiguration,
) (*pb.TransitionConfiguration, error)
) error
LatestExecutionBlock(ctx context.Context) (*pb.ExecutionBlock, error)
ExecutionBlockByHash(ctx context.Context, hash common.Hash) (*pb.ExecutionBlock, error)
}
@@ -155,35 +156,39 @@ func (c *Client) GetPayload(ctx context.Context, payloadId [8]byte) (*pb.Executi
// ExchangeTransitionConfiguration calls the engine_exchangeTransitionConfigurationV1 method via JSON-RPC.
func (c *Client) ExchangeTransitionConfiguration(
ctx context.Context, cfg *pb.TransitionConfiguration,
) (*pb.TransitionConfiguration, error) {
) error {
// We set terminal block number to 0 as the parameter is not set on the consensus layer.
zeroBigNum := big.NewInt(0)
cfg.TerminalBlockNumber = zeroBigNum.Bytes()
result := &pb.TransitionConfiguration{}
if err := c.rpc.CallContext(ctx, result, ExchangeTransitionConfigurationMethod, cfg); err != nil {
return nil, handleRPCError(err)
return handleRPCError(err)
}
// We surface an error to the user if local configuration settings mismatch
// according to the response from the execution node.
cfgTerminalHash := params.BeaconConfig().TerminalBlockHash[:]
if !bytes.Equal(cfgTerminalHash, result.TerminalBlockHash) {
return nil, errors.Wrapf(
ErrMismatchTerminalBlockHash,
return errors.Wrapf(
ErrConfigMismatch,
"got %#x from execution node, wanted %#x",
result.TerminalBlockHash,
cfgTerminalHash,
)
}
ttdCfg := params.BeaconConfig().TerminalTotalDifficulty
if ttdCfg != result.TerminalTotalDifficulty {
return nil, errors.Wrapf(
ErrMismatchTerminalTotalDiff,
ttdResult, err := hexutil.DecodeBig(result.TerminalTotalDifficulty)
if err != nil {
return errors.Wrap(err, "could not decode received terminal total difficulty")
}
if ttdResult.String() != ttdCfg {
return errors.Wrapf(
ErrConfigMismatch,
"got %s from execution node, wanted %s",
result.TerminalTotalDifficulty,
ttdResult.String(),
ttdCfg,
)
}
return result, nil
return nil
}
// LatestExecutionBlock fetches the latest execution engine block by calling

View File

@@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1/mocks"
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
"github.com/prysmaticlabs/prysm/config/params"
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
@@ -22,7 +23,10 @@ import (
"google.golang.org/protobuf/proto"
)
var _ = EngineCaller(&Client{})
var (
_ = Caller(&Client{})
_ = Caller(&mocks.EngineClient{})
)
func TestClient_IPC(t *testing.T) {
server := newTestIPCServer(t)
@@ -62,9 +66,8 @@ func TestClient_IPC(t *testing.T) {
t.Run(ExchangeTransitionConfigurationMethod, func(t *testing.T) {
want, ok := fix["TransitionConfiguration"].(*pb.TransitionConfiguration)
require.Equal(t, true, ok)
resp, err := client.ExchangeTransitionConfiguration(ctx, want)
err := client.ExchangeTransitionConfiguration(ctx, want)
require.NoError(t, err)
require.DeepEqual(t, want, resp)
})
t.Run(ExecutionBlockByNumberMethod, func(t *testing.T) {
want, ok := fix["ExecutionBlock"].(*pb.ExecutionBlock)
@@ -371,9 +374,8 @@ func TestClient_HTTP(t *testing.T) {
client.rpc = rpcClient
// We call the RPC method via HTTP and expect a proper result.
resp, err := client.ExchangeTransitionConfiguration(ctx, want)
err = client.ExchangeTransitionConfiguration(ctx, want)
require.NoError(t, err)
require.DeepEqual(t, want, resp)
})
t.Run(ExecutionBlockByHashMethod, func(t *testing.T) {
arg := common.BytesToHash([]byte("foo"))
@@ -449,8 +451,8 @@ func TestExchangeTransitionConfiguration(t *testing.T) {
client := &Client{}
client.rpc = rpcClient
_, err = client.ExchangeTransitionConfiguration(ctx, request)
require.Equal(t, true, errors.Is(err, ErrMismatchTerminalBlockHash))
err = client.ExchangeTransitionConfiguration(ctx, request)
require.Equal(t, true, errors.Is(err, ErrConfigMismatch))
})
t.Run("wrong terminal total difficulty", func(t *testing.T) {
request, ok := fix["TransitionConfiguration"].(*pb.TransitionConfiguration)
@@ -482,8 +484,8 @@ func TestExchangeTransitionConfiguration(t *testing.T) {
client := &Client{}
client.rpc = rpcClient
_, err = client.ExchangeTransitionConfiguration(ctx, request)
require.Equal(t, true, errors.Is(err, ErrMismatchTerminalTotalDiff))
err = client.ExchangeTransitionConfiguration(ctx, request)
require.Equal(t, true, errors.Is(err, ErrConfigMismatch))
})
}

View File

@@ -21,6 +21,9 @@ var (
ErrUnknownPayloadStatus = errors.New("unknown payload status")
// ErrUnsupportedScheme for unsupported URL schemes.
ErrUnsupportedScheme = errors.New("unsupported url scheme, only http(s) and ipc are supported")
// ErrConfigMismatch when the execution node's terminal total difficulty or
// terminal block hash received via the API mismatches Prysm's configuration value.
ErrConfigMismatch = errors.New("execution client configuration mismatch")
// ErrMismatchTerminalBlockHash when the terminal block hash value received via
// the API mismatches Prysm's configuration value.
ErrMismatchTerminalBlockHash = errors.New("terminal block hash mismatch")

View File

@@ -0,0 +1,12 @@
load("@prysm//tools/go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["client.go"],
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1/mocks",
visibility = ["//visibility:public"],
deps = [
"//proto/engine/v1:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
],
)

View File

@@ -0,0 +1,50 @@
package mocks
import (
"context"
"github.com/ethereum/go-ethereum/common"
pb "github.com/prysmaticlabs/prysm/proto/engine/v1"
)
// EngineClient --
type EngineClient struct {
NewPayloadResp []byte
PayloadIDBytes *pb.PayloadIDBytes
ForkChoiceUpdatedResp []byte
ExecutionPayload *pb.ExecutionPayload
Err error
ExecutionBlock *pb.ExecutionBlock
}
// NewPayload --
func (e *EngineClient) NewPayload(_ context.Context, _ *pb.ExecutionPayload) ([]byte, error) {
return e.NewPayloadResp, nil
}
// ForkchoiceUpdated --
func (e *EngineClient) ForkchoiceUpdated(
_ context.Context, _ *pb.ForkchoiceState, _ *pb.PayloadAttributes,
) (*pb.PayloadIDBytes, []byte, error) {
return e.PayloadIDBytes, e.ForkChoiceUpdatedResp, nil
}
// GetPayload --
func (e *EngineClient) GetPayload(_ context.Context, _ [8]byte) (*pb.ExecutionPayload, error) {
return e.ExecutionPayload, nil
}
// ExchangeTransitionConfiguration --
func (e *EngineClient) ExchangeTransitionConfiguration(_ context.Context, _ *pb.TransitionConfiguration) error {
return e.Err
}
// LatestExecutionBlock --
func (e *EngineClient) LatestExecutionBlock(_ context.Context) (*pb.ExecutionBlock, error) {
return e.ExecutionBlock, nil
}
// ExecutionBlockByHash --
func (e *EngineClient) ExecutionBlockByHash(_ context.Context, _ common.Hash) (*pb.ExecutionBlock, error) {
return e.ExecutionBlock, nil
}

View File

@@ -157,7 +157,7 @@ type Service struct {
headTicker *time.Ticker
httpLogger bind.ContractFilterer
eth1DataFetcher RPCDataFetcher
engineAPIClient *engine.Client
engineAPIClient engine.Caller
rpcClient RPCClient
headerCache *headerCache // cache to store block hash/block height.
latestEth1Data *ethpb.LatestETH1Data
@@ -217,6 +217,9 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) {
return nil, errors.Wrap(err, "unable to initialize engine API client")
}
// Check transition configuration for the engine API client in the background.
go s.checkTransitionConfiguration(ctx)
if err := s.ensureValidPowchainData(ctx); err != nil {
return nil, errors.Wrap(err, "unable to validate powchain data")
}
@@ -299,15 +302,12 @@ func (s *Service) Status() error {
return nil
}
// get error from run function
if s.runError != nil {
return s.runError
}
return nil
return s.runError
}
// EngineAPIClient returns the associated engine API client to interact
// with an execution node via JSON-RPC.
func (s *Service) EngineAPIClient() *engine.Client {
func (s *Service) EngineAPIClient() engine.Caller {
return s.engineAPIClient
}

View File

@@ -129,7 +129,7 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot) (*en
}
p := &enginev1.PayloadAttributes{
Timestamp: uint64(t.Unix()),
Random: random,
PrevRandao: random,
SuggestedFeeRecipient: params.BeaconConfig().FeeRecipient.Bytes(),
}
payloadID, _, err := vs.ExecutionEngineCaller.ForkchoiceUpdated(ctx, f, p)
@@ -267,7 +267,7 @@ func emptyPayload() *enginev1.ExecutionPayload {
StateRoot: make([]byte, fieldparams.RootLength),
ReceiptsRoot: make([]byte, fieldparams.RootLength),
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
Random: make([]byte, fieldparams.RootLength),
PrevRandao: make([]byte, fieldparams.RootLength),
BaseFeePerGas: make([]byte, fieldparams.RootLength),
BlockHash: make([]byte, fieldparams.RootLength),
}

View File

@@ -23,7 +23,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
enginev1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
"github.com/prysmaticlabs/prysm/config/params"
@@ -64,7 +64,7 @@ type Server struct {
PendingDepositsFetcher depositcache.PendingDepositsFetcher
OperationNotifier opfeed.Notifier
StateGen stategen.StateManager
ExecutionEngineCaller v1.EngineCaller
ExecutionEngineCaller enginev1.Caller
BeaconDB db.HeadAccessDatabase
}

View File

@@ -26,7 +26,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/operations/voluntaryexits"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
v1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
enginev1 "github.com/prysmaticlabs/prysm/beacon-chain/powchain/engine-api-client/v1"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/beacon"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/debug"
"github.com/prysmaticlabs/prysm/beacon-chain/rpc/eth/events"
@@ -109,7 +109,7 @@ type Config struct {
OperationNotifier opfeed.Notifier
StateGen *stategen.State
MaxMsgSize int
ExecutionEngineCaller v1.EngineCaller
ExecutionEngineCaller enginev1.Caller
}
// NewService instantiates a new RPC service instance that will