Skip to content

Commit b8f7aee

Browse files
authored
Add new changeset + simplify tokenPool ops (#102)
* new build * high tx timeout * more logs * more logs * bump max conc req * rate limit logs * moew logs * bump timeoutCtx * no rate limit * public convert mapkeys to cc * register reciever cs * nit cleanup * updated bnm token pool * added CCIPBurnMintTokenPoolOwnerId * pool bytes, token 32byte * possible semphore fix * faisal fix * more logs * nb * wip upgrade * nit * cleanups * rebased * fix go mod issue * downgraded mcms package * go mod nit * revert mcms gomod * rebased * fix ci * nit * go mod tidy fix * updated gomd * debug log * lint * spelling nit
1 parent 629398b commit b8f7aee

File tree

25 files changed

+412
-80
lines changed

25 files changed

+412
-80
lines changed

deployment/changesets/cd_deploy_tp_and_configure.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package changesets
22

33
import (
4+
"fmt"
5+
46
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
57
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
68
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
@@ -26,6 +28,7 @@ var _ cldf.ChangeSetV2[DeployTPAndConfigureConfig] = DeployTPAndConfigure{}
2628

2729
// Apply implements deployment.ChangeSetV2.
2830
func (d DeployTPAndConfigure) Apply(e cldf.Environment, config DeployTPAndConfigureConfig) (cldf.ChangesetOutput, error) {
31+
ab := cldf.NewMemoryAddressBook()
2932
state, err := deployment.LoadOnchainStatesui(e)
3033
if err != nil {
3134
return cldf.ChangesetOutput{}, err
@@ -67,10 +70,31 @@ func (d DeployTPAndConfigure) Apply(e cldf.Environment, config DeployTPAndConfig
6770
config.BurnMintTpInput.CCIPObjectRefObjectId = state[config.SuiChainSelector].CCIPObjectRef
6871
config.BurnMintTpInput.TokenPoolAdministrator = deployerAddr // check with felix if this is fine
6972

70-
_, err = operations.ExecuteSequence(e.OperationsBundle, burnminttokenpoolops.DeployAndInitBurnMintTokenPoolSequence, deps, config.BurnMintTpInput)
73+
BnMTokenPoolSeqReport, err := operations.ExecuteSequence(e.OperationsBundle, burnminttokenpoolops.DeployAndInitBurnMintTokenPoolSequence, deps, config.BurnMintTpInput)
7174
if err != nil {
7275
return cldf.ChangesetOutput{}, err
7376
}
77+
78+
// save BnM Pool to the addressbook
79+
typeAndVersionBurnMintTokenPool := cldf.NewTypeAndVersion(deployment.SuiBnMTokenPoolType, deployment.Version1_0_0)
80+
err = ab.Save(config.SuiChainSelector, BnMTokenPoolSeqReport.Output.BurnMintTPPackageID, typeAndVersionBurnMintTokenPool)
81+
if err != nil {
82+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save BnMTokenPool address %s for Sui chain %d: %w", BnMTokenPoolSeqReport.Output.BurnMintTPPackageID, config.SuiChainSelector, err)
83+
}
84+
85+
// save BnM Pool State to the addressBook
86+
typeAndVersionBurnMintTokenPoolState := cldf.NewTypeAndVersion(deployment.SuiBnMTokenPoolStateType, deployment.Version1_0_0)
87+
err = ab.Save(config.SuiChainSelector, BnMTokenPoolSeqReport.Output.Objects.StateObjectId, typeAndVersionBurnMintTokenPoolState)
88+
if err != nil {
89+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save BnMTokenPoolState address %s for Sui chain %d: %w", BnMTokenPoolSeqReport.Output.Objects.StateObjectId, config.SuiChainSelector, err)
90+
}
91+
92+
// save BnM Pool OwnerId to the addressBook
93+
typeAndVersionBurnMintTokenPoolOwnerId := cldf.NewTypeAndVersion(deployment.SuiBnMTokenPoolOwnerIDType, deployment.Version1_0_0)
94+
err = ab.Save(config.SuiChainSelector, BnMTokenPoolSeqReport.Output.Objects.OwnerCapObjectId, typeAndVersionBurnMintTokenPoolOwnerId)
95+
if err != nil {
96+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save BnMTokenPoolOwnerCapId address %s for Sui chain %d: %w", BnMTokenPoolSeqReport.Output.Objects.OwnerCapObjectId, config.SuiChainSelector, err)
97+
}
7498
}
7599

76100
if tokenPoolType == "lnr" {
@@ -103,7 +127,8 @@ func (d DeployTPAndConfigure) Apply(e cldf.Environment, config DeployTPAndConfig
103127
}
104128

105129
return cldf.ChangesetOutput{
106-
Reports: seqReports,
130+
AddressBook: ab,
131+
Reports: seqReports,
107132
}, nil
108133
}
109134

deployment/changesets/cs_add_remote_tp.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func (d AddRemoteTP) Apply(e cldf.Environment, config AddRemoteTPConfig) (cldf.C
5050
}
5151

5252
// Todo: validate that len of TokenpoolTypes == RemoteChainSelectors == RemotePoolAddressToAdd
53-
5453
for _, tokenPoolType := range config.TokenPoolTypes {
5554
if tokenPoolType == "lnr" {
5655
for i, chainSelector := range config.RemoteChainSelectors {

deployment/changesets/cs_deploy_dummy_receiver.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import (
1111
ccipops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip"
1212
)
1313

14-
type DeployDummyRecieverConfig struct {
14+
type DeployDummyReceiverConfig struct {
1515
SuiChainSelector uint64
1616
McmsOwner string
1717
}
1818

19-
var _ cldf.ChangeSetV2[DeployDummyRecieverConfig] = DeployDummyReciever{}
19+
var _ cldf.ChangeSetV2[DeployDummyReceiverConfig] = DeployDummyReceiver{}
2020

2121
// DeployAptosChain deploys Aptos chain packages and modules
22-
type DeployDummyReciever struct{}
22+
type DeployDummyReceiver struct{}
2323

2424
// Apply implements deployment.ChangeSetV2.
25-
func (d DeployDummyReciever) Apply(e cldf.Environment, config DeployDummyRecieverConfig) (cldf.ChangesetOutput, error) {
25+
func (d DeployDummyReceiver) Apply(e cldf.Environment, config DeployDummyReceiverConfig) (cldf.ChangesetOutput, error) {
2626
state, err := deployment.LoadOnchainStatesui(e)
2727
if err != nil {
2828
return cldf.ChangesetOutput{}, err
@@ -45,7 +45,7 @@ func (d DeployDummyReciever) Apply(e cldf.Environment, config DeployDummyRecieve
4545
},
4646
}
4747

48-
// Run DummyReciever Operation
48+
// Run DummyReceiver Operation
4949
DeployDummyReceiverOp, err := operations.ExecuteOperation(e.OperationsBundle, ccipops.DeployCCIPDummyReceiverOp, deps, ccipops.DeployDummyReceiverInput{
5050
CCIPPackageId: state[config.SuiChainSelector].CCIPAddress,
5151
McmsPackageId: state[config.SuiChainSelector].MCMsAddress,
@@ -55,8 +55,7 @@ func (d DeployDummyReciever) Apply(e cldf.Environment, config DeployDummyRecieve
5555
return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy LinkToken for Sui chain %d: %w", config.SuiChainSelector, err)
5656
}
5757

58-
// register reciever
59-
58+
// register receiver
6059
seqReports = append(seqReports, []operations.Report[any, any]{DeployDummyReceiverOp.ToGenericReport()}...)
6160

6261
return cldf.ChangesetOutput{
@@ -66,6 +65,6 @@ func (d DeployDummyReciever) Apply(e cldf.Environment, config DeployDummyRecieve
6665
}
6766

6867
// VerifyPreconditions implements deployment.ChangeSetV2.
69-
func (d DeployDummyReciever) VerifyPreconditions(e cldf.Environment, config DeployDummyRecieverConfig) error {
68+
func (d DeployDummyReceiver) VerifyPreconditions(e cldf.Environment, config DeployDummyReceiverConfig) error {
7069
return nil
7170
}

deployment/changesets/cs_deploy_sui_chain.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,18 @@ func (d DeploySuiChain) Apply(e cldf.Environment, config DeploySuiChainConfig) (
186186
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save onRamp state object Id %s for Sui chain %d: %w", ccipOnRampSeqReport.Output.Objects.StateObjectId, config.DestChainSelector, err)
187187
}
188188

189+
// save OnRampOwnerCapObjectID to addressbook
189190
typeAndVersionOnRampOwnerCapObjectId := cldf.NewTypeAndVersion(deployment.SuiOnRampOwnerCapObjectIDType, deployment.Version1_0_0)
190191
err = ab.Save(config.SuiChainSelector, ccipOnRampSeqReport.Output.Objects.OwnerCapObjectId, typeAndVersionOnRampOwnerCapObjectId)
191192
if err != nil {
192-
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save onRamp state object Id %s for Sui chain %d: %w", ccipOnRampSeqReport.Output.Objects.StateObjectId, config.DestChainSelector, err)
193+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save OnRampOwnerCapObjectID %s for Sui chain %d: %w", ccipOnRampSeqReport.Output.Objects.StateObjectId, config.DestChainSelector, err)
194+
}
195+
196+
// save OnRampUpgradeCapId to addressbook
197+
typeAndVersionOnRampUpgradeCapId := cldf.NewTypeAndVersion(deployment.SuiOnRampUpgradeCapObjectIDType, deployment.Version1_0_0)
198+
err = ab.Save(config.SuiChainSelector, ccipOnRampSeqReport.Output.Objects.UpgradeCapObjectId, typeAndVersionOnRampUpgradeCapId)
199+
if err != nil {
200+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to save OnRampUpgradeCapId %s for Sui chain %d: %w", ccipOnRampSeqReport.Output.Objects.StateObjectId, config.DestChainSelector, err)
193201
}
194202

195203
// --------------------------

deployment/changesets/cs_mint_token.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ func (d MintLinkToken) Apply(e cldf.Environment, config MintLinkTokenConfig) (cl
5656

5757
seqReports = append(seqReports, mintLinkTokenReport.ToGenericReport())
5858

59-
fmt.Println("MINT TOKEN REPORT: ", seqReports)
60-
6159
return cldf.ChangesetOutput{
6260
AddressBook: ab,
6361
Reports: seqReports,
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package changesets
2+
3+
import (
4+
"fmt"
5+
6+
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
7+
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
8+
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
9+
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
10+
ccipops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip"
11+
)
12+
13+
type RegisterDummyReceiverConfig struct {
14+
SuiChainSelector uint64
15+
CCIPObjectRefObjectId string
16+
DummyReceiverPackageId string
17+
}
18+
19+
var _ cldf.ChangeSetV2[RegisterDummyReceiverConfig] = RegisterDummyReceiver{}
20+
21+
type RegisterDummyReceiver struct{}
22+
23+
// Apply implements deployment.ChangeSetV2.
24+
func (d RegisterDummyReceiver) Apply(e cldf.Environment, config RegisterDummyReceiverConfig) (cldf.ChangesetOutput, error) {
25+
ab := cldf.NewMemoryAddressBook()
26+
seqReports := make([]operations.Report[any, any], 0)
27+
28+
suiChain := e.BlockChains.SuiChains()[config.SuiChainSelector]
29+
30+
deps := sui_ops.OpTxDeps{
31+
Client: suiChain.Client,
32+
Signer: suiChain.Signer,
33+
GetCallOpts: func() *bind.CallOpts {
34+
b := uint64(400_000_000)
35+
return &bind.CallOpts{
36+
WaitForExecution: true,
37+
GasBudget: &b,
38+
}
39+
},
40+
}
41+
42+
// Run RegisterReceiver Operation
43+
RegisterReceiverOp, err := operations.ExecuteOperation(e.OperationsBundle, ccipops.RegisterDummyReceiverOp, deps, ccipops.RegisterDummyReceiverInput{
44+
CCIPObjectRefObjectId: config.CCIPObjectRefObjectId,
45+
DummyReceiverPackageId: config.DummyReceiverPackageId,
46+
})
47+
if err != nil {
48+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to register receiver for Sui chain %d: %w", config.SuiChainSelector, err)
49+
}
50+
51+
seqReports = append(seqReports, []operations.Report[any, any]{RegisterReceiverOp.ToGenericReport()}...)
52+
53+
return cldf.ChangesetOutput{
54+
AddressBook: ab,
55+
Reports: seqReports,
56+
}, nil
57+
}
58+
59+
// VerifyPreconditions implements deployment.ChangeSetV2.
60+
func (d RegisterDummyReceiver) VerifyPreconditions(e cldf.Environment, config RegisterDummyReceiverConfig) error {
61+
return nil
62+
}

deployment/common.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package deployment
2+
3+
import (
4+
"encoding/hex"
5+
"fmt"
6+
"strings"
7+
)
8+
9+
func StrToBytes(s string) ([]byte, error) {
10+
raw, err := hex.DecodeString(strings.TrimSpace(strings.TrimPrefix(s, "0x")))
11+
if err != nil {
12+
return nil, err
13+
}
14+
return raw, nil
15+
}
16+
17+
func StrTo32(s string) ([]byte, error) {
18+
raw, err := hex.DecodeString(strings.TrimSpace(strings.TrimPrefix(s, "0x")))
19+
if err != nil {
20+
return nil, err
21+
}
22+
if len(raw) > 32 {
23+
return nil, fmt.Errorf("address longer than 32 bytes: %d", len(raw))
24+
}
25+
out := make([]byte, 32)
26+
copy(out[32-len(raw):], raw) // left-pad with zeros
27+
return out, nil
28+
}

deployment/ops/ccip/op_register_dummy_receiver.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
type RegisterDummyReceiverInput struct {
1616
CCIPObjectRefObjectId string
1717
DummyReceiverPackageId string
18-
ReceiverStateParams []string
1918
}
2019

2120
type RegisterDummyReceiverObjects struct {
@@ -39,15 +38,13 @@ var registerDummyReceiverHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps,
3938
b.GetContext(),
4039
opts,
4140
bind.Object{Id: input.CCIPObjectRefObjectId},
42-
//input.ReceiverStateParams,
4341
)
4442
if err != nil {
4543
return sui_ops.OpTxResult[RegisterDummyReceiverObjects]{}, fmt.Errorf("failed to execute dummy receiver registration: %w", err)
4644
}
4745

4846
b.Logger.Infow("Dummy receiver registered",
4947
"dummyReceiverPackageId", input.DummyReceiverPackageId,
50-
"receiverStateParams", input.ReceiverStateParams,
5148
)
5249

5350
return sui_ops.OpTxResult[RegisterDummyReceiverObjects]{

deployment/ops/ccip/seq_deploy_and_init_dummy_receiver.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type DeployAndInitDummyReceiverInput struct {
1313
DeployDummyReceiverInput
1414
// For registration
1515
CCIPObjectRefObjectId string
16-
ReceiverStateParams []string
1716
}
1817

1918
type DeployDummyReceiverSeqObjects struct {
@@ -54,7 +53,6 @@ var DeployAndInitDummyReceiverSequence = cld_ops.NewSequence(
5453
RegisterDummyReceiverInput{
5554
CCIPObjectRefObjectId: input.CCIPObjectRefObjectId,
5655
DummyReceiverPackageId: deployReport.Output.PackageId,
57-
ReceiverStateParams: input.ReceiverStateParams,
5856
},
5957
)
6058
if err != nil {

deployment/ops/ccip_burn_mint_token_pool/op_burn_mint_token_pool.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
1111
module_burn_mint_token_pool "github.com/smartcontractkit/chainlink-sui/bindings/generated/ccip/ccip_token_pools/burn_mint_token_pool"
12+
"github.com/smartcontractkit/chainlink-sui/deployment"
1213
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
1314
)
1415

@@ -155,14 +156,22 @@ var applyChainUpdates = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input Burn
155156
for i, addresses := range input.RemotePoolAddressesToAdd {
156157
remotePoolAddressesBytes[i] = make([][]byte, len(addresses))
157158
for j, address := range addresses {
158-
remotePoolAddressesBytes[i][j] = []byte(address)
159+
b, err := deployment.StrToBytes(address)
160+
if err != nil {
161+
return sui_ops.OpTxResult[NoObjects]{}, fmt.Errorf("bad remote pool address [%d][%d]: %w", i, j, err)
162+
}
163+
remotePoolAddressesBytes[i][j] = b
159164
}
160165
}
161166

162167
// Convert []string to [][]byte for RemoteTokenAddressesToAdd
163168
remoteTokenAddressesBytes := make([][]byte, len(input.RemoteTokenAddressesToAdd))
164169
for i, address := range input.RemoteTokenAddressesToAdd {
165-
remoteTokenAddressesBytes[i] = []byte(address)
170+
b32, err := deployment.StrTo32(address)
171+
if err != nil {
172+
return sui_ops.OpTxResult[NoObjects]{}, fmt.Errorf("bad remote token address [%d]: %w", i, err)
173+
}
174+
remoteTokenAddressesBytes[i] = b32
166175
}
167176

168177
opts := deps.GetCallOpts()

0 commit comments

Comments
 (0)