Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: standarddize underflow errors in EVM #719

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ abstract contract SpokePool is

// slither-disable-next-line timestamp
uint256 currentTime = getCurrentTime();
if (currentTime - quoteTimestamp > depositQuoteTimeBuffer) revert InvalidQuoteTimestamp();
if (quoteTimestamp > currentTime || currentTime - quoteTimestamp > depositQuoteTimeBuffer) {
revert InvalidQuoteTimestamp();
}

// fillDeadline is relative to the destination chain.
// Don’t allow fillDeadline to be more than several bundles into the future.
Expand Down
13 changes: 11 additions & 2 deletions test/evm/hardhat/SpokePool.Deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {

const { AddressZero: ZERO_ADDRESS } = ethers.constants;

describe("SpokePool Depositor Logic", async function () {
describe.only("SpokePool Depositor Logic", async function () {
let spokePool: Contract, weth: Contract, erc20: Contract, unwhitelistedErc20: Contract;
let depositor: SignerWithAddress, recipient: SignerWithAddress;
let quoteTimestamp: number;
Expand Down Expand Up @@ -404,6 +404,12 @@ describe("SpokePool Depositor Logic", async function () {
...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.sub(quoteTimeBuffer).sub(1))
)
).to.be.revertedWith("InvalidQuoteTimestamp");
await expect(
spokePool.connect(depositor).depositV3(
// quoteTimestamp in the future should also revert with InvalidQuoteTimestamp
...getDepositArgsFromRelayData(relayData, destinationChainId, currentTime.add(500))
)
).to.be.revertedWith("InvalidQuoteTimestamp");
await expect(
spokePool.connect(depositor).depositV3(
// quoteTimestamp right at the buffer is OK
Expand Down Expand Up @@ -533,7 +539,10 @@ describe("SpokePool Depositor Logic", async function () {
);
});
it("deposit ID state variable incremented", async function () {
await spokePool.connect(depositor).depositV3(...depositArgs);
const tx = await spokePool.connect(depositor).depositV3(...depositArgs);

const final = await tx.wait();
console.log("final", final.gasUsed);
expect(await spokePool.numberOfDeposits()).to.equal(1);
});
it("tokens are always pulled from caller, even if different from specified depositor", async function () {
Expand Down
Loading