Skip to content

Commit

Permalink
improve logging in deployment code to denote human readable chain name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Dec 5, 2024
1 parent a873aa5 commit a13c2f4
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 122 deletions.
69 changes: 31 additions & 38 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,31 @@ func deployChainContracts(
}
chainState, chainExists := state.Chains[chain.Selector]
if !chainExists {
return fmt.Errorf("chain %d not found in existing state, deploy the prerequisites first", chain.Selector)
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 %d, deploy the prerequisites first", chain.Selector)
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 %d, deploy the mcms contracts first", chain.Selector)
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 %d, deploy the prerequisites first", chain.Selector)
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 %d, deploy the prerequisites first", chain.Selector)
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 %d, deploy the prerequisites first", chain.Selector)
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 %d, deploy the prerequisites first", chain.Selector)
return fmt.Errorf("router not found for chain %s, deploy the prerequisites first", chain.Name)
}
if chainState.Receiver == nil {
ccipReceiver, err := deployment.DeployContract(e.Logger, chain, ab,
_, err := deployment.DeployContract(e.Logger, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*maybe_revert_message_receiver.MaybeRevertMessageReceiver] {
receiverAddr, tx, receiver, err2 := maybe_revert_message_receiver.DeployMaybeRevertMessageReceiver(
chain.DeployerKey,
Expand All @@ -221,9 +221,8 @@ func deployChainContracts(
e.Logger.Errorw("Failed to deploy receiver", "err", err)
return err
}
e.Logger.Infow("deployed receiver", "addr", ccipReceiver.Address)
} else {
e.Logger.Infow("receiver already deployed", "addr", chainState.Receiver.Address)
e.Logger.Infow("receiver already deployed", "addr", chainState.Receiver.Address, "chain", chain.Name)
}
rmnRemoteContract := chainState.RMNRemote
if chainState.RMNRemote == nil {
Expand All @@ -242,20 +241,19 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy RMNRemote", "err", err)
e.Logger.Errorw("Failed to deploy RMNRemote", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("deployed RMNRemote", "addr", rmnRemote.Address)
rmnRemoteContract = rmnRemote.Contract
} else {
e.Logger.Infow("rmn remote already deployed", "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", "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", "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 @@ -265,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", "err", err)
e.Logger.Errorw("Failed to confirm RMNRemote config", "chain", chain.Name, "err", err)
return err
}

Expand All @@ -286,16 +284,15 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy RMNProxyNew", "err", err)
e.Logger.Errorw("Failed to deploy RMNProxyNew", "chain", chain.Selector, "err", err)
return err
}
e.Logger.Infow("deployed new RMNProxyNew", "addr", rmnProxy.Address)
rmnProxyContract = rmnProxy.Contract
} else {
e.Logger.Infow("rmn proxy already deployed", "addr", chainState.RMNProxyNew.Address)
e.Logger.Infow("rmn proxy already deployed", "chain", chain.Name, "addr", chainState.RMNProxyNew.Address)
}
if chainState.TestRouter == nil {
testRouterContract, err := deployment.DeployContract(e.Logger, chain, ab,
_, err := deployment.DeployContract(e.Logger, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*router.Router] {
routerAddr, tx2, routerC, err2 := router.DeployRouter(
chain.DeployerKey,
Expand All @@ -308,12 +305,11 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy test router", "err", err)
e.Logger.Errorw("Failed to deploy test router", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("deployed test router", "addr", testRouterContract.Address)
} else {
e.Logger.Infow("test router already deployed", "addr", chainState.TestRouter.Address)
e.Logger.Infow("test router already deployed", "chain", chain.Name, "addr", chainState.TestRouter.Address)
}

nmContract := chainState.NonceManager
Expand All @@ -330,13 +326,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy nonce manager", "err", err)
e.Logger.Errorw("Failed to deploy nonce manager", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("Deployed nonce manager", "addr", nonceManager.Address)
nmContract = nonceManager.Contract
} else {
e.Logger.Infow("nonce manager already deployed", "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 @@ -371,13 +366,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy fee quoter", "err", err)
e.Logger.Errorw("Failed to deploy fee quoter", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("Deployed fee quoter", "addr", feeQuoter.Address)
feeQuoterContract = feeQuoter.Contract
} else {
e.Logger.Infow("fee quoter already deployed", "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 @@ -403,13 +397,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy onramp", "err", err)
e.Logger.Errorw("Failed to deploy onramp", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("Deployed onramp", "addr", onRamp.Address)
onRampContract = onRamp.Contract
} else {
e.Logger.Infow("onramp already deployed", "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 @@ -436,13 +429,12 @@ func deployChainContracts(
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy offramp", "err", err)
e.Logger.Errorw("Failed to deploy offramp", "chain", chain.Name, "err", err)
return err
}
e.Logger.Infow("Deployed offramp", "addr", offRamp.Address)
offRampContract = offRamp.Contract
} else {
e.Logger.Infow("offramp already deployed", "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 @@ -451,16 +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", "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)
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", "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())
return nil
}
25 changes: 12 additions & 13 deletions deployment/ccip/changeset/cs_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"golang.org/x/exp/maps"

"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
Expand Down Expand Up @@ -111,7 +112,7 @@ func deployCapReg(
}
})
if err != nil {
lggr.Errorw("Failed to deploy capreg", "err", err)
lggr.Errorw("Failed to deploy capreg", "chain", chain.Name, "err", err)
return nil, err
}
return capReg, nil
Expand Down Expand Up @@ -152,10 +153,9 @@ func deployHomeChain(
}
})
if err != nil {
lggr.Errorw("Failed to deploy CCIPHome", "err", err)
lggr.Errorw("Failed to deploy CCIPHome", "chain", chain.Name, "err", err)
return nil, err
}
lggr.Infow("deployed CCIPHome", "addr", ccipHome.Address)

rmnHome, err := deployment.DeployContract(
lggr, chain, ab,
Expand All @@ -170,10 +170,9 @@ func deployHomeChain(
},
)
if err != nil {
lggr.Errorw("Failed to deploy RMNHome", "err", err)
lggr.Errorw("Failed to deploy RMNHome", "chain", chain.Name, "err", err)
return nil, err
}
lggr.Infow("deployed RMNHome", "addr", rmnHome.Address)

// considering the RMNHome is recently deployed, there is no digest to overwrite
tx, err := rmnHome.Contract.SetCandidate(chain.DeployerKey, rmnHomeStatic, rmnHomeDynamic, [32]byte{})
Expand All @@ -184,19 +183,19 @@ func deployHomeChain(

rmnCandidateDigest, err := rmnHome.Contract.GetCandidateDigest(nil)
if err != nil {
lggr.Errorw("Failed to get RMNHome candidate digest", "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", "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", "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 @@ -217,22 +216,22 @@ func deployHomeChain(
},
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
lggr.Errorw("Failed to add capabilities", "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", "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", "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 @@ -246,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))
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 @@ -317,7 +316,7 @@ func addNodes(
}
tx, err := capReg.AddNodes(chain.DeployerKey, nodeParams)
if err != nil {
lggr.Errorw("Failed to add nodes", "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
10 changes: 6 additions & 4 deletions deployment/ccip/changeset/cs_initial_add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/merklemulti"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/deployment/common/types"
Expand Down Expand Up @@ -178,19 +179,20 @@ func configureChain(
e.Logger.Errorw("Failed to load existing onchain state", "err")
return err
}
homeChain := e.Chains[c.HomeChainSel]
capReg := existingState.Chains[c.HomeChainSel].CapabilityRegistry
if capReg == nil {
e.Logger.Errorw("Failed to get capability registry")
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", "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", "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 @@ -267,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", "chainConfig", chainConfig)
lggr.Infow("Applied chain config updates", "homeChain", h.Name, "addedChain", chainSelector, "chainConfig", chainConfig)
return chainConfig, nil
}

Expand Down
Loading

0 comments on commit a13c2f4

Please sign in to comment.