From bb61af183aa3522347b92a7afde367d151a6764c Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 19 Dec 2023 13:25:02 +0100 Subject: [PATCH] feat: change the increaseBounty event to make it easier to index (#14) --- .gas-snapshot | 94 ++++++++++++------------- src/IncentivizedMessageEscrow.sol | 10 +-- src/interfaces/IMessageEscrowEvents.sol | 8 +-- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 15f13a1..0723d42 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,56 +1,56 @@ -AckReentryTest:test_reentry_on_ack_message() (gas: 531773) -CallReentryTest:test_reentry_on_call_message() (gas: 560904) +AckReentryTest:test_reentry_on_ack_message() (gas: 531789) +CallReentryTest:test_reentry_on_call_message() (gas: 560903) EscrowInformationTest:test_check_escrow_events() (gas: 100336) EscrowInformationTest:test_check_escrow_state() (gas: 97727) EscrowInformationTest:test_gas_refund(uint256) (runs: 256, μ: 149013, ~: 153891) EscrowWrongGasPaymentTest:test_fail_not_enough_gas_sent() (gas: 94273) EscrowWrongGasPaymentTest:test_place_incentive() (gas: 90175) GasSpendControlTest:test_fail_relayer_has_to_provide_enough_gas() (gas: 606085) -GasSpendControlTest:test_process_ack_gas() (gas: 621789) +GasSpendControlTest:test_process_ack_gas() (gas: 602789) GasSpendControlTest:test_process_delivery_gas() (gas: 361408) -IncreaseBountyTest:test_fail_bounty_does_not_exist() (gas: 18067) -IncreaseBountyTest:test_fail_overpay() (gas: 128710) -IncreaseBountyTest:test_fail_under_and_overpay(int256) (runs: 256, μ: 130796, ~: 130796) -IncreaseBountyTest:test_increase_escrow() (gas: 130476) -IncreaseBountyTest:test_no_increase_escrow() (gas: 123205) -MessageIdentifierTest:test_destination_identifier_impacts_message_identifier() (gas: 302723) -MessageIdentifierTest:test_non_unique_bounty(bytes) (runs: 256, μ: 105473, ~: 105367) -MessageIdentifierTest:test_unique_identifier_block_10() (gas: 97503) -MessageIdentifierTest:test_unique_identifier_block_11() (gas: 97459) -NoImplementationAddressSetTest:test_error_no_implementation_address_set() (gas: 343984) -OnRecvAckTest:test_on_ack() (gas: 231293) -OnRecvCallTest:test_on_call() (gas: 163342) -OnRecvRecoverAckTest:test_recover_ack() (gas: 248194) -OnRecvTimeoutTest:test_on_timeout() (gas: 122875) -ReturnBombTest:test_process_ack_gas() (gas: 5339423) -TargetDeltaZeroTest:test_target_delta_zero(uint16) (runs: 256, μ: 257572, ~: 257572) -TestMessages:testCannotVerifySignaturesWithInvalidSignature(bytes) (runs: 256, μ: 28353, ~: 28345) -TestMessages:testCannotVerifySignaturesWithOutOfBoundsSignature(bytes) (runs: 256, μ: 29972, ~: 29964) -TestMessages:testHashMismatchedVMIsNotVerified() (gas: 92458) +IncreaseBountyTest:test_fail_bounty_does_not_exist() (gas: 18055) +IncreaseBountyTest:test_fail_overpay() (gas: 128688) +IncreaseBountyTest:test_fail_under_and_overpay(int256) (runs: 256, μ: 130774, ~: 130774) +IncreaseBountyTest:test_increase_escrow() (gas: 130475) +IncreaseBountyTest:test_no_increase_escrow() (gas: 123204) +MessageIdentifierTest:test_destination_identifier_impacts_message_identifier() (gas: 302699) +MessageIdentifierTest:test_non_unique_bounty(bytes) (runs: 256, μ: 105449, ~: 105343) +MessageIdentifierTest:test_unique_identifier_block_10() (gas: 97491) +MessageIdentifierTest:test_unique_identifier_block_11() (gas: 97447) +NoImplementationAddressSetTest:test_error_no_implementation_address_set() (gas: 344384) +OnRecvAckTest:test_on_ack() (gas: 231324) +OnRecvCallTest:test_on_call() (gas: 163377) +OnRecvRecoverAckTest:test_recover_ack() (gas: 246226) +OnRecvTimeoutTest:test_on_timeout() (gas: 122848) +ReturnBombTest:test_process_ack_gas() (gas: 5339420) +TargetDeltaZeroTest:test_target_delta_zero(uint16) (runs: 256, μ: 257574, ~: 257574) +TestMessages:testCannotVerifySignaturesWithInvalidSignature(bytes) (runs: 256, μ: 28385, ~: 28377) +TestMessages:testCannotVerifySignaturesWithOutOfBoundsSignature(bytes) (runs: 256, μ: 30004, ~: 29996) +TestMessages:testHashMismatchedVMIsNotVerified() (gas: 92346) TestMessages:testQuorum() (gas: 22727) -TestMessages:testQuorumCanAlwaysBeReached(uint256) (runs: 256, μ: 9352, ~: 9402) -TestMessages:testVerifySignatures(bytes) (runs: 256, μ: 27360, ~: 27352) -TestMessagesC2Sigs:test_compare_wormhole_implementation_and_calldata_version() (gas: 145508) -TestMessagesC2Sigs:test_error_invalid_vm() (gas: 135944) -TestMessagesC:test_compare_wormhole_implementation_and_calldata_version() (gas: 105270) -TestMessagesC:test_error_invalid_vm() (gas: 103798) -TestRoundtrip:test_escrow_wormhole_message(bytes) (runs: 256, μ: 265095, ~: 264584) -TestSetRemoteImplementation:test_set_remote_implementation(bytes32,bytes) (runs: 256, μ: 110311, ~: 96467) -TestSetRemoteImplementation:test_set_remote_implementation_twice(bytes32,bytes) (runs: 256, μ: 93461, ~: 83021) +TestMessages:testQuorumCanAlwaysBeReached(uint256) (runs: 256, μ: 9346, ~: 9402) +TestMessages:testVerifySignatures(bytes) (runs: 256, μ: 27346, ~: 27338) +TestMessagesC2Sigs:test_compare_wormhole_implementation_and_calldata_version() (gas: 145170) +TestMessagesC2Sigs:test_error_invalid_vm() (gas: 135841) +TestMessagesC:test_compare_wormhole_implementation_and_calldata_version() (gas: 105094) +TestMessagesC:test_error_invalid_vm() (gas: 103784) +TestRoundtrip:test_escrow_wormhole_message(bytes) (runs: 256, μ: 265131, ~: 264620) +TestSetRemoteImplementation:test_set_remote_implementation(bytes32,bytes) (runs: 256, μ: 109353, ~: 95762) +TestSetRemoteImplementation:test_set_remote_implementation_twice(bytes32,bytes) (runs: 256, μ: 93609, ~: 83128) TestprocessPacketDisabled:test_process_message_disabled(bytes,bytes,address) (runs: 256, μ: 10269, ~: 10249) -TimeOverflowTest:test_larger_than_uint_time_is_fine() (gas: 253835) -TimeOverflowTest:test_overflow_in_unchecked_is_fine() (gas: 256023) -processPacketAckTest:test_ack_called_event() (gas: 219447) -processPacketAckTest:test_ack_different_recipitents() (gas: 254120) -processPacketAckTest:test_ack_less_time_than_expected(uint64,uint64) (runs: 256, μ: 257109, ~: 258979) -processPacketAckTest:test_ack_more_time_than_expected(uint64,uint64) (runs: 256, μ: 259775, ~: 259775) -processPacketAckTest:test_ack_process_message() (gas: 214657) -processPacketCallTest:test_call_process_message() (gas: 177932) -processPacketCallTest:test_call_process_message_twice() (gas: 173570) -processPacketCallTest:test_expect_caller(address) (runs: 256, μ: 229026, ~: 229026) -processPacketNoReceiveTest:test_application_does_not_implement_interface() (gas: 174912) -sendPacketPaymentTest:test_error_send_message_without_additional_cost() (gas: 110264) -sendPacketPaymentTest:test_estimate_cost() (gas: 8101) -sendPacketPaymentTest:test_process_message_with_additional_payment(bytes) (runs: 256, μ: 175786, ~: 175572) -sendPacketPaymentTest:test_process_message_without_additional_payment(bytes) (runs: 256, μ: 176346, ~: 176132) -sendPacketPaymentTest:test_send_message_with_additional_cost() (gas: 102989) \ No newline at end of file +TimeOverflowTest:test_larger_than_uint_time_is_fine() (gas: 253819) +TimeOverflowTest:test_overflow_in_unchecked_is_fine() (gas: 255989) +processPacketAckTest:test_ack_called_event() (gas: 219449) +processPacketAckTest:test_ack_different_recipitents() (gas: 254122) +processPacketAckTest:test_ack_less_time_than_expected(uint64,uint64) (runs: 256, μ: 256800, ~: 258981) +processPacketAckTest:test_ack_more_time_than_expected(uint64,uint64) (runs: 256, μ: 259777, ~: 259777) +processPacketAckTest:test_ack_process_message() (gas: 214659) +processPacketCallTest:test_call_process_message() (gas: 177934) +processPacketCallTest:test_call_process_message_twice() (gas: 173572) +processPacketCallTest:test_expect_caller(address) (runs: 256, μ: 229431, ~: 229431) +processPacketNoReceiveTest:test_application_does_not_implement_interface() (gas: 174918) +sendPacketPaymentTest:test_error_send_message_without_additional_cost() (gas: 110283) +sendPacketPaymentTest:test_estimate_cost() (gas: 8119) +sendPacketPaymentTest:test_process_message_with_additional_payment(bytes) (runs: 256, μ: 175760, ~: 175545) +sendPacketPaymentTest:test_process_message_without_additional_payment(bytes) (runs: 256, μ: 176320, ~: 176105) +sendPacketPaymentTest:test_send_message_with_additional_cost() (gas: 103008) \ No newline at end of file diff --git a/src/IncentivizedMessageEscrow.sol b/src/IncentivizedMessageEscrow.sol index 36b18fc..752ef61 100644 --- a/src/IncentivizedMessageEscrow.sol +++ b/src/IncentivizedMessageEscrow.sol @@ -122,15 +122,17 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes // Check that the provided gas is exact if (msg.value != sum) revert IncorrectValueProvided(sum, uint128(msg.value)); + uint96 newPriceOfDeliveryGas = incentive.priceOfDeliveryGas + deliveryGasPriceIncrease; + uint96 newPriceOfAckGas = incentive.priceOfAckGas + ackGasPriceIncrease; // Update storage. - incentive.priceOfDeliveryGas += deliveryGasPriceIncrease; - incentive.priceOfAckGas += ackGasPriceIncrease; + incentive.priceOfDeliveryGas = newPriceOfDeliveryGas; + incentive.priceOfAckGas = newPriceOfAckGas; // Emit the event with the increased values. emit BountyIncreased( messageIdentifier, - deliveryGasPriceIncrease, - ackGasPriceIncrease + newPriceOfDeliveryGas, + newPriceOfAckGas ); } diff --git a/src/interfaces/IMessageEscrowEvents.sol b/src/interfaces/IMessageEscrowEvents.sol index a19e0f8..8410565 100644 --- a/src/interfaces/IMessageEscrowEvents.sol +++ b/src/interfaces/IMessageEscrowEvents.sol @@ -20,12 +20,12 @@ interface IMessageEscrowEvents { ); // To save gas, this event does not emit the full incentive scheme. - // Instead, the off-chain relayer should collect all BountyIncreased for a specific event - // then add all deliveryGasPriceIncrease and ackGasPriceIncrease to their respective payments. + // Instead, the new gas prices are emitted. As a result, the relayer can collect all bountyIncreased + // and then use the maximum. (since the maxmimum is enforced in the smart contract) event BountyIncreased( bytes32 indexed messageIdentifier, - uint96 deliveryGasPriceIncrease, - uint96 ackGasPriceIncrease + uint96 newDeliveryGasPrice, + uint96 newAckGasPrice );