-
Notifications
You must be signed in to change notification settings - Fork 592
feat: get mana limit from rollup by default. #13029
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
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 |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { getInitialTestAccounts } from '@aztec/accounts/testing'; | ||
| import type { PXE, TxReceipt } from '@aztec/aztec.js'; | ||
| import { Bot, type BotConfig, getBotDefaultConfig } from '@aztec/bot'; | ||
| import type { Logger } from '@aztec/foundation/log'; | ||
| import type { SequencerClient } from '@aztec/sequencer-client'; | ||
|
|
||
| import { jest } from '@jest/globals'; | ||
| import 'jest-extended'; | ||
|
|
||
| import { setup } from './fixtures/utils.js'; | ||
|
|
||
| describe('e2e_sequencer_config', () => { | ||
| jest.setTimeout(20 * 60 * 1000); // 20 minutes | ||
|
|
||
| let teardown: () => Promise<void>; | ||
| let sequencer: SequencerClient | undefined; | ||
| let config: BotConfig; | ||
| let bot: Bot; | ||
| let pxe: PXE; | ||
| let logger: Logger; | ||
|
|
||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('bad config', () => { | ||
| it('fails to create sequencer if maxL2BlockGas is less than manaTarget', async () => { | ||
| const manaTarget = 21e18; | ||
| await expect( | ||
| setup(1, { | ||
| manaTarget: BigInt(manaTarget), | ||
| // The max is defined as 2x the manaTarget | ||
| maxL2BlockGas: manaTarget * 3, | ||
| }), | ||
| ).rejects.toThrow(/provided maxL2BlockGas of \d+ is greater than the maximum allowed by the L1 \(\d+\)/); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Sequencer config', () => { | ||
| const manaTarget = 21e18; | ||
| beforeAll(async () => { | ||
| const initialFundedAccounts = await getInitialTestAccounts(); | ||
| ({ teardown, sequencer, pxe, logger } = await setup(1, { | ||
| maxL2BlockGas: manaTarget * 2, | ||
| manaTarget: BigInt(manaTarget), | ||
| initialFundedAccounts, | ||
| })); | ||
| config = { | ||
| ...getBotDefaultConfig(), | ||
| followChain: 'PENDING', | ||
| ammTxs: false, | ||
| txMinedWaitSeconds: 12, | ||
| }; | ||
| bot = await Bot.create(config, { pxe }); | ||
| }); | ||
|
|
||
| afterAll(() => teardown()); | ||
|
|
||
| it('properly sets config', () => { | ||
| if (!sequencer) { | ||
| throw new Error('Sequencer not found'); | ||
| } | ||
| expect(sequencer.maxL2BlockGas).toBe(manaTarget * 2); | ||
| }); | ||
|
|
||
| it('respects maxL2BlockGas', async () => { | ||
| await sequencer!.updateSequencerConfig({ | ||
| maxTxsPerBlock: 1, | ||
| minTxsPerBlock: 0, | ||
| }); | ||
| sequencer!.flush(); | ||
|
|
||
| // Run a tx to get the total mana used | ||
| const receipt: TxReceipt = (await bot.run()) as TxReceipt; | ||
| expect(receipt).toBeDefined(); | ||
| expect(receipt.status).toBe('success'); | ||
| const block = await pxe.getBlock(receipt.blockNumber!); | ||
| expect(block).toBeDefined(); | ||
| const totalManaUsed = block?.header.totalManaUsed!.toBigInt(); | ||
|
Contributor
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. Not really a note to this pr, but there should be a way to get the mana used just for the tx from the receipt or so. Related to this pr, could you not just use the pxe to simulate the costs such that you don't need to wait on blocks? But guess you could not use the bot as easily then.
Collaborator
Author
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. Yeah the bot just seemed like the easiest, since I think we would need to actually send the tx regardless to show that the sequencer rejects it. |
||
|
|
||
| logger.info(`Total mana used: ${totalManaUsed}`); | ||
| expect(totalManaUsed).toBeGreaterThan(0n); | ||
| bot.updateConfig({ | ||
| l2GasLimit: Number(totalManaUsed), | ||
| daGasLimit: Number(totalManaUsed), | ||
| }); | ||
|
|
||
| // Set the maxL2BlockGas to the total mana used | ||
| await sequencer!.updateSequencerConfig({ | ||
| maxL2BlockGas: Number(totalManaUsed), | ||
| }); | ||
|
|
||
| // Flush the sequencer to make sure the new config is applied to the next tx | ||
| sequencer!.flush(); | ||
|
|
||
| // Run a tx and expect it to succeed | ||
| const receipt2: TxReceipt = (await bot.run()) as TxReceipt; | ||
| expect(receipt2).toBeDefined(); | ||
| expect(receipt2.status).toBe('success'); | ||
|
|
||
| // Set the maxL2BlockGas to the total mana used - 1 | ||
| await sequencer!.updateSequencerConfig({ | ||
| maxL2BlockGas: Number(totalManaUsed) - 1, | ||
| }); | ||
|
|
||
| // Flush the sequencer to make sure the new config is applied to the next tx | ||
| sequencer!.flush(); | ||
|
|
||
| // Try to run a tx and expect it to fail | ||
| await expect(bot.run()).rejects.toThrow(/Timeout awaiting isMined/); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ export const DefaultL1ContractsConfig = { | |
| slashingRoundSize: 10, | ||
| governanceProposerQuorum: 6, | ||
| governanceProposerRoundSize: 10, | ||
| manaTarget: BigInt(100e6), | ||
| manaTarget: BigInt(1e10), | ||
|
Contributor
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. How come so big a value? 😛
Collaborator
Author
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. Tests failed otherwise. We're apparently setting insane high gas limits on transactions and I didn't want to track them all down. |
||
| provingCostPerMana: BigInt(100), | ||
| } satisfies L1ContractsConfig; | ||
|
|
||
|
|
||
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.
Am I loosing it, or was the only change here the formatting?
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.
Just formatting (on save). The real change in this file is further down.