-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Eth1 connections #10073
Merged
rauljordan
merged 11 commits into
prysmaticlabs:develop
from
michaelneuder:eth1-connections
Jan 14, 2022
Merged
Eth1 connections #10073
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
881be0c
Adding Eth1 connections data message to service definition
05bbf23
PoC implementation for ETH1 connections RPC
cfd760c
naming revisions
michaelneuder 7470b05
cleanup
michaelneuder 2cb0663
Merge branch 'develop' into eth1-connections
rauljordan 9a2fb3e
register powchain info fetcher
rauljordan 6cebbe1
regenerate protos
rauljordan 79ae079
gazelle Bazel
rauljordan 72bb618
fixing comments
michaelneuder 838d237
Merge branch 'develop' into eth1-connections
rauljordan 59f5dd2
merge fixes
rauljordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,10 @@ type ChainStartFetcher interface { | |
type ChainInfoFetcher interface { | ||
Eth2GenesisPowchainInfo() (uint64, *big.Int) | ||
IsConnectedToETH1() bool | ||
CurrentETH1Endpoint() string | ||
CurrentETH1ConnectionError() error | ||
ETH1Endpoints() []string | ||
ETH1ConnectionErrors() []error | ||
} | ||
|
||
// POWBlockFetcher defines a struct that can retrieve mainchain blocks. | ||
|
@@ -324,6 +328,37 @@ func (s *Service) IsConnectedToETH1() bool { | |
return s.connectedETH1 | ||
} | ||
|
||
// CurrentETH1Endpoint returns the URL of the current ETH1 endpoint. | ||
func (s *Service) CurrentETH1Endpoint() string { | ||
return s.cfg.currHttpEndpoint.Url | ||
} | ||
|
||
// CurrentETH1ConnectionError returns the error (if any) of the current connection. | ||
func (s *Service) CurrentETH1ConnectionError() error { | ||
_, _, err := s.dialETH1Nodes(s.cfg.currHttpEndpoint) | ||
return err | ||
} | ||
|
||
// ETH1Endpoints returns the slice of HTTP endpoint URLs (default is 0th element). | ||
func (s *Service) ETH1Endpoints() []string { | ||
var eps []string | ||
for _, ep := range s.cfg.httpEndpoints { | ||
eps = append(eps, ep.Url) | ||
} | ||
return eps | ||
} | ||
|
||
// ETH1ConnectionErrors returns a slice of errors for each HTTP endpoint. An error | ||
// of nil means the connection was successful. | ||
func (s *Service) ETH1ConnectionErrors() []error { | ||
var errs []error | ||
for _, ep := range s.cfg.httpEndpoints { | ||
_, _, err := s.dialETH1Nodes(ep) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing applies here |
||
errs = append(errs, err) | ||
} | ||
return errs | ||
} | ||
|
||
// DepositRoot returns the Merkle root of the latest deposit trie | ||
// from the ETH1.0 deposit contract. | ||
func (s *Service) DepositRoot() [32]byte { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package testutil | ||
|
||
import ( | ||
"math/big" | ||
) | ||
|
||
// MockGenesisTimeFetcher is a fake implementation of the powchain.ChainInfoFetcher | ||
type MockPOWChainInfoFetcher struct { | ||
CurrEndpoint string | ||
CurrError error | ||
Endpoints []string | ||
Errors []error | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) Eth2GenesisPowchainInfo() (uint64, *big.Int) { | ||
return uint64(0), &big.Int{} | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) IsConnectedToETH1() bool { | ||
return true | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) CurrentETH1Endpoint() string { | ||
return m.CurrEndpoint | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) CurrentETH1ConnectionError() error { | ||
return m.CurrError | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) ETH1Endpoints() []string { | ||
return m.Endpoints | ||
} | ||
|
||
func (m *MockPOWChainInfoFetcher) ETH1ConnectionErrors() []error { | ||
return m.Errors | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clients should be closed after we dial them otherwise there is a resource leak and the connection is
kept active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, totally missed this. thanks for addressing!