Skip to content

Commit

Permalink
consolidations: add event
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Jul 11, 2024
1 parent 0bf8294 commit d779d52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/consolidations/main.eas
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions test/Consolidation.t.sol.in
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d779d52

Please sign in to comment.