Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add onlyAggregator to respondToTask #883

Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
eadece7
fix: add again old NewBatch event
uri-99 Aug 26, 2024
f27fd9a
chore: make bindings and redeploy contracts
uri-99 Aug 26, 2024
e015126
fix: go bindings
uri-99 Aug 26, 2024
d1a325f
feat: add RespondToTaskOld
uri-99 Aug 26, 2024
3ca02bc
refactor: change _old for old, to V2 for new
uri-99 Aug 26, 2024
ca7fd53
feat: add sendAggregatedResponseV2 to aggregator
uri-99 Aug 26, 2024
679ed22
feat: add processNewBatchV2 to avs_subscriber
uri-99 Aug 26, 2024
feab74c
feat: add SignedTaskResponseV2
uri-99 Aug 26, 2024
9fe3900
feat: add ProcessNewBatchLogV2
uri-99 Aug 26, 2024
019f7cc
feat: subscribeToNewTasksV2, SubscribeToNewTasksV2, getLatestTaskFrom…
uri-99 Aug 26, 2024
60b1ccd
feat: aggregator: sendAggregatedResponseV2, AddNewTaskV2
uri-99 Aug 26, 2024
0038673
feat: subscriber SubscribeToNewTasksV2
uri-99 Aug 26, 2024
e1088d3
feat: server ProcessOperatorSignedTaskResponseV2
uri-99 Aug 26, 2024
318ef36
feat: operator NewTaskCreatedChanV2, and discerning ProcessNewBatchLogV2
uri-99 Aug 26, 2024
48d7cc8
feat: rpc_client SendSignedTaskResponseToAggregatorV2
uri-99 Aug 26, 2024
99b503f
feat: aggregator v1 v2 discerning
uri-99 Aug 26, 2024
5a5f4f8
fixes: fix
uri-99 Aug 26, 2024
6fa127a
remove: agg subscribe to v2 in different goroutine, now subscribes bo…
uri-99 Aug 27, 2024
549a2ba
feat: agg subscribes to both success
uri-99 Aug 27, 2024
943d7a1
feat: add if block.number in alignedservicemanager.sol
uri-99 Aug 27, 2024
79a6a33
feat: reading of blockNumber insteadof B2 bool
uri-99 Aug 27, 2024
642169d
feat: if block num in aggregator
uri-99 Aug 27, 2024
87ac992
fix: lower block num
uri-99 Aug 27, 2024
23947ee
fix: if conditions and switchBlockNumber
uri-99 Aug 27, 2024
06e86d6
refactor: comment on respondToTask easier to use
uri-99 Aug 27, 2024
905f740
refactor: add 'V2' to event NewBatch and function respondToTask
uri-99 Aug 27, 2024
39bbb6d
chore: update OPERATOR_VERSION to v0.5.0
JuArce Aug 27, 2024
2aa3500
chore: set switch block at 2_268_375
JuArce Aug 27, 2024
5e12786
chore: set switch block at 2_268_375 in service manager
JuArce Aug 27, 2024
2cda24f
chore: update config operator template
JuArce Aug 27, 2024
b5ff94b
fix: use correct types
JuArce Aug 27, 2024
f2fac00
chore: update OPERATOR VERSION
JuArce Aug 27, 2024
a40c786
feat: add onlyAggregator on respondToTask (missing init)
uri-99 Aug 27, 2024
15b7e2e
fix: onlyAggregator modifier
uri-99 Aug 27, 2024
a2fe7d3
feat: reinitializer(2) on aligned to ser aggregator address
uri-99 Aug 27, 2024
202e4d4
feat: add aggregator to deploy
uri-99 Aug 28, 2024
33dddbf
feat: special add_aggregator upgrade script, with its reinitialize(2)…
uri-99 Aug 28, 2024
aacb985
feat: fix add aggregator upgrader
uri-99 Aug 28, 2024
cd3c174
chore: better initializeAggregator comments
uri-99 Aug 28, 2024
9e2f4e5
feat: upgrade script for holesky
uri-99 Aug 28, 2024
15c9dcd
refactor: aggregator to alignedAggregator
uri-99 Aug 28, 2024
5458f1b
feat: read aggregator from config/permissions.aggregator
uri-99 Aug 28, 2024
52ab7a0
fix: correct aggregator address on devnet permissions
uri-99 Aug 28, 2024
8cf623c
fix: setting aggregator address on deploy
uri-99 Aug 28, 2024
7363947
fix: verifyBatchInclusion
Aug 29, 2024
e9c7dcb
feat: add old verifyBatchInclusion for backwards compatability
Aug 29, 2024
9aff329
fix (service-manager): merkle inclusion check
Aug 29, 2024
8b89ce7
fix (service-manager): merkle inclusion check
Aug 29, 2024
327dfee
chore: add comment specifying purpose
Aug 29, 2024
23b36ae
refactor: change msg.sender to alignedAggregator in respondToTask
uri-99 Aug 30, 2024
437d4f2
Merge branch '862-fix-add-old-events-for-operator-smooth-upgradeabili…
uri-99 Aug 30, 2024
9a90a9e
refactor: remove v2 from agg.go
uri-99 Sep 2, 2024
e25bd49
refactor: remove unnesecary 'v2'
uri-99 Sep 3, 2024
380b432
refactor: remove unnecesarry 'v2'
uri-99 Sep 3, 2024
364597c
refactor: remove unnecesarry 'v2'
uri-99 Sep 3, 2024
acfb16a
remore: old verifyBatchInclusion function, old moved to sender_addres…
uri-99 Sep 3, 2024
974f13e
Merge remote-tracking branch 'origin/main' into 851-add-max-limit-eth…
uri-99 Sep 3, 2024
9a96ee0
fix: update anvil state
uri-99 Sep 4, 2024
5483d5c
remove: anvil state
uri-99 Sep 4, 2024
179c466
chore: anvil state
uri-99 Sep 4, 2024
a731f2a
feat: add old verifyBatchInclusion for retro compatibility
uri-99 Sep 4, 2024
38ba53f
Merge branch 'main' into 874-refactor-rename-main-contracts-to-v2
uri-99 Sep 4, 2024
a5001b8
fix: forge test
uri-99 Sep 4, 2024
55d5ce1
Merge branch 'main' into 851-add-max-limit-eth-in-payment-from-batche…
uri-99 Sep 4, 2024
fcba55f
fix: testnet upgrade script outputs to $OUTPUT_PATH and not hardcoded…
uri-99 Sep 4, 2024
e9a4651
fix: use $DEPLOY_CONFIG_PATH in upgrade script
uri-99 Sep 4, 2024
03fea02
Merge branch '874-refactor-rename-main-contracts-to-v2' into 851-add-…
uri-99 Sep 4, 2024
467b589
feat: handleNewBatchLog on another thread (as before)
uri-99 Sep 4, 2024
cdb0927
fix: ProcessOperatorSignedTaskResponse back to ProcessOperatorSignedT…
uri-99 Sep 4, 2024
6a4af20
Merge branch '874-refactor-rename-main-contracts-to-v2' into 851-add-…
uri-99 Sep 4, 2024
0a855a9
Merge branch 'main' into 851-add-max-limit-eth-in-payment-from-batche…
uri-99 Sep 5, 2024
df5483d
refactor: remove agg address parsing from forge_output
uri-99 Sep 5, 2024
dab846c
chore: fix comment
uri-99 Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ anvil_upgrade_index_registry:
@echo "Upgrading Index Registry Contracts..."
. contracts/scripts/anvil/upgrade_index_registry.sh

anvil_upgrade_add_aggregator:
@echo "Adding Aggregator to Aligned Contracts..."
. contracts/scripts/anvil/upgrade_add_aggregator_to_service_manager.sh

lint_contracts:
@cd contracts && npm run lint:sol

Expand Down Expand Up @@ -429,6 +433,10 @@ upgrade_stake_registry: ## Upgrade Stake Registry
@echo "Upgrading Stake Registry..."
@. contracts/scripts/.env && . contracts/scripts/upgrade_stake_registry.sh

upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
@echo "Adding Aggregator to Aligned Contracts..."
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh

deploy_verify_batch_inclusion_caller:
@echo "Deploying VerifyBatchInclusionCaller contract..."
@. examples/verify/.env && . examples/verify/scripts/deploy_verify_batch_inclusion_caller.sh
Expand Down
101 changes: 87 additions & 14 deletions contracts/bindings/AlignedLayerServiceManager/binding.go

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion contracts/script/deploy/AlignedLayerDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
address public pauser;
uint256 public initalPausedStatus;
address public deployer;
address public alignedLayerAggregator;

BLSApkRegistry public apkRegistry;
AlignedLayerServiceManager public alignedLayerServiceManager;
Expand Down Expand Up @@ -95,6 +96,11 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
);
emit log_named_address("You are deploying from", deployer);

alignedLayerAggregator = stdJson.readAddress(
config_data,
".permissions.aggregator"
);

vm.startBroadcast();

// deploy proxy admin for ability to upgrade proxy contracts
Expand Down Expand Up @@ -242,7 +248,8 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
abi.encodeWithSelector(
AlignedLayerServiceManager.initialize.selector,
deployer,
deployer
deployer,
alignedLayerAggregator
)
);

Expand Down Expand Up @@ -792,6 +799,10 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
config_data,
".permissions.ejector"
);
address alignedLayerAggregator = stdJson.readAddress(
config_data,
".permissions.aggregator"
);
string memory permissions = "permissions";
vm.serializeAddress(
permissions,
Expand All @@ -804,7 +815,11 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
alignedLayerUpgrader
);
vm.serializeAddress(permissions, "alignedLayerChurner", churner);

vm.serializeAddress(permissions, "pauserRegistry", pauser);

vm.serializeAddress(permissions, "alignedLayerAggregator", alignedLayerAggregator);

string memory permissions_output = vm.serializeAddress(
permissions,
"alignedLayerEjector",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"permissions": {
"owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"aggregator": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"aggregator": "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
"upgrader": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"churner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"ejector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"deploymentBlock": 0
},
"permissions": {
"alignedLayerAggregator": "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
"alignedLayerChurner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"alignedLayerEjector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"alignedLayerOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Expand Down
118 changes: 118 additions & 0 deletions contracts/script/upgrade/AlignedLayerUpgradeAddAggregator.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.12;

import {Script} from "forge-std/Script.sol";
import "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol";
import {RegistryCoordinator} from "eigenlayer-middleware/RegistryCoordinator.sol";
import {StakeRegistry} from "eigenlayer-middleware/StakeRegistry.sol";
import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {AlignedLayerServiceManager} from "src/core/AlignedLayerServiceManager.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "forge-std/StdJson.sol";

contract AlignedLayerSetAggregator is Script {
function run(
string memory eigenLayerDeploymentFilePath,
string memory alignedLayerDeploymentFilePath,
string memory alignedConfigFilePath
) external returns (address, address) {
string memory eigen_deployment_file = vm.readFile(
eigenLayerDeploymentFilePath
);

string memory aligned_deployment_file = vm.readFile(
alignedLayerDeploymentFilePath
);

string memory aligned_config_file = vm.readFile(
alignedConfigFilePath
);

ProxyAdmin alignedLayerProxyAdmin = ProxyAdmin(
stdJson.readAddress(
aligned_deployment_file,
".addresses.alignedLayerProxyAdmin"
)
);

RegistryCoordinator registryCoordinator = RegistryCoordinator(
stdJson.readAddress(
aligned_deployment_file,
".addresses.registryCoordinator"
)
);

AVSDirectory avsDirectory = AVSDirectory(
stdJson.readAddress(
eigen_deployment_file,
".addresses.avsDirectory"
)
);

StakeRegistry stakeRegistry = StakeRegistry(
stdJson.readAddress(
aligned_deployment_file,
".addresses.stakeRegistry"
)
);

IRewardsCoordinator rewardsCoordinator = IRewardsCoordinator(
stdJson.readAddress(
eigen_deployment_file,
".addresses.rewardsCoordinator"
)
);

address alignedLayerAggregator = stdJson.readAddress(
aligned_config_file,
".permissions.aggregator"
);

vm.startBroadcast();

AlignedLayerServiceManager alignedLayerServiceManagerImplementation = new AlignedLayerServiceManager(
avsDirectory,
rewardsCoordinator,
registryCoordinator,
stakeRegistry
);

vm.stopBroadcast();
vm.startBroadcast();

// alignedLayerServiceManager is the proxy
AlignedLayerServiceManager alignedLayerServiceManager = AlignedLayerServiceManager(
payable(
stdJson.readAddress(
aligned_deployment_file,
".addresses.alignedLayerServiceManager"
)
)
);

vm.stopBroadcast();
vm.startBroadcast();

alignedLayerProxyAdmin.upgrade(
TransparentUpgradeableProxy(
payable(address(alignedLayerServiceManager))
),
address(alignedLayerServiceManagerImplementation)
);

vm.stopBroadcast();
vm.startBroadcast();

alignedLayerServiceManager.initializeAggregator(
alignedLayerAggregator
);

vm.stopBroadcast();

return (
address(alignedLayerServiceManager),
address(alignedLayerServiceManagerImplementation)
);
}
}
17 changes: 10 additions & 7 deletions contracts/scripts/anvil/deploy_aligned_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ forge_output=$(forge script script/deploy/BatcherPaymentServiceDeployer.s.sol \
batcher_payment_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}')
batcher_payment_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')

# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file
jq --arg batcher_payment_service_proxy "$batcher_payment_service_proxy" '.addresses.batcherPaymentService = $batcher_payment_service_proxy' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp.temp.json"
jq --arg batcher_payment_service_implementation "$batcher_payment_service_implementation" '.addresses.batcherPaymentServiceImplementation = $batcher_payment_service_implementation' "script/output/devnet/alignedlayer_deployment_output.temp.temp.json" > "script/output/devnet/alignedlayer_deployment_output.temp.json"
# Save ALIGNED_LAYER_AGGREGATOR_ADDRESS
ALIGNED_LAYER_AGGREGATOR_ADDRESS=$(jq -r '.address' ../config-files/anvil.aggregator.ecdsa.key.json)
jq --arg alignedLayerAggregator "0x$ALIGNED_LAYER_AGGREGATOR_ADDRESS" '.permissions += {"alignedLayerAggregator": $alignedLayerAggregator}' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp1.json"

# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file
jq --arg batcher_payment_service_proxy "$batcher_payment_service_proxy" '.addresses.batcherPaymentService = $batcher_payment_service_proxy' "script/output/devnet/alignedlayer_deployment_output.temp1.json" > "script/output/devnet/alignedlayer_deployment_output.temp2.json"
jq --arg batcher_payment_service_implementation "$batcher_payment_service_implementation" '.addresses.batcherPaymentServiceImplementation = $batcher_payment_service_implementation' "script/output/devnet/alignedlayer_deployment_output.temp2.json" > "script/output/devnet/alignedlayer_deployment_output.temp3.json"

# Replace the original file with the temporary file
mv "script/output/devnet/alignedlayer_deployment_output.temp.json" "script/output/devnet/alignedlayer_deployment_output.json"
mv "script/output/devnet/alignedlayer_deployment_output.temp3.json" "script/output/devnet/alignedlayer_deployment_output.json"

# Delete the temporary file
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.json"
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.temp.json"

rm -f "script/output/devnet/alignedlayer_deployment_output.temp1.json"
rm -f "script/output/devnet/alignedlayer_deployment_output.temp2.json"
rm -f "script/output/devnet/alignedlayer_deployment_output.temp3.json"


# Kill the anvil process to save state
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

cd "$parent_path"

cd ../../

jq 'del(.block)' scripts/anvil/state/alignedlayer-deployed-anvil-state.json > scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json

cp -f scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json scripts/anvil/state/alignedlayer-deployed-anvil-state.json

rm scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json

anvil --load-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json --dump-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json &

sleep 2

# Save the output to a variable to later extract the address of the new deployed contract
forge_output=$(forge script script/upgrade/AlignedLayerUpgradeAddAggregator.s.sol \
"./script/output/devnet/eigenlayer_deployment_output.json" \
"./script/output/devnet/alignedlayer_deployment_output.json" \
"./script/deploy/config/devnet/aligned.devnet.config.json" \
--rpc-url "http://localhost:8545" \
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
--broadcast \
--sig "run(string memory eigenLayerDeploymentFilePath, string memory alignedLayerDeploymentFilePath, string memory alignedConfigFilePath)")

echo "$forge_output"

pkill anvil

ALIGNED_LAYER_AGGREGATOR_ADDRESS=$(jq -r '.permissions.aggregator' ./script/deploy/config/devnet/aligned.devnet.config.json)
jq --arg alignedLayerAggregator "$ALIGNED_LAYER_AGGREGATOR_ADDRESS" '.permissions += {"alignedLayerAggregator": $alignedLayerAggregator}' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp.json"

mv "script/output/devnet/alignedlayer_deployment_output.temp.json" "script/output/devnet/alignedlayer_deployment_output.json"
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.json"
38 changes: 38 additions & 0 deletions contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

cd "$parent_path"

cd ../../contracts

# Save the output to a variable to later extract the address of the new deployed contract
forge_output=$(forge script script/upgrade/AlignedLayerUpgradeAddAggregator.s.sol \
$EXISTING_DEPLOYMENT_INFO_PATH \
$OUTPUT_PATH \
$DEPLOY_CONFIG_PATH \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
--sig "run(string memory eigenLayerDeploymentFilePath, string memory alignedLayerDeploymentFilePath, string memory alignedConfigFilePath)")

echo "$forge_output"

# Extract the alignedLayerServiceManagerImplementation value from the output
new_aligned_layer_service_manager_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')

# Use the extracted value to replace the alignedLayerServiceManagerImplementation value in alignedlayer_deployment_output.json and save it to a temporary file
jq --arg new_aligned_layer_service_manager_implementation "$new_aligned_layer_service_manager_implementation" '.addresses.alignedLayerServiceManagerImplementation = $new_aligned_layer_service_manager_implementation' $OUTPUT_PATH > "script/output/holesky/alignedlayer_deployment_output.temp.json"

# Write aggregator addres to deployment output file
ALIGNED_LAYER_AGGREGATOR_ADDRESS=$(jq -r '.permissions.aggregator' $DEPLOY_CONFIG_PATH)
jq --arg alignedLayerAggregator "$ALIGNED_LAYER_AGGREGATOR_ADDRESS" '.permissions += {"alignedLayerAggregator": $alignedLayerAggregator}' "script/output/holesky/alignedlayer_deployment_output.temp.json" > "script/output/holesky/alignedlayer_deployment_output.temp2.json"

# Replace the original file with the temporary file
mv "script/output/holesky/alignedlayer_deployment_output.temp2.json" $OUTPUT_PATH

# Delete the temporary file
rm -f "script/output/holesky/alignedlayer_deployment_output.temp.json"
28 changes: 25 additions & 3 deletions contracts/src/core/AlignedLayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ contract AlignedLayerServiceManager is
// @param _rewardsInitiator The address which is allowed to create AVS rewards submissions.
function initialize(
address _initialOwner,
address _rewardsInitiator
address _rewardsInitiator,
address _alignedAggregator
) public initializer {
__ServiceManagerBase_init(_initialOwner, _rewardsInitiator);
alignedAggregator = _alignedAggregator; //can't do setAggregator(aggregator) since caller is not the owner
}

// This function is to be run only on upgrade
// If a new contract is deployed, this function should be removed
// Because this new value is also added in the constructor
function initializeAggregator(
address _alignedAggregator
) public reinitializer(2) {
setAggregator(_alignedAggregator);
}

function createNewTask(
Expand Down Expand Up @@ -91,7 +102,7 @@ contract AlignedLayerServiceManager is
bytes32 batchMerkleRoot,
address senderAddress,
NonSignerStakesAndSignature memory nonSignerStakesAndSignature
) external {
) external onlyAggregator {
uint256 initialGasLeft = gasleft();

bytes32 batchIdentifierHash = keccak256(
Expand Down Expand Up @@ -161,7 +172,7 @@ contract AlignedLayerServiceManager is
senderAddress,
batchersBalances[senderAddress]
);
payable(msg.sender).transfer(txCost);
payable(alignedAggregator).transfer(txCost);
}

function verifyBatchInclusion(
Expand Down Expand Up @@ -231,6 +242,10 @@ contract AlignedLayerServiceManager is
);
}

function setAggregator(address _alignedAggregator) public onlyOwner {
alignedAggregator = _alignedAggregator;
}

function withdraw(uint256 amount) external {
if (batchersBalances[msg.sender] < amount) {
revert InsufficientFunds(
Expand Down Expand Up @@ -272,4 +287,11 @@ contract AlignedLayerServiceManager is
) public pure returns (bool) {
return keccak256(publicInput) == hash;
}

modifier onlyAggregator() {
if (msg.sender != alignedAggregator) {
revert SenderIsNotAggregator(msg.sender, alignedAggregator);
}
_;
}
}
4 changes: 3 additions & 1 deletion contracts/src/core/AlignedLayerServiceManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ abstract contract AlignedLayerServiceManagerStorage {
// Storage for batchers balances. Used by aggregator to pay for respondToTask
mapping(address => uint256) internal batchersBalances;

address public alignedAggregator;

// storage gap for upgradeability
// solhint-disable-next-line var-name-mixedcase
uint256[48] private __GAP;
uint256[47] private __GAP;
}
Loading
Loading