Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein committed Sep 13, 2024
1 parent 0a63818 commit 4ea8911
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewChainInboundProposal(
addDON, err := state.Chains[homeChainSel].CapabilityRegistry.AddDON(SimTransactOpts(),
nodes.NonBootstraps().PeerIDs(), []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: CCIPCapabilityId,
CapabilityId: CCIPCapabilityID,
Config: newDONArgs,
},
}, false, false, nodes.NonBootstraps().DefaultF())
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func DeployCCIPContracts(e deployment.Environment, c DeployCCIPContractConfig) (
e.Logger.Errorw("Failed to get hashed capability id", "err", err)
return ab, err
}
if cr != CCIPCapabilityId {
return ab, fmt.Errorf("Capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityId[:]))
if cr != CCIPCapabilityID {
return ab, fmt.Errorf("Capability registry does not support CCIP %s %s", hexutil.Encode(cr[:]), hexutil.Encode(CCIPCapabilityID[:]))
}
// Signal to CR that our nodes support CCIP capability.
if err := AddNodes(
Expand Down
25 changes: 10 additions & 15 deletions integration-tests/deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"

Expand All @@ -20,6 +19,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink/integration-tests/deployment"
cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ocr3_config_encoder"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
Expand Down Expand Up @@ -53,18 +53,15 @@ const (
)

var (
// TODO: sort out why the mismatch here
//CCIPCapabilityId [32]byte = utils.MustHash(hexutil.Encode(MustABIEncode(`[{"type": "string"}, {"type": "string"}]`, CapabilityLabelledName, CapabilityVersion)))
CCIPCapabilityId = MustHashFromBytes(hexutil.MustDecode("0xe0da3c2b9005178f4731c9f40164f1933ad00bac9d6c13ad4ca1a8a763416380"))
CCIPCapabilityID = utils.Keccak256Fixed(MustABIEncode(`[{"type": "string"}, {"type": "string"}]`, CapabilityLabelledName, CapabilityVersion))
)

func MustHashFromBytes(b []byte) [32]byte {
if len(b) != 32 {
panic("invalid length")
func MustABIEncode(abiString string, args ...interface{}) []byte {
encoded, err := utils.ABIEncode(abiString, args...)
if err != nil {
panic(err)
}
var res [32]byte
copy(res[:], b)
return res
return encoded
}

func DeployCapReg(lggr logger.Logger, chains map[uint64]deployment.Chain, chainSel uint64) (deployment.AddressBook, common.Address, error) {
Expand Down Expand Up @@ -136,14 +133,13 @@ func AddNodes(
chain deployment.Chain,
p2pIDs [][32]byte,
) error {
// Need to sort, otherwise _checkIsValidUniqueSubset onChain will fail
var nodeParams []capabilities_registry.CapabilitiesRegistryNodeParams
for _, p2pID := range p2pIDs {
nodeParam := capabilities_registry.CapabilitiesRegistryNodeParams{
NodeOperatorId: NodeOperatorID,
Signer: p2pID, // Not used in tests
P2pId: p2pID,
HashedCapabilityIds: [][32]byte{CCIPCapabilityId},
HashedCapabilityIds: [][32]byte{CCIPCapabilityID},
}
nodeParams = append(nodeParams, nodeParam)
}
Expand Down Expand Up @@ -173,7 +169,6 @@ func AddChainConfig(
chainSelector uint64,
p2pIDs [][32]byte,
) (ccip_config.CCIPConfigTypesChainConfigInfo, error) {
// Need to sort, otherwise _checkIsValidUniqueSubset onChain will fail
// First Add ChainConfig that includes all p2pIDs as readers
encodedExtraChainConfig, err := chainconfig.EncodeChainConfig(chainconfig.ChainConfig{
GasPriceDeviationPPB: ccipocr3.NewBigIntFromInt64(1000),
Expand Down Expand Up @@ -315,7 +310,7 @@ func LatestCCIPDON(registry *capabilities_registry.CapabilitiesRegistry) (*capab
var ccipDON capabilities_registry.CapabilitiesRegistryDONInfo
for _, don := range dons {
if len(don.CapabilityConfigurations) == 1 &&
don.CapabilityConfigurations[0].CapabilityId == CCIPCapabilityId &&
don.CapabilityConfigurations[0].CapabilityId == CCIPCapabilityID &&
don.Id > ccipDON.Id {
ccipDON = don
}
Expand Down Expand Up @@ -375,7 +370,7 @@ func AddDON(
}
tx, err := capReg.AddDON(home.DeployerKey, nodes.PeerIDs(), []capabilities_registry.CapabilitiesRegistryCapabilityConfiguration{
{
CapabilityId: CCIPCapabilityId,
CapabilityId: CCIPCapabilityID,
Config: encodedConfigs,
},
}, false, false, nodes.DefaultF())
Expand Down

0 comments on commit 4ea8911

Please sign in to comment.