Skip to content

Commit

Permalink
withdrawals: add event for new withdrawal request
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Jul 11, 2024
1 parent 1ad38d1 commit 0bf8294
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/withdrawals/main.eas
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ check_input:
swap1 ;; [slot, pk2_am, ..]
sstore ;; [..]

;; Assemble log data.
caller ;; [caller, ..]
push1 96 ;; [96, caller, ..]
shl ;; [caller, ..]
push0 ;; [0, caller, ..]
mstore ;; [..]
push1 INPUT_SIZE ;; [size, ..]
push0 ;; [ost, size, ..]
push1 20 ;; [dest, ost, size, ..]
calldatacopy ;; [..]

;; Log record.
push1 RECORD_SIZE ;; [size, ..]
push0 ;; [idx, size, ..]
log0 ;; [..]

;; Increment queue tail over last and write to storage.
push1 1 ;; [1, tail_idx]
add ;; [tail_idx+1]
Expand Down
10 changes: 10 additions & 0 deletions test/Withdrawal.t.sol.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ contract WithdrawalsTest is Test {
// count is accepted and read successfully.
function testWithdrawal() public {
bytes memory data = hex"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222";

vm.expectEmit(false, false, false, true);
assembly {
let ptr := mload(0x40)
mstore(ptr, shl(96, address()))
mstore(add(ptr, 20), mload(add(data, 32)))
mstore(add(ptr, 52), mload(add(data, 64)))
log0(ptr, 76)
}

(bool ret,) = addr.call{value: 2}(data);
assertEq(ret, true);
assertStorage(count_slot, 1, "unexpected request count");
Expand Down

0 comments on commit 0bf8294

Please sign in to comment.