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

Refactor ccip launcher to mirror on chain state(CCIP-2687) #15065

Merged
merged 16 commits into from
Nov 4, 2024

Conversation

0xAustinWang
Copy link
Contributor

@0xAustinWang 0xAustinWang commented Nov 1, 2024

https://smartcontract-it.atlassian.net/browse/CCIP-2687

This PR in chainlink-ccip must be merged first: smartcontractkit/chainlink-ccip#285

Refactors the way we handle the launcher logic for ccip. Rather than managing state transitions in here, we just rely on the capability registry smart contract to manage the state.

What that means for us is that we simply need to read current state from the capability registry, and apply it by shutting down oracles that previously existed but no longer exist, and starting oracles that now exist but did not previously exist.

The code here is changed on two levels

  • DON level in launcher.go
    -- DON management is handled in launcher.go/processDiff, where we need to perform certain actions when a don is created, deleted, or updated
    -- This level manages the creation of Oracles, but not the starting and shutting down of oracles
  • Oracle level in deployment.go
    -- Oracle management is handled really basically by deployment.go/Transition.
    -- This level manages the Start and Stop of Oracle instances

@0xAustinWang 0xAustinWang changed the title Ccip/launcher refactor Refactor ccip launcher to mirror on chain state Nov 1, 2024
Copy link
Contributor

github-actions bot commented Nov 1, 2024

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

Copy link
Contributor

github-actions bot commented Nov 1, 2024

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@0xAustinWang 0xAustinWang changed the title Refactor ccip launcher to mirror on chain state Refactor ccip launcher to mirror on chain state(CCIP-2687) Nov 1, 2024
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/launcher.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/launcher.go Outdated Show resolved Hide resolved
@0xAustinWang 0xAustinWang force-pushed the ccip/launcherRefactor branch from 784d3fe to 907c251 Compare November 1, 2024 10:43
Copy link
Contributor

@makramkd makramkd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just needs some unit tests 👍

go.mod Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/launcher.go Outdated Show resolved Hide resolved
@0xAustinWang 0xAustinWang marked this pull request as ready for review November 1, 2024 15:07
@0xAustinWang 0xAustinWang requested review from a team as code owners November 1, 2024 15:07
@0xAustinWang 0xAustinWang force-pushed the ccip/launcherRefactor branch from 9477792 to 9fc3236 Compare November 4, 2024 01:32
Copy link
Contributor

@makramkd makramkd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to address lint errors + run make gomodtidy from the root CL directory to update all mod files

core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/launcher.go Show resolved Hide resolved
@0xAustinWang 0xAustinWang requested a review from a team as a code owner November 4, 2024 08:54
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
core/capabilities/ccip/launcher/deployment.go Outdated Show resolved Hide resolved
// This shuts down instances that were present previously, but are no longer needed
for digest, oracle := range prevPlugins {
if _, ok := c[digest]; !ok {
err = multierr.Append(err, oracle.Close())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I believe we could close them in parallel to get some performance boost.

Also maybe it's easier to use sets i.e. mapset for figuring out which oracles needs to be closed and which ones are new.

old = someSet()
new = someSet()

close = old - new 
open = new - old

Copy link
Contributor

@makramkd makramkd Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha interesting thing is that this set sub logic is mirrored in the diff code. Maybe needs a lib to unify 🤔

Copy link
Contributor

@jmank88 jmank88 Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to start and close in parallel.

In this situation since we have a max of 4 oracles only, i think using a mapset is unnecessary. We also key the oracles based on config digest, which would be less meaningful in a mapset.

core/capabilities/ccip/launcher/launcher.go Outdated Show resolved Hide resolved
@0xAustinWang 0xAustinWang added this pull request to the merge queue Nov 4, 2024
Merged via the queue into develop with commit e466f4f Nov 4, 2024
157 of 159 checks passed
@0xAustinWang 0xAustinWang deleted the ccip/launcherRefactor branch November 4, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants