forked from NSPG13/agent-bounties
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeployStandingMetaV2.s.sol
More file actions
94 lines (83 loc) · 5.18 KB
/
Copy pathDeployStandingMetaV2.s.sol
File metadata and controls
94 lines (83 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.26;
import "../src/AgentBountyFactory.sol";
import "../src/StandingMetaV2Bundle.sol";
interface StandingMetaDeployVm {
function addr(uint256 privateKey) external returns (address);
function envAddress(string calldata name) external returns (address);
function envString(string calldata name) external returns (string memory);
function envUint(string calldata name) external returns (uint256);
function startBroadcast(uint256 privateKey) external;
function stopBroadcast() external;
function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
external
returns (string memory);
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
external
returns (string memory);
function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory);
function writeJson(string calldata json, string calldata path) external;
}
/// @notice Deploys only the standing-meta-v2 policy components on Base mainnet.
/// The canonical factory and native USDC addresses are deliberately immutable here.
contract DeployStandingMetaV2 {
StandingMetaDeployVm private constant vm =
StandingMetaDeployVm(address(uint160(uint256(keccak256("hevm cheat code")))));
uint256 private constant BASE_MAINNET_CHAIN_ID = 8_453;
address private constant BASE_MAINNET_FACTORY = 0x082C52131aaF0C56e76b075f895EAB6fcaB6d2F9;
address private constant BASE_MAINNET_USDC = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;
uint256 private constant MIN_KEEPER_BALANCE_AFTER_DEPLOYMENT = 100_000_000_000_000;
function run() external {
require(block.chainid == BASE_MAINNET_CHAIN_ID, "Base mainnet only");
require(
AgentBountyFactory(BASE_MAINNET_FACTORY).settlementToken() == BASE_MAINNET_USDC,
"canonical factory token drift"
);
uint256 deployerKey = vm.envUint("BASE_KEEPER_PRIVATE_KEY");
address deployer = vm.addr(deployerKey);
require(deployer.balance >= 500_000_000_000_000, "keeper reserve too low to deploy safely");
address attester = vm.envAddress("PARTICIPANT_ATTESTER_ADDRESS");
address verifierOne = vm.envAddress("REGRESSION_VERIFIER_ONE_ADDRESS");
address verifierTwo = vm.envAddress("REGRESSION_VERIFIER_TWO_ADDRESS");
require(attester != address(0), "attester zero");
require(
verifierOne != address(0) && verifierTwo != address(0) && verifierOne != verifierTwo, "verifier set invalid"
);
address[] memory verifiers = new address[](2);
verifiers[0] = verifierOne;
verifiers[1] = verifierTwo;
bytes32 verifierSetHash = keccak256(abi.encode(verifiers));
vm.startBroadcast(deployerKey);
StandingMetaV2Bundle bundle = new StandingMetaV2Bundle(BASE_MAINNET_FACTORY, attester, verifierOne, verifierTwo);
vm.stopBroadcast();
ParticipantEligibilityRegistry participants = bundle.participantRegistry();
OnchainTermsRegistry terms = bundle.termsRegistry();
CanonicalIndependentChildVerifierV2 module = bundle.verifierModule();
require(bundle.canonicalFactory() == BASE_MAINNET_FACTORY, "bundle factory drift");
require(address(module.canonicalFactory()) == BASE_MAINNET_FACTORY, "module factory drift");
require(module.settlementToken() == BASE_MAINNET_USDC, "module token drift");
require(address(module.participantRegistry()) == address(participants), "participant registry drift");
require(address(module.termsRegistry()) == address(terms), "terms registry drift");
require(module.taskVerifierSetHash() == verifierSetHash, "verifier set drift");
require(module.taskVerifierThreshold() == 2, "verifier threshold drift");
require(deployer.balance >= MIN_KEEPER_BALANCE_AFTER_DEPLOYMENT, "keeper reserve depleted below minimum");
string memory objectKey = "standing-meta-v2-deployment";
vm.serializeUint(objectKey, "chain_id", block.chainid);
vm.serializeAddress(objectKey, "deployer", deployer);
vm.serializeAddress(objectKey, "canonical_factory", BASE_MAINNET_FACTORY);
vm.serializeAddress(objectKey, "settlement_token", BASE_MAINNET_USDC);
vm.serializeAddress(objectKey, "participant_attester", attester);
vm.serializeAddress(objectKey, "bundle", address(bundle));
vm.serializeAddress(objectKey, "participant_registry", address(participants));
vm.serializeAddress(objectKey, "terms_registry", address(terms));
vm.serializeAddress(objectKey, "verifier_one", verifierOne);
vm.serializeAddress(objectKey, "verifier_two", verifierTwo);
vm.serializeBytes32(objectKey, "verifier_set_hash", verifierSetHash);
vm.serializeBytes32(objectKey, "acceptance_criteria_hash", module.ACCEPTANCE_CRITERIA_HASH());
vm.serializeUint(objectKey, "keeper_balance_after_wei", deployer.balance);
string memory json = vm.serializeAddress(objectKey, "verifier_module", address(module));
vm.writeJson(json, vm.envString("DEPLOYMENT_EVIDENCE_PATH"));
}
}