Skip to content

Commit 014bd4d

Browse files
fix(contracts): check address are not zero in initialization (#1094)
Co-authored-by: Urix <[email protected]>
1 parent 88f276c commit 014bd4d

File tree

6 files changed

+49
-16
lines changed

6 files changed

+49
-16
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ build_aligned_contracts:
472472

473473
show_aligned_error_codes:
474474
@echo "\nAlignedLayerServiceManager errors:"
475-
@cd contracts/src/core && forge inspect IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
475+
@cd contracts && forge inspect src/core/IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
476476
@echo "\nBatcherPaymentService errors:"
477-
@cd contracts/src/core && forge inspect BatcherPaymentService.sol:BatcherPaymentService errors
477+
@cd contracts && forge inspect src/core/BatcherPaymentService.sol:BatcherPaymentService errors
478478

479479
__BUILD__:
480480
build_binaries:

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

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

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ contract AlignedLayerServiceManager is
3636
__stakeRegistry
3737
)
3838
{
39+
if (address(__avsDirectory) == address(0)) {
40+
revert InvalidAddress("avsDirectory");
41+
}
42+
if (address(__rewardsCoordinator) == address(0)) {
43+
revert InvalidAddress("rewardsCoordinator");
44+
}
45+
if (address(__registryCoordinator) == address(0)) {
46+
revert InvalidAddress("registryCoordinator");
47+
}
48+
if (address(__stakeRegistry) == address(0)) {
49+
revert InvalidAddress("stakeRegistry");
50+
}
3951
_disableInitializers();
4052
}
4153

@@ -45,6 +57,15 @@ contract AlignedLayerServiceManager is
4557
address _rewardsInitiator,
4658
address _alignedAggregator
4759
) public initializer {
60+
if (_initialOwner == address(0)) {
61+
revert InvalidAddress("initialOwner");
62+
}
63+
if (_rewardsInitiator == address(0)) {
64+
revert InvalidAddress("rewardsInitiator");
65+
}
66+
if (_alignedAggregator == address(0)) {
67+
revert InvalidAddress("alignedAggregator");
68+
}
4869
__ServiceManagerBase_init(_initialOwner, _rewardsInitiator);
4970
alignedAggregator = _alignedAggregator; //can't do setAggregator(aggregator) since caller is not the owner
5071
}
@@ -129,7 +150,7 @@ contract AlignedLayerServiceManager is
129150
if (currentBatch.responded) {
130151
revert BatchAlreadyResponded(batchIdentifierHash);
131152
}
132-
currentBatch.responded = true;
153+
currentBatch.responded = true;
133154

134155
// Check that batcher has enough funds to fund response
135156
if (batchersBalances[senderAddress] < currentBatch.respondToTaskFeeLimit) {
@@ -181,7 +202,7 @@ contract AlignedLayerServiceManager is
181202
senderAddress,
182203
batchersBalances[senderAddress]
183204
);
184-
205+
185206
payable(alignedAggregator).transfer(txCost);
186207
}
187208

@@ -240,16 +261,17 @@ contract AlignedLayerServiceManager is
240261
bytes memory merkleProof,
241262
uint256 verificationDataBatchIndex
242263
) external view returns (bool) {
243-
return this.verifyBatchInclusion(
244-
proofCommitment,
245-
pubInputCommitment,
246-
provingSystemAuxDataCommitment,
247-
proofGeneratorAddr,
248-
batchMerkleRoot,
249-
merkleProof,
250-
verificationDataBatchIndex,
251-
address(0)
252-
);
264+
return
265+
this.verifyBatchInclusion(
266+
proofCommitment,
267+
pubInputCommitment,
268+
provingSystemAuxDataCommitment,
269+
proofGeneratorAddr,
270+
batchMerkleRoot,
271+
merkleProof,
272+
verificationDataBatchIndex,
273+
address(0)
274+
);
253275
}
254276

255277
function setAggregator(address _alignedAggregator) public onlyOwner {

contracts/src/core/BatcherPaymentService.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ contract BatcherPaymentService is
5050
uint256 required
5151
); // 955c0664
5252
error InvalidMerkleRoot(bytes32 expected, bytes32 actual); // 9f13b65c
53+
error InvalidAddress(string param); // 161eb542
5354

5455
// CONSTRUCTOR & INITIALIZER
5556
constructor() EIP712("Aligned", "1") {
@@ -70,6 +71,15 @@ contract BatcherPaymentService is
7071
address _batcherWallet,
7172
bytes32 _noncedVerificationDataTypeHash
7273
) public initializer {
74+
if (address(_alignedLayerServiceManager) == address(0)) {
75+
revert InvalidAddress("alignedServiceManager");
76+
}
77+
if (_batcherPaymentServiceOwner == address(0)) {
78+
revert InvalidAddress("batcherPaymentServiceOwner");
79+
}
80+
if (_batcherWallet == address(0)) {
81+
revert InvalidAddress("batcherWallet");
82+
}
7383
__Ownable_init(); // default is msg.sender
7484
__UUPSUpgradeable_init();
7585
_transferOwnership(_batcherPaymentServiceOwner);

contracts/src/core/IAlignedLayerServiceManager.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface IAlignedLayerServiceManager {
3434
error SenderIsNotAggregator(address sender, address alignedAggregator); // 2cbe4195
3535
error InvalidDepositAmount(uint256 amount); // 412ed242
3636
error ExceededMaxRespondFee(uint256 respondToTaskFeeLimit, uint256 txCost); // 86fc507e
37+
error InvalidAddress(string param); // 161eb542
3738

3839
function createNewTask(
3940
bytes32 batchMerkleRoot,

contracts/test/AlignedLayerServiceManager.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ contract AlignedLayerServiceManagerTest is BLSMockAVSDeployer {
4343

4444
alignedLayerServiceManager = new AlignedLayerServiceManager(
4545
avsDirectory,
46-
IRewardsCoordinator(address(rewardsCoordinator)),
46+
IRewardsCoordinator(address(rewardsCoordinatorMock)),
4747
IRegistryCoordinator(address(registryCoordinator)),
4848
IStakeRegistry(address(stakeRegistry))
4949
);

0 commit comments

Comments
 (0)