Skip to content

Instantly share code, notes, and snippets.

@0xmichalis
Last active November 9, 2023 21:16
Show Gist options
  • Save 0xmichalis/4e19f091b4cf70fbb415e6ad366e145c to your computer and use it in GitHub Desktop.
Save 0xmichalis/4e19f091b4cf70fbb415e6ad366e145c to your computer and use it in GitHub Desktop.
Hyperlane client router storage layout analysis

v1 storage layout:

├──OwnerUpgradeable
├──AbacusConnectionClient
│  ├──IAbacusConnectionManager public abacusConnectionManager;  <--|
│  ├──IInterchainGasPaymaster public interchainGasPaymaster;       |  50 slots
│  └──uint256[48] private __GAP;                                <--|
|
├──mapping(uint32 => bytes32) public routers;                   <--|
|                                                                  |  50 slots
└──uint256[49] private __GAP;                                   <--|

v2 storage layout:

├──OwnerUpgradeable
├──HyperlaneConnectionClient
│  ├──IMailbox public mailbox;                                   <--|   
│  ├──IInterchainGasPaymaster public interchainGasPaymaster;        |
|  ├──IInterchainSecurityModule public interchainSecurityModule;    |
|  |  # __GAP should have been decreased to 47 because of           |  51 slots
|  |  # the addition of interchainSecurityModule in order to        |
|  |  # maintain backwards-compatibility between v1->v2             |
│  └──uint256[48] private __GAP;                                 <--|
|
├──mapping(uint32 => bytes32) public routers;                    <--|
|                                                                   |  50 slots
└──uint256[49] private __GAP;                                    <--|

v3 storage layout:

├──OwnerUpgradeable
├──MailboxClient
│  ├──IPostDispatchHook public hook;                               <--|
│  └──IInterchainSecurityModule public interchainSecurityModule;      |  2 slots
|   # MailboxClient misses a gap to make it upgrade-safe           <--|
|
├──EnumerableMapExtended.UintToBytes32Map internal _routers;       <--|
|                                                                     |  49 slots
└──uint256[48] private __GAP;                                      <--|
@yorhodes
Copy link

yorhodes commented Nov 9, 2023

v2 layout

$ forge inspect Router storage --pretty
| Name                     | Type                                          | Slot | Offset | Bytes | Contract                    |
|--------------------------|-----------------------------------------------|------|--------|-------|-----------------------------|
| _initialized             | uint8                                         | 0    | 0      | 1     | contracts/Router.sol:Router |
| _initializing            | bool                                          | 0    | 1      | 1     | contracts/Router.sol:Router |
| __gap                    | uint256[50]                                   | 1    | 0      | 1600  | contracts/Router.sol:Router |
| _owner                   | address                                       | 51   | 0      | 20    | contracts/Router.sol:Router |
| __gap                    | uint256[49]                                   | 52   | 0      | 1568  | contracts/Router.sol:Router |
| mailbox                  | contract IMailbox                             | 101  | 0      | 20    | contracts/Router.sol:Router |
| interchainGasPaymaster   | contract IInterchainGasPaymaster              | 102  | 0      | 20    | contracts/Router.sol:Router |
| interchainSecurityModule | contract IInterchainSecurityModule            | 103  | 0      | 20    | contracts/Router.sol:Router |
| __GAP                    | uint256[48]                                   | 104  | 0      | 1536  | contracts/Router.sol:Router |
| _routers                 | struct EnumerableMapExtended.UintToBytes32Map | 152  | 0      | 96    | contracts/Router.sol:Router |
| __GAP                    | uint256[49]                                   | 155  | 0      | 1568  | contracts/Router.sol:Router |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment