feat: Adding fr compatibility to smt variables api#4884
Conversation
- Now they are compatible with Fr variables - Changed FFIterm constant initialization
| this->term = slv->s.mkInteger(tmp); | ||
| } | ||
| // this->term = slv->s.mkInteger(tmp); won't work for now since the assertion will definitely fail | ||
| std::string strvalue = slv->s.mkFiniteFieldElem(t, slv->fp, base).getFiniteFieldValue(); // TODO(alex): works for now |
There was a problem hiding this comment.
Could you add a more descriptive TODO? What do you want to do here in the future?
Also, we are switching to the TODO format, where we add an issue here (https://github.com/AztecProtocol/barretenberg/issues) with the description and then write TODO(#issue_number)
| cvc5::Term res = this->solver->s.mkConst(this->solver->s.getIntegerSort(), | ||
| "fe0f65a52067384116dc1137d798e0ca00a7ed46950e4eab7db51e08481535f2_div_" + | ||
| std::string(*this) + "_" + std::string(other)); | ||
| cvc5::Term res = Var("fe0f65a52067384116dc1137d798e0ca00a7ed46950e4eab7db51e08481535f2_div_" + std::string(*this) + "_" + std::string(other), this->solver).term; |
| } | ||
|
|
||
| void FFITerm::operator<(const bb::fr& other) const{ | ||
| cvc5::Term lt = this->solver->s.mkTerm(cvc5::Kind::INTS_MODULUS, {this->term, this->modulus}); |
There was a problem hiding this comment.
Why are you doing modular reduction in these?
| static FFITerm Const(const std::string& val, Solver* slv, uint32_t base = 16); | ||
|
|
||
| explicit FFITerm(bb::fr value, Solver* s){ | ||
| std::stringstream buf; // TODO(alex): looks bad. Would be great to create tostring() converter |
|
|
||
| using namespace smt_terms; | ||
|
|
||
| TEST(integermod, addition) |
There was a problem hiding this comment.
could you change the name of the class of tests from integermod to FFITerm?
| static FFTerm Const(const std::string& val, Solver* slv, uint32_t base = 16); | ||
|
|
||
| FFTerm(bb::fr value, Solver* s){ | ||
| std::stringstream buf; // TODO(alex): looks bad. Would be great to create tostring() converter |
|
|
||
| using namespace smt_terms; | ||
|
|
||
| TEST(finitefield, addition) |
There was a problem hiding this comment.
Could you rename from finitefield to FFTerm?
- changed division method to be more readable - changed the hash value that is used as a dvision symbolic variable name to md5(Aztec) - Removed the mod operations from inequalities methods in FFITerm - Modified `==` and `!=` methods in FFITerm so now there won't be any redundant mod operations
- FFTerm -> FFITerm
Merging to merge
Benchmark resultsNo metrics with a significant change found. Detailed resultsAll benchmarks are run on txs on the This benchmark source data is available in JSON format on S3 here. Values are compared against data from master at commit L2 block published to L1Each column represents the number of txs on an L2 block published to L1.
L2 chain processingEach column represents the number of blocks on the L2 chain where each block has 16 txs.
Circuits statsStats on running time and I/O sizes collected for every circuit run across all benchmarks.
Tree insertion statsThe duration to insert a fixed batch of leaves into each tree type.
MiscellaneousTransaction sizes based on how many contracts are deployed in the tx.
Transaction processing duration by data writes.
|
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-package: 0.26.1</summary> ## [0.26.1](aztec-package-v0.26.0...aztec-package-v0.26.1) (2024-03-06) ### Miscellaneous * **aztec-package:** Synchronize aztec-packages versions </details> <details><summary>barretenberg.js: 0.26.1</summary> ## [0.26.1](barretenberg.js-v0.26.0...barretenberg.js-v0.26.1) (2024-03-06) ### Miscellaneous * **barretenberg.js:** Synchronize aztec-packages versions </details> <details><summary>aztec-cli: 0.26.1</summary> ## [0.26.1](aztec-cli-v0.26.0...aztec-cli-v0.26.1) (2024-03-06) ### Miscellaneous * **aztec-cli:** Synchronize aztec-packages versions </details> <details><summary>aztec-packages: 0.26.1</summary> ## [0.26.1](aztec-packages-v0.26.0...aztec-packages-v0.26.1) (2024-03-06) ### Features * Adding fr compatibility to smt variables api ([#4884](#4884)) ([c085cbb](c085cbb)) * **avm-simulator:** Implement EMITUNENCRYPTEDLOG ([#4926](#4926)) ([5f3304e](5f3304e)) * Choose constructor method in Contract.deploy ([#4939](#4939)) ([e899e56](e899e56)) * Indirect mem flag deserialisation ([#4877](#4877)) ([4c6820f](4c6820f)) ### Miscellaneous * Add missing jobs to CI end ([#4963](#4963)) ([ff4110e](ff4110e)) * **avm-simulator:** Better type env getters ([#4950](#4950)) ([8f97977](8f97977)) * **avm-simulator:** Revive field comparison ([#4957](#4957)) ([ee21374](ee21374)) * **avm-simulator:** Test improvements ([#4946](#4946)) ([f74e6a1](f74e6a1)) * Fix CCI config ([#4974](#4974)) ([40178f0](40178f0)) * Remove commitment key copy out of instance ([#4893](#4893)) ([6eb6778](6eb6778)) * **vscode:** Add avm-transpiler to vscode rust-analyzer settings ([#4952](#4952)) ([db915e5](db915e5)) </details> <details><summary>barretenberg: 0.26.1</summary> ## [0.26.1](barretenberg-v0.26.0...barretenberg-v0.26.1) (2024-03-06) ### Features * Adding fr compatibility to smt variables api ([#4884](#4884)) ([c085cbb](c085cbb)) * Indirect mem flag deserialisation ([#4877](#4877)) ([4c6820f](4c6820f)) ### Miscellaneous * Remove commitment key copy out of instance ([#4893](#4893)) ([6eb6778](6eb6778)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- <details><summary>aztec-package: 0.26.1</summary> ## [0.26.1](AztecProtocol/aztec-packages@aztec-package-v0.26.0...aztec-package-v0.26.1) (2024-03-06) ### Miscellaneous * **aztec-package:** Synchronize aztec-packages versions </details> <details><summary>barretenberg.js: 0.26.1</summary> ## [0.26.1](AztecProtocol/aztec-packages@barretenberg.js-v0.26.0...barretenberg.js-v0.26.1) (2024-03-06) ### Miscellaneous * **barretenberg.js:** Synchronize aztec-packages versions </details> <details><summary>aztec-cli: 0.26.1</summary> ## [0.26.1](AztecProtocol/aztec-packages@aztec-cli-v0.26.0...aztec-cli-v0.26.1) (2024-03-06) ### Miscellaneous * **aztec-cli:** Synchronize aztec-packages versions </details> <details><summary>aztec-packages: 0.26.1</summary> ## [0.26.1](AztecProtocol/aztec-packages@aztec-packages-v0.26.0...aztec-packages-v0.26.1) (2024-03-06) ### Features * Adding fr compatibility to smt variables api ([#4884](AztecProtocol/aztec-packages#4884)) ([c085cbb](AztecProtocol/aztec-packages@c085cbb)) * **avm-simulator:** Implement EMITUNENCRYPTEDLOG ([#4926](AztecProtocol/aztec-packages#4926)) ([5f3304e](AztecProtocol/aztec-packages@5f3304e)) * Choose constructor method in Contract.deploy ([#4939](AztecProtocol/aztec-packages#4939)) ([e899e56](AztecProtocol/aztec-packages@e899e56)) * Indirect mem flag deserialisation ([#4877](AztecProtocol/aztec-packages#4877)) ([4c6820f](AztecProtocol/aztec-packages@4c6820f)) ### Miscellaneous * Add missing jobs to CI end ([#4963](AztecProtocol/aztec-packages#4963)) ([ff4110e](AztecProtocol/aztec-packages@ff4110e)) * **avm-simulator:** Better type env getters ([#4950](AztecProtocol/aztec-packages#4950)) ([8f97977](AztecProtocol/aztec-packages@8f97977)) * **avm-simulator:** Revive field comparison ([#4957](AztecProtocol/aztec-packages#4957)) ([ee21374](AztecProtocol/aztec-packages@ee21374)) * **avm-simulator:** Test improvements ([#4946](AztecProtocol/aztec-packages#4946)) ([f74e6a1](AztecProtocol/aztec-packages@f74e6a1)) * Fix CCI config ([#4974](AztecProtocol/aztec-packages#4974)) ([40178f0](AztecProtocol/aztec-packages@40178f0)) * Remove commitment key copy out of instance ([#4893](AztecProtocol/aztec-packages#4893)) ([6eb6778](AztecProtocol/aztec-packages@6eb6778)) * **vscode:** Add avm-transpiler to vscode rust-analyzer settings ([#4952](AztecProtocol/aztec-packages#4952)) ([db915e5](AztecProtocol/aztec-packages@db915e5)) </details> <details><summary>barretenberg: 0.26.1</summary> ## [0.26.1](AztecProtocol/aztec-packages@barretenberg-v0.26.0...barretenberg-v0.26.1) (2024-03-06) ### Features * Adding fr compatibility to smt variables api ([#4884](AztecProtocol/aztec-packages#4884)) ([c085cbb](AztecProtocol/aztec-packages@c085cbb)) * Indirect mem flag deserialisation ([#4877](AztecProtocol/aztec-packages#4877)) ([4c6820f](AztecProtocol/aztec-packages@4c6820f)) ### Miscellaneous * Remove commitment key copy out of instance ([#4893](AztecProtocol/aztec-packages#4893)) ([6eb6778](AztecProtocol/aztec-packages@6eb6778)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This pr updates FFTerm and FFITerm classes. Also CMakeLists are changed a little.
FFTerm
bb::frrather than strings orFFTerm::ConstFFITerm
.mod()method, that performs the operation of taking the remainder on terms. It leads to less constrained system of equations and helps the solver to work faster. However, now you have to do it manually.Since you need these classes to behave similarly, they now both have identical methods. However, most of them are just placeholders in
FFTermclass.Tests
Added simple unit tests for both
FFTermandFFItermto test that all the arithmetic operations are implemented properly.updt
Terms
changed division method to be more readable
changed the hash value that is used as a dvision symbolic variable
name to md5(Aztec)
Removed the mod operations from inequalities methods in FFITerm
Modified
==and!=methods in FFITerm so now there won't be anyredundant mod operations