Skip to content

Commit a42b604

Browse files
committed
chore(contracts): move AtomicDeployer
1 parent 0b443e3 commit a42b604

File tree

2 files changed

+172
-169
lines changed

2 files changed

+172
-169
lines changed

contracts/script/deploy/AllAtomic.s.sol

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -6,179 +6,12 @@ import {SuccinctStaking} from "../../src/SuccinctStaking.sol";
66
import {SuccinctVApp} from "../../src/SuccinctVApp.sol";
77
import {IntermediateSuccinct} from "../../src/tokens/IntermediateSuccinct.sol";
88
import {SuccinctGovernor} from "../../src/SuccinctGovernor.sol";
9-
import {Succinct} from "../../src/tokens/Succinct.sol";
10-
import {FixtureLoader} from "../../test/utils/FixtureLoader.sol";
9+
import {AtomicDeployer} from "../utils/AtomicDeployer.sol";
1110
import {ERC1967Proxy} from
1211
"../../lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
13-
import {SP1VerifierGateway} from "../../lib/sp1-contracts/contracts/src/SP1VerifierGateway.sol";
14-
import {SP1Verifier} from "../../lib/sp1-contracts/contracts/src/v5.0.0/SP1VerifierGroth16.sol";
15-
16-
contract AtomicDeployer {
17-
// Staking proxy param
18-
address public stakingImpl;
19-
20-
// IntermediateSuccinct param
21-
address public prove;
22-
23-
// Governor params
24-
uint48 public votingDelay;
25-
uint32 public votingPeriod;
26-
uint256 public proposalThreshold;
27-
uint256 public quorumFraction;
28-
29-
address public vappImpl;
30-
address public owner;
31-
address public auctioneer;
32-
address public verifier;
33-
uint256 public minDepositAmount;
34-
bytes32 public vkey;
35-
address public dispenser;
36-
uint256 public minStakeAmount;
37-
uint256 public maxUnstakeRequests;
38-
uint256 public unstakePeriod;
39-
uint256 public slashCancellationPeriod;
40-
bytes32 public genesisStateRoot;
41-
42-
address public deployerOwner;
43-
44-
constructor() {
45-
deployerOwner = msg.sender;
46-
}
47-
48-
modifier onlyOwner() {
49-
require(msg.sender == deployerOwner);
50-
_;
51-
}
52-
53-
function setParams1(
54-
address _stakingImpl,
55-
address _prove,
56-
uint48 _votingDelay,
57-
uint32 _votingPeriod,
58-
uint256 _proposalThreshold,
59-
uint256 _quorumFraction
60-
) external onlyOwner {
61-
stakingImpl = _stakingImpl;
62-
prove = _prove;
63-
votingDelay = _votingDelay;
64-
votingPeriod = _votingPeriod;
65-
proposalThreshold = _proposalThreshold;
66-
quorumFraction = _quorumFraction;
67-
}
68-
69-
function setParams2(
70-
address _vappImpl,
71-
address _owner,
72-
address _auctioneer,
73-
address _verifier,
74-
uint256 _minDepositAmount,
75-
bytes32 _vkey
76-
) external onlyOwner {
77-
vappImpl = _vappImpl;
78-
owner = _owner;
79-
auctioneer = _auctioneer;
80-
verifier = _verifier;
81-
minDepositAmount = _minDepositAmount;
82-
vkey = _vkey;
83-
}
84-
85-
function setParams3(
86-
address _dispenser,
87-
uint256 _minStakeAmount,
88-
uint256 _maxUnstakeRequests,
89-
uint256 _unstakePeriod,
90-
uint256 _slashCancellationPeriod,
91-
bytes32 _genesisStateRoot
92-
) external onlyOwner {
93-
dispenser = _dispenser;
94-
minStakeAmount = _minStakeAmount;
95-
maxUnstakeRequests = _maxUnstakeRequests;
96-
unstakePeriod = _unstakePeriod;
97-
slashCancellationPeriod = _slashCancellationPeriod;
98-
genesisStateRoot = _genesisStateRoot;
99-
}
100-
101-
function deploy(bytes32 salt, bytes calldata iproveCode, bytes calldata governorCode)
102-
external
103-
onlyOwner
104-
returns (address, address, address, address)
105-
{
106-
address STAKING;
107-
{
108-
STAKING = address(new ERC1967Proxy{salt: salt}(stakingImpl, ""));
109-
}
110-
111-
address I_PROVE;
112-
{
113-
// I_PROVE = address(new IntermediateSuccinct{salt: salt}(prove, STAKING));
114-
bytes memory args = abi.encode(prove, STAKING);
115-
bytes memory initCode = abi.encodePacked(iproveCode, args);
116-
117-
assembly {
118-
I_PROVE := create2(0, add(initCode, 0x20), mload(initCode), salt)
119-
if iszero(extcodesize(I_PROVE)) { revert(0, 0) }
120-
}
121-
}
122-
123-
address GOVERNOR;
124-
{
125-
// GOVERNOR = address(
126-
// new SuccinctGovernor{salt: salt}(
127-
// I_PROVE, votingDelay, votingPeriod, proposalThreshold, quorumFraction
128-
// )
129-
// );
130-
bytes memory args =
131-
abi.encode(I_PROVE, votingDelay, votingPeriod, proposalThreshold, quorumFraction);
132-
bytes memory initCode = abi.encodePacked(governorCode, args);
133-
134-
assembly {
135-
GOVERNOR := create2(0, add(initCode, 0x20), mload(initCode), salt)
136-
if iszero(extcodesize(GOVERNOR)) { revert(0, 0) }
137-
}
138-
}
139-
140-
address VAPP;
141-
{
142-
// Encode the initialize function call data
143-
bytes memory vappInitData;
144-
{
145-
vappInitData = abi.encodeCall(
146-
SuccinctVApp.initialize,
147-
(
148-
owner,
149-
prove,
150-
I_PROVE,
151-
auctioneer,
152-
STAKING,
153-
verifier,
154-
minDepositAmount,
155-
vkey,
156-
genesisStateRoot
157-
)
158-
);
159-
}
160-
VAPP = address(new ERC1967Proxy{salt: salt}(vappImpl, vappInitData));
161-
}
162-
163-
SuccinctStaking(STAKING).initialize(
164-
owner,
165-
GOVERNOR,
166-
VAPP,
167-
prove,
168-
I_PROVE,
169-
dispenser,
170-
minStakeAmount,
171-
maxUnstakeRequests,
172-
unstakePeriod,
173-
slashCancellationPeriod
174-
);
175-
176-
return (STAKING, VAPP, I_PROVE, GOVERNOR);
177-
}
178-
}
17912

18013
// Deploy all contracts.
181-
contract AllAtomicScript is BaseScript, FixtureLoader {
14+
contract AllAtomicScript is BaseScript {
18215
function run() external broadcaster {
18316
// Read config
18417
bytes32 salt = readBytes32("CREATE2_SALT");
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import {SuccinctStaking} from "../../src/SuccinctStaking.sol";
5+
import {SuccinctVApp} from "../../src/SuccinctVApp.sol";
6+
import {IntermediateSuccinct} from "../../src/tokens/IntermediateSuccinct.sol";
7+
import {ERC1967Proxy} from
8+
"../../lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
9+
10+
contract AtomicDeployer {
11+
// Staking proxy param
12+
address public stakingImpl;
13+
14+
// IntermediateSuccinct param
15+
address public prove;
16+
17+
// Governor params
18+
uint48 public votingDelay;
19+
uint32 public votingPeriod;
20+
uint256 public proposalThreshold;
21+
uint256 public quorumFraction;
22+
23+
// VApp params
24+
address public vappImpl;
25+
address public owner;
26+
address public auctioneer;
27+
address public verifier;
28+
uint256 public minDepositAmount;
29+
bytes32 public vkey;
30+
31+
// Staking params
32+
address public dispenser;
33+
uint256 public minStakeAmount;
34+
uint256 public maxUnstakeRequests;
35+
uint256 public unstakePeriod;
36+
uint256 public slashCancellationPeriod;
37+
bytes32 public genesisStateRoot;
38+
39+
address public deployerOwner;
40+
41+
constructor() {
42+
deployerOwner = msg.sender;
43+
}
44+
45+
modifier onlyOwner() {
46+
require(msg.sender == deployerOwner);
47+
_;
48+
}
49+
50+
function setParams1(
51+
address _stakingImpl,
52+
address _prove,
53+
uint48 _votingDelay,
54+
uint32 _votingPeriod,
55+
uint256 _proposalThreshold,
56+
uint256 _quorumFraction
57+
) external onlyOwner {
58+
stakingImpl = _stakingImpl;
59+
prove = _prove;
60+
votingDelay = _votingDelay;
61+
votingPeriod = _votingPeriod;
62+
proposalThreshold = _proposalThreshold;
63+
quorumFraction = _quorumFraction;
64+
}
65+
66+
function setParams2(
67+
address _vappImpl,
68+
address _owner,
69+
address _auctioneer,
70+
address _verifier,
71+
uint256 _minDepositAmount,
72+
bytes32 _vkey
73+
) external onlyOwner {
74+
vappImpl = _vappImpl;
75+
owner = _owner;
76+
auctioneer = _auctioneer;
77+
verifier = _verifier;
78+
minDepositAmount = _minDepositAmount;
79+
vkey = _vkey;
80+
}
81+
82+
function setParams3(
83+
address _dispenser,
84+
uint256 _minStakeAmount,
85+
uint256 _maxUnstakeRequests,
86+
uint256 _unstakePeriod,
87+
uint256 _slashCancellationPeriod,
88+
bytes32 _genesisStateRoot
89+
) external onlyOwner {
90+
dispenser = _dispenser;
91+
minStakeAmount = _minStakeAmount;
92+
maxUnstakeRequests = _maxUnstakeRequests;
93+
unstakePeriod = _unstakePeriod;
94+
slashCancellationPeriod = _slashCancellationPeriod;
95+
genesisStateRoot = _genesisStateRoot;
96+
}
97+
98+
function deploy(bytes32 salt, bytes calldata iproveCode, bytes calldata governorCode)
99+
external
100+
onlyOwner
101+
returns (address, address, address, address)
102+
{
103+
address STAKING;
104+
{
105+
STAKING = address(new ERC1967Proxy{salt: salt}(stakingImpl, ""));
106+
}
107+
108+
address I_PROVE;
109+
{
110+
// I_PROVE = address(new IntermediateSuccinct{salt: salt}(prove, STAKING));
111+
bytes memory args = abi.encode(prove, STAKING);
112+
bytes memory initCode = abi.encodePacked(iproveCode, args);
113+
114+
assembly {
115+
I_PROVE := create2(0, add(initCode, 0x20), mload(initCode), salt)
116+
if iszero(extcodesize(I_PROVE)) { revert(0, 0) }
117+
}
118+
}
119+
120+
address GOVERNOR;
121+
{
122+
bytes memory args =
123+
abi.encode(I_PROVE, votingDelay, votingPeriod, proposalThreshold, quorumFraction);
124+
bytes memory initCode = abi.encodePacked(governorCode, args);
125+
126+
assembly {
127+
GOVERNOR := create2(0, add(initCode, 0x20), mload(initCode), salt)
128+
if iszero(extcodesize(GOVERNOR)) { revert(0, 0) }
129+
}
130+
}
131+
132+
address VAPP;
133+
{
134+
// Encode the initialize function call data
135+
bytes memory vappInitData;
136+
{
137+
vappInitData = abi.encodeCall(
138+
SuccinctVApp.initialize,
139+
(
140+
owner,
141+
prove,
142+
I_PROVE,
143+
auctioneer,
144+
STAKING,
145+
verifier,
146+
minDepositAmount,
147+
vkey,
148+
genesisStateRoot
149+
)
150+
);
151+
}
152+
VAPP = address(new ERC1967Proxy{salt: salt}(vappImpl, vappInitData));
153+
}
154+
155+
SuccinctStaking(STAKING).initialize(
156+
owner,
157+
GOVERNOR,
158+
VAPP,
159+
prove,
160+
I_PROVE,
161+
dispenser,
162+
minStakeAmount,
163+
maxUnstakeRequests,
164+
unstakePeriod,
165+
slashCancellationPeriod
166+
);
167+
168+
return (STAKING, VAPP, I_PROVE, GOVERNOR);
169+
}
170+
}

0 commit comments

Comments
 (0)