Skip to content

Commit 8e88fc5

Browse files
authored
deploy receiver contract in chainlink-ccip as part of chain contracts (#1191)
* deploy receiver contract in chainlink-ccip as part of chain contracts * fix tests * update test
1 parent 57c0fe5 commit 8e88fc5

File tree

8 files changed

+309
-4
lines changed

8 files changed

+309
-4
lines changed

chains/evm/deployment/v1_7_0/changesets/deploy_chain_contracts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestDeployChainContracts_Apply(t *testing.T) {
194194

195195
newAddrs, err := out.DataStore.Addresses().Fetch()
196196
require.NoError(t, err, "Failed to fetch addresses from datastore")
197-
require.Len(t, newAddrs, 13)
197+
require.Len(t, newAddrs, 14)
198198

199199
for _, addr := range existingAddrs {
200200
for _, newAddr := range newAddrs {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package mock_receiver
2+
3+
import (
4+
"github.com/Masterminds/semver/v3"
5+
"github.com/ethereum/go-ethereum/accounts/abi/bind"
6+
"github.com/ethereum/go-ethereum/common"
7+
"github.com/ethereum/go-ethereum/core/types"
8+
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/utils/operations/contract"
9+
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/latest/mock_receiver_v2"
10+
cldf_deployment "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
11+
)
12+
13+
var ContractType cldf_deployment.ContractType = "MockReceiver"
14+
15+
type ConstructorArgs struct {
16+
RequiredVerifiers []common.Address
17+
OptionalVerifiers []common.Address
18+
OptionalThreshold uint8
19+
}
20+
21+
var Deploy = contract.NewDeploy(
22+
"mock-receiver-v2:deploy",
23+
semver.MustParse("1.7.0"),
24+
"Deploys the MockReceiverV2 contract",
25+
ContractType,
26+
mock_receiver_v2.MockReceiverV2ABI,
27+
func(ConstructorArgs) error { return nil },
28+
contract.VMDeployers[ConstructorArgs]{
29+
DeployEVM: func(opts *bind.TransactOpts, backend bind.ContractBackend, args ConstructorArgs) (common.Address, *types.Transaction, error) {
30+
address, tx, _, err := mock_receiver_v2.DeployMockReceiverV2(opts, backend, args.RequiredVerifiers, args.OptionalVerifiers, args.OptionalThreshold)
31+
return address, tx, err
32+
},
33+
},
34+
)

chains/evm/deployment/v1_7_0/sequences/deploy_chain_contracts.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_7_0/operations/commit_onramp"
2222
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_7_0/operations/executor_onramp"
2323
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_7_0/operations/fee_quoter_v2"
24+
mock_receiver "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_7_0/operations/mock_receiver"
2425
"github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
2526
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
2627
cldf_deployment "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
@@ -316,6 +317,17 @@ var DeployChainContracts = cldf_ops.NewSequence(
316317
}
317318
addresses = append(addresses, commitOffRampRef)
318319

320+
mockReceiver, err := maybeDeployContract(b, mock_receiver.Deploy, mock_receiver.ContractType, chain, contract.DeployInput[mock_receiver.ConstructorArgs]{
321+
ChainSelector: chain.Selector,
322+
Args: mock_receiver.ConstructorArgs{
323+
RequiredVerifiers: []common.Address{common.HexToAddress(commitOffRampRef.Address)},
324+
},
325+
}, input.ExistingAddresses)
326+
if err != nil {
327+
return sequences.OnChainOutput{}, fmt.Errorf("failed to deploy MockReceiver: %w", err)
328+
}
329+
addresses = append(addresses, mockReceiver)
330+
319331
// Set signature config on the CommitOffRamp
320332
setSignatureConfigReport, err := cldf_ops.ExecuteOperation(b, commit_offramp.SetSignatureConfigs, chain, contract.FunctionInput[commit_offramp.SignatureConfigArgs]{
321333
ChainSelector: chain.Selector,

chains/evm/deployment/v1_7_0/sequences/deploy_chain_contracts_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestDeployChainContracts_Idempotency(t *testing.T) {
117117
},
118118
)
119119
require.NoError(t, err, "ExecuteSequence should not error")
120-
require.Len(t, report.Output.Addresses, 13, "Expected 13 addresses in output")
120+
require.Len(t, report.Output.Addresses, 14, "Expected 14 addresses in output")
121121
require.Len(t, report.Output.Writes, 4, "Expected 4 writes in output")
122122
for _, write := range report.Output.Writes {
123123
// Contracts are deployed & still owned by deployer, so all writes should be executed
@@ -230,7 +230,7 @@ func TestDeployChainContracts_MultipleDeployments(t *testing.T) {
230230

231231
for i, report := range allReports {
232232
require.NotEmpty(t, report.Output.Addresses, "Expected addresses for chain %d", chainSelectors[i])
233-
require.Len(t, report.Output.Addresses, 13)
233+
require.Len(t, report.Output.Addresses, 14)
234234
}
235235
})
236236

@@ -339,7 +339,7 @@ func TestDeployChainContracts_MultipleDeployments(t *testing.T) {
339339
for _, result := range results {
340340
require.NoError(t, result.err, "Failed to execute sequence for chain %d", result.chainSelector)
341341
require.NotEmpty(t, result.report.Output.Addresses, "Expected addresses for chain %d", result.chainSelector)
342-
require.Len(t, result.report.Output.Addresses, 13)
342+
require.Len(t, result.report.Output.Addresses, 14)
343343
}
344344
})
345345
}

chains/evm/gobindings/generated/latest/mock_receiver_v2/mock_receiver_v2.go

Lines changed: 255 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)