-
Notifications
You must be signed in to change notification settings - Fork 855
Xrpl ntt accountant #4893
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?
Xrpl ntt accountant #4893
Changes from all commits
9b61789
8887705
147a7db
afb363b
cb8ff19
3ee99ec
c6a3a82
1493e9a
1907de9
372528d
a933400
8ffdab7
dcc2ec9
796725c
98de883
3c3a9bc
2180696
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,13 +100,88 @@ uint32 nonce | |
| []byte payload | ||
| ``` | ||
|
|
||
| ### Initialize Transceiver | ||
| ### Registration (Initialize Transceiver & Peer Registration) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth linking to https://github.com/wormhole-foundation/native-token-transfers/blob/main/docs/Transceiver.md in this section |
||
|
|
||
| Because XRPL has no smart contracts, the [`WormholeTransceiverInfo`](https://github.com/wormhole-foundation/native-token-transfers/blob/main/docs/Transceiver.md#initialize-transceiver) (hub init) and | ||
| [`WormholeTransceiverRegistration`](https://github.com/wormhole-foundation/native-token-transfers/blob/main/docs/Transceiver.md#transceiver-peer-registration) (peer) messages cannot be emitted natively. | ||
| Instead, when a custody account is initialized (`initialize`) or a peer is | ||
| registered (`register_peer`), the Solana Sequencer emits the registration as an | ||
| `XrplRelease` (XREL) carrying the `XrplRegistration` (XREG) bytes in its first | ||
| memo. The delegated manager set signs and submits that XREL as a multisig Payment | ||
| to the Core Account (there is no standalone XREG message and the executor is not | ||
| involved). The watcher then re-keys and synthesizes the canonical transceiver | ||
| message under the correct NTT transceiver emitter. | ||
|
|
||
| > 🚧 TODO | ||
| Upon a Payment to the Core Account, the guardian watcher MUST | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also must verify that the message came from the matching manager? though I'm confused about how an XREG message from the sequencer results in a payment from the manager without either manager changes in this PR or a generic payment message in the Sequencer PR. I would expect the latter - that the Sequencer issues a generic payment to the core bridge containing this registration. Maybe I'm missing where that occurs, but it looks like this is simply posted as a VAA payload. 😕
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed at sequencer level! XREG is wrapped in XREL which is signed by delegated manager and captured by watcher. |
||
|
|
||
| - Verify that the transaction is `validated` | ||
| - Verify that the transaction result is `tesSUCCESS` | ||
| - Verify that the transaction type is `Payment` | ||
| - Verify that the **first** memo (index 0) has a MemoFormat of | ||
| `application/x-ntt-registration`, hex-encoded | ||
| - Verify that the MemoData begins with the `XREG` prefix | ||
|
|
||
| The MemoData carries the raw `XREG` bytes: | ||
|
|
||
| ```go | ||
| [4]byte prefix = "XREG" | ||
| uint8 kind // 0 = Hub, 1 = Peer | ||
| [20]byte manager // XRPL custody account id | ||
| []byte token_id // wire form, per the sequencer token_id encoding (see below) | ||
| // Hub tail (kind=0): | ||
| uint8 token_decimals | ||
| // Peer tail (kind=1): | ||
| uint16 peer_chain // big-endian | ||
| [32]byte peer_address | ||
| ``` | ||
|
|
||
| The `token_id` uses the same encoding as the sequencer's XREL payload: | ||
|
|
||
| | Token Type | Byte 0 | Bytes 1+ | Total | | ||
| | ---------- | ------ | --------------------------- | -------- | | ||
| | XRP | 0x00 | (none) | 1 byte | | ||
| | IOU | 0x01 | currency (20) + issuer (20) | 41 bytes | | ||
| | MPT | 0x02 | mpt_issuance_id (24) | 25 bytes | | ||
|
|
||
| ### Transceiver (Peer) Registration | ||
| The watcher derives the NTT transceiver emitter | ||
| `keccak256("ntt" + manager32 + token32)` — the **same** emitter used for | ||
| `NativeTokenTransfer` messages from this manager+token pair — and emits the VAA | ||
| under it, so the accountant keys hub/peer state on the same emitter it sees | ||
| transfers from. | ||
|
|
||
| #### Initialize Transceiver (kind = Hub) | ||
|
|
||
| Synthesize a `WormholeTransceiverInfo` payload (70 bytes): | ||
|
|
||
| ```go | ||
| [4]byte prefix = 0x9c23bd3b | ||
| [32]byte manager_address // manager32 (left-padded XRPL account) | ||
| uint8 manager_mode // 0 = Locking, 1 = Burning (see below) | ||
| [32]byte token_address // token32 derived from token_id | ||
| uint8 token_decimals | ||
| ``` | ||
|
|
||
| `manager_mode` is derived by the watcher from the XREG `manager` and `token_id`: | ||
| an XRPL custody account is in **Burning** mode when it is itself the token's | ||
| issuer (it can mint/burn), and **Locking** mode otherwise (it holds a token | ||
| issued by another account). The issuer is the last 20 bytes of an IOU `token_id`, | ||
| or the first 20 bytes of an MPT `mpt_issuance_id`; XRP has no issuer and is always | ||
| Locking. The `ntt-global-accountant` only accepts Locking hubs, but the init | ||
| message must attest the manager's true mode rather than assume Locking. | ||
|
|
||
| #### Transceiver (Peer) Registration (kind = Peer) | ||
|
|
||
| Synthesize a `WormholeTransceiverRegistration` payload (38 bytes): | ||
|
|
||
| ```go | ||
| [4]byte prefix = 0x18fc67c2 | ||
| uint16 chain_id // big-endian, the peer chain | ||
| [32]byte transceiver_address // the peer address | ||
| ``` | ||
|
|
||
| > 🚧 TODO | ||
| An operator submits the resulting VAAs to the NTT global accountant via | ||
| `submit_vaas` to establish the hub/peer registration before transfers are | ||
| enforced. | ||
|
|
||
| ### NativeTokenTransfer TransceiverMessage | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.