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

feat: Add CLI command to advance epoch #9014

Merged
merged 1 commit into from
Oct 3, 2024
Merged
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
5 changes: 5 additions & 0 deletions yarn-project/aztec.js/src/utils/cheat_codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export class CheatCodes {
);
return new CheatCodes(ethCheatCodes, aztecCheatCodes, rollupCheatCodes);
}

static createRollup(rpcUrl: string, addresses: Pick<L1ContractAddresses, 'rollupAddress'>): RollupCheatCodes {
const ethCheatCodes = new EthCheatCodes(rpcUrl);
return new RollupCheatCodes(ethCheatCodes, addresses);
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions yarn-project/cli/src/cmds/l1/advance_epoch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { CheatCodes, createPXEClient, makeFetch } from '@aztec/aztec.js';
import { type LogFn } from '@aztec/foundation/log';

export async function advanceEpoch(l1RpcUrl: string, rpcUrl: string, log: LogFn) {
const pxe = createPXEClient(rpcUrl, makeFetch([], true));
const rollupAddress = await pxe.getNodeInfo().then(i => i.l1ContractAddresses.rollupAddress);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to get the address without instantiating the entire pxe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we could accept it as an argument, or ask the node directly. I built it this way for consistency with the other commands, but we should allow these other options as you say.


const cheat = CheatCodes.createRollup(l1RpcUrl, { rollupAddress });

await cheat.advanceToNextEpoch();
log(`Warped time to advance to next epoch`);
}
14 changes: 14 additions & 0 deletions yarn-project/cli/src/cmds/l1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
);
});

program
.command('advance-epoch')
.description('Use L1 cheat codes to warp time until the next epoch.')
.requiredOption(
'--l1-rpc-url <string>',
'Url of the ethereum host. Chain identifiers localhost and testnet can be used',
ETHEREUM_HOST,
)
.addOption(pxeOption)
.action(async options => {
const { advanceEpoch } = await import('./advance_epoch.js');
await advanceEpoch(options.l1RpcUrl, options.rpcUrl, log);
});

program
.command('prover-stats', { hidden: true })
.requiredOption(
Expand Down
Loading