Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/xchain-helpers"]
path = lib/xchain-helpers
url = https://github.com/oldchili/xchain-helpers.git
branch = lz-gov-bridge
68 changes: 21 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,40 @@
## Foundry
# LZ Init Library

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
Reusable Solidity library for LayerZero configuration in Sky governance spells. Standardizes the wiring and management of SkyLink deployments across chains.

Foundry consists of:
## Library Functions (`LZInit.sol`)

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
### L1 Functions

## Documentation
- **`addGovRoute`** — Add a governance route from LZ_GOV_SENDER to a new remote chain. Sets the peer, send library, DVN/executor config, and whitelists the L1GovernanceRelay via setCanCallTarget.
- **`addOftRoute`** — Add a new OFT route from the chain this function runs on to a remote chain. Sets the peer, send/receive libraries, DVN/executor configs, enforced options, and rate limits. Also usable on L2 via `relayAddOftRoute`.
- **`activateOft`** — Activate a pre-configured OFT adapter by setting non-zero rate limits. For adapters already configured by the deployer with rate limits at zero. Includes sanity checks (owner, delegate, peer, token, paused, rate limits at zero, accounting type). Also usable on L2 via `relayActivateOft`.
- **`updateRateLimits`** — Update rate limits on an OFT adapter for a given destination.

https://book.getfoundry.sh/
### Relay Functions (L1 → L2)

## Usage
Each relay function encodes a call to the corresponding `LZL2Spell` function and sends it via the LZ governance bridge (`L1GovernanceRelay` → `GovOAppSender` → `L2GovernanceRelay`).

### Build
- **`relayAddOftRoute`**
- **`relayActivateOft`**
- **`relayUpdateRateLimits`**

```shell
$ forge build
```

### Test

```shell
$ forge test
```
### Star Subproxy

### Format
- **`initLZSender`** — Configure the LZ endpoint for a non-OApp sender (e.g. Star subproxy using LZForwarder).

```shell
$ forge fmt
```
## L2 Spell (`LZL2Spell.sol`)

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```
Deployed once per L2, delegatecalled by `L2GovernanceRelay`. Exposes `addOftRoute`, `activateOft`, and `updateRateLimits` for remote execution via relay.

### Cast
## Build

```shell
$ cast <subcommand>
forge build
```

### Help
## Test

```shell
$ forge --help
$ anvil --help
$ cast --help
ETH_RPC_URL=<mainnet_rpc> MAINNET_RPC_URL=<mainnet_rpc> forge test
```
Loading