Add READMEs to hook and ism folders

hook-ism-contract-READMEs
Yorke Rhodes 2 months ago
parent 7dccf80b57
commit 67e4b37bcc
No known key found for this signature in database
GPG Key ID: 9EEACF1DA75C5627
  1. 58
      solidity/contracts/hooks/README.md
  2. 20
      solidity/contracts/isms/README.md

@ -0,0 +1,58 @@
# Post-Dispatch Hooks
Post-dispatch hooks allow developers to configure additional origin chain behavior with message content dispatched via the Mailbox.
```mermaid
flowchart TB
subgraph Origin
Sender
M_O[(Mailbox)]
Hook[IPostDispatchHook]
Sender -- "dispatch(..., metadata, hook)\n{value}" --> M_O
M_O -- "postDispatch(message, metadata)\n{value}" --> Hook
end
```
If the `postDispatch` function receives insufficient payment, it may revert.
> [!WARNING]
> Post-Dispatch Hooks may be replayable. Developers creating custom hooks should implement safe checks to prevent this behavior. [Here](./warp-route/RateLimitedHook.sol#L16) is an example implementation.
### Quote Dispatch (Fees)
Fees are often charged in `postDispatch` to cover costs such as destination chain transaction submission and security provisioning. To receive a quote for a corresponding `postDispatch` call, you can query the `quoteDispatch` function.
The Mailbox has a `quoteDispatch` function that returns the aggregate fee required for a `dispatch` call to be successful.
```mermaid
flowchart TB
subgraph Origin
Sender
M_O[(Mailbox)]
R_H[RequiredHook]
Hook[Hook]
Sender -- "quoteDispatch(..., metadata, hook)" --> M_O
M_O -- "required = quoteDispatch(message, metadata)" --> R_H
M_O -- "fee = hook.quoteDispatch(message, metadata)" --> Hook
M_O -- "required + fee" --> Sender
end
```
The custom `metadata` will be passed to the required hook's `quoteDispatch` and `postDispatch` functions, before being passed to the default hook's `postDispatch` function.
```mermaid
flowchart LR
subgraph Origin Chain
Sender
M_O[(Mailbox)]
R_H[RequiredHook]
D_H[DefaultHook]
Sender -- "dispatch(..., metadata){value}" --> M_O
M_O -. "fee = quoteDispatch(...)" .- R_H
M_O -- "postDispatch(metadata, ...)\n{fee}" --> R_H
M_O -. "postDispatch(metadata, ...)\n{value - fee}" ..-> D_H
end
```

@ -0,0 +1,20 @@
# Interchain Security Modules
Interchain security modules allow developers to configure additional security checks for message content dispatched via the Mailbox.
```mermaid
flowchart LR
subgraph Destination Chain
ISM[InterchainSecurityModule]
Recipient[Recipient]
M_D[(Mailbox)]
M_D -- "verify(metadata, message)" --> ISM
ISM -. "interchainSecurityModule()" .- Recipient
M_D -- "handle(origin, sender, body)" --> Recipient
end
```
> [!WARNING]
> Interchain security modules may be replayable. Developers creating custom modules should include replay protection if necessary. [Here](./warp-route/RateLimitedIsm.sol#L23) is an example implementation.
Loading…
Cancel
Save