Skip to content

Commit

Permalink
chore: address comment + bump jest timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 9, 2024
1 parent 4d9af8a commit 4db0a1d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 30 deletions.
3 changes: 2 additions & 1 deletion docs/docs/guides/developer_guides/js_apps/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ The [`CheatCodes`](../../../reference/developer_references/sandbox_reference/che

### Set next block timestamp

Since the rollup time is dependent on what "slot" the block is included in, the way to progress time is to just progress the time of the underlying chain by a number of slots. The duration of a slot can be looked up using `SLOT_DURATION()` in the Rollup (code in Leonidas.sol).
Since the rollup time is dependent on what "slot" the block is included in, time can be progressed by progressing slots.
The duration of a slot is available by calling `SLOT_DURATION()` on the Rollup (code in Leonidas.sol).

You can then use the `warp` function on the EthCheatCodes to progress the underlying chain.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/protocol-specs/l1-smart-contracts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The contract keeps track of the current state of the L2 and progresses this stat
It also facilitates cross-chain communication (communication between the L1 inbox and outbox contracts).

:::info
The following is simplified by showcasing a case where proof and block is provided at the same time.
The following example shows a simplified case where proof and block are provided in the same transaction.
:::

```python
Expand Down
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/empty_block_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x0fd670f50fe4aa674019d7b45d3240783808b39168844a1d3ea185c7b794d35d",
"archive": "0x0a5e13310d0c5b768e262a51b698d6aa3fb7f45e5d64708d7d3bfc3e8d3fc64a",
"body": "0x00000000",
"txsEffectsHash": "0x00d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf2",
"decodedHeader": {
Expand All @@ -22,10 +22,10 @@
"blockNumber": 1,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000005",
"chainId": 31337,
"timestamp": 1723039188,
"timestamp": 1723019086,
"version": 1,
"coinbase": "0xe0ec11d0cd010cee529e7a44ba3beb6ee056c4fe",
"feeRecipient": "0x08bec9330909387da1cb2a8006753c66541463590452a9f41754c165fcce17b6",
"coinbase": "0x6e255429b3eecd76bc5123d4539de205bfc8ed04",
"feeRecipient": "0x3020f3cce26a2e314fa3cade1dc808c87e6deab7b1c90a86c383428189c062b1",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
Expand Down Expand Up @@ -56,8 +56,8 @@
}
}
},
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000066b37dd4e0ec11d0cd010cee529e7a44ba3beb6ee056c4fe08bec9330909387da1cb2a8006753c66541463590452a9f41754c165fcce17b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00cc766bc18ada368859edc32a486d1656c973f343dbd1e50c0d20c419a809ca",
"header": "0x1200a06aae1368abe36530b585bd7a4d2ba4de5037b82076412691a187d7621e00000001000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000100b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000008019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000010023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001000000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000066b32f4e6e255429b3eecd76bc5123d4539de205bfc8ed043020f3cce26a2e314fa3cade1dc808c87e6deab7b1c90a86c383428189c062b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00e3c26b1e5dbca4734754e663ec588ed9e101588a8ece487c82934f559cfedd",
"numTxs": 0
}
}
14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/empty_block_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"l2ToL1Messages": []
},
"block": {
"archive": "0x05b3a3f8074cb1ae6a999d787fa80cd8adea43965d75eaf706533da6ab99e670",
"archive": "0x2b5b19f8f6282401f17498335c43653551c57ff4b1bd98d00d1429d79c50d293",
"body": "0x00000000",
"txsEffectsHash": "0x00d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf2",
"decodedHeader": {
Expand All @@ -22,18 +22,18 @@
"blockNumber": 2,
"slotNumber": "0x0000000000000000000000000000000000000000000000000000000000000006",
"chainId": 31337,
"timestamp": 1723039200,
"timestamp": 1723019098,
"version": 1,
"coinbase": "0xe0ec11d0cd010cee529e7a44ba3beb6ee056c4fe",
"feeRecipient": "0x08bec9330909387da1cb2a8006753c66541463590452a9f41754c165fcce17b6",
"coinbase": "0x6e255429b3eecd76bc5123d4539de205bfc8ed04",
"feeRecipient": "0x3020f3cce26a2e314fa3cade1dc808c87e6deab7b1c90a86c383428189c062b1",
"gasFees": {
"feePerDaGas": 0,
"feePerL2Gas": 0
}
},
"lastArchive": {
"nextAvailableLeafIndex": 2,
"root": "0x0fd670f50fe4aa674019d7b45d3240783808b39168844a1d3ea185c7b794d35d"
"root": "0x0a5e13310d0c5b768e262a51b698d6aa3fb7f45e5d64708d7d3bfc3e8d3fc64a"
},
"stateReference": {
"l1ToL2MessageTree": {
Expand All @@ -56,8 +56,8 @@
}
}
},
"header": "0x0fd670f50fe4aa674019d7b45d3240783808b39168844a1d3ea185c7b794d35d00000002000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000066b37de0e0ec11d0cd010cee529e7a44ba3beb6ee056c4fe08bec9330909387da1cb2a8006753c66541463590452a9f41754c165fcce17b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x00ff9a8ced4cf4b9645b299e835e4a01950643e3d86c0f68963c9a03078d5da7",
"header": "0x0a5e13310d0c5b768e262a51b698d6aa3fb7f45e5d64708d7d3bfc3e8d3fc64a00000002000000000000000000000000000000000000000000000000000000000000000200d09e7feff5a1049661763ded52742f02aac5d9793b27a40d6b9c60a668bdf200089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c0007638bb56b6dda2b64b8f76841114ac3a87a1820030e2e16772c4d294879c314f44d672eb357739e42463497f9fdac46623af863eea4d947ca00a497dcdeb3000000200b59baa35b9dc267744f0ccb4e3b0255c1fc512460d91130c6bc19fb2668568d0000010019a8c197c12bb33da6314c4ef4f8f6fcb9e25250c085df8672adf67c8f1e3dbc0000018023c08a6b1297210c5e24c76b9a936250a1ce2721576c26ea797c7ec35f9e46a9000001800000000000000000000000000000000000000000000000000000000000007a690000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000066b32f5a6e255429b3eecd76bc5123d4539de205bfc8ed043020f3cce26a2e314fa3cade1dc808c87e6deab7b1c90a86c383428189c062b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"publicInputsHash": "0x009806b2a395a75e618221b9a39c98be96c7a4053616894d9bc92bbd35c92eb0",
"numTxs": 0
}
}
12 changes: 6 additions & 6 deletions l1-contracts/test/fixtures/mixed_block_1.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions l1-contracts/test/fixtures/mixed_block_2.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions l1-contracts/test/sparta/Sparta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ contract SpartaTest is DecoderBase {
modifier setup(uint256 _validatorCount) {
string memory _name = "mixed_block_1";
{
Leonidas leo = new Leonidas(address(1));
Leonidas leonidas = new Leonidas(address(1));
DecoderBase.Full memory full = load(_name);
uint256 slotNumber = full.block.decodedHeader.globalVariables.slotNumber;
uint256 initialTime =
full.block.decodedHeader.globalVariables.timestamp - slotNumber * leo.SLOT_DURATION();
full.block.decodedHeader.globalVariables.timestamp - slotNumber * leonidas.SLOT_DURATION();
vm.warp(initialTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@aztec/aztec.js';
import { DocsExampleContract, TokenBlacklistContract, type TokenContract } from '@aztec/noir-contracts.js';

import { jest } from '@jest/globals';

import {
type ISnapshotManager,
type SubsystemsContext,
Expand Down Expand Up @@ -84,6 +86,9 @@ export class BlacklistTokenContractTest {
* 2. Publicly deploy accounts, deploy token contract and a "bad account".
*/
async applyBaseSnapshots() {
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
jest.setTimeout(120_000);

await this.snapshotManager.snapshot('3_accounts', addAccounts(3, this.logger), async ({ accountKeys }, { pxe }) => {
const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1));
this.wallets = await Promise.all(accountManagers.map(a => a.getWallet()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@aztec/aztec.js';
import { DocsExampleContract, TokenContract } from '@aztec/noir-contracts.js';

import { jest } from '@jest/globals';

import {
type ISnapshotManager,
type SubsystemsContext,
Expand Down Expand Up @@ -46,6 +48,9 @@ export class TokenContractTest {
* 2. Publicly deploy accounts, deploy token contract and a "bad account".
*/
async applyBaseSnapshots() {
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
jest.setTimeout(120_000);

await this.snapshotManager.snapshot('3_accounts', addAccounts(3, this.logger), async ({ accountKeys }, { pxe }) => {
const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1));
this.wallets = await Promise.all(accountManagers.map(a => a.getWallet()));
Expand Down

0 comments on commit 4db0a1d

Please sign in to comment.