-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
CCIP-4593 Create rmnproxy setRMN changeset #15674
Changes from all commits
ded3f4c
10314c8
5f14bf0
75c676f
b31ec5a
5f6d2d5
93232f8
0394053
94c0418
61da889
b3a30bb
b75b760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,113 @@ import ( | |
"github.com/smartcontractkit/ccip-owner-contracts/pkg/gethwrappers" | ||
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/mcms" | ||
"github.com/smartcontractkit/ccip-owner-contracts/pkg/proposal/timelock" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_home" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" | ||
) | ||
|
||
type SetRMNRemoteOnRMNProxyConfig struct { | ||
ChainSelectors []uint64 | ||
MCMSConfig *MCMSConfig | ||
} | ||
|
||
func (c SetRMNRemoteOnRMNProxyConfig) Validate(state CCIPOnChainState) error { | ||
for _, chain := range c.ChainSelectors { | ||
err := deployment.IsValidChainSelector(chain) | ||
if err != nil { | ||
return err | ||
} | ||
chainState, exists := state.Chains[chain] | ||
if !exists { | ||
return fmt.Errorf("chain %d not found in state", chain) | ||
} | ||
if chainState.RMNRemote == nil { | ||
return fmt.Errorf("RMNRemote not found for chain %d", chain) | ||
} | ||
if chainState.RMNProxy == nil { | ||
return fmt.Errorf("RMNProxy not found for chain %d", chain) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func SetRMNRemoteOnRMNProxy(e deployment.Environment, cfg SetRMNRemoteOnRMNProxyConfig) (deployment.ChangesetOutput, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming nit (not a big fan of it though) |
||
state, err := LoadOnchainState(e) | ||
if err != nil { | ||
return deployment.ChangesetOutput{}, fmt.Errorf("failed to load onchain state: %w", err) | ||
} | ||
if err := cfg.Validate(state); err != nil { | ||
return deployment.ChangesetOutput{}, err | ||
} | ||
var timelockBatch []timelock.BatchChainOperation | ||
multiSigs := make(map[uint64]*gethwrappers.ManyChainMultiSig) | ||
timelocks := make(map[uint64]common.Address) | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do this so often I feel like we should just have a helper like |
||
for _, sel := range cfg.ChainSelectors { | ||
chain, exists := e.Chains[sel] | ||
if !exists { | ||
return deployment.ChangesetOutput{}, fmt.Errorf("chain %d not found", sel) | ||
} | ||
txOpts := chain.DeployerKey | ||
if cfg.MCMSConfig != nil { | ||
txOpts = deployment.SimTransactOpts() | ||
} | ||
mcmsOps, err := setRMNRemoteOnRMNProxyOp(txOpts, chain, state.Chains[sel], cfg.MCMSConfig != nil) | ||
if err != nil { | ||
return deployment.ChangesetOutput{}, fmt.Errorf("failed to set RMNRemote on RMNProxy for chain %s: %w", chain.String(), err) | ||
} | ||
if cfg.MCMSConfig != nil { | ||
timelockBatch = append(timelockBatch, timelock.BatchChainOperation{ | ||
ChainIdentifier: mcms.ChainIdentifier(sel), | ||
Batch: []mcms.Operation{mcmsOps}, | ||
}) | ||
multiSigs[sel] = state.Chains[sel].ProposerMcm | ||
timelocks[sel] = state.Chains[sel].Timelock.Address() | ||
} | ||
} | ||
// If we're not using MCMS, we can just return now as we've already confirmed the transactions | ||
if len(timelockBatch) == 0 { | ||
return deployment.ChangesetOutput{}, nil | ||
} | ||
prop, err := proposalutils.BuildProposalFromBatches( | ||
timelocks, | ||
multiSigs, | ||
timelockBatch, | ||
fmt.Sprintf("proposal to set RMNRemote on RMNProxy for chains %v", cfg.ChainSelectors), | ||
cfg.MCMSConfig.MinDelay, | ||
) | ||
if err != nil { | ||
return deployment.ChangesetOutput{}, err | ||
} | ||
return deployment.ChangesetOutput{ | ||
Proposals: []timelock.MCMSWithTimelockProposal{ | ||
*prop, | ||
}, | ||
}, nil | ||
} | ||
|
||
func setRMNRemoteOnRMNProxyOp(txOpts *bind.TransactOpts, chain deployment.Chain, chainState CCIPChainState, mcmsEnabled bool) (mcms.Operation, error) { | ||
rmnProxy := chainState.RMNProxy | ||
rmnRemoteAddr := chainState.RMNRemote.Address() | ||
setRMNTx, err := rmnProxy.SetARM(txOpts, rmnRemoteAddr) | ||
if err != nil { | ||
return mcms.Operation{}, fmt.Errorf("failed to build call data/transaction to set RMNRemote on RMNProxy for chain %s: %w", chain.String(), err) | ||
} | ||
if !mcmsEnabled { | ||
_, err = deployment.ConfirmIfNoError(chain, setRMNTx, err) | ||
if err != nil { | ||
return mcms.Operation{}, fmt.Errorf("failed to confirm tx to set RMNRemote on RMNProxy for chain %s: %w", chain.String(), deployment.MaybeDataErr(err)) | ||
} | ||
} | ||
return mcms.Operation{ | ||
To: rmnProxy.Address(), | ||
Data: setRMNTx.Data(), | ||
Value: big.NewInt(0), | ||
}, nil | ||
} | ||
|
||
type RMNNopConfig struct { | ||
NodeIndex uint64 | ||
OffchainPublicKey [32]byte | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a ticket for this? Its weird that its timing out, it takes 90s on my laptop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes created https://smartcontract-it.atlassian.net/browse/CCIP-4594