Skip to content

Commit 1ff7bb1

Browse files
authored
proposal: ensure that EVM errors are always consistant on underflows (#720)
1 parent 3d0e899 commit 1ff7bb1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

contracts/SpokePool.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,11 @@ abstract contract SpokePool is
520520
// It is assumed that cross-chain timestamps are normally loosely in-sync, but clock drift can occur. If the
521521
// SpokePool time stalls or lags significantly, it is still possible to make deposits by setting quoteTimestamp
522522
// within the configured buffer. The owner should pause deposits/fills if this is undesirable.
523-
// This will underflow if quoteTimestamp is more than depositQuoteTimeBuffer;
524-
// this is safe but will throw an unintuitive error.
525523

526524
// slither-disable-next-line timestamp
527525
uint256 currentTime = getCurrentTime();
528-
if (currentTime - quoteTimestamp > depositQuoteTimeBuffer) revert InvalidQuoteTimestamp();
526+
if (quoteTimestamp > currentTime || currentTime - quoteTimestamp > depositQuoteTimeBuffer)
527+
revert InvalidQuoteTimestamp();
529528

530529
// fillDeadline is relative to the destination chain.
531530
// Don't allow fillDeadline to be more than several bundles into the future.

test/evm/hardhat/SpokePool.Deposit.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ describe("SpokePool Depositor Logic", async function () {
431431
...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.sub(quoteTimeBuffer).sub(1))
432432
)
433433
).to.be.revertedWith("InvalidQuoteTimestamp");
434+
await expect(
435+
spokePool.connect(depositor)[depositV3Bytes](
436+
// quoteTimestamp in the future should also revert with InvalidQuoteTimestamp
437+
...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.add(500))
438+
)
439+
).to.be.revertedWith("InvalidQuoteTimestamp");
434440
await expect(
435441
spokePool.connect(depositor)[depositV3Bytes](
436442
// quoteTimestamp right at the buffer is OK

0 commit comments

Comments
 (0)