From 3c7dcb931297239765e0070516068fbe69c14136 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Wed, 14 Feb 2024 11:22:34 +0100 Subject: [PATCH] Do not emit events from AbstractTBTCDepositor In all cases considered so far, the child contract emits its own events in the functions calling `_initializeDeposit` and `_finalizeDeposit`. The events emitted by child contracts have the advantage of emitting decoded extra data in the parameters. We could emit events from the parent contract as well but they cost gas and we are emitting the same data in child contract events. Also, we sometimes need to be creative in child contracts and come up with other names than DepositInitialized and DepositFinalized even though that is exactly what happens :) --- .../integrator/AbstractTBTCDepositor.sol | 22 ---------------- .../integrator/AbstractTBTCDepositor.test.ts | 26 ------------------- 2 files changed, 48 deletions(-) diff --git a/solidity/contracts/integrator/AbstractTBTCDepositor.sol b/solidity/contracts/integrator/AbstractTBTCDepositor.sol index fea46a0f8..7aeab8844 100644 --- a/solidity/contracts/integrator/AbstractTBTCDepositor.sol +++ b/solidity/contracts/integrator/AbstractTBTCDepositor.sol @@ -96,14 +96,6 @@ abstract contract AbstractTBTCDepositor { // slither-disable-next-line unused-state uint256[47] private __gap; - event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt); - - event DepositFinalized( - uint256 indexed depositKey, - uint256 tbtcAmount, - uint32 finalizedAt - ); - /// @notice Initializes the contract. MUST BE CALLED from the child /// contract initializer. // slither-disable-next-line dead-code @@ -150,12 +142,6 @@ abstract contract AbstractTBTCDepositor { reveal.fundingOutputIndex ); - emit DepositInitialized( - depositKey, - /* solhint-disable-next-line not-rely-on-time */ - uint32(block.timestamp) - ); - // The Bridge does not allow to reveal the same deposit twice and // revealed deposits stay there forever. The transaction will revert // if the deposit has already been revealed so, there is no need to do @@ -211,14 +197,6 @@ abstract contract AbstractTBTCDepositor { tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee); - // slither-disable-next-line reentrancy-events - emit DepositFinalized( - depositKey, - tbtcAmount, - /* solhint-disable-next-line not-rely-on-time */ - uint32(block.timestamp) - ); - extraData = deposit.extraData; } diff --git a/solidity/test/integrator/AbstractTBTCDepositor.test.ts b/solidity/test/integrator/AbstractTBTCDepositor.test.ts index 7f77dfe15..14b51c25f 100644 --- a/solidity/test/integrator/AbstractTBTCDepositor.test.ts +++ b/solidity/test/integrator/AbstractTBTCDepositor.test.ts @@ -131,12 +131,6 @@ describe("AbstractTBTCDepositor", () => { .withArgs(fixture.expectedDepositKey) }) - it("should emit the DepositInitialized event", async () => { - await expect(tx) - .to.emit(depositor, "DepositInitialized") - .withArgs(fixture.expectedDepositKey, await lastBlockTime()) - }) - it("should return proper values", async () => { await expect(tx) .to.emit(depositor, "InitializeDepositReturned") @@ -233,16 +227,6 @@ describe("AbstractTBTCDepositor", () => { await restoreSnapshot() }) - it("should emit the DepositFinalized event", async () => { - await expect(tx) - .to.emit(depositor, "DepositFinalized") - .withArgs( - fixture.expectedDepositKey, - expectedTbtcAmount, - await lastBlockTime() - ) - }) - it("should return proper values", async () => { await expect(tx) .to.emit(depositor, "FinalizeDepositReturned") @@ -277,16 +261,6 @@ describe("AbstractTBTCDepositor", () => { await restoreSnapshot() }) - it("should emit the DepositFinalized event", async () => { - await expect(tx) - .to.emit(depositor, "DepositFinalized") - .withArgs( - fixture.expectedDepositKey, - expectedTbtcAmount, - await lastBlockTime() - ) - }) - it("should return proper values", async () => { await expect(tx) .to.emit(depositor, "FinalizeDepositReturned")