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
move upgrades to mcms
  • Loading branch information
tt-cll committed Feb 18, 2025
commit 798d06bffd7d3d5a6ad56932b901eb059929d5ab
168 changes: 132 additions & 36 deletions deployment/ccip/changeset/solana/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
import (
"errors"
"fmt"
"math/big"

"github.com/Masterminds/semver/v3"
"github.com/gagliardetto/solana-go"
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock"
chainsel "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/mcms"
"github.com/smartcontractkit/mcms/sdk"
mcmsSolana "github.com/smartcontractkit/mcms/sdk/solana"
mcmsTypes "github.com/smartcontractkit/mcms/types"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/state"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"

solBinary "github.com/gagliardetto/binary"
solRpc "github.com/gagliardetto/solana-go/rpc"
Expand Down Expand Up @@ -46,23 +52,29 @@
// SpillAddress and UpgradeAuthority must be set
SpillAddress solana.PublicKey
UpgradeAuthority solana.PublicKey
// We assume if the signer key is set, we're not using MCMS
SignerKey *solana.PrivateKey
MCMS *cs.MCMSConfig
}

func (cfg UpgradeConfigSolana) Validate(e deployment.Environment, chainSelector uint64) error {
if cfg.NewFeeQuoterVersion == nil && cfg.NewRouterVersion == nil && cfg.NewOffRampVersion == nil {
return nil
}
if cfg.NewFeeQuoterVersion != nil || cfg.NewRouterVersion != nil {
if cfg.SpillAddress.IsZero() {
return errors.New("spill address must be set for fee quoter and router upgrades")
}
if cfg.UpgradeAuthority.IsZero() {
return errors.New("upgrade authority must be set for fee quoter and router upgrades")
}
}
return ValidateMCMSConfig(e, chainSelector, cfg.MCMS)
}

func DeployChainContractsChangesetSolana(e deployment.Environment, config DeployChainContractsConfigSolana) (deployment.ChangesetOutput, error) {
c := config.DeployChainContractsConfig
if err := c.Validate(); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("invalid DeployChainContractsConfig: %w", err)
}
if config.UpgradeConfig.NewFeeQuoterVersion != nil || config.UpgradeConfig.NewRouterVersion != nil {
if config.UpgradeConfig.SpillAddress.IsZero() {
return deployment.ChangesetOutput{}, errors.New("spill address must be set for fee quoter and router upgrades")
}
if config.UpgradeConfig.UpgradeAuthority.IsZero() {
return deployment.ChangesetOutput{}, errors.New("upgrade authority must be set for fee quoter and router upgrades")
}
}
newAddresses := deployment.NewMemoryAddressBook()
existingState, err := changeset.LoadOnchainState(e)
if err != nil {
Expand All @@ -75,6 +87,10 @@
return deployment.ChangesetOutput{}, err
}

timelocks := map[uint64]string{}
proposers := map[uint64]string{}
inspectors := map[uint64]sdk.Inspector{}
var batches []mcmsTypes.BatchOperation
for chainSel := range c.ContractParamsPerChain {
if _, exists := existingState.SupportedChains()[chainSel]; !exists {
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not supported", chainSel)
Expand All @@ -88,19 +104,52 @@
if existingState.SolChains[chainSel].LinkToken.IsZero() {
return deployment.ChangesetOutput{}, fmt.Errorf("fee tokens not found for chain %d", chainSel)
}
ixns, err := deployChainContractsSolana(e, chain, newAddresses, config)
if err := config.UpgradeConfig.Validate(e, chainSel); err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("invalid UpgradeConfig: %w", err)
}
addresses, _ := e.ExistingAddresses.AddressesForChain(chainSel)
mcmState, _ := state.MaybeLoadMCMSWithTimelockChainStateSolana(chain, addresses)

timelocks[chainSel] = mcmsSolana.ContractAddress(
mcmState.TimelockProgram,
mcmsSolana.PDASeed(mcmState.TimelockSeed),
)
proposers[chainSel] = mcmsSolana.ContractAddress(mcmState.McmProgram, mcmsSolana.PDASeed(mcmState.ProposerMcmSeed))
inspectors[chainSel] = mcmsSolana.NewInspector(chain.Client)

mcmsTxs, err := deployChainContractsSolana(e, chain, newAddresses, config)
if err != nil {
e.Logger.Errorw("Failed to deploy CCIP contracts", "err", err, "newAddresses", newAddresses)
return deployment.ChangesetOutput{}, err
}
// create proposals for ixns
if len(ixns) > 0 {
e.Logger.Infow("Deployed contracts", "chain", chain.String(), "instructions", ixns)
if len(mcmsTxs) > 0 {
batches = append(batches, mcmsTypes.BatchOperation{
ChainSelector: mcmsTypes.ChainSelector(chainSel),
Transactions: mcmsTxs,
})
}
}

if config.UpgradeConfig.MCMS != nil {
proposal, err := proposalutils.BuildProposalFromBatchesV2(
e.GetContext(),
timelocks,
proposers,
inspectors,
batches,
"proposal to upgrade CCIP contracts",
config.UpgradeConfig.MCMS.MinDelay)
if err != nil {
return deployment.ChangesetOutput{}, fmt.Errorf("failed to build proposal: %w", err)
}
return deployment.ChangesetOutput{
MCMSTimelockProposals: []mcms.TimelockProposal{*proposal},
AddressBook: newAddresses,
}, nil
}

return deployment.ChangesetOutput{
Proposals: []timelock.MCMSWithTimelockProposal{},
AddressBook: newAddresses,
}, nil
}
Expand Down Expand Up @@ -276,9 +325,9 @@
chain deployment.SolChain,
ab deployment.AddressBook,
config DeployChainContractsConfigSolana,
) ([]solana.Instruction, error) {
) ([]mcmsTypes.Transaction, error) {
// we may need to gather instructions and submit them as part of MCMS
ixns := make([]solana.Instruction, 0)
ixns := make([]mcmsTypes.Transaction, 0)
state, err := changeset.LoadOnchainStateSolana(e)
if err != nil {
e.Logger.Errorw("Failed to load existing onchain state", "err", err)
Expand Down Expand Up @@ -329,15 +378,31 @@
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, 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, closeIxn)
}
upgradeData, err := upgradeIxn.Data()
if err != nil {
return ixns, fmt.Errorf("failed to extract upgrade data: %w", err)
}
upgradeTx, err := mcmsSolana.NewTransaction(

Check failure on line 385 in deployment/ccip/changeset/solana/cs_deploy_chain.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (deployment)

ineffectual assignment to err (ineffassign)
feeQuoterAddress.String(),
upgradeData,
big.NewInt(0), // e.g. value
upgradeIxn.Accounts(), // pass along needed accounts
string(cs.FeeQuoter), // some string identifying the target
[]string{}, // any relevant metadata
)
closeData, err := closeIxn.Data()
if err != nil {
return ixns, fmt.Errorf("failed to extract close data: %w", err)
}
closeTx, err := mcmsSolana.NewTransaction(

Check failure on line 397 in deployment/ccip/changeset/solana/cs_deploy_chain.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (deployment)

ineffectual assignment to err (ineffassign)
bufferProgram.String(),
closeData,
big.NewInt(0), // e.g. value
closeIxn.Accounts(), // pass along needed accounts
string(cs.FeeQuoter), // some string identifying the target
[]string{}, // any relevant metadata
)
ixns = append(ixns, upgradeTx, closeTx)
} else {
e.Logger.Infow("Using existing fee quoter", "addr", chainState.FeeQuoter.String())
feeQuoterAddress = chainState.FeeQuoter
Expand Down Expand Up @@ -382,15 +447,31 @@
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, 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, closeIxn)
}
upgradeData, err := upgradeIxn.Data()
if err != nil {
return ixns, fmt.Errorf("failed to extract upgrade data: %w", err)
}
upgradeTx, err := mcmsSolana.NewTransaction(

Check failure on line 454 in deployment/ccip/changeset/solana/cs_deploy_chain.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint (deployment)

ineffectual assignment to err (ineffassign)
ccipRouterProgram.String(),
upgradeData,
big.NewInt(0), // e.g. value
upgradeIxn.Accounts(), // pass along needed accounts
string(cs.Router), // some string identifying the target
[]string{}, // any relevant metadata
)
closeData, err := closeIxn.Data()
if err != nil {
return ixns, fmt.Errorf("failed to extract close data: %w", err)
}
closeTx, err := mcmsSolana.NewTransaction(
bufferProgram.String(),
closeData,
big.NewInt(0), // e.g. value
closeIxn.Accounts(), // pass along needed accounts
string(cs.Router), // some string identifying the target
[]string{}, // any relevant metadata
)
ixns = append(ixns, upgradeTx, closeTx)
} else {
e.Logger.Infow("Using existing router", "addr", chainState.Router.String())
ccipRouterProgram = chainState.Router
Expand Down Expand Up @@ -440,7 +521,22 @@
if err != nil {
return ixns, fmt.Errorf("failed to build instruction: %w", err)
}
ixns = append(ixns, []solana.Instruction{priceUpdaterix}...)
priceUpdaterData, err := priceUpdaterix.Data()
if err != nil {
return ixns, fmt.Errorf("failed to extract price updater data: %w", err)
}
priceUpdaterTx, err := mcmsSolana.NewTransaction(
offRampAddress.String(),
priceUpdaterData,
big.NewInt(0), // e.g. value
priceUpdaterix.Accounts(), // pass along needed accounts
string(cs.OffRamp), // some string identifying the target
[]string{}, // any relevant metadata
)
if err != nil {
return ixns, fmt.Errorf("failed to create price updater transaction: %w", err)
}
ixns = append(ixns, priceUpdaterTx)
} else {
e.Logger.Infow("Using existing offramp", "addr", chainState.OffRamp.String())
offRampAddress = chainState.OffRamp
Expand Down
Loading
Loading