From 0bf8294ea5558074b4d6cbd4dce3630e58dc7fce Mon Sep 17 00:00:00 2001 From: lightclient Date: Thu, 11 Jul 2024 07:49:24 -0600 Subject: [PATCH 1/4] 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"); From d779d52895cb42a44be510984ac8f01b9e3a2b2c Mon Sep 17 00:00:00 2001 From: lightclient Date: Thu, 11 Jul 2024 07:52:38 -0600 Subject: [PATCH 2/4] consolidations: add event --- src/consolidations/main.eas | 17 +++++++++++++++++ test/Consolidation.t.sol.in | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/consolidations/main.eas b/src/consolidations/main.eas index 6ef34d4..b082e3a 100644 --- a/src/consolidations/main.eas +++ b/src/consolidations/main.eas @@ -141,6 +141,23 @@ check_input: swap1 ;; [slot, target[16:48], ..] 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/Consolidation.t.sol.in b/test/Consolidation.t.sol.in index 1ae1d3e..9f50d25 100644 --- a/test/Consolidation.t.sol.in +++ b/test/Consolidation.t.sol.in @@ -32,6 +32,16 @@ contract ConsolidationTest is Test { // request count is accepted and read successfully. function testConsolidation() public { bytes memory data = hex"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"; + + 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"); From d8eea580eea537daac00ed43e0dbdc8b3f25b246 Mon Sep 17 00:00:00 2001 From: lightclient Date: Thu, 18 Jul 2024 07:34:21 -0600 Subject: [PATCH 3/4] test: update to use new cheatcode --- test/Consolidation.t.sol.in | 7 ++++--- test/Withdrawal.t.sol.in | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Consolidation.t.sol.in b/test/Consolidation.t.sol.in index 9f50d25..eb251f5 100644 --- a/test/Consolidation.t.sol.in +++ b/test/Consolidation.t.sol.in @@ -33,17 +33,18 @@ contract ConsolidationTest is Test { function testConsolidation() public { bytes memory data = hex"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"; - vm.expectEmit(false, false, false, true); + vm.expectEmitAnonymous(false, 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) + mstore(add(ptr, 84), mload(add(data, 96))) + log0(ptr, 116) } (bool ret,) = addr.call{value: 2}(data); - assertEq(ret, true); + assertEq(ret, true, "call failed"); assertStorage(count_slot, 1, "unexpected request count"); assertExcess(0); diff --git a/test/Withdrawal.t.sol.in b/test/Withdrawal.t.sol.in index a7b5e93..1d65bfc 100644 --- a/test/Withdrawal.t.sol.in +++ b/test/Withdrawal.t.sol.in @@ -35,7 +35,7 @@ contract WithdrawalsTest is Test { function testWithdrawal() public { bytes memory data = hex"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222"; - vm.expectEmit(false, false, false, true); + vm.expectEmitAnonymous(false, false, false, false, true); assembly { let ptr := mload(0x40) mstore(ptr, shl(96, address())) From d338503bc30816432dc01409b986ed115459bee3 Mon Sep 17 00:00:00 2001 From: lightclient Date: Tue, 20 Aug 2024 08:36:43 -0600 Subject: [PATCH 4/4] update forge --- lib/forge-std | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/forge-std b/lib/forge-std index 155d547..bf66061 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 155d547c449afa8715f538d69454b83944117811 +Subproject commit bf6606142994b1e47e2882ce0cd477c020d77623