Skip to content

Commit

Permalink
more logs and review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Dec 5, 2024
1 parent 3b026ea commit 45f4625
Show file tree
Hide file tree
Showing 19 changed files with 162 additions and 117 deletions.
1 change: 1 addition & 0 deletions deployment/ccip/changeset/cs_add_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func TestAddChainInbound(t *testing.T) {

// verify if the configs are updated
require.NoError(t, ValidateCCIPHomeConfigSetUp(
e.Env.Logger,
state.Chains[e.HomeChainSel].CapabilityRegistry,
state.Chains[e.HomeChainSel].CCIPHome,
newChain,
Expand Down
58 changes: 29 additions & 29 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,28 @@ func deployChainContracts(
}
chainState, chainExists := state.Chains[chain.Selector]
if !chainExists {
return fmt.Errorf("chain %s not found in existing state, deploy the prerequisites first", chain.Name)
return fmt.Errorf("chain %s not found in existing state, deploy the prerequisites first", chain.Name())
}
if chainState.Weth9 == nil {
return fmt.Errorf("weth9 not found for chain %s, deploy the prerequisites first", chain.Name)
return fmt.Errorf("weth9 not found for chain %s, deploy the prerequisites first", chain.Name())
}
if chainState.Timelock == nil {
return fmt.Errorf("timelock not found for chain %s, deploy the mcms contracts first", chain.Name)
return fmt.Errorf("timelock not found for chain %s, deploy the mcms contracts first", chain.Name())
}
weth9Contract := chainState.Weth9
if chainState.LinkToken == nil {
return fmt.Errorf("link token not found for chain %s, deploy the prerequisites first", chain.Name)
return fmt.Errorf("link token not found for chain %s, deploy the prerequisites first", chain.Name())
}
linkTokenContract := chainState.LinkToken
if chainState.TokenAdminRegistry == nil {
return fmt.Errorf("token admin registry not found for chain %s, deploy the prerequisites first", chain.Name)
return fmt.Errorf("token admin registry not found for chain %s, deploy the prerequisites first", chain.Name())
}
tokenAdminReg := chainState.TokenAdminRegistry
if chainState.RegistryModule == nil {
return fmt.Errorf("registry module not found for chain %s, deploy the prerequisites first", chain.Name)
return fmt.Errorf("registry module not found for chain %s, deploy the prerequisites first", chain.Name())
}
if chainState.Router == nil {
return fmt.Errorf("router not found for chain %s, deploy the prerequisites first", chain.Name)
return fmt.Errorf("router not found for chain %s, deploy the prerequisites first", chain.Name())
}
if chainState.Receiver == nil {
_, err := deployment.DeployContract(e.Logger, chain, ab,
Expand All @@ -222,7 +222,7 @@ func deployChainContracts(
return err
}
} else {
e.Logger.Infow("receiver already deployed", "addr", chainState.Receiver.Address, "chain", chain.Name)
e.Logger.Infow("receiver already deployed", "addr", chainState.Receiver.Address, "chain", chain.Name())
}
rmnRemoteContract := chainState.RMNRemote
if chainState.RMNRemote == nil {
Expand All @@ -241,19 +241,19 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy RMNRemote", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy RMNRemote", "chain", chain.Name(), "err", err)
return err
}
rmnRemoteContract = rmnRemote.Contract
} else {
e.Logger.Infow("rmn remote already deployed", "chain", chain.Name, "addr", chainState.RMNRemote.Address)
e.Logger.Infow("rmn remote already deployed", "chain", chain.Name(), "addr", chainState.RMNRemote.Address)
}
activeDigest, err := rmnHome.GetActiveDigest(&bind.CallOpts{})
if err != nil {
e.Logger.Errorw("Failed to get active digest", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to get active digest", "chain", chain.Name(), "err", err)
return err
}
e.Logger.Infow("setting active home digest to rmn remote", "chain", chain.Name, "digest", activeDigest)
e.Logger.Infow("setting active home digest to rmn remote", "chain", chain.Name(), "digest", activeDigest)

tx, err := rmnRemoteContract.SetConfig(chain.DeployerKey, rmn_remote.RMNRemoteConfig{
RmnHomeContractConfigDigest: activeDigest,
Expand All @@ -263,7 +263,7 @@ func deployChainContracts(
F: 0, // TODO: update when we have signers
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
e.Logger.Errorw("Failed to confirm RMNRemote config", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to confirm RMNRemote config", "chain", chain.Name(), "err", err)
return err
}

Expand All @@ -284,12 +284,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy RMNProxyNew", "chain", chain.Selector, "err", err)
e.Logger.Errorw("Failed to deploy RMNProxyNew", "chain", chain.Name(), "err", err)
return err
}
rmnProxyContract = rmnProxy.Contract
} else {
e.Logger.Infow("rmn proxy already deployed", "chain", chain.Name, "addr", chainState.RMNProxyNew.Address)
e.Logger.Infow("rmn proxy already deployed", "chain", chain.Name(), "addr", chainState.RMNProxyNew.Address)
}
if chainState.TestRouter == nil {
_, err := deployment.DeployContract(e.Logger, chain, ab,
Expand All @@ -305,11 +305,11 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy test router", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy test router", "chain", chain.Name(), "err", err)
return err
}
} else {
e.Logger.Infow("test router already deployed", "chain", chain.Name, "addr", chainState.TestRouter.Address)
e.Logger.Infow("test router already deployed", "chain", chain.Name(), "addr", chainState.TestRouter.Address)
}

nmContract := chainState.NonceManager
Expand All @@ -326,12 +326,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy nonce manager", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy nonce manager", "chain", chain.Name(), "err", err)
return err
}
nmContract = nonceManager.Contract
} else {
e.Logger.Infow("nonce manager already deployed", "chain", chain.Name, "addr", chainState.NonceManager.Address)
e.Logger.Infow("nonce manager already deployed", "chain", chain.Name(), "addr", chainState.NonceManager.Address)
}
feeQuoterContract := chainState.FeeQuoter
if chainState.FeeQuoter == nil {
Expand Down Expand Up @@ -366,12 +366,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy fee quoter", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy fee quoter", "chain", chain.Name(), "err", err)
return err
}
feeQuoterContract = feeQuoter.Contract
} else {
e.Logger.Infow("fee quoter already deployed", "chain", chain.Name, "addr", chainState.FeeQuoter.Address)
e.Logger.Infow("fee quoter already deployed", "chain", chain.Name(), "addr", chainState.FeeQuoter.Address)
}
onRampContract := chainState.OnRamp
if onRampContract == nil {
Expand All @@ -397,12 +397,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy onramp", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy onramp", "chain", chain.Name(), "err", err)
return err
}
onRampContract = onRamp.Contract
} else {
e.Logger.Infow("onramp already deployed", "chain", chain.Name, "addr", chainState.OnRamp.Address)
e.Logger.Infow("onramp already deployed", "chain", chain.Name(), "addr", chainState.OnRamp.Address)
}
offRampContract := chainState.OffRamp
if offRampContract == nil {
Expand All @@ -429,12 +429,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy offramp", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to deploy offramp", "chain", chain.Name(), "err", err)
return err
}
offRampContract = offRamp.Contract
} else {
e.Logger.Infow("offramp already deployed", "chain", chain.Name, "addr", chainState.OffRamp.Address)
e.Logger.Infow("offramp already deployed", "chain", chain.Name(), "addr", chainState.OffRamp.Address)
}
// Basic wiring is always needed.
tx, err = feeQuoterContract.ApplyAuthorizedCallerUpdates(chain.DeployerKey, fee_quoter.AuthorizedCallersAuthorizedCallerArgs{
Expand All @@ -443,17 +443,17 @@ func deployChainContracts(
AddedCallers: []common.Address{offRampContract.Address(), chain.DeployerKey.From},
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
e.Logger.Errorw("Failed to confirm fee quoter authorized caller update", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to confirm fee quoter authorized caller update", "chain", chain.Name(), "err", err)
return err
}
e.Logger.Infow("Added fee quoter authorized callers", "chain", chain.Name, "callers", offRampContract.Address(), chain.DeployerKey.From)
e.Logger.Infow("Added fee quoter authorized callers", "chain", chain.Name(), "callers", []common.Address{offRampContract.Address(), chain.DeployerKey.From})
tx, err = nmContract.ApplyAuthorizedCallerUpdates(chain.DeployerKey, nonce_manager.AuthorizedCallersAuthorizedCallerArgs{
AddedCallers: []common.Address{offRampContract.Address(), onRampContract.Address()},
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
e.Logger.Errorw("Failed to update nonce manager with ramps", "chain", chain.Name, "err", err)
e.Logger.Errorw("Failed to update nonce manager with ramps", "chain", chain.Name(), "err", err)
return err
}
e.Logger.Infow("Added nonce manager authorized callers", "chain", chain.Name, "callers", offRampContract.Address(), onRampContract.Address())
e.Logger.Infow("Added nonce manager authorized callers", "chain", chain.Name(), "callers", []common.Address{offRampContract.Address(), onRampContract.Address()})
return nil
}
22 changes: 11 additions & 11 deletions deployment/ccip/changeset/cs_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func deployCapReg(
}
})
if err != nil {
lggr.Errorw("Failed to deploy capreg", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to deploy capreg", "chain", chain.Name(), "err", err)
return nil, err
}
return capReg, nil
Expand Down Expand Up @@ -153,7 +153,7 @@ func deployHomeChain(
}
})
if err != nil {
lggr.Errorw("Failed to deploy CCIPHome", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to deploy CCIPHome", "chain", chain.Name(), "err", err)
return nil, err
}

Expand All @@ -170,7 +170,7 @@ func deployHomeChain(
},
)
if err != nil {
lggr.Errorw("Failed to deploy RMNHome", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to deploy RMNHome", "chain", chain.Name(), "err", err)
return nil, err
}

Expand All @@ -183,19 +183,19 @@ func deployHomeChain(

rmnCandidateDigest, err := rmnHome.Contract.GetCandidateDigest(nil)
if err != nil {
lggr.Errorw("Failed to get RMNHome candidate digest", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to get RMNHome candidate digest", "chain", chain.Name(), "err", err)
return nil, err
}

tx, err = rmnHome.Contract.PromoteCandidateAndRevokeActive(chain.DeployerKey, rmnCandidateDigest, [32]byte{})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
lggr.Errorw("Failed to promote candidate and revoke active on RMNHome", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to promote candidate and revoke active on RMNHome", "chain", chain.Name(), "err", err)
return nil, err
}

rmnActiveDigest, err := rmnHome.Contract.GetActiveDigest(nil)
if err != nil {
lggr.Errorw("Failed to get RMNHome active digest", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to get RMNHome active digest", "chain", chain.Name(), "err", err)
return nil, err
}
lggr.Infow("Got rmn home active digest", "digest", rmnActiveDigest)
Expand All @@ -216,22 +216,22 @@ func deployHomeChain(
},
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
lggr.Errorw("Failed to add capabilities", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to add capabilities", "chain", chain.Name(), "err", err)
return nil, err
}

tx, err = capReg.Contract.AddNodeOperators(chain.DeployerKey, nodeOps)
txBlockNum, err := deployment.ConfirmIfNoError(chain, tx, err)
if err != nil {
lggr.Errorw("Failed to add node operators", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to add node operators", "chain", chain.Name(), "err", err)
return nil, err
}
addedEvent, err := capReg.Contract.FilterNodeOperatorAdded(&bind.FilterOpts{
Start: txBlockNum,
Context: context.Background(),
}, nil, nil)
if err != nil {
lggr.Errorw("Failed to filter NodeOperatorAdded event", "chain", chain.Name, "err", err)
lggr.Errorw("Failed to filter NodeOperatorAdded event", "chain", chain.Name(), "err", err)
return capReg, err
}
// Need to fetch nodeoperators ids to be able to add nodes for corresponding node operators
Expand All @@ -245,7 +245,7 @@ func deployHomeChain(
}
}
if len(p2pIDsByNodeOpId) != len(nodeP2PIDsPerNodeOpAdmin) {
lggr.Errorw("Failed to add all node operators", "added", maps.Keys(p2pIDsByNodeOpId), "expected", maps.Keys(nodeP2PIDsPerNodeOpAdmin), "chain", chain.Name)
lggr.Errorw("Failed to add all node operators", "added", maps.Keys(p2pIDsByNodeOpId), "expected", maps.Keys(nodeP2PIDsPerNodeOpAdmin), "chain", chain.Name())
return capReg, errors.New("failed to add all node operators")
}
// Adds initial set of nodes to CR, who all have the CCIP capability
Expand Down Expand Up @@ -316,7 +316,7 @@ func addNodes(
}
tx, err := capReg.AddNodes(chain.DeployerKey, nodeParams)
if err != nil {
lggr.Errorw("Failed to add nodes", "chain", chain.Name, "err", deployment.MaybeDataErr(err))
lggr.Errorw("Failed to add nodes", "chain", chain.Name(), "err", deployment.MaybeDataErr(err))
return err
}
_, err = chain.Confirm(tx)
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_home_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestDeployHomeChain(t *testing.T) {
require.NotNil(t, state.Chains[homeChainSel].RMNHome)
snap, err := state.View([]uint64{homeChainSel})
require.NoError(t, err)
chainName := e.Chains[homeChainSel].Name
chainName := e.Chains[homeChainSel].Name()
_, ok := snap[chainName]
require.True(t, ok)
capRegSnap, ok := snap[chainName].CapabilityRegistry[state.Chains[homeChainSel].CapabilityRegistry.Address().String()]
Expand Down
30 changes: 23 additions & 7 deletions deployment/ccip/changeset/cs_initial_add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ func configureChain(
homeChain := e.Chains[c.HomeChainSel]
capReg := existingState.Chains[c.HomeChainSel].CapabilityRegistry
if capReg == nil {
e.Logger.Errorw("Failed to get capability registry", "chain", homeChain.Name)
e.Logger.Errorw("Failed to get capability registry", "chain", homeChain.Name())
return fmt.Errorf("capability registry not found")
}
ccipHome := existingState.Chains[c.HomeChainSel].CCIPHome
if ccipHome == nil {
e.Logger.Errorw("Failed to get ccip home", "chain", homeChain.Name, "err", err)
e.Logger.Errorw("Failed to get ccip home", "chain", homeChain.Name(), "err", err)
return fmt.Errorf("ccip home not found")
}
rmnHome := existingState.Chains[c.HomeChainSel].RMNHome
if rmnHome == nil {
e.Logger.Errorw("Failed to get rmn home", "chain", homeChain.Name, "err", err)
e.Logger.Errorw("Failed to get rmn home", "chain", homeChain.Name(), "err", err)
return fmt.Errorf("rmn home not found")
}

Expand Down Expand Up @@ -269,7 +269,7 @@ func addChainConfig(
if _, err := deployment.ConfirmIfNoError(h, tx, err); err != nil {
return ccip_home.CCIPHomeChainConfigArgs{}, err
}
lggr.Infow("Applied chain config updates", "homeChain", h.Name, "addedChain", chainSelector, "chainConfig", chainConfig)
lggr.Infow("Applied chain config updates", "homeChain", h.Name(), "addedChain", chainSelector, "chainConfig", chainConfig)
return chainConfig, nil
}

Expand Down Expand Up @@ -303,17 +303,17 @@ func createDON(

donID := latestDon.Id + 1

err = internal.SetupCommitDON(donID, commitConfig, capReg, home, nodes, ccipHome)
err = internal.SetupCommitDON(lggr, donID, commitConfig, capReg, home, nodes, ccipHome)
if err != nil {
return fmt.Errorf("setup commit don: %w", err)
}

// TODO: bug in contract causing this to not work as expected.
err = internal.SetupExecDON(donID, execConfig, capReg, home, nodes, ccipHome)
err = internal.SetupExecDON(lggr, donID, execConfig, capReg, home, nodes, ccipHome)
if err != nil {
return fmt.Errorf("setup exec don: %w", err)
}
return ValidateCCIPHomeConfigSetUp(capReg, ccipHome, newChainSel)
return ValidateCCIPHomeConfigSetUp(lggr, capReg, ccipHome, newChainSel)
}

func addDON(
Expand Down Expand Up @@ -371,6 +371,15 @@ func addDON(
if err != nil {
return err
}
lggr.Debugw("Fetched OCR3 Configs",
"MultiOCR3BaseOCRConfig.F", ocrConfig.ConfigInfo.F,
"MultiOCR3BaseOCRConfig.N", ocrConfig.ConfigInfo.N,
"MultiOCR3BaseOCRConfig.IsSignatureVerificationEnabled", ocrConfig.ConfigInfo.IsSignatureVerificationEnabled,
"Signers", ocrConfig.Signers,
"Transmitters", ocrConfig.Transmitters,
"configDigest", hex.EncodeToString(ocrConfig.ConfigInfo.ConfigDigest[:]),
"chain", dest.Name(),
)
// TODO: assertions to be done as part of full state
// resprentation validation CCIP-3047
if mapOfframpOCR3Configs[pluginType].ConfigDigest != ocrConfig.ConfigInfo.ConfigDigest {
Expand Down Expand Up @@ -402,6 +411,7 @@ func addDON(

// ValidateCCIPHomeConfigSetUp checks that the commit and exec active and candidate configs are set up correctly
func ValidateCCIPHomeConfigSetUp(
lggr logger.Logger,
capReg *capabilities_registry.CapabilitiesRegistry,
ccipHome *ccip_home.CCIPHome,
chainSel uint64,
Expand All @@ -422,10 +432,12 @@ func ValidateCCIPHomeConfigSetUp(
if err != nil {
return fmt.Errorf("get active commit digest: %w", err)
}
lggr.Debugw("Fetched active commit digest", "commitActiveDigest", hex.EncodeToString(commitActiveDigest[:]))
commitCandidateDigest, err := ccipHome.GetCandidateDigest(nil, donID, uint8(cctypes.PluginTypeCCIPCommit))
if err != nil {
return fmt.Errorf("get commit candidate digest: %w", err)
}
lggr.Debugw("Fetched candidate commit digest", "commitCandidateDigest", hex.EncodeToString(commitCandidateDigest[:]))
if commitConfigs.ActiveConfig.ConfigDigest == [32]byte{} {
return fmt.Errorf(
"active config digest is empty for commit, expected nonempty, donID: %d, cfg: %+v, config digest from GetActiveDigest call: %x, config digest from GetCandidateDigest call: %x",
Expand All @@ -441,6 +453,10 @@ func ValidateCCIPHomeConfigSetUp(
if err != nil {
return fmt.Errorf("get all exec configs: %w", err)
}
lggr.Debugw("Fetched exec configs",
"ActiveConfig.ConfigDigest", hex.EncodeToString(execConfigs.ActiveConfig.ConfigDigest[:]),
"CandidateConfig.ConfigDigest", hex.EncodeToString(execConfigs.CandidateConfig.ConfigDigest[:]),
)
if execConfigs.ActiveConfig.ConfigDigest == [32]byte{} {
return fmt.Errorf("active config digest is empty for exec, expected nonempty, cfg: %v", execConfigs.ActiveConfig)
}
Expand Down
Loading

0 comments on commit 45f4625

Please sign in to comment.