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: account contracts pay fee through FPC #5543

Conversation

alexghr
Copy link
Contributor

@alexghr alexghr commented Apr 3, 2024

This PR builds on top of the previous one to enable account contracts to pay for their deployment through an FPC privately

Fix #5191

Copy link
Contributor Author

alexghr commented Apr 3, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @alexghr and the rest of your teammates on Graphite Graphite

@alexghr alexghr linked an issue Apr 3, 2024 that may be closed by this pull request
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from e951798 to b17a11a Compare April 3, 2024 09:26
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from 4a30597 to 24b446d Compare April 3, 2024 09:26
@AztecBot
Copy link
Collaborator

AztecBot commented Apr 3, 2024

Benchmark results

No metrics with a significant change found.

Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Values are compared against data from master at commit e0e72008 and shown if the difference exceeds 1%.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 676 676 676
l1_rollup_calldata_gas 6,424 6,424 6,412
l1_rollup_execution_gas 585,757 585,757 585,745
l2_block_processing_time_in_ms 1,285 4,912 (+1%) 9,509 (+3%)
note_successful_decrypting_time_in_ms 222 (-7%) 510 (-5%) 1,001 (+4%)
note_trial_decrypting_time_in_ms 24.8 (-35%) 32.8 (-34%) 119 (+45%)
l2_block_building_time_in_ms 11,859 43,187 (+1%) 84,394
l2_block_rollup_simulation_time_in_ms 7,077 24,436 (+1%) 46,989
l2_block_public_tx_process_time_in_ms 4,744 (+1%) 18,627 (+1%) 37,169 (+1%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 13,855 27,572 (+4%)
note_history_successful_decrypting_time_in_ms 1,298 2,364 (-2%)
note_history_trial_decrypting_time_in_ms 68.6 (-26%) 105 (+3%)
node_database_size_in_bytes 18,608,208 34,967,632
pxe_database_size_in_bytes 29,859 59,414

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 179 (-3%) 44,377 26,164
private-kernel-ordering 161 (-3%) 50,830 39,325
base-parity 4,180 (+3%) 128 311
root-parity 1,149 (-1%) 1,244 311
base-rollup 14,360 116,608 861
root-rollup 50.4 (-1%) 4,359 725
private-kernel-inner 219 (-3%) 71,744 26,164
public-kernel-app-logic 119 (-2%) 47,695 40,661
public-kernel-tail 161 (-2%) 53,372 13,269
merge-rollup 10.0 (+3%) 2,568 861
public-kernel-teardown 116 47,695 40,661
public-kernel-setup 115 47,695 40,661

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.1 (+1%) 16.4 (+2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.6 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.588 (+1%) 0.504 (+1%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 46.1 (+1%) 72.4 230 448 872 (+1%) 1,724 N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 96.0 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.473 (+1%) 0.446 0.419 (+1%) 0.418 0.415 (+1%) 0.413 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 54.2 108 (+1%) 334 (-2%) 663 1,311 (+1%) 2,614 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.479 0.484 0.455 (-2%) 0.456 0.454 (+1%) 0.454 (+1%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 61.3
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 109
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.535

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 40,548 501,142

Transaction size based on fee payment method

Metric native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 905 1,161 1,377

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 1,697 (-1%) 1,088 (-1%) 5,493 (+2%)
Metric 1 public data writes 2 public data writes 3 public data writes 4 public data writes 5 public data writes 8 public data writes
tx_sequencer_processing_time_ms 573 (-1%) 439 (+1%) 1,058 (-1%) 525 1,729 (-1%) 584

@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from 24b446d to 0655d0f Compare April 3, 2024 12:59
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from 1bcaa26 to 51ed6a1 Compare April 3, 2024 15:56
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from 0655d0f to 0a3da42 Compare April 3, 2024 15:56
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from 51ed6a1 to f61f732 Compare April 4, 2024 08:07
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch 2 times, most recently from b639abd to 439440b Compare April 4, 2024 08:54
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from d90f2d5 to 5b2e7e4 Compare April 4, 2024 09:02
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch 2 times, most recently from 18818d5 to 137cb61 Compare April 4, 2024 09:06
@alexghr alexghr marked this pull request as ready for review April 4, 2024 09:07
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from 137cb61 to aa5132b Compare April 4, 2024 09:10
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from 856626e to 4d98bc8 Compare April 4, 2024 10:32
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from aa5132b to 37ec9d9 Compare April 4, 2024 10:32
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from 4d98bc8 to 1bbdc57 Compare April 4, 2024 12:22
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from 37ec9d9 to cff2a1a Compare April 4, 2024 12:22
@alexghr alexghr force-pushed the 04-02-feat_pay_fee_when_deploying_schnorr_account branch from 1bbdc57 to 086911b Compare April 4, 2024 13:53
@alexghr alexghr force-pushed the 04-03-feat_account_contracts_pay_fee_through_fpc branch from cff2a1a to 5fa7680 Compare April 4, 2024 13:53
// first, register the account with the PXE so that it can receive notes
await accountManager.register();

// right now, the only way to fund an undeployed account with private notes is to transfer them
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like privately_mint_private_note should have a recipient argument, right?

@alexghr
Copy link
Contributor Author

alexghr commented Apr 8, 2024

Superseded by #5601

@alexghr alexghr closed this Apr 8, 2024
@alexghr alexghr deleted the 04-03-feat_account_contracts_pay_fee_through_fpc branch April 8, 2024 09:09
alexghr added a commit that referenced this pull request Apr 10, 2024
This PR enables accounts to pay tx fees when they're deployed. To
achieve this a new deployment method was added that's used by the
`AccountManager` class to optionally register/publicly deploy and
initialize the target account contract.

Entrypoint classes now accept authwits/packed arguments alongside the
normal function calls from before. This is needed so that authwits could
be created in a parent context and then passed along as transient
authwits to the transaction (see `ExecutionRequestInit` wrapper type)

Initializing an account contract can use any of the three existing
payment methods:
- using bridged gas token from L1
- paying privately through a fee payment contract
- paying publicly through a fee payment contract

In order to use fee payment contracts this PR adds `noinitcheck` to
`spend_private_authwit` and `spend_public_authwit` because it's not
possible to read the init nullifier in the current tx (protocol
limitation). Instead the contract relies on the note containing the
public key to exist to validate that the contract has been initialized
correctly.

An extra payment flow is tested as well: a third party takes the
account's public keys and deploys and initializes the account while
paying the associated fee. This simulates the flow where a deployment
service is used that takes payment through a side chain (e.g. fiat).

Breaking change: moved `DefaultMultiCallEntrypoint` to aztec.js

This PR supersedes #5540 and #5543.

Fix #5190 #5191 #5544.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pay fees via FPC privately during account contract initialization
3 participants