Skip to content

Commit 70f93f3

Browse files
committed
scripts/test feedback
Signed-off-by: Faisal Usmani <faisal.of.usmani@gmail.com>
1 parent 24c4460 commit 70f93f3

File tree

1 file changed

+9
-85
lines changed

1 file changed

+9
-85
lines changed

CLAUDE.md

Lines changed: 9 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Across uses a **hub-and-spoke** model with optimistic verification to enable fas
1414

1515
### Key Roles
1616

17-
| Role | Description |
18-
|------|-------------|
19-
| **Depositor** | End user (non-technical) who initiates a cross-chain transfer via one of multiple entry points (deposit, sponsored, gasless flows) on the origin SpokePool |
20-
| **Relayer** | Fills deposits on destination chain by fronting tokens, later reimbursed via merkle proof. Relayers compete on speed and cross-chain inventory management to determine if a deposit is profitable based on the fees offered |
17+
| Role | Description |
18+
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| **Depositor** | End user (non-technical) who initiates a cross-chain transfer via one of multiple entry points (deposit, sponsored, gasless flows) on the origin SpokePool |
20+
| **Relayer** | Fills deposits on destination chain by fronting tokens, later reimbursed via merkle proof. Relayers compete on speed and cross-chain inventory management to determine if a deposit is profitable based on the fees offered |
2121
| **Data Worker** | Off-chain agent that validates and aggregates deposits/fills across multiple chains, constructs merkle trees, and calls `proposeRootBundle()` on HubPool (stakes a bond). Unlike relayers, data workers are RPC-intensive and maintain a longer lookback window; speed is less critical |
22-
| **Disputer** | Monitors proposed bundles; can call `disputeRootBundle()` during the challenge period if a bundle is invalid |
23-
| **LP** | Deposits L1 tokens into HubPool to earn relay fees |
22+
| **Disputer** | Monitors proposed bundles; can call `disputeRootBundle()` during the challenge period if a bundle is invalid |
23+
| **LP** | Deposits L1 tokens into HubPool to earn relay fees |
2424

2525
### Protocol Flow
2626

@@ -40,7 +40,6 @@ HubPool on L1 owns all L2 SpokePools. Admin functions are relayed cross-chain vi
4040

4141
SpokePool is deployed on many chains. For the list of all available chains, see `broadcast/deployed-addresses.md`.
4242

43-
4443
## Development Frameworks
4544

4645
- **Foundry** (primary) - Used for new tests and deployment scripts
@@ -99,36 +98,12 @@ Use `FOUNDRY_PROFILE=local-test` (or `yarn test-evm-foundry`) for local Foundry
9998

10099
### Deployment Scripts
101100

102-
- Numbered with `.s.sol` suffix: `001DeployHubPool.s.sol`, `004DeployArbitrumAdapter.s.sol`
101+
- `.s.sol` suffix, see `script/` for examples (e.g. `script/DeployArbitrumAdapter.s.sol`)
103102
- Script contracts: `contract Deploy<ContractName> is Script, Test, Constants`
104103

105104
## Writing Tests
106105

107-
```solidity
108-
// SPDX-License-Identifier: BUSL-1.1
109-
pragma solidity ^0.8.0;
110-
111-
import { Test } from "forge-std/Test.sol";
112-
import { MyContract } from "../contracts/MyContract.sol";
113-
114-
contract MyContractTest is Test {
115-
MyContract public myContract;
116-
117-
function setUp() public {
118-
myContract = new MyContract();
119-
}
120-
121-
function testBasicFunctionality() public {
122-
// Test implementation
123-
assertEq(myContract.value(), expected);
124-
}
125-
126-
function testRevertOnInvalidInput() public {
127-
vm.expectRevert();
128-
myContract.doSomething(invalidInput);
129-
}
130-
}
131-
```
106+
See `test/evm/foundry/local/` for examples (e.g. `Router_Adapter.t.sol`).
132107

133108
### Test Gotchas
134109

@@ -142,60 +117,9 @@ contract MyContractTest is Test {
142117
```
143118
- **Delegatecall context**: Adapter tests via HubPool emit events from HubPool's address; `vm.expectRevert()` may lose error data
144119

145-
## Deployment Scripts
146-
147-
Scripts follow a numbered pattern and use shared utilities from `script/utils/`.
148-
149-
```solidity
150-
// SPDX-License-Identifier: BUSL-1.1
151-
pragma solidity ^0.8.0;
152-
153-
import { Script } from "forge-std/Script.sol";
154-
import { Test } from "forge-std/Test.sol";
155-
import { console } from "forge-std/console.sol";
156-
import { Constants } from "./utils/Constants.sol";
157-
import { MyContract } from "../contracts/MyContract.sol";
158-
159-
// How to run:
160-
// 1. `source .env` where `.env` has MNEMONIC="x x x ... x" and ETHERSCAN_API_KEY="x"
161-
// 2. forge script script/00XDeployMyContract.s.sol:DeployMyContract --rpc-url $NODE_URL_1 -vvvv
162-
// 3. Verify simulation works
163-
// 4. Deploy: forge script script/00XDeployMyContract.s.sol:DeployMyContract --rpc-url $NODE_URL_1 --broadcast --verify -vvvv
164-
165-
contract DeployMyContract is Script, Test, Constants {
166-
function run() external {
167-
string memory deployerMnemonic = vm.envString("MNEMONIC");
168-
uint256 deployerPrivateKey = vm.deriveKey(deployerMnemonic, 0);
169-
170-
uint256 chainId = block.chainid;
171-
// Validate chain if needed
172-
require(chainId == getChainId("MAINNET"), "Deploy on mainnet only");
173-
174-
vm.startBroadcast(deployerPrivateKey);
175-
176-
MyContract myContract = new MyContract /* constructor args */();
177-
178-
console.log("Chain ID:", chainId);
179-
console.log("MyContract deployed to:", address(myContract));
180-
181-
vm.stopBroadcast();
182-
}
183-
}
184-
```
185-
186-
For upgradeable contracts, use `DeploymentUtils` which provides `deployNewProxy()`.
187-
188120
## Configuration
189121

190-
See `foundry.toml` for Foundry configuration. Key settings:
191-
192-
- Source: `contracts/`
193-
- Tests: `test/evm/foundry/`
194-
- Solidity: 0.8.30
195-
- EVM: Prague
196-
- Optimizer: 800 runs with via-ir
197-
198-
**Do not modify `foundry.toml` without asking** - explain what you want to change and why.
122+
See `foundry.toml` for Foundry configuration. **Do not modify `foundry.toml` without asking.**
199123

200124
## Security Practices
201125

0 commit comments

Comments
 (0)