-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump docs, add TODOs for buggy behavior (#15023)
- Loading branch information
Showing
7 changed files
with
125 additions
and
52 deletions.
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
Binary file not shown.
Binary file not shown.
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,18 @@ | ||
// Package launcher provides the functionality to launch and manage OCR instances. | ||
// For system-level documentation and diagrams, please refer to the README.md | ||
// in this package directory. | ||
// | ||
// The CCIP launcher, at a high level, consumes updates from the Capabilities Registry, | ||
// in particular, DON additions, updates, and removals, and depending on the changes, | ||
// launches (in the case of additions and updates) or shuts down (in the case of removals) | ||
// CCIP OCR instances. | ||
// | ||
// It achieves this by diffing the current state of the registry with the previous state, | ||
// and then launching or shutting down instances as necessary. See the launcher's tick() | ||
// method for the main logic. | ||
// | ||
// Diffing logic is contained within diff.go, and the main logic for launching and shutting | ||
// down instances is contained within launcher.go. | ||
// | ||
// Active/candidate deployment support is provided by the ccipDeployment struct in deployment.go. | ||
package launcher |
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 |
---|---|---|
|
@@ -29,16 +29,17 @@ var ( | |
_ registrysyncer.Launcher = (*launcher)(nil) | ||
) | ||
|
||
// New creates a new instance of the CCIP launcher. | ||
func New( | ||
capabilityID string, | ||
p2pID ragep2ptypes.PeerID, | ||
myP2PID ragep2ptypes.PeerID, | ||
lggr logger.Logger, | ||
homeChainReader ccipreader.HomeChain, | ||
tickInterval time.Duration, | ||
oracleCreator cctypes.OracleCreator, | ||
) *launcher { | ||
return &launcher{ | ||
p2pID: p2pID, | ||
myP2PID: myP2PID, | ||
capabilityID: capabilityID, | ||
lggr: lggr, | ||
homeChainReader: homeChainReader, | ||
|
@@ -57,8 +58,12 @@ func New( | |
type launcher struct { | ||
services.StateMachine | ||
|
||
capabilityID string | ||
p2pID ragep2ptypes.PeerID | ||
// capabilityID is the fully qualified capability registry ID of the CCIP capability. | ||
// this is <capability_name>@<capability-semver>, e.g "[email protected]". | ||
capabilityID string | ||
|
||
// myP2PID is the peer ID of the node running this launcher. | ||
myP2PID ragep2ptypes.PeerID | ||
lggr logger.Logger | ||
homeChainReader ccipreader.HomeChain | ||
stopChan chan struct{} | ||
|
@@ -129,6 +134,7 @@ func (l *launcher) Start(context.Context) error { | |
}) | ||
} | ||
|
||
// monitor calls tick() at regular intervals to check for changes in the capability registry. | ||
func (l *launcher) monitor() { | ||
defer l.wg.Done() | ||
ticker := time.NewTicker(l.tickInterval) | ||
|
@@ -144,6 +150,8 @@ func (l *launcher) monitor() { | |
} | ||
} | ||
|
||
// tick gets the latest registry state and processes the diff between the current and latest state. | ||
// This may lead to starting or stopping OCR instances. | ||
func (l *launcher) tick() error { | ||
// Ensure that the home chain reader is healthy. | ||
// For new jobs it may be possible that the home chain reader is not yet ready | ||
|
@@ -197,7 +205,7 @@ func (l *launcher) processUpdate(updated map[registrysyncer.DonID]registrysyncer | |
|
||
futDeployment, err := updateDON( | ||
l.lggr, | ||
l.p2pID, | ||
l.myP2PID, | ||
l.homeChainReader, | ||
*prevDeployment, | ||
don, | ||
|
@@ -231,24 +239,26 @@ func (l *launcher) processAdded(added map[registrysyncer.DonID]registrysyncer.DO | |
for donID, don := range added { | ||
dep, err := createDON( | ||
l.lggr, | ||
l.p2pID, | ||
l.myP2PID, | ||
l.homeChainReader, | ||
don, | ||
l.oracleCreator, | ||
) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("processAdded: call createDON %d: %w", donID, err) | ||
} | ||
if dep == nil { | ||
// not a member of this DON. | ||
continue | ||
} | ||
|
||
// TODO: this doesn't seem to be correct; a newly added DON will not have an active | ||
// instance but a candidate instance. | ||
if err := dep.StartActive(); err != nil { | ||
if shutdownErr := dep.CloseActive(); shutdownErr != nil { | ||
l.lggr.Errorw("Failed to shutdown active instance after failed start", "donId", donID, "err", shutdownErr) | ||
} | ||
return fmt.Errorf("failed to start oracles for CCIP DON %d: %w", donID, err) | ||
return fmt.Errorf("processAdded: start oracles for CCIP DON %d: %w", donID, err) | ||
} | ||
|
||
// update state. | ||
|
@@ -314,26 +324,24 @@ func updateDON( | |
don.ID, err) | ||
} | ||
|
||
commitBgd, err := createFutureActiveCandidateDeployment(don.ID, prevDeployment, commitOCRConfigs, oracleCreator, cctypes.PluginTypeCCIPCommit) | ||
commitAcd, err := createFutureActiveCandidateDeployment(don.ID, prevDeployment, commitOCRConfigs, oracleCreator, cctypes.PluginTypeCCIPCommit) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create future active-candidate deployment for CCIP commit plugin: %w, don id: %d", err, don.ID) | ||
} | ||
|
||
execBgd, err := createFutureActiveCandidateDeployment(don.ID, prevDeployment, execOCRConfigs, oracleCreator, cctypes.PluginTypeCCIPExec) | ||
execAcd, err := createFutureActiveCandidateDeployment(don.ID, prevDeployment, execOCRConfigs, oracleCreator, cctypes.PluginTypeCCIPExec) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create future active-candidate deployment for CCIP exec plugin: %w, don id: %d", err, don.ID) | ||
} | ||
|
||
return &ccipDeployment{ | ||
commit: commitBgd, | ||
exec: execBgd, | ||
commit: commitAcd, | ||
exec: execAcd, | ||
}, nil | ||
} | ||
|
||
// valid cases: | ||
// a) len(ocrConfigs) == 2 && !prevDeployment.HasCandidateInstance(pluginType): this is a new candidate instance. | ||
// b) len(ocrConfigs) == 1 && prevDeployment.HasCandidateInstance(): this is a promotion of candidate->active. | ||
// All other cases are invalid. This is enforced in the ccip config contract. | ||
// TODO: this is not technically correct, CCIPHome has other transitions | ||
// that are not covered here, e.g revokeCandidate. | ||
func createFutureActiveCandidateDeployment( | ||
donID uint32, | ||
prevDeployment ccipDeployment, | ||
|
@@ -344,13 +352,13 @@ func createFutureActiveCandidateDeployment( | |
var deployment activeCandidateDeployment | ||
if isNewCandidateInstance(pluginType, ocrConfigs, prevDeployment) { | ||
// this is a new candidate instance. | ||
greenOracle, err := oracleCreator.Create(donID, cctypes.OCR3ConfigWithMeta(ocrConfigs[1])) | ||
candidateOracle, err := oracleCreator.Create(donID, cctypes.OCR3ConfigWithMeta(ocrConfigs[1])) | ||
if err != nil { | ||
return activeCandidateDeployment{}, fmt.Errorf("failed to create CCIP commit oracle: %w", err) | ||
} | ||
|
||
deployment.active = prevDeployment.commit.active | ||
deployment.candidate = greenOracle | ||
deployment.candidate = candidateOracle | ||
} else if isPromotion(pluginType, ocrConfigs, prevDeployment) { | ||
// this is a promotion of candidate->active. | ||
deployment.active = prevDeployment.commit.candidate | ||
|
@@ -409,6 +417,7 @@ func createDON( | |
return nil, fmt.Errorf("failed to create CCIP exec oracle: %w", err) | ||
} | ||
|
||
// TODO: incorrect, should be setting candidate? | ||
return &ccipDeployment{ | ||
commit: activeCandidateDeployment{ | ||
active: commitOracle, | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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