Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deployment/common/proposalutils/propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type TimelockConfig struct {
MCMSAction types.TimelockAction `json:"mcmsAction"`
OverrideRoot bool `json:"overrideRoot"` // if true, override the previous root with the new one.
TimelockQualifierPerChain map[uint64]string `json:"timelockQualifierPerChain,omitempty"` // optional qualifier to fetch timelock address from datastore
ValidDuration *time.Duration `json:"validDuration" yaml:"validDuration"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to validUntil to match the name of the attribute in the proposal itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, nevermind. I see the semantic is different. It's a duration, not a timestamp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be the case. The proposal field contains the full duration (NOW seconds + whatever time duration we set), and the config we are adding just contains the extra time we are adding to the NOW seconds.

So each one has its own meaning.

}

func (tc *TimelockConfig) MCMBasedOnActionSolana(s state.MCMSWithTimelockStateSolana) (string, error) {
Expand Down Expand Up @@ -212,7 +213,11 @@ func BuildProposalFromBatchesV2(
return nil, err
}

validUntil := time.Now().Unix() + int64(DefaultValidUntil.Seconds())
proposalDuration := DefaultValidUntil
if mcmsCfg.ValidDuration != nil {
proposalDuration = *mcmsCfg.ValidDuration
}
validUntil := time.Now().Add(proposalDuration).Unix()

builder := mcmslib.NewTimelockProposalBuilder()
builder.
Expand Down
28 changes: 28 additions & 0 deletions deployment/cre/common/strategies/mcms_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package strategies_test
import (
"math/big"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
mcmstypes "github.com/smartcontractkit/mcms/types"
Expand Down Expand Up @@ -201,4 +202,31 @@ func TestMCMSTransaction_BuildProposal(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, mcmsContracts.CancellerMcm.Address().String(), metadata.MCMAddress)
})

t.Run("uses custom ValidDuration value to set the proposal duration", func(t *testing.T) {
m := getMCMSTransaction(t, *fixture.Env)
validDuration := 2 * time.Second
cfg := contracts.MCMSConfig{
MinDelay: 0,
TimelockQualifierPerChain: map[uint64]string{
fixture.RegistrySelector: "",
},
ValidDuration: &validDuration,
}
mcmsContracts, err := strategies.GetMCMSContracts(*fixture.Env, fixture.RegistrySelector, cfg)
require.NoError(t, err)
m.Config = &cfg
m.MCMSContracts = mcmsContracts
m.ChainSel = fixture.RegistrySelector

op, err := proposalutils.BatchOperationForChain(m.ChainSel, m.Address.Hex(), []byte{0x01, 0x02, 0x03}, big.NewInt(0), "", nil)
require.NoError(t, err)

p, err := m.BuildProposal([]mcmstypes.BatchOperation{op})
require.NoError(t, err)

expectedValidUntil := time.Now().Add(validDuration).Unix()
// Using InDelta to allow for slight timing differences during test execution
assert.InDelta(t, uint32(expectedValidUntil), p.ValidUntil, 1, "ValidUntil should be within 1 second of expected value") //nolint:gosec // G115
})
}
8 changes: 3 additions & 5 deletions deployment/cre/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"

"github.com/smartcontractkit/chainlink/deployment/common/changeset/state"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"

"github.com/smartcontractkit/chainlink-deployments-framework/datastore"

cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"

"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/common/changeset/state"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
"github.com/smartcontractkit/chainlink/deployment/common/types"

capabilities_registry "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0"
Expand Down
Loading