Skip to content

Commit 23ba2f4

Browse files
committed
feat: agg mode payment service contract + deployment
1 parent c987d70 commit 23ba2f4

File tree

11 files changed

+2286
-4195
lines changed

11 files changed

+2286
-4195
lines changed

contracts/broadcast/AlignedProofAggregationServiceDeployer.s.sol/560048/run-latest.json

Lines changed: 169 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
pragma solidity ^0.8.12;
2+
3+
import {AggregationModePaymentService} from "../../src/core/AggregationModePaymentService.sol";
4+
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
5+
6+
import "forge-std/Script.sol";
7+
import "forge-std/StdJson.sol";
8+
9+
contract AggregationModePaymentServiceDeployer is Script {
10+
function run(string memory configPath, string memory outputPath) external returns (address, address) {
11+
string memory configData = vm.readFile(configPath);
12+
13+
address owner = stdJson.readAddress(configData, ".permissions.paymentServiceOwner");
14+
15+
vm.startBroadcast();
16+
17+
AggregationModePaymentService implementation = new AggregationModePaymentService();
18+
ERC1967Proxy proxy =
19+
new ERC1967Proxy(address(implementation), abi.encodeWithSignature("initialize(address)", owner));
20+
21+
vm.stopBroadcast();
22+
23+
string memory addresses = "addresses";
24+
vm.serializeAddress(addresses, "aggregationModePaymentService", address(proxy));
25+
string memory addressesStr =
26+
vm.serializeAddress(addresses, "aggregationModePaymentServiceImplementation", address(implementation));
27+
28+
string memory parentObject = "parent";
29+
string memory finalJson = vm.serializeString(parentObject, "addresses", addressesStr);
30+
vm.writeJson(finalJson, outputPath);
31+
32+
return (address(proxy), address(implementation));
33+
}
34+
}

contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"risc0AggregationProgramImageId": "0xd8cfdd5410c70395c0a1af1842a0148428cc46e353355faccfba694dd4862dbf"
1111
},
1212
"permissions": {
13-
"owner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"
13+
"owner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
14+
"paymentServiceOwner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"
1415
}
1516
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"addresses": {
33
"alignedProofAggregationService": "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc",
4-
"alignedProofAggregationServiceImplementation": "0xFD471836031dc5108809D173A067e8486B9047A3"
4+
"alignedProofAggregationServiceImplementation": "0xFD471836031dc5108809D173A067e8486B9047A3",
5+
"aggregationModePaymentService": "0x922D6956C99E12DFeB3224DEA977D0939758A1Fe",
6+
"aggregationModePaymentServiceImplementation": "0x162A433068F51e18b7d13932F27e66a3f99E6890"
57
}
6-
}
8+
}

contracts/scripts/anvil/deploy_aligned_contracts.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ jq '.programs_id.risc0AggregationProgramImageId = $input[0].risc0_chunk_aggregat
8080

8181
cd contracts
8282

83-
# Deploy proof aggregation service contract with SP1 Verifier
83+
# Deploy proof aggregation service contract with SP1|Risc0 Verifier
84+
proof_aggregation_service_output=./script/output/devnet/proof_aggregation_service_deployment_output.json
8485
forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \
8586
./script/deploy/config/devnet/proof-aggregator-service.devnet.config.json \
86-
./script/output/devnet/proof_aggregation_service_deployment_output.json \
87+
$proof_aggregation_service_output \
8788
--rpc-url "http://localhost:8545" \
8889
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
8990
--broadcast \
@@ -100,5 +101,32 @@ forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \
100101
--sig "run(string configPath, string outputPath)" \
101102
--via-ir
102103

104+
# Deploy Aggregation mode payment service
105+
aggregation_mode_payment_service_output=./script/output/devnet/aggregation_mode_payment_service_deployment_output.json
106+
proof_aggregation_service_temp1=$proof_aggregation_service_output.temp1.json
107+
proof_aggregation_service_temp2=$proof_aggregation_service_output.temp2.json
108+
109+
forge script script/deploy/AggregationModePaymentService.s.sol \
110+
./script/deploy/config/devnet/proof-aggregator-service.devnet.config.json \
111+
$aggregation_mode_payment_service_output \
112+
--rpc-url "http://localhost:8545" \
113+
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
114+
--broadcast \
115+
--sig "run(string configPath, string outputPath)"
116+
117+
aggregation_mode_payment_service_proxy=$(jq -r '.addresses.aggregationModePaymentService' $aggregation_mode_payment_service_output)
118+
aggregation_mode_payment_service_implementation=$(jq -r '.addresses.aggregationModePaymentServiceImplementation' $aggregation_mode_payment_service_output)
119+
120+
jq --arg aggregation_mode_payment_service "$aggregation_mode_payment_service_proxy" \
121+
'.addresses.aggregationModePaymentService = $aggregation_mode_payment_service' \
122+
"$proof_aggregation_service_output" > "$proof_aggregation_service_temp1"
123+
124+
jq --arg aggregation_mode_payment_service_implementation "$aggregation_mode_payment_service_implementation" \
125+
'.addresses.aggregationModePaymentServiceImplementation = $aggregation_mode_payment_service_implementation' \
126+
"$proof_aggregation_service_temp1" > "$proof_aggregation_service_temp2"
127+
128+
mv "$proof_aggregation_service_temp2" "$proof_aggregation_service_output"
129+
rm -f "$aggregation_mode_payment_service_output" "$proof_aggregation_service_temp1" "$proof_aggregation_service_temp2"
130+
103131
# Kill the anvil process to save state
104132
pkill anvil

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/scripts/anvil/state/eigenlayer-deployed-anvil-state.json

Lines changed: 2000 additions & 4138 deletions
Large diffs are not rendered by default.

contracts/scripts/anvil/state/risc0-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/scripts/anvil/state/sp1-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.12;
3+
4+
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
5+
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
6+
import {UUPSUpgradeable} from "@openzeppelin-upgrades/contracts/proxy/utils/UUPSUpgradeable.sol";
7+
8+
contract AggregationModePaymentService is Initializable, OwnableUpgradeable, UUPSUpgradeable {
9+
// 24hs
10+
uint256 constant paymentValidUntilSeconds = 86400;
11+
12+
event UserPayment(address user, uint256 amount, uint256 from, uint256 until);
13+
14+
error InvalidDepositAmount(uint256 amount);
15+
16+
constructor() {
17+
_disableInitializers();
18+
}
19+
20+
function initialize(address _owner) public initializer {
21+
__Ownable_init();
22+
__UUPSUpgradeable_init();
23+
_transferOwnership(_owner);
24+
}
25+
26+
function _authorizeUpgrade(address newImplementation)
27+
internal
28+
override
29+
onlyOwner // solhint-disable-next-line no-empty-blocks
30+
{}
31+
32+
receive() external payable {
33+
uint256 amount = msg.value;
34+
35+
if (amount < 1) {
36+
revert InvalidDepositAmount(amount);
37+
}
38+
39+
emit UserPayment(msg.sender, amount, block.timestamp, block.timestamp + paymentValidUntilSeconds * amount);
40+
}
41+
}

0 commit comments

Comments
 (0)