Skip to content

Commit

Permalink
CCIP-4573 Changesets ccip 1.5 (#15588)
Browse files Browse the repository at this point in the history
* just start

* placeholders

* state

* change

* updates

* updates

* all updates

* change

* comments

* progress so far

* add test

* more updates

* updates

* changes

* updates

* formatting

* fix crib

* fix more tests

* lint fix

* comments

* fix format

* multichain

* fix lint

* fix lint

* change func name

* review comments

* lint fix

* removed legacyjobclient

* review comments
  • Loading branch information
AnieeG authored Dec 19, 2024
1 parent 06a4445 commit cc49b25
Show file tree
Hide file tree
Showing 25 changed files with 1,814 additions and 159 deletions.
25 changes: 25 additions & 0 deletions core/services/ocr2/plugins/ccip/testhelpers/integration/jobspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package integrationtesthelpers

import (
"bytes"
"crypto/sha256"
"fmt"
"text/template"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/lib/pq"

"github.com/smartcontractkit/chainlink-common/pkg/types"
Expand All @@ -28,6 +30,7 @@ type OCR2TaskJobSpec struct {
ForwardingAllowed bool `toml:"forwardingAllowed"`
OCR2OracleSpec job.OCR2OracleSpec
ObservationSource string `toml:"observationSource"` // List of commands for the Chainlink node
ExternalJobID string `toml:"externalJobID"`
}

// Type returns the type of the job
Expand All @@ -39,9 +42,14 @@ func (o *OCR2TaskJobSpec) String() (string, error) {
if o.OCR2OracleSpec.FeedID != nil {
feedID = o.OCR2OracleSpec.FeedID.Hex()
}
externalID, err := ExternalJobID(o.Name)
if err != nil {
return "", err
}
specWrap := struct {
Name string
JobType string
ExternalJobID string
MaxTaskDuration string
ForwardingAllowed bool
ContractID string
Expand All @@ -62,6 +70,7 @@ func (o *OCR2TaskJobSpec) String() (string, error) {
}{
Name: o.Name,
JobType: o.JobType,
ExternalJobID: externalID,
ForwardingAllowed: o.ForwardingAllowed,
MaxTaskDuration: o.MaxTaskDuration,
ContractID: o.OCR2OracleSpec.ContractID,
Expand All @@ -82,6 +91,7 @@ func (o *OCR2TaskJobSpec) String() (string, error) {
ocr2TemplateString := `
type = "{{ .JobType }}"
name = "{{.Name}}"
externalJobID = "{{.ExternalJobID}}"
forwardingAllowed = {{.ForwardingAllowed}}
{{if .MaxTaskDuration}}
maxTaskDuration = "{{ .MaxTaskDuration }}" {{end}}
Expand Down Expand Up @@ -332,3 +342,18 @@ func (c *CCIPIntegrationTestHarness) NewCCIPJobSpecParams(tokenPricesUSDPipeline
USDCAttestationAPI: usdcAttestationAPI,
}
}

func ExternalJobID(jobName string) (string, error) {
in := []byte(jobName)
sha256Hash := sha256.New()
sha256Hash.Write(in)
in = sha256Hash.Sum(nil)[:16]
// tag as valid UUID v4 https://github.com/google/uuid/blob/0f11ee6918f41a04c201eceeadf612a377bc7fbc/version4.go#L53-L54
in[6] = (in[6] & 0x0f) | 0x40 // Version 4
in[8] = (in[8] & 0x3f) | 0x80 // Variant is 10
id, err := uuid.FromBytes(in)
if err != nil {
return "", err
}
return id.String(), nil
}
26 changes: 5 additions & 21 deletions deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_home"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/maybe_revert_message_receiver"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/nonce_manager"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
Expand Down Expand Up @@ -178,32 +177,17 @@ func deployChainContracts(
}
rmnProxyContract := chainState.RMNProxy
if chainState.RMNProxy == nil {
e.Logger.Errorw("RMNProxy not found", "chain", chain.String())
return fmt.Errorf("rmn proxy not found for chain %s, deploy the prerequisites first", chain.String())
}
if chainState.Receiver == nil {
_, 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,
chain.Client,
false,
)
return deployment.ContractDeploy[*maybe_revert_message_receiver.MaybeRevertMessageReceiver]{
receiverAddr, receiver, tx, deployment.NewTypeAndVersion(CCIPReceiver, deployment.Version1_0_0), err2,
}
})
if err != nil {
e.Logger.Errorw("Failed to deploy receiver", "err", err)
return err
}
} else {
e.Logger.Infow("receiver already deployed", "addr", chainState.Receiver.Address, "chain", chain.String())
}
var rmnLegacyAddr common.Address
if chainState.MockRMN != nil {
rmnLegacyAddr = chainState.MockRMN.Address()
}
// TODO add legacy RMN here when 1.5 contracts are available
// If RMN is deployed, set rmnLegacyAddr to the RMN address
if chainState.RMN != nil {
rmnLegacyAddr = chainState.RMN.Address()
}
if rmnLegacyAddr == (common.Address{}) {
e.Logger.Warnf("No legacy RMN contract found for chain %s, will not setRMN in RMNRemote", chain.String())
}
Expand Down
8 changes: 7 additions & 1 deletion deployment/ccip/changeset/cs_deploy_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func TestDeployChainContractsChangeset(t *testing.T) {
for _, chain := range e.AllChainSelectors() {
cfg[chain] = proposalutils.SingleGroupTimelockConfig(t)
}
var prereqCfg []DeployPrerequisiteConfigPerChain
for _, chain := range e.AllChainSelectors() {
prereqCfg = append(prereqCfg, DeployPrerequisiteConfigPerChain{
ChainSelector: chain,
})
}
e, err = commonchangeset.ApplyChangesets(t, e, nil, []commonchangeset.ChangesetApplication{
{
Changeset: commonchangeset.WrapChangeSet(DeployHomeChain),
Expand All @@ -57,7 +63,7 @@ func TestDeployChainContractsChangeset(t *testing.T) {
{
Changeset: commonchangeset.WrapChangeSet(DeployPrerequisites),
Config: DeployPrerequisiteConfig{
ChainSelectors: selectors,
Configs: prereqCfg,
},
},
{
Expand Down
Loading

0 comments on commit cc49b25

Please sign in to comment.