Skip to content

Commit

Permalink
solana upgrade changeset (#16427)
Browse files Browse the repository at this point in the history
* try upgrade in CI

* update sha

* make gomodtidy

* try setting signer

* fix params

* set keypair to authority

* deploy same artifact

* revert gomod

* return ixns

* upgrade in place

* fix build

* lint

* bump gomod

* validate upgrades

* lint

* comments

* gomod

* fix merge

* lint

* lint

* cr comments

* lint

* lint

* lint

* move upgrades to mcms

* bump delay

* wip

* wip

* mcms fix

* log in CI

* preload first

* wip

* wip

* check bytes

* lint

* revert buffer

* use program data size

* add padding

* lint

* bubble mcms error

* Revert "bubble mcms error"

This reverts commit 334689d.
  • Loading branch information
tt-cll authored and krehermann committed Feb 27, 2025
1 parent 8dbac7b commit 8661467
Show file tree
Hide file tree
Showing 23 changed files with 995 additions and 189 deletions.
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ require (
github.com/smartcontractkit/chainlink-protos/rmn/v1.6/go v0.0.0-20250131130834-15e0d4cde2a6 // indirect
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112 // indirect
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250213203720-e15b1333a14a // indirect
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.7 // indirect
github.com/smartcontractkit/chainlink-testing-framework/framework v0.5.3 // indirect
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect
github.com/smartcontractkit/mcms v0.10.0 // indirect
github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20241009055228-33d0c0bf38de // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,8 @@ github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112/go.mod h1:TcOliTQU6r59DwG4lo3U+mFM9WWyBHGuFkkxQpvSujo=
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250213203720-e15b1333a14a h1:C+XavZQ0rBOpOrh45LUhdOsvtI8OQ0XZKI5pi+GP6h4=
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250213203720-e15b1333a14a/go.mod h1:aFm1QC/n99mVeBDtv0SE0co56+IECY6Y1fR3OfNYy3c=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.7 h1:E7k5Sym9WnMOc4X40lLnQb6BMosxi8DfUBU9pBJjHOQ=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.7/go.mod h1:WYxCxAWpeXEHfhB0GaiV2sj21Ooh9r/Nf7tzmJgAibs=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.5.3 h1:CeZqFz/si4YBnYE1118mtc4FBLs2Za1qohYAeLZTI+o=
github.com/smartcontractkit/chainlink-testing-framework/framework v0.5.3/go.mod h1:9b5ugzYeKkwbxZ9yMOoxUaPiONDLC/QLCncarDFnhwk=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.22 h1:W3doYLVoZN8VwJb/kAZsbDjW+6cgZPgNTcQHJUH9JrA=
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.22/go.mod h1:70JLBXQncNHyW63ik4PvPQGjQGZ1xK67MKrDanVAk2w=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
Expand Down
7 changes: 6 additions & 1 deletion deployment/ccip/changeset/solana/cs_add_remote_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,15 @@ func doAddRemoteChainToSolana(
}
}

addressLookupTable, err := cs.FetchOfframpLookupTable(e.GetContext(), chain, offRampID)
if err != nil {
return fmt.Errorf("failed to get offramp reference addresses: %w", err)
}

if err := solCommonUtil.ExtendLookupTable(
e.GetContext(),
chain.Client,
s.SolChains[chainSel].OfframpAddressLookupTable,
addressLookupTable,
*chain.DeployerKey,
lookUpTableEntries,
); err != nil {
Expand Down
14 changes: 12 additions & 2 deletions deployment/ccip/changeset/solana/cs_billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,15 @@ func AddBillingToken(e deployment.Environment, cfg BillingTokenConfig) (deployme
return deployment.ChangesetOutput{}, fmt.Errorf("failed to confirm instructions: %w", err)
}

addressLookupTable, err := cs.FetchOfframpLookupTable(e.GetContext(), chain, chainState.OffRamp)
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to get offramp reference addresses: %w", err)
}

if err := solCommonUtil.ExtendLookupTable(
e.GetContext(),
chain.Client,
chainState.OfframpAddressLookupTable,
addressLookupTable,
*chain.DeployerKey,
[]solana.PublicKey{tokenBillingPDA},
); err != nil {
Expand Down Expand Up @@ -170,10 +175,15 @@ func AddBillingTokenForRemoteChain(e deployment.Environment, cfg BillingTokenFor
return deployment.ChangesetOutput{}, fmt.Errorf("failed to confirm instructions: %w", err)
}

addressLookupTable, err := cs.FetchOfframpLookupTable(e.GetContext(), chain, chainState.OffRamp)
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to get offramp reference addresses: %w", err)
}

if err := solCommonUtil.ExtendLookupTable(
e.GetContext(),
chain.Client,
chainState.OfframpAddressLookupTable,
addressLookupTable,
*chain.DeployerKey,
[]solana.PublicKey{remoteBillingPDA},
); err != nil {
Expand Down
39 changes: 24 additions & 15 deletions deployment/ccip/changeset/solana/cs_build_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,32 @@ func runCommand(command string, args []string, workDir string) (string, error) {

// Clone and checkout the specific revision of the repo
func cloneRepo(e deployment.Environment, revision string) error {
// Remove the clone directory if it already exists
if _, err := os.Stat(cloneDir); !os.IsNotExist(err) {
os.RemoveAll(cloneDir)
}
// Check if the repository already exists
if _, err := os.Stat(filepath.Join(cloneDir, ".git")); err == nil {
e.Logger.Debugw("Repository already exists, discarding local changes and updating", "dir", cloneDir)

e.Logger.Debugw("Cloning repository", "url", repoURL, "revision", revision)
_, err := runCommand("git", []string{"clone", repoURL, cloneDir}, ".")
if err != nil {
return fmt.Errorf("failed to clone repository: %w", err)
// Discard any local changes
_, err := runCommand("git", []string{"reset", "--hard"}, cloneDir)
if err != nil {
return fmt.Errorf("failed to discard local changes: %w", err)
}

// Fetch the latest changes from the remote
_, err = runCommand("git", []string{"fetch", "origin"}, cloneDir)
if err != nil {
return fmt.Errorf("failed to fetch origin: %w", err)
}
} else {
// Repository does not exist, clone it
e.Logger.Debugw("Cloning repository", "url", repoURL, "revision", revision)
_, err := runCommand("git", []string{"clone", repoURL, cloneDir}, ".")
if err != nil {
return fmt.Errorf("failed to clone repository: %w", err)
}
}

e.Logger.Debugw("Checking out revision", "revision", revision)
_, err = runCommand("git", []string{"checkout", revision}, cloneDir)
_, err := runCommand("git", []string{"checkout", revision}, cloneDir)
if err != nil {
return fmt.Errorf("failed to checkout revision %s: %w", revision, err)
}
Expand Down Expand Up @@ -93,7 +106,6 @@ type BuildSolanaConfig struct {
ChainSelector uint64
GitCommitSha string
DestinationDir string
IsUpgrade bool
CleanDestinationDir bool
CreateDestinationDir bool
}
Expand All @@ -116,11 +128,8 @@ func BuildSolanaChangeset(e deployment.Environment, config BuildSolanaConfig) (d
return deployment.ChangesetOutput{}, fmt.Errorf("error cloning repo: %w", err)
}

// Upgrades don't need to generate keys, we upgrade the program in place
if !config.IsUpgrade {
if err := replaceKeys(e); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("error replacing keys: %w", err)
}
if err := replaceKeys(e); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("error replacing keys: %w", err)
}

// Build the project with Anchor
Expand Down
Loading

0 comments on commit 8661467

Please sign in to comment.