Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 huangzhen1997, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
Coverage Report |
andrevmatos
left a comment
There was a problem hiding this comment.
Some simplifications, but mostly lgtm
krebernisak
left a comment
There was a problem hiding this comment.
LGTM - I second feedback from Andre, and would be great to add SUI in the same PR
| .storeUint(tokenReceiver, 256) // uint256 | ||
| .storeRef(accountsCell) // SnakedCell<uint256> | ||
|
|
||
| return builder.endCell() |
There was a problem hiding this comment.
Can we please test TONChain.encodeExtraArgs() with these, and decodeExtraArgs its result?
The encode method isn't actively used right now, as we build the cells directly here from the ExtraArgs object when we need to ccipSend below, so we use the Cell result directly, which should be fine.
But in ccip-o11y, we'll need to serialize those to store in ccip-o11y-db, and it'd be good to have a consistent way to serialize them here (we may eventually pull ccip-sdk into ccip-o11y, and then we'll need this). Also, the serialized extraArgs coming from ccip-o11y db through CCIP-API for these will be decoded.
So far for EVM, our idea was to store only the bits content of the cell in serialized form (i.e. NOT the whole serialized cell), so it can begin with the tag, for consistency with all other chain families. But we need to make sure this also works for these snaked cells.
There was a problem hiding this comment.
Thanks, Andre!
I've pushed a commit: eeef3e0
Please review and let's discuss how to resolve this cc @Farber98
So far for EVM, our idea was to store only the bits content of the cell in serialized form (i.e. NOT the whole serialized cell)
This is simple for EVM (small args) but not straightforwards for SVM/SUI extra args which have lists stored as nested cells, and might fail on other future args where more data is required. Cell is a tree structure and has a special BOC encoding b/c of it. This clashes with the idea that chain-specific extraArgs encodings should start with a standard prefix.
Then there's also the current observability implementation which just reads first cell bits, which currently drops data for SVM/SUI (data encoded as more than one root cell): https://github.com/smartcontractkit/ccip-o11y/blob/main/ccip/ton/processor/ton_event_decode.go#L266
915e4e5 to
afbf675
Compare
afbf675 to
4072c7f
Compare
andrevmatos
left a comment
There was a problem hiding this comment.
Some nits, we can re-approve later
| */ | ||
| export function encodeAddressToAny(address: BytesLike): Buffer { | ||
| const bytes = getAddressBytes(address) | ||
| return bytesToBuffer(bytes.length < 32 ? zeroPadValue(bytes, 32) : bytes) |
There was a problem hiding this comment.
Nit, to avoid the double serialization/deserialization:
| return bytesToBuffer(bytes.length < 32 ? zeroPadValue(bytes, 32) : bytes) | |
| return bytes.length < 32 ? Buffer.concat([Buffer.alloc(32 - bytes.length), bytes]) : Buffer.from(bytes) |
| function decodeLegacyEVMTONExtraArgs( | ||
| extraArgs: BytesLike, | ||
| ): (EVMExtraArgsV2 & { _tag: 'EVMExtraArgsV2' }) | undefined { | ||
| let bytes | ||
| try { | ||
| bytes = bytesToBuffer(extraArgs) | ||
| if (dataSlice(bytes, 0, 4) !== EVMExtraArgsV2Tag) return | ||
| } catch { | ||
| return | ||
| } | ||
|
|
||
| const slice = new Slice(new BitReader(new BitString(bytes, 32, bytes.length * 8)), []) | ||
| const gasLimit = slice.loadMaybeUintBig(256) ?? 0n | ||
| const allowOutOfOrderExecution = slice.loadBit() | ||
|
|
||
| return { | ||
| _tag: 'EVMExtraArgsV2', | ||
| gasLimit, | ||
| allowOutOfOrderExecution, | ||
| } | ||
| } | ||
|
|
||
| function decodeTONExtraArgsCell( |
There was a problem hiding this comment.
I think these deserve their own extra-args.ts submodule, instead of on index.ts
Adds SVMExtraArgsV1 encoding support for TON source chain, enabling TON → Solana CCIP messages.