Skip to content

Commit 32d6ca4

Browse files
authored
feat: auto verify contracts after deployment (#272)
# Automatic Smart Contract Verification Integration **Resolves:** [#214](#214) This pull request implements **automatic smart contract verification** across deployment scripts in the `service_contracts/tools` directory, utilizing the `filfox-verifier` tool to verify contracts on the Filecoin network. The verification process is controlled via the `AUTO_VERIFY` environment variable and enhances deployment reliability through **automated post-deployment validation**. # RESOLVES #214 --- ## 🧩 Changes Made ### ✅ `deploy-all-warm-storage-calibnet.sh` - Added comprehensive verification for **all major contracts** and **proxy contracts**. - Added **automatic dependency installation** and **chain ID detection**. - Integrated end-to-end verification sequence for the full warm storage deployment pipeline. ### ✅ `deploy-registry-calibnet.sh` - Integrated verification for both **registry implementation** and **proxy contracts**. - Uses consistent logging and automatic chain identification. ### ✅ `deploy-session-key-registry.sh` - Implemented **post-deployment verification** for the **Session Key Registry** contract. ### ✅ `deploy-warm-storage-view.sh` - Added verification steps for the **Warm Storage State View** contract. ### ✅ `deploy-warm-storage-implementation-only.sh` - Included verification for the **Warm Storage Implementation** contract after deployment. ---
1 parent dc2c8ab commit 32d6ca4

8 files changed

+419
-110
lines changed

service_contracts/tools/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ The following parameters are critical for proof generation and validation. They
5252
## Environment Variables
5353

5454
### Required for all scripts:
55-
- `KEYSTORE` - Path to the Ethereum keystore file
55+
These scripts now follow forge/cast's environment variable conventions. Set the following environment variables instead of passing flags:
56+
- `ETH_KEYSTORE` - Path to the Ethereum keystore file (or keep using `KEYSTORE` and it will be mapped)
5657
- `PASSWORD` - Password for the keystore (can be empty string if no password)
57-
- `RPC_URL` - RPC endpoint for Calibration testnet
58+
- `ETH_RPC_URL` - RPC endpoint for Calibration testnet (e.g. `https://api.calibration.node.glif.io/rpc/v1`)
59+
- `ETH_FROM` - Optional: address to use as deployer (forge/cast default is taken from the keystore)
5860

5961
### Required for specific scripts:
6062
- `deploy-warm-storage-calibnet.sh` requires:
@@ -72,11 +74,13 @@ The following parameters are critical for proof generation and validation. They
7274
### Fresh Deployment (All Contracts)
7375

7476
```bash
75-
export KEYSTORE="/path/to/keystore.json"
77+
78+
export ETH_KEYSTORE="/path/to/keystore.json"
7679
export PASSWORD="your-password"
77-
export RPC_URL="https://api.calibration.node.glif.io/rpc/v1"
80+
export ETH_RPC_URL="https://api.calibration.node.glif.io/rpc/v1"
7881
export CHALLENGE_FINALITY="10" # Use "150" for mainnet
7982

83+
8084
# Optional: Custom proving periods
8185
export MAX_PROVING_PERIOD="240" # 240 epochs for calibnet, 2880 for mainnet
8286
export CHALLENGE_WINDOW_SIZE="30" # 30 epochs for calibnet, 60 for mainnet

service_contracts/tools/deploy-all-warm-storage.sh

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,24 @@ SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
2626

2727
echo "Deploying all Warm Storage contracts"
2828

29-
if [ -z "$RPC_URL" ]; then
30-
echo "Error: RPC_URL is not set"
29+
if [ -z "$ETH_RPC_URL" ]; then
30+
echo "Error: ETH_RPC_URL is not set"
3131
exit 1
3232
fi
3333

3434
# Auto-detect chain ID from RPC
35-
CHAIN_ID=$(cast chain-id --rpc-url "$RPC_URL")
36-
if [ -z "$CHAIN_ID" ]; then
37-
echo "Error: Failed to detect chain ID from RPC"
38-
exit 1
35+
if [ -z "$CHAIN" ]; then
36+
export CHAIN=$(cast chain-id)
37+
if [ -z "$CHAIN" ]; then
38+
echo "Error: Failed to detect chain ID from RPC"
39+
exit 1
40+
fi
3941
fi
4042

4143
# Set network-specific configuration based on chain ID
42-
# See service_contracts/tools/README.md for deployment parameter documentation
43-
case "$CHAIN_ID" in
44+
# NOTE: CHALLENGE_FINALITY should always be 150 in production for security.
45+
# Calibnet uses lower values for faster testing and development.
46+
case "$CHAIN" in
4447
"314159")
4548
NETWORK_NAME="calibnet"
4649
# Network-specific addresses for calibnet
@@ -64,12 +67,12 @@ case "$CHAIN_ID" in
6467
echo " Supported networks:"
6568
echo " 314159 - Filecoin Calibration testnet"
6669
echo " 314 - Filecoin mainnet"
67-
echo " Detected chain ID: $CHAIN_ID"
70+
echo " Detected chain ID: $CHAIN"
6871
exit 1
6972
;;
7073
esac
7174

72-
echo "Detected Chain ID: $CHAIN_ID ($NETWORK_NAME)"
75+
echo "Detected Chain ID: $CHAIN ($NETWORK_NAME)"
7376

7477
if [ "$DRY_RUN" != "true" ] && [ -z "$KEYSTORE" ]; then
7578
echo "Error: KEYSTORE is not set (required for actual deployment)"
@@ -172,13 +175,13 @@ if [ "$DRY_RUN" = "true" ]; then
172175
echo "🧪 Using dummy SessionKeyRegistry address: $SESSION_KEY_REGISTRY_ADDRESS"
173176
fi
174177
else
175-
if [ -z "$KEYSTORE" ]; then
176-
echo "Error: KEYSTORE is not set (required for actual deployment)"
178+
if [ -z "$ETH_KEYSTORE" ]; then
179+
echo "Error: ETH_KEYSTORE is not set (required for actual deployment)"
177180
exit 1
178181
fi
179182

180-
ADDR=$(cast wallet address --keystore "$KEYSTORE" --password "$PASSWORD")
181-
NONCE="$(cast nonce --rpc-url "$RPC_URL" "$ADDR")"
183+
ADDR=$(cast wallet address --password "$PASSWORD")
184+
NONCE="$(cast nonce "$ADDR")"
182185
BROADCAST_FLAG="--broadcast"
183186
echo "Deploying contracts from address $ADDR"
184187
echo "🚀 Will deploy and broadcast all transactions"
@@ -203,7 +206,8 @@ if [ "$DRY_RUN" = "true" ]; then
203206
exit 1
204207
fi
205208
else
206-
VERIFIER_IMPLEMENTATION_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID lib/pdp/src/PDPVerifier.sol:PDPVerifier | grep "Deployed to" | awk '{print $3}')
209+
# forge and cast will read ETH_RPC_URL, ETH_KEYSTORE, PASSWORD, ETH_FROM from the environment
210+
VERIFIER_IMPLEMENTATION_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE lib/pdp/src/PDPVerifier.sol:PDPVerifier | grep "Deployed to" | awk '{print $3}')
207211
if [ -z "$VERIFIER_IMPLEMENTATION_ADDRESS" ]; then
208212
echo "Error: Failed to extract PDPVerifier contract address"
209213
exit 1
@@ -222,7 +226,7 @@ if [ "$DRY_RUN" = "true" ]; then
222226
PDP_VERIFIER_ADDRESS="0x2345678901234567890123456789012345678901" # Dummy address for dry-run
223227
echo "✅ PDPVerifier proxy deployment planned"
224228
else
225-
PDP_VERIFIER_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $VERIFIER_IMPLEMENTATION_ADDRESS $INIT_DATA | grep "Deployed to" | awk '{print $3}')
229+
PDP_VERIFIER_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $VERIFIER_IMPLEMENTATION_ADDRESS $INIT_DATA | grep "Deployed to" | awk '{print $3}')
226230
if [ -z "$PDP_VERIFIER_ADDRESS" ]; then
227231
echo "Error: Failed to extract PDPVerifier proxy address"
228232
exit 1
@@ -244,7 +248,7 @@ if [ "$DRY_RUN" = "true" ]; then
244248
exit 1
245249
fi
246250
else
247-
PAYMENTS_CONTRACT_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID lib/fws-payments/src/Payments.sol:Payments | grep "Deployed to" | awk '{print $3}')
251+
PAYMENTS_CONTRACT_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE lib/fws-payments/src/Payments.sol:Payments | grep "Deployed to" | awk '{print $3}')
248252
if [ -z "$PAYMENTS_CONTRACT_ADDRESS" ]; then
249253
echo "Error: Failed to extract Payments contract address"
250254
exit 1
@@ -266,7 +270,7 @@ if [ "$DRY_RUN" = "true" ]; then
266270
exit 1
267271
fi
268272
else
269-
REGISTRY_IMPLEMENTATION_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID src/ServiceProviderRegistry.sol:ServiceProviderRegistry | grep "Deployed to" | awk '{print $3}')
273+
REGISTRY_IMPLEMENTATION_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE src/ServiceProviderRegistry.sol:ServiceProviderRegistry | grep "Deployed to" | awk '{print $3}')
270274
if [ -z "$REGISTRY_IMPLEMENTATION_ADDRESS" ]; then
271275
echo "Error: Failed to extract ServiceProviderRegistry implementation address"
272276
exit 1
@@ -285,7 +289,7 @@ if [ "$DRY_RUN" = "true" ]; then
285289
SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS="0x5678901234567890123456789012345678901234" # Dummy address for dry-run
286290
echo "✅ ServiceProviderRegistry proxy deployment planned"
287291
else
288-
SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $REGISTRY_IMPLEMENTATION_ADDRESS $REGISTRY_INIT_DATA | grep "Deployed to" | awk '{print $3}')
292+
SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $REGISTRY_IMPLEMENTATION_ADDRESS $REGISTRY_INIT_DATA | grep "Deployed to" | awk '{print $3}')
289293
if [ -z "$SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS" ]; then
290294
echo "Error: Failed to extract ServiceProviderRegistry proxy address"
291295
exit 1
@@ -307,7 +311,7 @@ if [ "$DRY_RUN" = "true" ]; then
307311
SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS="0x6789012345678901234567890123456789012345" # Dummy address for dry-run
308312
echo "✅ FilecoinWarmStorageService implementation deployment planned"
309313
else
310-
SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID src/FilecoinWarmStorageService.sol:FilecoinWarmStorageService --constructor-args $PDP_VERIFIER_ADDRESS $PAYMENTS_CONTRACT_ADDRESS $USDFC_TOKEN_ADDRESS $FILBEAM_BENEFICIARY_ADDRESS $SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS $SESSION_KEY_REGISTRY_ADDRESS | grep "Deployed to" | awk '{print $3}')
314+
SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE src/FilecoinWarmStorageService.sol:FilecoinWarmStorageService --constructor-args $PDP_VERIFIER_ADDRESS $PAYMENTS_CONTRACT_ADDRESS $USDFC_TOKEN_ADDRESS $FILBEAM_BENEFICIARY_ADDRESS $SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS $SESSION_KEY_REGISTRY_ADDRESS | grep "Deployed to" | awk '{print $3}')
311315
if [ -z "$SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS" ]; then
312316
echo "Error: Failed to extract FilecoinWarmStorageService contract address"
313317
exit 1
@@ -331,7 +335,7 @@ if [ "$DRY_RUN" = "true" ]; then
331335
WARM_STORAGE_SERVICE_ADDRESS="0x7890123456789012345678901234567890123456" # Dummy address for dry-run
332336
echo "✅ FilecoinWarmStorageService proxy deployment planned"
333337
else
334-
WARM_STORAGE_SERVICE_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE --chain-id $CHAIN_ID lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS $INIT_DATA | grep "Deployed to" | awk '{print $3}')
338+
WARM_STORAGE_SERVICE_ADDRESS=$(forge create --password "$PASSWORD" $BROADCAST_FLAG --nonce $NONCE lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS $INIT_DATA | grep "Deployed to" | awk '{print $3}')
335339
if [ -z "$WARM_STORAGE_SERVICE_ADDRESS" ]; then
336340
echo "Error: Failed to extract FilecoinWarmStorageService proxy address"
337341
exit 1
@@ -389,3 +393,24 @@ echo "FilBeam controller address: $FILBEAM_CONTROLLER_ADDRESS"
389393
echo "FilBeam beneficiary address: $FILBEAM_BENEFICIARY_ADDRESS"
390394
echo "Service name: $SERVICE_NAME"
391395
echo "Service description: $SERVICE_DESCRIPTION"
396+
397+
# Contract verification
398+
if [ "$DRY_RUN" = "false" ] && [ "${AUTO_VERIFY:-true}" = "true" ]; then
399+
echo
400+
echo "🔍 Starting automatic contract verification..."
401+
402+
pushd "$(dirname "$0")/.." >/dev/null
403+
source tools/verify-contracts.sh
404+
405+
verify_contracts_batch \
406+
"$VERIFIER_IMPLEMENTATION_ADDRESS,lib/pdp/src/PDPVerifier.sol:PDPVerifier" \
407+
"$PDP_VERIFIER_ADDRESS,lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy" \
408+
"$PAYMENTS_CONTRACT_ADDRESS,lib/fws-payments/src/Payments.sol:Payments" \
409+
"$REGISTRY_IMPLEMENTATION_ADDRESS,src/ServiceProviderRegistry.sol:ServiceProviderRegistry" \
410+
"$SERVICE_PROVIDER_REGISTRY_PROXY_ADDRESS,lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" \
411+
"$SERVICE_PAYMENTS_IMPLEMENTATION_ADDRESS,src/FilecoinWarmStorageService.sol:FilecoinWarmStorageService" \
412+
"$WARM_STORAGE_SERVICE_ADDRESS,lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy" \
413+
"$WARM_STORAGE_VIEW_ADDRESS,src/FilecoinWarmStorageServiceStateView.sol:FilecoinWarmStorageServiceStateView"
414+
415+
popd >/dev/null
416+
fi

service_contracts/tools/deploy-registry-calibnet.sh

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
# Assumption: forge, cast, jq are in the PATH
66
# Assumption: called from contracts directory so forge paths work out
77
#
8+
89
echo "Deploying Service Provider Registry Contract"
910

10-
if [ -z "$RPC_URL" ]; then
11-
echo "Error: RPC_URL is not set"
11+
export CHAIN=314159
12+
13+
if [ -z "$ETH_RPC_URL" ]; then
14+
echo "Error: ETH_RPC_URL is not set"
1215
exit 1
1316
fi
1417

15-
if [ -z "$KEYSTORE" ]; then
16-
echo "Error: KEYSTORE is not set"
18+
if [ -z "$ETH_KEYSTORE" ]; then
19+
echo "Error: ETH_KEYSTORE is not set"
1720
exit 1
1821
fi
1922

@@ -22,23 +25,23 @@ if [ -z "$PASSWORD" ]; then
2225
echo "Warning: PASSWORD is not set, using empty password"
2326
fi
2427

25-
ADDR=$(cast wallet address --keystore "$KEYSTORE" --password "$PASSWORD")
28+
ADDR=$(cast wallet address --password "$PASSWORD")
2629
echo "Deploying contracts from address $ADDR"
2730

28-
# Get current balance
29-
BALANCE=$(cast balance --rpc-url "$RPC_URL" "$ADDR")
31+
# Get current balance and nonce (cast will use ETH_RPC_URL)
32+
BALANCE=$(cast balance "$ADDR")
3033
echo "Deployer balance: $BALANCE"
3134

32-
NONCE="$(cast nonce --rpc-url "$RPC_URL" "$ADDR")"
35+
NONCE="$(cast nonce "$ADDR")"
3336
echo "Starting nonce: $NONCE"
3437

3538
# Deploy ServiceProviderRegistry implementation
3639
echo ""
3740
echo "=== STEP 1: Deploying ServiceProviderRegistry Implementation ==="
38-
REGISTRY_IMPLEMENTATION_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" --broadcast --nonce $NONCE --chain-id 314159 src/ServiceProviderRegistry.sol:ServiceProviderRegistry --optimizer-runs 1 --via-ir | grep "Deployed to" | awk '{print $3}')
41+
REGISTRY_IMPLEMENTATION_ADDRESS=$(forge create --password "$PASSWORD" --broadcast --nonce $NONCE src/ServiceProviderRegistry.sol:ServiceProviderRegistry --optimizer-runs 1 --via-ir | grep "Deployed to" | awk '{print $3}')
3942
if [ -z "$REGISTRY_IMPLEMENTATION_ADDRESS" ]; then
40-
echo "Error: Failed to extract ServiceProviderRegistry implementation address"
41-
exit 1
43+
echo "Error: Failed to extract ServiceProviderRegistry implementation address"
44+
exit 1
4245
fi
4346
echo "✓ ServiceProviderRegistry implementation deployed at: $REGISTRY_IMPLEMENTATION_ADDRESS"
4447
NONCE=$(expr $NONCE + "1")
@@ -50,25 +53,25 @@ echo "=== STEP 2: Deploying ServiceProviderRegistry Proxy ==="
5053
INIT_DATA=$(cast calldata "initialize()")
5154
echo "Initialization calldata: $INIT_DATA"
5255

53-
REGISTRY_PROXY_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" --broadcast --nonce $NONCE --chain-id 314159 lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $REGISTRY_IMPLEMENTATION_ADDRESS $INIT_DATA --optimizer-runs 1 --via-ir | grep "Deployed to" | awk '{print $3}')
56+
REGISTRY_PROXY_ADDRESS=$(forge create --password "$PASSWORD" --broadcast --nonce $NONCE lib/pdp/src/ERC1967Proxy.sol:MyERC1967Proxy --constructor-args $REGISTRY_IMPLEMENTATION_ADDRESS $INIT_DATA --optimizer-runs 1 --via-ir | grep "Deployed to" | awk '{print $3}')
5457
if [ -z "$REGISTRY_PROXY_ADDRESS" ]; then
55-
echo "Error: Failed to extract ServiceProviderRegistry proxy address"
56-
exit 1
58+
echo "Error: Failed to extract ServiceProviderRegistry proxy address"
59+
exit 1
5760
fi
5861
echo "✓ ServiceProviderRegistry proxy deployed at: $REGISTRY_PROXY_ADDRESS"
5962

6063
# Verify deployment by calling version() on the proxy
6164
echo ""
6265
echo "=== STEP 3: Verifying Deployment ==="
63-
VERSION=$(cast call --rpc-url "$RPC_URL" $REGISTRY_PROXY_ADDRESS "VERSION()(string)")
66+
VERSION=$(cast call $REGISTRY_PROXY_ADDRESS "version()(string)")
6467
if [ -z "$VERSION" ]; then
65-
echo "Warning: Could not verify contract version"
68+
echo "Warning: Could not verify contract version"
6669
else
67-
echo "✓ Contract version: $VERSION"
70+
echo "✓ Contract version: $VERSION"
6871
fi
6972

7073
# Get registration fee
71-
FEE=$(cast call --rpc-url "$RPC_URL" $REGISTRY_PROXY_ADDRESS "REGISTRATION_FEE()(uint256)")
74+
FEE=$(cast call $REGISTRY_PROXY_ADDRESS "REGISTRATION_FEE()(uint256)")
7275
if [ -z "$FEE" ]; then
7376
echo "Warning: Could not retrieve registration fee"
7477
FEE_IN_FIL="unknown"
@@ -78,11 +81,18 @@ else
7881
fi
7982

8083
# Get burn actor address
81-
BURN_ACTOR=$(cast call --rpc-url "$RPC_URL" $REGISTRY_PROXY_ADDRESS "BURN_ACTOR()(address)")
84+
BURN_ACTOR=$(cast call $REGISTRY_PROXY_ADDRESS "BURN_ACTOR()(address)")
8285
if [ -z "$BURN_ACTOR" ]; then
83-
echo "Warning: Could not retrieve burn actor address"
86+
echo "Warning: Could not retrieve burn actor address"
8487
else
85-
echo "✓ Burn actor address: $BURN_ACTOR"
88+
echo "✓ Burn actor address: $BURN_ACTOR"
89+
fi
90+
91+
# Get contract version (this should be used instead of hardcoded version)
92+
CONTRACT_VERSION=$(cast call --rpc-url "$RPC_URL" $REGISTRY_PROXY_ADDRESS "VERSION()(string)")
93+
if [ -z "$CONTRACT_VERSION" ]; then
94+
echo "Warning: Could not retrieve contract version"
95+
CONTRACT_VERSION="Unknown"
8696
fi
8797

8898
# Get contract version (this should be used instead of hardcoded version)
@@ -97,7 +107,7 @@ echo ""
97107
echo "=========================================="
98108
echo "=== DEPLOYMENT SUMMARY ==="
99109
echo "=========================================="
100-
echo "ServiceProviderRegistry Implementation: $REGISTRY_IMPLEMENTATION_ADDRESS"
110+
echo "ServiceProviderRegistry Implementation: $REGISTRY_IMPLEMENTATION_ADDRESS"
101111
echo "ServiceProviderRegistry Proxy: $REGISTRY_PROXY_ADDRESS"
102112
echo "=========================================="
103113
echo ""
@@ -121,4 +131,18 @@ echo " cast call $REGISTRY_PROXY_ADDRESS \"getAllActiveProviders()(uint256[])
121131
echo " State changes (requires registration fee):"
122132
echo " Register as provider (requires proper encoding of PDPData)"
123133
echo ""
124-
echo "=========================================="
134+
135+
# Automatic contract verification
136+
if [ "${AUTO_VERIFY:-true}" = "true" ]; then
137+
echo
138+
echo "🔍 Starting automatic contract verification..."
139+
140+
pushd "$(dirname $0)/.." >/dev/null
141+
source tools/verify-contracts.sh
142+
verify_contracts_batch "$REGISTRY_IMPLEMENTATION_ADDRESS,src/ServiceProviderRegistry.sol:ServiceProviderRegistry"
143+
popd >/dev/null
144+
else
145+
echo
146+
echo "⏭️ Skipping automatic verification (export AUTO_VERIFY=true to enable)"
147+
fi
148+
echo "=========================================="

service_contracts/tools/deploy-session-key-registry.sh

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,49 @@
99
# - called from service_contracts directory
1010
# - PATH has forge and cast
1111

12-
if [ -z "$RPC_URL" ]; then
13-
echo "Error: RPC_URL is not set"
12+
if [ -z "$ETH_RPC_URL" ]; then
13+
echo "Error: ETH_RPC_URL is not set"
1414
exit 1
1515
fi
1616

1717
# Auto-detect chain ID from RPC if not already set
18-
if [ -z "$CHAIN_ID" ]; then
19-
CHAIN_ID=$(cast chain-id --rpc-url "$RPC_URL")
20-
if [ -z "$CHAIN_ID" ]; then
18+
if [ -z "$CHAIN" ]; then
19+
export CHAIN=$(cast chain-id)
20+
if [ -z "$CHAIN" ]; then
2121
echo "Error: Failed to detect chain ID from RPC"
2222
exit 1
2323
fi
2424
fi
2525

26-
if [ -z "$KEYSTORE" ]; then
27-
echo "Error: KEYSTORE is not set"
26+
27+
if [ -z "$ETH_KEYSTORE" ]; then
28+
echo "Error: ETH_KEYSTORE is not set"
2829
exit 1
2930
fi
3031

31-
ADDR=$(cast wallet address --keystore "$KEYSTORE" --password "$PASSWORD")
32+
ADDR=$(cast wallet address --password "$PASSWORD")
3233
echo "Deploying SessionKeyRegistry from address $ADDR..."
3334

3435
# Check if NONCE is already set (when called from main deploy script)
3536
# If not, get it from the network (when running standalone)
3637
if [ -z "$NONCE" ]; then
37-
NONCE="$(cast nonce --rpc-url "$RPC_URL" "$ADDR")"
38+
NONCE="$(cast nonce "$ADDR")"
3839
fi
3940

40-
export SESSION_KEY_REGISTRY_ADDRESS=$(forge create --rpc-url "$RPC_URL" --keystore "$KEYSTORE" --password "$PASSWORD" --broadcast --nonce $NONCE --chain-id $CHAIN_ID lib/session-key-registry/src/SessionKeyRegistry.sol:SessionKeyRegistry | grep "Deployed to" | awk '{print $3}')
41+
export SESSION_KEY_REGISTRY_ADDRESS=$(forge create --password "$PASSWORD" --broadcast --nonce $NONCE lib/session-key-registry/src/SessionKeyRegistry.sol:SessionKeyRegistry | grep "Deployed to" | awk '{print $3}')
4142

4243
echo SessionKeyRegistry deployed at $SESSION_KEY_REGISTRY_ADDRESS
44+
45+
# Automatic contract verification
46+
if [ "${AUTO_VERIFY:-true}" = "true" ]; then
47+
echo
48+
echo "🔍 Starting automatic contract verification..."
49+
50+
pushd "$(dirname $0)/.." >/dev/null
51+
source tools/verify-contracts.sh
52+
verify_contracts_batch "$SESSION_KEY_REGISTRY_ADDRESS,src/SessionKeyRegistry.sol:SessionKeyRegistry"
53+
popd >/dev/null
54+
else
55+
echo
56+
echo "⏭️ Skipping automatic verification (export AUTO_VERIFY=true to enable)"
57+
fi

0 commit comments

Comments
 (0)