From 0bf8294ea5558074b4d6cbd4dce3630e58dc7fce Mon Sep 17 00:00:00 2001 From: lightclient Date: Thu, 11 Jul 2024 07:49:24 -0600 Subject: [PATCH] withdrawals: add event for new withdrawal request --- src/withdrawals/main.eas | 16 ++++++++++++++++ test/Withdrawal.t.sol.in | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/withdrawals/main.eas b/src/withdrawals/main.eas index a2d3ec5..b109751 100644 --- a/src/withdrawals/main.eas +++ b/src/withdrawals/main.eas @@ -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] diff --git a/test/Withdrawal.t.sol.in b/test/Withdrawal.t.sol.in index b0d5959..a7b5e93 100644 --- a/test/Withdrawal.t.sol.in +++ b/test/Withdrawal.t.sol.in @@ -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");