Skip to content
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

support address codec implementation #16485

Merged
merged 17 commits into from
Feb 20, 2025
Merged

support address codec implementation #16485

merged 17 commits into from
Feb 20, 2025

Conversation

huangzhen1997
Copy link
Contributor

No description provided.

Copy link
Contributor

@ilija42 ilija42 left a comment

Choose a reason for hiding this comment

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

What is the use case?

@huangzhen1997
Copy link
Contributor Author

huangzhen1997 commented Feb 19, 2025

What is the use case?

To provide a service of address encoding/decoding scheme for different source chain
smartcontractkit/chainlink-ccip#619 (comment)

Copy link
Contributor

@ilija42 ilija42 left a comment

Choose a reason for hiding this comment

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

Seems like we are patching the problem and solving the root cause? Why do we even encode addresses in the plugin. Not saying that I want to block this work

@huangzhen1997
Copy link
Contributor Author

huangzhen1997 commented Feb 19, 2025

Seems like we are patching the problem and solving the root cause? Why do we even encode addresses in the plugin. Not saying that I want to block this work

It's for the chain reader, the oracle creator provide this codec and will be used by ccip chain reader to replace this evm specific util function (internal/libs/typeconv/address.go). Check the PR Blaž was trying to do, this's going to replace it

Copy link
Contributor

Flakeguard Summary

Ran new or updated tests between develop and 617aab7 (implement-address-codec).

View Flaky Detector Details | Compare Changes

Found Flaky Tests ❌

4 Results
Name Pass Ratio Panicked? Timed Out? Race? Runs Successes Failures Skips Package Package Panicked? Avg Duration Code Owners
TestPublicKeyFromBytes 0% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana false 0s @smartcontractkit/ccip-offchain
TestPublicKeyFromBytes/empty 0% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana false 0s @smartcontractkit/ccip-offchain
TestPublicKeyFromBytes/longer_than_required 0% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana false 0s @smartcontractkit/ccip-offchain
TestPublicKeyFromBytes/smaller_than_required 0% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana false 0s @smartcontractkit/ccip-offchain

Artifacts

For detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json.

Copy link
Contributor

@prashantkumar1982 prashantkumar1982 left a comment

Choose a reason for hiding this comment

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

Could you also check if you can delete this one: encodeOffRampAddr(), and instead just call addressCodec.AddressBytesToString()?
The checkSum field i think can be removed, and always set checkSum = true.

@@ -307,6 +304,12 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
return nil, nil, fmt.Errorf("unsupported chain %v", chainFamily)
}
messageHasher := plugin.MessageHasher(i.lggr.Named(chainFamily).Named("MessageHasherV1"))
addressCodec := ccipcommon.NewAddressCodec(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you instead create this addressCodec in NewPluginOracleCreator(), store it as a member of the pluginOracleCreator struct, and then here in this function, pass the same instance to the commit/exec plugin factories.
We basically only need 1 instance. No need to create separate one per-chain or plugn

if len(addr) != common.AddressLength {
return "", fmt.Errorf("invalid EVM address length, expected %v, got %d", common.AddressLength, len(addr))
}
return hexutil.Encode(addr), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this, use this version:
common.BytesToAddress(addr).Hex()

The reason is because the latter is EIP55-compliant.
More context: https://medium.com/@zakhard/eip-55-explained-solving-the-address-checksum-problem-01ac2bb0efc4

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. Now that this is inside chainlink we can use the standard evm libraries.

@@ -307,6 +304,12 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
return nil, nil, fmt.Errorf("unsupported chain %v", chainFamily)
}
messageHasher := plugin.MessageHasher(i.lggr.Named(chainFamily).Named("MessageHasherV1"))
addressCodec := ccipcommon.NewAddressCodec(
ccipcommon.NewAddressCodecParams(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to send these?
Why can't the NewAddressCodecParams() just create locally itself?

Copy link
Contributor Author

@huangzhen1997 huangzhen1997 Feb 20, 2025

Choose a reason for hiding this comment

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

Yes it's not ideal, but a workaround for the import circle when I import ccipevm or ccipsolana from common

Copy link
Contributor

github-actions bot commented Feb 20, 2025

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@@ -286,6 +277,7 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
destFromAccounts []string,
publicConfig ocr3confighelper.PublicConfig,
destChainFamily string,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Now that you are passing offrampAddrStr, I think the previous param destChainFamily is not needed?

@winder winder enabled auto-merge February 20, 2025 22:20
@winder winder added this pull request to the merge queue Feb 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 20, 2025
@winder winder added this pull request to the merge queue Feb 20, 2025
Merged via the queue into develop with commit 82fade9 Feb 20, 2025
188 checks passed
@winder winder deleted the implement-address-codec branch February 20, 2025 23:05
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.

4 participants