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

no padding + mcms #16511

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
18238ab
try upgrade in CI
tt-cll Feb 13, 2025
6cca0c8
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 13, 2025
fd07e4a
update sha
tt-cll Feb 13, 2025
2740026
make gomodtidy
tt-cll Feb 13, 2025
750c267
try setting signer
tt-cll Feb 13, 2025
dc7c4b5
fix params
tt-cll Feb 13, 2025
4197aac
set keypair to authority
tt-cll Feb 13, 2025
55de91e
deploy same artifact
tt-cll Feb 13, 2025
21c5043
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 13, 2025
937b0e9
revert gomod
tt-cll Feb 13, 2025
a39034e
return ixns
tt-cll Feb 15, 2025
1b7345e
upgrade in place
tt-cll Feb 15, 2025
9f3550b
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 15, 2025
6953d7a
fix build
tt-cll Feb 15, 2025
c97275e
lint
tt-cll Feb 15, 2025
9f31584
bump gomod
tt-cll Feb 15, 2025
ab47391
validate upgrades
tt-cll Feb 15, 2025
80202c5
lint
tt-cll Feb 15, 2025
8468bb4
comments
tt-cll Feb 17, 2025
c6b2475
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 17, 2025
07866dc
gomod
tt-cll Feb 17, 2025
f27eae6
fix merge
tt-cll Feb 18, 2025
02980fa
lint
tt-cll Feb 18, 2025
a23d140
lint
tt-cll Feb 18, 2025
74f835f
cr comments
tt-cll Feb 18, 2025
ab58af5
lint
tt-cll Feb 18, 2025
514651e
lint
tt-cll Feb 18, 2025
20ab5e4
lint
tt-cll Feb 18, 2025
814a3ba
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 18, 2025
798d06b
move upgrades to mcms
tt-cll Feb 18, 2025
4ac68ab
bump delay
tt-cll Feb 18, 2025
3a32ebc
wip
tt-cll Feb 19, 2025
8ca3f34
wip
tt-cll Feb 19, 2025
5d1cf7b
mcms fix
tt-cll Feb 19, 2025
8f2035f
log in CI
tt-cll Feb 19, 2025
66eea30
preload first
tt-cll Feb 19, 2025
e2261bf
Merge pull request #16465 from smartcontractkit/tt/mcms1
tt-cll Feb 19, 2025
639eb8d
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 19, 2025
93d29b3
wip
tt-cll Feb 20, 2025
ecc46ff
wip
tt-cll Feb 20, 2025
de3ae32
check bytes
tt-cll Feb 20, 2025
74d17e5
lint
tt-cll Feb 20, 2025
fabd20b
revert buffer
tt-cll Feb 20, 2025
b8cef56
Merge pull request #16493 from smartcontractkit/tt/extend
tt-cll Feb 21, 2025
2691c6b
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
tt-cll Feb 21, 2025
7e500ae
use program data size
tt-cll Feb 21, 2025
3a73a76
add padding
tt-cll Feb 21, 2025
077f354
no padding + mcms
tt-cll Feb 21, 2025
9a80c3c
no padding + mcms
tt-cll Feb 21, 2025
09bafb2
lint
tt-cll Feb 21, 2025
abdbce8
Merge branch 'tt/solanaUpgrades' into tt/shouldBreakMcms
tt-cll Feb 21, 2025
334689d
bubble mcms error
tt-cll Feb 21, 2025
6df6280
Merge remote-tracking branch 'origin/tt/solanaUpgrades' into tt/shoul…
tt-cll Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comments
  • Loading branch information
tt-cll committed Feb 17, 2025
commit 8468bb4dfc1bcb47e84d5c39dbab9dd025e62884
67 changes: 54 additions & 13 deletions deployment/ccip/changeset/solana/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,24 @@ func deployChainContractsSolana(
if err != nil {
return ixns, fmt.Errorf("failed to generate upgrade instruction: %w", err)
}
closeIxn, err := generateCloseBufferIxn(
&e,
bufferProgram,
config.UpgradeConfig.SpillAddress,
config.UpgradeConfig.UpgradeAuthority,
)
if err != nil {
return ixns, fmt.Errorf("failed to generate close buffer instruction: %w", err)
}
feeQuoterAddress = chainState.FeeQuoter
if config.UpgradeConfig.SignerKey != nil {
// if we're not using MCMS to upgrade, confirm txn with the signer key
if err := chain.Confirm([]solana.Instruction{upgradeIxn}, solCommonUtil.AddSigners(*config.UpgradeConfig.SignerKey)); err != nil {
if err := chain.Confirm([]solana.Instruction{upgradeIxn, closeIxn}, solCommonUtil.AddSigners(*config.UpgradeConfig.SignerKey)); err != nil {
return ixns, fmt.Errorf("failed to confirm upgradeFeeQuoter: %w", err)
}
e.Logger.Infow("Upgraded FeeQuoter", "addr", chainState.FeeQuoter.String(), "chain", chain.String())
} else {
ixns = append(ixns, upgradeIxn)
ixns = append(ixns, upgradeIxn, closeIxn)
}
} else {
e.Logger.Infow("Using existing fee quoter", "addr", chainState.FeeQuoter.String())
Expand Down Expand Up @@ -371,15 +380,24 @@ func deployChainContractsSolana(
if err != nil {
return ixns, fmt.Errorf("failed to generate upgrade instruction: %w", err)
}
closeIxn, err := generateCloseBufferIxn(
&e,
bufferProgram,
config.UpgradeConfig.SpillAddress,
config.UpgradeConfig.UpgradeAuthority,
)
if err != nil {
return ixns, fmt.Errorf("failed to generate close buffer instruction: %w", err)
}
ccipRouterProgram = chainState.Router
if config.UpgradeConfig.SignerKey != nil {
// if we're not using MCMS to upgrade, confirm txn with the signer key
if err := chain.Confirm([]solana.Instruction{upgradeIxn}, solCommonUtil.AddSigners(*config.UpgradeConfig.SignerKey)); err != nil {
if err := chain.Confirm([]solana.Instruction{upgradeIxn, closeIxn}, solCommonUtil.AddSigners(*config.UpgradeConfig.SignerKey)); err != nil {
return ixns, fmt.Errorf("failed to confirm upgradeRouter: %w", err)
}
e.Logger.Infow("Upgraded Router", "addr", chainState.Router.String(), "chain", chain.String())
} else {
ixns = append(ixns, upgradeIxn)
ixns = append(ixns, upgradeIxn, closeIxn)
}
} else {
e.Logger.Infow("Using existing router", "addr", chainState.Router.String())
Expand Down Expand Up @@ -623,24 +641,24 @@ func setUpgradeAuthority(
newUpgradeAuthority *solana.PublicKey,
isBuffer bool,
) error {
slice1 := solana.NewAccountMeta(programID, true, false)
// Buffers use the program account as the program data account
programDataSlice := solana.NewAccountMeta(programID, true, false)
if !isBuffer {
// Derive the program data address
// Actual program accounts use the program data account
programDataAddress, _, _ := solana.FindProgramAddress([][]byte{programID.Bytes()}, solana.BPFLoaderUpgradeableProgramID)
slice1 = solana.NewAccountMeta(programDataAddress, true, false)
programDataSlice = solana.NewAccountMeta(programDataAddress, true, false)
}

// Accounts involved in the transaction
keys := solana.AccountMetaSlice{
slice1, // Program account (writable)
programDataSlice, // Program account (writable)
solana.NewAccountMeta(currentUpgradeAuthority.PublicKey(), false, true), // Current upgrade authority (signer)
solana.NewAccountMeta(*newUpgradeAuthority, false, false), // New upgrade authority
}

// Create the instruction
instruction := solana.NewInstruction(
solana.BPFLoaderUpgradeableProgramID,
keys,
// https://github.com/solana-playground/solana-playground/blob/2998d4cf381aa319d26477c5d4e6d15059670a75/vscode/src/commands/deploy/bpf-upgradeable/bpf-upgradeable.ts#L72
[]byte{4, 0, 0, 0}, // 4-byte SetAuthority instruction identifier
)

Expand All @@ -660,11 +678,11 @@ func generateUpgradeIxn(
upgradeAuthority solana.PublicKey,
) (solana.Instruction, error) {
// Derive the program data address
programDataAddress, _, _ := solana.FindProgramAddress([][]byte{programID.Bytes()}, solana.BPFLoaderUpgradeableProgramID)
programDataAccount, _, _ := solana.FindProgramAddress([][]byte{programID.Bytes()}, solana.BPFLoaderUpgradeableProgramID)

// Accounts involved in the transaction
keys := solana.AccountMetaSlice{
solana.NewAccountMeta(programDataAddress, true, false), // Program account (writable)
solana.NewAccountMeta(programDataAccount, true, false), // Program account (writable)
solana.NewAccountMeta(programID, true, false),
solana.NewAccountMeta(bufferAddress, true, false), // Buffer account (writable)
solana.NewAccountMeta(spillAddress, true, false), // Spill account (writable)
Expand All @@ -673,12 +691,35 @@ func generateUpgradeIxn(
solana.NewAccountMeta(upgradeAuthority, false, true), // Current upgrade authority (signer)
}

// Create the instruction
instruction := solana.NewInstruction(
solana.BPFLoaderUpgradeableProgramID,
keys,
// https://github.com/solana-playground/solana-playground/blob/2998d4cf381aa319d26477c5d4e6d15059670a75/vscode/src/commands/deploy/bpf-upgradeable/bpf-upgradeable.ts#L66
[]byte{3, 0, 0, 0}, // 4-byte Upgrade instruction identifier
)

return instruction, nil
}

func generateCloseBufferIxn(
e *deployment.Environment,
bufferAddress solana.PublicKey,
recipient solana.PublicKey,
upgradeAuthority solana.PublicKey,
) (solana.Instruction, error) {

keys := solana.AccountMetaSlice{
solana.NewAccountMeta(bufferAddress, true, false),
solana.NewAccountMeta(recipient, false, false),
solana.NewAccountMeta(upgradeAuthority, false, true),
}

instruction := solana.NewInstruction(
solana.BPFLoaderUpgradeableProgramID,
keys,
// https://github.com/solana-playground/solana-playground/blob/2998d4cf381aa319d26477c5d4e6d15059670a75/vscode/src/commands/deploy/bpf-upgradeable/bpf-upgradeable.ts#L78
[]byte{5, 0, 0, 0}, // 4-byte Close instruction identifier
)

return instruction, nil
}
25 changes: 25 additions & 0 deletions deployment/ccip/changeset/solana/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ func TestDeployChainContractsChangesetSolana(t *testing.T) {
)
}
require.NoError(t, err)
// Verify router and fee quoter upgraded in place
// and offramp had 2nd address added
addresses, err := e.ExistingAddresses.AddressesForChain(solChainSelectors[0])
numRouters := 0
numFeeQuoters := 0
numOffRamps := 0
for _, address := range addresses {
if address.Type == changeset.Router {
numRouters++
}
if address.Type == changeset.FeeQuoter {
numFeeQuoters++
}
if address.Type == changeset.OffRamp {
numOffRamps++
}
}
require.Equal(t, 1, numRouters)
require.Equal(t, 1, numFeeQuoters)
if ci {
require.Equal(t, 2, numOffRamps)
} else {
require.Equal(t, 1, numOffRamps)
}
require.NoError(t, err)
// solana verification
testhelpers.ValidateSolanaState(t, e, solChainSelectors)
}
6 changes: 3 additions & 3 deletions deployment/ccip/changeset/solana_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ type SolCCIPChainState struct {
}

func FetchOfframpLookupTable(ctx context.Context, chain deployment.SolChain, offRampAddress solana.PublicKey) (solana.PublicKey, error) {
var referenceAddresses solOffRamp.ReferenceAddresses
var referenceAddressesAccount solOffRamp.ReferenceAddresses
offRampReferenceAddressesPDA, _, _ := solState.FindOfframpReferenceAddressesPDA(offRampAddress)
err := chain.GetAccountDataBorshInto(ctx, offRampReferenceAddressesPDA, &referenceAddresses)
err := chain.GetAccountDataBorshInto(ctx, offRampReferenceAddressesPDA, &referenceAddressesAccount)
if err != nil {
return solana.PublicKey{}, fmt.Errorf("failed to get offramp reference addresses: %w", err)
}
return referenceAddresses.OfframpLookupTable, nil
return referenceAddressesAccount.OfframpLookupTable, nil
}

func LoadOnchainStateSolana(e deployment.Environment) (CCIPOnChainState, error) {
Expand Down
4 changes: 3 additions & 1 deletion deployment/solana_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ func (c SolChain) DeployProgram(logger logger.Logger, programName string, isUpgr
}

var cmd *exec.Cmd
// We need to specify the program ID on the inital deploy but not on upgrades
// Upgrades happen in place so we don't need to supply the keypair
// It will write the .so file to a buffer and then deploy it to the existing keypair
if !isUpgrade {
// Keypair exists, include program-id
logger.Infow("Deploying program with existing keypair",
"programFile", programFile,
"programKeyPair", programKeyPair)
Expand Down