From 7c2ecf0d39347a53e68447f5239aa4c0510b9e23 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 12 Dec 2024 18:12:42 -0600 Subject: [PATCH] fix: remove valid unit to reuse util for proposal creation --- .../common/changeset/example/link_transfer.go | 28 ++++++------------- .../changeset/example/link_transfer_test.go | 23 ++------------- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/deployment/common/changeset/example/link_transfer.go b/deployment/common/changeset/example/link_transfer.go index 5073d90c235..2e3be48a4d1 100644 --- a/deployment/common/changeset/example/link_transfer.go +++ b/deployment/common/changeset/example/link_transfer.go @@ -29,7 +29,6 @@ type TransferConfig struct { } type MCMSConfig struct { - ValidUntil uint32 // unix time until the proposal will be valid MinDelay time.Duration // delay for timelock worker to execute the transfers. OverrideRoot bool } @@ -113,10 +112,7 @@ func (cfg LinkTransferConfig) Validate(e deployment.Environment) error { if cfg.McmsConfig.MinDelay > MaxTimelockDelay { return errors.New("minDelay must be less than 7 days") } - // Check that validUntil is in the future - if time.Unix(int64(cfg.McmsConfig.ValidUntil), 0).Before(time.Now()) { - return fmt.Errorf("validUntil must be in the future") - } + return nil } @@ -180,7 +176,7 @@ func LinkTransfer(e deployment.Environment, cfg *LinkTransferConfig) (deployment } mcmsPerChain := map[uint64]*owner_helpers.ManyChainMultiSig{} - timelockAddresses := map[mcms.ChainIdentifier]common.Address{} + timelockAddresses := map[uint64]common.Address{} // Initialize state for each chain linkStatePerChain, mcmsStatePerChain, err := initStatePerChain(cfg, e) @@ -196,7 +192,7 @@ func LinkTransfer(e deployment.Environment, cfg *LinkTransferConfig) (deployment mcmsPerChain[uint64(chainID)] = mcmsState.ProposerMcm - timelockAddresses[chainID] = timelockAddress + timelockAddresses[chainSelector] = timelockAddress batch := timelock.BatchChainOperation{ ChainIdentifier: chainID, Batch: []mcms.Operation{}, @@ -221,22 +217,14 @@ func LinkTransfer(e deployment.Environment, cfg *LinkTransferConfig) (deployment allBatches = append(allBatches, batch) } - chainMetadata, err := proposalutils.BuildProposalMetadata(chainSelectors, mcmsPerChain) - if err != nil { - return deployment.ChangesetOutput{}, err - } + if cfg.McmsConfig != nil { - proposal, err := timelock.NewMCMSWithTimelockProposal( - "1", - cfg.McmsConfig.ValidUntil, - []mcms.Signature{}, - cfg.McmsConfig.OverrideRoot, - chainMetadata, + proposal, err := proposalutils.BuildProposalFromBatches( timelockAddresses, - "Value transfer proposal", + mcmsPerChain, allBatches, - timelock.Schedule, - cfg.McmsConfig.MinDelay.String(), + "LINK Value transfer proposal", + cfg.McmsConfig.MinDelay, ) if err != nil { return deployment.ChangesetOutput{}, err diff --git a/deployment/common/changeset/example/link_transfer_test.go b/deployment/common/changeset/example/link_transfer_test.go index cd84613be00..eecfbd37c95 100644 --- a/deployment/common/changeset/example/link_transfer_test.go +++ b/deployment/common/changeset/example/link_transfer_test.go @@ -111,7 +111,6 @@ func TestLinkTransferMCMS(t *testing.T) { }, }, McmsConfig: &example.MCMSConfig{ - ValidUntil: 4131638958, MinDelay: 0, OverrideRoot: true, }, @@ -237,8 +236,7 @@ func TestValidate(t *testing.T) { chainSelector: {{To: mcmsState.Timelock.Address(), Value: big.NewInt(100)}}}, From: chain.DeployerKey.From, McmsConfig: &example.MCMSConfig{ - ValidUntil: uint32(time.Now().Add(1 * time.Hour).Unix()), - MinDelay: time.Hour, + MinDelay: time.Hour, }, }, }, @@ -262,8 +260,7 @@ func TestValidate(t *testing.T) { }, From: mcmsState.Timelock.Address(), McmsConfig: &example.MCMSConfig{ - ValidUntil: uint32(time.Now().Add(1 * time.Hour).Unix()), - MinDelay: time.Hour, + MinDelay: time.Hour, }, }, errorMsg: "sender does not have enough funds for transfers for chain selector 909606746561742123, required: 1850, available: 0", @@ -347,8 +344,7 @@ func TestValidate(t *testing.T) { chainSelector: {{To: mcmsState.Timelock.Address(), Value: big.NewInt(100)}}}, From: chain.DeployerKey.From, McmsConfig: &example.MCMSConfig{ - ValidUntil: uint32(time.Now().Add(1 * time.Hour).Unix()), - MinDelay: time.Hour * 24 * 10, + MinDelay: time.Hour * 24 * 10, }, }, errorMsg: "minDelay must be less than 7 days", @@ -361,19 +357,6 @@ func TestValidate(t *testing.T) { }, errorMsg: "'to' address for transfers must be set", }, - { - name: "invalid config: validUntil in the past", - cfg: example.LinkTransferConfig{ - Transfers: map[uint64][]example.TransferConfig{ - chainSelector: {{To: mcmsState.Timelock.Address(), Value: big.NewInt(100)}}}, - From: chain.DeployerKey.From, - McmsConfig: &example.MCMSConfig{ - ValidUntil: uint32(time.Now().Add(-1 * time.Hour).Unix()), - MinDelay: time.Hour, - }, - }, - errorMsg: "validUntil must be in the future", - }, } for _, tt := range tests {