Skip to content

Commit 847a4d6

Browse files
committed
fix
1 parent 1c253fa commit 847a4d6

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"addresses": {
3+
"batcherPaymentService": "0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650",
4+
"batcherPaymentServiceImplementation": "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0"
5+
}
6+
}

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/BatcherPaymentService.sol

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ contract BatcherPaymentService is
7878

7979
// PAYABLE FUNCTIONS
8080
receive() external payable {
81-
userData[msg.sender].balance += msg.value;
82-
userData[msg.sender].unlockBlockTime = 0;
83-
emit PaymentReceived(msg.sender, msg.value);
81+
if (msg.sender != address(alignedLayerServiceManager)) { // `alignedLayerServiceManager.withdraw()` triggers `receive()` (and with only 2300 gas)
82+
userData[msg.sender].balance += msg.value;
83+
userData[msg.sender].unlockBlockTime = 0;
84+
emit PaymentReceived(msg.sender, msg.value);
85+
}
8486
}
8587

8688
// PUBLIC FUNCTIONS
@@ -178,14 +180,16 @@ contract BatcherPaymentService is
178180
emit FundsWithdrawn(msg.sender, amount);
179181
}
180182

183+
181184
function withdraw_from_service_manager(
182-
uint256 amount
183-
) public onlyOwner { // or onlyBatcher ??
184-
alignedLayerServiceManager.withdraw(amount); // reverts on InsufficientBalance
185+
uint256 amount,
186+
address withdrawAddress
187+
) public payable onlyOwner {
188+
alignedLayerServiceManager.withdraw(amount); // reverts if InsufficientBalance
185189
// money is now in this contract
186-
// now transfer to hardcoded batcher wallet
187-
payable(batcherWallet).transfer(amount);
188-
// todo test
190+
// we transfer it to the withdraw address
191+
payable(withdrawAddress).transfer(amount); // non-reentrant since .transfer() has low gas limit. Also, Owner is a multisig.
192+
// this.balance is unchanged
189193
}
190194

191195
function pause() public onlyOwner {

0 commit comments

Comments
 (0)