Skip to content

Commit a7c8786

Browse files
authored
updated docs and remove outdated bits (#89)
1 parent 75ddcec commit a7c8786

File tree

6 files changed

+41
-64
lines changed

6 files changed

+41
-64
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ The purpose of this SDK is to make on-chain integrations with Wormhole on EVM co
44

55
For off-chain code, please refer to the [TypeScript SDK](https://github.com/wormhole-foundation/wormhole-sdk-ts) and in particular the [EVM platform implementation](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/platforms/evm).
66

7-
This SDK was originally created for integrations with the WormholeRelayer and then expanded to cover all integration.
8-
97
## Releases
108

119
> License Reminder
@@ -40,9 +38,9 @@ It is strongly recommended that you run the forge test suite of this SDK with yo
4038

4139
This SDK comes with its own IERC20 interface and SafeERC20 implementation. Given that projects tend to combine different SDKs, there's often this annoying issue of clashes of IERC20 interfaces, even though they are effectively the same. We handle this issue by importing `IERC20/IERC20.sol` which allows remapping the `IERC20/` prefix to whatever directory contains `IERC20.sol` in your project, thus providing an override mechanism that should allow dealing with this problem seamlessly until forge allows remapping of individual files. The same approach is used for SafeERC20.
4240

43-
## Components
41+
## Components & Testing
4442

45-
For additional documentation of components, see the docs directory.
43+
For additional documentation of components and how to test integrations, see the docs directory.
4644

4745
## Style
4846

docs/RawDispatcher.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ Contracts using this base class have to override the associated virtual function
114114

115115
### Integrator Library
116116

117-
Of course, integrations have to actually make use of these custom dispatch functions to reap their benefits. To this end, contracts using the RawDispatcher pattern/base call should come with two additional "SDKs":
118-
1. For on-chain integrations: A Solidity integrator `library` that fills the role of what is otherwise provided by an `interface`. That is, a set of encoding and decoding functions that mirror the contract's ABI but implement the custom call format of the contract decoding its returned `bytes` under the hood.
119-
2. For off-chain integrations: A Typescript analog of the integrator library. The [layouting package](https://www.npmjs.com/package/binary-layout) offers an easy, declarative way to specify such custom encodings. It is also used in [the Wormhole Typescript SDK](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/base/src/utils/layout.ts) to [define common types](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/layout-items) and various other layout examples can be found in [the protocols defined within the SDK itself](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/protocols) (e.g. [TokenBridge Messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/tokenBridge/tokenBridgeLayout.ts), [WormholeRelayer Messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/relayer/relayerLayout.ts), [CCTP messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/circleBridge/circleBridgeLayout.ts)) or strewn throughout the various example repos e.g. [example-swap-layer](https://github.com/wormhole-foundation/example-swap-layer/blob/main/evm/ts-sdk/src/layout.ts) or [example-native-token-transfers](https://github.com/wormhole-foundation/example-native-token-transfers/tree/main/sdk/definitions/src/layouts).
117+
Of course, integrations have to actually make use of these custom dispatch functions to reap their benefits. To this end, contracts using the RawDispatcher pattern/base should come with two additional "SDKs":
118+
1. For on-chain integrations: A Solidity integrator `library` that fills the role of what is otherwise provided by an `interface`. That is, a set of encoding and decoding functions that mirror the contract's ABI but that implement the custom call format of the contract and decoding of its returned `bytes`.
119+
2. For off-chain integrations: A TypeScript analog of the integrator library. The [layouting package](https://www.npmjs.com/package/binary-layout) offers an easy, declarative way to specify such custom encodings. It is also used in [the Wormhole Typescript SDK](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/base/src/utils/layout.ts) to [define common types](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/layout-items) and various other layout examples can be found in [the protocols defined within the SDK itself](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/protocols) (e.g. [TokenBridge Messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/tokenBridge/tokenBridgeLayout.ts), [WormholeRelayer Messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/relayer/relayerLayout.ts), [CCTP messages](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/core/definitions/src/protocols/circleBridge/circleBridgeLayout.ts)) or strewn throughout the various example repos e.g. [example-swap-layer](https://github.com/wormhole-foundation/example-swap-layer/blob/main/evm/ts-sdk/src/layout.ts) or [example-native-token-transfers](https://github.com/wormhole-foundation/example-native-token-transfers/tree/main/sdk/definitions/src/layouts).
120120

121121
### Limitations
122122

docs/Testing.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,69 @@
1-
# Testing
1+
# Introduction
22

33
As a general point, your testing environment should match your real world environment as much as possible. Therefore, fork testing is generally encouraged over running standalone tests, despite the RPC provider dependency and its associated headaches.
44

55
Besides fork testing, forge also offers [mockCall](https://book.getfoundry.sh/cheatcodes/mock-call), [mockCallRevert](https://book.getfoundry.sh/cheatcodes/mock-call-revert), and [mockFunction](https://book.getfoundry.sh/cheatcodes/mock-function) cheat-codes, which should typically be preferred over writing and deploying mock contracts due to their more explicit nature.
66

7-
## Utils
7+
# Utils
88

99
All Solidity testing utilities can be found in src/testing.
1010

11-
### WormholeOverride
11+
## WormholeForkTest
1212

1313
**Purpose**
1414

15-
The `WormholeOverride` library is the main way to fork test integrations. It allows overriding the current guardian set of the core bridge with a newly generated one which can then be used to sign messages and thus create VAAs.
15+
The `WormholeForkTest` contract serves as a base class for fork testing Wormhole (and CCTP) integrations. It provides utilities for setting up and managing multiple forks, taking control of each chain's CoreBridge and CCTP MessageTransmitter using the respective override libraries, and various other common tasks.
16+
17+
**Fork Handling**
18+
19+
The contract comes with built-in default RPC URLs for each chain, but these can be overridden by explicitly specifying a custom RPC URL when calling `setUpFork()`. By default, it forks against mainnet chains, but this can be changed by setting `isMainnet` to false in the constructor. The `selectFork(uint16)` function is used to switch between forks using the Wormhole chain id.
20+
21+
**Utilities**
22+
23+
- Provides addresses of all Wormhole and CCTP contracts and other useful constants
24+
- Creates a TokenBridge attestation for a token on a given chain and automatically submits it on all other forks
25+
- USDC minting through the `UsdcDealer` library
26+
- Fetching and parsing of both Wormhole and CCTP messages from Forge logs
27+
- Creating VAAs/Circle attestations for Wormhole/CCTP messages
28+
29+
## WormholeRelayerTest
30+
31+
The `WormholeRelayerTest` contract extends `WormholeForkTest`, by providing additional utils for testing WormholeRelayer integrations. Namely picking up and delivering of WormholeRelayer messages to their intended targets and checking the delivery result afterwards. See test/WormholeRelayer.t.sol for an example.
32+
33+
## WormholeOverride
34+
35+
**Purpose**
36+
37+
The `WormholeOverride` library allows taking control of the CoreBridge on a given chain by overriding the current guardian set with a newly generated one, which can then be used to sign published messages and thus create VAAs.
1638

1739
**Default Guardian Set**
1840

19-
By default the new guardian set has the same size as the old one, again to match the forked network's setup as closely as possible and keep message sizes and gas costs accurate. Since this can bloat traces and make them harder to read due to the VAAs' sizes, overriding with a single guardian when debugging tests can be helpful. This can be achieved by setting the environment variable `DEFAULT_TO_DEVNET_GUARDIAN` to true.
41+
By default, the new guardian set has the same size as the old one, again to match the forked network's setup as closely as possible and keep message sizes and gas costs accurate. Since this can bloat traces and make them harder to read due to the VAAs' sizes, overriding with a single guardian when debugging tests can be helpful. This can be achieved by setting the environment variable `DEFAULT_TO_DEVNET_GUARDIAN` to true.
42+
43+
Also by default, the addresses and private keys of the new guardians are deterministically derived using Forge's `makeAddrAndKey` utility with the strings `guardian<i = 1, ..., n>`, naturally giving rise to the same values across all forks that are being overridden.
2044

2145
**Log Parsing**
2246

23-
Besides signing messages / creating VAAs, `WormholeOverride` also provides convenient forge log parsing capabilities to ensure that the right number of messages with the correct content are emitted by the core bridge. Be sure to call `vm.recordLogs();` beforehand to capture emitted events so that they are available for parsing.
47+
Besides signing messages / creating VAAs, `WormholeOverride` also provides convenient forge log parsing capabilities to ensure that the right number of messages with the correct content are emitted by the core bridge. Be sure to call `vm.recordLogs()` beforehand to capture emitted events so that they are available for parsing.
2448

2549
**Message Fee**
2650

2751
Integrators should ensure that their contracts work correctly in case of a non-zero Wormhole message fee. `WormholeOverride` provides `setMessageFee` for this purpose.
2852

53+
## CctpOverride
2954

30-
### CctpOverride
31-
32-
The `CctpOverride` library, is somewhat similar to `WormholeOverride` in that it allows overriding Circle's attester in their CCTP [MessageTransmitter](https://github.com/circlefin/evm-cctp-contracts/blob/master/src/MessageTransmitter.sol) contract (which is comparable in its functionality to Wormhole's core bridge).
55+
The `CctpOverride` library is somewhat similar to `WormholeOverride` in that it allows overriding Circle's attester in their CCTP [MessageTransmitter](https://github.com/circlefin/evm-cctp-contracts/blob/master/src/MessageTransmitter.sol) contract (which is comparable in its functionality to Wormhole's core bridge).
3356

3457
However, `CctpOverride`, rather than providing generic signing and log parsing functionality like `WormholeOverride`, is more specialized and only deals with signing and log-parsing `CctpTokenBurnMessage`s emitted through Circle's [TokenMessenger](https://github.com/circlefin/evm-cctp-contracts/blob/master/src/TokenMessenger.sol) contract (which is roughly comparable to Wormhole's token bridge).
3558

36-
37-
### WormholeCctpSimulator
38-
39-
The `WormholeCctpSimulator` contract can be deployed to simulate a virtual `WormholeCctpTokenMessenger` instance on some made-up foreign chain. It uses `0xDDDDDDDD` as the circle domain of that chain, and also simulates virtual instances of Circle's TokenMessenger and USDC contract, which are correctly registered with the instances on the forked chain. The foreign Wormhole chain id and the address of the foreign sender can be set during construction. Uses `WormholeOverride` and `CctpOverride`.
40-
41-
### UsdcDealer
59+
## UsdcDealer
4260

4361
Forge's `deal` cheat code does not work for USDC. `UsdcDealer` is another override library that implements a `deal` function that allows minting of USDC.
4462

45-
### ERC20Mock
63+
## ERC20Mock
4664

4765
Copy of SolMate's ERC20 Mock token that uses the overrideable `IERC20` interface of this SDK to guarantee compatibility.
4866

49-
### LogUtils
67+
## LogUtils
5068

51-
A library to simplify filtering of logs captured in Forge tests. Used by `WormholeOverride`, `CctpOverride`, ...
69+
A library to simplify filtering of logs captured in Forge tests via `vm.recordLogs()`. Used by `WormholeOverride`, `CctpOverride`, ...

docs/WormholeRelayer.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/bytecode_analysis/calldata_slice_to_memory.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ compiler:
1818
```
1919
solc_version = "0.8.23"
2020
optimizer = true
21-
optimizer_runs = 20000
2221
via_ir = true
2322
```
2423

docs/bytecode_analysis/solidity_calldata_bytes.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ compiler:
1919
```
2020
solc_version = "0.8.23"
2121
optimizer = true
22-
optimizer_runs = 20000
2322
via_ir = true
2423
```
2524

0 commit comments

Comments
 (0)