-
Notifications
You must be signed in to change notification settings - Fork 257
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: address issues when using wall-time #8329
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { | |
TxStatus, | ||
sleep, | ||
} from '@aztec/aztec.js'; | ||
import { EthAddress } from '@aztec/circuits.js'; | ||
import { ETHEREUM_SLOT_DURATION, EthAddress } from '@aztec/circuits.js'; | ||
import { RollupAbi } from '@aztec/l1-artifacts'; | ||
import { type BootstrapNode } from '@aztec/p2p'; | ||
import { type PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe'; | ||
|
@@ -60,7 +60,12 @@ describe('e2e_p2p_network', () => { | |
|
||
const initialValidators = [EthAddress.fromString(account.address)]; | ||
|
||
({ teardown, config, logger, deployL1ContractsValues } = await setup(0, { initialValidators, ...options })); | ||
({ teardown, config, logger, deployL1ContractsValues } = await setup(0, { | ||
initialValidators, | ||
l1BlockTime: ETHEREUM_SLOT_DURATION, | ||
salt: 420, | ||
...options, | ||
})); | ||
|
||
bootstrapNode = await createBootstrapNode(BOOT_NODE_UDP_PORT); | ||
bootstrapNodeEnr = bootstrapNode.getENR().encodeTxt(); | ||
|
@@ -77,15 +82,31 @@ describe('e2e_p2p_network', () => { | |
for (let i = 0; i < NUM_NODES; i++) { | ||
const account = privateKeyToAccount(`0x${getPrivateKeyFromIndex(i + 1)!.toString('hex')}`); | ||
await rollup.write.addValidator([account.address]); | ||
logger.debug(`Adding ${account.address} as validator`); | ||
} | ||
|
||
// Remove the initial sequencer from the set! This was the sequencer we used for perform the setup. | ||
logger.debug(`Removing ${account.address} as validator`); | ||
const txHash = await rollup.write.removeValidator([account.address]); | ||
|
||
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: txHash }); | ||
|
||
//@note Now we jump ahead to the next epoch such that the validator committee is picked | ||
// INTERVAL MINING: If we are using anvil interval mining this will NOT progress the time! | ||
// Which means that the validator set will still be empty! So anyone can propose. | ||
const slotsInEpoch = await rollup.read.EPOCH_DURATION(); | ||
const timestamp = await rollup.read.getTimestampForSlot([slotsInEpoch]); | ||
const cheatCodes = new EthCheatCodes(config.l1RpcUrl); | ||
await cheatCodes.warp(Number(timestamp)); | ||
try { | ||
await cheatCodes.warp(Number(timestamp)); | ||
} catch (err) { | ||
logger.debug('Warp failed, time already satisfied'); | ||
} | ||
|
||
// Send and await a tx to make sure we mine a block for the warp to correctly progress. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ☠️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we were to sleep for |
||
await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ | ||
hash: await deployL1ContractsValues.walletClient.sendTransaction({ to: account.address, value: 1n, account }), | ||
}); | ||
}); | ||
|
||
afterEach(() => teardown()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,7 +455,11 @@ export async function setup( | |
deployL1ContractsValues.l1ContractAddresses.rollupAddress, | ||
deployL1ContractsValues.publicClient, | ||
); | ||
watcher.start(); | ||
|
||
// If we are NOT using wall time, we should start the watcher to jump in time as needed. | ||
if (!opts.l1BlockTime) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment would be useful here |
||
watcher.start(); | ||
} | ||
|
||
const wallets = numberOfAccounts > 0 ? await createAccounts(pxe, numberOfAccounts) : []; | ||
const cheatCodes = CheatCodes.create(config.l1RpcUrl, pxe!); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this not there before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't seem so