Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0b607bb
Add deploy + setKeeperRegistry changesets
bitrider23 May 5, 2026
5f11f43
Add constant to set the eth bal mon contract type
bitrider23 May 5, 2026
098e534
Change files names
bitrider23 May 5, 2026
497d267
Remove renounceRole logic since it is not neccesary
bitrider23 May 5, 2026
b5fa134
Improve setKeeperRegistryAddress changeset strcuture
bitrider23 May 5, 2026
97ce85d
add setWatchList changeset
bitrider23 May 6, 2026
45d7569
fix import error
bitrider23 May 6, 2026
a25ed4b
Change logic on setKeeperRegistryAddress to use new proposal builder
bitrider23 May 6, 2026
4610db7
Add withdraw changeset
bitrider23 May 7, 2026
57bde83
add transferOwnership changeset
bitrider23 May 8, 2026
f4116b5
Add deploy ethbalmon testing
bitrider23 May 8, 2026
4bb993a
Add more deploy tests
bitrider23 May 8, 2026
c3b46d0
Add ethBalMon setWatchList validate configuration function
bitrider23 May 8, 2026
20a33c5
Merge branch 'develop' into feat/deploy_ethbalmon
bitrider23 May 8, 2026
87fb2e9
Remove unused package
bitrider23 May 8, 2026
5edb5ab
Fix lint feedback
bitrider23 May 8, 2026
aae63ef
Fix lint feedback
bitrider23 May 8, 2026
99955d2
Merge branch 'develop' into feat/deploy_ethbalmon
bitrider23 May 11, 2026
01006e9
Fix lint
bitrider23 May 11, 2026
88960cb
Remove unnecesary conversion
bitrider23 May 11, 2026
04d17aa
Remove wrong comment
bitrider23 May 11, 2026
8711270
Add useful comments for types
bitrider23 May 11, 2026
666ecaa
Change log info
bitrider23 May 11, 2026
8dbcab1
Get output after check error
bitrider23 May 12, 2026
466268a
Fix validations
bitrider23 May 12, 2026
0b44240
Change withdraw config amount type
bitrider23 May 12, 2026
27a9267
leave the inspector as nil and complete on proposalutils functions
bitrider23 May 12, 2026
9699421
Rename files from camel case to snake
bitrider23 May 12, 2026
147cc2e
Change action based on mcmc config input
bitrider23 May 13, 2026
4cbd039
Fix lint
bitrider23 May 13, 2026
68cb16b
Format structures
bitrider23 May 13, 2026
57663e6
Format file
bitrider23 May 13, 2026
7933f54
Validate balance >0
bitrider23 May 13, 2026
ee1d25f
Validate MCMS is on datastore
bitrider23 May 13, 2026
558faf6
Add zero address check after check if is valid hex
bitrider23 May 13, 2026
0db1992
Format file
bitrider23 May 13, 2026
730d65d
Fix copilot feedback
bitrider23 May 14, 2026
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
510 changes: 510 additions & 0 deletions deployment/vault/changeset/ethbalmon_deploy.go

Large diffs are not rendered by default.

699 changes: 699 additions & 0 deletions deployment/vault/changeset/ethbalmon_deploy_test.go

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions deployment/vault/changeset/ethbalmon_mcms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package changeset

import (
mcmstypes "github.com/smartcontractkit/mcms/types"

cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"

"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
)

// ethBalMonMCMSContractTypeForAction selects the MCMS contract type in the datastore for EthBalMon
// timelock proposals, matching operations.generateMCMSProposals.
func ethBalMonMCMSContractTypeForAction(action mcmstypes.TimelockAction) cldf.ContractType {
if action == mcmstypes.TimelockActionBypass {
return commontypes.BypasserManyChainMultisig
}
return commontypes.ProposerManyChainMultisig
}

// ethBalMonMCMSContractTypeForProposal resolves MCMS datastore type from optional timelock config.
// When cfg is nil or MCMSAction is empty, the action is treated as schedule (non-bypass), so the proposer MCM is used.
func ethBalMonMCMSContractTypeForProposal(cfg *proposalutils.TimelockConfig) cldf.ContractType {
action := mcmstypes.TimelockActionSchedule
if cfg != nil && cfg.MCMSAction != "" {
action = cfg.MCMSAction
}
return ethBalMonMCMSContractTypeForAction(action)
}

func ethBalMonProposalTimelockConfig(cfg *proposalutils.TimelockConfig) proposalutils.TimelockConfig {
if cfg == nil {
return proposalutils.TimelockConfig{MinDelay: 0}
}
return *cfg
}

// deployEthBalMonAcceptOwnershipMCMSAction returns the MCMS timelock action for the post-deploy accept-ownership proposal.
// When cfg is nil or MCMSAction is unset, the deploy flow defaults to bypass.
func deployEthBalMonAcceptOwnershipMCMSAction(cfg *proposalutils.TimelockConfig) mcmstypes.TimelockAction {
if cfg == nil || cfg.MCMSAction == "" {
return mcmstypes.TimelockActionBypass
}
return cfg.MCMSAction
}

func deployEthBalMonAcceptOwnershipTimelockConfig(cfg *proposalutils.TimelockConfig) proposalutils.TimelockConfig {
out := proposalutils.TimelockConfig{MinDelay: 0}
if cfg != nil {
out = *cfg
}
if out.MCMSAction == "" {
out.MCMSAction = mcmstypes.TimelockActionBypass
}
return out
}
257 changes: 257 additions & 0 deletions deployment/vault/changeset/ethbalmon_set_keeper_registry_address.go
Comment thread
bitrider23 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
package changeset

import (
"encoding/json"
"errors"
"fmt"

"github.com/Masterminds/semver/v3"
"github.com/ethereum/go-ethereum/common"
"github.com/smartcontractkit/mcms"
mcmstypes "github.com/smartcontractkit/mcms/types"

cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/generated/eth_balance_monitor_wrapper"
"github.com/smartcontractkit/chainlink/deployment/common/proposalutils"
commontypes "github.com/smartcontractkit/chainlink/deployment/common/types"
vaulttypes "github.com/smartcontractkit/chainlink/deployment/vault/changeset/types"
)

type setKeeperRegistryAddress struct{}

var SetKeeperRegistryAddress cldf.ChangeSetV2[vaulttypes.EthBalMonSetKeeperRegistryAddressInput] = setKeeperRegistryAddress{}

func (sk setKeeperRegistryAddress) VerifyPreconditions(env cldf.Environment, config vaulttypes.EthBalMonSetKeeperRegistryAddressInput) error {
return ValidateSetKeeperRegistryAddressConfig(env.GetContext(), env, config)
}

func (sk setKeeperRegistryAddress) Apply(
e cldf.Environment,
config vaulttypes.EthBalMonSetKeeperRegistryAddressInput,
) (cldf.ChangesetOutput, error) {
logger := e.Logger
logger.Infow("Generating SetKeeperRegistryAddress proposal for Ethereum Balance Monitor",
"numChains", len(config.Chains),
)

evmChains := e.BlockChains.EVMChains()

var primaryChain cldf_evm.Chain
for chainSelector := range config.Chains {
primaryChain = evmChains[chainSelector]
break
}

deps := VaultDeps{
Auth: primaryChain.DeployerKey,
Chain: primaryChain,
Environment: e,
DataStore: e.DataStore,
}

seqInput := EthBalMonSetKeeperRegistryAddressSequenceInput{
Chains: config.Chains,
MCMSConfig: config.MCMSConfig,
}

seqReport, err := operations.ExecuteSequence(
e.OperationsBundle,
SetKeeperRegistrySequence,
deps,
seqInput,
)
if err != nil {
return cldf.ChangesetOutput{}, fmt.Errorf("failed to set keeper registry address sequence: %w", err)
}

return cldf.ChangesetOutput{
MCMSTimelockProposals: seqReport.Output.MCMSTimelockProposals,
}, nil
}

type EthBalMonSetKeeperRegistryAddressSequenceInput struct {
Chains map[uint64]vaulttypes.SetKeeperRegistryChainConfig `json:"chains"`
MCMSConfig *proposalutils.TimelockConfig `json:"mcms_config,omitempty"`
}

type EthBalMonSetKeeperRegistryAddressSequenceOutput struct {
MCMSTimelockProposals []mcms.TimelockProposal
}

var SetKeeperRegistrySequence = operations.NewSequence(
"ethbalmon-set-keeper-registry",
semver.MustParse("1.0.0"),
"Generate MCMS timelock proposal to set Keeper Registry address on EthBalMon across chains",
func(
b operations.Bundle,
deps VaultDeps,
input EthBalMonSetKeeperRegistryAddressSequenceInput,
) (EthBalMonSetKeeperRegistryAddressSequenceOutput, error) {
b.Logger.Infow("Starting EthBalMon set keeper registry sequence",
"chains", len(input.Chains),
)

if len(input.Chains) == 0 {
return EthBalMonSetKeeperRegistryAddressSequenceOutput{}, errors.New("no chains provided")
}

var batches []mcmstypes.BatchOperation
timelockAddresses := make(map[uint64]string)
mcmAddressByChain := make(map[uint64]string)

for chainSelector, chainConfig := range input.Chains {
opReport, err := operations.ExecuteOperation(
b,
SetKeeperRegistryOperation,
deps,
SetKeeperRegistryOperationInput{
ChainSelector: chainSelector,
NewKeeperRegistryAddress: chainConfig.NewKeeperRegistryAddress,
MCMSConfig: input.MCMSConfig,
},
)
if err != nil {
return EthBalMonSetKeeperRegistryAddressSequenceOutput{},
fmt.Errorf("chain %d: failed to generate set keeper registry batch: %w", chainSelector, err)
}

opOut := opReport.Output

batches = append(batches, opOut.BatchOperation)
timelockAddresses[chainSelector] = opOut.TimelockAddress
mcmAddressByChain[chainSelector] = opOut.MCMSAddress
}

proposal, err := proposalutils.BuildProposalFromBatchesV2(
deps.Environment,
timelockAddresses,
mcmAddressByChain,
nil,
batches,
"EthBalMon SetKeeperRegistryAddress",
ethBalMonProposalTimelockConfig(input.MCMSConfig),
)
if err != nil {
return EthBalMonSetKeeperRegistryAddressSequenceOutput{},
fmt.Errorf("failed to build timelock proposal: %w", err)
}

b.Logger.Infow("Generated EthBalMon set keeper registry proposal",
"chains", len(input.Chains),
"operations", len(batches),
)

return EthBalMonSetKeeperRegistryAddressSequenceOutput{
MCMSTimelockProposals: []mcms.TimelockProposal{*proposal},
}, nil
},
)

type SetKeeperRegistryOperationInput struct {
ChainSelector uint64 `json:"chain_selector"`
NewKeeperRegistryAddress string `json:"new_keeper_registry_address"`
MCMSConfig *proposalutils.TimelockConfig `json:"mcms_config,omitempty"`
}

type SetKeeperRegistryOperationOutput struct {
ChainSelector uint64 `json:"chain_selector"`
BatchOperation mcmstypes.BatchOperation `json:"batch_operation"`
TimelockAddress string `json:"timelock_address"`
MCMSAddress string `json:"mcms_address"`
}

var SetKeeperRegistryOperation = operations.NewOperation(
"ethbalmon-set-keeper-registry-op",
semver.MustParse("1.0.0"),
"Generate batch operation to set Keeper Registry address on the Ethereum Balance Monitor contract",
func(
b operations.Bundle,
deps VaultDeps,
input SetKeeperRegistryOperationInput,
) (SetKeeperRegistryOperationOutput, error) {
chain, ok := deps.Environment.BlockChains.EVMChains()[input.ChainSelector]
if !ok {
return SetKeeperRegistryOperationOutput{}, fmt.Errorf("chain not found in environment: %d", input.ChainSelector)
}

ethBalMonAddr, err := mustGetContractAddress(
deps.DataStore,
input.ChainSelector,
cldf.ContractType(vaulttypes.EthBalMonContractType),
)
if err != nil {
return SetKeeperRegistryOperationOutput{},
fmt.Errorf("failed to get EthBalMon address: %w", err)
}

timelockAddr, err := mustGetContractAddress(
deps.DataStore,
input.ChainSelector,
commontypes.RBACTimelock,
)
if err != nil {
return SetKeeperRegistryOperationOutput{},
fmt.Errorf("failed to get timelock address: %w", err)
}

mcmsAddr, err := mustGetContractAddress(
deps.DataStore,
input.ChainSelector,
ethBalMonMCMSContractTypeForProposal(input.MCMSConfig),
)
if err != nil {
return SetKeeperRegistryOperationOutput{},
fmt.Errorf("failed to get MCMS address: %w", err)
}

ethBalMon, err := eth_balance_monitor_wrapper.NewEthBalanceMonitor(
common.HexToAddress(ethBalMonAddr),
chain.Client,
)
if err != nil {
return SetKeeperRegistryOperationOutput{},
fmt.Errorf("failed to instantiate EthBalanceMonitor at %s: %w", ethBalMonAddr, err)
}

setKeeperRegistryTx, err := ethBalMon.SetKeeperRegistryAddress(
cldf.SimTransactOpts(),
common.HexToAddress(input.NewKeeperRegistryAddress),
)
if err != nil {
return SetKeeperRegistryOperationOutput{},
fmt.Errorf("failed to generate setKeeperRegistryAddress calldata: %w", err)
}

batch := mcmstypes.BatchOperation{
ChainSelector: mcmstypes.ChainSelector(input.ChainSelector),
Transactions: []mcmstypes.Transaction{
{
OperationMetadata: mcmstypes.OperationMetadata{
ContractType: vaulttypes.EthBalMonContractType,
Tags: []string{
"setKeeperRegistryAddress",
},
},
To: ethBalMonAddr,
Data: setKeeperRegistryTx.Data(),
AdditionalFields: json.RawMessage(`{"value": 0}`),
},
},
}

b.Logger.Infow("Generated EthBalMon set keeper registry batch",
"chainSelector", input.ChainSelector,
"ethBalMon", ethBalMonAddr,
"newKeeperRegistry", input.NewKeeperRegistryAddress,
)

return SetKeeperRegistryOperationOutput{
ChainSelector: input.ChainSelector,
BatchOperation: batch,
TimelockAddress: timelockAddr,
MCMSAddress: mcmsAddr,
}, nil
},
)
Loading
Loading