-
Notifications
You must be signed in to change notification settings - Fork 1
feat: refactor usages of chain selectors API to use remote API #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pablo <[email protected]>
🦋 Changeset detectedLatest commit: 5a07554 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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) |
There was a problem hiding this comment.
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.
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
| // 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
Signed-off-by: Pablo <[email protected]>
|
| 5, // Value in GWEI | ||
| "MyEVMContractType", | ||
| []string{"tag1", "tag2"}, | ||
| common.Address{}, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, | ||
| } | ||
| { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
| // 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for instance
| // 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
gustavogama-cll
left a comment
There was a problem hiding this 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:
- 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
- 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
/internaluntil there's a clear use case justifying it




This PR upgrades usages of the chain selectors lib to use the new Remote API smartcontractkit/chain-selectors#182
Notes:
chainselcontext.Backgroundthat I had to hardcode in the evm sdk. This is because we still need to provide actxvariable 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.