Skip to content

Commit

Permalink
Fix: ToB-16 (update gas data) (#1451)
Browse files Browse the repository at this point in the history
* Update gas data after each sent message

* Expect call to GasOracle in sendMessage test
  • Loading branch information
ChiTimesChi authored Oct 17, 2023
1 parent 2da67ba commit 176a31d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/contracts-core/contracts/Origin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ contract Origin is StateHub, OriginEvents, InterfaceOrigin {
_insertAndSave(messageHash);
// Emit event with message information
emit Sent(messageHash, messageNonce, destination, msgPayload);
// Update the gas oracle data. We do this after the provided tips are checked so that
// the provided message is sent in the event that the gas oracle data is updated to a higher value.
InterfaceGasOracle(gasOracle).updateGasData(destination);
// TODO: consider doing this before the message is sent, while adjusting GasOracle.getMinimumTips() to
// use the pending gas oracle data.
}

/// @dev Returns the minimum tips for sending a message to the given destination with the given request and content.
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-core/test/suite/Origin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ contract OriginTest is AgentSecuredTest {
emit StateSaved(state);
vm.expectEmit();
emit Sent(leafs[i], i + 1, DOMAIN_REMOTE, messages[i]);
vm.expectCall(gasOracle, abi.encodeCall(InterfaceGasOracle.updateGasData, (DOMAIN_REMOTE)));
vm.prank(sender);
(uint32 messageNonce, bytes32 messageHash) = InterfaceOrigin(origin).sendBaseMessage(
DOMAIN_REMOTE, addressToBytes32(recipient), period, encodedRequest, content
Expand Down

0 comments on commit 176a31d

Please sign in to comment.