...
This commit is contained in:
94
FOUNDRY_SETUP.md
Normal file
94
FOUNDRY_SETUP.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# Foundry Container Setup
|
||||
|
||||
**CRITICAL**: ALL Foundry tools MUST run through Podman containers. NO bare processes.
|
||||
|
||||
## Current Setup
|
||||
|
||||
### Anvil (Persistent Container)
|
||||
```bash
|
||||
# Status
|
||||
podman ps | grep mev-bot-anvil
|
||||
|
||||
# Logs
|
||||
podman logs -f mev-bot-anvil
|
||||
|
||||
# Restart
|
||||
podman restart mev-bot-anvil
|
||||
|
||||
# Stop
|
||||
podman stop mev-bot-anvil
|
||||
```
|
||||
|
||||
### Cast (via Podman Exec)
|
||||
```bash
|
||||
# Block number
|
||||
./bin/cast bn --rpc-url http://localhost:8545
|
||||
|
||||
# Balance
|
||||
./bin/cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:8545
|
||||
|
||||
# Call contract
|
||||
./bin/cast call <address> "<signature>" --rpc-url http://localhost:8545
|
||||
```
|
||||
|
||||
### Forge (Ephemeral Containers with Volume Mounts)
|
||||
```bash
|
||||
# Build
|
||||
./bin/forge build
|
||||
|
||||
# Test
|
||||
./bin/forge test
|
||||
|
||||
# Deploy
|
||||
./bin/forge script <script> --rpc-url http://localhost:8545
|
||||
```
|
||||
|
||||
## Why Container-Only?
|
||||
|
||||
**DO NOT use**:
|
||||
- `/home/administrator/.foundry/bin/anvil`
|
||||
- `/home/administrator/.foundry/bin/cast`
|
||||
- `/home/administrator/.foundry/bin/forge`
|
||||
|
||||
**ALWAYS use**:
|
||||
- `podman` commands for Anvil management
|
||||
- `./bin/cast` wrapper (runs via `podman exec`)
|
||||
- `./bin/forge` wrapper (runs ephemeral container)
|
||||
|
||||
## Benefits
|
||||
|
||||
✅ Process isolation and resource limits
|
||||
✅ Automatic restart policies
|
||||
✅ Clean shutdown and cleanup
|
||||
✅ Integrated with container stack
|
||||
✅ No orphaned processes
|
||||
✅ Version management through image tags
|
||||
|
||||
## Container Details
|
||||
|
||||
**Image**: `ghcr.io/foundry-rs/foundry:latest`
|
||||
**Network**: host mode (port 8545 exposed)
|
||||
**Container Name**: `mev-bot-anvil`
|
||||
**Command**: `anvil --fork-url https://arb1.arbitrum.io/rpc --host 0.0.0.0 --port 8545 --chain-id 42161`
|
||||
|
||||
## Implementation
|
||||
|
||||
`./bin/cast`:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
podman exec mev-bot-anvil cast "$@" 2>&1 | grep -v "nightly build"
|
||||
```
|
||||
|
||||
`./bin/forge`:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
podman run --rm --network host -v "$(pwd):/workspace" -w /workspace ghcr.io/foundry-rs/foundry:latest forge "$@" 2>&1 | grep -v "nightly build"
|
||||
```
|
||||
|
||||
`./bin/anvil`:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
echo "ERROR: Do not run anvil directly!"
|
||||
echo "Anvil runs as a persistent container: mev-bot-anvil"
|
||||
exit 1
|
||||
```
|
||||
Reference in New Issue
Block a user