-
Notifications
You must be signed in to change notification settings - Fork 4k
op-node: Light CL: Follow Source using EL or CL #18500
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
Closed
pcw109550
wants to merge
9
commits into
pcw109550/light-cl-follow-source
from
pcw109550/light-cl-follow-source-el-cl
Closed
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4cd4247
op-node: Follow Source: EL / CL support
pcw109550 d8c37c6
devstack: Allow EL or CL to be follow source
pcw109550 67d1978
Inject CurrentL1
pcw109550 14631ae
logs for injecting CurrentL1
pcw109550 1496ff2
refactor to less rpc calls
pcw109550 5fbdfd8
acceptance-tests: Check CurrentL1 is advancing
pcw109550 3d50958
linter
pcw109550 d2a3d9a
fix error args
pcw109550 5a387a2
sanity check external values using L1
pcw109550 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,66 @@ | ||
| package sources | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-service/client" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| "github.com/ethereum-optimism/optimism/op-service/sources/caching" | ||
| "github.com/ethereum/go-ethereum/log" | ||
| ) | ||
|
|
||
| type FollowClient struct { | ||
| l2Client *L2Client | ||
| rollupClient *RollupClient | ||
| followCL bool | ||
| } | ||
|
|
||
| type FollowStatus struct { | ||
| SafeL2 eth.L2BlockRef | ||
| FinalizedL2 eth.L2BlockRef | ||
| CurrentL1 eth.L1BlockRef | ||
| } | ||
|
|
||
| func NewFollowClient(client client.RPC, log log.Logger, metrics caching.Metrics, config *L2ClientConfig) (*FollowClient, error) { | ||
| l2Client, err := NewL2Client(client, log, metrics, config) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create Eth client: %w", err) | ||
| } | ||
| rollupClient := NewRollupClient(client) | ||
| // Check the RPC is from CL | ||
| ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) | ||
| defer cancel() | ||
| _, err = rollupClient.SyncStatus(ctx) | ||
| followCL := err == nil | ||
| if followCL { | ||
| log.Info("FollowClient: Following CL") | ||
| } else { | ||
| log.Info("FollowClient: Following EL") | ||
| } | ||
| return &FollowClient{l2Client: l2Client, rollupClient: rollupClient, followCL: followCL}, nil | ||
| } | ||
|
|
||
| func (s *FollowClient) GetFollowStatus(ctx context.Context) (*FollowStatus, error) { | ||
| if s.followCL { | ||
| status, err := s.rollupClient.SyncStatus(ctx) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("Failed to fetch external syncStatus", "err", err) | ||
| } | ||
| return &FollowStatus{ | ||
| FinalizedL2: status.FinalizedL2, | ||
| SafeL2: status.SafeL2, | ||
| CurrentL1: status.CurrentL1, | ||
| }, nil | ||
| } | ||
| eFinalized, err := s.l2Client.L2BlockRefByLabel(ctx, eth.Finalized) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("Failed to fetch external finalizedRef", "err", err) | ||
| } | ||
| eSafe, err := s.l2Client.L2BlockRefByLabel(ctx, eth.Safe) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("Failed to fetch external safeRef", "err", err) | ||
| } | ||
| return &FollowStatus{FinalizedL2: eFinalized, SafeL2: eSafe}, nil | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.