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

ccip: Add unknown address types #836

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

ccip: Add unknown address types #836

wants to merge 3 commits into from

Conversation

winder
Copy link
Collaborator

@winder winder commented Oct 8, 2024

Introduce new address types in a backwards compatible way.

}

var res Bytes32
copy(res[:], b)

Choose a reason for hiding this comment

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

Would we want to put the bytes at the end of the array?
ie. should the result of the conversion be "0x1234" -> "0x000...01234" rather than "0x1234" -> "0x12340000..."?

Copy link
Contributor

Choose a reason for hiding this comment

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

The former seems to be more of what I would expect, at least if the hex bytes represented a number

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 code isn't changed from v1. There aren't many places using Bytes32 after this change, we would have to review those to see if it makes sense to modify the behavior.

I guess my expectation would be s == NewBytes32FromString(s).String() which definitely isn't the case with the current implementation which also silently truncates the input.

pkg/types/ccipocr3/v2/generic_types.go Show resolved Hide resolved
}

func (s SeqNumRange) String() string {
return fmt.Sprintf("[%d -> %d]", s[0], s[1])
Copy link

@0xAustinWang 0xAustinWang Oct 11, 2024

Choose a reason for hiding this comment

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

Seems like the SeqNumRange is inclusive of the endpoints, let's include that in a comment somewhere.

Do we have a preference for this specific arrow notation instead of math notation [start, end]?

pkg/types/ccipocr3/v2/generic_types.go Show resolved Hide resolved

// String returns the hex representation of the unknown address.
func (a UnknownAddress) String() string {
return Bytes(a).String()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we prefix this by something to make it clear that its unknown?

Suggested change
return Bytes(a).String()
return fmt.Sprintf("unkown_%s", Bytes(a).String())

Copy link
Contributor

Choose a reason for hiding this comment

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

Should unknown addresses string representations ever be passed in somewhere that will make use of that representation (e.g like the contract reader)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that would be great.

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 would rather not attach semantics to the string representation. It's mainly kept here for convenience and backwards compatibility.

Copy link
Collaborator Author

@winder winder Oct 14, 2024

Choose a reason for hiding this comment

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

It's part of the CCIP message, so I guess we need to keep it without a prefix.

}

func (a UnknownAddress) MarshalJSON() ([]byte, error) {
return Bytes(a).MarshalJSON()
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto here re: prefix

}

var res Bytes32
copy(res[:], b)
Copy link
Contributor

Choose a reason for hiding this comment

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

The former seems to be more of what I would expect, at least if the hex bytes represented a number

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this API surface need to be exported? Who will use it?

Copy link
Collaborator

@jmank88 jmank88 left a comment

Choose a reason for hiding this comment

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

This looks like it includes CCIP specific code. Can we move it to chainlink-ccip?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do these types use json struct tags? Are we mixing layers of the API?

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.

5 participants