-
Notifications
You must be signed in to change notification settings - Fork 272
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: benchmark tx size with fee #5414
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { | ||
AccountWalletWithPrivateKey, | ||
AztecAddress, | ||
FeePaymentMethod, | ||
NativeFeePaymentMethod, | ||
PrivateFeePaymentMethod, | ||
PublicFeePaymentMethod, | ||
TxStatus, | ||
} from '@aztec/aztec.js'; | ||
import { FPCContract, GasTokenContract, TokenContract } from '@aztec/noir-contracts.js'; | ||
import { getCanonicalGasTokenAddress } from '@aztec/protocol-contracts/gas-token'; | ||
|
||
import { jest } from '@jest/globals'; | ||
|
||
import { EndToEndContext, publicDeployAccounts, setup } from '../fixtures/utils.js'; | ||
|
||
jest.setTimeout(50_000); | ||
|
||
describe('benchmarks/tx_size_fees', () => { | ||
let ctx: EndToEndContext; | ||
let aliceWallet: AccountWalletWithPrivateKey; | ||
let bobAddress: AztecAddress; | ||
let sequencerAddress: AztecAddress; | ||
let gas: GasTokenContract; | ||
let fpc: FPCContract; | ||
let token: TokenContract; | ||
|
||
// setup the environment | ||
beforeAll(async () => { | ||
ctx = await setup(3); | ||
aliceWallet = ctx.wallets[0]; | ||
bobAddress = ctx.wallets[1].getAddress(); | ||
sequencerAddress = ctx.wallets[2].getAddress(); | ||
|
||
await ctx.aztecNode.setConfig({ | ||
feeRecipient: sequencerAddress, | ||
}); | ||
|
||
await publicDeployAccounts(aliceWallet, ctx.accounts); | ||
}); | ||
|
||
// deploy the contracts | ||
beforeAll(async () => { | ||
gas = await GasTokenContract.at( | ||
getCanonicalGasTokenAddress(ctx.deployL1ContractsValues.l1ContractAddresses.gasPortalAddress), | ||
aliceWallet, | ||
); | ||
token = await TokenContract.deploy(aliceWallet, aliceWallet.getAddress(), 'test', 'test', 18).send().deployed(); | ||
fpc = await FPCContract.deploy(aliceWallet, token.address, gas.address).send().deployed(); | ||
}); | ||
|
||
// mint tokens | ||
beforeAll(async () => { | ||
await Promise.all([ | ||
gas.methods.mint_public(aliceWallet.getAddress(), 1000n).send().wait(), | ||
token.methods.privately_mint_private_note(1000n).send().wait(), | ||
token.methods.mint_public(aliceWallet.getAddress(), 1000n).send().wait(), | ||
|
||
gas.methods.mint_public(fpc.address, 1000n).send().wait(), | ||
]); | ||
}); | ||
|
||
it.each<() => Promise<FeePaymentMethod | undefined>>([ | ||
() => Promise.resolve(undefined), | ||
() => NativeFeePaymentMethod.create(aliceWallet), | ||
() => Promise.resolve(new PublicFeePaymentMethod(token.address, fpc.address, aliceWallet)), | ||
() => Promise.resolve(new PrivateFeePaymentMethod(token.address, fpc.address, aliceWallet)), | ||
])('sends a tx with a fee', async createPaymentMethod => { | ||
const paymentMethod = await createPaymentMethod(); | ||
const tx = await token.methods | ||
.transfer(aliceWallet.getAddress(), bobAddress, 1n, 0) | ||
.send({ | ||
fee: paymentMethod | ||
? { | ||
maxFee: 3n, | ||
paymentMethod, | ||
} | ||
: undefined, | ||
}) | ||
.wait(); | ||
|
||
expect(tx.status).toEqual(TxStatus.MINED); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,8 +160,17 @@ function processTxPXEProcessingStats(entry: TxPXEProcessingStats, results: Bench | |
} | ||
|
||
/** Process entries for events tx-public-part-processed, grouped by public data writes */ | ||
function processTxSequencerProcessingStats(entry: TxSequencerProcessingStats, results: BenchmarkCollectedResults) { | ||
function processTxSequencerProcessingStats( | ||
entry: TxSequencerProcessingStats, | ||
results: BenchmarkCollectedResults, | ||
fileName: string, | ||
) { | ||
append(results, 'tx_sequencer_processing_time_ms', entry.publicDataUpdateRequests, entry.duration); | ||
// only track specific txs to ensure they're doing the same thing | ||
// TODO(alexg): need a better way to identify these txs | ||
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 it's like we want to be able to set tracing on individual transactions. 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. I've created #5445 |
||
if (entry.classRegisteredCount === 0 && entry.newCommitmentCount >= 2 && fileName.includes('bench-tx-size')) { | ||
append(results, 'tx_with_fee_size_in_bytes', entry.feePaymentMethod, entry.effectsSize); | ||
} | ||
} | ||
|
||
/** Process a tree insertion event and updates results */ | ||
|
@@ -192,7 +201,7 @@ function processTreeInsertion(entry: TreeInsertionStats, results: BenchmarkColle | |
} | ||
|
||
/** Processes a parsed entry from a log-file and updates results */ | ||
function processEntry(entry: Stats, results: BenchmarkCollectedResults) { | ||
function processEntry(entry: Stats, results: BenchmarkCollectedResults, fileName: string) { | ||
switch (entry.eventName) { | ||
case 'rollup-published-to-l1': | ||
return processRollupPublished(entry, results); | ||
|
@@ -211,7 +220,7 @@ function processEntry(entry: Stats, results: BenchmarkCollectedResults) { | |
case 'tx-pxe-processing': | ||
return processTxPXEProcessingStats(entry, results); | ||
case 'tx-sequencer-processing': | ||
return processTxSequencerProcessingStats(entry, results); | ||
return processTxSequencerProcessingStats(entry, results, fileName); | ||
case 'tree-insertion': | ||
return processTreeInsertion(entry, results); | ||
default: | ||
|
@@ -240,7 +249,7 @@ export async function main() { | |
|
||
for await (const line of rl) { | ||
const entry = JSON.parse(line); | ||
processEntry(entry, collected); | ||
processEntry(entry, collected, path.basename(filePath)); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will we make this assumption on mainnet? Just wondering.
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.
It's a weak assumption. I think it's ok for benchmarking right now, but will have to be changed later. WDYT?
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.
I agree. Fine for now, but we probably want some clarity, first for ourselves, then for other sequencers on how to interpret what is going on in setup and teardown.