@@ -15,146 +15,147 @@ import {SP1Verifier} from "../../lib/sp1-contracts/contracts/src/v5.0.0/SP1Verif
1515import {Succinct} from "../../src/tokens/Succinct.sol " ;
1616import {IntermediateSuccinct} from "../../src/tokens/IntermediateSuccinct.sol " ;
1717
18- // contract DeployProveAndVAppScript is BaseScript, FixtureLoader {
19- // string internal constant PROVE_KEY = "PROVE";
20- // string internal constant STAKING_KEY = "STAKING";
21- // string internal constant VAPP_KEY = "VAPP";
22-
23- // // Get from the corresponding chain deployment here:
24- // // https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments
25- // address internal SP1_VERIFIER_GATEWAY_GROTH16 = 0x397A5f7f3dBd538f23DE225B51f532c34448dA9B;
26-
27- // function run() external broadcaster {
28- // // Deploy the SP1VerifierGatway.
29- // SP1VerifierGateway gateway = new SP1VerifierGateway(msg.sender);
30- // SP1Verifier groth16 = new SP1Verifier();
31- // gateway.addRoute(address(groth16));
32-
33- // // Deploy SuccinctStaking.
34- // SuccinctStaking staking = new SuccinctStaking(msg.sender);
35-
36- // // Deploy MockERC20 PROVE and iPROVE tokens.
37- // Succinct prove = new Succinct(msg.sender);
38- // IntermediateSuccinct iProve = new IntermediateSuccinct(address(prove), address(staking));
39-
40- // // Deploy VApp contract
41- // bytes32 vkey = bytes32(0x002124aeceb145cb3e4d4b50f94571ab92fc27c165ccc4ac41d930bc86595088);
42- // bytes32 genesisStateRoot =
43- // bytes32(0xa11f4a6c98ad88ce1f707acc85018b1ee2ac1bc5e8dd912c8273400b7e535beb);
44- // uint64 genesisTimestamp = 0;
45- // address vAppImpl = address(new SuccinctVApp());
46- // SuccinctVApp vApp = SuccinctVApp(payable(address(new ERC1967Proxy(vAppImpl, ""))));
47- // vApp.initialize(
48- // msg.sender,
49- // address(prove),
50- // address(iProve),
51- // address(staking),
52- // address(gateway),
53- // vkey,
54- // genesisStateRoot,
55- // genesisTimestamp
56- // );
57-
58- // // Initialize SuccinctStaking.
59- // staking.initialize(address(vApp), address(prove), address(iProve), 10e18, 1 days, 1 days, 0);
60-
61- // // ===== MINT PROVE TOKENS =====
62- // console.log("=== Minting PROVE tokens ===");
63- // uint256 totalMintAmount = 1000000 * 1e18;
64- // prove.mint(msg.sender, totalMintAmount);
65- // console.log("Minted %s PROVE tokens to %s", totalMintAmount / 1e18, msg.sender);
66- // console.log("Your PROVE balance: %s", prove.balanceOf(msg.sender) / 1e18);
67-
68- // // ===== CREATE PROVER =====
69- // console.log("\n=== Creating prover ===");
70- // address prover = staking.createProver(10000);
71- // console.log("Created prover: %s", prover);
72-
73- // // ===== STAKE TO PROVER =====
74- // console.log("\n=== Staking to prover ===");
75- // prove.approve(address(staking), staking.minStakeAmount());
76- // staking.stake(prover, staking.minStakeAmount());
77- // console.log("Staked %s PROVE tokens to prover", totalMintAmount / 1e18);
78- // console.log("Prover PROVE balance: %s", prove.balanceOf(prover) / 1e18);
79-
80- // // ===== PROCESS 10 DEPOSITS =====
81- // console.log("\n=== Processing 10 deposits ===");
82-
83- // // Pre-calculate total approval needed to reduce transactions
84- // uint256 totalApprovalNeeded = 0;
85- // for (uint256 i = 0; i < 10; i++) {
86- // uint256 depositAmount = (100 + (i * 10)) * 1e18;
87- // totalApprovalNeeded += depositAmount;
88- // }
89-
90- // // Single approval for all deposits
91- // prove.approve(address(vApp), totalApprovalNeeded);
92- // console.log("Approved %s PROVE tokens for batch deposits", totalApprovalNeeded / 1e18);
93-
94- // uint256 totalDeposited = 0;
95- // uint64[] memory depositReceipts = new uint64[](10);
96-
97- // for (uint256 i = 0; i < 10; i++) {
98- // // Vary deposit amounts: base amount + some variation based on index
99- // uint256 depositAmount = (100 + (i * 10)) * 1e18; // 100, 110, 120, ... 190 PROVE
100-
101- // uint64 receipt = SuccinctVApp(address(vApp)).deposit(depositAmount);
102- // depositReceipts[i] = receipt;
103- // totalDeposited += depositAmount;
104-
105- // // Log every 5th deposit to avoid spam
106- // if ((i + 1) % 5 == 0) {
107- // console.log(
108- // "Completed %s deposits. Latest: %s PROVE (Receipt #%s)",
109- // i + 1,
110- // depositAmount / 1e18,
111- // receipt
112- // );
113- // }
114- // }
115-
116- // console.log("Total deposited: %s PROVE", totalDeposited / 1e18);
117- // console.log("VApp PROVE balance: %s", prove.balanceOf(address(vApp)) / 1e18);
118- // console.log("Your remaining PROVE balance: %s", prove.balanceOf(msg.sender) / 1e18);
119-
120- // // ===== PROCESS 10 WITHDRAWAL REQUESTS =====
121- // console.log("\n=== Processing 10 withdrawal requests ===");
122-
123- // uint256 totalWithdrawRequested = 0;
124- // uint64[] memory withdrawalReceipts = new uint64[](10);
125-
126- // for (uint256 i = 0; i < 10; i++) {
127- // // Vary withdrawal amounts: smaller amounts to ensure we don't exceed deposits
128- // uint256 withdrawAmount = (50 + (i * 5)) * 1e18; // 50, 55, 60, ... 545 PROVE
129-
130- // uint64 withdrawReceipt =
131- // SuccinctVApp(address(vApp)).requestWithdraw(msg.sender, withdrawAmount);
132- // withdrawalReceipts[i] = withdrawReceipt;
133- // totalWithdrawRequested += withdrawAmount;
134-
135- // // Log every 5th withdrawal to avoid spam
136- // if ((i + 1) % 5 == 0) {
137- // console.log(
138- // "Completed %s withdrawals. Latest: %s PROVE (Receipt #%s)",
139- // i + 1,
140- // withdrawAmount / 1e18,
141- // withdrawReceipt
142- // );
143- // }
144- // }
145-
146- // console.log("Total withdrawal requested: %s PROVE", totalWithdrawRequested / 1e18);
147-
148- // // ===== SUMMARY =====
149- // console.log("\n=== Summary ===");
150- // console.log("PROVE Token Address: %s", address(prove));
151- // console.log("MockStaking Address: %s", address(staking));
152- // console.log("SuccinctVApp Address: %s", address(vApp));
153- // console.log("Current Receipt Number: %s", SuccinctVApp(address(vApp)).currentOnchainTxId());
154- // console.log("VApp PROVE Balance: %s", prove.balanceOf(address(vApp)) / 1e18);
155- // console.log("Your PROVE Balance: %s", prove.balanceOf(msg.sender) / 1e18);
156- // console.log("Total Deposits Made: 10");
157- // console.log("Total Withdrawals Requested: 10");
158- // console.log("Net Deposited: %s PROVE", (totalDeposited - totalWithdrawRequested) / 1e18);
159- // }
160- // }
18+ contract DeployProveAndVAppScript is BaseScript , FixtureLoader {
19+ string internal constant PROVE_KEY = "PROVE " ;
20+ string internal constant STAKING_KEY = "STAKING " ;
21+ string internal constant VAPP_KEY = "VAPP " ;
22+
23+ // Get from the corresponding chain deployment here:
24+ // https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments
25+ address internal SP1_VERIFIER_GATEWAY_GROTH16 = 0x397A5f7f3dBd538f23DE225B51f532c34448dA9B ;
26+
27+ function run () external broadcaster {
28+ // Deploy the SP1VerifierGatway.
29+ SP1VerifierGateway gateway = new SP1VerifierGateway (msg .sender );
30+ SP1Verifier groth16 = new SP1Verifier ();
31+ gateway.addRoute (address (groth16));
32+
33+ // Deploy SuccinctStaking.
34+ SuccinctStaking staking = new SuccinctStaking (msg .sender );
35+
36+ // Deploy MockERC20 PROVE and iPROVE tokens.
37+ Succinct prove = new Succinct (msg .sender );
38+ IntermediateSuccinct iProve = new IntermediateSuccinct (address (prove), address (staking));
39+
40+ // Deploy VApp contract
41+ bytes32 vkey = bytes32 (0x008191fd1466cbb0dc44b6bf0b09d3c302fc2891c15bd66a28106e74c8edc907 );
42+ bytes32 genesisStateRoot =
43+ bytes32 (0x4b15a7d34ea0ec471d0d6ab9170cc2910f590819ee168e2a799e25244e327116 );
44+ uint64 genesisTimestamp = 0 ;
45+ address vAppImpl = address (new SuccinctVApp ());
46+ SuccinctVApp vApp = SuccinctVApp (payable (address (new ERC1967Proxy (vAppImpl, "" ))));
47+ vApp.initialize (
48+ msg .sender ,
49+ address (prove),
50+ address (iProve),
51+ msg .sender ,
52+ address (staking),
53+ address (gateway),
54+ 0 ,
55+ vkey,
56+ genesisStateRoot
57+ );
58+
59+ // Initialize SuccinctStaking.
60+ staking.initialize (address (vApp), address (prove), address (iProve), 10e18 , 1 days, 1 days, 0 );
61+
62+ // ===== MINT PROVE TOKENS =====
63+ console.log ("=== Minting PROVE tokens === " );
64+ uint256 totalMintAmount = 1000000 * 1e18 ;
65+ prove.mint (msg .sender , totalMintAmount);
66+ console.log ("Minted %s PROVE tokens to %s " , totalMintAmount / 1e18 , msg .sender );
67+ console.log ("Your PROVE balance: %s " , prove.balanceOf (msg .sender ) / 1e18 );
68+
69+ // ===== CREATE PROVER =====
70+ console.log ("\n=== Creating prover === " );
71+ address prover = staking.createProver (10000 );
72+ console.log ("Created prover: %s " , prover);
73+
74+ // ===== STAKE TO PROVER =====
75+ console.log ("\n=== Staking to prover === " );
76+ prove.approve (address (staking), staking.minStakeAmount ());
77+ staking.stake (prover, staking.minStakeAmount ());
78+ console.log ("Staked %s PROVE tokens to prover " , totalMintAmount / 1e18 );
79+ console.log ("Prover PROVE balance: %s " , prove.balanceOf (prover) / 1e18 );
80+
81+ // ===== PROCESS 10 DEPOSITS =====
82+ console.log ("\n=== Processing 10 deposits === " );
83+
84+ // Pre-calculate total approval needed to reduce transactions
85+ uint256 totalApprovalNeeded = 0 ;
86+ for (uint256 i = 0 ; i < 10 ; i++ ) {
87+ uint256 depositAmount = (100 + (i * 10 )) * 1e18 ;
88+ totalApprovalNeeded += depositAmount;
89+ }
90+
91+ // Single approval for all deposits
92+ prove.approve (address (vApp), totalApprovalNeeded);
93+ console.log ("Approved %s PROVE tokens for batch deposits " , totalApprovalNeeded / 1e18 );
94+
95+ uint256 totalDeposited = 0 ;
96+ uint64 [] memory depositReceipts = new uint64 [](10 );
97+
98+ for (uint256 i = 0 ; i < 10 ; i++ ) {
99+ // Vary deposit amounts: base amount + some variation based on index
100+ uint256 depositAmount = (100 + (i * 10 )) * 1e18 ; // 100, 110, 120, ... 190 PROVE
101+
102+ uint64 receipt = SuccinctVApp (address (vApp)).deposit (depositAmount);
103+ depositReceipts[i] = receipt;
104+ totalDeposited += depositAmount;
105+
106+ // Log every 5th deposit to avoid spam
107+ if ((i + 1 ) % 5 == 0 ) {
108+ console.log (
109+ "Completed %s deposits. Latest: %s PROVE (Receipt #%s) " ,
110+ i + 1 ,
111+ depositAmount / 1e18 ,
112+ receipt
113+ );
114+ }
115+ }
116+
117+ console.log ("Total deposited: %s PROVE " , totalDeposited / 1e18 );
118+ console.log ("VApp PROVE balance: %s " , prove.balanceOf (address (vApp)) / 1e18 );
119+ console.log ("Your remaining PROVE balance: %s " , prove.balanceOf (msg .sender ) / 1e18 );
120+
121+ // ===== PROCESS 10 WITHDRAWAL REQUESTS =====
122+ console.log ("\n=== Processing 10 withdrawal requests === " );
123+
124+ uint256 totalWithdrawRequested = 0 ;
125+ uint64 [] memory withdrawalReceipts = new uint64 [](10 );
126+
127+ for (uint256 i = 0 ; i < 10 ; i++ ) {
128+ // Vary withdrawal amounts: smaller amounts to ensure we don't exceed deposits
129+ uint256 withdrawAmount = (50 + (i * 5 )) * 1e18 ; // 50, 55, 60, ... 545 PROVE
130+
131+ uint64 withdrawReceipt =
132+ SuccinctVApp (address (vApp)).requestWithdraw (msg .sender , withdrawAmount);
133+ withdrawalReceipts[i] = withdrawReceipt;
134+ totalWithdrawRequested += withdrawAmount;
135+
136+ // Log every 5th withdrawal to avoid spam
137+ if ((i + 1 ) % 5 == 0 ) {
138+ console.log (
139+ "Completed %s withdrawals. Latest: %s PROVE (Receipt #%s) " ,
140+ i + 1 ,
141+ withdrawAmount / 1e18 ,
142+ withdrawReceipt
143+ );
144+ }
145+ }
146+
147+ console.log ("Total withdrawal requested: %s PROVE " , totalWithdrawRequested / 1e18 );
148+
149+ // ===== SUMMARY =====
150+ console.log ("\n=== Summary === " );
151+ console.log ("PROVE Token Address: %s " , address (prove));
152+ console.log ("MockStaking Address: %s " , address (staking));
153+ console.log ("SuccinctVApp Address: %s " , address (vApp));
154+ console.log ("Current Receipt Number: %s " , SuccinctVApp (address (vApp)).currentOnchainTxId ());
155+ console.log ("VApp PROVE Balance: %s " , prove.balanceOf (address (vApp)) / 1e18 );
156+ console.log ("Your PROVE Balance: %s " , prove.balanceOf (msg .sender ) / 1e18 );
157+ console.log ("Total Deposits Made: 10 " );
158+ console.log ("Total Withdrawals Requested: 10 " );
159+ console.log ("Net Deposited: %s PROVE " , (totalDeposited - totalWithdrawRequested) / 1e18 );
160+ }
161+ }
0 commit comments