Skip to content

Conversation

@ecPablo
Copy link
Collaborator

@ecPablo ecPablo commented Feb 6, 2026

This PR upgrades usages of the chain selectors lib to use the new Remote API smartcontractkit/chain-selectors#182
Notes:

  • The SUI and Aptos chain selectors remote APIs are not implemented yet. So we are keeping the local ones. Those chains don't have many updates so it's not as important to support that in the remote API + remote support is only available on EVM in the meantime.
  • A lot of the file changes are just standardising on the import name to chainsel
  • There's a couple of context.Background that I had to hardcode in the evm sdk. This is because we still need to provide a ctx variable at the interface level, which would mean a breaking change is introduced and all chain families sdk would need to be updated. I'd prefer to leave that for a separate PR to handle communications and keep things isolated in case of reverts, etc.

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: 5a07554

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smartcontractkit/mcms Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


// TODO: passing this as param requires a breaking change to the Encoder interfaces
// which requires changes too all chain specific SDKs. Consider refactoring later.
evmChainID, err := getEVMChainID(context.Background(), e.ChainSelector, e.IsSim)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to remove this context.Background() and pass it as a param. But doing so will mean modifying the interfaces on the sdk pkg which is a pretty significant breaking change. My proposal is to go with this suboptimal approach so we can get the benefits of the remote apis now, and work on adding the ctx as separate followup so we can scope all breaking changes in a single PR and document better the changes that product teams would need to do for announcements, etc.

// which requires changes too all chain specific SDKs. Consider refactoring later.
// this could even mean not using a ctx, and instead providing the chainID directly to the Encoder
// at construction time.
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) //nolint
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the code that we need to remove in the followup, by introducing a ctx param in the callstack, moving the chain selectors fetch upstream and just adding a chainID parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

ToGethRootMetadata is a public function (though I'm not sure it should be; as usual, we expose far more than we should, imo). And, as such, isn't this a breaking change anyways?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the question should be: you chose to preserve ToGetOperation but not ToGetRootMetadata. Why the distinction?

@ecPablo ecPablo marked this pull request as ready for review February 11, 2026 15:47
@ecPablo ecPablo requested a review from a team as a code owner February 11, 2026 15:47
ChrisAmora
ChrisAmora previously approved these changes Feb 11, 2026
@cl-sonarqube-production
Copy link

5, // Value in GWEI
"MyEVMContractType",
[]string{"tag1", "tag2"},
common.Address{},
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

builder.AddOperation(types.Operation{
ChainSelector: selector,
Transaction: tx,
ChainSelector: selector,
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

IsSigner: false,
IsWritable: true,
}
{
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

accounts,
"MySolanaContractType",
[]string{"tag1", "tag2"}
"programIDGoesHere",
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

toAddress := aptos.AccountAddress{}
if err := toAddress.ParseStringRelaxed("0xe2bb72029d2e1f48b7bede6569a9226653c43ab44e1a7e0df21eac31b3c91bf4"); err != nil {
panic(err)
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

[]byte("calldata"),
"MyAptosContractType",
[]string("tag1", "tag2")
"package",
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

)
if err != nil {
panic(err)
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent

timelockBuilder.AddOperation(types.BatchOperation{
ChainSelector: selector,
Transactions: []types.Transaction{tx},
ChainSelector: selector,
Copy link
Contributor

Choose a reason for hiding this comment

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

broken indent


// set root
executable, err := mcms.NewExecutable(proposal, executorsMap)
// TODO: we should pass the context once we remove background context in the remote chain selectors api
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this TODO spread all over the place. It's doing more harm than good, imo, because it's very noisy. How about you simply add a link to the Jira ticket after the //nolint:contextcheck comment?

Comment on lines +111 to +112
// TODO: we should pass the context once we remove background context in the remote chain selectors api
executable, err := mcms.NewExecutable(proposal, executorsMap) //nolint:contextcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

for instance

Suggested change
// TODO: we should pass the context once we remove background context in the remote chain selectors api
executable, err := mcms.NewExecutable(proposal, executorsMap) //nolint:contextcheck
executable, err := mcms.NewExecutable(proposal, executorsMap) //nolint:contextcheck //OPT-400 - remove bg ctx


s.ChainB = types.ChainSelector(cselectors.GETH_TESTNET.Selector)
s.ChainC = types.ChainSelector(cselectors.GETH_DEVNET_2.Selector)
s.ChainB = types.ChainSelector(chainsel.ETHEREUM_TESTNET_SEPOLIA.Selector)
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it a problem to use real chain selectors for the e2e tests? Why do we need to change them?

cmds:
- golangci-lint run
- golangci-lint run --build-tags="e2e,test"
- golangci-lint run --config=.golangci.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't .golangci.yml the default?

// this function is used in a lot of places, and passing the context through all of them would be a big breaking change
// so a bigger refactor may be needed to properly pass context through all the layers that use this function
ctx := context.Background()
details, err := chainselremote.GetChainDetailsBySelector(ctx, uint64(sel))
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the fallback already implemented in cldf now?


// buildTimelockConverters builds a map of chain selectors to their corresponding TimelockConverter implementations.
func (m *TimelockProposal) buildTimelockConverters() (map[types.ChainSelector]sdk.TimelockConverter, error) {
func (m *TimelockProposal) buildTimelockConverters(_ context.Context) (map[types.ChainSelector]sdk.TimelockConverter, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we passing a context if it won't be used?

Copy link
Contributor

@gustavogama-cll gustavogama-cll left a comment

Choose a reason for hiding this comment

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

a couple of general comments:

  1. I think mixing the "chainsel" renames with the remote API in the same PR was a bad idea... too much noise, and it'll make it hard to review a possible revert, later
  2. if feeds that there's a lot of api in the mcms library that should be public; that's why I prefer to place all the implementation in /internal until there's a clear use case justifying it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants