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: Point::fromXandSign(...) #7455

Merged
merged 11 commits into from
Jul 15, 2024
Merged

Conversation

benesjan
Copy link
Contributor

For the slot as point scheme we will need to compress point to a byte optimal form. This PR implements functionality for that.

Copy link
Contributor Author

benesjan commented Jul 12, 2024

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

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

@AztecBot
Copy link
Collaborator

AztecBot commented Jul 12, 2024

Benchmark results

Metrics with a significant change:

  • proof_construction_time_sha256_100_ms (16): 6,498 (+19%)
  • avm_simulation_time_ms (Token:mint_public): 338 (+502%)
  • avm_simulation_time_ms (Token:transfer_public): 28.1 (-34%)
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.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256_ms 5,547 (-3%) 1,513 (-2%) 702 (-1%) 738 770
proof_construction_time_sha256_30_ms 11,380 (-4%) 3,097 (-2%) 1,400 (-1%) 1,439 (+1%) 1,463
proof_construction_time_sha256_100_ms 42,458 (-3%) 11,650 (-2%) ⚠️ 6,498 (+19%) 5,643 (+4%) 5,409 (+1%)
proof_construction_time_poseidon_hash_ms 79.0 (+1%) 34.0 34.0 58.0 89.0 (+1%)
proof_construction_time_poseidon_hash_30_ms 1,467 (-3%) 410 (-1%) 200 229 (+3%) 265 (-1%)
proof_construction_time_poseidon_hash_100_ms 5,446 (-3%) 1,492 (-2%) 673 (-1%) 747 (+2%) 750 (+1%)

L2 block published to L1

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

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 708 708 708
l1_rollup_calldata_gas 6,576 6,590 6,600
l1_rollup_execution_gas 583,038 583,203 583,364
l2_block_processing_time_in_ms 760 (+1%) 1,438 (+2%) 2,705
l2_block_building_time_in_ms 13,181 (+1%) 26,019 51,027 (+1%)
l2_block_rollup_simulation_time_in_ms 13,181 (+1%) 26,019 51,027 (+1%)
l2_block_public_tx_process_time_in_ms 11,035 (+1%) 23,669 48,661 (+1%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 7,212 10,074 (+1%)
node_database_size_in_bytes 12,443,728 16,396,368 (-1%)
pxe_database_size_in_bytes 16,254 26,813

Circuits stats

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

Circuit simulation_time_in_ms witness_generation_time_in_ms input_size_in_bytes output_size_in_bytes proving_time_in_ms proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 116 (+1%) 398 (+2%) 21,732 54,085 N/A N/A N/A N/A
private-kernel-inner 229 719 (+2%) 81,199 54,264 N/A N/A N/A N/A
private-kernel-tail 1,120 (-3%) 2,601 (+6%) 61,808 61,554 N/A N/A N/A N/A
base-parity 6.50 (-1%) 811 (+2%) 160 96.0 1,408 (-3%) 12,676 3.00 131,072
root-parity 107 (-2%) 121 (+5%) 64,860 96.0 33,726 (+6%) 12,676 3.00 4,194,304
base-rollup 4,221 4,844 (-1%) 180,315 632 43,891 13,476 28.0 4,194,304
root-rollup 152 118 (+3%) 51,261 652 28,390 (-2%) 13,412 26.0 4,194,304
public-kernel-setup 195 (-2%) 2,406 (-1%) 112,536 80,310 18,835 (+3%) 118,916 3,323 2,097,152
public-kernel-app-logic 150 3,305 112,536 80,310 10,211 (-2%) 118,916 3,323 1,048,576
public-kernel-tail 896 26,475 (-4%) 409,413 10,046 67,553 24,868 384 8,388,608
private-kernel-reset-tiny 298 1,006 (+1%) 77,007 53,954 N/A N/A N/A N/A
private-kernel-tail-to-public 6,889 (+3%) 2,878 (+2%) 777,415 1,632 N/A N/A N/A N/A
public-kernel-teardown 142 (+3%) 3,377 (+2%) 112,536 80,310 19,004 (-1%) 118,916 3,323 2,097,152
merge-rollup 58.1 (+1%) N/A 33,566 632 N/A N/A N/A N/A
undefined N/A N/A N/A N/A 165,834 (-2%) N/A N/A N/A

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms
ContractClassRegisterer:register 1,312 9,344 397 (+1%) N/A N/A
ContractInstanceDeployer:deploy 1,376 9,344 25.1 N/A N/A
MultiCallEntrypoint:entrypoint 1,888 9,344 627 (+1%) N/A N/A
GasToken:deploy 1,344 9,344 570 (+1%) N/A N/A
SchnorrAccount:constructor 1,280 9,344 430 N/A N/A
SchnorrAccount:entrypoint 2,272 9,344 765 N/A N/A
Token:privately_mint_private_note 1,248 9,344 501 (+1%) N/A N/A
FPC:fee_entrypoint_public 1,312 9,344 101 (+2%) N/A N/A
Token:transfer 1,280 9,344 1,462 N/A N/A
AuthRegistry:set_authorized (avm) 19,222 N/A N/A 95,392 2,107 (-1%)
FPC:prepare_fee (avm) 26,664 N/A N/A 95,456 2,803 (-2%)
Token:transfer_public (avm) 42,914 N/A N/A 95,456 3,183 (-1%)
AuthRegistry:consume (avm) 33,100 N/A N/A 95,424 2,762 (-2%)
FPC:pay_refund (avm) 36,829 N/A N/A 95,424 10,883 (-1%)
Benchmarking:create_note 1,312 9,344 425 N/A N/A
SchnorrAccount:verify_private_authwit 1,248 9,344 42.0 (+1%) N/A N/A
Token:unshield 1,344 9,344 1,185 N/A N/A
FPC:fee_entrypoint_private 1,344 9,344 1,551 N/A N/A

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
GasToken:_increase_public_balance 100 (+1%) 13,790
GasToken:set_portal 10.6 (-10%) 3,339
Token:constructor 124 (-5%) 23,692
FPC:constructor 92.4 (-1%) 13,592
GasToken:mint_public 81.5 (-2%) 10,158
Token:mint_public ⚠️ 338 (+502%) 19,034
Token:assert_minter_and_mint 68.6 12,925
AuthRegistry:set_authorized 44.4 7,812
FPC:prepare_fee 107 (-3%) 15,062
Token:transfer_public ⚠️ 28.1 (-34%) 31,218
FPC:pay_refund 120 (-12%) 25,260
Benchmarking:increment_balance 1,344 15,267
Token:_increase_public_balance 15.1 (-4%) 15,006
FPC:pay_refund_with_shielded_rebate 179 (-2%) 26,347

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.160 (+5%)

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 256 leaves 512 leaves 1024 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.4 16.8 (+1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.600 0.515 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 48.3 (+1%) 75.8 131 (+1%) 247 466
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.493 0.466 0.450 0.447 0.437
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 59.8 112 (+1%) 183 (+1%) 356 (+1%) 688
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.504 0.501 0.484 0.481 (+1%) 0.473
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 73.1 (+1%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 133 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.520 N/A N/A N/A N/A

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 76,847 667,838

Transaction size based on fee payment method

| Metric | |
| - | |

@benesjan benesjan force-pushed the 07-12-feat_point_fromxandsign_._ branch from bdc53f8 to 861fae6 Compare July 15, 2024 10:31
@benesjan benesjan changed the base branch from master to 07-15-docs_documenting_fields July 15, 2024 10:31
Base automatically changed from 07-15-docs_documenting_fields to master July 15, 2024 10:49
@benesjan benesjan force-pushed the 07-12-feat_point_fromxandsign_._ branch from 861fae6 to edfb207 Compare July 15, 2024 10:57
@benesjan benesjan marked this pull request as ready for review July 15, 2024 14:08
@benesjan benesjan requested review from nventuro and sklppy88 July 15, 2024 14:08
Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Very nice!

yarn-project/foundation/src/fields/fields.test.ts Outdated Show resolved Hide resolved
yarn-project/foundation/src/fields/point.ts Show resolved Hide resolved
yarn-project/foundation/src/fields/point.ts Outdated Show resolved Hide resolved
@benesjan benesjan force-pushed the 07-12-feat_point_fromxandsign_._ branch from bf8149c to 46db3de Compare July 15, 2024 18:29
@benesjan benesjan enabled auto-merge (squash) July 15, 2024 18:30
throw new NotOnCurveError();
}

const yPositiveBigInt = y.toBigInt() > (Fr.MODULUS - 1n) / 2n ? Fr.MODULUS - y.toBigInt() : y.toBigInt();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const yPositiveBigInt = y.toBigInt() > (Fr.MODULUS - 1n) / 2n ? Fr.MODULUS - y.toBigInt() : y.toBigInt();
const yPositiveBigInt = y.toBigInt() <= (Fr.MODULUS - 1n) / 2n ? y.toBigInt() : Fr.MODULUS - y.toBigInt();

Nit, but this way the sign condition is the same in both places we use it

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah silly automerge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will sneak it in a PR up the stack 👍

@benesjan benesjan merged commit 225c6f6 into master Jul 15, 2024
93 checks passed
@benesjan benesjan deleted the 07-12-feat_point_fromxandsign_._ branch July 15, 2024 19:46
rahul-kothari pushed a commit that referenced this pull request Jul 16, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](#7421))
([103f099](103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

<details><summary>barretenberg.js: 0.46.7</summary>

##
[0.46.7](barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.7</summary>

##
[0.46.7](aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](#7448))
([699fb79](699fb79))
* Add unconstrained getters to sharedmutable
([#7429](#7429))
([c0ff566](c0ff566))
* Devnet updates
([#7421](#7421))
([103f099](103f099))
* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))
* Cli l1-chain-id option
([#7490](#7490))
([307bc57](307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](#7481))
([a3f6feb](a3f6feb))
* Fix msg_sender direct call exploit
([#7404](#7404))
([1dcae45](1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](#7493))
([b209fad](b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](#7336))
([0c7459b](0c7459b))
* Validate gas used
([#7459](#7459))
([6dc7598](6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](#7491))
([1e8a597](1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](71960d4))
* Turn on elaborator
([#7451](#7451))
([0599500](0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](#7455))
([225c6f6](225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](#7492))
([f1216a7](f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](#7475))
([1a6c7f2](1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](#7479))
([457a115](457a115))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Jul 17, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@aztec-package-v0.46.6...aztec-package-v0.46.7)
(2024-07-16)


### Features

* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))


### Bug Fixes

* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))


### Miscellaneous

* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

<details><summary>barretenberg.js: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg.js-v0.46.6...barretenberg.js-v0.46.7)
(2024-07-16)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@aztec-packages-v0.46.6...aztec-packages-v0.46.7)
(2024-07-16)


### Features

* Add unconstrained context to txe
([#7448](AztecProtocol/aztec-packages#7448))
([699fb79](AztecProtocol/aztec-packages@699fb79))
* Add unconstrained getters to sharedmutable
([#7429](AztecProtocol/aztec-packages#7429))
([c0ff566](AztecProtocol/aztec-packages@c0ff566))
* Devnet updates
([#7421](AztecProtocol/aztec-packages#7421))
([103f099](AztecProtocol/aztec-packages@103f099))
* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))
* Cli l1-chain-id option
([#7490](AztecProtocol/aztec-packages#7490))
([307bc57](AztecProtocol/aztec-packages@307bc57))
* Don't pass secrets to earthly-ci 'publish docs' command
([#7481](AztecProtocol/aztec-packages#7481))
([a3f6feb](AztecProtocol/aztec-packages@a3f6feb))
* Fix msg_sender direct call exploit
([#7404](AztecProtocol/aztec-packages#7404))
([1dcae45](AztecProtocol/aztec-packages@1dcae45))
* Missing NoteSelector from JSON RPC proxies
([#7493](AztecProtocol/aztec-packages#7493))
([b209fad](AztecProtocol/aztec-packages@b209fad))
* **pxe:** Best effort noir call stack generation
([#7336](AztecProtocol/aztec-packages#7336))
([0c7459b](AztecProtocol/aztec-packages@0c7459b))
* Validate gas used
([#7459](AztecProtocol/aztec-packages#7459))
([6dc7598](AztecProtocol/aztec-packages@6dc7598))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Checking compute_encrypted_note_log against TS impl
([#7491](AztecProtocol/aztec-packages#7491))
([1e8a597](AztecProtocol/aztec-packages@1e8a597))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
* Replace relative paths to noir-protocol-circuits
([71960d4](AztecProtocol/aztec-packages@71960d4))
* Turn on elaborator
([#7451](AztecProtocol/aztec-packages#7451))
([0599500](AztecProtocol/aztec-packages@0599500))
</details>

<details><summary>barretenberg: 0.46.7</summary>

##
[0.46.7](AztecProtocol/aztec-packages@barretenberg-v0.46.6...barretenberg-v0.46.7)
(2024-07-16)


### Features

* Point::fromXandSign(...)
([#7455](AztecProtocol/aztec-packages#7455))
([225c6f6](AztecProtocol/aztec-packages@225c6f6))


### Bug Fixes

* **avm:** Update generated verifier
([#7492](AztecProtocol/aztec-packages#7492))
([f1216a7](AztecProtocol/aztec-packages@f1216a7))


### Miscellaneous

* **avm:** More stats and codegen cleanup
([#7475](AztecProtocol/aztec-packages#7475))
([1a6c7f2](AztecProtocol/aztec-packages@1a6c7f2))
* Included subrelation witness degrees in the relations relevant to
zk-sumcheck
([#7479](AztecProtocol/aztec-packages#7479))
([457a115](AztecProtocol/aztec-packages@457a115))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants