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

Remove Execution Client Fallback and Make Providing an Execution Client Required #10921

Merged
merged 33 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4efee0f
Starting
terencechain Jun 22, 2022
237d083
Merge branch 'develop' of github.com:prysmaticlabs/prysm into rm-eth1…
terencechain Jul 25, 2022
94fe46e
Done
terencechain Jul 25, 2022
d4e4926
Merge branch 'develop' into rm-eth1-fallback
terencechain Jul 25, 2022
298db67
Fix more tests
terencechain Jul 25, 2022
23f0244
Merge branch 'rm-eth1-fallback' of github.com:prysmaticlabs/prysm int…
terencechain Jul 25, 2022
aa8ac90
Fix test
terencechain Jul 26, 2022
d01d423
Fix test
terencechain Jul 26, 2022
9175053
fix confs
rauljordan Aug 11, 2022
b37a27e
fix up
rauljordan Aug 11, 2022
1edebb7
building
rauljordan Aug 11, 2022
c54e221
requirement
rauljordan Aug 11, 2022
dcc6945
gaz
rauljordan Aug 11, 2022
f250c98
builds
rauljordan Aug 11, 2022
7352f3f
rem deadcode
rauljordan Aug 11, 2022
b1ddc7d
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 11, 2022
6fc56e5
fix
rauljordan Aug 11, 2022
d76681c
Merge branch 'rm-eth1-fallback' of github.com:prysmaticlabs/prysm int…
rauljordan Aug 11, 2022
32a2aae
fix up
rauljordan Aug 11, 2022
3313121
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 11, 2022
8e9d8da
sync up
rauljordan Aug 15, 2022
4cbc6d9
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
e7df490
removed checked method
rauljordan Aug 15, 2022
418e028
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
4536229
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
59516bc
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
1a72ca4
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
5dde8a2
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
08b7e93
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 15, 2022
06810da
Merge branch 'develop' into rm-eth1-fallback
nisdas Aug 16, 2022
db082e0
Update service_test.go
terencechain Aug 16, 2022
24294b4
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 16, 2022
4722c98
Merge branch 'develop' into rm-eth1-fallback
rauljordan Aug 16, 2022
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
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func setupBeaconChain(t *testing.T, beaconDB db.Database) *Service {
web3Service, err = execution.NewService(
ctx,
execution.WithDatabase(beaconDB),
execution.WithHttpEndpoints([]string{endpoint}),
execution.WithHttpEndpoint(endpoint),
execution.WithDepositContractAddress(common.Address{}),
)
require.NoError(t, err, "Unable to set up web3 service")
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/execution/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ go_test(
"//crypto/bls:go_default_library",
"//encoding/bytesutil:go_default_library",
"//monitoring/clientstats:go_default_library",
"//network:go_default_library",
"//network/authorization:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
Expand Down
20 changes: 10 additions & 10 deletions beacon-chain/execution/block_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestLatestMainchainInfo_OK(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
)
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestBlockHashByHeight_ReturnsHash(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestBlockHashByHeight_ReturnsError_WhenNoEth1Client(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand All @@ -132,7 +132,7 @@ func TestBlockExists_ValidHash(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestBlockExists_InvalidHash(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand All @@ -187,7 +187,7 @@ func TestBlockExists_UsesCachedBlockInfo(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestService_BlockNumberByTimestamp(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err)
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestService_BlockNumberByTimestampLessTargetTime(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err)
Expand Down Expand Up @@ -287,7 +287,7 @@ func TestService_BlockNumberByTimestampMoreTargetTime(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err)
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestService_BlockTimeByHeight_ReturnsError_WhenNoEth1Client(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down
14 changes: 7 additions & 7 deletions beacon-chain/execution/deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestProcessDeposit_OK(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "Unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestProcessDeposit_InvalidMerkleBranch(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestProcessDeposit_InvalidPublicKey(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestProcessDeposit_InvalidSignature(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -203,7 +203,7 @@ func TestProcessDeposit_UnableToVerify(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestProcessDeposit_IncompleteDeposit(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestProcessDeposit_AllDepositedSuccessfully(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDatabase(beaconDB),
)
require.NoError(t, err, "unable to setup web3 ETH1.0 chain service")
Expand Down
16 changes: 8 additions & 8 deletions beacon-chain/execution/log_processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestProcessDepositLog_OK(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestProcessDepositLog_InsertsPendingDeposit(t *testing.T) {
})

web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestUnpackDepositLogData_OK(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
)
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) {
})

web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestProcessETH2GenesisLog(t *testing.T) {
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(beaconDB),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -392,7 +392,7 @@ func TestProcessETH2GenesisLog_CorrectNumOfDeposits(t *testing.T) {
})

web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(kvStore),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -490,7 +490,7 @@ func TestProcessETH2GenesisLog_LargePeriodOfNoLogs(t *testing.T) {
})

web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(testAcc.ContractAddr),
WithDatabase(kvStore),
WithDepositCache(depositCache),
Expand Down Expand Up @@ -602,7 +602,7 @@ func newPowchainService(t *testing.T, eth1Backend *mock.TestAccount, beaconDB db
server.Stop()
})
web3Service, err := NewService(context.Background(),
WithHttpEndpoints([]string{endpoint}),
WithHttpEndpoint(endpoint),
WithDepositContractAddress(eth1Backend.ContractAddr),
WithDatabase(beaconDB),
WithDepositCache(depositCache),
Expand Down
46 changes: 11 additions & 35 deletions beacon-chain/execution/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,31 @@ import (
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stategen"
"github.com/prysmaticlabs/prysm/v3/network"
"github.com/prysmaticlabs/prysm/v3/network/authorization"
)

type Option func(s *Service) error

// WithHttpEndpoints deduplicates and parses http endpoints for the execution chain service to use,
// and sets the "current" endpoint that will be used first.
func WithHttpEndpoints(endpointStrings []string) Option {
// WithHttpEndpoint parse http endpoint for the powchain service to use.
func WithHttpEndpoint(endpointString string) Option {
return func(s *Service) error {
stringEndpoints := dedupEndpoints(endpointStrings)
endpoints := make([]network.Endpoint, len(stringEndpoints))
for i, e := range stringEndpoints {
endpoints[i] = HttpEndpoint(e)
}
// Select first http endpoint in the provided list.
var currEndpoint network.Endpoint
if len(endpointStrings) > 0 {
currEndpoint = endpoints[0]
}
s.cfg.httpEndpoints = endpoints
s.cfg.currHttpEndpoint = currEndpoint
s.cfg.currHttpEndpoint = HttpEndpoint(endpointString)
return nil
}
}

// WithHttpEndpointsAndJWTSecret for authenticating the execution node JSON-RPC endpoint.
func WithHttpEndpointsAndJWTSecret(endpointStrings []string, secret []byte) Option {
// WithHttpEndpointAndJWTSecret for authenticating the execution node JSON-RPC endpoint.
func WithHttpEndpointAndJWTSecret(endpointString string, secret []byte) Option {
return func(s *Service) error {
if len(secret) == 0 {
return nil
}
stringEndpoints := dedupEndpoints(endpointStrings)
endpoints := make([]network.Endpoint, len(stringEndpoints))
// Overwrite authorization type for all endpoints to be of a bearer
// type.
for i, e := range stringEndpoints {
hEndpoint := HttpEndpoint(e)
hEndpoint.Auth.Method = authorization.Bearer
hEndpoint.Auth.Value = string(secret)
endpoints[i] = hEndpoint
}
// Select first http endpoint in the provided list.
var currEndpoint network.Endpoint
if len(endpointStrings) > 0 {
currEndpoint = endpoints[0]
}
s.cfg.httpEndpoints = endpoints
s.cfg.currHttpEndpoint = currEndpoint
// Overwrite authorization type for all endpoints to be of a bearer type.
hEndpoint := HttpEndpoint(endpointString)
hEndpoint.Auth.Method = authorization.Bearer
hEndpoint.Auth.Value = string(secret)

s.cfg.currHttpEndpoint = hEndpoint
return nil
}
}
Expand Down
42 changes: 3 additions & 39 deletions beacon-chain/execution/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ type BeaconNodeStatsUpdater interface {
}

type PowchainCollector struct {
SyncEth1Connected *prometheus.Desc
SyncEth1FallbackConnected *prometheus.Desc
SyncEth1FallbackConfigured *prometheus.Desc // true if flag specified: --fallback-web3provider
updateChan chan clientstats.BeaconNodeStats
latestStats clientstats.BeaconNodeStats
SyncEth1Connected *prometheus.Desc
updateChan chan clientstats.BeaconNodeStats
latestStats clientstats.BeaconNodeStats
sync.Mutex
ctx context.Context
finishChan chan struct{}
Expand All @@ -38,8 +36,6 @@ func (pc *PowchainCollector) Update(update clientstats.BeaconNodeStats) {
// prometheus.Collector interface.
func (pc *PowchainCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- pc.SyncEth1Connected
ch <- pc.SyncEth1FallbackConfigured
ch <- pc.SyncEth1FallbackConnected
}

// Collect is invoked by the prometheus collection loop.
Expand All @@ -54,26 +50,6 @@ func (pc *PowchainCollector) Describe(ch chan<- *prometheus.Desc) {
func (pc *PowchainCollector) Collect(ch chan<- prometheus.Metric) {
bs := pc.getLatestStats()

var syncEth1FallbackConfigured float64 = 0
if bs.SyncEth1FallbackConfigured {
syncEth1FallbackConfigured = 1
}
ch <- prometheus.MustNewConstMetric(
pc.SyncEth1FallbackConfigured,
prometheus.GaugeValue,
syncEth1FallbackConfigured,
)

var syncEth1FallbackConnected float64 = 0
if bs.SyncEth1FallbackConnected {
syncEth1FallbackConnected = 1
}
ch <- prometheus.MustNewConstMetric(
pc.SyncEth1FallbackConnected,
prometheus.GaugeValue,
syncEth1FallbackConnected,
)

var syncEth1Connected float64 = 0
if bs.SyncEth1Connected {
syncEth1Connected = 1
Expand Down Expand Up @@ -120,18 +96,6 @@ func NewPowchainCollector(ctx context.Context) (*PowchainCollector, error) {
namespace := "powchain"
updateChan := make(chan clientstats.BeaconNodeStats, 2)
c := &PowchainCollector{
SyncEth1FallbackConfigured: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_fallback_configured"),
"Boolean recording whether a fallback eth1 endpoint was configured: 0=false, 1=true.",
nil,
nil,
),
SyncEth1FallbackConnected: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_fallback_connected"),
"Boolean indicating whether a fallback eth1 endpoint is currently connected: 0=false, 1=true.",
nil,
nil,
),
SyncEth1Connected: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sync_eth1_connected"),
"Boolean indicating whether an eth1 endpoint is currently connected: 0=false, 1=true.",
Expand Down
Loading